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