import { defineComponent as g, ref as m, useColor as f, useGun as x, useUser as y, watchEffect as k, watch as B, openBlock as r, createElementBlock as s, createVNode as N, unref as l, toDisplayString as p, createCommentVNode as v, normalizeStyle as b, renderSlot as z, theme as C, selectedUser as A } from "./composables-Ci32s3jE.js";
import { AccountAvatar as S } from "./components.js";
import { _export_sfc as D } from "./_plugin-vue_export-helper-DueaC3du.js";
const $ = ["title"], E = {
  key: 0,
  class: "mx-2 font-bold text-sm max-w-8ch overflow-ellipsis overflow-hidden whitespace-nowrap"
}, U = /* @__PURE__ */ g({
  __name: "AccountBadge",
  props: {
    pub: { type: String, default: "" },
    showName: { type: Boolean, default: !0 },
    size: { type: Number, default: 30 },
    selectable: Boolean,
    vertical: Boolean
  },
  setup(e) {
    const n = e, t = m(""), o = m(""), u = f("deep"), h = f("light"), i = x(), { user: c } = y();
    k(() => {
      t.value = "", o.value = "", i.user(n.pub).get("profile").get("name").on((a) => {
        t.value = a;
      }), i.user().get("petnames").get(n.pub).on(async (a) => {
        o.value = await c.decrypt(a);
      });
    }), B(() => c.is, (a) => {
      a || (t.value = "", o.value = "");
    });
    function w() {
      n.selectable && (A.pub = n.pub);
    }
    return (a, d) => (r(), s("div", {
      class: "frame p-2px flex items-center rounded-full bg-light-900 dark-bg-dark-200 cursor-pointer shadow transition duration-400 ease-in",
      style: b({ backgroundColor: e.pub ? l(C).dark ? l(u).hex(e.pub) : l(h).hex(e.pub) : "transparent", flexDirection: e.vertical ? "column" : "row" }),
      title: e.showName ? o.value ? o.value : e.pub : t.value,
      onClick: d[0] || (d[0] = (V) => w())
    }, [
      N(l(S), {
        pub: e.pub,
        size: e.size
      }, null, 8, ["pub", "size"]),
      e.showName && t.value ? (r(), s("div", E, p(t.value), 1)) : v("", !0),
      t.value && !e.showName ? (r(), s("div", {
        key: 1,
        class: "tip mx-2 font-bold text-sm max-w-8ch overflow-ellipsis overflow-hidden whitespace-nowrap absolute opacity-0 hover-opacity-100 transition-all duration-300 ease-in text-center transform translate-y-2 p-1 rounded-lg",
        style: b({ transform: `translateY(${-e.size - 5}px) translateX(-50%)`, backgroundColor: l(u).hex(e.pub) })
      }, p(t.value), 5)) : v("", !0),
      z(a.$slots, "default", {}, void 0, !0)
    ], 12, $));
  }
}), X = /* @__PURE__ */ D(U, [["__scopeId", "data-v-b7b96d95"]]);
export {
  X as default
};
//# sourceMappingURL=AccountBadge-DEeZNpBT.js.map
