import { c as nt, p as St, h as ct, f as _, i as O, r as m, b as v, d as it, u as ot, s as X, k as $t, e as At, a as Z, t as H, n as Tt, o as zt } from "./AssetItem-ufNA-vj9.js";
import { t as lt, I as vt, K as Rt, w as n, x as c, z as f, C as r, y as w, r as ut, l as Ot, A as tt, O as et, p as Y, E as t, v as Pt, W as jt, F as Ct, L as Et } from "./index-DRgrWhNH.js";
import { e as at, i as st } from "./each-C_AuyVTL.js";
function rt(I, u, h, $) {
  if (h === "sui")
    return `https://suiscan.xyz/${$}/tx/${u}`;
  switch (String(I.chainId)) {
    case "137":
      return `https://polygonscan.com/tx/${u}`;
    case "88888":
      return `https://chiliscan.com/tx/${u}`;
    case "43114":
      return `https://subnets.avax.network/c-chain/tx/${u}`;
    case "80002":
      return `https://amoy.polygonscan.com/tx/${u}`;
    case "88882":
      return `https://testnet.chiliscan.com/tx/${u}`;
    case "43113":
      return `https://subnets-test.avax.network/c-chain/block/${u}`;
    default:
      return null;
  }
}
var Yt = _('<div class="crtw-my-4 flex justify-center"><div class="crtw-w-64 crtw-h-64 crtw-rounded-xl crtw-shadow-md crtw-bg-white flex items-center justify-center overflow-hidden"><img alt="Token" class="max-w-full max-h-full object-contain"/></div></div>'), Ft = _('<span> </span> <span class="crtw-break-all crtw-whitespace-normal crtw-break-words"> </span>', 1), Mt = _('<div class="crtw-mb-2"><a target="_blank" rel="noopener noreferrer" class="crtw-text-blue-600 crtw-underline"><div class="crtw-break-words"><!></div></a></div>'), Nt = _('<span> </span> <span class="text-gray-500 break-all whitespace-normal"> </span>', 1), Ut = _('<span> </span> <span class="crtw-break-all crtw-whitespace-normal crtw-break-words"> </span>', 1), Vt = _('<div class="crtw-mb-3"><p class="crtw-text-red-600 break-words"><!></p></div>'), qt = _('<div class="crtw-mt-6"><div class="crtw-text-lg crtw-font-semibold crtw-mb-2">Successful</div> <!> <div>Failed</div> <!> <button class="crtw-bg-black hover:crtw-bg-gray-800 crtw-text-white crtw-px-4 crtw-py-2 crtw-rounded-md crtw-mt-4">Try Again</button></div>'), Kt = _('If you are not seeing your new token, please contact <a href="mailto:support@credenza3.com" class="text-blue-600 underline">support@credenza3.com</a>.', 1), Lt = _(
  `Typically, your purchase will be processed within a few seconds. In the
      event of unusually high traffic, you may have to wait as much as a minute
      or so. If several minutes pass and you are not seeing your purchase,
      please contact <a class="crtw-underline" href="mailto:support@credenza3.com">support@credenza3.com</a>.`,
  1
), Wt = _('<div><div class="crtw-text-black-900 crtw-text-xl md:crtw-text-2xl crtw-font-semibold crtw-pt-5 crtw-mb-3.5 crtw-text-center"> </div> <div class="crtw-mb-3.5 crtw-text-sm crtw-text-justify"> </div> <!> <div class="crtw-mb-3.5 crtw-text-sm crtw-text-justify"><!></div></div>');
function pt(I, u) {
  if (new.target) return nt({ component: pt, ...I });
  lt(u, !1);
  let h = St(u, "options", 12);
  const { openUI: $ } = vt(Rt);
  let { title: N, subtitle: A, orders: g, networkType: U, tokenImage: T, isSui: V } = h();
  const dt = (g ?? []).filter((e) => e.tx), z = (g ?? []).filter((e) => !e.tx);
  function mt() {
    var e;
    if (z.some((y) => y.asset)) {
      const y = z.filter((l) => l.asset).map((l) => ({
        packageId: l.asset.packageId,
        type: l.asset.type,
        assetId: l.asset.assetId,
        amount: l.asset.amount
      }));
      if (!y.length) return;
      $(et.PAYMENT, {
        subtitle: "Retrying failed orders",
        payments: { credenzaStoredValue: { disabled: !1 } },
        assets: y
      });
      return;
    }
    const x = [], b = [];
    for (const y of z) {
      const l = y.directive;
      l.type !== "membership" ? x.push({
        contractAddress: l.resource_id,
        tokenId: (e = l.value) === null || e === void 0 ? void 0 : e.token_id,
        amount: l.value.amount
      }) : b.push({ contractAddress: l.resource_id });
    }
    !x.length && !b.length || $(et.PAYMENT, {
      subtitle: "Retrying failed orders",
      payments: { credenzaStoredValue: { disabled: !1 } },
      tokens: x,
      memberships: b
    });
  }
  var ft = {
    get options() {
      return h();
    },
    set options(e) {
      h(e), Ot();
    },
    $set: ot,
    $on: (e, p) => it(u, e, p)
  };
  ct();
  var q = Wt(), K = n(q), wt = n(K, !0);
  c(K);
  var L = f(K, 2), _t = n(L, !0);
  c(L);
  var J = f(L, 2);
  {
    var ht = (e) => {
      var p = Yt(), x = n(p), b = n(x);
      c(x), c(p), w(() => X(b, "src", T)), v(e, p);
    };
    O(J, (e) => {
      T && e(ht);
    });
  }
  var Q = f(J, 2), gt = n(Q);
  {
    var xt = (e) => {
      var p = qt(), x = f(n(p), 2);
      at(x, 1, () => dt, st, (P, i) => {
        var F = Z(), W = Y(F);
        {
          var a = (S) => {
            var R = Mt(), j = n(R), M = n(j), B = n(M);
            {
              var D = (s) => {
                var o = H();
                w(() => m(o, (t(i), r(() => t(i).metadata.name)))), v(s, o);
              }, G = (s) => {
                var o = Ft(), d = Y(o), C = n(d, !0);
                c(d);
                var k = f(d, 2), E = n(k);
                c(k), w(() => {
                  m(C, (t(i), r(() => t(i).directive.type))), m(E, `(${t(i), r(() => t(i).directive.resource_id) ?? ""})`);
                }), v(s, o);
              };
              O(B, (s) => {
                t(i), r(() => t(i).metadata?.name) ? s(D) : s(G, !1);
              });
            }
            c(M), c(j), c(R), w((s) => X(j, "href", s), [
              () => (Pt(rt), t(i), r(() => rt({ chainId: t(i).directive?.chain_id || "" }, t(i).tx, t(i).directive.chain_type, U || "")))
            ]), v(S, R);
          };
          O(W, (S) => {
            t(i), r(() => t(i).tx) && S(a);
          });
        }
        v(P, F);
      });
      var b = f(x, 2);
      let y;
      var l = f(b, 2);
      {
        var kt = (P) => {
          var i = Z(), F = Y(i);
          at(F, 1, () => z, st, (W, a) => {
            var S = Vt(), R = n(S), j = n(R);
            {
              var M = (s) => {
                var o = H();
                w(() => m(o, (t(a), r(() => t(a).metadata.name)))), v(s, o);
              }, B = (s) => {
                var o = Nt(), d = Y(o), C = n(d, !0);
                c(d);
                var k = f(d, 2), E = n(k);
                c(k), w(() => {
                  m(C, (t(a), r(() => t(a).directive.type))), m(E, `(${t(a), r(() => t(a).directive.resource_id) ?? ""})`);
                }), v(s, o);
              }, D = (s) => {
                var o = H();
                w(() => m(o, `AssetId ${t(a), r(() => t(a).asset.assetId) ?? ""} : ${t(a), r(() => t(a).error) ?? ""}`)), v(s, o);
              }, G = (s) => {
                var o = Ut(), d = Y(o), C = n(d, !0);
                c(d);
                var k = f(d, 2), E = n(k);
                c(k), w(() => {
                  m(C, (t(a), r(() => t(a).asset?.type))), m(E, `(${t(a), r(() => t(a).asset?.packageId) ?? ""}) : ${t(a), r(() => t(a).error) ?? ""}`);
                }), v(s, o);
              };
              O(j, (s) => {
                t(a), r(() => t(a).metadata?.name) ? s(M) : (t(a), r(() => t(a).directive?.type) ? s(B, 1) : (t(a), r(() => t(a).asset?.assetId) ? s(D, 2) : s(G, !1)));
              });
            }
            c(R), c(S), v(W, S);
          }), v(P, i);
        };
        O(l, (P) => {
          r(() => z.length) && P(kt);
        });
      }
      var It = f(l, 2);
      c(p), w(() => y = $t(b, 1, "crtw-text-lg crtw-font-semibold crtw-mt-6 crtw-mb-2", null, y, { hidden: !z.length })), At("click", It, mt), v(e, p);
    }, yt = (e) => {
      var p = Kt();
      tt(2), v(e, p);
    }, bt = (e) => {
      var p = Lt();
      tt(2), v(e, p);
    };
    O(gt, (e) => {
      r(() => g.length) ? e(xt) : V ? e(yt, 1) : e(bt, !1);
    });
  }
  return c(Q), c(q), w(() => {
    m(wt, N), m(_t, A);
  }), v(I, q), ut(ft);
}
function Bt(I, u) {
  if (new.target) return nt({ component: Bt, ...I });
  lt(u, !1);
  const h = () => zt(Et, "$pageOptsStore", $), [$, N] = Tt();
  let A = vt(jt);
  var g = {
    $set: ot,
    $on: (T, V) => it(u, T, V)
  };
  ct();
  {
    let T = Ct(() => ({
      title: A.content?.paymentResult?.title || "Success!",
      subtitle: h()?.subtitle || A.content?.paymentResult?.subtitle || "Your payment was successful!",
      description: A.content?.paymentResult?.description,
      orders: h()?.orders || [],
      networkType: A.networkType,
      tokenImage: h()?.tokenImage || "",
      isSui: !0
    }));
    pt(I, {
      get options() {
        return t(T);
      }
    });
  }
  var U = ut(g);
  return N(), U;
}
export {
  Bt as default
};
//# sourceMappingURL=PaymentResult-KtRS8Ycg.js.map
