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