import { computed as T, ref as x, watch as N, resolveComponent as m, openBlock as r, createElementBlock as n, createElementVNode as s, normalizeStyle as S, unref as e, createCommentVNode as v, createBlock as $, createVNode as b, withDirectives as g, vModelText as y, Fragment as B, renderList as D, toDisplayString as w, vModelSelect as E } from "vue";
import { useUser as I, useMd as L, useProject as P, useNewDiscourseItem as z, itemTypes as F } from "./composables-5f691338.js";
const H = { class: "flex flex-col" }, G = ["value"], h = { class: "flex flex-col gap-2 m-2 bg-light-200 dark-bg-dark-400 p-2 rounded-xl shadow relative" }, q = ["innerHTML"], A = { class: "p-2 flex flex-col gap2" }, J = ["value"], K = { class: "p-2 break-all max-w-80vw overflow-scroll" }, X = {
  __name: "ProjectPage",
  props: {
    path: {
      type: String,
      default: ""
    }
  },
  emits: ["gift", "user"],
  setup(f, { emit: O }) {
    const k = f, { user: U } = I(), V = L(), { project: l, updateField: i, updateCover: _ } = P(k.path), a = T(() => k.path.includes(U.pub)), p = x(!1), u = x(l.text);
    N(() => l.text, (c) => {
      u.value = c;
    });
    const { newItem: d, add: Q } = z();
    return (c, o) => {
      const j = m("form-picture"), C = m("form-title"), M = m("project-funding");
      return r(), n("div", H, [
        s("div", {
          class: "p-2 relative",
          style: S({ background: `url(${e(l).cover}) center`, backgroundColor: e(l).color, paddingTop: e(l).cover || e(l).color ? "120px" : "" })
        }, [
          e(a) ? (r(), n("input", {
            key: 0,
            class: "absolute top-4 right-4",
            type: "color",
            value: e(l).color,
            onInput: o[0] || (o[0] = (t) => e(i)("color", t.target.value))
          }, null, 40, G)) : v("", !0),
          e(a) ? (r(), $(j, {
            key: 1,
            onUpdate: o[1] || (o[1] = (t) => e(_)(t))
          })) : v("", !0),
          b(C, {
            text: e(l).title,
            editable: e(a),
            onUpdate: o[2] || (o[2] = (t) => e(i)("title", t))
          }, null, 8, ["text", "editable"])
        ], 4),
        s("div", h, [
          e(a) ? (r(), n("div", {
            key: 0,
            class: "i-la-pen cursor-pointer text-2xl absolute top-2 right-2 z-2",
            onClick: o[3] || (o[3] = (t) => p.value = !p.value)
          })) : v("", !0),
          !p.value || !e(a) ? (r(), n("div", {
            key: 1,
            class: "p-2 markdown-body text-base prose prose-truegray dark-bg-dark-400",
            innerHTML: e(V).render(u.value || "")
          }, null, 8, q)) : g((r(), n("textarea", {
            key: 2,
            class: "dark-bg-dark-400",
            "onUpdate:modelValue": [
              o[4] || (o[4] = (t) => u.value = t),
              o[5] || (o[5] = (t) => e(i)("text", t))
            ]
          }, null, 512)), [
            [y, u.value]
          ])
        ]),
        b(M, {
          path: f.path,
          enabled: e(l).funding,
          onEnable: o[6] || (o[6] = (t) => e(i)("funding", "true")),
          onGift: o[7] || (o[7] = (t) => c.$emit("gift", t))
        }, null, 8, ["path", "enabled"]),
        s("div", A, [
          g(s("input", {
            class: "dark-bg-dark-400",
            type: "text",
            "onUpdate:modelValue": o[8] || (o[8] = (t) => e(d).title = t)
          }, null, 512), [
            [y, e(d).title]
          ]),
          g(s("select", {
            class: "dark-bg-dark-400",
            "onUpdate:modelValue": o[9] || (o[9] = (t) => e(d).type = t)
          }, [
            (r(!0), n(B, null, D(e(F), (t) => (r(), n("option", {
              key: t.type,
              value: t.type
            }, w(t.title), 9, J))), 128))
          ], 512), [
            [E, e(d).type]
          ]),
          s("pre", K, w(e(d)), 1)
        ])
      ]);
    };
  }
};
export {
  X as default
};
//# sourceMappingURL=ProjectPage-2801f554.js.map
