import { c as V, p as E, h as st, f as F, i as H, r as q, e as nt, b as I, d as Y, u as Z, E as N, s as it, a as ot, F as ct } from "./AssetItem-BxjLUzNd.js";
import { a as lt } from "./index-client-C5PXnhDi.js";
import { t as G, p as D, E as l, V as Q, z as k, w as L, v, C as p, x, y as B, r as K, l as J, A as U, bJ as W, bZ as dt, b_ as O, D as M, J as R, b$ as vt, I as ut, bb as ft } from "./index-BBXAtvZr.js";
import { e as X, i as P } from "./each-D1jTQ_vC.js";
import { C as T } from "./ContentHeader-CNIXuMji.js";
import { L as pt } from "./Loader-Byv7_nwE.js";
var gt = F('<img alt="Asset" class="crtw-w-full crtw-h-full crtw-object-cover"/>'), wt = F('<p class="crtw-text-xl crtw-font-bold crtw-text-gray-900"> <span class="crtw-text-[10px] crtw-text-gray-400 crtw-align-top crtw-uppercase">usd</span></p>'), mt = F('<p class="crtw-text-xs crtw-text-gray-500 crtw-leading-tight"> </p>'), _t = F('<!> <button class="crtw-text-gray-800 crtw-absolute crtw-top-4 crtw-left-4">&larr; Back</button> <div class="crtx-flex crtw-max-w-full crtw-aspect-square crtw-bg-[#B4A7D6] crtw-rounded-sm crtw-mb-4 crtw-overflow-hidden"><!></div> <div class="crtw-space-y-1"><!> <!></div> <div class="crtw-mt-[10px]"><p class="crtw-text-xs crtw-text-gray-400 crtw-leading-tight"> </p> <p class="crtw-text-xs crtw-text-gray-400 crtw-leading-tight"> </p></div>', 1);
function $(g, s) {
  if (new.target) return V({ component: $, ...g });
  G(s, !1);
  let t = E(s, "asset", 12), u = E(s, "onClose", 12);
  var c = {
    get asset() {
      return t();
    },
    set asset(a) {
      t(a), J();
    },
    get onClose() {
      return u();
    },
    set onClose(a) {
      u(a), J();
    },
    $set: Z,
    $on: (a, o) => Y(s, a, o)
  };
  st();
  var y = _t(), w = D(y);
  {
    let a = Q(() => (v(t()), p(() => t().metadata?.name ?? ""))), o = Q(() => (v(t()), p(() => t().metadata?.description ?? "")));
    T(w, {
      get text() {
        return l(a);
      },
      get description() {
        return l(o);
      }
    });
  }
  var h = k(w, 2), n = k(h, 2), b = L(n);
  {
    var m = (a) => {
      var o = gt();
      B((j) => it(o, "src", j), [
        () => (v(N), v(t()), p(() => N(t().metadata?.image || t().metadata?.image_url)))
      ]), I(a, o);
    };
    H(b, (a) => {
      v(t()), p(() => t().metadata?.image || t().metadata?.image_url) && a(m);
    });
  }
  x(n);
  var d = k(n, 2), S = L(d);
  {
    var e = (a) => {
      var o = wt(), j = L(o);
      U(), x(o), B(() => q(j, `${v(t()), p(() => t().metadata?.price) ?? ""} `)), I(a, o);
    };
    H(S, (a) => {
      v(t()), p(() => t().metadata?.price) && a(e);
    });
  }
  var r = k(S, 2);
  X(
    r,
    1,
    () => (v(t()), p(() => Object.entries(t().metadata ?? {}).filter(([a]) => !["image", "image_url", "price", "name", "description"].includes(a)))),
    P,
    (a, o) => {
      var j = W(() => dt(l(o), 2));
      let et = () => l(j)[0], at = () => l(j)[1];
      var z = mt(), rt = L(z);
      x(z), B(() => q(rt, `${et() ?? ""}: ${at() ?? ""}`)), I(a, z);
    }
  ), x(d);
  var f = k(d, 2), _ = L(f), A = L(_);
  x(_);
  var i = k(_, 2), C = L(i);
  return x(i), x(f), B(() => {
    q(A, `Contract: ${v(t()), p(() => t().contractAddress) ?? ""}`), q(C, `Token Id: ${v(t()), p(() => t().tokenId) ?? ""}`);
  }), nt("click", h, function(...a) {
    u()?.apply(this, a);
  }), I(g, y), K(c);
}
var xt = F(`<!> <div class="crtw-w-full crtw-text-center">You don't have any assets yet.</div>`, 1), yt = F('<!> <div class="crtw-flex crtw-flex-wrap crtw-justify-center crtw-w-full crtw-gap-2"></div>', 1);
function tt(g, s) {
  if (new.target) return V({ component: tt, ...g });
  G(s, !0);
  let t = E(s, "options", 7), u = E(s, "isLoading", 7), c = O(null);
  function y() {
    M(c, null);
  }
  var w = {
    get options() {
      return t();
    },
    set options(e) {
      t(e), J();
    },
    get isLoading() {
      return u();
    },
    set isLoading(e) {
      u(e), J();
    },
    $set: Z,
    $on: (e, r) => Y(s, e, r)
  }, h = ot(), n = D(h);
  {
    var b = (e) => {
      pt(e, {});
    }, m = (e) => {
      $(e, {
        get asset() {
          return l(c);
        },
        onClose: y
      });
    }, d = (e) => {
      var r = xt(), f = D(r);
      T(f, {
        get text() {
          return t().title;
        },
        get description() {
          return t().description;
        }
      }), U(2), I(e, r);
    }, S = (e) => {
      var r = yt(), f = D(r);
      T(f, {
        get text() {
          return t().title;
        },
        get description() {
          return t().description;
        }
      });
      var _ = k(f, 2);
      X(_, 21, () => t().assets, P, (A, i) => {
        ct(A, {
          get asset() {
            return l(i);
          },
          onSelect: (C) => M(c, C, !0)
        });
      }), x(_), I(e, r);
    };
    H(n, (e) => {
      u() ? e(b) : l(c) ? e(m, 1) : t().assets?.length ? e(S, !1) : e(d, 2);
    });
  }
  return I(g, h), K(w);
}
function ht(g, s) {
  if (new.target) return V({ component: ht, ...g });
  G(s, !0);
  var t = this && this.__awaiter || function(n, b, m, d) {
    function S(e) {
      return e instanceof m ? e : new m(function(r) {
        r(e);
      });
    }
    return new (m || (m = Promise))(function(e, r) {
      function f(i) {
        try {
          A(d.next(i));
        } catch (C) {
          r(C);
        }
      }
      function _(i) {
        try {
          A(d.throw(i));
        } catch (C) {
          r(C);
        }
      }
      function A(i) {
        i.done ? e(i.value) : S(i.value).then(f, _);
      }
      A((d = d.apply(n, b || [])).next());
    });
  };
  const { getAssets: u } = R(vt), c = R(ut).walletAssets;
  let y = O(ft([])), w = O(!1);
  lt(() => t(void 0, void 0, void 0, function* () {
    if (c?.length) {
      M(w, !0);
      try {
        M(y, yield u({ assetsConfig: c, opts: { fetchMetadata: !0 } }), !0);
      } catch {
      }
      M(w, !1);
    }
  }));
  var h = {
    $set: Z,
    $on: (n, b) => Y(s, n, b)
  };
  {
    let n = W(() => ({ title: "My Assets", description: "", assets: l(y) }));
    tt(g, {
      get options() {
        return l(n);
      },
      get isLoading() {
        return l(w);
      }
    });
  }
  return K(h);
}
export {
  ht as default
};
//# sourceMappingURL=Assets-CfVfDMS2.js.map
