import { useUser as V, useMd as F, useProject as M, computed as P, ref as x, watch as j, useNewDiscourseItem as B, openBlock as r, createElementBlock as n, createBaseVNode as s, unref as e, createCommentVNode as m, createBlock as C, createVNode as b, normalizeStyle as N, withDirectives as c, vModelText as f, vModelSelect as S, Fragment as $, renderList as D, toDisplayString as y, itemTypes as I } from "./composables-108ad332.js";
import { FormPicture as L, FormTitle as z, ProjectFunding as E } from "./components.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(g, { emit: O }) {
    const k = g, { user: w } = V(), T = F(), { project: o, updateField: i, updateCover: U } = M(k.path), a = P(() => k.path.includes(w.pub)), p = x(!1), u = x(o.text);
    j(() => o.text, (v) => {
      u.value = v;
    });
    const { newItem: d, add: Q } = B();
    return (v, l) => (r(), n("div", H, [
      s("div", {
        class: "p-2 relative",
        style: N({ background: `url(${e(o).cover}) center`, backgroundColor: e(o).color, paddingTop: e(o).cover || e(o).color ? "120px" : "" })
      }, [
        e(a) ? (r(), n("input", {
          key: 0,
          class: "absolute top-4 right-4",
          type: "color",
          value: e(o).color,
          onInput: l[0] || (l[0] = (t) => e(i)("color", t.target.value))
        }, null, 40, G)) : m("", !0),
        e(a) ? (r(), C(e(L), {
          key: 1,
          onUpdate: l[1] || (l[1] = (t) => e(U)(t))
        })) : m("", !0),
        b(e(z), {
          text: e(o).title,
          editable: e(a),
          onUpdate: l[2] || (l[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: l[3] || (l[3] = (t) => p.value = !p.value)
        })) : m("", !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(T).render(u.value || "")
        }, null, 8, q)) : c((r(), n("textarea", {
          key: 2,
          class: "dark-bg-dark-400",
          "onUpdate:modelValue": [
            l[4] || (l[4] = (t) => u.value = t),
            l[5] || (l[5] = (t) => e(i)("text", t))
          ]
        }, null, 512)), [
          [f, u.value]
        ])
      ]),
      b(e(E), {
        path: g.path,
        enabled: e(o).funding,
        onEnable: l[6] || (l[6] = (t) => e(i)("funding", "true")),
        onGift: l[7] || (l[7] = (t) => v.$emit("gift", t))
      }, null, 8, ["path", "enabled"]),
      s("div", A, [
        c(s("input", {
          class: "dark-bg-dark-400",
          type: "text",
          "onUpdate:modelValue": l[8] || (l[8] = (t) => e(d).title = t)
        }, null, 512), [
          [f, e(d).title]
        ]),
        c(s("select", {
          class: "dark-bg-dark-400",
          "onUpdate:modelValue": l[9] || (l[9] = (t) => e(d).type = t)
        }, [
          (r(!0), n($, null, D(e(I), (t) => (r(), n("option", {
            key: t.type,
            value: t.type
          }, y(t.title), 9, J))), 128))
        ], 512), [
          [S, e(d).type]
        ]),
        s("pre", K, y(e(d)), 1)
      ])
    ]));
  }
};
export {
  X as default
};
//# sourceMappingURL=ProjectPage-3fb09d97.js.map
