import { defineComponent as S, ref as m, useUser as g, useAuth as $, useClipboard as P, useShare as N, computed as k, unref as s, openBlock as o, createElementBlock as l, createVNode as p, createBaseVNode as e, toDisplayString as q, normalizeStyle as B, normalizeClass as T, createCommentVNode as c, withCtx as x, Transition as j, downloadFile as A, createBlock as V, TransitionGroup as z, renderSlot as E } from "./composables-Ci32s3jE.js";
import { AuthPass as J, QrShow as O } from "./components.js";
const Q = {
  key: 0,
  class: "flex flex-col items-stretch pb-4 border-1 border-dark-100 border-opacity-10 max-w-120 mx-auto dark-bg-dark-200"
}, D = /* @__PURE__ */ e("div", { class: "mt-4 mx-6" }, "Please make sure to safely store your cryptographic keypair to be able to use it again later", -1), F = {
  key: 0,
  class: "flex p-4 items-center bg-dark-100 bg-opacity-20 mt-2 shadow-inset"
}, G = {
  key: 0,
  class: "i-la-lock"
}, K = {
  key: 1,
  class: "i-la-unlock"
}, L = { class: "text-sm" }, R = /* @__PURE__ */ e("div", { class: "text-m" }, "Key Pair", -1), U = { class: "flex flex-wrap" }, Y = /* @__PURE__ */ e("div", { class: "i-la-share" }, null, -1), H = /* @__PURE__ */ e("div", { class: "px-1" }, "Share", -1), I = [
  Y,
  H
], M = /* @__PURE__ */ e("div", { class: "i-la-copy" }, null, -1), W = {
  key: 0,
  class: "px-2"
}, X = {
  key: 1,
  class: "px-2"
}, Z = ["href"], ee = /* @__PURE__ */ e("div", { class: "i-la-link" }, null, -1), te = /* @__PURE__ */ e("div", { class: "px-2" }, "Link", -1), se = [
  ee,
  te
], oe = /* @__PURE__ */ e("div", { class: "i-la-qrcode" }, null, -1), le = /* @__PURE__ */ e("div", { class: "px-2" }, "QR", -1), ne = [
  oe,
  le
], ae = /* @__PURE__ */ e("div", { class: "i-la-envelope-open-text" }, null, -1), ie = /* @__PURE__ */ e("div", { class: "px-2" }, "Text", -1), re = [
  ae,
  ie
], ce = /* @__PURE__ */ e("div", { class: "i-la-file-code" }, null, -1), de = /* @__PURE__ */ e("div", { class: "px-2" }, "JSON", -1), ue = [
  ce,
  de
], ve = {
  key: 1,
  class: "flex w-full justify-center mt-4"
}, _e = ["value"], he = /* @__PURE__ */ S({
  __name: "AuthCredentials",
  emits: ["close"],
  setup(pe, { emit: me }) {
    const n = m("pass"), { user: v } = g();
    function _(r) {
      n.value != r ? n.value = r : n.value = null;
    }
    const { pass: i } = $(), { text: ke, copy: f, copied: h, isSupported: y } = P(), { share: b, isSupported: C } = N(), a = m(!0), u = k(() => {
      var r;
      return a.value ? (r = i == null ? void 0 : i.safe) == null ? void 0 : r.enc : JSON.stringify(v.pair());
    }), w = k(() => a.value ? i.links.pass : i.links.pair);
    return (r, t) => s(v).is ? (o(), l("div", Q, [
      D,
      p(s(J)),
      u.value ? (o(), l("div", F, [
        e("div", {
          class: "flex flex-col w-34 items-center",
          style: B({ color: a.value ? "green" : "red" })
        }, [
          e("button", {
            class: "m-2 button text-2xl",
            onClick: t[0] || (t[0] = (d) => a.value = !a.value)
          }, [
            a.value ? (o(), l("div", G)) : (o(), l("div", K))
          ]),
          e("div", L, q(a.value ? "Encrypted" : "Plain Text"), 1),
          R
        ], 4),
        e("div", U, [
          s(C) ? (o(), l("button", {
            key: 0,
            class: T(["m-2 button items-center", { active: n.value == "pass" }]),
            onClick: t[1] || (t[1] = (d) => s(b)({ title: "Your key pair", text: u.value }))
          }, I, 2)) : c("", !0),
          s(y) ? (o(), l("button", {
            key: 1,
            class: "m-2 button items-center",
            onClick: t[2] || (t[2] = (d) => s(f)(u.value))
          }, [
            M,
            p(j, { name: "fade" }, {
              default: x(() => [
                s(h) ? (o(), l("div", W, "Copied!")) : (o(), l("div", X, "Copy"))
              ]),
              _: 1
            })
          ])) : c("", !0),
          e("a", {
            class: "m-2 button items-center",
            href: w.value,
            target: "_blank",
            onClick: t[3] || (t[3] = (d) => _("links"))
          }, se, 8, Z),
          e("button", {
            class: "m-2 button items-center",
            onClick: t[4] || (t[4] = (d) => _("qr"))
          }, ne),
          e("button", {
            class: "m-2 button items-center",
            onClick: t[5] || (t[5] = (d) => _("key"))
          }, re),
          e("button", {
            class: "m-2 button items-center",
            onClick: t[6] || (t[6] = (d) => {
              s(A)(u.value, "text/json", (s(v).name || "account") + ".json", !1), n.value = null;
            })
          }, ue)
        ])
      ])) : c("", !0),
      n.value ? (o(), l("div", ve, [
        p(z, { name: "fade" }, {
          default: x(() => [
            n.value == "key" ? (o(), l("textarea", {
              class: "p-4 text-sm flex-1 rounded-xl",
              key: "text",
              rows: "9",
              value: u.value
            }, null, 8, _e)) : c("", !0),
            n.value == "qr" ? (o(), V(s(O), {
              class: "max-w-600px",
              key: "qr",
              data: a.value ? s(i).links.pass : s(i).links.pair
            }, null, 8, ["data"])) : c("", !0)
          ]),
          _: 1
        })
      ])) : c("", !0),
      E(r.$slots, "default")
    ])) : c("", !0);
  }
});
export {
  he as default
};
//# sourceMappingURL=AuthCredentials-wDOTh_Xj.js.map
