import { ref as B, computed as g, createElementBlock as s, openBlock as t, normalizeStyle as C, createElementVNode as y, createBlock as R, createCommentVNode as i, unref as l, toDisplayString as w, withCtx as x } from "vue";
import { currentRoom as S, useRoom as z, useColor as E, useBackground as N, useRoomLogo as P, favRoom as V } from "./composables-BAZQlC3e.js";
import { UiPanel as D, RoomPage as F } from "./components.js";
const L = ["src"], U = {
  key: 1,
  class: "font-bold ml-1"
}, j = {
  key: 0,
  class: "i-la-star"
}, q = {
  key: 1,
  class: "i-la-star-solid"
}, I = {
  __name: "RoomButton",
  props: {
    pub: { type: String, default: () => S.pub },
    panel: { type: Boolean, default: !0 }
  },
  emits: ["room", "rooms", "browse"],
  setup(r) {
    const a = r, n = B(!1), m = g(() => z(a.pub));
    E("deep");
    const $ = g(() => N({
      pub: a.pub,
      size: 200,
      attachment: "local"
    })), { logo: p } = P(a.pub);
    return (u, o) => {
      var d, b, f, v, c, k;
      return t(), s("div", {
        class: "px-0 flex gap-2",
        style: C({ ...$.value })
      }, [
        y("button", {
          class: "rounded-xl flex items-center gap-2 hover-contrast-120 flex-auto bg-dark-400 bg-op-30 backdrop-blur",
          onClick: o[0] || (o[0] = (e) => {
            n.value = !0, u.$emit("browse", "");
          })
        }, [
          l(p) ? (t(), s("img", {
            key: 0,
            class: "h-12 rounded-xl",
            src: l(p)
          }, null, 8, L)) : i("", !0),
          (f = (b = (d = m.value) == null ? void 0 : d.room) == null ? void 0 : b.profile) != null && f.name ? (t(), s("div", U, w((v = m.value) == null ? void 0 : v.room.profile.name.substring(0, 15)), 1)) : i("", !0)
        ]),
        y("button", {
          class: "button",
          onClick: o[1] || (o[1] = (e) => l(V)(r.pub))
        }, [
          (k = (c = m.value) == null ? void 0 : c.room) != null && k.isFavourite ? (t(), s("div", q)) : (t(), s("div", j))
        ]),
        r.panel ? (t(), R(l(D), {
          key: 0,
          class: "break-all",
          open: n.value,
          "close-button": !1,
          onClose: o[5] || (o[5] = (e) => n.value = !1)
        }, {
          default: x(() => [
            (t(), R(l(F), {
              key: r.pub,
              onRoom: o[2] || (o[2] = (e) => u.$emit("room", e)),
              onRooms: o[3] || (o[3] = (e) => u.$emit("rooms")),
              onBrowse: o[4] || (o[4] = (e) => {
                u.$emit("browse", e), n.value = !1;
              })
            }))
          ]),
          _: 1
        }, 8, ["open"])) : i("", !0)
      ], 4);
    };
  }
};
export {
  I as default
};
//# sourceMappingURL=RoomButton-CZtN5Sk1.js.map
