@oneclick.dev/cms-core-modules 0.0.123 → 0.0.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{ContentEditor-C-Wm48ai.js → ContentEditor-BcIUumah.js} +39 -39
  2. package/dist/{ContentEditor-MDGolnIP.mjs → ContentEditor-DX1bTQKs.mjs} +4910 -4793
  3. package/dist/{Detail-Dk8E6_uF.mjs → Detail-B7pe808q.mjs} +15 -14
  4. package/dist/Detail-BESGmY7z.js +1 -0
  5. package/dist/{Detail-Cn9Bk0u0.mjs → Detail-B_Q7Qkuz.mjs} +26 -25
  6. package/dist/Detail-CNiLIEh9.js +1 -0
  7. package/dist/{Detail-B_scnidb.mjs → Detail-DNxAzeCs.mjs} +35 -34
  8. package/dist/Detail-t3tOcy3X.js +1 -0
  9. package/dist/Editor-D4evcdhv.mjs +768 -0
  10. package/dist/Editor-gLLtuJbY.js +1 -0
  11. package/dist/FormStatusBadge.vue_vue_type_script_setup_true_lang-BjKpsqT9.js +1 -0
  12. package/dist/FormStatusBadge.vue_vue_type_script_setup_true_lang-D5v5AhLe.mjs +76 -0
  13. package/dist/Knowledge-B66vxz--.js +1 -0
  14. package/dist/Knowledge-BnMTTuJ7.mjs +742 -0
  15. package/dist/Overview-BE4uYPx0.mjs +745 -0
  16. package/dist/Overview-CQRpFhbJ.mjs +286 -0
  17. package/dist/Overview-CTs7sX4d.js +1 -0
  18. package/dist/Overview-Cj89XXKN.js +1 -0
  19. package/dist/Overview-D_c18mbR.mjs +248 -0
  20. package/dist/Overview-g4Rcj245.js +1 -0
  21. package/dist/TableView-6mdrL3zx.js +4 -0
  22. package/dist/{TableView-C4Zyp8d7.mjs → TableView-Du5nOE6R.mjs} +2 -2
  23. package/dist/Test-CzmOmi53.mjs +447 -0
  24. package/dist/Test-USDtNFY1.js +1 -0
  25. package/dist/UserDetail-DpUL3mhk.mjs +1483 -0
  26. package/dist/UserDetail-KRIfxaYd.js +1 -0
  27. package/dist/cms-core-modules.css +1 -1
  28. package/dist/index-CQuN5rKx.js +1 -0
  29. package/dist/index-CnDGeInm.js +1 -0
  30. package/dist/index-CqDTc5Ig.mjs +20 -0
  31. package/dist/index-CyvvAdt4.js +1 -0
  32. package/dist/index-DIRD7t5_.mjs +20 -0
  33. package/dist/index-OJuBYR60.mjs +57 -0
  34. package/dist/index.cjs.js +1 -1
  35. package/dist/index.mjs +327 -84
  36. package/dist/server-handlers.cjs.js +1 -1
  37. package/dist/server-handlers.mjs +1764 -605
  38. package/dist/src/contentManager/components/content-editor/tiptap-extensions/Container.d.ts +1 -1
  39. package/dist/src/contentManager/components/content-editor/tiptap-extensions/Row.d.ts +7 -0
  40. package/dist/src/contentManager/components/content-editor/tiptap-extensions/Stack.d.ts +7 -0
  41. package/dist/src/contentManager/components/content-editor/tiptap-extensions/helpers/resizeHistory.d.ts +9 -0
  42. package/dist/src/contentManager/components/content-editor/tiptap-menus/ElementEditorMenu.vue.d.ts +3 -1
  43. package/dist/src/firebaseAuthManager/components/DeleteUserDialog.vue.d.ts +25 -0
  44. package/dist/src/firebaseAuthManager/components/ReasonActionDialog.vue.d.ts +23 -0
  45. package/dist/src/firebaseAuthManager/components/UserStatusBadge.vue.d.ts +5 -0
  46. package/dist/src/firebaseAuthManager/config.d.ts +151 -0
  47. package/dist/src/firebaseAuthManager/index.d.ts +163 -0
  48. package/dist/src/firebaseAuthManager/index.vue.d.ts +14 -0
  49. package/dist/src/firebaseAuthManager/metadata.d.ts +2 -0
  50. package/dist/src/firebaseAuthManager/pages/Overview.vue.d.ts +2 -0
  51. package/dist/src/firebaseAuthManager/pages/UserDetail.vue.d.ts +2 -0
  52. package/dist/src/firebaseAuthManager/permissions.d.ts +5 -0
  53. package/dist/src/firebaseAuthManager/routes.d.ts +5 -0
  54. package/dist/src/firebaseAuthManager/server.d.ts +162 -0
  55. package/dist/src/firebaseAuthManager/types.d.ts +84 -0
  56. package/dist/src/formBuilder/components/FormPreviewDialog.vue.d.ts +12 -0
  57. package/dist/src/formBuilder/components/FormStatusBadge.vue.d.ts +9 -0
  58. package/dist/src/formBuilder/config.d.ts +31 -0
  59. package/dist/src/formBuilder/index.d.ts +44 -0
  60. package/dist/src/formBuilder/index.vue.d.ts +14 -0
  61. package/dist/src/formBuilder/lib/forms.d.ts +11 -0
  62. package/dist/src/formBuilder/metadata.d.ts +2 -0
  63. package/dist/src/formBuilder/pages/Editor.vue.d.ts +2 -0
  64. package/dist/src/formBuilder/pages/Overview.vue.d.ts +2 -0
  65. package/dist/src/formBuilder/permissions.d.ts +5 -0
  66. package/dist/src/formBuilder/routes.d.ts +5 -0
  67. package/dist/src/formBuilder/server.d.ts +87 -0
  68. package/dist/src/formBuilder/tools.d.ts +1 -0
  69. package/dist/src/formBuilder/types.d.ts +46 -0
  70. package/dist/src/helpbot/composables/useHelpbotApi.d.ts +18 -0
  71. package/dist/src/helpbot/config.d.ts +17 -0
  72. package/dist/src/helpbot/index.d.ts +29 -0
  73. package/dist/src/helpbot/index.vue.d.ts +2 -0
  74. package/dist/src/helpbot/metadata.d.ts +2 -0
  75. package/dist/src/helpbot/pages/Knowledge.vue.d.ts +4 -0
  76. package/dist/src/helpbot/pages/Overview.vue.d.ts +2 -0
  77. package/dist/src/helpbot/pages/Test.vue.d.ts +4 -0
  78. package/dist/src/helpbot/permissions.d.ts +5 -0
  79. package/dist/src/helpbot/routes.d.ts +5 -0
  80. package/dist/src/helpbot/types.d.ts +42 -0
  81. package/dist/src/index.d.ts +3 -0
  82. package/dist/src/server-handlers.d.ts +2 -0
  83. package/dist/types-9N-DKxNj.mjs +250 -0
  84. package/dist/types-BMraG1kN.js +1 -0
  85. package/dist/types-Cem0vPo_.js +1 -0
  86. package/dist/types-ibC3-e1N.mjs +2630 -0
  87. package/dist/useHelpbotApi-BIIungOh.js +1 -0
  88. package/dist/useHelpbotApi-HC9JSiSn.mjs +229 -0
  89. package/dist/vee-validate-zod-BQElPD0m.js +1 -0
  90. package/dist/vee-validate-zod-CN16K2x9.mjs +1780 -0
  91. package/package.json +2 -2
  92. package/src/formBuilder/tools.ts +1 -0
  93. package/dist/Detail-BCUUNWvp.js +0 -1
  94. package/dist/Detail-DGg_xXZc.js +0 -1
  95. package/dist/Detail-Sc2qZdxj.js +0 -1
  96. package/dist/TableView-BkwoKREo.js +0 -4
  97. package/dist/vee-validate-zod-SjDT8X35.mjs +0 -4404
  98. package/dist/vee-validate-zod-VCmLnrtQ.js +0 -1
