import { defineComponent as w, ref as m, useColor as f, useGun as x, useUser as y, watchEffect as k, SEA as B, watch as N, openBlock as r, createElementBlock as s, createVNode as z, unref as n, toDisplayString as p, createCommentVNode as v, normalizeStyle as b, renderSlot as A, theme as C, selectedUser as S } from "./composables-078fa750.js";
import { AccountAvatar as D } from "./components.js";
import { _export_sfc as E } from "./_plugin-vue_export-helper-6a641814.js";
const $ = ["title"], U = {
  key: 0,
  class: "mx-2 font-bold text-sm max-w-8ch overflow-ellipsis overflow-hidden whitespace-nowrap"
}, V = /* @__PURE__ */ w({
  __name: "AccountBadge",
  props: {
    pub: { type: String, default: "" },
    showName: { type: Boolean, default: !0 },
    size: { type: Number, default: 30 },
    selectable: Boolean,
    vertical: Boolean
  },
  setup(e) {
    const l = e, t = m(""), o = m(""), u = f("deep"), h = f("light"), c = x(), { user: i } = y();
    k(() => {
      t.value = "", o.value = "", c.user(l.pub).get("profile").get("name").on((a) => {
        t.value = a;
      }), c.user().get("petnames").get(l.pub).on(async (a) => {
        o.value = await B.decrypt(a, i.pair());
      });
    }), N(() => i.is, (a) => {
      a || (t.value = "", o.value = "");
    });
    function g() {
      l.selectable && (S.pub = l.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 ? n(C).dark ? n(u).hex(e.pub) : n(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] = (G) => g())
    }, [
      z(n(D), {
        pub: e.pub,
        size: e.size
      }, null, 8, ["pub", "size"]),
      e.showName && t.value ? (r(), s("div", U, 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: n(u).hex(e.pub) })
      }, p(t.value), 5)) : v("", !0),
      A(a.$slots, "default", {}, void 0, !0)
    ], 12, $));
  }
});
const Y = /* @__PURE__ */ E(V, [["__scopeId", "data-v-d737c201"]]);
export {
  Y as default
};
//# sourceMappingURL=AccountBadge-101c1685.js.map
