import { jsxs as n, jsx as t } from "react/jsx-runtime";
import { b as g, G as y, u as k } from "../config-BDnHptBC.js";
import { Notes as s } from "../components/Notes.js";
import { Accordion as b } from "../components/Accordion.js";
import { TinyNumber as q } from "../components/TinyNumber.js";
import { useTypedTranslation as x } from "../localisation.js";
import { formatBigToHuman as a } from "../utils/formatters/formatBigToHuman.js";
import { formatTinyNumber as N } from "../utils/formatters/formatTinyNumber.js";
import { formatUsdAmount as u } from "../utils/formatters/formatUsdAmount.js";
const v = () => {
  const { t: r } = x(), { ctx: e } = g(), { slippageTolerance: m } = y(), {
    isDirectNearTokenWithdrawal: l,
    isDirectTokenOnNearTransfer: c,
    isNativeNearDeposit: p
  } = k(), i = () => {
    let o;
    if (e.quote) {
      if (e.quote.type !== "QUOTE_DEPOSIT_ANY_AMOUNT")
        o = a(
          e.quote.amountOut,
          e.sourceToken.decimals
        );
      else if (e.quote.type === "QUOTE_DEPOSIT_ANY_AMOUNT")
        return `any amount of ${e.sourceToken.symbol}`;
    }
    return (!e.sourceTokenAmount || e.sourceTokenAmount === "0") && (o = "0"), e.sourceToken && (o = a(
      e.sourceTokenAmount,
      e.sourceToken.decimals
    )), o && e.sourceToken ? `${o} ${e.sourceToken.symbol}` : "—";
  }, T = () => e.quote ? `${e.quote.timeEstimate} sec.` : l || c || p ? "1 sec." : "—", d = e.sourceToken && e.targetToken && e.sourceToken.price / e.targetToken.price, f = !e.quote || !e.sourceToken || !e.targetToken || e.quote.type === "QUOTE_DEPOSIT_ANY_AMOUNT" || e.sourceToken.symbol === e.targetToken.symbol ? r("deposit.summary.title", "Transaction details") : e.isDepositFromExternalWallet ? /* @__PURE__ */ n("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
    `1 ${e.sourceToken.symbol} ≈ `,
    N(d ?? 0),
    " ",
    `${e.targetToken.symbol}`,
    /* @__PURE__ */ t("span", { className: "text-sw-gray-50", children: ` (${u(e.sourceToken.price)})` })
  ] }) : /* @__PURE__ */ n("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
    `${i()} ≈ `,
    " ",
    /* @__PURE__ */ t(
      q,
      {
        value: e.quote.amountOut,
        decimals: e.targetToken.decimals
      }
    ),
    " ",
    `${e.targetToken.symbol}`,
    /* @__PURE__ */ t("span", { className: "text-sw-gray-50", children: ` (${u(parseFloat(e.quote.amountOutUsd))})` })
  ] });
  return /* @__PURE__ */ t(
    b,
    {
      expandedHeightPx: 121,
      expandedByDefault: !1,
      isBadgeLoading: e.quoteStatus === "pending",
      badge: e.quote ? `~ ${e.quote.timeEstimate ?? 0} sec` : void 0,
      title: f,
      children: /* @__PURE__ */ n(s, { children: [
        /* @__PURE__ */ t(
          s.Item,
          {
            label: r("deposit.summary.youWillDeposit.label", "You will deposit"),
            value: i()
          }
        ),
        /* @__PURE__ */ t(
          s.Item,
          {
            label: r("quote.result.maxSlippage.label", "Max slippage"),
            value: `${(m / 100).toFixed(2)}%`
          }
        ),
        /* @__PURE__ */ t(
          s.Item,
          {
            isLoading: e.quoteStatus === "pending",
            label: r("quote.result.processingTime.label", "Processing time"),
            value: T()
          }
        )
      ] })
    }
  );
};
export {
  v as DepositSummary
};
//# sourceMappingURL=DepositSummary.js.map
