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