@delmaredigital/payload-puck 0.1.0

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 (128) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +1580 -0
  3. package/dist/AccordionClient.d.mts +24 -0
  4. package/dist/AccordionClient.d.ts +24 -0
  5. package/dist/AccordionClient.js +786 -0
  6. package/dist/AccordionClient.js.map +1 -0
  7. package/dist/AccordionClient.mjs +784 -0
  8. package/dist/AccordionClient.mjs.map +1 -0
  9. package/dist/AnimatedWrapper.d.mts +30 -0
  10. package/dist/AnimatedWrapper.d.ts +30 -0
  11. package/dist/AnimatedWrapper.js +379 -0
  12. package/dist/AnimatedWrapper.js.map +1 -0
  13. package/dist/AnimatedWrapper.mjs +377 -0
  14. package/dist/AnimatedWrapper.mjs.map +1 -0
  15. package/dist/admin/client.d.mts +108 -0
  16. package/dist/admin/client.d.ts +108 -0
  17. package/dist/admin/client.js +177 -0
  18. package/dist/admin/client.js.map +1 -0
  19. package/dist/admin/client.mjs +173 -0
  20. package/dist/admin/client.mjs.map +1 -0
  21. package/dist/admin/index.d.mts +157 -0
  22. package/dist/admin/index.d.ts +157 -0
  23. package/dist/admin/index.js +31 -0
  24. package/dist/admin/index.js.map +1 -0
  25. package/dist/admin/index.mjs +29 -0
  26. package/dist/admin/index.mjs.map +1 -0
  27. package/dist/api/index.d.mts +460 -0
  28. package/dist/api/index.d.ts +460 -0
  29. package/dist/api/index.js +588 -0
  30. package/dist/api/index.js.map +1 -0
  31. package/dist/api/index.mjs +578 -0
  32. package/dist/api/index.mjs.map +1 -0
  33. package/dist/components/index.css +339 -0
  34. package/dist/components/index.css.map +1 -0
  35. package/dist/components/index.d.mts +222 -0
  36. package/dist/components/index.d.ts +222 -0
  37. package/dist/components/index.js +9177 -0
  38. package/dist/components/index.js.map +1 -0
  39. package/dist/components/index.mjs +9130 -0
  40. package/dist/components/index.mjs.map +1 -0
  41. package/dist/config/config.editor.css +339 -0
  42. package/dist/config/config.editor.css.map +1 -0
  43. package/dist/config/config.editor.d.mts +153 -0
  44. package/dist/config/config.editor.d.ts +153 -0
  45. package/dist/config/config.editor.js +9400 -0
  46. package/dist/config/config.editor.js.map +1 -0
  47. package/dist/config/config.editor.mjs +9368 -0
  48. package/dist/config/config.editor.mjs.map +1 -0
  49. package/dist/config/index.d.mts +68 -0
  50. package/dist/config/index.d.ts +68 -0
  51. package/dist/config/index.js +2017 -0
  52. package/dist/config/index.js.map +1 -0
  53. package/dist/config/index.mjs +1991 -0
  54. package/dist/config/index.mjs.map +1 -0
  55. package/dist/editor/index.d.mts +784 -0
  56. package/dist/editor/index.d.ts +784 -0
  57. package/dist/editor/index.js +4517 -0
  58. package/dist/editor/index.js.map +1 -0
  59. package/dist/editor/index.mjs +4483 -0
  60. package/dist/editor/index.mjs.map +1 -0
  61. package/dist/fields/index.css +339 -0
  62. package/dist/fields/index.css.map +1 -0
  63. package/dist/fields/index.d.mts +600 -0
  64. package/dist/fields/index.d.ts +600 -0
  65. package/dist/fields/index.js +7739 -0
  66. package/dist/fields/index.js.map +1 -0
  67. package/dist/fields/index.mjs +7590 -0
  68. package/dist/fields/index.mjs.map +1 -0
  69. package/dist/index-CQu6SzDg.d.mts +327 -0
  70. package/dist/index-CoUQnyC3.d.ts +327 -0
  71. package/dist/index.d.mts +6 -0
  72. package/dist/index.d.ts +6 -0
  73. package/dist/index.js +569 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/index.mjs +555 -0
  76. package/dist/index.mjs.map +1 -0
  77. package/dist/layouts/index.d.mts +96 -0
  78. package/dist/layouts/index.d.ts +96 -0
  79. package/dist/layouts/index.js +394 -0
  80. package/dist/layouts/index.js.map +1 -0
  81. package/dist/layouts/index.mjs +378 -0
  82. package/dist/layouts/index.mjs.map +1 -0
  83. package/dist/plugin/index.d.mts +289 -0
  84. package/dist/plugin/index.d.ts +289 -0
  85. package/dist/plugin/index.js +569 -0
  86. package/dist/plugin/index.js.map +1 -0
  87. package/dist/plugin/index.mjs +555 -0
  88. package/dist/plugin/index.mjs.map +1 -0
  89. package/dist/render/index.d.mts +109 -0
  90. package/dist/render/index.d.ts +109 -0
  91. package/dist/render/index.js +2146 -0
  92. package/dist/render/index.js.map +1 -0
  93. package/dist/render/index.mjs +2123 -0
  94. package/dist/render/index.mjs.map +1 -0
  95. package/dist/shared-DMAF1AcH.d.mts +545 -0
  96. package/dist/shared-DMAF1AcH.d.ts +545 -0
  97. package/dist/theme/index.d.mts +155 -0
  98. package/dist/theme/index.d.ts +155 -0
  99. package/dist/theme/index.js +201 -0
  100. package/dist/theme/index.js.map +1 -0
  101. package/dist/theme/index.mjs +186 -0
  102. package/dist/theme/index.mjs.map +1 -0
  103. package/dist/types-D7D3rZ1J.d.mts +116 -0
  104. package/dist/types-D7D3rZ1J.d.ts +116 -0
  105. package/dist/types-_6MvjyKv.d.mts +104 -0
  106. package/dist/types-_6MvjyKv.d.ts +104 -0
  107. package/dist/utils/index.d.mts +267 -0
  108. package/dist/utils/index.d.ts +267 -0
  109. package/dist/utils/index.js +426 -0
  110. package/dist/utils/index.js.map +1 -0
  111. package/dist/utils/index.mjs +412 -0
  112. package/dist/utils/index.mjs.map +1 -0
  113. package/dist/utils-DaRs9t0J.d.mts +85 -0
  114. package/dist/utils-gAvt0Vhw.d.ts +85 -0
  115. package/examples/README.md +240 -0
  116. package/examples/api/puck/pages/[id]/route.ts +64 -0
  117. package/examples/api/puck/pages/[id]/versions/route.ts +47 -0
  118. package/examples/api/puck/pages/route.ts +45 -0
  119. package/examples/app/(frontend)/page.tsx +94 -0
  120. package/examples/app/[...slug]/page.tsx +101 -0
  121. package/examples/app/pages/[id]/edit/page.tsx +148 -0
  122. package/examples/components/CustomBanner.tsx +368 -0
  123. package/examples/config/custom-config.ts +223 -0
  124. package/examples/config/payload.config.example.ts +64 -0
  125. package/examples/lib/puck-layouts.ts +258 -0
  126. package/examples/lib/puck-theme.ts +94 -0
  127. package/examples/styles/puck-theme.css +171 -0
  128. package/package.json +157 -0
