import { computed as D, reactive as y, ref as $, createElementBlock as a, openBlock as s, Fragment as m, createElementVNode as l, createVNode as g, createCommentVNode as k, renderList as b, createBlock as S, unref as r, normalizeStyle as B, withCtx as w, withDirectives as v, toDisplayString as E, vModelSelect as q, vModelText as x } from "vue";
import { useUser as I, useGun as L, genUUID as R } from "./composables-BAZQlC3e.js";
import { GiftWallet as C, UiLayer as j } from "./components.js";
import { currencies as G } from "./currencies-BZwbRKMz.js";
const M = { class: "flex flex-col gap-2" }, N = { class: "flex flex-col gap-2" }, O = ["onClick"], Y = { class: "p-2" }, T = {
  class: "grid grid-cols-2 gap-2",
  style: { "grid-template-columns": "1fr 6fr" }
}, z = ["value"], Q = {
  __name: "GiftWallets",
  props: {
    pub: {
      type: String,
      default: "OKrDaDeD8VeA27d673RqlodSnebnaDq6Ci23Ys_ABWE.q8fI2lkxO46R8TMjeUeAf7I0yBS5mdH_Cb9_285Wkqk"
    },
    activeWallet: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["wallet", "clear"],
  setup(u, { emit: F }) {
    const f = u, { user: i } = I(), c = L();
    D(() => i.pub == f.pub);
    const p = y({});
    c.user(f.pub).get("wallets").map().on((o, e) => {
      if (!o) {
        delete p[e];
        return;
      }
      let t = { ...o };
      delete t._, p[e] = t;
    });
    const d = $(), n = y({
      currency: "",
      account: "",
      url: ""
    });
    function W() {
      const o = R();
      c.user().get("wallets").get(o).put(n), d.value = !1;
    }
    function U(o) {
      console.log(o), c.user().get("wallets").get(o).put(null);
    }
    return (o, e) => (s(), a(m, null, [
      l("div", M, [
        l("div", N, [
          (s(!0), a(m, null, b(p, (t, V) => (s(), S(r(C), {
            class: "cursor-pointer",
            key: t,
            wallet: t,
            style: B({ backgroundColor: t == u.activeWallet ? "#3333" : "" }),
            onClick: (A) => t != u.activeWallet ? o.$emit("wallet", t) : o.$emit("clear")
          }, {
            default: w(() => [
              r(i).pub == u.pub ? (s(), a("div", {
                key: 0,
                class: "i-la-trash-alt opacity-40 hover-opacity-90",
                onClick: (A) => U(V)
              }, null, 8, O)) : k("", !0)
            ]),
            _: 2
          }, 1032, ["wallet", "style", "onClick"]))), 128))
        ]),
        r(i).pub == u.pub ? (s(), a("button", {
          key: 0,
          class: "button",
          onClick: e[0] || (e[0] = (t) => d.value = !0)
        }, "Add a wallet")) : k("", !0)
      ]),
      g(r(j), {
        open: d.value,
        onClose: e[5] || (e[5] = (t) => d.value = !1)
      }, {
        default: w(() => [
          l("div", Y, [
            e[10] || (e[10] = l("div", { class: "text-xl" }, "Add a new wallet", -1)),
            l("div", T, [
              e[6] || (e[6] = l("div", { class: "p-2" }, "Currency", -1)),
              v(l("select", {
                class: "rounded-xl dark-bg-dark-100 p-2",
                "onUpdate:modelValue": e[1] || (e[1] = (t) => n.currency = t),
                placeholder: "Your account currency"
              }, [
                (s(!0), a(m, null, b(r(G), (t) => (s(), a("option", {
                  key: t,
                  value: t
                }, E(t), 9, z))), 128))
              ], 512), [
                [q, n.currency]
              ]),
              e[7] || (e[7] = l("div", { class: "p-2" }, "Account", -1)),
              v(l("textarea", {
                class: "shadow-lg rounded-xl p-2",
                "onUpdate:modelValue": e[2] || (e[2] = (t) => n.account = t),
                type: "text",
                placeholder: "Your account details"
              }, null, 512), [
                [x, n.account]
              ]),
              e[8] || (e[8] = l("div", { class: "p-2" }, "URL", -1)),
              v(l("input", {
                class: "shadow-lg rounded-xl p-2",
                "onUpdate:modelValue": e[3] || (e[3] = (t) => n.url = t),
                type: "text",
                placeholder: "Link to the payment gateway"
              }, null, 512), [
                [x, n.url]
              ]),
              e[9] || (e[9] = l("div", { class: "p-2" }, "PREVIEW", -1)),
              g(r(C), { wallet: n }, null, 8, ["wallet"]),
              l("button", {
                class: "button col-span-2",
                onClick: e[4] || (e[4] = (t) => W())
              }, "Add the wallet")
            ])
          ])
        ]),
        _: 1
      }, 8, ["open"])
    ], 64));
  }
};
export {
  Q as default
};
//# sourceMappingURL=GiftWallets-B4l_CAo0.js.map
