import { useUser as B, useMd as M, useProject as V, computed as z, ref as F, watch as D, resolveComponent as N, openBlock as s, createElementBlock as i, createBaseVNode as n, unref as e, createBlock as S, createCommentVNode as g, toDisplayString as b, createVNode as p, normalizeStyle as E, withDirectives as H, vModelText as L, useDebounceFn as G } from "./composables-61bf5e40.js";
import { FormPicture as I, FormTitle as O, ProjectFunding as q, ProjectForm as A } from "./components.js";
const J = { class: "flex flex-col max-w-65ch" }, K = ["value"], Q = { class: "rounded p-2 bg-light-100 bg-opacity-80 dark-bg-dark-300 dark-bg-opacity-60 flex items-center" }, R = { class: "flex flex-col" }, W = { class: "font-mono text-xs capitalize" }, X = /* @__PURE__ */ n("div", { class: "flex-1" }, null, -1), Y = { class: "flex flex-col gap-2 px-4 bg-light-200 dark-bg-dark-400 relative" }, Z = ["innerHTML"], _ = { class: "text-xs max-w-full overflow-scroll" }, le = {
  __name: "ProjectPage",
  props: {
    path: {
      type: String,
      default: ""
    }
  },
  emits: ["gift", "user"],
  setup(r, { emit: ee }) {
    const m = r, { user: P } = B(), $ = M(), { project: l, updateField: d, updateCover: w } = V(m.path), a = z(() => m.path.includes(P.pub)), v = F(!1), u = F(l.content);
    D(() => l.content, (c) => {
      u.value = c;
    });
    const T = G(d, 1e3);
    return (c, t) => {
      var f, x, k, y, h, j, C;
      const U = N("account-badge");
      return s(), i("div", J, [
        n("div", {
          class: "p-2 relative",
          style: E({ background: `url(${e(l).cover}) center`, backgroundColor: (f = e(l)) == null ? void 0 : f.color, paddingTop: (x = e(l)) != null && x.cover || (k = e(l)) != null && k.color ? "220px" : "60px" })
        }, [
          e(a) ? (s(), S(e(I), {
            key: 0,
            class: "absolute top-2",
            onUpdate: t[0] || (t[0] = (o) => e(w)(o))
          })) : g("", !0),
          e(a) ? (s(), i("input", {
            key: 1,
            class: "absolute top-4 right-4",
            type: "color",
            value: (y = e(l)) == null ? void 0 : y.color,
            onInput: t[1] || (t[1] = (o) => e(d)("color", o.target.value))
          }, null, 40, K)) : g("", !0),
          n("div", Q, [
            n("div", R, [
              n("div", W, b((h = e(l)) == null ? void 0 : h.type) + " " + b((j = e(l)) == null ? void 0 : j.id), 1),
              p(e(O), {
                text: (C = e(l)) == null ? void 0 : C.title,
                editable: e(a),
                onUpdate: t[2] || (t[2] = (o) => e(d)("title", o))
              }, null, 8, ["text", "editable"])
            ]),
            X,
            p(U, {
              pub: r.path.slice(-87),
              onClick: t[3] || (t[3] = (o) => c.$emit("user", r.path.slice(-87)))
            }, null, 8, ["pub"])
          ])
        ], 4),
        n("div", Y, [
          e(a) ? (s(), i("div", {
            key: 0,
            class: "i-la-pen cursor-pointer text-2xl absolute top-2 right-2 z-2",
            onClick: t[4] || (t[4] = (o) => v.value = !v.value)
          })) : g("", !0),
          !v.value || !e(a) ? (s(), i("div", {
            key: 1,
            class: "p-2 text-base prose prose-truegray dark-prose-light dark-bg-dark-400",
            innerHTML: e($).render(u.value || "")
          }, null, 8, Z)) : H((s(), i("textarea", {
            key: 2,
            class: "dark-bg-dark-400",
            "onUpdate:modelValue": [
              t[5] || (t[5] = (o) => u.value = o),
              t[6] || (t[6] = (o) => e(T)("content", o))
            ]
          }, null, 512)), [
            [L, u.value]
          ]),
          n("pre", _, b(Object.keys(e(l))), 1)
        ]),
        p(e(q), {
          path: r.path,
          enabled: !!e(l).funding,
          onEnable: t[7] || (t[7] = (o) => e(d)("funding", "true")),
          onGift: t[8] || (t[8] = (o) => c.$emit("gift", o))
        }, null, 8, ["path", "enabled"]),
        p(e(A), { source: r.path }, null, 8, ["source"])
      ]);
    };
  }
};
export {
  le as default
};
//# sourceMappingURL=ProjectPage-bb6fc783.js.map