@@ -0,0 +1,4517 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var iconsReact = require('@tabler/icons-react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var puck = require('@measured/puck');
10
+ var DialogPrimitive = require('@radix-ui/react-dialog');
11
+ var reactSlot = require('@radix-ui/react-slot');
12
+ var classVarianceAuthority = require('class-variance-authority');
13
+ var LabelPrimitive = require('@radix-ui/react-label');
14
+ var navigation = require('next/navigation');
15
+ require('@measured/puck/puck.css');
16
+ var headingAnalyzer = require('@measured/puck-plugin-heading-analyzer');
17
+ require('@measured/puck-plugin-heading-analyzer/dist/index.css');
18
+ var dynamic = require('next/dynamic');
19
+
20
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
+
22
+ function _interopNamespace(e) {
23
+ if (e && e.__esModule) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n.default = e;
37
+ return Object.freeze(n);
38
+ }
39
+
40
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
41
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
42
+ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
43
+ var headingAnalyzer__default = /*#__PURE__*/_interopDefault(headingAnalyzer);
44
+ var dynamic__default = /*#__PURE__*/_interopDefault(dynamic);
45
+
46
+ var __defProp = Object.defineProperty;
47
+ var __getOwnPropNames = Object.getOwnPropertyNames;
48
+ var __esm = (fn, res) => function __init() {
49
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
50
+ };
51
+ var __export = (target, all) => {
52
+ for (var name in all)
53
+ __defProp(target, name, { get: all[name], enumerable: true });
54
+ };
55
+ function LoadingState({ message = "Loading editor..." }) {
56
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center bg-gray-50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
57
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconLoader2, { className: "h-8 w-8 animate-spin text-gray-600 mx-auto mb-4" }),
58
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600", children: message })
59
+ ] }) });
60
+ }
61
+ var init_LoadingState = __esm({
62
+ "src/editor/components/LoadingState.tsx"() {
63
+ "use client";
64
+ }
65
+ });
66
+ exports.VersionHistory = void 0;
67
+ var init_VersionHistory = __esm({
68
+ "src/editor/components/VersionHistory.tsx"() {
69
+ "use client";
70
+ exports.VersionHistory = React.memo(function VersionHistory2({
71
+ pageId,
72
+ apiEndpoint = "/api/puck/pages",
73
+ onRestore,
74
+ disabled
75
+ }) {
76
+ const [isOpen, setIsOpen] = React.useState(false);
77
+ const [isLoading, setIsLoading] = React.useState(false);
78
+ const [isRestoring, setIsRestoring] = React.useState(false);
79
+ const [versions, setVersions] = React.useState([]);
80
+ const [error, setError] = React.useState(null);
81
+ const [isAvailable, setIsAvailable] = React.useState(null);
82
+ const dropdownRef = React.useRef(null);
83
+ React.useEffect(() => {
84
+ async function checkAvailability() {
85
+ try {
86
+ const response = await fetch(`${apiEndpoint}/${pageId}/versions?limit=1`, {
87
+ method: "GET"
88
+ });
89
+ setIsAvailable(response.status !== 404);
90
+ } catch {
91
+ setIsAvailable(false);
92
+ }
93
+ }
94
+ checkAvailability();
95
+ }, [apiEndpoint, pageId]);
96
+ React.useEffect(() => {
97
+ function handleClickOutside(event) {
98
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
99
+ setIsOpen(false);
100
+ }
101
+ }
102
+ document.addEventListener("mousedown", handleClickOutside);
103
+ return () => document.removeEventListener("mousedown", handleClickOutside);
104
+ }, []);
105
+ const fetchVersions = React.useCallback(async () => {
106
+ setIsLoading(true);
107
+ setError(null);
108
+ try {
109
+ const response = await fetch(`${apiEndpoint}/${pageId}/versions?limit=20`);
110
+ if (!response.ok) {
111
+ throw new Error("Failed to fetch versions");
112
+ }
113
+ const data = await response.json();
114
+ setVersions(data.docs || []);
115
+ } catch (err) {
116
+ setError(err instanceof Error ? err.message : "Failed to load versions");
117
+ console.error("Error fetching versions:", err);
118
+ } finally {
119
+ setIsLoading(false);
120
+ }
121
+ }, [apiEndpoint, pageId]);
122
+ React.useEffect(() => {
123
+ if (isOpen) {
124
+ fetchVersions();
125
+ }
126
+ }, [isOpen, fetchVersions]);
127
+ const handleRestore = React.useCallback(
128
+ async (version) => {
129
+ if (!confirm(`Restore this version from ${formatDate(version.updatedAt)}? This will overwrite current changes.`)) {
130
+ return;
131
+ }
132
+ setIsRestoring(true);
133
+ try {
134
+ const response = await fetch(`${apiEndpoint}/${pageId}/versions`, {
135
+ method: "POST",
136
+ headers: { "Content-Type": "application/json" },
137
+ body: JSON.stringify({ versionId: version.id })
138
+ });
139
+ if (!response.ok) {
140
+ throw new Error("Failed to restore version");
141
+ }
142
+ onRestore?.(version);
143
+ setIsOpen(false);
144
+ window.location.reload();
145
+ } catch (err) {
146
+ setError(err instanceof Error ? err.message : "Failed to restore version");
147
+ console.error("Error restoring version:", err);
148
+ } finally {
149
+ setIsRestoring(false);
150
+ }
151
+ },
152
+ [apiEndpoint, pageId, onRestore]
153
+ );
154
+ function formatDate(dateStr) {
155
+ const date = new Date(dateStr);
156
+ const now = /* @__PURE__ */ new Date();
157
+ const diffMs = now.getTime() - date.getTime();
158
+ const diffMins = Math.floor(diffMs / 6e4);
159
+ const diffHours = Math.floor(diffMs / 36e5);
160
+ const diffDays = Math.floor(diffMs / 864e5);
161
+ if (diffMins < 1) return "Just now";
162
+ if (diffMins < 60) return `${diffMins}m ago`;
163
+ if (diffHours < 24) return `${diffHours}h ago`;
164
+ if (diffDays < 7) return `${diffDays}d ago`;
165
+ return date.toLocaleDateString();
166
+ }
167
+ function formatTime(dateStr) {
168
+ const date = new Date(dateStr);
169
+ return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
170
+ }
171
+ if (isAvailable !== true) {
172
+ return null;
173
+ }
174
+ const baseBtn = "inline-flex items-center whitespace-nowrap px-3 py-1.5 text-sm font-medium rounded-md transition-colors";
175
+ const secondaryBtn = `${baseBtn} text-gray-700 bg-white border border-gray-300 hover:bg-gray-100`;
176
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: dropdownRef, className: "relative", children: [
177
+ /* @__PURE__ */ jsxRuntime.jsxs(
178
+ "button",
179
+ {
180
+ type: "button",
181
+ onClick: () => setIsOpen(!isOpen),
182
+ disabled,
183
+ className: `${secondaryBtn} disabled:opacity-50 disabled:cursor-not-allowed`,
184
+ children: [
185
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconHistory, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
186
+ "History",
187
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconChevronDown, { className: "h-3 w-3 ml-1 flex-shrink-0" })
188
+ ]
189
+ }
190
+ ),
191
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
192
+ "div",
193
+ {
194
+ className: "absolute top-full right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-[400px] overflow-hidden",
195
+ children: [
196
+ /* @__PURE__ */ jsxRuntime.jsxs(
197
+ "div",
198
+ {
199
+ className: "border-b border-gray-200 flex items-center justify-between px-4 py-3",
200
+ children: [
201
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-sm text-gray-900", children: "Version History" }),
202
+ /* @__PURE__ */ jsxRuntime.jsx(
203
+ "button",
204
+ {
205
+ type: "button",
206
+ onClick: () => setIsOpen(false),
207
+ className: "text-gray-400 hover:text-gray-600 transition-colors p-1",
208
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" })
209
+ }
210
+ )
211
+ ]
212
+ }
213
+ ),
214
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-[340px] overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(
215
+ "div",
216
+ {
217
+ className: "flex items-center justify-center p-8",
218
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconLoader2, { className: "h-5 w-5 animate-spin text-gray-400" })
219
+ }
220
+ ) : error ? /* @__PURE__ */ jsxRuntime.jsx(
221
+ "div",
222
+ {
223
+ className: "text-sm text-red-600 p-4 text-center",
224
+ children: error
225
+ }
226
+ ) : versions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
227
+ "div",
228
+ {
229
+ className: "text-sm text-gray-500 p-4 text-center",
230
+ children: "No version history available"
231
+ }
232
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", children: versions.map((version, index) => /* @__PURE__ */ jsxRuntime.jsxs(
233
+ "div",
234
+ {
235
+ className: "hover:bg-gray-50 rounded-md transition-colors flex items-center justify-between px-3 py-2.5 gap-3",
236
+ children: [
237
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
238
+ /* @__PURE__ */ jsxRuntime.jsxs(
239
+ "div",
240
+ {
241
+ className: "flex items-center gap-2",
242
+ children: [
243
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-gray-900", children: formatDate(version.updatedAt) }),
244
+ index === 0 && /* @__PURE__ */ jsxRuntime.jsx(
245
+ "span",
246
+ {
247
+ className: "text-xs font-medium rounded-full px-2 py-0.5 bg-blue-100 text-blue-700",
248
+ children: "Current"
249
+ }
250
+ ),
251
+ version.version._status === "published" && /* @__PURE__ */ jsxRuntime.jsx(
252
+ "span",
253
+ {
254
+ className: "text-xs font-medium rounded-full px-2 py-0.5 bg-green-100 text-green-700",
255
+ children: "Published"
256
+ }
257
+ ),
258
+ version.autosave && /* @__PURE__ */ jsxRuntime.jsx(
259
+ "span",
260
+ {
261
+ className: "text-xs text-gray-400",
262
+ title: "Autosaved",
263
+ children: "(auto)"
264
+ }
265
+ )
266
+ ]
267
+ }
268
+ ),
269
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-500 mt-0.5", children: [
270
+ formatTime(version.updatedAt),
271
+ version.version.title && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
272
+ " \xB7 ",
273
+ version.version.title
274
+ ] })
275
+ ] })
276
+ ] }),
277
+ index > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
278
+ "button",
279
+ {
280
+ type: "button",
281
+ onClick: () => handleRestore(version),
282
+ disabled: isRestoring,
283
+ className: "text-xs font-medium text-blue-600 hover:text-blue-800 transition-colors disabled:opacity-50 flex items-center gap-1 px-2 py-1 flex-shrink-0",
284
+ children: [
285
+ isRestoring ? /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconLoader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconRotate, { className: "h-3 w-3" }),
286
+ "Restore"
287
+ ]
288
+ }
289
+ ),
290
+ index === 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconCheck, { className: "h-4 w-4" }) })
291
+ ]
292
+ },
293
+ version.id
294
+ )) }) })
295
+ ]
296
+ }
297
+ )
298
+ ] });
299
+ });
300
+ }
301
+ });
302
+ function cn(...inputs) {
303
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
304
+ }
305
+ var init_utils = __esm({
306
+ "src/lib/utils.ts"() {
307
+ }
308
+ });
309
+ var usePuck; exports.HeaderActions = void 0;
310
+ var init_HeaderActions = __esm({
311
+ "src/editor/components/HeaderActions.tsx"() {
312
+ "use client";
313
+ init_VersionHistory();
314
+ init_utils();
315
+ usePuck = puck.createUsePuck();
316
+ exports.HeaderActions = React.memo(function HeaderActions2({
317
+ children,
318
+ onBack,
319
+ onPreview,
320
+ onSave,
321
+ onPublish,
322
+ isSaving,
323
+ hasUnsavedChanges,
324
+ lastSaved,
325
+ documentStatus,
326
+ wasPublished,
327
+ actionsStart,
328
+ actionsEnd,
329
+ showSaveDraft = true,
330
+ showViewPage = true,
331
+ showInteractiveToggle = false,
332
+ showPreviewButton = true,
333
+ onOpenPreview,
334
+ showVersionHistory = true,
335
+ pageId,
336
+ apiEndpoint = "/api/puck/pages",
337
+ saveError,
338
+ onDismissError
339
+ }) {
340
+ const appState = usePuck((s) => s.appState);
341
+ const dispatch = usePuck((s) => s.dispatch);
342
+ const isInteractive = appState.ui.previewMode === "interactive";
343
+ const togglePreviewMode = React.useCallback(() => {
344
+ dispatch({
345
+ type: "setUi",
346
+ ui: {
347
+ previewMode: isInteractive ? "edit" : "interactive"
348
+ }
349
+ });
350
+ }, [dispatch, isInteractive]);
351
+ const handleSaveClick = React.useCallback(() => {
352
+ onSave(appState.data);
353
+ }, [onSave, appState.data]);
354
+ const handlePublishClick = React.useCallback(() => {
355
+ if (onPublish) {
356
+ onPublish(appState.data);
357
+ }
358
+ }, [onPublish, appState.data]);
359
+ const btnBase = "inline-flex items-center whitespace-nowrap text-sm font-medium rounded-md transition-colors";
360
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
361
+ actionsStart,
362
+ /* @__PURE__ */ jsxRuntime.jsxs(
363
+ "button",
364
+ {
365
+ type: "button",
366
+ onClick: onBack,
367
+ className: cn(btnBase, "px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50"),
368
+ children: [
369
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconArrowLeft, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
370
+ "Back"
371
+ ]
372
+ }
373
+ ),
374
+ documentStatus && (() => {
375
+ const isPublished = documentStatus === "published";
376
+ const hasUnpublishedChanges = documentStatus === "draft" && wasPublished;
377
+ let badgeLabel;
378
+ if (isPublished) {
379
+ badgeLabel = "Published";
380
+ } else if (hasUnpublishedChanges) {
381
+ badgeLabel = "Unpublished Changes";
382
+ } else {
383
+ badgeLabel = "Draft";
384
+ }
385
+ return /* @__PURE__ */ jsxRuntime.jsx(
386
+ "span",
387
+ {
388
+ className: cn(
389
+ "px-2.5 py-1 border rounded-full text-xs font-medium whitespace-nowrap",
390
+ isPublished && "bg-green-100 text-green-800 border-green-300",
391
+ hasUnpublishedChanges && "bg-orange-100 text-orange-700 border-orange-200",
392
+ !isPublished && !hasUnpublishedChanges && "bg-amber-100 text-amber-700 border-amber-200"
393
+ ),
394
+ children: badgeLabel
395
+ }
396
+ );
397
+ })(),
398
+ showInteractiveToggle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
399
+ /* @__PURE__ */ jsxRuntime.jsxs(
400
+ "button",
401
+ {
402
+ type: "button",
403
+ onClick: () => isInteractive && togglePreviewMode(),
404
+ className: cn(
405
+ "inline-flex items-center gap-1 text-xs font-medium rounded transition-colors px-2.5 py-1.5 border",
406
+ !isInteractive ? "bg-blue-500 text-white border-blue-500" : "bg-gray-100 text-gray-500 border-gray-200"
407
+ ),
408
+ children: [
409
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconPointer, { className: "h-3.5 w-3.5" }),
410
+ "Edit"
411
+ ]
412
+ }
413
+ ),
414
+ /* @__PURE__ */ jsxRuntime.jsxs(
415
+ "button",
416
+ {
417
+ type: "button",
418
+ onClick: () => !isInteractive && togglePreviewMode(),
419
+ className: cn(
420
+ "inline-flex items-center gap-1 text-xs font-medium rounded transition-colors px-2.5 py-1.5 border",
421
+ isInteractive ? "bg-blue-500 text-white border-blue-500" : "bg-gray-100 text-gray-500 border-gray-200"
422
+ ),
423
+ children: [
424
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconHandClick, { className: "h-3.5 w-3.5" }),
425
+ "Interactive"
426
+ ]
427
+ }
428
+ )
429
+ ] }),
430
+ lastSaved && !saveError && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-500 flex items-center gap-1 whitespace-nowrap", children: [
431
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconCheck, { className: "h-3 w-3 flex-shrink-0" }),
432
+ "Saved ",
433
+ lastSaved.toLocaleTimeString()
434
+ ] }),
435
+ hasUnsavedChanges && !saveError && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-amber-600 font-medium whitespace-nowrap", children: "Unsaved" }),
436
+ saveError && /* @__PURE__ */ jsxRuntime.jsxs(
437
+ "button",
438
+ {
439
+ type: "button",
440
+ onClick: () => {
441
+ },
442
+ className: "flex items-center gap-1.5 px-2.5 py-1.5 bg-red-50 border border-red-200 rounded-md text-red-700 text-xs font-medium",
443
+ children: [
444
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconAlertTriangle, { className: "h-4 w-4 text-red-500 flex-shrink-0" }),
445
+ "Error"
446
+ ]
447
+ }
448
+ ),
449
+ saveError && /* @__PURE__ */ jsxRuntime.jsx(
450
+ "div",
451
+ {
452
+ className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/50",
453
+ onClick: onDismissError,
454
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
455
+ "div",
456
+ {
457
+ className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 overflow-hidden",
458
+ onClick: (e) => e.stopPropagation(),
459
+ children: [
460
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-5 py-4 border-b border-gray-200 bg-red-50", children: [
461
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconAlertTriangle, { className: "h-5 w-5 text-red-600" }) }),
462
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
463
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-base font-semibold text-gray-900", children: "Save Failed" }),
464
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500", children: "Unable to save your changes" })
465
+ ] })
466
+ ] }),
467
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-700", children: saveError }) }),
468
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-4 bg-gray-50 border-t border-gray-200 flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
469
+ "button",
470
+ {
471
+ type: "button",
472
+ onClick: onDismissError,
473
+ className: "px-4 py-2 bg-gray-900 text-white text-sm font-medium rounded-md hover:bg-gray-800 transition-colors",
474
+ children: "Close"
475
+ }
476
+ ) })
477
+ ]
478
+ }
479
+ )
480
+ }
481
+ ),
482
+ showPreviewButton && onOpenPreview && /* @__PURE__ */ jsxRuntime.jsxs(
483
+ "button",
484
+ {
485
+ type: "button",
486
+ onClick: onOpenPreview,
487
+ disabled: isSaving,
488
+ className: cn(
489
+ btnBase,
490
+ "px-3 py-1.5 bg-blue-600 text-white border border-blue-600 rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
491
+ ),
492
+ children: [
493
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconEye, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
494
+ "Preview"
495
+ ]
496
+ }
497
+ ),
498
+ showViewPage && /* @__PURE__ */ jsxRuntime.jsxs(
499
+ "button",
500
+ {
501
+ type: "button",
502
+ onClick: onPreview,
503
+ className: cn(btnBase, "px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50"),
504
+ children: [
505
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconExternalLink, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
506
+ "View"
507
+ ]
508
+ }
509
+ ),
510
+ showVersionHistory && pageId && /* @__PURE__ */ jsxRuntime.jsx(
511
+ exports.VersionHistory,
512
+ {
513
+ pageId,
514
+ apiEndpoint,
515
+ disabled: isSaving
516
+ }
517
+ ),
518
+ showSaveDraft && /* @__PURE__ */ jsxRuntime.jsxs(
519
+ "button",
520
+ {
521
+ type: "button",
522
+ onClick: handleSaveClick,
523
+ disabled: isSaving || !hasUnsavedChanges,
524
+ className: cn(
525
+ btnBase,
526
+ "px-3 py-1.5 bg-white text-gray-700 border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
527
+ ),
528
+ children: [
529
+ isSaving ? /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconLoader2, { className: "h-4 w-4 mr-1 flex-shrink-0 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconDeviceFloppy, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
530
+ "Save"
531
+ ]
532
+ }
533
+ ),
534
+ onPublish && /* @__PURE__ */ jsxRuntime.jsxs(
535
+ "button",
536
+ {
537
+ type: "button",
538
+ onClick: handlePublishClick,
539
+ disabled: isSaving,
540
+ className: cn(
541
+ btnBase,
542
+ "px-3 py-1.5 bg-blue-600 text-white border border-blue-600 rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
543
+ ),
544
+ children: [
545
+ isSaving ? /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconLoader2, { className: "h-4 w-4 mr-1 flex-shrink-0 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconUpload, { className: "h-4 w-4 mr-1 flex-shrink-0" }),
546
+ "Publish"
547
+ ]
548
+ }
549
+ ),
550
+ actionsEnd,
551
+ !onPublish && children
552
+ ] });
553
+ });
554
+ }
555
+ });
556
+
557
+ // src/fields/shared.ts
558
+ function cn2(...classes) {
559
+ return classes.filter(Boolean).join(" ");
560
+ }
561
+ function isLegacyWidthValue(value) {
562
+ if (!value || typeof value !== "object") return false;
563
+ const v = value;
564
+ return typeof v.maxWidth === "number" && typeof v.unit === "string" && typeof v.mode === "string" && !("minWidth" in v) && !("minHeight" in v) && !("maxHeight" in v);
565
+ }
566
+ function hexToRgb(hex) {
567
+ const clean = hex.replace(/^#/, "");
568
+ if (clean.length !== 6) return null;
569
+ const r = parseInt(clean.substring(0, 2), 16);
570
+ const g = parseInt(clean.substring(2, 4), 16);
571
+ const b = parseInt(clean.substring(4, 6), 16);
572
+ if (isNaN(r) || isNaN(g) || isNaN(b)) return null;
573
+ return { r, g, b };
574
+ }
575
+ function colorValueToCSS(color) {
576
+ if (!color?.hex) return void 0;
577
+ const rgb = hexToRgb(color.hex);
578
+ if (!rgb) return color.hex;
579
+ const opacity = (color.opacity ?? 100) / 100;
580
+ if (opacity === 1) {
581
+ return color.hex;
582
+ }
583
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
584
+ }
585
+ function paddingValueToCSS(padding) {
586
+ if (!padding) return void 0;
587
+ const { top, right, bottom, left, unit } = padding;
588
+ if (top === right && right === bottom && bottom === left) {
589
+ return `${top}${unit}`;
590
+ }
591
+ if (top === bottom && left === right) {
592
+ return `${top}${unit} ${right}${unit}`;
593
+ }
594
+ if (left === right) {
595
+ return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
596
+ }
597
+ return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
598
+ }
599
+ function marginValueToCSS(margin) {
600
+ if (!margin) return void 0;
601
+ const { top, right, bottom, left, unit } = margin;
602
+ if (top === right && right === bottom && bottom === left) {
603
+ return `${top}${unit}`;
604
+ }
605
+ if (top === bottom && left === right) {
606
+ return `${top}${unit} ${right}${unit}`;
607
+ }
608
+ if (left === right) {
609
+ return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
610
+ }
611
+ return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
612
+ }
613
+ function borderValueToCSS(border) {
614
+ if (!border || border.style === "none") return void 0;
615
+ const color = colorValueToCSS(border.color) || "#000000";
616
+ const style = {};
617
+ if (border.sides.top) {
618
+ style.borderTopWidth = `${border.width}px`;
619
+ style.borderTopStyle = border.style;
620
+ style.borderTopColor = color;
621
+ }
622
+ if (border.sides.right) {
623
+ style.borderRightWidth = `${border.width}px`;
624
+ style.borderRightStyle = border.style;
625
+ style.borderRightColor = color;
626
+ }
627
+ if (border.sides.bottom) {
628
+ style.borderBottomWidth = `${border.width}px`;
629
+ style.borderBottomStyle = border.style;
630
+ style.borderBottomColor = color;
631
+ }
632
+ if (border.sides.left) {
633
+ style.borderLeftWidth = `${border.width}px`;
634
+ style.borderLeftStyle = border.style;
635
+ style.borderLeftColor = color;
636
+ }
637
+ if (border.radius > 0) {
638
+ style.borderRadius = `${border.radius}px`;
639
+ }
640
+ return Object.keys(style).length > 0 ? style : void 0;
641
+ }
642
+ function widthValueToCSS(width) {
643
+ if (!width) return void 0;
644
+ const style = {};
645
+ if (width.mode === "full") {
646
+ style.width = "100%";
647
+ style.maxWidth = "100%";
648
+ } else {
649
+ style.maxWidth = `${width.maxWidth}${width.unit}`;
650
+ style.width = "100%";
651
+ }
652
+ switch (width.alignment) {
653
+ case "left":
654
+ style.marginLeft = "0";
655
+ style.marginRight = "auto";
656
+ break;
657
+ case "center":
658
+ style.marginLeft = "auto";
659
+ style.marginRight = "auto";
660
+ break;
661
+ case "right":
662
+ style.marginLeft = "auto";
663
+ style.marginRight = "0";
664
+ break;
665
+ }
666
+ return style;
667
+ }
668
+ function dimensionsValueToCSS(dimensions) {
669
+ if (!dimensions) return void 0;
670
+ if (isLegacyWidthValue(dimensions)) {
671
+ return widthValueToCSS(dimensions);
672
+ }
673
+ const dim = dimensions;
674
+ const style = {};
675
+ if (dim.mode === "full") {
676
+ style.width = "100%";
677
+ style.maxWidth = "100%";
678
+ } else {
679
+ style.width = "100%";
680
+ if (dim.maxWidth?.enabled !== false && dim.maxWidth?.value > 0) {
681
+ style.maxWidth = `${dim.maxWidth.value}${dim.maxWidth.unit}`;
682
+ }
683
+ if (dim.minWidth?.enabled && dim.minWidth.value > 0) {
684
+ style.minWidth = `${dim.minWidth.value}${dim.minWidth.unit}`;
685
+ }
686
+ }
687
+ if (dim.minHeight?.enabled && dim.minHeight.value > 0) {
688
+ style.minHeight = `${dim.minHeight.value}${dim.minHeight.unit}`;
689
+ }
690
+ if (dim.maxHeight?.enabled && dim.maxHeight.value > 0) {
691
+ style.maxHeight = `${dim.maxHeight.value}${dim.maxHeight.unit}`;
692
+ }
693
+ switch (dim.alignment) {
694
+ case "left":
695
+ style.marginLeft = "0";
696
+ style.marginRight = "auto";
697
+ break;
698
+ case "center":
699
+ style.marginLeft = "auto";
700
+ style.marginRight = "auto";
701
+ break;
702
+ case "right":
703
+ style.marginLeft = "auto";
704
+ style.marginRight = "0";
705
+ break;
706
+ }
707
+ return style;
708
+ }
709
+ function gradientValueToCSS(gradient) {
710
+ if (!gradient?.stops || gradient.stops.length === 0) {
711
+ return "transparent";
712
+ }
713
+ const sortedStops = [...gradient.stops].sort((a, b) => a.position - b.position);
714
+ const stopsCSS = sortedStops.map((stop) => {
715
+ const color = colorValueToCSS(stop.color) || "transparent";
716
+ return `${color} ${stop.position}%`;
717
+ }).join(", ");
718
+ if (gradient.type === "radial") {
719
+ const shape = gradient.radialShape || "circle";
720
+ const position = gradient.radialPosition || "center";
721
+ return `radial-gradient(${shape} at ${position}, ${stopsCSS})`;
722
+ }
723
+ return `linear-gradient(${gradient.angle}deg, ${stopsCSS})`;
724
+ }
725
+ function positionToCSS(position) {
726
+ const positionMap = {
727
+ center: "center",
728
+ top: "top",
729
+ bottom: "bottom",
730
+ left: "left",
731
+ right: "right",
732
+ "top-left": "top left",
733
+ "top-right": "top right",
734
+ "bottom-left": "bottom left",
735
+ "bottom-right": "bottom right"
736
+ };
737
+ return position ? positionMap[position] || "center" : "center";
738
+ }
739
+ function maskDirectionToCSS(direction) {
740
+ const directionMap = {
741
+ "to-top": "to top",
742
+ "to-bottom": "to bottom",
743
+ "to-left": "to left",
744
+ "to-right": "to right",
745
+ "to-top-left": "to top left",
746
+ "to-top-right": "to top right",
747
+ "to-bottom-left": "to bottom left",
748
+ "to-bottom-right": "to bottom right",
749
+ "from-center": "radial"
750
+ // Not used for linear, handled separately in maskToCSS
751
+ };
752
+ return directionMap[direction] || "to bottom";
753
+ }
754
+ function maskToCSS(mask) {
755
+ const startAlpha = (mask.startOpacity ?? 100) / 100;
756
+ const endAlpha = (mask.endOpacity ?? 0) / 100;
757
+ if (mask.direction === "from-center") {
758
+ return `radial-gradient(circle at center, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
759
+ }
760
+ const direction = maskDirectionToCSS(mask.direction);
761
+ return `linear-gradient(${direction}, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
762
+ }
763
+ function backgroundValueToCSS(bg) {
764
+ if (!bg || bg.type === "none") {
765
+ return {};
766
+ }
767
+ const style = {};
768
+ switch (bg.type) {
769
+ case "solid":
770
+ if (bg.solid?.hex) {
771
+ style.backgroundColor = colorValueToCSS(bg.solid);
772
+ }
773
+ break;
774
+ case "gradient":
775
+ if (bg.gradient && bg.gradient.stops && bg.gradient.stops.length > 0) {
776
+ style.background = gradientValueToCSS(bg.gradient);
777
+ }
778
+ break;
779
+ case "image":
780
+ if (bg.image?.media?.url) {
781
+ const imageUrl = bg.image.media.url;
782
+ const size = bg.image.size || "cover";
783
+ const position = positionToCSS(bg.image.position);
784
+ const repeat = bg.image.repeat || "no-repeat";
785
+ const attachment = bg.image.attachment || "scroll";
786
+ if (bg.overlay?.enabled) {
787
+ const overlayCSS = bg.overlay.type === "solid" ? colorValueToCSS(bg.overlay.solid) : gradientValueToCSS(bg.overlay.gradient);
788
+ if (bg.overlay.type === "solid" && overlayCSS) {
789
+ style.backgroundImage = `linear-gradient(${overlayCSS}, ${overlayCSS}), url(${imageUrl})`;
790
+ } else {
791
+ style.backgroundImage = `${overlayCSS}, url(${imageUrl})`;
792
+ }
793
+ style.backgroundSize = `auto, ${size}`;
794
+ style.backgroundPosition = `center, ${position}`;
795
+ style.backgroundRepeat = `no-repeat, ${repeat}`;
796
+ style.backgroundAttachment = `scroll, ${attachment}`;
797
+ } else {
798
+ style.backgroundImage = `url(${imageUrl})`;
799
+ style.backgroundSize = size;
800
+ style.backgroundPosition = position;
801
+ style.backgroundRepeat = repeat;
802
+ style.backgroundAttachment = attachment;
803
+ }
804
+ if (bg.image.mask?.enabled) {
805
+ const maskCSS = maskToCSS(bg.image.mask);
806
+ style.maskImage = maskCSS;
807
+ style.WebkitMaskImage = maskCSS;
808
+ }
809
+ }
810
+ break;
811
+ }
812
+ return style;
813
+ }
814
+ function transformOriginToCSS(origin) {
815
+ const originMap = {
816
+ center: "center",
817
+ top: "top",
818
+ bottom: "bottom",
819
+ left: "left",
820
+ right: "right",
821
+ "top-left": "top left",
822
+ "top-right": "top right",
823
+ "bottom-left": "bottom left",
824
+ "bottom-right": "bottom right"
825
+ };
826
+ return originMap[origin] || "center";
827
+ }
828
+ function transformValueToCSS(transform) {
829
+ if (!transform) return void 0;
830
+ const style = {};
831
+ const transforms = [];
832
+ if (transform.enable3D && transform.perspective) {
833
+ style.perspective = `${transform.perspective}px`;
834
+ }
835
+ if (transform.translateX !== 0 || transform.translateY !== 0) {
836
+ transforms.push(
837
+ `translate(${transform.translateX}${transform.translateUnit}, ${transform.translateY}${transform.translateUnit})`
838
+ );
839
+ }
840
+ if (transform.rotate !== 0) {
841
+ transforms.push(`rotate(${transform.rotate}deg)`);
842
+ }
843
+ if (transform.enable3D) {
844
+ if (transform.rotateX && transform.rotateX !== 0) {
845
+ transforms.push(`rotateX(${transform.rotateX}deg)`);
846
+ }
847
+ if (transform.rotateY && transform.rotateY !== 0) {
848
+ transforms.push(`rotateY(${transform.rotateY}deg)`);
849
+ }
850
+ }
851
+ if (transform.scaleX !== 1 || transform.scaleY !== 1) {
852
+ if (transform.scaleX === transform.scaleY) {
853
+ transforms.push(`scale(${transform.scaleX})`);
854
+ } else {
855
+ transforms.push(`scale(${transform.scaleX}, ${transform.scaleY})`);
856
+ }
857
+ }
858
+ if (transform.skewX !== 0 || transform.skewY !== 0) {
859
+ if (transform.skewX !== 0 && transform.skewY !== 0) {
860
+ transforms.push(`skew(${transform.skewX}deg, ${transform.skewY}deg)`);
861
+ } else if (transform.skewX !== 0) {
862
+ transforms.push(`skewX(${transform.skewX}deg)`);
863
+ } else {
864
+ transforms.push(`skewY(${transform.skewY}deg)`);
865
+ }
866
+ }
867
+ if (transforms.length > 0) {
868
+ style.transform = transforms.join(" ");
869
+ }
870
+ if (transform.origin !== "center") {
871
+ style.transformOrigin = transformOriginToCSS(transform.origin);
872
+ }
873
+ if (transform.enable3D) {
874
+ style.transformStyle = "preserve-3d";
875
+ }
876
+ return Object.keys(style).length > 0 ? style : void 0;
877
+ }
878
+ function isResponsiveValue(value) {
879
+ if (!value || typeof value !== "object") return false;
880
+ return "base" in value;
881
+ }
882
+ function camelToKebab(str) {
883
+ return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
884
+ }
885
+ function cssPropertiesToString(styles) {
886
+ return Object.entries(styles).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${camelToKebab(key)}: ${value}`).join("; ");
887
+ }
888
+ function responsiveValueToCSS(value, converter, uniqueId) {
889
+ if (value === null || value === void 0) {
890
+ return { baseStyles: {}, mediaQueryCSS: "" };
891
+ }
892
+ if (!isResponsiveValue(value)) {
893
+ const styles = converter(value);
894
+ return {
895
+ baseStyles: styles || {},
896
+ mediaQueryCSS: ""
897
+ };
898
+ }
899
+ const mediaQueries = [];
900
+ let baseStyles = {};
901
+ BREAKPOINTS.forEach((bp) => {
902
+ const bpValue = value[bp.key];
903
+ if (bpValue === void 0) return;
904
+ const cssProps = converter(bpValue);
905
+ if (!cssProps) return;
906
+ if (bp.key === "base") {
907
+ baseStyles = cssProps;
908
+ } else {
909
+ const styleString = cssPropertiesToString(cssProps);
910
+ if (styleString) {
911
+ mediaQueries.push(
912
+ `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
913
+ );
914
+ }
915
+ }
916
+ });
917
+ return { baseStyles, mediaQueryCSS: mediaQueries.join("\n") };
918
+ }
919
+ function visibilityValueToCSS(visibility, uniqueId) {
920
+ if (!visibility) return "";
921
+ const mediaQueries = [];
922
+ if (visibility.base === false) {
923
+ mediaQueries.push(`.${uniqueId} { display: none; }`);
924
+ }
925
+ let lastVisibility = visibility.base;
926
+ BREAKPOINTS.slice(1).forEach((bp) => {
927
+ const bpValue = visibility[bp.key];
928
+ if (bpValue === void 0) return;
929
+ if (bpValue !== lastVisibility) {
930
+ if (bpValue === false) {
931
+ mediaQueries.push(
932
+ `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: none; } }`
933
+ );
934
+ } else {
935
+ mediaQueries.push(
936
+ `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: block; } }`
937
+ );
938
+ }
939
+ lastVisibility = bpValue;
940
+ }
941
+ });
942
+ return mediaQueries.join("\n");
943
+ }
944
+ function animationOriginToCSS(origin) {
945
+ if (!origin) return "center";
946
+ const originMap = {
947
+ center: "center",
948
+ top: "top",
949
+ bottom: "bottom",
950
+ left: "left",
951
+ right: "right",
952
+ "top-left": "top left",
953
+ "top-right": "top right",
954
+ "bottom-left": "bottom left",
955
+ "bottom-right": "bottom right"
956
+ };
957
+ return originMap[origin] || "center";
958
+ }
959
+ function animationValueToCSS(anim) {
960
+ if (!anim || anim.mode !== "custom") return void 0;
961
+ const duration = anim.duration ?? 300;
962
+ const delay = anim.delay ?? 0;
963
+ const easing = anim.easing ?? "ease";
964
+ const easingCSS = EASING_CSS_MAP[easing] || "ease";
965
+ return {
966
+ transition: `all ${duration}ms ${easingCSS} ${delay}ms`,
967
+ transitionProperty: "opacity, transform, filter, background-color, color, border-color, box-shadow"
968
+ };
969
+ }
970
+ function getEntranceAnimationStyles(anim) {
971
+ const defaultResult = {
972
+ initial: {},
973
+ animate: {},
974
+ duration: 500,
975
+ delay: 0,
976
+ easing: "ease",
977
+ origin: "center"
978
+ };
979
+ if (!anim || anim.mode !== "preset" || anim.entrance === "none") {
980
+ return defaultResult;
981
+ }
982
+ const duration = anim.entranceDuration ?? 500;
983
+ const delay = anim.entranceDelay ?? 0;
984
+ const easing = EASING_CSS_MAP[anim.easing ?? "ease"] || "ease";
985
+ const origin = animationOriginToCSS(anim.origin);
986
+ const distance = anim.distance ?? 24;
987
+ const scaleFrom = anim.scaleFrom ?? 0.9;
988
+ const rotateAngle = anim.rotateAngle ?? 15;
989
+ const blurAmount = anim.blurAmount ?? 8;
990
+ const entrance = anim.entrance ?? "none";
991
+ let initial = {};
992
+ let animate = {};
993
+ switch (entrance) {
994
+ // ==================== FADE (6) ====================
995
+ case "fade-in":
996
+ initial = { opacity: 0 };
997
+ animate = { opacity: 1 };
998
+ break;
999
+ case "fade-up":
1000
+ initial = { opacity: 0, transform: `translateY(${distance}px)` };
1001
+ animate = { opacity: 1, transform: "translateY(0)" };
1002
+ break;
1003
+ case "fade-down":
1004
+ initial = { opacity: 0, transform: `translateY(-${distance}px)` };
1005
+ animate = { opacity: 1, transform: "translateY(0)" };
1006
+ break;
1007
+ case "fade-left":
1008
+ initial = { opacity: 0, transform: `translateX(${distance}px)` };
1009
+ animate = { opacity: 1, transform: "translateX(0)" };
1010
+ break;
1011
+ case "fade-right":
1012
+ initial = { opacity: 0, transform: `translateX(-${distance}px)` };
1013
+ animate = { opacity: 1, transform: "translateX(0)" };
1014
+ break;
1015
+ case "fade-scale":
1016
+ initial = { opacity: 0, transform: `scale(${scaleFrom})` };
1017
+ animate = { opacity: 1, transform: "scale(1)" };
1018
+ break;
1019
+ // ==================== SCALE (4) ====================
1020
+ case "scale-in":
1021
+ initial = { opacity: 0, transform: `scale(${scaleFrom})` };
1022
+ animate = { opacity: 1, transform: "scale(1)" };
1023
+ break;
1024
+ case "scale-up":
1025
+ initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(${distance}px)` };
1026
+ animate = { opacity: 1, transform: "scale(1) translateY(0)" };
1027
+ break;
1028
+ case "scale-down":
1029
+ initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(-${distance}px)` };
1030
+ animate = { opacity: 1, transform: "scale(1) translateY(0)" };
1031
+ break;
1032
+ case "scale-out":
1033
+ initial = { opacity: 0, transform: `scale(${2 - scaleFrom})` };
1034
+ animate = { opacity: 1, transform: "scale(1)" };
1035
+ break;
1036
+ // ==================== SLIDE (4) ====================
1037
+ case "slide-up":
1038
+ initial = { transform: `translateY(${distance}px)` };
1039
+ animate = { transform: "translateY(0)" };
1040
+ break;
1041
+ case "slide-down":
1042
+ initial = { transform: `translateY(-${distance}px)` };
1043
+ animate = { transform: "translateY(0)" };
1044
+ break;
1045
+ case "slide-left":
1046
+ initial = { transform: `translateX(${distance}px)` };
1047
+ animate = { transform: "translateX(0)" };
1048
+ break;
1049
+ case "slide-right":
1050
+ initial = { transform: `translateX(-${distance}px)` };
1051
+ animate = { transform: "translateX(0)" };
1052
+ break;
1053
+ // ==================== BLUR (3) ====================
1054
+ case "blur-in":
1055
+ initial = { opacity: 0, filter: `blur(${blurAmount}px)` };
1056
+ animate = { opacity: 1, filter: "blur(0)" };
1057
+ break;
1058
+ case "blur-up":
1059
+ initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(${distance}px)` };
1060
+ animate = { opacity: 1, filter: "blur(0)", transform: "translateY(0)" };
1061
+ break;
1062
+ case "blur-down":
1063
+ initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(-${distance}px)` };
1064
+ animate = { opacity: 1, filter: "blur(0)", transform: "translateY(0)" };
1065
+ break;
1066
+ // ==================== ROTATE (3) ====================
1067
+ case "rotate-in":
1068
+ initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) scale(${scaleFrom})` };
1069
+ animate = { opacity: 1, transform: "rotate(0) scale(1)" };
1070
+ break;
1071
+ case "rotate-up":
1072
+ initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) translateY(${distance}px)` };
1073
+ animate = { opacity: 1, transform: "rotate(0) translateY(0)" };
1074
+ break;
1075
+ case "rotate-down":
1076
+ initial = { opacity: 0, transform: `rotate(-${rotateAngle}deg) translateY(-${distance}px)` };
1077
+ animate = { opacity: 1, transform: "rotate(0) translateY(0)" };
1078
+ break;
1079
+ // ==================== BOUNCE (3) ====================
1080
+ // These use spring/bounce easing by default for the effect
1081
+ case "bounce-in":
1082
+ initial = { opacity: 0, transform: `scale(${scaleFrom * 0.8})` };
1083
+ animate = { opacity: 1, transform: "scale(1)" };
1084
+ break;
1085
+ case "bounce-up":
1086
+ initial = { opacity: 0, transform: `translateY(${distance * 1.5}px)` };
1087
+ animate = { opacity: 1, transform: "translateY(0)" };
1088
+ break;
1089
+ case "bounce-down":
1090
+ initial = { opacity: 0, transform: `translateY(-${distance * 1.5}px)` };
1091
+ animate = { opacity: 1, transform: "translateY(0)" };
1092
+ break;
1093
+ // ==================== FLIP (2) ====================
1094
+ // Flip uses perspective in transform for proper 3D effect
1095
+ // Starts from -90deg (tilted back) so the flip motion is visible
1096
+ case "flip-x":
1097
+ initial = {
1098
+ transform: "perspective(1000px) rotateX(-90deg)",
1099
+ opacity: 0.2,
1100
+ backfaceVisibility: "hidden"
1101
+ };
1102
+ animate = {
1103
+ transform: "perspective(1000px) rotateX(0deg)",
1104
+ opacity: 1,
1105
+ backfaceVisibility: "hidden"
1106
+ };
1107
+ break;
1108
+ case "flip-y":
1109
+ initial = {
1110
+ transform: "perspective(1000px) rotateY(-90deg)",
1111
+ opacity: 0.2,
1112
+ backfaceVisibility: "hidden"
1113
+ };
1114
+ animate = {
1115
+ transform: "perspective(1000px) rotateY(0deg)",
1116
+ opacity: 1,
1117
+ backfaceVisibility: "hidden"
1118
+ };
1119
+ break;
1120
+ // ==================== ZOOM (2) ====================
1121
+ case "zoom-in":
1122
+ initial = { opacity: 0, transform: `scale(${scaleFrom * 0.5})` };
1123
+ animate = { opacity: 1, transform: "scale(1)" };
1124
+ break;
1125
+ case "zoom-out":
1126
+ initial = { opacity: 0, transform: `scale(${2.5 - scaleFrom})` };
1127
+ animate = { opacity: 1, transform: "scale(1)" };
1128
+ break;
1129
+ }
1130
+ return {
1131
+ initial,
1132
+ animate,
1133
+ duration,
1134
+ delay,
1135
+ easing,
1136
+ origin
1137
+ };
1138
+ }
1139
+ var alignmentMap, shadowMap, headingLevelMap, textSizeMap, aspectRatioMap, dividerStyleMap, justifyContentMap, alignItemsMap, BREAKPOINTS, EASING_CSS_MAP;
1140
+ var init_shared = __esm({
1141
+ "src/fields/shared.ts"() {
1142
+ alignmentMap = {
1143
+ left: "text-left",
1144
+ center: "text-center",
1145
+ right: "text-right"
1146
+ };
1147
+ shadowMap = {
1148
+ none: "",
1149
+ sm: "shadow-sm",
1150
+ md: "shadow-md",
1151
+ lg: "shadow-lg",
1152
+ xl: "shadow-xl",
1153
+ "2xl": "shadow-2xl"
1154
+ };
1155
+ headingLevelMap = {
1156
+ h1: "text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight",
1157
+ h2: "text-3xl md:text-4xl font-bold tracking-tight",
1158
+ h3: "text-2xl md:text-3xl font-semibold",
1159
+ h4: "text-xl md:text-2xl font-semibold",
1160
+ h5: "text-lg md:text-xl font-medium",
1161
+ h6: "text-base md:text-lg font-medium"
1162
+ };
1163
+ textSizeMap = {
1164
+ xs: "text-xs",
1165
+ sm: "text-sm",
1166
+ base: "text-base",
1167
+ lg: "text-lg",
1168
+ xl: "text-xl",
1169
+ "2xl": "text-2xl"
1170
+ };
1171
+ aspectRatioMap = {
1172
+ auto: "",
1173
+ square: "aspect-square",
1174
+ video: "aspect-video",
1175
+ portrait: "aspect-[3/4]",
1176
+ landscape: "aspect-[4/3]",
1177
+ wide: "aspect-[21/9]"
1178
+ };
1179
+ dividerStyleMap = {
1180
+ solid: "border-solid",
1181
+ dashed: "border-dashed",
1182
+ dotted: "border-dotted"
1183
+ };
1184
+ justifyContentMap = {
1185
+ start: "justify-start",
1186
+ "flex-start": "justify-start",
1187
+ center: "justify-center",
1188
+ end: "justify-end",
1189
+ "flex-end": "justify-end",
1190
+ between: "justify-between",
1191
+ "space-between": "justify-between",
1192
+ around: "justify-around",
1193
+ "space-around": "justify-around",
1194
+ evenly: "justify-evenly",
1195
+ "space-evenly": "justify-evenly"
1196
+ };
1197
+ alignItemsMap = {
1198
+ start: "items-start",
1199
+ "flex-start": "items-start",
1200
+ center: "items-center",
1201
+ end: "items-end",
1202
+ "flex-end": "items-end",
1203
+ stretch: "items-stretch",
1204
+ baseline: "items-baseline"
1205
+ };
1206
+ BREAKPOINTS = [
1207
+ { key: "base", label: "Base", minWidth: null },
1208
+ { key: "sm", label: "SM", minWidth: 640 },
1209
+ { key: "md", label: "MD", minWidth: 768 },
1210
+ { key: "lg", label: "LG", minWidth: 1024 },
1211
+ { key: "xl", label: "XL", minWidth: 1280 }
1212
+ ];
1213
+ EASING_CSS_MAP = {
1214
+ linear: "linear",
1215
+ ease: "ease",
1216
+ "ease-in": "ease-in",
1217
+ "ease-out": "ease-out",
1218
+ "ease-in-out": "ease-in-out",
1219
+ spring: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
1220
+ "spring-gentle": "cubic-bezier(0.34, 1.56, 0.64, 1)",
1221
+ bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
1222
+ "bounce-in": "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
1223
+ "bounce-out": "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
1224
+ "back-in": "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
1225
+ "back-out": "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
1226
+ "back-in-out": "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
1227
+ elastic: "cubic-bezier(0.68, -0.6, 0.32, 1.6)"
1228
+ };
1229
+ }
1230
+ });
1231
+ var usePuck2, DEFAULT_LAYOUT_CONFIG; exports.IframeWrapper = void 0;
1232
+ var init_IframeWrapper = __esm({
1233
+ "src/editor/components/IframeWrapper.tsx"() {
1234
+ "use client";
1235
+ init_shared();
1236
+ usePuck2 = puck.createUsePuck();
1237
+ DEFAULT_LAYOUT_CONFIG = {
1238
+ background: "#ffffff",
1239
+ isDark: false
1240
+ };
1241
+ exports.IframeWrapper = React.memo(function IframeWrapper2({
1242
+ children,
1243
+ document: iframeDoc,
1244
+ layouts,
1245
+ layoutStyles,
1246
+ layoutKey = "pageLayout",
1247
+ defaultLayout: defaultLayout2 = "default"
1248
+ }) {
1249
+ const appState = usePuck2((s) => s.appState);
1250
+ const isInteractive = appState.ui.previewMode === "interactive";
1251
+ const rootProps = appState.data.root?.props;
1252
+ const layoutValue = rootProps?.[layoutKey] || defaultLayout2;
1253
+ const showHeaderOverride = rootProps?.showHeader;
1254
+ const showFooterOverride = rootProps?.showFooter;
1255
+ const pageBackground = rootProps?.pageBackground;
1256
+ const layoutConfigMap = React.useMemo(() => {
1257
+ if (layouts) {
1258
+ const map = {};
1259
+ for (const layout of layouts) {
1260
+ map[layout.value] = {
1261
+ background: layout.editorBackground ?? "#ffffff",
1262
+ isDark: layout.editorDarkMode ?? false,
1263
+ header: layout.header,
1264
+ footer: layout.footer,
1265
+ stickyHeaderHeight: layout.stickyHeaderHeight
1266
+ };
1267
+ }
1268
+ return map;
1269
+ }
1270
+ if (layoutStyles) {
1271
+ return layoutStyles;
1272
+ }
1273
+ return { default: DEFAULT_LAYOUT_CONFIG };
1274
+ }, [layouts, layoutStyles]);
1275
+ const layoutConfig = layoutConfigMap[layoutValue] || layoutConfigMap[defaultLayout2] || DEFAULT_LAYOUT_CONFIG;
1276
+ React.useEffect(() => {
1277
+ if (!iframeDoc) return;
1278
+ const body = iframeDoc.body;
1279
+ const html = iframeDoc.documentElement;
1280
+ if (pageBackground) {
1281
+ const bgStyles = backgroundValueToCSS(pageBackground);
1282
+ body.style.background = "";
1283
+ body.style.backgroundColor = "";
1284
+ body.style.backgroundImage = "";
1285
+ Object.assign(body.style, bgStyles);
1286
+ } else {
1287
+ body.style.background = layoutConfig.background;
1288
+ }
1289
+ body.style.backgroundAttachment = "fixed";
1290
+ body.style.minHeight = "100vh";
1291
+ if (layoutConfig.isDark) {
1292
+ html.classList.add("dark");
1293
+ html.classList.remove("light");
1294
+ body.style.color = "#ffffff";
1295
+ } else {
1296
+ html.classList.remove("dark");
1297
+ html.classList.add("light");
1298
+ body.style.color = "#1f2937";
1299
+ }
1300
+ const RICHTEXT_STYLES_ID = "puck-richtext-output-styles";
1301
+ if (!iframeDoc.getElementById(RICHTEXT_STYLES_ID)) {
1302
+ const style = iframeDoc.createElement("style");
1303
+ style.id = RICHTEXT_STYLES_ID;
1304
+ style.textContent = `
1305
+ /* Rich Text Output Styles for Puck Preview */
1306
+ .richtext-output {
1307
+ font-size: 1.125rem;
1308
+ line-height: 1.75;
1309
+ color: inherit;
1310
+ }
1311
+ .richtext-output h1 {
1312
+ margin-top: 2rem;
1313
+ margin-bottom: 1rem;
1314
+ font-weight: 700;
1315
+ font-size: 2.25rem;
1316
+ line-height: 1.2;
1317
+ }
1318
+ .richtext-output h1:first-child { margin-top: 0; }
1319
+ .richtext-output h2 {
1320
+ margin-top: 2rem;
1321
+ margin-bottom: 1rem;
1322
+ font-weight: 700;
1323
+ font-size: 1.875rem;
1324
+ line-height: 1.25;
1325
+ }
1326
+ .richtext-output h2:first-child { margin-top: 0; }
1327
+ .richtext-output h3 {
1328
+ margin-top: 2rem;
1329
+ margin-bottom: 1rem;
1330
+ font-weight: 700;
1331
+ font-size: 1.5rem;
1332
+ line-height: 1.3;
1333
+ }
1334
+ .richtext-output h3:first-child { margin-top: 0; }
1335
+ .richtext-output h4 {
1336
+ margin-top: 2rem;
1337
+ margin-bottom: 1rem;
1338
+ font-weight: 700;
1339
+ font-size: 1.25rem;
1340
+ line-height: 1.35;
1341
+ }
1342
+ .richtext-output h4:first-child { margin-top: 0; }
1343
+ .richtext-output p {
1344
+ margin-bottom: 1.25rem;
1345
+ }
1346
+ .richtext-output p:last-child { margin-bottom: 0; }
1347
+ .richtext-output ul {
1348
+ margin-bottom: 1.25rem;
1349
+ padding-left: 2rem;
1350
+ list-style-type: disc !important;
1351
+ }
1352
+ .richtext-output ol {
1353
+ margin-bottom: 1.25rem;
1354
+ padding-left: 2rem;
1355
+ list-style-type: decimal !important;
1356
+ }
1357
+ .richtext-output li {
1358
+ margin-bottom: 0.5rem;
1359
+ display: list-item !important;
1360
+ }
1361
+ .richtext-output li::marker {
1362
+ color: currentColor;
1363
+ }
1364
+ .richtext-output ul ul,
1365
+ .richtext-output ol ul {
1366
+ list-style-type: circle !important;
1367
+ margin-top: 0.5rem;
1368
+ margin-bottom: 0;
1369
+ }
1370
+ .richtext-output ul ul ul,
1371
+ .richtext-output ol ul ul {
1372
+ list-style-type: square !important;
1373
+ }
1374
+ .richtext-output ol ol,
1375
+ .richtext-output ul ol {
1376
+ list-style-type: lower-alpha !important;
1377
+ margin-top: 0.5rem;
1378
+ margin-bottom: 0;
1379
+ }
1380
+ .richtext-output blockquote {
1381
+ margin: 1.5rem 0;
1382
+ padding-left: 1.5rem;
1383
+ border-left: 4px solid #e5e7eb;
1384
+ font-style: italic;
1385
+ }
1386
+ .richtext-output a {
1387
+ color: #2563eb;
1388
+ text-decoration: underline;
1389
+ }
1390
+ .richtext-output a:hover { opacity: 0.8; }
1391
+ .richtext-output code {
1392
+ background-color: #f3f4f6;
1393
+ padding: 0.125rem 0.25rem;
1394
+ border-radius: 0.25rem;
1395
+ font-size: 0.875rem;
1396
+ }
1397
+ .richtext-output mark {
1398
+ background-color: #fef08a;
1399
+ padding: 0.125rem 0.25rem;
1400
+ border-radius: 0.125rem;
1401
+ }
1402
+ .richtext-output s,
1403
+ .richtext-output strike {
1404
+ text-decoration: line-through;
1405
+ }
1406
+ @media (max-width: 768px) {
1407
+ .richtext-output { font-size: 1rem; }
1408
+ .richtext-output h1 { font-size: 1.875rem; }
1409
+ .richtext-output h2 { font-size: 1.5rem; }
1410
+ .richtext-output h3 { font-size: 1.25rem; }
1411
+ }
1412
+ `;
1413
+ iframeDoc.head.appendChild(style);
1414
+ }
1415
+ }, [iframeDoc, layoutConfig, pageBackground]);
1416
+ const LayoutHeader = layoutConfig.header;
1417
+ const LayoutFooter = layoutConfig.footer;
1418
+ const shouldShowHeader = showHeaderOverride === "hide" ? false : showHeaderOverride === "show" ? !!LayoutHeader : !!LayoutHeader;
1419
+ const shouldShowFooter = showFooterOverride === "hide" ? false : showFooterOverride === "show" ? !!LayoutFooter : !!LayoutFooter;
1420
+ if (shouldShowHeader || shouldShowFooter) {
1421
+ const contentStyle = {
1422
+ flex: 1,
1423
+ position: "relative",
1424
+ // Add padding-top for sticky headers so content doesn't render behind them
1425
+ ...shouldShowHeader && layoutConfig.stickyHeaderHeight && { paddingTop: layoutConfig.stickyHeaderHeight }
1426
+ };
1427
+ const headerFooterStyle = isInteractive ? {} : { pointerEvents: "none" };
1428
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", minHeight: "100vh" }, children: [
1429
+ shouldShowHeader && LayoutHeader && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerFooterStyle, children: /* @__PURE__ */ jsxRuntime.jsx(LayoutHeader, {}) }),
1430
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: contentStyle, children }),
1431
+ shouldShowFooter && LayoutFooter && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerFooterStyle, children: /* @__PURE__ */ jsxRuntime.jsx(LayoutFooter, {}) })
1432
+ ] });
1433
+ }
1434
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
1435
+ });
1436
+ }
1437
+ });
1438
+ var Dialog, DialogPortal, DialogOverlay, DialogContent, DialogContentFullscreen, DialogHeader, DialogFooter, DialogTitle, DialogDescription;
1439
+ var init_dialog = __esm({
1440
+ "src/components/ui/dialog.tsx"() {
1441
+ "use client";
1442
+ init_utils();
1443
+ Dialog = DialogPrimitive__namespace.Root;
1444
+ DialogPortal = DialogPrimitive__namespace.Portal;
1445
+ DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1446
+ DialogPrimitive__namespace.Overlay,
1447
+ {
1448
+ ref,
1449
+ className: cn(
1450
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1451
+ className
1452
+ ),
1453
+ ...props
1454
+ }
1455
+ ));
1456
+ DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
1457
+ DialogContent = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
1458
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
1459
+ /* @__PURE__ */ jsxRuntime.jsxs(
1460
+ DialogPrimitive__namespace.Content,
1461
+ {
1462
+ ref,
1463
+ className: cn(
1464
+ "fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-4xl translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg max-h-[85vh] overflow-hidden p-6",
1465
+ className
1466
+ ),
1467
+ ...props,
1468
+ children: [
1469
+ children,
1470
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
1471
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" }),
1472
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
1473
+ ] })
1474
+ ]
1475
+ }
1476
+ )
1477
+ ] }));
1478
+ DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
1479
+ DialogContentFullscreen = React__namespace.forwardRef(({ className, children, hideCloseButton = false, accessibleTitle = "Dialog", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
1481
+ /* @__PURE__ */ jsxRuntime.jsxs(
1482
+ DialogPrimitive__namespace.Content,
1483
+ {
1484
+ ref,
1485
+ className: cn(
1486
+ "fixed inset-0 z-50 flex flex-col bg-background duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1487
+ className
1488
+ ),
1489
+ ...props,
1490
+ children: [
1491
+ /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { className: "sr-only", children: accessibleTitle }),
1492
+ children,
1493
+ !hideCloseButton && /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
1494
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" }),
1495
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
1496
+ ] })
1497
+ ]
1498
+ }
1499
+ )
1500
+ ] }));
1501
+ DialogContentFullscreen.displayName = "DialogContentFullscreen";
1502
+ DialogHeader = ({
1503
+ className,
1504
+ ...props
1505
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1506
+ "div",
1507
+ {
1508
+ className: cn(
1509
+ "flex flex-col space-y-1.5 text-center sm:text-left",
1510
+ className
1511
+ ),
1512
+ ...props
1513
+ }
1514
+ );
1515
+ DialogHeader.displayName = "DialogHeader";
1516
+ DialogFooter = ({
1517
+ className,
1518
+ ...props
1519
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1520
+ "div",
1521
+ {
1522
+ className: cn(
1523
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
1524
+ className
1525
+ ),
1526
+ ...props
1527
+ }
1528
+ );
1529
+ DialogFooter.displayName = "DialogFooter";
1530
+ DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1531
+ DialogPrimitive__namespace.Title,
1532
+ {
1533
+ ref,
1534
+ className: cn(
1535
+ "text-lg font-semibold leading-none tracking-tight",
1536
+ className
1537
+ ),
1538
+ ...props
1539
+ }
1540
+ ));
1541
+ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
1542
+ DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1543
+ DialogPrimitive__namespace.Description,
1544
+ {
1545
+ ref,
1546
+ className: cn("text-sm text-muted-foreground", className),
1547
+ ...props
1548
+ }
1549
+ ));
1550
+ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
1551
+ }
1552
+ });
1553
+
1554
+ // src/layouts/defaults.ts
1555
+ var defaultLayout, landingLayout, fullWidthLayout, DEFAULT_LAYOUTS;
1556
+ var init_defaults = __esm({
1557
+ "src/layouts/defaults.ts"() {
1558
+ defaultLayout = {
1559
+ value: "default",
1560
+ label: "Default",
1561
+ description: "Standard page layout with contained content width",
1562
+ classes: {
1563
+ wrapper: "",
1564
+ container: "mx-auto px-4 sm:px-6 lg:px-8",
1565
+ content: ""
1566
+ },
1567
+ maxWidth: "1200px",
1568
+ fullWidth: false
1569
+ };
1570
+ landingLayout = {
1571
+ value: "landing",
1572
+ label: "Landing",
1573
+ description: "Full-width sections with no global container constraints",
1574
+ classes: {
1575
+ wrapper: "",
1576
+ container: "",
1577
+ content: ""
1578
+ },
1579
+ fullWidth: true
1580
+ };
1581
+ fullWidthLayout = {
1582
+ value: "full-width",
1583
+ label: "Full Width",
1584
+ description: "Content spans the full viewport width",
1585
+ classes: {
1586
+ wrapper: "w-full",
1587
+ container: "w-full",
1588
+ content: ""
1589
+ },
1590
+ maxWidth: "100%",
1591
+ fullWidth: true
1592
+ };
1593
+ DEFAULT_LAYOUTS = [
1594
+ defaultLayout,
1595
+ landingLayout,
1596
+ fullWidthLayout
1597
+ ];
1598
+ }
1599
+ });
1600
+
1601
+ // src/layouts/utils.ts
1602
+ function getLayout(layouts, value, fallback = "default") {
1603
+ const layout = layouts.find((l) => l.value === value);
1604
+ if (layout) return layout;
1605
+ if (value !== fallback) {
1606
+ return layouts.find((l) => l.value === fallback);
1607
+ }
1608
+ return layouts[0];
1609
+ }
1610
+ function layoutsToOptions(layouts) {
1611
+ return layouts.map(({ value, label, description }) => ({
1612
+ value,
1613
+ label,
1614
+ description
1615
+ }));
1616
+ }
1617
+ var init_utils2 = __esm({
1618
+ "src/layouts/utils.ts"() {
1619
+ init_defaults();
1620
+ }
1621
+ });
1622
+ function LayoutWrapper({ children, layout, className, overrides }) {
1623
+ if (!layout) {
1624
+ if (overrides?.background) {
1625
+ const bgStyles = backgroundValueToCSS(overrides.background);
1626
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { minHeight: "100vh", ...bgStyles }, children });
1627
+ }
1628
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
1629
+ }
1630
+ const Header = layout.header;
1631
+ const Footer = layout.footer;
1632
+ const shouldShowHeader = overrides?.showHeader === "hide" ? false : overrides?.showHeader === "show" ? true : !!Header;
1633
+ const shouldShowFooter = overrides?.showFooter === "hide" ? false : overrides?.showFooter === "show" ? true : !!Footer;
1634
+ const useStickyFooter = layout.stickyFooter !== false;
1635
+ const mainStyle = {
1636
+ ...layout.stickyHeaderHeight && shouldShowHeader ? { paddingTop: layout.stickyHeaderHeight } : {},
1637
+ ...useStickyFooter ? stickyFooterMainStyle : {}
1638
+ };
1639
+ const outerBackgroundStyles = overrides?.background ? backgroundValueToCSS(overrides.background) : {
1640
+ ...layout.styles?.wrapper?.background !== void 0 ? { background: layout.styles.wrapper.background } : {},
1641
+ ...layout.styles?.wrapper?.backgroundAttachment !== void 0 ? { backgroundAttachment: layout.styles.wrapper.backgroundAttachment } : {}
1642
+ };
1643
+ const effectiveMaxWidth = overrides?.maxWidth && overrides.maxWidth !== "default" ? overrides.maxWidth : layout.maxWidth;
1644
+ const wrapWithStickyFooter = (content) => {
1645
+ if (useStickyFooter) {
1646
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...stickyFooterContainerStyle, ...outerBackgroundStyles }, children: content });
1647
+ }
1648
+ const hasBackground = Object.keys(outerBackgroundStyles).length > 0;
1649
+ if (hasBackground) {
1650
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { minHeight: "100vh", ...outerBackgroundStyles }, children: content });
1651
+ }
1652
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: content });
1653
+ };
1654
+ if (layout.wrapper) {
1655
+ const CustomWrapper = layout.wrapper;
1656
+ return wrapWithStickyFooter(
1657
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1658
+ shouldShowHeader && Header && /* @__PURE__ */ jsxRuntime.jsx(Header, {}),
1659
+ /* @__PURE__ */ jsxRuntime.jsx("main", { style: Object.keys(mainStyle).length > 0 ? mainStyle : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CustomWrapper, { children }) }),
1660
+ shouldShowFooter && Footer && /* @__PURE__ */ jsxRuntime.jsx(Footer, {})
1661
+ ] })
1662
+ );
1663
+ }
1664
+ const wrapperStyle = {
1665
+ ...layout.styles?.wrapper
1666
+ };
1667
+ const containerStyle = {
1668
+ ...effectiveMaxWidth && !layout.fullWidth ? { maxWidth: effectiveMaxWidth } : {},
1669
+ ...layout.styles?.container
1670
+ };
1671
+ const contentStyle = {
1672
+ ...layout.styles?.content
1673
+ };
1674
+ const dataAttrs = {
1675
+ "data-layout": layout.value,
1676
+ ...layout.dataAttributes
1677
+ };
1678
+ if (layout.fullWidth) {
1679
+ return wrapWithStickyFooter(
1680
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1681
+ shouldShowHeader && Header && /* @__PURE__ */ jsxRuntime.jsx(Header, {}),
1682
+ /* @__PURE__ */ jsxRuntime.jsx(
1683
+ "main",
1684
+ {
1685
+ className: [layout.classes?.wrapper, className].filter(Boolean).join(" ") || void 0,
1686
+ style: {
1687
+ ...mainStyle,
1688
+ ...Object.keys(wrapperStyle).length > 0 ? wrapperStyle : {}
1689
+ },
1690
+ ...dataAttrs,
1691
+ children
1692
+ }
1693
+ ),
1694
+ shouldShowFooter && Footer && /* @__PURE__ */ jsxRuntime.jsx(Footer, {})
1695
+ ] })
1696
+ );
1697
+ }
1698
+ return wrapWithStickyFooter(
1699
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1700
+ shouldShowHeader && Header && /* @__PURE__ */ jsxRuntime.jsx(Header, {}),
1701
+ /* @__PURE__ */ jsxRuntime.jsx(
1702
+ "main",
1703
+ {
1704
+ className: layout.classes?.wrapper || void 0,
1705
+ style: {
1706
+ ...mainStyle,
1707
+ ...Object.keys(wrapperStyle).length > 0 ? wrapperStyle : {}
1708
+ },
1709
+ ...dataAttrs,
1710
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1711
+ "div",
1712
+ {
1713
+ className: [layout.classes?.container, className].filter(Boolean).join(" ") || void 0,
1714
+ style: Object.keys(containerStyle).length > 0 ? containerStyle : void 0,
1715
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1716
+ "div",
1717
+ {
1718
+ className: layout.classes?.content || void 0,
1719
+ style: Object.keys(contentStyle).length > 0 ? contentStyle : void 0,
1720
+ children
1721
+ }
1722
+ )
1723
+ }
1724
+ )
1725
+ }
1726
+ ),
1727
+ shouldShowFooter && Footer && /* @__PURE__ */ jsxRuntime.jsx(Footer, {})
1728
+ ] })
1729
+ );
1730
+ }
1731
+ var stickyFooterContainerStyle, stickyFooterMainStyle;
1732
+ var init_LayoutWrapper = __esm({
1733
+ "src/layouts/LayoutWrapper.tsx"() {
1734
+ init_shared();
1735
+ stickyFooterContainerStyle = {
1736
+ minHeight: "100vh",
1737
+ display: "flex",
1738
+ flexDirection: "column"
1739
+ };
1740
+ stickyFooterMainStyle = {
1741
+ flex: 1
1742
+ };
1743
+ }
1744
+ });
1745
+
1746
+ // src/layouts/index.ts
1747
+ var init_layouts = __esm({
1748
+ "src/layouts/index.ts"() {
1749
+ init_defaults();
1750
+ init_utils2();
1751
+ init_LayoutWrapper();
1752
+ }
1753
+ });
1754
+ function useScrollAnimation(options = {}) {
1755
+ const {
1756
+ triggerOnScroll = true,
1757
+ threshold = 0.1,
1758
+ once = true,
1759
+ rootMargin = "0px",
1760
+ delay = 0
1761
+ } = options;
1762
+ const ref = React.useRef(null);
1763
+ const [isInView, setIsInView] = React.useState(false);
1764
+ const [hasAnimated, setHasAnimated] = React.useState(false);
1765
+ const timeoutRef = React.useRef(null);
1766
+ const hasMountedRef = React.useRef(false);
1767
+ const reset = React.useCallback(() => {
1768
+ setIsInView(false);
1769
+ setHasAnimated(false);
1770
+ hasMountedRef.current = false;
1771
+ if (timeoutRef.current) {
1772
+ clearTimeout(timeoutRef.current);
1773
+ timeoutRef.current = null;
1774
+ }
1775
+ }, []);
1776
+ React.useEffect(() => {
1777
+ if (!triggerOnScroll) {
1778
+ if (hasMountedRef.current) return;
1779
+ hasMountedRef.current = true;
1780
+ requestAnimationFrame(() => {
1781
+ requestAnimationFrame(() => {
1782
+ if (delay > 0) {
1783
+ timeoutRef.current = setTimeout(() => {
1784
+ setIsInView(true);
1785
+ setHasAnimated(true);
1786
+ }, delay);
1787
+ } else {
1788
+ setIsInView(true);
1789
+ setHasAnimated(true);
1790
+ }
1791
+ });
1792
+ });
1793
+ return;
1794
+ }
1795
+ if (once && hasAnimated) {
1796
+ return;
1797
+ }
1798
+ const element = ref.current;
1799
+ if (!element) return;
1800
+ if (typeof IntersectionObserver === "undefined") {
1801
+ setIsInView(true);
1802
+ setHasAnimated(true);
1803
+ return;
1804
+ }
1805
+ const observer = new IntersectionObserver(
1806
+ (entries) => {
1807
+ const [entry] = entries;
1808
+ const inView = entry.isIntersecting;
1809
+ if (inView) {
1810
+ if (delay > 0) {
1811
+ timeoutRef.current = setTimeout(() => {
1812
+ setIsInView(true);
1813
+ setHasAnimated(true);
1814
+ }, delay);
1815
+ } else {
1816
+ setIsInView(true);
1817
+ setHasAnimated(true);
1818
+ }
1819
+ if (once) {
1820
+ observer.disconnect();
1821
+ }
1822
+ } else if (!once) {
1823
+ if (timeoutRef.current) {
1824
+ clearTimeout(timeoutRef.current);
1825
+ timeoutRef.current = null;
1826
+ }
1827
+ setIsInView(false);
1828
+ }
1829
+ },
1830
+ {
1831
+ threshold,
1832
+ rootMargin
1833
+ }
1834
+ );
1835
+ observer.observe(element);
1836
+ return () => {
1837
+ observer.disconnect();
1838
+ if (timeoutRef.current) {
1839
+ clearTimeout(timeoutRef.current);
1840
+ timeoutRef.current = null;
1841
+ }
1842
+ };
1843
+ }, [triggerOnScroll, threshold, once, rootMargin, delay, hasAnimated]);
1844
+ return {
1845
+ ref,
1846
+ isInView,
1847
+ hasAnimated,
1848
+ reset
1849
+ };
1850
+ }
1851
+ var init_useScrollAnimation = __esm({
1852
+ "src/hooks/useScrollAnimation.ts"() {
1853
+ "use client";
1854
+ }
1855
+ });
1856
+ function AnimatedWrapper({
1857
+ animation,
1858
+ children,
1859
+ className,
1860
+ style,
1861
+ as: Component = "div"
1862
+ }) {
1863
+ const hasAnimation = animation && (animation.mode === "preset" && animation.entrance && animation.entrance !== "none" || animation.mode === "custom");
1864
+ if (!hasAnimation) {
1865
+ if (className || style) {
1866
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { className, style, children });
1867
+ }
1868
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
1869
+ }
1870
+ const { ref, isInView } = useScrollAnimation({
1871
+ triggerOnScroll: animation.triggerOnScroll ?? true,
1872
+ threshold: animation.triggerThreshold ?? 0.1,
1873
+ once: animation.triggerOnce ?? true,
1874
+ rootMargin: animation.triggerMargin
1875
+ });
1876
+ if (animation.mode === "preset") {
1877
+ const { initial, animate, duration, delay, easing, origin } = getEntranceAnimationStyles(animation);
1878
+ const animationStyles = isInView ? animate : initial;
1879
+ const transitionProperties = [
1880
+ `opacity ${duration}ms ${easing} ${delay}ms`,
1881
+ `transform ${duration}ms ${easing} ${delay}ms`,
1882
+ `filter ${duration}ms ${easing} ${delay}ms`
1883
+ ].join(", ");
1884
+ return /* @__PURE__ */ jsxRuntime.jsx(
1885
+ Component,
1886
+ {
1887
+ ref,
1888
+ className,
1889
+ style: {
1890
+ ...style,
1891
+ ...animationStyles,
1892
+ transition: transitionProperties,
1893
+ transformOrigin: origin
1894
+ },
1895
+ children
1896
+ }
1897
+ );
1898
+ }
1899
+ const customStyles = animationValueToCSS(animation);
1900
+ return /* @__PURE__ */ jsxRuntime.jsx(
1901
+ Component,
1902
+ {
1903
+ ref,
1904
+ className,
1905
+ style: {
1906
+ ...style,
1907
+ ...customStyles,
1908
+ // Apply opacity for visibility-based transitions
1909
+ opacity: isInView ? 1 : 0
1910
+ },
1911
+ children
1912
+ }
1913
+ );
1914
+ }
1915
+ var init_AnimatedWrapper = __esm({
1916
+ "src/components/AnimatedWrapper.tsx"() {
1917
+ "use client";
1918
+ init_useScrollAnimation();
1919
+ init_shared();
1920
+ }
1921
+ });
1922
+ function generateUniqueId() {
1923
+ return `c${(++idCounter).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
1924
+ }
1925
+ var idCounter, defaultProps, ContainerConfig;
1926
+ var init_Container_server = __esm({
1927
+ "src/components/layout/Container.server.tsx"() {
1928
+ init_shared();
1929
+ init_AnimatedWrapper();
1930
+ idCounter = 0;
1931
+ defaultProps = {
1932
+ content: [],
1933
+ background: null,
1934
+ customPadding: null,
1935
+ dimensions: null,
1936
+ border: null,
1937
+ margin: null,
1938
+ animation: null,
1939
+ innerBackground: null,
1940
+ innerPadding: null,
1941
+ innerBorder: null,
1942
+ visibility: null
1943
+ };
1944
+ ContainerConfig = {
1945
+ label: "Container",
1946
+ fields: {
1947
+ content: { type: "slot" }
1948
+ },
1949
+ defaultProps,
1950
+ render: ({
1951
+ content: Content2,
1952
+ background,
1953
+ customPadding,
1954
+ dimensions,
1955
+ border,
1956
+ margin,
1957
+ animation,
1958
+ innerBackground,
1959
+ innerPadding,
1960
+ innerBorder,
1961
+ visibility
1962
+ }) => {
1963
+ const uniqueId = generateUniqueId();
1964
+ const outerClass = `puck-container-outer-${uniqueId}`;
1965
+ const innerClass = `puck-container-inner-${uniqueId}`;
1966
+ const mediaQueries = [];
1967
+ const outerBackgroundStyles = backgroundValueToCSS(background);
1968
+ const outerStyles = {
1969
+ ...outerBackgroundStyles
1970
+ };
1971
+ const outerPaddingResult = responsiveValueToCSS(
1972
+ customPadding,
1973
+ (v) => ({ padding: paddingValueToCSS(v) }),
1974
+ outerClass
1975
+ );
1976
+ Object.assign(outerStyles, outerPaddingResult.baseStyles);
1977
+ if (outerPaddingResult.mediaQueryCSS) {
1978
+ mediaQueries.push(outerPaddingResult.mediaQueryCSS);
1979
+ }
1980
+ const outerBorderStyles = borderValueToCSS(border);
1981
+ if (outerBorderStyles) {
1982
+ Object.assign(outerStyles, outerBorderStyles);
1983
+ }
1984
+ const marginResult = responsiveValueToCSS(
1985
+ margin,
1986
+ (v) => ({ margin: marginValueToCSS(v) }),
1987
+ outerClass
1988
+ );
1989
+ Object.assign(outerStyles, marginResult.baseStyles);
1990
+ if (marginResult.mediaQueryCSS) {
1991
+ mediaQueries.push(marginResult.mediaQueryCSS);
1992
+ }
1993
+ const innerBackgroundStyles = backgroundValueToCSS(innerBackground);
1994
+ const innerStyles = {
1995
+ ...innerBackgroundStyles
1996
+ };
1997
+ const dimensionsResult = responsiveValueToCSS(
1998
+ dimensions,
1999
+ dimensionsValueToCSS,
2000
+ innerClass
2001
+ );
2002
+ Object.assign(innerStyles, dimensionsResult.baseStyles);
2003
+ if (dimensionsResult.mediaQueryCSS) {
2004
+ mediaQueries.push(dimensionsResult.mediaQueryCSS);
2005
+ }
2006
+ const innerPaddingResult = responsiveValueToCSS(
2007
+ innerPadding,
2008
+ (v) => ({ padding: paddingValueToCSS(v) }),
2009
+ innerClass
2010
+ );
2011
+ Object.assign(innerStyles, innerPaddingResult.baseStyles);
2012
+ if (innerPaddingResult.mediaQueryCSS) {
2013
+ mediaQueries.push(innerPaddingResult.mediaQueryCSS);
2014
+ }
2015
+ const innerBorderStyles = borderValueToCSS(innerBorder);
2016
+ if (innerBorderStyles) {
2017
+ Object.assign(innerStyles, innerBorderStyles);
2018
+ }
2019
+ const visibilityCSS = visibilityValueToCSS(visibility, outerClass);
2020
+ if (visibilityCSS) {
2021
+ mediaQueries.push(visibilityCSS);
2022
+ }
2023
+ const contentClasses = cn2("px-4", innerClass);
2024
+ const hasInnerStyles = Object.keys(innerStyles).length > 0;
2025
+ const allMediaQueryCSS = mediaQueries.join("\n");
2026
+ const ContentSlot = Content2;
2027
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2028
+ allMediaQueryCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: allMediaQueryCSS }),
2029
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: outerClass, style: outerStyles, children: hasInnerStyles ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: contentClasses, style: innerStyles, children: /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, { className: contentClasses, style: innerStyles }) })
2030
+ ] });
2031
+ }
2032
+ };
2033
+ }
2034
+ });
2035
+ function generateUniqueId2() {
2036
+ return `f${(++idCounter2).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2037
+ }
2038
+ var idCounter2, flexDirectionMap, flexWrapMap, defaultProps2, FlexConfig;
2039
+ var init_Flex_server = __esm({
2040
+ "src/components/layout/Flex.server.tsx"() {
2041
+ init_shared();
2042
+ init_AnimatedWrapper();
2043
+ idCounter2 = 0;
2044
+ flexDirectionMap = {
2045
+ row: "flex-row",
2046
+ column: "flex-col",
2047
+ "row-reverse": "flex-row-reverse",
2048
+ "column-reverse": "flex-col-reverse"
2049
+ };
2050
+ flexWrapMap = {
2051
+ wrap: "flex-wrap",
2052
+ nowrap: "flex-nowrap",
2053
+ "wrap-reverse": "flex-wrap-reverse"
2054
+ };
2055
+ defaultProps2 = {
2056
+ content: [],
2057
+ direction: "row",
2058
+ justifyContent: null,
2059
+ alignItems: null,
2060
+ gap: 24,
2061
+ wrap: "wrap",
2062
+ background: null,
2063
+ customPadding: null,
2064
+ margin: null,
2065
+ dimensions: null,
2066
+ border: null,
2067
+ animation: null,
2068
+ visibility: null
2069
+ };
2070
+ FlexConfig = {
2071
+ label: "Flex",
2072
+ fields: {
2073
+ content: { type: "slot" }
2074
+ },
2075
+ defaultProps: defaultProps2,
2076
+ render: ({
2077
+ content: Content2,
2078
+ direction,
2079
+ justifyContent,
2080
+ alignItems,
2081
+ gap,
2082
+ wrap,
2083
+ background,
2084
+ customPadding,
2085
+ margin,
2086
+ dimensions,
2087
+ border,
2088
+ animation,
2089
+ visibility
2090
+ }) => {
2091
+ const uniqueId = generateUniqueId2();
2092
+ const wrapperClass = `puck-flex-${uniqueId}`;
2093
+ const contentClass = `puck-flex-content-${uniqueId}`;
2094
+ const mediaQueries = [];
2095
+ const backgroundStyles = backgroundValueToCSS(background);
2096
+ const wrapperStyles = {
2097
+ ...backgroundStyles
2098
+ };
2099
+ const paddingResult = responsiveValueToCSS(
2100
+ customPadding,
2101
+ (v) => ({ padding: paddingValueToCSS(v) }),
2102
+ wrapperClass
2103
+ );
2104
+ Object.assign(wrapperStyles, paddingResult.baseStyles);
2105
+ if (paddingResult.mediaQueryCSS) {
2106
+ mediaQueries.push(paddingResult.mediaQueryCSS);
2107
+ }
2108
+ const borderStyles = borderValueToCSS(border);
2109
+ if (borderStyles) {
2110
+ Object.assign(wrapperStyles, borderStyles);
2111
+ }
2112
+ const marginResult = responsiveValueToCSS(
2113
+ margin,
2114
+ (v) => ({ margin: marginValueToCSS(v) }),
2115
+ wrapperClass
2116
+ );
2117
+ Object.assign(wrapperStyles, marginResult.baseStyles);
2118
+ if (marginResult.mediaQueryCSS) {
2119
+ mediaQueries.push(marginResult.mediaQueryCSS);
2120
+ }
2121
+ const dimensionsResult = responsiveValueToCSS(
2122
+ dimensions,
2123
+ dimensionsValueToCSS,
2124
+ contentClass
2125
+ );
2126
+ const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
2127
+ if (visibilityCSS) {
2128
+ mediaQueries.push(visibilityCSS);
2129
+ }
2130
+ const contentClasses = cn2(
2131
+ "flex w-full min-h-[50px]",
2132
+ flexDirectionMap[direction],
2133
+ justifyContent && justifyContentMap[justifyContent],
2134
+ alignItems && alignItemsMap[alignItems],
2135
+ flexWrapMap[wrap],
2136
+ "[&>*]:min-w-0",
2137
+ contentClass
2138
+ );
2139
+ const contentStyles = {
2140
+ gap,
2141
+ ...dimensionsResult.baseStyles
2142
+ };
2143
+ if (dimensionsResult.mediaQueryCSS) {
2144
+ mediaQueries.push(dimensionsResult.mediaQueryCSS);
2145
+ }
2146
+ const allMediaQueryCSS = mediaQueries.join("\n");
2147
+ const ContentSlot = Content2;
2148
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2149
+ allMediaQueryCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: allMediaQueryCSS }),
2150
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: wrapperClass, style: wrapperStyles, children: /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, { className: contentClasses, style: contentStyles }) })
2151
+ ] });
2152
+ }
2153
+ };
2154
+ }
2155
+ });
2156
+ function generateUniqueId3() {
2157
+ return `g${(++idCounter3).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2158
+ }
2159
+ var idCounter3, defaultProps3, GridConfig;
2160
+ var init_Grid_server = __esm({
2161
+ "src/components/layout/Grid.server.tsx"() {
2162
+ init_shared();
2163
+ init_AnimatedWrapper();
2164
+ idCounter3 = 0;
2165
+ defaultProps3 = {
2166
+ content: [],
2167
+ numColumns: 3,
2168
+ gap: 24,
2169
+ background: null,
2170
+ customPadding: null,
2171
+ dimensions: null,
2172
+ border: null,
2173
+ margin: null,
2174
+ animation: null,
2175
+ visibility: null
2176
+ };
2177
+ GridConfig = {
2178
+ label: "Grid",
2179
+ fields: {
2180
+ content: { type: "slot" }
2181
+ },
2182
+ defaultProps: defaultProps3,
2183
+ render: ({
2184
+ content: Content2,
2185
+ numColumns,
2186
+ gap,
2187
+ background,
2188
+ customPadding,
2189
+ dimensions,
2190
+ border,
2191
+ margin,
2192
+ animation,
2193
+ visibility
2194
+ }) => {
2195
+ const uniqueId = generateUniqueId3();
2196
+ const wrapperClass = `puck-grid-${uniqueId}`;
2197
+ const contentClass = `puck-grid-content-${uniqueId}`;
2198
+ const mediaQueries = [];
2199
+ const backgroundStyles = backgroundValueToCSS(background);
2200
+ const wrapperStyles = {
2201
+ ...backgroundStyles
2202
+ };
2203
+ const paddingResult = responsiveValueToCSS(
2204
+ customPadding,
2205
+ (v) => ({ padding: paddingValueToCSS(v) }),
2206
+ wrapperClass
2207
+ );
2208
+ Object.assign(wrapperStyles, paddingResult.baseStyles);
2209
+ if (paddingResult.mediaQueryCSS) {
2210
+ mediaQueries.push(paddingResult.mediaQueryCSS);
2211
+ }
2212
+ const borderStyles = borderValueToCSS(border);
2213
+ if (borderStyles) {
2214
+ Object.assign(wrapperStyles, borderStyles);
2215
+ }
2216
+ const marginResult = responsiveValueToCSS(
2217
+ margin,
2218
+ (v) => ({ margin: marginValueToCSS(v) }),
2219
+ wrapperClass
2220
+ );
2221
+ Object.assign(wrapperStyles, marginResult.baseStyles);
2222
+ if (marginResult.mediaQueryCSS) {
2223
+ mediaQueries.push(marginResult.mediaQueryCSS);
2224
+ }
2225
+ const dimensionsResult = responsiveValueToCSS(
2226
+ dimensions,
2227
+ dimensionsValueToCSS,
2228
+ contentClass
2229
+ );
2230
+ const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
2231
+ if (visibilityCSS) {
2232
+ mediaQueries.push(visibilityCSS);
2233
+ }
2234
+ const contentClasses = cn2(
2235
+ "flex flex-col w-full",
2236
+ "md:grid",
2237
+ contentClass
2238
+ );
2239
+ const contentStyles = {
2240
+ gap,
2241
+ ...dimensionsResult.baseStyles
2242
+ };
2243
+ if (dimensionsResult.mediaQueryCSS) {
2244
+ mediaQueries.push(dimensionsResult.mediaQueryCSS);
2245
+ }
2246
+ const gridStyles = {
2247
+ ...contentStyles,
2248
+ "--grid-cols": numColumns
2249
+ };
2250
+ const allMediaQueryCSS = mediaQueries.join("\n");
2251
+ const ContentSlot = Content2;
2252
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2253
+ allMediaQueryCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: allMediaQueryCSS }),
2254
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, style: wrapperStyles, children: [
2255
+ /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, { className: contentClasses, style: gridStyles }),
2256
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
2257
+ @media (min-width: 768px) {
2258
+ .flex.md\\:grid {
2259
+ grid-template-columns: repeat(var(--grid-cols), 1fr);
2260
+ }
2261
+ }
2262
+ ` })
2263
+ ] })
2264
+ ] });
2265
+ }
2266
+ };
2267
+ }
2268
+ });
2269
+ function generateUniqueId4() {
2270
+ return `s${(++idCounter4).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2271
+ }
2272
+ var idCounter4, defaultProps4, SectionConfig;
2273
+ var init_Section_server = __esm({
2274
+ "src/components/layout/Section.server.tsx"() {
2275
+ init_shared();
2276
+ init_AnimatedWrapper();
2277
+ idCounter4 = 0;
2278
+ defaultProps4 = {
2279
+ id: "",
2280
+ content: [],
2281
+ background: null,
2282
+ fullWidth: false,
2283
+ customPadding: null,
2284
+ dimensions: null,
2285
+ border: null,
2286
+ margin: null,
2287
+ animation: null,
2288
+ visibility: null
2289
+ };
2290
+ SectionConfig = {
2291
+ label: "Section",
2292
+ fields: {
2293
+ content: { type: "slot" }
2294
+ },
2295
+ defaultProps: defaultProps4,
2296
+ render: ({
2297
+ id,
2298
+ content: Content2,
2299
+ background,
2300
+ fullWidth,
2301
+ customPadding,
2302
+ dimensions,
2303
+ border,
2304
+ margin,
2305
+ animation,
2306
+ visibility
2307
+ }) => {
2308
+ const uniqueId = generateUniqueId4();
2309
+ const sectionClass = `puck-section-${uniqueId}`;
2310
+ const contentClass = `puck-section-content-${uniqueId}`;
2311
+ const mediaQueries = [];
2312
+ const backgroundStyles = backgroundValueToCSS(background);
2313
+ const sectionStyles = {
2314
+ ...backgroundStyles
2315
+ };
2316
+ const paddingResult = responsiveValueToCSS(
2317
+ customPadding,
2318
+ (v) => ({ padding: paddingValueToCSS(v) }),
2319
+ sectionClass
2320
+ );
2321
+ Object.assign(sectionStyles, paddingResult.baseStyles);
2322
+ if (paddingResult.mediaQueryCSS) {
2323
+ mediaQueries.push(paddingResult.mediaQueryCSS);
2324
+ }
2325
+ const borderStyles = borderValueToCSS(border);
2326
+ if (borderStyles) {
2327
+ Object.assign(sectionStyles, borderStyles);
2328
+ }
2329
+ const marginResult = responsiveValueToCSS(
2330
+ margin,
2331
+ (v) => ({ margin: marginValueToCSS(v) }),
2332
+ sectionClass
2333
+ );
2334
+ Object.assign(sectionStyles, marginResult.baseStyles);
2335
+ if (marginResult.mediaQueryCSS) {
2336
+ mediaQueries.push(marginResult.mediaQueryCSS);
2337
+ }
2338
+ const visibilityCSS = visibilityValueToCSS(visibility, sectionClass);
2339
+ if (visibilityCSS) {
2340
+ mediaQueries.push(visibilityCSS);
2341
+ }
2342
+ const sectionClasses = cn2("relative w-full", sectionClass);
2343
+ const dimensionsResult = responsiveValueToCSS(
2344
+ dimensions,
2345
+ dimensionsValueToCSS,
2346
+ contentClass
2347
+ );
2348
+ if (dimensionsResult.mediaQueryCSS) {
2349
+ mediaQueries.push(dimensionsResult.mediaQueryCSS);
2350
+ }
2351
+ const contentClasses = cn2(
2352
+ "relative z-10",
2353
+ // Only apply preset content width if no dimensions set
2354
+ !dimensions && !fullWidth && "max-w-[1200px] mx-auto px-4",
2355
+ contentClass
2356
+ );
2357
+ const allMediaQueryCSS = mediaQueries.join("\n");
2358
+ const ContentSlot = Content2;
2359
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2360
+ allMediaQueryCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: allMediaQueryCSS }),
2361
+ /* @__PURE__ */ jsxRuntime.jsx(
2362
+ "section",
2363
+ {
2364
+ id: id || void 0,
2365
+ className: sectionClasses,
2366
+ style: sectionStyles,
2367
+ children: /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, { className: contentClasses, style: dimensionsResult.baseStyles })
2368
+ }
2369
+ )
2370
+ ] });
2371
+ }
2372
+ };
2373
+ }
2374
+ });
2375
+ function generateUniqueId5() {
2376
+ return `sp${(++idCounter5).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2377
+ }
2378
+ var idCounter5, heightMap, widthMap, defaultProps5, SpacerConfig;
2379
+ var init_Spacer_server = __esm({
2380
+ "src/components/layout/Spacer.server.tsx"() {
2381
+ init_shared();
2382
+ idCounter5 = 0;
2383
+ heightMap = {
2384
+ "8px": "h-2",
2385
+ "16px": "h-4",
2386
+ "24px": "h-6",
2387
+ "32px": "h-8",
2388
+ "48px": "h-12",
2389
+ "64px": "h-16",
2390
+ "80px": "h-20",
2391
+ "96px": "h-24",
2392
+ "128px": "h-32"
2393
+ };
2394
+ widthMap = {
2395
+ "8px": "w-2",
2396
+ "16px": "w-4",
2397
+ "24px": "w-6",
2398
+ "32px": "w-8",
2399
+ "48px": "w-12",
2400
+ "64px": "w-16",
2401
+ "80px": "w-20",
2402
+ "96px": "w-24",
2403
+ "128px": "w-32"
2404
+ };
2405
+ defaultProps5 = {
2406
+ size: "24px",
2407
+ direction: "vertical",
2408
+ visibility: null
2409
+ };
2410
+ SpacerConfig = {
2411
+ label: "Spacer",
2412
+ defaultProps: defaultProps5,
2413
+ render: ({ size, direction, visibility }) => {
2414
+ const uniqueId = generateUniqueId5();
2415
+ const wrapperClass = `puck-spacer-${uniqueId}`;
2416
+ const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
2417
+ const getClasses = () => {
2418
+ const heightClass = heightMap[size] || "h-6";
2419
+ const widthClass = widthMap[size] || "w-6";
2420
+ if (direction === "vertical") {
2421
+ return `block ${heightClass} w-full`;
2422
+ }
2423
+ if (direction === "horizontal") {
2424
+ return `inline-block ${widthClass} h-full`;
2425
+ }
2426
+ return `block ${heightClass} ${widthClass}`;
2427
+ };
2428
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2429
+ visibilityCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: visibilityCSS }),
2430
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn2(getClasses(), wrapperClass), "aria-hidden": "true" })
2431
+ ] });
2432
+ }
2433
+ };
2434
+ }
2435
+ });
2436
+ function generateUniqueId6() {
2437
+ return `t${(++idCounter6).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2438
+ }
2439
+ var idCounter6, defaultProps6, TemplateServerConfig;
2440
+ var init_Template_server = __esm({
2441
+ "src/components/layout/Template.server.tsx"() {
2442
+ init_shared();
2443
+ idCounter6 = 0;
2444
+ defaultProps6 = {
2445
+ content: [],
2446
+ templateId: null,
2447
+ dimensions: null,
2448
+ customPadding: null,
2449
+ margin: null,
2450
+ visibility: null
2451
+ };
2452
+ TemplateServerConfig = {
2453
+ label: "Template",
2454
+ fields: {
2455
+ // In server config, templateId is just for reference (no loading UI)
2456
+ templateId: {
2457
+ type: "text",
2458
+ label: "Template ID"
2459
+ },
2460
+ content: {
2461
+ type: "slot"
2462
+ }
2463
+ },
2464
+ defaultProps: defaultProps6,
2465
+ render: ({ content: Content2, dimensions, customPadding, margin, visibility }) => {
2466
+ const uniqueId = generateUniqueId6();
2467
+ const wrapperClass = `puck-template-${uniqueId}`;
2468
+ const contentClass = `puck-template-content-${uniqueId}`;
2469
+ const mediaQueries = [];
2470
+ const wrapperStyles = {};
2471
+ const paddingResult = responsiveValueToCSS(
2472
+ customPadding,
2473
+ (v) => ({ padding: paddingValueToCSS(v) }),
2474
+ wrapperClass
2475
+ );
2476
+ Object.assign(wrapperStyles, paddingResult.baseStyles);
2477
+ if (paddingResult.mediaQueryCSS) {
2478
+ mediaQueries.push(paddingResult.mediaQueryCSS);
2479
+ }
2480
+ const marginResult = responsiveValueToCSS(
2481
+ margin,
2482
+ (v) => ({ margin: marginValueToCSS(v) }),
2483
+ wrapperClass
2484
+ );
2485
+ Object.assign(wrapperStyles, marginResult.baseStyles);
2486
+ if (marginResult.mediaQueryCSS) {
2487
+ mediaQueries.push(marginResult.mediaQueryCSS);
2488
+ }
2489
+ const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
2490
+ if (visibilityCSS) {
2491
+ mediaQueries.push(visibilityCSS);
2492
+ }
2493
+ const dimensionsResult = responsiveValueToCSS(
2494
+ dimensions,
2495
+ dimensionsValueToCSS,
2496
+ contentClass
2497
+ );
2498
+ if (dimensionsResult.mediaQueryCSS) {
2499
+ mediaQueries.push(dimensionsResult.mediaQueryCSS);
2500
+ }
2501
+ const allMediaQueryCSS = mediaQueries.join("\n");
2502
+ const ContentSlot = Content2;
2503
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2504
+ allMediaQueryCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: allMediaQueryCSS }),
2505
+ /* @__PURE__ */ jsxRuntime.jsx(
2506
+ "div",
2507
+ {
2508
+ className: cn2("template-wrapper", wrapperClass),
2509
+ style: Object.keys(wrapperStyles).length > 0 ? wrapperStyles : void 0,
2510
+ children: /* @__PURE__ */ jsxRuntime.jsx(ContentSlot, { className: contentClass, style: dimensionsResult.baseStyles })
2511
+ }
2512
+ )
2513
+ ] });
2514
+ }
2515
+ };
2516
+ }
2517
+ });
2518
+ var defaultProps7, HeadingConfig;
2519
+ var init_Heading_server = __esm({
2520
+ "src/components/typography/Heading.server.tsx"() {
2521
+ init_shared();
2522
+ init_AnimatedWrapper();
2523
+ defaultProps7 = {
2524
+ text: "Heading Text",
2525
+ level: "h2",
2526
+ alignment: null,
2527
+ textColor: null,
2528
+ dimensions: null,
2529
+ animation: null,
2530
+ margin: null,
2531
+ customPadding: null
2532
+ };
2533
+ HeadingConfig = {
2534
+ label: "Heading",
2535
+ defaultProps: defaultProps7,
2536
+ render: ({ text, level, alignment, textColor, dimensions, animation, margin, customPadding }) => {
2537
+ const tag = level || "h2";
2538
+ const alignmentValue = alignment ?? "left";
2539
+ const classes = cn2(
2540
+ headingLevelMap[level] || headingLevelMap.h2,
2541
+ alignmentMap[alignmentValue] || alignmentMap.left
2542
+ );
2543
+ const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
2544
+ const style = {
2545
+ ...dimensionsStyles
2546
+ };
2547
+ const marginCSS = marginValueToCSS(margin);
2548
+ if (marginCSS) {
2549
+ style.margin = marginCSS;
2550
+ }
2551
+ const paddingCSS = paddingValueToCSS(customPadding);
2552
+ if (paddingCSS) {
2553
+ style.padding = paddingCSS;
2554
+ }
2555
+ const colorCSS = colorValueToCSS(textColor);
2556
+ if (colorCSS) {
2557
+ style.color = colorCSS;
2558
+ }
2559
+ const headingElement = React.createElement(tag, { className: classes, style: Object.keys(style).length > 0 ? style : void 0 }, text);
2560
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: headingElement });
2561
+ }
2562
+ };
2563
+ }
2564
+ });
2565
+ var defaultProps8, TextConfig;
2566
+ var init_Text_server = __esm({
2567
+ "src/components/typography/Text.server.tsx"() {
2568
+ init_shared();
2569
+ init_AnimatedWrapper();
2570
+ defaultProps8 = {
2571
+ content: "Enter your text here...",
2572
+ size: "base",
2573
+ alignment: null,
2574
+ textColor: null,
2575
+ dimensions: null,
2576
+ animation: null,
2577
+ margin: null,
2578
+ customPadding: null
2579
+ };
2580
+ TextConfig = {
2581
+ label: "Text",
2582
+ defaultProps: defaultProps8,
2583
+ render: ({ content, size, alignment, textColor, dimensions, animation, margin, customPadding }) => {
2584
+ const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
2585
+ const style = {
2586
+ ...dimensionsStyles
2587
+ };
2588
+ const marginCSS = marginValueToCSS(margin);
2589
+ if (marginCSS) {
2590
+ style.margin = marginCSS;
2591
+ }
2592
+ const paddingCSS = paddingValueToCSS(customPadding);
2593
+ if (paddingCSS) {
2594
+ style.padding = paddingCSS;
2595
+ }
2596
+ const colorCSS = colorValueToCSS(textColor);
2597
+ if (colorCSS) {
2598
+ style.color = colorCSS;
2599
+ }
2600
+ const alignmentValue = alignment ?? "left";
2601
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx(
2602
+ "p",
2603
+ {
2604
+ className: cn2(
2605
+ textSizeMap[size] || textSizeMap.base,
2606
+ alignmentMap[alignmentValue] || alignmentMap.left
2607
+ ),
2608
+ style: Object.keys(style).length > 0 ? style : void 0,
2609
+ children: content
2610
+ }
2611
+ ) });
2612
+ }
2613
+ };
2614
+ }
2615
+ });
2616
+ var defaultProps9, RichTextConfig;
2617
+ var init_RichText_server = __esm({
2618
+ "src/components/typography/RichText.server.tsx"() {
2619
+ init_shared();
2620
+ init_AnimatedWrapper();
2621
+ defaultProps9 = {
2622
+ content: "<p>Enter your content here...</p>",
2623
+ alignment: null,
2624
+ textColor: null,
2625
+ dimensions: null,
2626
+ animation: null,
2627
+ margin: null,
2628
+ customPadding: null
2629
+ };
2630
+ RichTextConfig = {
2631
+ label: "Rich Text",
2632
+ defaultProps: defaultProps9,
2633
+ render: ({ content, alignment, textColor, dimensions, animation, margin, customPadding }) => {
2634
+ const dimensionsStyles = dimensions ? dimensionsValueToCSS(dimensions) : void 0;
2635
+ const style = {
2636
+ ...dimensionsStyles
2637
+ };
2638
+ const marginCSS = marginValueToCSS(margin);
2639
+ if (marginCSS) {
2640
+ style.margin = marginCSS;
2641
+ }
2642
+ const customPaddingCSS = paddingValueToCSS(customPadding);
2643
+ if (customPaddingCSS) {
2644
+ style.padding = customPaddingCSS;
2645
+ }
2646
+ const colorCSS = colorValueToCSS(textColor);
2647
+ if (colorCSS) {
2648
+ style.color = colorCSS;
2649
+ }
2650
+ const alignmentValue = alignment ?? "left";
2651
+ const alignmentClass = alignmentMap[alignmentValue] || alignmentMap.left;
2652
+ if (!content || content === "<p></p>") {
2653
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("section", { className: cn2("relative overflow-hidden px-4", alignmentClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prose dark:prose-invert", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx("em", { children: "No content available" }) }) }) }) });
2654
+ }
2655
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("section", { className: cn2("relative overflow-hidden px-4", alignmentClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2656
+ "div",
2657
+ {
2658
+ className: "prose dark:prose-invert",
2659
+ dangerouslySetInnerHTML: { __html: content }
2660
+ }
2661
+ ) }) });
2662
+ }
2663
+ };
2664
+ }
2665
+ });
2666
+ function generateUniqueId7() {
2667
+ return `i${(++idCounter7).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2668
+ }
2669
+ var idCounter7, defaultProps10, ImageConfig;
2670
+ var init_Image_server = __esm({
2671
+ "src/components/media/Image.server.tsx"() {
2672
+ init_shared();
2673
+ init_AnimatedWrapper();
2674
+ idCounter7 = 0;
2675
+ defaultProps10 = {
2676
+ image: null,
2677
+ alt: "",
2678
+ aspectRatio: "auto",
2679
+ link: "",
2680
+ openInNewTab: false,
2681
+ margin: null,
2682
+ border: null,
2683
+ dimensions: null,
2684
+ alignment: null,
2685
+ transform: null,
2686
+ animation: null,
2687
+ customPadding: null,
2688
+ visibility: null
2689
+ };
2690
+ ImageConfig = {
2691
+ label: "Image",
2692
+ defaultProps: defaultProps10,
2693
+ render: ({ image, alt, aspectRatio, link, openInNewTab, dimensions, alignment, margin, border, transform, animation, customPadding, visibility }) => {
2694
+ const uniqueId = generateUniqueId7();
2695
+ const wrapperClass = `puck-image-${uniqueId}`;
2696
+ const visibilityCSS = visibilityValueToCSS(visibility, wrapperClass);
2697
+ const dimensionsStyles = dimensionsValueToCSS(dimensions);
2698
+ const style = {
2699
+ ...dimensionsStyles
2700
+ };
2701
+ const marginCSS = marginValueToCSS(margin);
2702
+ if (marginCSS) {
2703
+ style.margin = marginCSS;
2704
+ }
2705
+ const paddingCSS = paddingValueToCSS(customPadding);
2706
+ if (paddingCSS) {
2707
+ style.padding = paddingCSS;
2708
+ }
2709
+ const borderStyles = borderValueToCSS(border);
2710
+ if (borderStyles) {
2711
+ Object.assign(style, borderStyles);
2712
+ }
2713
+ const transformStyles = transformValueToCSS(transform);
2714
+ if (transformStyles) {
2715
+ Object.assign(style, transformStyles);
2716
+ }
2717
+ const alignmentValue = alignment ?? "center";
2718
+ const alignmentClasses = cn2(
2719
+ "flex",
2720
+ alignmentValue === "left" && "justify-start",
2721
+ alignmentValue === "center" && "justify-center",
2722
+ alignmentValue === "right" && "justify-end"
2723
+ );
2724
+ if (!image?.url) {
2725
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2726
+ visibilityCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: visibilityCSS }),
2727
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn2("py-4 px-4", wrapperClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsxRuntime.jsx(
2728
+ "div",
2729
+ {
2730
+ className: cn2(
2731
+ "relative overflow-hidden rounded-lg w-full max-w-md bg-muted flex items-center justify-center min-h-[200px]",
2732
+ aspectRatioMap[aspectRatio] || ""
2733
+ ),
2734
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "No image selected" })
2735
+ }
2736
+ ) }) })
2737
+ ] });
2738
+ }
2739
+ const imageElement = aspectRatio === "auto" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative overflow-hidden rounded-lg w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
2740
+ "img",
2741
+ {
2742
+ src: image.url,
2743
+ alt: alt || image.alt || "",
2744
+ className: "w-full h-auto object-cover"
2745
+ }
2746
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn2("relative overflow-hidden rounded-lg w-full", aspectRatioMap[aspectRatio]), children: /* @__PURE__ */ jsxRuntime.jsx(
2747
+ "img",
2748
+ {
2749
+ src: image.url,
2750
+ alt: alt || image.alt || "",
2751
+ className: "absolute inset-0 w-full h-full object-cover"
2752
+ }
2753
+ ) });
2754
+ const content = link ? /* @__PURE__ */ jsxRuntime.jsx(
2755
+ "a",
2756
+ {
2757
+ href: link,
2758
+ target: openInNewTab ? "_blank" : void 0,
2759
+ rel: openInNewTab ? "noopener noreferrer" : void 0,
2760
+ className: "block transition-opacity hover:opacity-90",
2761
+ children: imageElement
2762
+ }
2763
+ ) : imageElement;
2764
+ return /* @__PURE__ */ jsxRuntime.jsxs(AnimatedWrapper, { animation, children: [
2765
+ visibilityCSS && /* @__PURE__ */ jsxRuntime.jsx("style", { children: visibilityCSS }),
2766
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn2("py-4 px-4", wrapperClass), style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: alignmentClasses, children: content }) })
2767
+ ] });
2768
+ }
2769
+ };
2770
+ }
2771
+ });
2772
+ var buttonVariants, Button;
2773
+ var init_button = __esm({
2774
+ "src/components/ui/button.tsx"() {
2775
+ init_utils();
2776
+ buttonVariants = classVarianceAuthority.cva(
2777
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
2778
+ {
2779
+ variants: {
2780
+ variant: {
2781
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
2782
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
2783
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
2784
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
2785
+ ghost: "hover:bg-accent hover:text-accent-foreground",
2786
+ link: "text-primary underline-offset-4 hover:underline"
2787
+ },
2788
+ size: {
2789
+ default: "h-10 px-4 py-2",
2790
+ sm: "h-8 px-3 text-xs",
2791
+ lg: "h-11 px-8",
2792
+ icon: "h-10 w-10 p-2",
2793
+ "icon-sm": "h-8 w-8 p-1.5"
2794
+ }
2795
+ },
2796
+ defaultVariants: {
2797
+ variant: "default",
2798
+ size: "default"
2799
+ }
2800
+ }
2801
+ );
2802
+ Button = React__namespace.forwardRef(
2803
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
2804
+ const Comp = asChild ? reactSlot.Slot : "button";
2805
+ return /* @__PURE__ */ jsxRuntime.jsx(
2806
+ Comp,
2807
+ {
2808
+ className: cn(buttonVariants({ variant, size, className })),
2809
+ ref,
2810
+ ...props
2811
+ }
2812
+ );
2813
+ }
2814
+ );
2815
+ Button.displayName = "Button";
2816
+ }
2817
+ });
2818
+ var Input;
2819
+ var init_input = __esm({
2820
+ "src/components/ui/input.tsx"() {
2821
+ init_utils();
2822
+ Input = React__namespace.forwardRef(
2823
+ ({ className, type, ...props }, ref) => {
2824
+ return /* @__PURE__ */ jsxRuntime.jsx(
2825
+ "input",
2826
+ {
2827
+ type,
2828
+ className: cn(
2829
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2830
+ className
2831
+ ),
2832
+ ref,
2833
+ ...props
2834
+ }
2835
+ );
2836
+ }
2837
+ );
2838
+ Input.displayName = "Input";
2839
+ }
2840
+ });
2841
+ var labelVariants, Label;
2842
+ var init_label = __esm({
2843
+ "src/components/ui/label.tsx"() {
2844
+ "use client";
2845
+ init_utils();
2846
+ labelVariants = classVarianceAuthority.cva(
2847
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
2848
+ );
2849
+ Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
2850
+ LabelPrimitive__namespace.Root,
2851
+ {
2852
+ ref,
2853
+ className: cn(labelVariants(), className),
2854
+ ...props
2855
+ }
2856
+ ));
2857
+ Label.displayName = LabelPrimitive__namespace.Root.displayName;
2858
+ }
2859
+ });
2860
+ function SizeFieldInner({
2861
+ value,
2862
+ onChange,
2863
+ label = "Size",
2864
+ readOnly,
2865
+ showHeight = true,
2866
+ showFontSize = true
2867
+ }) {
2868
+ const currentValue = value || DEFAULT_VALUE;
2869
+ const handleModeChange = React.useCallback((mode) => {
2870
+ if (mode === "custom") {
2871
+ onChange({
2872
+ mode,
2873
+ ...CUSTOM_DEFAULTS
2874
+ });
2875
+ } else {
2876
+ onChange({ mode });
2877
+ }
2878
+ }, [onChange]);
2879
+ const handleValueChange = React.useCallback((field, val) => {
2880
+ onChange({
2881
+ ...currentValue,
2882
+ [field]: val
2883
+ });
2884
+ }, [currentValue, onChange]);
2885
+ const handleUnitChange = React.useCallback((unit) => {
2886
+ onChange({
2887
+ ...currentValue,
2888
+ unit
2889
+ });
2890
+ }, [currentValue, onChange]);
2891
+ const handleClear = React.useCallback(() => {
2892
+ onChange(null);
2893
+ }, [onChange]);
2894
+ const presets = [
2895
+ { mode: "sm", label: "SM" },
2896
+ { mode: "default", label: "Default" },
2897
+ { mode: "lg", label: "LG" },
2898
+ { mode: "custom", label: "Custom" }
2899
+ ];
2900
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "puck-field space-y-3", children: [
2901
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2902
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-foreground", children: label }),
2903
+ value && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
2904
+ Button,
2905
+ {
2906
+ type: "button",
2907
+ variant: "ghost",
2908
+ size: "icon-sm",
2909
+ onClick: handleClear,
2910
+ className: "text-muted-foreground hover:text-destructive",
2911
+ title: "Reset to default",
2912
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" })
2913
+ }
2914
+ )
2915
+ ] }),
2916
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: presets.map(({ mode, label: modeLabel }) => {
2917
+ const isActive = currentValue.mode === mode;
2918
+ return /* @__PURE__ */ jsxRuntime.jsx(
2919
+ Button,
2920
+ {
2921
+ type: "button",
2922
+ variant: isActive ? "default" : "secondary",
2923
+ size: "sm",
2924
+ onClick: () => handleModeChange(mode),
2925
+ disabled: readOnly,
2926
+ className: cn(
2927
+ "text-xs",
2928
+ isActive && "bg-primary hover:bg-primary/90"
2929
+ ),
2930
+ children: modeLabel
2931
+ },
2932
+ mode
2933
+ );
2934
+ }) }),
2935
+ currentValue.mode === "custom" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3 p-3 bg-muted/50 rounded-md", children: [
2936
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2937
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground flex-shrink-0", children: "Unit:" }),
2938
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1", children: ["px", "rem"].map((unit) => {
2939
+ const isActive = (currentValue.unit || "px") === unit;
2940
+ return /* @__PURE__ */ jsxRuntime.jsx(
2941
+ Button,
2942
+ {
2943
+ type: "button",
2944
+ variant: isActive ? "default" : "outline",
2945
+ size: "sm",
2946
+ onClick: () => handleUnitChange(unit),
2947
+ disabled: readOnly,
2948
+ className: cn(
2949
+ "text-xs font-mono h-7 px-2",
2950
+ isActive && "bg-primary hover:bg-primary/90"
2951
+ ),
2952
+ children: unit
2953
+ },
2954
+ unit
2955
+ );
2956
+ }) })
2957
+ ] }),
2958
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
2959
+ showHeight && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
2960
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Height" }),
2961
+ /* @__PURE__ */ jsxRuntime.jsx(
2962
+ Input,
2963
+ {
2964
+ type: "number",
2965
+ min: 0,
2966
+ value: currentValue.height ?? CUSTOM_DEFAULTS.height,
2967
+ onChange: (e) => handleValueChange("height", parseInt(e.target.value, 10) || 0),
2968
+ disabled: readOnly,
2969
+ className: "h-8 text-sm font-mono"
2970
+ }
2971
+ )
2972
+ ] }),
2973
+ showFontSize && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
2974
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Font Size" }),
2975
+ /* @__PURE__ */ jsxRuntime.jsx(
2976
+ Input,
2977
+ {
2978
+ type: "number",
2979
+ min: 0,
2980
+ value: currentValue.fontSize ?? CUSTOM_DEFAULTS.fontSize,
2981
+ onChange: (e) => handleValueChange("fontSize", parseInt(e.target.value, 10) || 0),
2982
+ disabled: readOnly,
2983
+ className: "h-8 text-sm font-mono"
2984
+ }
2985
+ )
2986
+ ] }),
2987
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
2988
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Padding X" }),
2989
+ /* @__PURE__ */ jsxRuntime.jsx(
2990
+ Input,
2991
+ {
2992
+ type: "number",
2993
+ min: 0,
2994
+ value: currentValue.paddingX ?? CUSTOM_DEFAULTS.paddingX,
2995
+ onChange: (e) => handleValueChange("paddingX", parseInt(e.target.value, 10) || 0),
2996
+ disabled: readOnly,
2997
+ className: "h-8 text-sm font-mono"
2998
+ }
2999
+ )
3000
+ ] }),
3001
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
3002
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: "Padding Y" }),
3003
+ /* @__PURE__ */ jsxRuntime.jsx(
3004
+ Input,
3005
+ {
3006
+ type: "number",
3007
+ min: 0,
3008
+ value: currentValue.paddingY ?? CUSTOM_DEFAULTS.paddingY,
3009
+ onChange: (e) => handleValueChange("paddingY", parseInt(e.target.value, 10) || 0),
3010
+ disabled: readOnly,
3011
+ className: "h-8 text-sm font-mono"
3012
+ }
3013
+ )
3014
+ ] })
3015
+ ] }),
3016
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-muted-foreground font-mono pt-1 border-t border-border/50", children: [
3017
+ showHeight && `h: ${currentValue.height ?? CUSTOM_DEFAULTS.height}${currentValue.unit || "px"}`,
3018
+ showHeight && " | ",
3019
+ `p: ${currentValue.paddingY ?? CUSTOM_DEFAULTS.paddingY}${currentValue.unit || "px"} ${currentValue.paddingX ?? CUSTOM_DEFAULTS.paddingX}${currentValue.unit || "px"}`,
3020
+ showFontSize && ` | font: ${currentValue.fontSize ?? CUSTOM_DEFAULTS.fontSize}${currentValue.unit || "px"}`
3021
+ ] })
3022
+ ] })
3023
+ ] });
3024
+ }
3025
+ function sizeValueToCSS(size) {
3026
+ if (!size || size.mode !== "custom") return void 0;
3027
+ const unit = size.unit || "px";
3028
+ const style = {};
3029
+ if (size.height != null) {
3030
+ style.height = `${size.height}${unit}`;
3031
+ }
3032
+ if (size.paddingX != null || size.paddingY != null) {
3033
+ const py = size.paddingY ?? 0;
3034
+ const px = size.paddingX ?? 0;
3035
+ style.padding = `${py}${unit} ${px}${unit}`;
3036
+ }
3037
+ if (size.fontSize != null) {
3038
+ style.fontSize = `${size.fontSize}${unit}`;
3039
+ }
3040
+ return Object.keys(style).length > 0 ? style : void 0;
3041
+ }
3042
+ function getSizeClasses(size, sizeMap) {
3043
+ if (!size) return sizeMap.default || "";
3044
+ if (size.mode === "custom") return "";
3045
+ return sizeMap[size.mode] || sizeMap.default || "";
3046
+ }
3047
+ var DEFAULT_VALUE, CUSTOM_DEFAULTS;
3048
+ var init_SizeField = __esm({
3049
+ "src/fields/SizeField.tsx"() {
3050
+ "use client";
3051
+ init_button();
3052
+ init_input();
3053
+ init_label();
3054
+ init_utils();
3055
+ DEFAULT_VALUE = {
3056
+ mode: "default"
3057
+ };
3058
+ CUSTOM_DEFAULTS = {
3059
+ height: 40,
3060
+ paddingX: 16,
3061
+ paddingY: 8,
3062
+ fontSize: 14,
3063
+ unit: "px"
3064
+ };
3065
+ React.memo(SizeFieldInner);
3066
+ }
3067
+ });
3068
+
3069
+ // src/theme/defaults.ts
3070
+ var DEFAULT_BUTTON_VARIANTS, DEFAULT_CTA_BUTTON_VARIANTS, DEFAULT_CTA_BACKGROUND_STYLES, DEFAULT_COLOR_PRESETS, DEFAULT_FOCUS_RING, DEFAULT_THEME;
3071
+ var init_defaults2 = __esm({
3072
+ "src/theme/defaults.ts"() {
3073
+ DEFAULT_BUTTON_VARIANTS = {
3074
+ default: { classes: "bg-primary text-primary-foreground hover:bg-primary/90" },
3075
+ secondary: { classes: "bg-secondary text-secondary-foreground hover:bg-secondary/80" },
3076
+ outline: { classes: "border border-input bg-background hover:bg-accent hover:text-accent-foreground" },
3077
+ ghost: { classes: "bg-transparent hover:bg-accent hover:text-accent-foreground" },
3078
+ destructive: { classes: "bg-destructive text-destructive-foreground hover:bg-destructive/90" },
3079
+ link: { classes: "text-primary underline-offset-4 hover:underline bg-transparent" }
3080
+ };
3081
+ DEFAULT_CTA_BUTTON_VARIANTS = {
3082
+ primary: { classes: "bg-primary text-primary-foreground hover:bg-primary/90" },
3083
+ secondary: { classes: "bg-secondary text-secondary-foreground hover:bg-secondary/80" },
3084
+ outline: { classes: "border border-input bg-background hover:bg-accent hover:text-accent-foreground" },
3085
+ ghost: { classes: "bg-transparent hover:bg-accent hover:text-accent-foreground" },
3086
+ link: { classes: "text-primary underline-offset-4 hover:underline bg-transparent" }
3087
+ };
3088
+ DEFAULT_CTA_BACKGROUND_STYLES = {
3089
+ default: "bg-muted",
3090
+ dark: "bg-foreground text-background",
3091
+ light: "bg-background"
3092
+ };
3093
+ DEFAULT_COLOR_PRESETS = [
3094
+ { hex: "#ffffff", label: "White" },
3095
+ { hex: "#f9fafb", label: "Gray 50" },
3096
+ { hex: "#f3f4f6", label: "Gray 100" },
3097
+ { hex: "#1f2937", label: "Gray 800" },
3098
+ { hex: "#111827", label: "Gray 900" },
3099
+ { hex: "#000000", label: "Black" },
3100
+ { hex: "#3b82f6", label: "Blue" },
3101
+ { hex: "#10b981", label: "Green" },
3102
+ { hex: "#f59e0b", label: "Amber" },
3103
+ { hex: "#ef4444", label: "Red" }
3104
+ ];
3105
+ DEFAULT_FOCUS_RING = "focus:ring-ring";
3106
+ DEFAULT_THEME = {
3107
+ buttonVariants: DEFAULT_BUTTON_VARIANTS,
3108
+ ctaButtonVariants: DEFAULT_CTA_BUTTON_VARIANTS,
3109
+ ctaBackgroundStyles: DEFAULT_CTA_BACKGROUND_STYLES,
3110
+ colorPresets: DEFAULT_COLOR_PRESETS,
3111
+ focusRingColor: DEFAULT_FOCUS_RING
3112
+ };
3113
+ }
3114
+ });
3115
+
3116
+ // src/theme/utils.ts
3117
+ function resolveTheme(config) {
3118
+ if (!config) return DEFAULT_THEME;
3119
+ return {
3120
+ buttonVariants: mergeVariants(DEFAULT_BUTTON_VARIANTS, config.buttonVariants),
3121
+ ctaButtonVariants: mergeVariants(DEFAULT_CTA_BUTTON_VARIANTS, config.ctaButtonVariants),
3122
+ ctaBackgroundStyles: mergeBackgroundStyles(
3123
+ DEFAULT_CTA_BACKGROUND_STYLES,
3124
+ config.ctaBackgroundStyles
3125
+ ),
3126
+ colorPresets: resolveColorPresets(config),
3127
+ focusRingColor: config.focusRingColor ?? DEFAULT_FOCUS_RING
3128
+ };
3129
+ }
3130
+ function mergeVariants(defaults, overrides) {
3131
+ if (!overrides) return defaults;
3132
+ const result = { ...defaults };
3133
+ for (const key of Object.keys(overrides)) {
3134
+ const override = overrides[key];
3135
+ if (override) {
3136
+ result[key] = override;
3137
+ }
3138
+ }
3139
+ return result;
3140
+ }
3141
+ function mergeBackgroundStyles(defaults, overrides) {
3142
+ if (!overrides) return defaults;
3143
+ return { ...defaults, ...overrides };
3144
+ }
3145
+ function resolveColorPresets(config) {
3146
+ if (!config.colorPresets) {
3147
+ return DEFAULT_COLOR_PRESETS;
3148
+ }
3149
+ if (config.extendColorPresets) {
3150
+ return [...DEFAULT_COLOR_PRESETS, ...config.colorPresets];
3151
+ }
3152
+ return config.colorPresets;
3153
+ }
3154
+ function getVariantClasses(variants, variant, fallback = "default") {
3155
+ const config = variants[variant];
3156
+ if (config?.classes) {
3157
+ return config.classes;
3158
+ }
3159
+ const fallbackConfig = variants[fallback];
3160
+ return fallbackConfig?.classes ?? "";
3161
+ }
3162
+ var init_utils3 = __esm({
3163
+ "src/theme/utils.ts"() {
3164
+ init_defaults2();
3165
+ }
3166
+ });
3167
+ var sizeStyles, alignmentWrapperMap, defaultProps11, ButtonConfig;
3168
+ var init_Button_server = __esm({
3169
+ "src/components/interactive/Button.server.tsx"() {
3170
+ init_shared();
3171
+ init_AnimatedWrapper();
3172
+ init_SizeField();
3173
+ init_defaults2();
3174
+ init_utils3();
3175
+ sizeStyles = {
3176
+ sm: "h-8 px-3 text-sm",
3177
+ default: "h-10 px-4",
3178
+ lg: "h-12 px-8 text-lg"
3179
+ };
3180
+ alignmentWrapperMap = {
3181
+ left: "text-left",
3182
+ center: "text-center",
3183
+ right: "text-right"
3184
+ };
3185
+ defaultProps11 = {
3186
+ text: "Click Me",
3187
+ link: "",
3188
+ variant: "default",
3189
+ size: null,
3190
+ openInNewTab: "no",
3191
+ margin: null,
3192
+ customBackgroundColor: null,
3193
+ customTextColor: null,
3194
+ customBorder: null,
3195
+ alignment: null,
3196
+ transform: null,
3197
+ animation: null,
3198
+ customPadding: null
3199
+ };
3200
+ ButtonConfig = {
3201
+ label: "Button",
3202
+ defaultProps: defaultProps11,
3203
+ render: ({ text, link, variant, size, openInNewTab, alignment, margin, customBackgroundColor, customTextColor, customBorder, transform, animation, customPadding }) => {
3204
+ const hasCustomBackground = customBackgroundColor?.hex;
3205
+ const hasCustomTextColor = customTextColor?.hex;
3206
+ const hasCustomPadding = customPadding;
3207
+ const hasCustomSize = size?.mode === "custom";
3208
+ const variantClasses = getVariantClasses(DEFAULT_BUTTON_VARIANTS, variant, "default");
3209
+ const sizeClasses = getSizeClasses(size, sizeStyles);
3210
+ const buttonClasses = cn2(
3211
+ "inline-flex items-center justify-center font-medium transition-colors",
3212
+ `focus:outline-none focus:ring-2 focus:ring-offset-2 ${DEFAULT_FOCUS_RING}`,
3213
+ "disabled:opacity-50 disabled:pointer-events-none",
3214
+ // Only apply variant styles if no custom background/text color
3215
+ !hasCustomBackground && !hasCustomTextColor && variantClasses,
3216
+ // Only apply background portion of variant if no custom background
3217
+ hasCustomBackground && !hasCustomTextColor && "hover:opacity-90",
3218
+ // Only apply size classes if not using custom size or custom padding
3219
+ !hasCustomPadding && !hasCustomSize && sizeClasses,
3220
+ // Apply rounded-md unless custom border has radius
3221
+ !customBorder?.radius && "rounded-md"
3222
+ );
3223
+ const buttonStyle = {};
3224
+ if (hasCustomBackground) {
3225
+ buttonStyle.backgroundColor = colorValueToCSS(customBackgroundColor);
3226
+ }
3227
+ if (hasCustomTextColor) {
3228
+ buttonStyle.color = colorValueToCSS(customTextColor);
3229
+ }
3230
+ const borderStyles = borderValueToCSS(customBorder);
3231
+ if (borderStyles) {
3232
+ Object.assign(buttonStyle, borderStyles);
3233
+ }
3234
+ const customSizeStyles = sizeValueToCSS(size);
3235
+ if (customSizeStyles) {
3236
+ Object.assign(buttonStyle, customSizeStyles);
3237
+ }
3238
+ const paddingCSS = paddingValueToCSS(customPadding);
3239
+ if (paddingCSS) {
3240
+ buttonStyle.padding = paddingCSS;
3241
+ }
3242
+ const transformStyles = transformValueToCSS(transform);
3243
+ if (transformStyles) {
3244
+ Object.assign(buttonStyle, transformStyles);
3245
+ }
3246
+ const buttonElement = link ? /* @__PURE__ */ jsxRuntime.jsx(
3247
+ "a",
3248
+ {
3249
+ href: link,
3250
+ target: openInNewTab === "yes" ? "_blank" : void 0,
3251
+ rel: openInNewTab === "yes" ? "noopener noreferrer" : void 0,
3252
+ className: buttonClasses,
3253
+ style: buttonStyle,
3254
+ children: text
3255
+ }
3256
+ ) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: buttonClasses, style: buttonStyle, children: text });
3257
+ const wrapperStyle = {};
3258
+ const marginCSS = marginValueToCSS(margin);
3259
+ if (marginCSS) {
3260
+ wrapperStyle.margin = marginCSS;
3261
+ }
3262
+ const alignmentValue = alignment ?? "left";
3263
+ return /* @__PURE__ */ jsxRuntime.jsx(
3264
+ AnimatedWrapper,
3265
+ {
3266
+ animation,
3267
+ className: alignmentWrapperMap[alignmentValue] || alignmentWrapperMap.left,
3268
+ style: wrapperStyle,
3269
+ children: buttonElement
3270
+ }
3271
+ );
3272
+ }
3273
+ };
3274
+ }
3275
+ });
3276
+ var defaultProps12, CardConfig;
3277
+ var init_Card_server = __esm({
3278
+ "src/components/interactive/Card.server.tsx"() {
3279
+ init_shared();
3280
+ init_AnimatedWrapper();
3281
+ defaultProps12 = {
3282
+ image: null,
3283
+ heading: "Card Heading",
3284
+ text: "Card description text goes here.",
3285
+ link: "",
3286
+ openInNewTab: false,
3287
+ shadow: "md",
3288
+ margin: null,
3289
+ background: null,
3290
+ border: null,
3291
+ dimensions: null,
3292
+ alignment: null,
3293
+ transform: null,
3294
+ animation: null,
3295
+ customPadding: null
3296
+ };
3297
+ CardConfig = {
3298
+ label: "Card",
3299
+ defaultProps: defaultProps12,
3300
+ render: ({ image, heading, text, link, openInNewTab, shadow, background, dimensions, alignment, margin, border, transform, animation, customPadding }) => {
3301
+ const hasBorderRadius = border?.radius && border.radius > 0;
3302
+ const cardClasses = cn2(
3303
+ "overflow-hidden transition-all bg-card",
3304
+ !hasBorderRadius && "rounded-lg",
3305
+ shadowMap[shadow] || "",
3306
+ link && "hover:shadow-lg cursor-pointer"
3307
+ );
3308
+ const wrapperStyle = {};
3309
+ const marginCSS = marginValueToCSS(margin);
3310
+ if (marginCSS) {
3311
+ wrapperStyle.margin = marginCSS;
3312
+ }
3313
+ const dimensionsStyles = dimensionsValueToCSS(dimensions);
3314
+ if (dimensionsStyles) {
3315
+ Object.assign(wrapperStyle, dimensionsStyles);
3316
+ }
3317
+ const transformStyles = transformValueToCSS(transform);
3318
+ if (transformStyles) {
3319
+ Object.assign(wrapperStyle, transformStyles);
3320
+ }
3321
+ const alignmentValue = alignment ?? "left";
3322
+ const alignmentClasses = cn2(
3323
+ "flex",
3324
+ alignmentValue === "left" && "justify-start",
3325
+ alignmentValue === "center" && "justify-center",
3326
+ alignmentValue === "right" && "justify-end"
3327
+ );
3328
+ const backgroundStyles = backgroundValueToCSS(background);
3329
+ const cardStyle = {
3330
+ ...backgroundStyles
3331
+ };
3332
+ const borderStyles = borderValueToCSS(border);
3333
+ if (borderStyles) {
3334
+ Object.assign(cardStyle, borderStyles);
3335
+ }
3336
+ const paddingCSS = paddingValueToCSS(customPadding);
3337
+ if (paddingCSS) {
3338
+ cardStyle.padding = paddingCSS;
3339
+ }
3340
+ const cardContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cardClasses, style: cardStyle, children: [
3341
+ image?.url ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative aspect-video w-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
3342
+ "img",
3343
+ {
3344
+ src: image.url,
3345
+ alt: image.alt || heading || "",
3346
+ className: "w-full h-full object-cover"
3347
+ }
3348
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video w-full bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "No image" }) }),
3349
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
3350
+ heading && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: heading }),
3351
+ text && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: text })
3352
+ ] })
3353
+ ] });
3354
+ if (link) {
3355
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsxRuntime.jsx(
3356
+ "a",
3357
+ {
3358
+ href: link,
3359
+ target: openInNewTab ? "_blank" : void 0,
3360
+ rel: openInNewTab ? "noopener noreferrer" : void 0,
3361
+ className: "block",
3362
+ style: wrapperStyle,
3363
+ children: cardContent
3364
+ }
3365
+ ) }) });
3366
+ }
3367
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: alignmentClasses, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: wrapperStyle, children: cardContent }) }) });
3368
+ }
3369
+ };
3370
+ }
3371
+ });
3372
+ var defaultProps13, DividerConfig;
3373
+ var init_Divider_server = __esm({
3374
+ "src/components/interactive/Divider.server.tsx"() {
3375
+ init_shared();
3376
+ init_AnimatedWrapper();
3377
+ defaultProps13 = {
3378
+ style: "solid",
3379
+ color: null,
3380
+ margin: null,
3381
+ dimensions: null,
3382
+ transform: null,
3383
+ animation: null,
3384
+ customPadding: null
3385
+ };
3386
+ DividerConfig = {
3387
+ label: "Divider",
3388
+ defaultProps: defaultProps13,
3389
+ render: ({ style, color, dimensions, margin, transform, animation, customPadding }) => {
3390
+ const dimensionsStyles = dimensionsValueToCSS(dimensions);
3391
+ const wrapperStyle = {
3392
+ ...dimensionsStyles
3393
+ };
3394
+ const marginCSS = marginValueToCSS(margin);
3395
+ if (marginCSS) {
3396
+ wrapperStyle.margin = marginCSS;
3397
+ }
3398
+ const paddingCSS = paddingValueToCSS(customPadding);
3399
+ if (paddingCSS) {
3400
+ wrapperStyle.padding = paddingCSS;
3401
+ }
3402
+ const transformStyles = transformValueToCSS(transform);
3403
+ if (transformStyles) {
3404
+ Object.assign(wrapperStyle, transformStyles);
3405
+ }
3406
+ const customColor = colorValueToCSS(color);
3407
+ const hrStyle = customColor ? { borderColor: customColor } : void 0;
3408
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4", style: Object.keys(wrapperStyle).length > 0 ? wrapperStyle : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
3409
+ "hr",
3410
+ {
3411
+ className: cn2(
3412
+ "border-t border-border",
3413
+ dividerStyleMap[style] || dividerStyleMap.solid
3414
+ ),
3415
+ style: hrStyle
3416
+ }
3417
+ ) }) });
3418
+ }
3419
+ };
3420
+ }
3421
+ });
3422
+ function AccordionItem({
3423
+ item,
3424
+ isOpen,
3425
+ onToggle,
3426
+ textColorCSS
3427
+ }) {
3428
+ const textStyle = textColorCSS ? { color: textColorCSS } : {};
3429
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-b border-border last:border-b-0", children: [
3430
+ /* @__PURE__ */ jsxRuntime.jsxs(
3431
+ "button",
3432
+ {
3433
+ type: "button",
3434
+ onClick: onToggle,
3435
+ className: "flex w-full items-center justify-between py-4 px-4 text-left font-medium transition-all hover:bg-muted/50 text-foreground",
3436
+ style: textStyle,
3437
+ children: [
3438
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title }),
3439
+ /* @__PURE__ */ jsxRuntime.jsx(
3440
+ iconsReact.IconChevronDown,
3441
+ {
3442
+ className: cn2(
3443
+ "h-4 w-4 shrink-0 transition-transform duration-200",
3444
+ isOpen && "rotate-180"
3445
+ )
3446
+ }
3447
+ )
3448
+ ]
3449
+ }
3450
+ ),
3451
+ /* @__PURE__ */ jsxRuntime.jsx(
3452
+ "div",
3453
+ {
3454
+ className: cn2(
3455
+ "overflow-hidden transition-all duration-200",
3456
+ isOpen ? "max-h-[1000px] opacity-100" : "max-h-0 opacity-0"
3457
+ ),
3458
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3459
+ "div",
3460
+ {
3461
+ className: "px-4 pb-4 text-muted-foreground",
3462
+ style: textColorCSS ? { color: textColorCSS } : void 0,
3463
+ children: item.content
3464
+ }
3465
+ )
3466
+ }
3467
+ )
3468
+ ] });
3469
+ }
3470
+ function AccordionClient({
3471
+ items,
3472
+ allowMultiple,
3473
+ textColor,
3474
+ margin,
3475
+ background,
3476
+ dimensions,
3477
+ transform,
3478
+ animation,
3479
+ customPadding
3480
+ }) {
3481
+ const [openItems, setOpenItems] = React.useState(() => {
3482
+ const initialOpen = /* @__PURE__ */ new Set();
3483
+ items?.forEach((item, index) => {
3484
+ if (item.defaultOpen) {
3485
+ initialOpen.add(index);
3486
+ }
3487
+ });
3488
+ return initialOpen;
3489
+ });
3490
+ const handleToggle = (index) => {
3491
+ setOpenItems((prev) => {
3492
+ const newSet = new Set(prev);
3493
+ if (newSet.has(index)) {
3494
+ newSet.delete(index);
3495
+ } else {
3496
+ if (!allowMultiple) {
3497
+ newSet.clear();
3498
+ }
3499
+ newSet.add(index);
3500
+ }
3501
+ return newSet;
3502
+ });
3503
+ };
3504
+ const textColorCSS = colorValueToCSS(textColor);
3505
+ const dimensionsStyles = dimensionsValueToCSS(dimensions);
3506
+ const accordionClasses = "rounded-lg border border-border overflow-hidden bg-card";
3507
+ const backgroundStyles = backgroundValueToCSS(background);
3508
+ const accordionStyle = backgroundStyles && Object.keys(backgroundStyles).length > 0 ? backgroundStyles : {};
3509
+ const style = {
3510
+ ...dimensionsStyles
3511
+ };
3512
+ const marginCSS = marginValueToCSS(margin);
3513
+ if (marginCSS) {
3514
+ style.margin = marginCSS;
3515
+ }
3516
+ const paddingCSS = paddingValueToCSS(customPadding);
3517
+ if (paddingCSS) {
3518
+ style.padding = paddingCSS;
3519
+ }
3520
+ const transformStyles = transformValueToCSS(transform);
3521
+ if (transformStyles) {
3522
+ Object.assign(style, transformStyles);
3523
+ }
3524
+ if (!items || items.length === 0) {
3525
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4", style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: accordionClasses, style: accordionStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-muted-foreground", children: "No accordion items. Add items in the editor." }) }) }) });
3526
+ }
3527
+ return /* @__PURE__ */ jsxRuntime.jsx(AnimatedWrapper, { animation, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4", style: Object.keys(style).length > 0 ? style : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: accordionClasses, style: accordionStyle, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
3528
+ AccordionItem,
3529
+ {
3530
+ item,
3531
+ isOpen: openItems.has(index),
3532
+ onToggle: () => handleToggle(index),
3533
+ textColorCSS
3534
+ },
3535
+ index
3536
+ )) }) }) });
3537
+ }
3538
+ var init_AccordionClient = __esm({
3539
+ "src/components/AccordionClient.tsx"() {
3540
+ "use client";
3541
+ init_shared();
3542
+ init_AnimatedWrapper();
3543
+ }
3544
+ });
3545
+ var defaultProps14, AccordionConfig;
3546
+ var init_Accordion_server = __esm({
3547
+ "src/components/interactive/Accordion.server.tsx"() {
3548
+ init_AccordionClient();
3549
+ defaultProps14 = {
3550
+ items: [
3551
+ {
3552
+ title: "What is this?",
3553
+ content: "This is an accordion component that can expand and collapse.",
3554
+ defaultOpen: false
3555
+ },
3556
+ {
3557
+ title: "How do I use it?",
3558
+ content: "Click on each item to expand or collapse it.",
3559
+ defaultOpen: false
3560
+ }
3561
+ ],
3562
+ allowMultiple: false,
3563
+ textColor: null,
3564
+ margin: null,
3565
+ background: null,
3566
+ dimensions: null,
3567
+ transform: null,
3568
+ animation: null,
3569
+ customPadding: null
3570
+ };
3571
+ AccordionConfig = {
3572
+ label: "Accordion",
3573
+ defaultProps: defaultProps14,
3574
+ render: (props) => /* @__PURE__ */ jsxRuntime.jsx(
3575
+ AccordionClient,
3576
+ {
3577
+ items: props.items,
3578
+ allowMultiple: props.allowMultiple,
3579
+ textColor: props.textColor,
3580
+ margin: props.margin,
3581
+ background: props.background,
3582
+ dimensions: props.dimensions,
3583
+ transform: props.transform,
3584
+ animation: props.animation,
3585
+ customPadding: props.customPadding
3586
+ }
3587
+ )
3588
+ };
3589
+ }
3590
+ });
3591
+
3592
+ // src/config/merge.ts
3593
+ var init_merge = __esm({
3594
+ "src/config/merge.ts"() {
3595
+ }
3596
+ });
3597
+ function createConfig(layouts = DEFAULT_LAYOUTS) {
3598
+ const layoutOptions = layoutsToOptions(layouts);
3599
+ return {
3600
+ root: {
3601
+ fields: {
3602
+ title: {
3603
+ type: "text",
3604
+ label: "Page Title"
3605
+ },
3606
+ pageLayout: {
3607
+ type: "select",
3608
+ label: "Page Layout",
3609
+ options: layoutOptions.map(({ value, label }) => ({ value, label }))
3610
+ }
3611
+ },
3612
+ defaultProps: {
3613
+ title: "New Page",
3614
+ pageLayout: "default"
3615
+ },
3616
+ render: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children })
3617
+ },
3618
+ categories: {
3619
+ layout: {
3620
+ title: "Layout",
3621
+ components: ["Container", "Flex", "Grid", "Section", "Spacer", "Template"],
3622
+ defaultExpanded: true
3623
+ },
3624
+ typography: {
3625
+ title: "Typography",
3626
+ components: ["Heading", "Text", "RichText"]
3627
+ },
3628
+ media: {
3629
+ title: "Media",
3630
+ components: ["Image"]
3631
+ },
3632
+ interactive: {
3633
+ title: "Interactive",
3634
+ components: ["Button", "Card", "Divider", "Accordion"]
3635
+ }
3636
+ },
3637
+ components: {
3638
+ // Layout
3639
+ Container: ContainerConfig,
3640
+ Flex: FlexConfig,
3641
+ Grid: GridConfig,
3642
+ Section: SectionConfig,
3643
+ Spacer: SpacerConfig,
3644
+ Template: TemplateServerConfig,
3645
+ // Typography
3646
+ Heading: HeadingConfig,
3647
+ Text: TextConfig,
3648
+ RichText: RichTextConfig,
3649
+ // Media
3650
+ Image: ImageConfig,
3651
+ // Interactive
3652
+ Button: ButtonConfig,
3653
+ Card: CardConfig,
3654
+ Divider: DividerConfig,
3655
+ Accordion: AccordionConfig
3656
+ }
3657
+ };
3658
+ }
3659
+ var baseConfig;
3660
+ var init_config = __esm({
3661
+ "src/config/index.tsx"() {
3662
+ init_layouts();
3663
+ init_Container_server();
3664
+ init_Flex_server();
3665
+ init_Grid_server();
3666
+ init_Section_server();
3667
+ init_Spacer_server();
3668
+ init_Template_server();
3669
+ init_Heading_server();
3670
+ init_Text_server();
3671
+ init_RichText_server();
3672
+ init_Image_server();
3673
+ init_Button_server();
3674
+ init_Card_server();
3675
+ init_Divider_server();
3676
+ init_Accordion_server();
3677
+ init_merge();
3678
+ init_layouts();
3679
+ baseConfig = createConfig(DEFAULT_LAYOUTS);
3680
+ }
3681
+ });
3682
+ function PageRenderer({
3683
+ data,
3684
+ config = baseConfig,
3685
+ wrapper: Wrapper,
3686
+ className,
3687
+ layouts = DEFAULT_LAYOUTS
3688
+ }) {
3689
+ if (!data || !data.content) {
3690
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "No content available" }) });
3691
+ }
3692
+ const content = /* @__PURE__ */ jsxRuntime.jsx(puck.Render, { config, data });
3693
+ const rootProps = data.root?.props;
3694
+ const overrides = {
3695
+ showHeader: rootProps?.showHeader,
3696
+ showFooter: rootProps?.showFooter,
3697
+ background: rootProps?.pageBackground,
3698
+ maxWidth: rootProps?.pageMaxWidth
3699
+ };
3700
+ let result = content;
3701
+ if (Wrapper) {
3702
+ result = /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { children: result });
3703
+ } else {
3704
+ const pageLayout = rootProps?.pageLayout;
3705
+ const layout = pageLayout ? getLayout(layouts, pageLayout) : void 0;
3706
+ if (layout) {
3707
+ result = /* @__PURE__ */ jsxRuntime.jsx(LayoutWrapper, { layout, className, overrides, children: result });
3708
+ } else if (className || overrides.background) {
3709
+ result = /* @__PURE__ */ jsxRuntime.jsx(LayoutWrapper, { className, overrides, children: result });
3710
+ }
3711
+ }
3712
+ return result;
3713
+ }
3714
+ var init_PageRenderer = __esm({
3715
+ "src/render/PageRenderer.tsx"() {
3716
+ init_config();
3717
+ init_layouts();
3718
+ }
3719
+ });
3720
+ exports.PreviewModal = void 0;
3721
+ var init_PreviewModal = __esm({
3722
+ "src/editor/components/PreviewModal.tsx"() {
3723
+ "use client";
3724
+ init_dialog();
3725
+ init_utils();
3726
+ init_PageRenderer();
3727
+ exports.PreviewModal = React.memo(function PreviewModal2({
3728
+ isOpen,
3729
+ onClose,
3730
+ data,
3731
+ pageTitle,
3732
+ onOpenInNewTab,
3733
+ layouts,
3734
+ hasUnsavedChanges = false,
3735
+ onSave,
3736
+ isSaving = false
3737
+ }) {
3738
+ const [pendingNavigation, setPendingNavigation] = React.useState(null);
3739
+ const [isNavigating, setIsNavigating] = React.useState(false);
3740
+ const handleContentClick = React.useCallback((e) => {
3741
+ const target = e.target;
3742
+ const anchor = target.closest("a");
3743
+ if (anchor) {
3744
+ const href = anchor.getAttribute("href");
3745
+ if (href?.startsWith("#") && !href.includes("/")) {
3746
+ return;
3747
+ }
3748
+ e.preventDefault();
3749
+ e.stopPropagation();
3750
+ if (href) {
3751
+ setPendingNavigation(href);
3752
+ }
3753
+ }
3754
+ }, []);
3755
+ const handleNavigate = React.useCallback((saveFirst) => {
3756
+ if (!pendingNavigation) return;
3757
+ const navigate = () => {
3758
+ setIsNavigating(true);
3759
+ onClose();
3760
+ window.location.href = pendingNavigation;
3761
+ };
3762
+ if (saveFirst && onSave) {
3763
+ onSave().then(navigate).catch(() => {
3764
+ setIsNavigating(false);
3765
+ });
3766
+ } else {
3767
+ navigate();
3768
+ }
3769
+ }, [pendingNavigation, onClose, onSave]);
3770
+ const handleCancelNavigation = React.useCallback(() => {
3771
+ setPendingNavigation(null);
3772
+ }, []);
3773
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(
3774
+ DialogContentFullscreen,
3775
+ {
3776
+ hideCloseButton: true,
3777
+ accessibleTitle: `Preview: ${pageTitle || "Page"}`,
3778
+ className: "p-0",
3779
+ children: [
3780
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed top-1/2 right-4 -translate-y-1/2 z-[9998] flex flex-col gap-2 items-end", children: [
3781
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-lg shadow-lg border border-gray-200 p-2 flex flex-col gap-1", children: [
3782
+ /* @__PURE__ */ jsxRuntime.jsxs(
3783
+ "button",
3784
+ {
3785
+ type: "button",
3786
+ onClick: onClose,
3787
+ className: "flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 rounded-md transition-colors",
3788
+ title: "Close preview (Esc)",
3789
+ children: [
3790
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" }),
3791
+ "Close Preview"
3792
+ ]
3793
+ }
3794
+ ),
3795
+ onOpenInNewTab && /* @__PURE__ */ jsxRuntime.jsxs(
3796
+ "button",
3797
+ {
3798
+ type: "button",
3799
+ onClick: onOpenInNewTab,
3800
+ className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",
3801
+ title: "Open published page in new tab",
3802
+ children: [
3803
+ /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconExternalLink, { className: "h-4 w-4" }),
3804
+ "View Page"
3805
+ ]
3806
+ }
3807
+ )
3808
+ ] }),
3809
+ hasUnsavedChanges && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-amber-100 text-amber-700 px-3 py-1.5 rounded-full text-xs font-medium shadow-sm", children: "Unsaved changes" })
3810
+ ] }),
3811
+ /* @__PURE__ */ jsxRuntime.jsx(
3812
+ "div",
3813
+ {
3814
+ className: "h-full overflow-auto bg-white",
3815
+ onClickCapture: handleContentClick,
3816
+ children: data ? /* @__PURE__ */ jsxRuntime.jsx(PageRenderer, { data, layouts }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full text-gray-500", children: "No content to preview" })
3817
+ }
3818
+ ),
3819
+ pendingNavigation && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxRuntime.jsxs(
3820
+ "div",
3821
+ {
3822
+ className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 overflow-hidden",
3823
+ onClick: (e) => e.stopPropagation(),
3824
+ children: [
3825
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-5 py-4 border-b border-gray-200 bg-amber-50", children: [
3826
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconAlertTriangle, { className: "h-5 w-5 text-amber-600" }) }),
3827
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3828
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-base font-semibold text-gray-900", children: "Navigate away?" }),
3829
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500", children: "This will close the preview" })
3830
+ ] })
3831
+ ] }),
3832
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4", children: [
3833
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-700 mb-2", children: "You're about to navigate to:" }),
3834
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-mono bg-gray-100 px-3 py-2 rounded text-gray-800 break-all", children: pendingNavigation }),
3835
+ hasUnsavedChanges && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-amber-600 mt-3 font-medium", children: "You have unsaved changes that will be lost." })
3836
+ ] }),
3837
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 bg-gray-50 border-t border-gray-200 flex flex-col sm:flex-row gap-2 sm:justify-end", children: [
3838
+ /* @__PURE__ */ jsxRuntime.jsx(
3839
+ "button",
3840
+ {
3841
+ type: "button",
3842
+ onClick: handleCancelNavigation,
3843
+ disabled: isNavigating || isSaving,
3844
+ className: "px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors disabled:opacity-50",
3845
+ children: "Cancel"
3846
+ }
3847
+ ),
3848
+ hasUnsavedChanges && onSave && /* @__PURE__ */ jsxRuntime.jsx(
3849
+ "button",
3850
+ {
3851
+ type: "button",
3852
+ onClick: () => handleNavigate(true),
3853
+ disabled: isNavigating || isSaving,
3854
+ className: "px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50",
3855
+ children: isSaving ? "Saving..." : "Save & Navigate"
3856
+ }
3857
+ ),
3858
+ /* @__PURE__ */ jsxRuntime.jsx(
3859
+ "button",
3860
+ {
3861
+ type: "button",
3862
+ onClick: () => handleNavigate(false),
3863
+ disabled: isNavigating || isSaving,
3864
+ className: cn(
3865
+ "px-4 py-2 text-sm font-medium rounded-md transition-colors disabled:opacity-50",
3866
+ hasUnsavedChanges ? "text-red-700 bg-red-50 border border-red-200 hover:bg-red-100" : "text-white bg-gray-900 hover:bg-gray-800"
3867
+ ),
3868
+ children: isNavigating ? "Navigating..." : hasUnsavedChanges ? "Navigate without saving" : "Navigate"
3869
+ }
3870
+ )
3871
+ ] })
3872
+ ]
3873
+ }
3874
+ ) })
3875
+ ]
3876
+ }
3877
+ ) });
3878
+ });
3879
+ }
3880
+ });
3881
+ function useUnsavedChanges() {
3882
+ const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false);
3883
+ const hasUnsavedChangesRef = React.useRef(hasUnsavedChanges);
3884
+ hasUnsavedChangesRef.current = hasUnsavedChanges;
3885
+ React.useEffect(() => {
3886
+ const handleBeforeUnload = (e) => {
3887
+ if (hasUnsavedChangesRef.current) {
3888
+ e.preventDefault();
3889
+ e.returnValue = "";
3890
+ }
3891
+ };
3892
+ window.addEventListener("beforeunload", handleBeforeUnload);
3893
+ return () => window.removeEventListener("beforeunload", handleBeforeUnload);
3894
+ }, []);
3895
+ const markClean = React.useCallback(() => {
3896
+ hasUnsavedChangesRef.current = false;
3897
+ setHasUnsavedChanges(false);
3898
+ }, []);
3899
+ const markDirty = React.useCallback(() => {
3900
+ hasUnsavedChangesRef.current = true;
3901
+ setHasUnsavedChanges(true);
3902
+ }, []);
3903
+ return {
3904
+ hasUnsavedChanges,
3905
+ markClean,
3906
+ markDirty
3907
+ };
3908
+ }
3909
+ var init_useUnsavedChanges = __esm({
3910
+ "src/editor/hooks/useUnsavedChanges.ts"() {
3911
+ "use client";
3912
+ }
3913
+ });
3914
+ function ThemeProvider({ children, theme }) {
3915
+ const resolvedTheme = React.useMemo(() => resolveTheme(theme), [theme]);
3916
+ const value = React.useMemo(
3917
+ () => ({
3918
+ theme: resolvedTheme
3919
+ }),
3920
+ [resolvedTheme]
3921
+ );
3922
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value, children });
3923
+ }
3924
+ var ThemeContext;
3925
+ var init_context = __esm({
3926
+ "src/theme/context.tsx"() {
3927
+ "use client";
3928
+ init_defaults2();
3929
+ init_utils3();
3930
+ ThemeContext = React.createContext(null);
3931
+ }
3932
+ });
3933
+
3934
+ // src/theme/example.ts
3935
+ var init_example = __esm({
3936
+ "src/theme/example.ts"() {
3937
+ }
3938
+ });
3939
+
3940
+ // src/theme/index.ts
3941
+ var init_theme = __esm({
3942
+ "src/theme/index.ts"() {
3943
+ init_context();
3944
+ init_defaults2();
3945
+ init_utils3();
3946
+ init_example();
3947
+ }
3948
+ });
3949
+
3950
+ // src/editor/PuckEditorCore.client.tsx
3951
+ var PuckEditorCore_client_exports = {};
3952
+ __export(PuckEditorCore_client_exports, {
3953
+ PuckEditorCore: () => PuckEditorCore
3954
+ });
3955
+ function PuckEditorCore({
3956
+ pageId,
3957
+ initialData,
3958
+ config,
3959
+ pageTitle,
3960
+ pageSlug,
3961
+ apiEndpoint = "/api/puck/pages",
3962
+ backUrl,
3963
+ previewUrl,
3964
+ enableViewports = true,
3965
+ plugins,
3966
+ layouts,
3967
+ layoutStyles,
3968
+ layoutKey = "pageLayout",
3969
+ headerActionsStart,
3970
+ headerActionsEnd,
3971
+ overrides: customOverrides,
3972
+ onSaveSuccess,
3973
+ onSaveError,
3974
+ onChange: onChangeProp,
3975
+ initialStatus,
3976
+ theme
3977
+ }) {
3978
+ const router = navigation.useRouter();
3979
+ const [isSaving, setIsSaving] = React.useState(false);
3980
+ const [lastSaved, setLastSaved] = React.useState(null);
3981
+ const [saveError, setSaveError] = React.useState(null);
3982
+ const [documentStatus, setDocumentStatus] = React.useState(initialStatus);
3983
+ const [wasPublished, setWasPublished] = React.useState(initialStatus === "published");
3984
+ const { hasUnsavedChanges, markClean, markDirty } = useUnsavedChanges();
3985
+ const [isPreviewOpen, setIsPreviewOpen] = React.useState(false);
3986
+ const dataWithSlug = React.useMemo(() => {
3987
+ const data = initialData;
3988
+ return {
3989
+ ...data,
3990
+ root: {
3991
+ ...data.root,
3992
+ props: {
3993
+ ...data.root?.props,
3994
+ slug: data.root?.props?.slug || pageSlug
3995
+ }
3996
+ }
3997
+ };
3998
+ }, [initialData, pageSlug]);
3999
+ const latestDataRef = React.useRef(dataWithSlug);
4000
+ const handleSave = React.useCallback(
4001
+ async (data) => {
4002
+ setIsSaving(true);
4003
+ const typedData = data;
4004
+ try {
4005
+ const response = await fetch(`${apiEndpoint}/${pageId}`, {
4006
+ method: "PATCH",
4007
+ headers: { "Content-Type": "application/json" },
4008
+ body: JSON.stringify({
4009
+ puckData: data,
4010
+ title: typedData.root?.props?.title || pageTitle,
4011
+ slug: typedData.root?.props?.slug || pageSlug,
4012
+ draft: true
4013
+ // Save as draft, don't publish
4014
+ })
4015
+ });
4016
+ if (!response.ok) {
4017
+ const errorData = await response.json();
4018
+ const errorMessage = errorData.error || errorData.message || "Failed to save page";
4019
+ const err = new Error(errorMessage);
4020
+ err.field = errorData.field;
4021
+ err.details = errorData.details;
4022
+ throw err;
4023
+ }
4024
+ setLastSaved(/* @__PURE__ */ new Date());
4025
+ setSaveError(null);
4026
+ setDocumentStatus("draft");
4027
+ markClean();
4028
+ onSaveSuccess?.(data);
4029
+ } catch (error) {
4030
+ console.error("Error saving page:", error);
4031
+ setSaveError(error instanceof Error ? error.message : "Unknown error");
4032
+ onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
4033
+ } finally {
4034
+ setIsSaving(false);
4035
+ }
4036
+ },
4037
+ [apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]
4038
+ );
4039
+ const handlePublish = React.useCallback(
4040
+ async (data) => {
4041
+ setIsSaving(true);
4042
+ const typedData = data;
4043
+ try {
4044
+ const response = await fetch(`${apiEndpoint}/${pageId}`, {
4045
+ method: "PATCH",
4046
+ headers: { "Content-Type": "application/json" },
4047
+ body: JSON.stringify({
4048
+ puckData: data,
4049
+ title: typedData.root?.props?.title || pageTitle,
4050
+ slug: typedData.root?.props?.slug || pageSlug,
4051
+ status: "published"
4052
+ })
4053
+ });
4054
+ if (!response.ok) {
4055
+ const errorData = await response.json();
4056
+ const errorMessage = errorData.error || errorData.message || "Failed to publish page";
4057
+ const err = new Error(errorMessage);
4058
+ err.field = errorData.field;
4059
+ err.details = errorData.details;
4060
+ throw err;
4061
+ }
4062
+ setLastSaved(/* @__PURE__ */ new Date());
4063
+ setSaveError(null);
4064
+ setDocumentStatus("published");
4065
+ setWasPublished(true);
4066
+ markClean();
4067
+ onSaveSuccess?.(data);
4068
+ } catch (error) {
4069
+ console.error("Error publishing page:", error);
4070
+ setSaveError(error instanceof Error ? error.message : "Unknown error");
4071
+ onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
4072
+ } finally {
4073
+ setIsSaving(false);
4074
+ }
4075
+ },
4076
+ [apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]
4077
+ );
4078
+ const handleChange = React.useCallback(
4079
+ (data) => {
4080
+ latestDataRef.current = data;
4081
+ markDirty();
4082
+ onChangeProp?.(data);
4083
+ },
4084
+ [markDirty, onChangeProp]
4085
+ );
4086
+ const handleBack = React.useCallback(() => {
4087
+ if (hasUnsavedChanges) {
4088
+ if (!confirm("You have unsaved changes. Are you sure you want to leave?")) {
4089
+ return;
4090
+ }
4091
+ }
4092
+ if (backUrl) {
4093
+ router.push(backUrl);
4094
+ } else {
4095
+ router.back();
4096
+ }
4097
+ }, [hasUnsavedChanges, router, backUrl]);
4098
+ const handlePreview = React.useCallback(() => {
4099
+ const currentSlug = latestDataRef.current?.root?.props?.slug || pageSlug;
4100
+ let url;
4101
+ if (typeof previewUrl === "function") {
4102
+ url = previewUrl(currentSlug);
4103
+ } else if (previewUrl) {
4104
+ url = previewUrl;
4105
+ } else {
4106
+ url = `/${currentSlug}`;
4107
+ }
4108
+ window.open(url, "_blank");
4109
+ }, [pageSlug, previewUrl]);
4110
+ const handleOpenPreview = React.useCallback(() => {
4111
+ setIsPreviewOpen(true);
4112
+ }, []);
4113
+ const handleSaveFromPreview = React.useCallback(async () => {
4114
+ const data = latestDataRef.current;
4115
+ setIsSaving(true);
4116
+ try {
4117
+ const response = await fetch(`${apiEndpoint}/${pageId}`, {
4118
+ method: "PATCH",
4119
+ headers: { "Content-Type": "application/json" },
4120
+ body: JSON.stringify({
4121
+ puckData: data,
4122
+ title: data?.root?.props?.title || pageTitle,
4123
+ slug: data?.root?.props?.slug || pageSlug,
4124
+ draft: true
4125
+ })
4126
+ });
4127
+ if (!response.ok) {
4128
+ const errorData = await response.json();
4129
+ const errorMessage = errorData.error || errorData.message || "Failed to save page";
4130
+ throw new Error(errorMessage);
4131
+ }
4132
+ setLastSaved(/* @__PURE__ */ new Date());
4133
+ setSaveError(null);
4134
+ setDocumentStatus("draft");
4135
+ markClean();
4136
+ onSaveSuccess?.(data);
4137
+ } catch (error) {
4138
+ console.error("Error saving page:", error);
4139
+ setSaveError(error instanceof Error ? error.message : "Unknown error");
4140
+ onSaveError?.(error instanceof Error ? error : new Error("Unknown error"));
4141
+ throw error;
4142
+ } finally {
4143
+ setIsSaving(false);
4144
+ }
4145
+ }, [apiEndpoint, pageId, pageTitle, pageSlug, markClean, onSaveSuccess, onSaveError]);
4146
+ const overrides = React.useMemo(
4147
+ () => ({
4148
+ headerActions: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
4149
+ exports.HeaderActions,
4150
+ {
4151
+ onBack: handleBack,
4152
+ onPreview: handlePreview,
4153
+ onSave: handleSave,
4154
+ onPublish: handlePublish,
4155
+ onOpenPreview: handleOpenPreview,
4156
+ isSaving,
4157
+ hasUnsavedChanges,
4158
+ lastSaved,
4159
+ documentStatus,
4160
+ wasPublished,
4161
+ actionsStart: headerActionsStart,
4162
+ actionsEnd: headerActionsEnd,
4163
+ pageId,
4164
+ apiEndpoint,
4165
+ saveError,
4166
+ onDismissError: () => setSaveError(null),
4167
+ children
4168
+ }
4169
+ ),
4170
+ // Always wrap iframe for richtext styles injection and theme-aware background
4171
+ iframe: ({ children, document: document2 }) => /* @__PURE__ */ jsxRuntime.jsx(exports.IframeWrapper, { document: document2, layouts, layoutStyles, layoutKey, children }),
4172
+ // Merge custom overrides
4173
+ ...customOverrides
4174
+ }),
4175
+ [
4176
+ handleBack,
4177
+ handlePreview,
4178
+ handleSave,
4179
+ handlePublish,
4180
+ handleOpenPreview,
4181
+ isSaving,
4182
+ hasUnsavedChanges,
4183
+ lastSaved,
4184
+ saveError,
4185
+ documentStatus,
4186
+ wasPublished,
4187
+ headerActionsStart,
4188
+ headerActionsEnd,
4189
+ pageId,
4190
+ apiEndpoint,
4191
+ layouts,
4192
+ layoutStyles,
4193
+ layoutKey,
4194
+ customOverrides
4195
+ ]
4196
+ );
4197
+ const defaultPlugins = [headingAnalyzer__default.default];
4198
+ const resolvedPlugins = React.useMemo(() => {
4199
+ if (plugins === false) return void 0;
4200
+ if (!plugins || plugins.length === 0) return defaultPlugins;
4201
+ return [...defaultPlugins, ...plugins];
4202
+ }, [plugins]);
4203
+ const editorContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4204
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-screen", children: /* @__PURE__ */ jsxRuntime.jsx(
4205
+ puck.Puck,
4206
+ {
4207
+ config,
4208
+ data: dataWithSlug,
4209
+ onChange: handleChange,
4210
+ onPublish: handlePublish,
4211
+ headerTitle: `${pageTitle} /${pageSlug}`,
4212
+ plugins: resolvedPlugins,
4213
+ viewports: enableViewports ? DEFAULT_VIEWPORTS : void 0,
4214
+ overrides
4215
+ }
4216
+ ) }),
4217
+ /* @__PURE__ */ jsxRuntime.jsx(
4218
+ exports.PreviewModal,
4219
+ {
4220
+ isOpen: isPreviewOpen,
4221
+ onClose: () => setIsPreviewOpen(false),
4222
+ data: latestDataRef.current,
4223
+ pageTitle,
4224
+ onOpenInNewTab: handlePreview,
4225
+ layouts,
4226
+ hasUnsavedChanges,
4227
+ onSave: handleSaveFromPreview,
4228
+ isSaving
4229
+ }
4230
+ )
4231
+ ] });
4232
+ if (theme) {
4233
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { theme, children: editorContent });
4234
+ }
4235
+ return editorContent;
4236
+ }
4237
+ var DEFAULT_VIEWPORTS;
4238
+ var init_PuckEditorCore_client = __esm({
4239
+ "src/editor/PuckEditorCore.client.tsx"() {
4240
+ "use client";
4241
+ init_HeaderActions();
4242
+ init_IframeWrapper();
4243
+ init_PreviewModal();
4244
+ init_useUnsavedChanges();
4245
+ init_theme();
4246
+ DEFAULT_VIEWPORTS = [
4247
+ {
4248
+ width: 360,
4249
+ height: "auto",
4250
+ label: "Mobile",
4251
+ icon: "Smartphone"
4252
+ },
4253
+ {
4254
+ width: 768,
4255
+ height: "auto",
4256
+ label: "Tablet",
4257
+ icon: "Tablet"
4258
+ },
4259
+ {
4260
+ width: 1280,
4261
+ height: "auto",
4262
+ label: "Desktop",
4263
+ icon: "Monitor"
4264
+ }
4265
+ ];
4266
+ }
4267
+ });
4268
+
4269
+ // src/editor/PuckEditor.client.tsx
4270
+ var PuckEditor_client_exports = {};
4271
+ __export(PuckEditor_client_exports, {
4272
+ PuckEditor: () => PuckEditor
4273
+ });
4274
+ function PuckEditor({
4275
+ pageId,
4276
+ initialData,
4277
+ config,
4278
+ pageTitle,
4279
+ pageSlug,
4280
+ apiEndpoint,
4281
+ backUrl,
4282
+ previewUrl,
4283
+ enableViewports,
4284
+ plugins,
4285
+ layouts,
4286
+ layoutStyles,
4287
+ layoutKey,
4288
+ headerActionsStart,
4289
+ headerActionsEnd,
4290
+ overrides,
4291
+ onSaveSuccess,
4292
+ onSaveError,
4293
+ onChange,
4294
+ initialStatus,
4295
+ theme
4296
+ }) {
4297
+ return /* @__PURE__ */ jsxRuntime.jsx(
4298
+ PuckEditorCore2,
4299
+ {
4300
+ pageId,
4301
+ initialData,
4302
+ config,
4303
+ pageTitle,
4304
+ pageSlug,
4305
+ apiEndpoint,
4306
+ backUrl,
4307
+ previewUrl,
4308
+ enableViewports,
4309
+ plugins,
4310
+ layouts,
4311
+ layoutStyles,
4312
+ layoutKey,
4313
+ headerActionsStart,
4314
+ headerActionsEnd,
4315
+ overrides,
4316
+ onSaveSuccess,
4317
+ onSaveError,
4318
+ onChange,
4319
+ initialStatus,
4320
+ theme
4321
+ }
4322
+ );
4323
+ }
4324
+ var PuckEditorCore2;
4325
+ var init_PuckEditor_client = __esm({
4326
+ "src/editor/PuckEditor.client.tsx"() {
4327
+ "use client";
4328
+ init_LoadingState();
4329
+ PuckEditorCore2 = dynamic__default.default(
4330
+ () => Promise.resolve().then(() => (init_PuckEditorCore_client(), PuckEditorCore_client_exports)).then((mod) => mod.PuckEditorCore),
4331
+ {
4332
+ ssr: false,
4333
+ loading: () => /* @__PURE__ */ jsxRuntime.jsx(LoadingState, {})
4334
+ }
4335
+ );
4336
+ }
4337
+ });
4338
+
4339
+ // src/editor/index.ts
4340
+ init_PuckEditor_client();
4341
+ init_PuckEditorCore_client();
4342
+ function PuckEditorView({
4343
+ config,
4344
+ collectionSlug = "pages",
4345
+ apiBasePath = "/api/puck",
4346
+ backUrl,
4347
+ previewUrl,
4348
+ layoutStyles,
4349
+ layoutKey = "pageLayout",
4350
+ plugins,
4351
+ onSaveSuccess,
4352
+ onSaveError
4353
+ }) {
4354
+ const params = navigation.useParams();
4355
+ const searchParams = navigation.useSearchParams();
4356
+ const pageId = params?.id || searchParams?.get("id") || "";
4357
+ const [page, setPage] = React.useState(null);
4358
+ const [loading, setLoading] = React.useState(true);
4359
+ const [error, setError] = React.useState(null);
4360
+ const [PuckEditor2, setPuckEditor] = React.useState(null);
4361
+ React.useEffect(() => {
4362
+ Promise.resolve().then(() => (init_PuckEditor_client(), PuckEditor_client_exports)).then((mod) => {
4363
+ setPuckEditor(() => mod.PuckEditor);
4364
+ });
4365
+ }, []);
4366
+ React.useEffect(() => {
4367
+ async function fetchPage() {
4368
+ if (!pageId) {
4369
+ setError("No page ID provided");
4370
+ setLoading(false);
4371
+ return;
4372
+ }
4373
+ try {
4374
+ setLoading(true);
4375
+ const response = await fetch(`${apiBasePath}/${collectionSlug}/${pageId}`);
4376
+ if (!response.ok) {
4377
+ const data2 = await response.json().catch(() => ({}));
4378
+ throw new Error(data2.error || `Failed to fetch page: ${response.status}`);
4379
+ }
4380
+ const data = await response.json();
4381
+ setPage(data.doc);
4382
+ } catch (err) {
4383
+ setError(err instanceof Error ? err.message : "An error occurred");
4384
+ } finally {
4385
+ setLoading(false);
4386
+ }
4387
+ }
4388
+ fetchPage();
4389
+ }, [pageId, apiBasePath, collectionSlug]);
4390
+ const computedBackUrl = backUrl || `/admin/collections/${collectionSlug}`;
4391
+ if (loading || !PuckEditor2) {
4392
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4393
+ display: "flex",
4394
+ height: "100vh",
4395
+ alignItems: "center",
4396
+ justifyContent: "center",
4397
+ backgroundColor: "#0f0f0f",
4398
+ color: "#fff"
4399
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
4400
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4401
+ width: "32px",
4402
+ height: "32px",
4403
+ border: "3px solid #333",
4404
+ borderTopColor: "#fff",
4405
+ borderRadius: "50%",
4406
+ animation: "spin 1s linear infinite",
4407
+ margin: "0 auto 16px"
4408
+ } }),
4409
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#888" }, children: "Loading editor..." }),
4410
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
4411
+ @keyframes spin {
4412
+ to { transform: rotate(360deg); }
4413
+ }
4414
+ ` })
4415
+ ] }) });
4416
+ }
4417
+ if (error) {
4418
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4419
+ display: "flex",
4420
+ height: "100vh",
4421
+ alignItems: "center",
4422
+ justifyContent: "center",
4423
+ backgroundColor: "#0f0f0f",
4424
+ color: "#fff"
4425
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
4426
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#f87171", marginBottom: "16px" }, children: error }),
4427
+ /* @__PURE__ */ jsxRuntime.jsxs(
4428
+ "a",
4429
+ {
4430
+ href: computedBackUrl,
4431
+ style: {
4432
+ color: "#60a5fa",
4433
+ textDecoration: "underline"
4434
+ },
4435
+ children: [
4436
+ "Back to ",
4437
+ collectionSlug
4438
+ ]
4439
+ }
4440
+ )
4441
+ ] }) });
4442
+ }
4443
+ if (!page) {
4444
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
4445
+ display: "flex",
4446
+ height: "100vh",
4447
+ alignItems: "center",
4448
+ justifyContent: "center",
4449
+ backgroundColor: "#0f0f0f",
4450
+ color: "#fff"
4451
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
4452
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#888", marginBottom: "16px" }, children: "Page not found" }),
4453
+ /* @__PURE__ */ jsxRuntime.jsxs(
4454
+ "a",
4455
+ {
4456
+ href: computedBackUrl,
4457
+ style: {
4458
+ color: "#60a5fa",
4459
+ textDecoration: "underline"
4460
+ },
4461
+ children: [
4462
+ "Back to ",
4463
+ collectionSlug
4464
+ ]
4465
+ }
4466
+ )
4467
+ ] }) });
4468
+ }
4469
+ const initialData = page.puckData || {
4470
+ root: {
4471
+ props: {
4472
+ title: page.title || "New Page"
4473
+ }
4474
+ },
4475
+ content: [],
4476
+ zones: {}
4477
+ };
4478
+ return /* @__PURE__ */ jsxRuntime.jsx(
4479
+ PuckEditor2,
4480
+ {
4481
+ pageId: page.id,
4482
+ initialData,
4483
+ config,
4484
+ pageTitle: page.title,
4485
+ pageSlug: page.slug,
4486
+ apiEndpoint: `${apiBasePath}/${collectionSlug}`,
4487
+ backUrl: computedBackUrl,
4488
+ previewUrl,
4489
+ layoutStyles,
4490
+ layoutKey,
4491
+ plugins,
4492
+ onSaveSuccess,
4493
+ onSaveError,
4494
+ initialStatus: page._status
4495
+ }
4496
+ );
4497
+ }
4498
+
4499
+ // src/editor/index.ts
4500
+ init_HeaderActions();
4501
+ init_IframeWrapper();
4502
+ init_LoadingState();
4503
+ init_PreviewModal();
4504
+ init_VersionHistory();
4505
+ init_useUnsavedChanges();
4506
+
4507
+ Object.defineProperty(exports, "headingAnalyzer", {
4508
+ enumerable: true,
4509
+ get: function () { return headingAnalyzer__default.default; }
4510
+ });
4511
+ exports.LoadingState = LoadingState;
4512
+ exports.PuckEditor = PuckEditor;
4513
+ exports.PuckEditorCore = PuckEditorCore;
4514
+ exports.PuckEditorView = PuckEditorView;
4515
+ exports.useUnsavedChanges = useUnsavedChanges;
4516
+ //# sourceMappingURL=index.js.map
4517
+ //# sourceMappingURL=index.js.map