import { defineComponent as g, ref as m, watchEffect as x, watch as y, createElementBlock as r, openBlock as u, normalizeStyle as f, unref as l, createVNode as k, createCommentVNode as p, renderSlot as B, toDisplayString as v } from "vue";
import { useColor as b, useGun as N, useUser as z, theme as C, selectedUser as A } from "./composables-BAZQlC3e.js";
import { AccountAvatar as S } from "./components.js";
import { _export_sfc as D } from "./_plugin-vue_export-helper-DueaC3du.js";
const $ = ["title"], E = /* @__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(""), s = b("deep"), h = b("light"), i = N(), { user: c } = z();
    x(() => {
      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);
      });
    }), y(() => c.is, (a) => {
      a || (t.value = "", o.value = "");
    });
    function w() {
      n.selectable && (A.pub = n.pub);
    }
    return (a, d) => (u(), r("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: f({ backgroundColor: e.pub ? l(C).dark ? l(s).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] = (U) => w())
    }, [
      k(l(S), {
        pub: e.pub,
        size: e.size
      }, null, 8, ["pub", "size"]),
      e.showName && t.value ? (u(), r("div", {
        class: "mx-2 font-bold text-sm max-w-8ch overflow-ellipsis overflow-hidden whitespace-nowrap",
        key: e.pub
      }, v(t.value), 1)) : p("", !0),
      t.value && !e.showName ? (u(), r("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: f({ transform: `translateY(${-e.size - 5}px) translateX(-50%)`, backgroundColor: l(s).hex(e.pub) })
      }, v(t.value), 5)) : p("", !0),
      B(a.$slots, "default", {}, void 0, !0)
    ], 12, $));
  }
}), X = /* @__PURE__ */ D(E, [["__scopeId", "data-v-78111ed2"]]);
export {
  X as default
};
//# sourceMappingURL=AccountBadge-sxjzZ_8r.js.map
