import { currentRoom as _, useUser as R, useRoom as w, computed as x, openBlock as s, createElementBlock as n, unref as o, recreateRoom as C, createCommentVNode as m, rootRoom as $, downloadFile as g, createBaseVNode as e } from "./composables-Ci32s3jE.js";
const B = { class: "flex flex-wrap items-center gap-2" }, N = /* @__PURE__ */ e("div", { class: "i-la-tools" }, null, -1), j = /* @__PURE__ */ e("div", { class: "ml-2" }, "Renew", -1), E = [
  N,
  j
], S = /* @__PURE__ */ e("div", { class: "i-la-download" }, null, -1), V = /* @__PURE__ */ e("div", { class: "ml-2" }, "Keys", -1), A = [
  S,
  V
], F = {
  key: 2,
  class: "flex flex-wrap py-4"
}, J = /* @__PURE__ */ e("div", { class: "i-ion-enter-outline" }, null, -1), K = /* @__PURE__ */ e("div", { class: "ml-2" }, "Enter", -1), L = [
  J,
  K
], O = /* @__PURE__ */ e("div", { class: "i-ion-exit-outline" }, null, -1), P = /* @__PURE__ */ e("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 s(), n("div", B, [
        (u = o(i).hosts) != null && u[o(l).pub] ? (s(), 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] ? (s(), 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),
        a.value != o($).pub ? (s(), n("div", F, [
          o(_).pub !== a.value ? (s(), n("button", {
            key: 0,
            class: "button",
            onClick: t[2] || (t[2] = (p) => o(k)(a.value))
          }, L)) : (s(), n("button", {
            key: 1,
            class: "button",
            onClick: t[3] || (t[3] = (p) => o(h)())
          }, U))
        ])) : m("", !0)
      ]);
    };
  }
};
export {
  z as default
};
//# sourceMappingURL=RoomActions-BYxxWIX3.js.map
