import { currentRoom as _, useUser as R, useRoom as w, computed as x, openBlock as e, createElementBlock as n, unref as o, recreateRoom as C, createCommentVNode as m, rootRoom as $, downloadFile as g, createBaseVNode as s } from "./composables-61bf5e40.js";
const B = { class: "flex flex-wrap items-center gap-2" }, N = /* @__PURE__ */ s("div", { class: "i-la-tools" }, null, -1), j = /* @__PURE__ */ s("div", { class: "ml-2" }, "Renew", -1), E = [
  N,
  j
], S = /* @__PURE__ */ s("div", { class: "i-la-download" }, null, -1), V = /* @__PURE__ */ s("div", { class: "ml-2" }, "Keys", -1), A = [
  S,
  V
], F = {
  key: 2,
  class: "flex flex-wrap py-4"
}, J = /* @__PURE__ */ s("div", { class: "i-ion-enter-outline" }, null, -1), K = /* @__PURE__ */ s("div", { class: "ml-2" }, "Enter", -1), L = [
  J,
  K
], O = /* @__PURE__ */ s("div", { class: "i-ion-exit-outline" }, null, -1), P = /* @__PURE__ */ s("div", { class: "ml-2" }, "Leave", -1), U = [
  O,
  P
], z = {
  __name: "RoomActions",
  props: {
    pub: { type: String, default: _.pub }
  },
  setup(f) {
    const d = f, { user: l } = R(), { room: i, leaveRoom: h, enterRoom: k } = w(d.pub), a = x(() => d.pub ? d.pub : _.pub);
    async function y(b) {
      var u;
      const t = await l.decrypt(b);
      g(JSON.stringify(t), "application/json", `room-${(u = i.profile) == null ? void 0 : u.name}.json`);
    }
    return (b, t) => {
      var u, v;
      return e(), n("div", B, [
        (u = o(i).hosts) != null && u[o(l).pub] ? (e(), n("button", {
          key: 0,
          class: "button",
          onClick: t[0] || (t[0] = (p) => {
            var c, r;
            return o(C)((r = (c = o(i).hosts) == null ? void 0 : c[o(l).pub]) == null ? void 0 : r.enc);
          })
        }, E)) : m("", !0),
        (v = o(i).hosts) != null && v[o(l).pub] ? (e(), n("button", {
          key: 1,
          class: "button",
          onClick: t[1] || (t[1] = (p) => {
            var c, r;
            return y((r = (c = o(i).hosts) == null ? void 0 : c[o(l).pub]) == null ? void 0 : r.enc);
          })
        }, A)) : m("", !0),
        o(a) != o($).pub ? (e(), n("div", F, [
          o(_).pub !== o(a) ? (e(), n("button", {
            key: 0,
            class: "button",
            onClick: t[2] || (t[2] = (p) => o(k)(o(a)))
          }, L)) : (e(), n("button", {
            key: 1,
            class: "button",
            onClick: t[3] || (t[3] = (p) => o(h)())
          }, U))
        ])) : m("", !0)
      ]);
    };
  }
};
export {
  z as default
};
//# sourceMappingURL=RoomActions-e78f5e87.js.map
