import { useCssVars as I, unref as n, useColor as V, computed as x, ref as c, onMounted as P, reactive as j, openBlock as b, createElementBlock as _, withDirectives as k, vModelText as y, createCommentVNode as z, createBaseVNode as l, withKeys as B, withModifiers as D, normalizeClass as C, createVNode as i, withCtx as g, addPost as M, pushScopeId as N, popScopeId as T } from "./composables-108ad332.js";
import { FormPicture as w, FormLink as K, FormYoutube as L, UiLayer as U, FormText as h } from "./components.js";
import { _export_sfc as A } from "./_plugin-vue_export-helper-6a641814.js";
const u = (d) => (N("data-v-c53fdb98"), d = d(), T(), d), E = {
  class: "w-full flex flex-col p-2 shadow-xl m-1 rounded-2xl",
  action: "javascript:void(0);"
}, H = { class: "flex flex-wrap z-100" }, R = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "i-la-info-circle" }, null, -1)), Y = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "i-mdi-text-long" }, null, -1)), q = [
  Y
], G = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "flex-1" }, null, -1)), J = { class: "flex justify-center flex-1" }, O = ["disabled"], Q = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "i-la-check" }, null, -1)), W = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "font-bold ml-2" }, "Submit", -1)), X = [
  Q,
  W
], Z = /* @__PURE__ */ u(() => /* @__PURE__ */ l("div", { class: "i-la-trash-alt" }, null, -1)), tt = [
  Z
], et = {
  __name: "PostForm",
  props: {
    tag: {
      type: String,
      default: " "
    }
  },
  emits: ["close"],
  setup(d, { emit: $ }) {
    const r = d;
    I((a) => ({
      "569a1dcc": n(S)
    }));
    const F = V("deep"), S = x(() => F.hex(r.tag)), f = c();
    P(() => {
      var a;
      (a = f.value) == null || a.focus();
    });
    const o = c({}), s = j({
      form: !1,
      youtube: !1,
      text: !1
    }), v = x(() => o.value.title || o.value.statement || o.value.text || o.value.cover);
    function p() {
      if (!v.value)
        return;
      const a = {
        ...o.value
      };
      M(r.tag, a), m();
    }
    function m() {
      s.form = !1, o.value = {}, $("close");
    }
    return (a, t) => (b(), _("form", E, [
      s.title ? k((b(), _("input", {
        key: 0,
        class: "font-bold text-xl dark-bg-dark-200",
        ref_key: "titleInput",
        ref: f,
        "onUpdate:modelValue": t[0] || (t[0] = (e) => o.value.title = e),
        placeholder: "Title",
        autofocus: ""
      }, null, 512)), [
        [y, o.value.title]
      ]) : z("", !0),
      k(l("textarea", {
        class: "text-1rem leading-relaxed dark-bg-dark-200",
        "onUpdate:modelValue": t[1] || (t[1] = (e) => o.value.statement = e),
        placeholder: "Short text statement",
        onKeyup: t[2] || (t[2] = B(D((e) => p(), ["ctrl"]), ["enter"]))
      }, null, 544), [
        [y, o.value.statement]
      ]),
      l("div", H, [
        l("button", {
          class: C(["button m-1", { active: o.value.title }]),
          title: "Add a heading",
          onClick: t[3] || (t[3] = (e) => s.title = !s.title)
        }, "H1", 2),
        i(n(w), {
          field: "icon",
          options: { picSize: 400, preserveRatio: !1 },
          onUpdate: t[4] || (t[4] = (e) => o.value.icon = e)
        }, {
          default: g(() => [
            R
          ]),
          _: 1
        }),
        i(n(w), {
          onUpdate: t[5] || (t[5] = (e) => o.value.cover = e)
        }),
        i(n(K), {
          onUpdate: t[6] || (t[6] = (e) => o.value.link = e)
        }),
        i(n(L), {
          onUpdate: t[7] || (t[7] = (e) => o.value.youtube = e)
        }),
        l("button", {
          class: C(["m-1 button", { active: o.value.text }]),
          onClick: t[8] || (t[8] = (e) => s.text = !0)
        }, q, 2),
        G,
        l("div", J, [
          l("button", {
            class: "plus button flex-1 justify-center m-1",
            disabled: !n(v),
            type: "submit",
            onClick: t[9] || (t[9] = (e) => p())
          }, X, 8, O),
          l("button", {
            class: "m-1 button text-xl",
            onClick: t[10] || (t[10] = (e) => m())
          }, tt)
        ])
      ]),
      i(n(U), {
        open: s.youtube,
        offset: "22vh",
        onClose: t[11] || (t[11] = (e) => s.youtube = !1)
      }, null, 8, ["open"]),
      i(n(U), {
        open: s.text,
        offset: "22vh",
        onClose: t[14] || (t[14] = (e) => s.text = !1)
      }, {
        default: g(() => [
          i(n(h), {
            text: o.value.text,
            "onUpdate:text": t[12] || (t[12] = (e) => o.value.text = e),
            onClose: t[13] || (t[13] = (e) => s.text = !1)
          }, null, 8, ["text"])
        ]),
        _: 1
      }, 8, ["open"])
    ]));
  }
}, nt = /* @__PURE__ */ A(et, [["__scopeId", "data-v-c53fdb98"]]);
export {
  nt as default
};
//# sourceMappingURL=PostForm-fd304d50.js.map