@@ -0,0 +1,768 @@
1
+ import { defineComponent as ke, ref as k, computed as c, watch as Ce, resolveComponent as v, openBlock as i, createBlock as b, withCtx as n, createVNode as s, createTextVNode as u, toDisplayString as x, createElementVNode as t, unref as a, normalizeStyle as Ie, createElementBlock as g, reactive as pe, onMounted as Ae, onBeforeUnmount as Pe, Fragment as Ne, createCommentVNode as C, normalizeClass as Le } from "vue";
2
+ import { Smartphone as Me, Tablet as Oe, Monitor as Ke, ArrowLeft as He, ShieldAlert as We, AlertCircle as xe, RefreshCw as Ge, Eye as be, Loader2 as Q, Save as Je, Send as qe, Archive as ye, ArchiveRestore as Ye, Settings2 as Qe, LockKeyhole as ge, FileText as he, Database as Xe, Clock3 as Ze } from "lucide-vue-next";
3
+ import { useModule as et, useModuleRoute as tt, useModulePermissions as st, useConfirmation as ot, useModuleApi as nt, useModuleBreadcrumbs as it } from "@oneclick.dev/cms-kit";
4
+ import { t as U } from "./index-RLz1QPrf.mjs";
5
+ import { c as X, h as De, a as _e, d as at, t as lt, _ as we, f as rt, b as H, r as W, i as dt } from "./FormStatusBadge.vue_vue_type_script_setup_true_lang-D5v5AhLe.mjs";
6
+ const ut = { class: "flex flex-wrap items-center justify-between gap-3 border-y py-3" }, mt = {
7
+ class: "flex items-center rounded-lg border bg-muted/40 p-1",
8
+ "aria-label": "Preview width"
9
+ }, ft = { class: "overflow-auto rounded-lg bg-muted/40 p-3 sm:p-6" }, ct = {
10
+ key: 1,
11
+ class: "flex min-h-[32rem] items-center justify-center p-8 text-center"
12
+ }, vt = /* @__PURE__ */ ke({
13
+ __name: "FormPreviewDialog",
14
+ props: {
15
+ open: { type: Boolean },
16
+ name: {},
17
+ definition: {}
18
+ },
19
+ emits: ["update:open"],
20
+ setup(Z, { emit: ee }) {
21
+ const R = Z, te = ee, w = k("desktop"), S = k(0), V = k(X(R.definition)), D = c({
22
+ get: () => R.open,
23
+ set: (l) => te("update:open", l)
24
+ }), N = c(() => w.value === "mobile" ? "390px" : w.value === "tablet" ? "768px" : "100%");
25
+ Ce(
26
+ () => R.open,
27
+ (l) => {
28
+ l && (V.value = X(R.definition), S.value += 1);
29
+ }
30
+ );
31
+ const y = () => {
32
+ };
33
+ return (l, o) => {
34
+ const L = v("DialogTitle"), j = v("DialogDescription"), h = v("DialogHeader"), p = v("Button"), M = v("FormDisplayer"), O = v("DialogScrollContent"), E = v("Dialog");
35
+ return i(), b(E, {
36
+ open: D.value,
37
+ "onUpdate:open": o[3] || (o[3] = (d) => D.value = d)
38
+ }, {
39
+ default: n(() => [
40
+ s(O, { class: "max-h-[94vh] max-w-[calc(100vw-2rem)] sm:max-w-6xl" }, {
41
+ default: n(() => [
42
+ s(h, null, {
43
+ default: n(() => [
44
+ s(L, null, {
45
+ default: n(() => [
46
+ u("Preview " + x(Z.name || "untitled form"), 1)
47
+ ]),
48
+ _: 1
49
+ }),
50
+ s(j, null, {
51
+ default: n(() => [...o[4] || (o[4] = [
52
+ u(" This preview runs locally in Studio. Completing it does not save a submission. ", -1)
53
+ ])]),
54
+ _: 1
55
+ })
56
+ ]),
57
+ _: 1
58
+ }),
59
+ t("div", ut, [
60
+ o[8] || (o[8] = t("p", { class: "text-sm text-muted-foreground" }, "Draft definition", -1)),
61
+ t("div", mt, [
62
+ s(p, {
63
+ size: "sm",
64
+ variant: w.value === "mobile" ? "secondary" : "ghost",
65
+ "aria-label": "Mobile preview",
66
+ onClick: o[0] || (o[0] = (d) => w.value = "mobile")
67
+ }, {
68
+ default: n(() => [
69
+ s(a(Me), { class: "size-4" }),
70
+ o[5] || (o[5] = t("span", { class: "hidden sm:inline" }, "Mobile", -1))
71
+ ]),
72
+ _: 1
73
+ }, 8, ["variant"]),
74
+ s(p, {
75
+ size: "sm",
76
+ variant: w.value === "tablet" ? "secondary" : "ghost",
77
+ "aria-label": "Tablet preview",
78
+ onClick: o[1] || (o[1] = (d) => w.value = "tablet")
79
+ }, {
80
+ default: n(() => [
81
+ s(a(Oe), { class: "size-4" }),
82
+ o[6] || (o[6] = t("span", { class: "hidden sm:inline" }, "Tablet", -1))
83
+ ]),
84
+ _: 1
85
+ }, 8, ["variant"]),
86
+ s(p, {
87
+ size: "sm",
88
+ variant: w.value === "desktop" ? "secondary" : "ghost",
89
+ "aria-label": "Desktop preview",
90
+ onClick: o[2] || (o[2] = (d) => w.value = "desktop")
91
+ }, {
92
+ default: n(() => [
93
+ s(a(Ke), { class: "size-4" }),
94
+ o[7] || (o[7] = t("span", { class: "hidden sm:inline" }, "Desktop", -1))
95
+ ]),
96
+ _: 1
97
+ }, 8, ["variant"])
98
+ ])
99
+ ]),
100
+ t("div", ft, [
101
+ t("div", {
102
+ class: "mx-auto min-h-[32rem] overflow-hidden rounded-lg border bg-background shadow-sm transition-[width] duration-200",
103
+ style: Ie({ width: N.value, maxWidth: "100%" })
104
+ }, [
105
+ a(De)(V.value) ? (i(), b(M, {
106
+ key: S.value,
107
+ settings: V.value,
108
+ "on-finish": y,
109
+ variables: [],
110
+ "input-values": {},
111
+ "enable-actions": !1,
112
+ class: "min-h-[32rem]"
113
+ }, null, 8, ["settings"])) : (i(), g("div", ct, [...o[9] || (o[9] = [
114
+ t("div", null, [
115
+ t("p", { class: "font-medium" }, "Nothing to preview yet"),
116
+ t("p", { class: "mt-1 text-sm text-muted-foreground" }, " Open the builder and add at least one form element. ")
117
+ ], -1)
118
+ ])]))
119
+ ], 4)
120
+ ])
121
+ ]),
122
+ _: 1
123
+ })
124
+ ]),
125
+ _: 1
126
+ }, 8, ["open"]);
127
+ };
128
+ }
129
+ }), pt = { class: "mx-auto flex w-full max-w-7xl flex-1 flex-col px-4 py-5 sm:px-6 sm:py-8 lg:px-8" }, xt = {
130
+ key: 0,
131
+ class: "flex min-h-96 items-center justify-center rounded-xl border border-dashed p-8"
132
+ }, bt = { class: "max-w-md text-center" }, yt = { class: "mx-auto flex size-11 items-center justify-center rounded-full bg-muted" }, gt = { class: "mt-1 text-sm leading-6 text-muted-foreground" }, ht = {
133
+ key: 1,
134
+ class: "space-y-6",
135
+ "aria-label": "Loading form"
136
+ }, _t = { class: "flex items-start justify-between gap-4" }, wt = { class: "space-y-3" }, kt = { class: "grid gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]" }, Ct = { class: "space-y-6" }, Dt = {
137
+ key: 2,
138
+ class: "flex min-h-96 items-center justify-center rounded-xl border border-destructive/30 bg-destructive/5 p-8"
139
+ }, zt = { class: "max-w-md text-center" }, Ft = { class: "mt-1 text-sm leading-6 text-muted-foreground" }, St = { class: "mt-5 flex flex-wrap justify-center gap-2" }, $t = { class: "flex flex-col gap-5 border-b pb-6 xl:flex-row xl:items-start xl:justify-between" }, Tt = { class: "min-w-0" }, Bt = { class: "flex flex-wrap items-center gap-2" }, Ut = { class: "truncate text-2xl font-semibold tracking-tight sm:text-3xl" }, Vt = {
140
+ key: 0,
141
+ class: "text-xs text-muted-foreground"
142
+ }, Rt = { class: "mt-2 max-w-2xl text-sm leading-6 text-muted-foreground" }, jt = { class: "flex w-full flex-wrap items-center gap-2 xl:w-auto xl:justify-end" }, Et = {
143
+ key: 0,
144
+ class: "mt-5 flex items-start gap-3 rounded-lg border border-destructive/30 bg-destructive/5 p-4",
145
+ role: "alert"
146
+ }, It = { class: "min-w-0" }, At = { class: "mt-1 break-words text-sm text-muted-foreground" }, Pt = {
147
+ key: 1,
148
+ class: "mt-5 flex items-start gap-3 rounded-lg border bg-muted/40 p-4"
149
+ }, Nt = { class: "grid gap-6 py-6 lg:grid-cols-[minmax(0,1fr)_20rem]" }, Lt = { class: "min-w-0 space-y-6" }, Mt = { class: "flex items-center gap-3" }, Ot = { class: "flex size-9 items-center justify-center rounded-lg bg-muted" }, Kt = { class: "space-y-2" }, Ht = {
150
+ key: 0,
151
+ class: "text-xs text-destructive"
152
+ }, Wt = {
153
+ key: 1,
154
+ class: "text-xs text-muted-foreground"
155
+ }, Gt = { class: "space-y-2" }, Jt = { class: "flex items-center justify-between gap-2" }, qt = {
156
+ key: 0,
157
+ class: "text-xs text-destructive"
158
+ }, Yt = {
159
+ key: 1,
160
+ class: "text-xs text-muted-foreground"
161
+ }, Qt = { class: "space-y-2 sm:col-span-2" }, Xt = { class: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between" }, Zt = { class: "flex items-start gap-3" }, es = { class: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted" }, ts = { class: "rounded-lg border border-dashed bg-muted/20 px-5 py-10 text-center sm:py-14" }, ss = { class: "mx-auto flex size-12 items-center justify-center rounded-xl border bg-background shadow-sm" }, os = { class: "mt-4 font-medium" }, ns = { class: "mx-auto mt-1 max-w-lg text-sm leading-6 text-muted-foreground" }, is = {
162
+ key: 0,
163
+ class: "mt-2 text-xs text-destructive"
164
+ }, as = { class: "space-y-6" }, ls = { class: "flex items-center justify-between gap-3" }, rs = { class: "flex items-center justify-between gap-3" }, ds = { class: "font-medium" }, us = { class: "flex items-center justify-between gap-3" }, ms = { class: "font-medium" }, fs = { class: "flex items-start justify-between gap-3" }, cs = { class: "max-w-40 text-right font-medium" }, vs = { class: "flex items-start gap-3" }, ps = { class: "min-w-0" }, xs = { class: "mt-0.5 break-all text-xs text-muted-foreground" }, bs = { class: "flex items-start gap-3" }, ks = /* @__PURE__ */ ke({
165
+ __name: "Editor",
166
+ setup(Z) {
167
+ const { config: ee } = et(), { moduleId: R, params: te, navigateTo: w } = tt(), { hasPermission: S } = st(), { confirm: V } = ot(), D = nt(), N = c(() => te.value.formId), y = c(() => !N.value || N.value === "new"), l = k(null), o = pe({
168
+ name: "",
169
+ key: "",
170
+ description: "",
171
+ definition: _e()
172
+ }), L = k(!1), j = k(""), h = k(""), p = k(null), M = k(JSON.stringify(o)), O = k(!1), E = k(!1), d = pe({
173
+ name: "",
174
+ key: "",
175
+ definition: ""
176
+ }), I = c(() => S("view-forms")), ne = c(() => I.value && S("create-form")), ze = c(() => I.value && S("edit-form")), ie = c(() => I.value && S("publish-form")), G = c(() => I.value && S("archive-form")), Fe = c(() => y.value ? ne.value : I.value), z = c(() => l.value?.status === "archived"), A = c(() => !z.value && (y.value ? ne.value : ze.value)), Se = c(() => A.value && !p.value), F = c(() => p.value !== null), P = c(() => at(o.definition)), ae = c(() => l.value?.status ?? "draft"), le = c(() => !!(l.value?.hasUnpublishedChanges || l.value?.status === "published" && $.value));
177
+ function se() {
178
+ return JSON.stringify({
179
+ name: o.name,
180
+ key: o.key,
181
+ description: o.description,
182
+ definition: o.definition
183
+ });
184
+ }
185
+ const $ = c(() => se() !== M.value), $e = c(() => F.value ? !0 : y.value || $.value ? !1 : l.value ? !l.value.hasUnpublishedChanges : !0);
186
+ it(() => [
187
+ { text: "Forms", href: "/forms" },
188
+ { text: y.value ? "New form" : l.value?.name || "Form" }
189
+ ]), Ce(
190
+ () => o.name,
191
+ (r) => {
192
+ y.value && !O.value && (o.key = lt(r));
193
+ }
194
+ );
195
+ function re() {
196
+ d.name = "", d.key = "", d.definition = "";
197
+ }
198
+ function de(r = !1) {
199
+ return re(), o.name = o.name.trim(), o.key = o.key.trim().toLowerCase(), o.description = o.description.trim(), o.name || (d.name = "Give this form a name."), o.key ? dt(o.key) || (d.key = "Start with a letter and use lowercase letters, numbers, single hyphens, or underscores.") : d.key = "Give this form a machine key.", r && !De(o.definition) && (d.definition = "Add at least one form element before publishing."), !d.name && !d.key && !d.definition;
200
+ }
201
+ function K(r) {
202
+ l.value = r, o.name = r.name ?? "", o.key = r.key ?? "", o.description = r.description ?? "", o.definition = X(r.definition ?? _e()), M.value = se(), O.value = !0, h.value = "", re();
203
+ }
204
+ async function ue() {
205
+ if (y.value || !I.value) {
206
+ M.value = se();
207
+ return;
208
+ }
209
+ L.value = !0, j.value = "";
210
+ try {
211
+ const r = N.value;
212
+ if (!r) return;
213
+ const e = await D.get(`/forms/${encodeURIComponent(r)}`);
214
+ K(H(e));
215
+ } catch (r) {
216
+ j.value = W(r, "The form could not be loaded from Firebase.");
217
+ } finally {
218
+ L.value = !1;
219
+ }
220
+ }
221
+ async function me(r = !0) {
222
+ if (!A.value || !de(!1)) return null;
223
+ p.value = "save", h.value = "";
224
+ const e = y.value;
225
+ try {
226
+ const f = {
227
+ name: o.name,
228
+ key: o.key,
229
+ description: o.description,
230
+ definition: X(o.definition)
231
+ };
232
+ let m;
233
+ if (e)
234
+ m = await D.post("/forms", { body: f });
235
+ else {
236
+ const B = l.value;
237
+ if (!B) return null;
238
+ f.expectedRevision = B.revision, m = await D.patch(
239
+ `/forms/${encodeURIComponent(B.id)}/draft`,
240
+ { body: f }
241
+ );
242
+ }
243
+ const T = H(m);
244
+ return K(T), e && w(`forms/${encodeURIComponent(T.id)}`), r && U.success(e ? "Form draft created" : "Draft saved"), T;
245
+ } catch (f) {
246
+ const m = W(f, "The draft could not be saved.");
247
+ return h.value = m, U.error(m), null;
248
+ } finally {
249
+ p.value = null;
250
+ }
251
+ }
252
+ async function Te() {
253
+ if (!ie.value || z.value || !de(!0) || !await V(
254
+ `Publish “${o.name}”? Apps using this form will be able to load the new immutable revision.`
255
+ )) return;
256
+ let e = l.value;
257
+ if (!((y.value || $.value) && (e = await me(!1), !e)) && e) {
258
+ p.value = "publish", h.value = "";
259
+ try {
260
+ const f = await D.post(
261
+ `/forms/${encodeURIComponent(e.id)}/publish`,
262
+ { body: { expectedRevision: e.revision } }
263
+ );
264
+ K(H(f)), U.success("Form published");
265
+ } catch (f) {
266
+ const m = W(f, "The form could not be published.");
267
+ h.value = m, U.error(m);
268
+ } finally {
269
+ p.value = null;
270
+ }
271
+ }
272
+ }
273
+ async function Be() {
274
+ if (!l.value || !G.value || z.value) return;
275
+ const r = $.value ? " Unsaved draft changes will be discarded." : "";
276
+ if (await V(
277
+ `Archive “${o.name}”? It will remain in Firebase and can be restored later.${r}`
278
+ )) {
279
+ p.value = "archive", h.value = "";
280
+ try {
281
+ const f = await D.post(
282
+ `/forms/${encodeURIComponent(l.value.id)}/archive`,
283
+ { body: { expectedRevision: l.value.revision } }
284
+ );
285
+ K(H(f)), U.success("Form archived");
286
+ } catch (f) {
287
+ const m = W(f, "The form could not be archived.");
288
+ h.value = m, U.error(m);
289
+ } finally {
290
+ p.value = null;
291
+ }
292
+ }
293
+ }
294
+ async function Ue() {
295
+ if (!(!l.value || !G.value || !z.value)) {
296
+ p.value = "restore", h.value = "";
297
+ try {
298
+ const r = await D.post(
299
+ `/forms/${encodeURIComponent(l.value.id)}/restore`,
300
+ { body: { expectedRevision: l.value.revision } }
301
+ );
302
+ K(H(r)), U.success("Form restored");
303
+ } catch (r) {
304
+ const e = W(r, "The form could not be restored.");
305
+ h.value = e, U.error(e);
306
+ } finally {
307
+ p.value = null;
308
+ }
309
+ }
310
+ }
311
+ async function fe() {
312
+ $.value && !F.value && !await V("Discard your unsaved changes and return to the form library?") || w("forms");
313
+ }
314
+ function Ve() {
315
+ O.value = !0;
316
+ }
317
+ function ce(r) {
318
+ $.value && (r.preventDefault(), r.returnValue = "");
319
+ }
320
+ return Ae(() => {
321
+ window.addEventListener("beforeunload", ce), ue();
322
+ }), Pe(() => {
323
+ window.removeEventListener("beforeunload", ce);
324
+ }), (r, e) => {
325
+ const f = v("Skeleton"), m = v("Button"), T = v("CardTitle"), B = v("CardDescription"), J = v("CardHeader"), oe = v("Label"), ve = v("Input"), Re = v("Textarea"), q = v("CardContent"), Y = v("Card"), je = v("FormBuilderSelect"), Ee = v("Separator");
326
+ return i(), g("main", pt, [
327
+ t("button", {
328
+ type: "button",
329
+ class: "mb-5 flex w-fit items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",
330
+ onClick: fe
331
+ }, [
332
+ s(a(He), { class: "size-4" }),
333
+ e[8] || (e[8] = u(" Forms ", -1))
334
+ ]),
335
+ Fe.value ? L.value ? (i(), g("section", ht, [
336
+ t("div", _t, [
337
+ t("div", wt, [
338
+ s(f, { class: "h-8 w-64" }),
339
+ s(f, { class: "h-4 w-80 max-w-full" })
340
+ ]),
341
+ s(f, { class: "h-10 w-28" })
342
+ ]),
343
+ t("div", kt, [
344
+ t("div", Ct, [
345
+ s(f, { class: "h-72 w-full rounded-xl" }),
346
+ s(f, { class: "h-64 w-full rounded-xl" })
347
+ ]),
348
+ s(f, { class: "h-80 w-full rounded-xl" })
349
+ ])
350
+ ])) : j.value ? (i(), g("section", Dt, [
351
+ t("div", zt, [
352
+ s(a(xe), { class: "mx-auto size-7 text-destructive" }),
353
+ e[12] || (e[12] = t("h1", { class: "mt-4 font-semibold" }, "Could not load this form", -1)),
354
+ t("p", Ft, x(j.value), 1),
355
+ t("div", St, [
356
+ s(m, {
357
+ variant: "outline",
358
+ onClick: fe
359
+ }, {
360
+ default: n(() => [...e[10] || (e[10] = [
361
+ u("Back to forms", -1)
362
+ ])]),
363
+ _: 1
364
+ }),
365
+ s(m, { onClick: ue }, {
366
+ default: n(() => [
367
+ s(a(Ge), { class: "size-4" }),
368
+ e[11] || (e[11] = u(" Try again ", -1))
369
+ ]),
370
+ _: 1
371
+ })
372
+ ])
373
+ ])
374
+ ])) : (i(), g(Ne, { key: 3 }, [
375
+ t("header", $t, [
376
+ t("div", Tt, [
377
+ t("div", Bt, [
378
+ t("h1", Ut, x(o.name || "Untitled form"), 1),
379
+ s(we, {
380
+ status: ae.value,
381
+ "has-unpublished-changes": le.value
382
+ }, null, 8, ["status", "has-unpublished-changes"]),
383
+ $.value ? (i(), g("span", Vt, "Unsaved")) : C("", !0)
384
+ ]),
385
+ t("p", Rt, x(y.value ? "Create a reusable form definition in your connected Firebase database." : `Editing draft revision ${l.value?.draftRevision ?? l.value?.revision ?? 0}. Published revisions stay immutable.`), 1)
386
+ ]),
387
+ t("div", jt, [
388
+ s(m, {
389
+ variant: "outline",
390
+ disabled: F.value,
391
+ onClick: e[0] || (e[0] = (_) => E.value = !0)
392
+ }, {
393
+ default: n(() => [
394
+ s(a(be), { class: "size-4" }),
395
+ e[13] || (e[13] = u(" Preview ", -1))
396
+ ]),
397
+ _: 1
398
+ }, 8, ["disabled"]),
399
+ A.value ? (i(), b(m, {
400
+ key: 0,
401
+ variant: "outline",
402
+ disabled: F.value || !y.value && !$.value,
403
+ onClick: e[1] || (e[1] = (_) => me())
404
+ }, {
405
+ default: n(() => [
406
+ p.value === "save" ? (i(), b(a(Q), {
407
+ key: 0,
408
+ class: "size-4 animate-spin"
409
+ })) : (i(), b(a(Je), {
410
+ key: 1,
411
+ class: "size-4"
412
+ })),
413
+ e[14] || (e[14] = u(" Save draft ", -1))
414
+ ]),
415
+ _: 1
416
+ }, 8, ["disabled"])) : C("", !0),
417
+ ie.value && !z.value ? (i(), b(m, {
418
+ key: 1,
419
+ disabled: $e.value,
420
+ onClick: Te
421
+ }, {
422
+ default: n(() => [
423
+ p.value === "publish" ? (i(), b(a(Q), {
424
+ key: 0,
425
+ class: "size-4 animate-spin"
426
+ })) : (i(), b(a(qe), {
427
+ key: 1,
428
+ class: "size-4"
429
+ })),
430
+ e[15] || (e[15] = u(" Publish ", -1))
431
+ ]),
432
+ _: 1
433
+ }, 8, ["disabled"])) : C("", !0),
434
+ l.value && G.value && !z.value ? (i(), b(m, {
435
+ key: 2,
436
+ variant: "ghost",
437
+ disabled: F.value,
438
+ onClick: Be
439
+ }, {
440
+ default: n(() => [
441
+ p.value === "archive" ? (i(), b(a(Q), {
442
+ key: 0,
443
+ class: "size-4 animate-spin"
444
+ })) : (i(), b(a(ye), {
445
+ key: 1,
446
+ class: "size-4"
447
+ })),
448
+ e[16] || (e[16] = u(" Archive ", -1))
449
+ ]),
450
+ _: 1
451
+ }, 8, ["disabled"])) : C("", !0),
452
+ l.value && G.value && z.value ? (i(), b(m, {
453
+ key: 3,
454
+ disabled: F.value,
455
+ onClick: Ue
456
+ }, {
457
+ default: n(() => [
458
+ p.value === "restore" ? (i(), b(a(Q), {
459
+ key: 0,
460
+ class: "size-4 animate-spin"
461
+ })) : (i(), b(a(Ye), {
462
+ key: 1,
463
+ class: "size-4"
464
+ })),
465
+ e[17] || (e[17] = u(" Restore form ", -1))
466
+ ]),
467
+ _: 1
468
+ }, 8, ["disabled"])) : C("", !0)
469
+ ])
470
+ ]),
471
+ h.value ? (i(), g("div", Et, [
472
+ s(a(xe), { class: "mt-0.5 size-5 shrink-0 text-destructive" }),
473
+ t("div", It, [
474
+ e[18] || (e[18] = t("p", { class: "font-medium" }, "The action did not complete", -1)),
475
+ t("p", At, x(h.value), 1),
476
+ e[19] || (e[19] = t("p", { class: "mt-1 text-xs text-muted-foreground" }, " If another editor changed this form, reload before trying again. ", -1))
477
+ ])
478
+ ])) : C("", !0),
479
+ z.value ? (i(), g("div", Pt, [
480
+ s(a(ye), { class: "mt-0.5 size-5 shrink-0 text-muted-foreground" }),
481
+ e[20] || (e[20] = t("div", null, [
482
+ t("p", { class: "font-medium" }, "This form is archived"),
483
+ t("p", { class: "mt-1 text-sm text-muted-foreground" }, " Its stored definition is read-only until someone with archive permission restores it. ")
484
+ ], -1))
485
+ ])) : C("", !0),
486
+ t("div", Nt, [
487
+ t("div", Lt, [
488
+ s(Y, null, {
489
+ default: n(() => [
490
+ s(J, null, {
491
+ default: n(() => [
492
+ t("div", Mt, [
493
+ t("div", Ot, [
494
+ s(a(Qe), { class: "size-4" })
495
+ ]),
496
+ t("div", null, [
497
+ s(T, { class: "text-base" }, {
498
+ default: n(() => [...e[21] || (e[21] = [
499
+ u("Form details", -1)
500
+ ])]),
501
+ _: 1
502
+ }),
503
+ s(B, null, {
504
+ default: n(() => [...e[22] || (e[22] = [
505
+ u("Human-readable details and the stable key used by apps.", -1)
506
+ ])]),
507
+ _: 1
508
+ })
509
+ ])
510
+ ])
511
+ ]),
512
+ _: 1
513
+ }),
514
+ s(q, { class: "grid gap-5 sm:grid-cols-2" }, {
515
+ default: n(() => [
516
+ t("div", Kt, [
517
+ s(oe, { for: "form-name" }, {
518
+ default: n(() => [...e[23] || (e[23] = [
519
+ u("Name", -1)
520
+ ])]),
521
+ _: 1
522
+ }),
523
+ s(ve, {
524
+ id: "form-name",
525
+ modelValue: o.name,
526
+ "onUpdate:modelValue": e[2] || (e[2] = (_) => o.name = _),
527
+ placeholder: "Contact form",
528
+ maxlength: "120",
529
+ disabled: !A.value || F.value,
530
+ "aria-invalid": !!d.name
531
+ }, null, 8, ["modelValue", "disabled", "aria-invalid"]),
532
+ d.name ? (i(), g("p", Ht, x(d.name), 1)) : (i(), g("p", Wt, "Shown to Studio users."))
533
+ ]),
534
+ t("div", Gt, [
535
+ t("div", Jt, [
536
+ s(oe, { for: "form-key" }, {
537
+ default: n(() => [...e[24] || (e[24] = [
538
+ u("Machine key", -1)
539
+ ])]),
540
+ _: 1
541
+ }),
542
+ y.value ? C("", !0) : (i(), b(a(ge), {
543
+ key: 0,
544
+ class: "size-3.5 text-muted-foreground",
545
+ "aria-label": "Key is locked"
546
+ }))
547
+ ]),
548
+ s(ve, {
549
+ id: "form-key",
550
+ modelValue: o.key,
551
+ "onUpdate:modelValue": e[3] || (e[3] = (_) => o.key = _),
552
+ placeholder: "contact-form",
553
+ maxlength: "80",
554
+ disabled: !A.value || !y.value || F.value,
555
+ "aria-invalid": !!d.key,
556
+ onInput: Ve
557
+ }, null, 8, ["modelValue", "disabled", "aria-invalid"]),
558
+ d.key ? (i(), g("p", qt, x(d.key), 1)) : (i(), g("p", Yt, x(y.value ? "Cannot be changed after the first save." : "Locked so app references remain stable."), 1))
559
+ ]),
560
+ t("div", Qt, [
561
+ s(oe, { for: "form-description" }, {
562
+ default: n(() => [...e[25] || (e[25] = [
563
+ u("Description", -1)
564
+ ])]),
565
+ _: 1
566
+ }),
567
+ s(Re, {
568
+ id: "form-description",
569
+ modelValue: o.description,
570
+ "onUpdate:modelValue": e[4] || (e[4] = (_) => o.description = _),
571
+ rows: "3",
572
+ maxlength: "2000",
573
+ placeholder: "What this form collects and where it is used.",
574
+ disabled: !A.value || F.value
575
+ }, null, 8, ["modelValue", "disabled"]),
576
+ e[26] || (e[26] = t("p", { class: "text-xs text-muted-foreground" }, "Internal context for editors; it is not rendered in the form.", -1))
577
+ ])
578
+ ]),
579
+ _: 1
580
+ })
581
+ ]),
582
+ _: 1
583
+ }),
584
+ s(Y, {
585
+ class: Le(d.definition ? "border-destructive/50" : "")
586
+ }, {
587
+ default: n(() => [
588
+ s(J, null, {
589
+ default: n(() => [
590
+ t("div", Xt, [
591
+ t("div", Zt, [
592
+ t("div", es, [
593
+ s(a(he), { class: "size-4" })
594
+ ]),
595
+ t("div", null, [
596
+ s(T, { class: "text-base" }, {
597
+ default: n(() => [...e[27] || (e[27] = [
598
+ u("Form canvas", -1)
599
+ ])]),
600
+ _: 1
601
+ }),
602
+ s(B, { class: "mt-1" }, {
603
+ default: n(() => [
604
+ u(x(P.value === 0 ? "No elements have been added yet." : `${P.value} top-level ${P.value === 1 ? "element" : "elements"} in this draft.`), 1)
605
+ ]),
606
+ _: 1
607
+ })
608
+ ])
609
+ ]),
610
+ Se.value ? (i(), b(je, {
611
+ key: 0,
612
+ modelValue: o.definition,
613
+ "onUpdate:modelValue": e[5] || (e[5] = (_) => o.definition = _),
614
+ "build-text": P.value === 0 ? "Build form" : "Edit form",
615
+ "edit-text": "Edit form"
616
+ }, null, 8, ["modelValue", "build-text"])) : z.value ? C("", !0) : (i(), b(m, {
617
+ key: 1,
618
+ variant: "outline",
619
+ disabled: ""
620
+ }, {
621
+ default: n(() => [
622
+ s(a(ge), { class: "size-4" }),
623
+ e[28] || (e[28] = u(" Read only ", -1))
624
+ ]),
625
+ _: 1
626
+ }))
627
+ ])
628
+ ]),
629
+ _: 1
630
+ }),
631
+ s(q, null, {
632
+ default: n(() => [
633
+ t("div", ts, [
634
+ t("div", ss, [
635
+ s(a(he), { class: "size-5 text-muted-foreground" })
636
+ ]),
637
+ t("p", os, x(P.value > 0 ? "Draft definition ready" : "Start with a blank form"), 1),
638
+ t("p", ns, x(P.value > 0 ? "Open the builder to change fields, validation, layout, conditions, and output behavior." : "Open the builder to add fields and configure how this form behaves. Saving keeps it a private draft."), 1),
639
+ s(m, {
640
+ variant: "outline",
641
+ class: "mt-5",
642
+ onClick: e[6] || (e[6] = (_) => E.value = !0)
643
+ }, {
644
+ default: n(() => [
645
+ s(a(be), { class: "size-4" }),
646
+ e[29] || (e[29] = u(" Preview draft ", -1))
647
+ ]),
648
+ _: 1
649
+ })
650
+ ]),
651
+ d.definition ? (i(), g("p", is, x(d.definition), 1)) : C("", !0)
652
+ ]),
653
+ _: 1
654
+ })
655
+ ]),
656
+ _: 1
657
+ }, 8, ["class"])
658
+ ]),
659
+ t("aside", as, [
660
+ s(Y, null, {
661
+ default: n(() => [
662
+ s(J, null, {
663
+ default: n(() => [
664
+ s(T, { class: "text-base" }, {
665
+ default: n(() => [...e[30] || (e[30] = [
666
+ u("Publication", -1)
667
+ ])]),
668
+ _: 1
669
+ }),
670
+ s(B, null, {
671
+ default: n(() => [...e[31] || (e[31] = [
672
+ u("Revision state stored in Firebase.", -1)
673
+ ])]),
674
+ _: 1
675
+ })
676
+ ]),
677
+ _: 1
678
+ }),
679
+ s(q, { class: "space-y-4 text-sm" }, {
680
+ default: n(() => [
681
+ t("div", ls, [
682
+ e[32] || (e[32] = t("span", { class: "text-muted-foreground" }, "Status", -1)),
683
+ s(we, {
684
+ status: ae.value,
685
+ "has-unpublished-changes": le.value
686
+ }, null, 8, ["status", "has-unpublished-changes"])
687
+ ]),
688
+ s(Ee),
689
+ t("div", rs, [
690
+ e[33] || (e[33] = t("span", { class: "text-muted-foreground" }, "Draft revision", -1)),
691
+ t("span", ds, x(l.value?.draftRevision ?? l.value?.revision ?? "Not saved"), 1)
692
+ ]),
693
+ t("div", us, [
694
+ e[34] || (e[34] = t("span", { class: "text-muted-foreground" }, "Published revision", -1)),
695
+ t("span", ms, x(l.value?.publishedRevision ?? "None"), 1)
696
+ ]),
697
+ t("div", fs, [
698
+ e[35] || (e[35] = t("span", { class: "text-muted-foreground" }, "Last updated", -1)),
699
+ t("span", cs, x(a(rt)(l.value?.updatedAt)), 1)
700
+ ])
701
+ ]),
702
+ _: 1
703
+ })
704
+ ]),
705
+ _: 1
706
+ }),
707
+ s(Y, null, {
708
+ default: n(() => [
709
+ s(J, null, {
710
+ default: n(() => [
711
+ s(T, { class: "text-base" }, {
712
+ default: n(() => [...e[36] || (e[36] = [
713
+ u("Storage", -1)
714
+ ])]),
715
+ _: 1
716
+ }),
717
+ s(B, null, {
718
+ default: n(() => [...e[37] || (e[37] = [
719
+ u("The configured definition source.", -1)
720
+ ])]),
721
+ _: 1
722
+ })
723
+ ]),
724
+ _: 1
725
+ }),
726
+ s(q, { class: "space-y-4 text-sm" }, {
727
+ default: n(() => [
728
+ t("div", vs, [
729
+ s(a(Xe), { class: "mt-0.5 size-4 shrink-0 text-muted-foreground" }),
730
+ t("div", ps, [
731
+ e[38] || (e[38] = t("p", { class: "font-medium" }, "Firebase", -1)),
732
+ t("p", xs, x(a(ee).formsCollection) + "/" + x(a(R)) + "/forms ", 1)
733
+ ])
734
+ ]),
735
+ t("div", bs, [
736
+ s(a(Ze), { class: "mt-0.5 size-4 shrink-0 text-muted-foreground" }),
737
+ e[39] || (e[39] = t("p", { class: "text-xs leading-5 text-muted-foreground" }, " Publishing writes an immutable revision; it does not overwrite a previously published definition. ", -1))
738
+ ])
739
+ ]),
740
+ _: 1
741
+ })
742
+ ]),
743
+ _: 1
744
+ })
745
+ ])
746
+ ])
747
+ ], 64)) : (i(), g("section", xt, [
748
+ t("div", bt, [
749
+ t("div", yt, [
750
+ s(a(We), { class: "size-5 text-muted-foreground" })
751
+ ]),
752
+ e[9] || (e[9] = t("h1", { class: "mt-4 font-semibold" }, "Permission required", -1)),
753
+ t("p", gt, " You do not have permission to " + x(y.value ? "create" : "view") + " this form. ", 1)
754
+ ])
755
+ ])),
756
+ s(vt, {
757
+ open: E.value,
758
+ "onUpdate:open": e[7] || (e[7] = (_) => E.value = _),
759
+ name: o.name,
760
+ definition: o.definition
761
+ }, null, 8, ["open", "name", "definition"])
762
+ ]);
763
+ };
764
+ }
765
+ });
766
+ export {
767
+ ks as default
768
+ };