@arkcit/engine 0.3.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 (42) hide show
  1. package/README.md +68 -0
  2. package/dist/UIEngine.d.ts +6 -0
  3. package/dist/UIEngine.js +3235 -0
  4. package/dist/bindings.d.ts +8 -0
  5. package/dist/bindings.js +146 -0
  6. package/dist/components/index.d.ts +17 -0
  7. package/dist/components/index.js +143 -0
  8. package/dist/core/index.d.ts +4 -0
  9. package/dist/core/index.js +9 -0
  10. package/dist/form/engineFormValidation.d.ts +2 -0
  11. package/dist/form/engineFormValidation.js +241 -0
  12. package/dist/form.d.ts +67 -0
  13. package/dist/form.js +241 -0
  14. package/dist/index.d.ts +15 -0
  15. package/dist/index.js +3336 -0
  16. package/dist/layout.d.ts +6 -0
  17. package/dist/layout.js +82 -0
  18. package/dist/preview/index.d.ts +63 -0
  19. package/dist/preview/index.js +1514 -0
  20. package/dist/react-web/index.d.ts +8 -0
  21. package/dist/react-web/index.js +3246 -0
  22. package/dist/registry.d.ts +2 -0
  23. package/dist/registry.js +0 -0
  24. package/dist/render-layer/index.d.ts +1 -0
  25. package/dist/render-layer/index.js +13 -0
  26. package/dist/renderStudioForm-CPQEzvT7.d.ts +75 -0
  27. package/dist/renderers/index.d.ts +8 -0
  28. package/dist/renderers/index.js +1570 -0
  29. package/dist/runtime/index.d.ts +1 -0
  30. package/dist/runtime/index.js +0 -0
  31. package/dist/schema/index.d.ts +1 -0
  32. package/dist/schema/index.js +0 -0
  33. package/dist/studio-bridge/index.d.ts +501 -0
  34. package/dist/studio-bridge/index.js +2840 -0
  35. package/dist/studioProps.d.ts +8 -0
  36. package/dist/studioProps.js +97 -0
  37. package/dist/types-9TZ2lQDP.d.ts +60 -0
  38. package/dist/types-CyAE6ZLH.d.ts +19 -0
  39. package/dist/types.d.ts +16 -0
  40. package/dist/types.js +0 -0
  41. package/dist/wizardEditingHandlers-D50tR-6n.d.ts +163 -0
  42. package/package.json +160 -0
@@ -0,0 +1,3246 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/react-web/engine/EngineWarningFallback.tsx
22
+ import { EngineWarningFallback } from "@arkcit/engine-react";
23
+
24
+ // src/react-web/engine/NodeErrorBoundary.tsx
25
+ import { NodeErrorBoundary } from "@arkcit/engine-react";
26
+
27
+ // src/react-web/engine/ReactWebEngineRoot.tsx
28
+ import { ReactWebEngineRoot as ReactWebEngineRootImpl } from "@arkcit/engine-react";
29
+
30
+ // src/studio-bridge/inline/InlineTextEditor.tsx
31
+ import { jsx } from "react/jsx-runtime";
32
+ var InlineTextEditor = ({
33
+ editing,
34
+ onChange,
35
+ onCancel,
36
+ onCommit
37
+ }) => editing.multiline ? /* @__PURE__ */ jsx(
38
+ "textarea",
39
+ {
40
+ className: "absolute z-[260] h-full w-full resize-none rounded-md border border-primary/70 bg-background/95 px-2 py-1 text-sm text-foreground outline-none ring-0 cursor-text shadow-lg",
41
+ style: editing.editorStyle,
42
+ value: editing.value,
43
+ autoFocus: true,
44
+ "aria-label": "Inline text editor",
45
+ onChange: (event) => onChange(event.target.value),
46
+ onBlur: onCommit,
47
+ onKeyDown: (event) => {
48
+ if (event.key === "Escape") {
49
+ event.preventDefault();
50
+ onCancel();
51
+ return;
52
+ }
53
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
54
+ event.preventDefault();
55
+ onCommit();
56
+ }
57
+ }
58
+ }
59
+ ) : /* @__PURE__ */ jsx(
60
+ "input",
61
+ {
62
+ className: "absolute z-[260] h-full w-full rounded-md border border-primary/70 bg-background/95 px-2 text-sm text-foreground outline-none ring-0 cursor-text shadow-lg",
63
+ style: editing.editorStyle,
64
+ value: editing.value,
65
+ autoFocus: true,
66
+ "aria-label": "Inline text editor",
67
+ onChange: (event) => onChange(event.target.value),
68
+ onBlur: onCommit,
69
+ onKeyDown: (event) => {
70
+ if (event.key === "Escape") {
71
+ event.preventDefault();
72
+ onCancel();
73
+ return;
74
+ }
75
+ if (event.key === "Enter") {
76
+ event.preventDefault();
77
+ onCommit();
78
+ }
79
+ }
80
+ }
81
+ );
82
+
83
+ // src/studio-bridge/nodes/StudioNodeWrapper.tsx
84
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
85
+ var StudioNodeWrapper = ({
86
+ nodeId,
87
+ wrapperClassName = "",
88
+ cursorClassName = "",
89
+ isSelected,
90
+ allowResizeHandle = true,
91
+ style,
92
+ onClick,
93
+ onDoubleClick,
94
+ onTouchStart,
95
+ onTouchMove,
96
+ onTouchEnd,
97
+ showResizeHandle,
98
+ onResizeMouseDown,
99
+ isInlineEditing,
100
+ preserveContentWhileInlineEditing = false,
101
+ children,
102
+ inlineEditor
103
+ }) => /* @__PURE__ */ jsxs(
104
+ "div",
105
+ {
106
+ "data-node-id": nodeId,
107
+ className: [
108
+ "relative block w-fit min-w-0 max-w-full rounded-md border border-transparent transition-colors",
109
+ wrapperClassName,
110
+ cursorClassName,
111
+ isSelected ? "border-dashed border-primary/60 bg-primary/5" : ""
112
+ ].filter(Boolean).join(" "),
113
+ style: __spreadValues({
114
+ position: "relative"
115
+ }, style != null ? style : {}),
116
+ onTouchStart,
117
+ onTouchMove,
118
+ onTouchEnd,
119
+ onClick,
120
+ onDoubleClick,
121
+ children: [
122
+ allowResizeHandle && showResizeHandle && onResizeMouseDown ? /* @__PURE__ */ jsx2(
123
+ "button",
124
+ {
125
+ type: "button",
126
+ className: "absolute -right-2 -top-2 z-20 inline-flex h-7 w-7 cursor-nwse-resize items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-foreground shadow-sm transition-colors hover:bg-primary-hover hover:border-primary-hover",
127
+ "aria-label": "Resize node",
128
+ onMouseDown: onResizeMouseDown,
129
+ children: "\u2922"
130
+ }
131
+ ) : null,
132
+ /* @__PURE__ */ jsx2(
133
+ "div",
134
+ {
135
+ className: isInlineEditing && !preserveContentWhileInlineEditing ? "pointer-events-none opacity-0" : void 0,
136
+ children
137
+ }
138
+ ),
139
+ isInlineEditing ? inlineEditor : null
140
+ ]
141
+ },
142
+ nodeId
143
+ );
144
+
145
+ // src/studio-bridge/inline/forceFullWidth.ts
146
+ var shouldForceStudioNodeFullWidth = ({
147
+ widthPct,
148
+ nodeType,
149
+ isStudioRendererContext,
150
+ colSpan
151
+ }) => widthPct === null && (nodeType === "Container" || nodeType === "Grid" || colSpan !== void 0 || isStudioRendererContext && (nodeType === "Form" || nodeType === "FormWizard"));
152
+
153
+ // src/studio-bridge/inline/inlineText.ts
154
+ var getEditableTextValue = ({
155
+ node,
156
+ nodeProps,
157
+ propName,
158
+ runtime,
159
+ resolveTranslationValue
160
+ }) => {
161
+ var _a;
162
+ let value = nodeProps[propName];
163
+ if (node.type === "FormField" && (propName === "label" || propName === "name")) {
164
+ const fieldObject = nodeProps.field && typeof nodeProps.field === "object" && !Array.isArray(nodeProps.field) ? nodeProps.field : null;
165
+ if (value === void 0 && fieldObject) {
166
+ value = fieldObject[propName];
167
+ }
168
+ }
169
+ if (typeof value === "string") return { value, mode: "primitive" };
170
+ if (typeof value === "number" || typeof value === "boolean") {
171
+ return { value: String(value), mode: "primitive" };
172
+ }
173
+ if (value && typeof value === "object") {
174
+ if ("$t" in value && typeof value.$t === "string") {
175
+ const translationValue = value;
176
+ const resolvedValue = resolveTranslationValue(translationValue, runtime);
177
+ return {
178
+ value: typeof resolvedValue === "string" ? resolvedValue : (_a = translationValue.defaultValue) != null ? _a : translationValue.$t,
179
+ mode: "translation"
180
+ };
181
+ }
182
+ try {
183
+ return {
184
+ value: JSON.stringify(value, null, 2),
185
+ mode: "json"
186
+ };
187
+ } catch (e) {
188
+ return null;
189
+ }
190
+ }
191
+ return null;
192
+ };
193
+ var selectCandidateInlineProp = ({
194
+ node,
195
+ isWizardStepNode,
196
+ orderedEditableTextProps,
197
+ getTextValue
198
+ }) => {
199
+ var _a, _b;
200
+ if (node.type === "FormField") {
201
+ if (getTextValue("label")) return "label";
202
+ if (getTextValue("name")) return "name";
203
+ }
204
+ if (node.type === "Button") {
205
+ if (getTextValue("children")) return "children";
206
+ }
207
+ if (node.type === "Form") {
208
+ if (getTextValue("title")) return "title";
209
+ }
210
+ if (isWizardStepNode) {
211
+ if (getTextValue("title")) return "title";
212
+ if (getTextValue("description")) return "description";
213
+ }
214
+ const blockedTypes = /* @__PURE__ */ new Set(["Form", "FormWizard", "Accordion", "ExpandablePanel"]);
215
+ if (node.type === "Cover") {
216
+ const coverTextProps = ["eyebrow", "title", "subtitle", "description", "children"];
217
+ return (_a = coverTextProps.find((propName) => getTextValue(propName) !== null)) != null ? _a : null;
218
+ }
219
+ const sourceProps = blockedTypes.has(node.type) ? [] : orderedEditableTextProps;
220
+ return (_b = sourceProps.find((propName) => getTextValue(propName) !== null)) != null ? _b : null;
221
+ };
222
+ var selectEffectiveInlineProp = ({
223
+ node,
224
+ isWizardStepNode,
225
+ hasRenderableChildren,
226
+ childrenInlineEntry,
227
+ candidateInlineProp
228
+ }) => {
229
+ if (isWizardStepNode) return candidateInlineProp;
230
+ if (node.type === "FormField") return candidateInlineProp;
231
+ if (node.type === "ScrollReveal") {
232
+ if (hasRenderableChildren) return null;
233
+ return childrenInlineEntry ? "children" : null;
234
+ }
235
+ if (node.type === "Cover") return candidateInlineProp;
236
+ if (node.type === "Dropdown" || node.type === "Tooltip" || node.type === "Popin" || node.type === "Drawer") {
237
+ return candidateInlineProp;
238
+ }
239
+ if (hasRenderableChildren) {
240
+ return childrenInlineEntry ? "children" : null;
241
+ }
242
+ return candidateInlineProp;
243
+ };
244
+
245
+ // src/studio-bridge/inline/inlineEditing.ts
246
+ var getValueAtPropPath = (source, propPath) => propPath.split(".").filter(Boolean).reduce((current, segment) => {
247
+ if (!current || typeof current !== "object" || Array.isArray(current)) return void 0;
248
+ return current[segment];
249
+ }, source);
250
+ var computeInlineEditorStyle = ({
251
+ wrapperElement,
252
+ targetElementForEditor
253
+ }) => {
254
+ if (!targetElementForEditor) return { inset: 0 };
255
+ const wrapperRect = wrapperElement.getBoundingClientRect();
256
+ const targetRect = targetElementForEditor.getBoundingClientRect();
257
+ return {
258
+ top: Math.max(0, targetRect.top - wrapperRect.top - 2),
259
+ left: Math.max(0, targetRect.left - wrapperRect.left - 2),
260
+ width: Math.max(48, targetRect.width + 4),
261
+ height: Math.max(32, targetRect.height + 4)
262
+ };
263
+ };
264
+ var shouldUseMultilineInlineEditor = ({
265
+ mode,
266
+ value
267
+ }) => mode === "json" || value.length > 64;
268
+ var applyInlineEditingValue = ({
269
+ editingState,
270
+ rawValue,
271
+ schemaNodes,
272
+ onInlineTextEdit,
273
+ findNodeById: findNodeById2
274
+ }) => {
275
+ var _a;
276
+ if (!onInlineTextEdit) return;
277
+ const isFormFieldLabelOrName = editingState.propName === "label" || editingState.propName === "name";
278
+ const applyFormFieldValue = (nextValue) => {
279
+ var _a2;
280
+ const targetNode2 = findNodeById2(editingState.nodeId, schemaNodes);
281
+ const targetProps2 = (_a2 = targetNode2 == null ? void 0 : targetNode2.props) != null ? _a2 : {};
282
+ const currentField = targetProps2.field && typeof targetProps2.field === "object" && !Array.isArray(targetProps2.field) ? targetProps2.field : {};
283
+ if ((targetNode2 == null ? void 0 : targetNode2.type) === "FormField" && isFormFieldLabelOrName) {
284
+ onInlineTextEdit(editingState.nodeId, "field", __spreadProps(__spreadValues({}, currentField), {
285
+ [editingState.propName]: nextValue
286
+ }));
287
+ }
288
+ };
289
+ const targetNode = findNodeById2(editingState.nodeId, schemaNodes);
290
+ const targetProps = (_a = targetNode == null ? void 0 : targetNode.props) != null ? _a : {};
291
+ const currentValue = getValueAtPropPath(targetProps, editingState.propName);
292
+ if (editingState.mode === "translation" && currentValue && typeof currentValue === "object" && !Array.isArray(currentValue) && typeof currentValue.$t === "string") {
293
+ onInlineTextEdit(editingState.nodeId, editingState.propName, __spreadProps(__spreadValues({}, currentValue), {
294
+ $t: rawValue,
295
+ defaultValue: rawValue
296
+ }));
297
+ return;
298
+ }
299
+ if (editingState.mode === "json") {
300
+ try {
301
+ const parsed = JSON.parse(rawValue);
302
+ applyFormFieldValue(parsed);
303
+ onInlineTextEdit(editingState.nodeId, editingState.propName, parsed);
304
+ return;
305
+ } catch (e) {
306
+ applyFormFieldValue(rawValue);
307
+ onInlineTextEdit(editingState.nodeId, editingState.propName, rawValue);
308
+ return;
309
+ }
310
+ }
311
+ const trimmed = rawValue.trim();
312
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
313
+ try {
314
+ const parsed = JSON.parse(trimmed);
315
+ applyFormFieldValue(parsed);
316
+ onInlineTextEdit(editingState.nodeId, editingState.propName, parsed);
317
+ return;
318
+ } catch (e) {
319
+ }
320
+ }
321
+ applyFormFieldValue(rawValue);
322
+ onInlineTextEdit(editingState.nodeId, editingState.propName, rawValue);
323
+ };
324
+
325
+ // src/studio-bridge/inline/inlineEditorOpening.ts
326
+ var openInlineEditorFromDoubleClick = ({
327
+ event,
328
+ nodeId,
329
+ nodeType,
330
+ effectiveCandidateInlineProp,
331
+ getTextValue,
332
+ setInlineEditing
333
+ }) => {
334
+ var _a;
335
+ const targetElement = event.target;
336
+ const targetInlineProp = (_a = targetElement == null ? void 0 : targetElement.closest("[data-inline-prop]")) == null ? void 0 : _a.getAttribute("data-inline-prop");
337
+ const chosenProp = nodeType === "Cover" && targetInlineProp ? targetInlineProp : targetInlineProp && targetInlineProp !== "children" ? targetInlineProp : effectiveCandidateInlineProp;
338
+ if (!chosenProp) return false;
339
+ const initialEntry = getTextValue(chosenProp);
340
+ if (initialEntry === null) return false;
341
+ const targetElementForEditor = targetInlineProp ? targetElement == null ? void 0 : targetElement.closest("[data-inline-prop]") : null;
342
+ const wrapperElement = event.currentTarget;
343
+ const editorStyle = computeInlineEditorStyle({
344
+ wrapperElement,
345
+ targetElementForEditor
346
+ });
347
+ event.preventDefault();
348
+ event.stopPropagation();
349
+ setInlineEditing({
350
+ nodeId,
351
+ propName: chosenProp,
352
+ value: initialEntry.value,
353
+ multiline: shouldUseMultilineInlineEditor({
354
+ mode: initialEntry.mode,
355
+ value: initialEntry.value
356
+ }),
357
+ mode: initialEntry.mode,
358
+ editorStyle
359
+ });
360
+ return true;
361
+ };
362
+
363
+ // src/studio-bridge/inline/resolveInlineEditingTarget.ts
364
+ var INLINE_TECHNICAL_TEXT_PROPS = /* @__PURE__ */ new Set(["className", "rootMargin"]);
365
+ var PREFERRED_INLINE_TEXT_PROPS = [
366
+ "children",
367
+ "label",
368
+ "title",
369
+ "description",
370
+ "placeholder",
371
+ "name",
372
+ "text"
373
+ ];
374
+ var resolveInlineEditingTarget = ({
375
+ node,
376
+ nodeProps,
377
+ runtime,
378
+ editableTextProps,
379
+ resolveTranslationValue
380
+ }) => {
381
+ var _a, _b, _c, _d, _e;
382
+ const isWizardStepNode = node.type === "Container" && String((_a = nodeProps.cardSection) != null ? _a : "") !== "header" && String((_b = nodeProps.cardSection) != null ? _b : "") !== "body" && String((_c = nodeProps.cardSection) != null ? _c : "") !== "footer" && (nodeProps.layout && typeof nodeProps.layout === "object" && !Array.isArray(nodeProps.layout) ? Boolean(nodeProps.layout.wizardStep) : false);
383
+ const canResolveInlineText = isWizardStepNode || editableTextProps.length > 0;
384
+ const orderedEditableTextProps = canResolveInlineText ? [
385
+ ...PREFERRED_INLINE_TEXT_PROPS.filter((prop) => editableTextProps.includes(prop)),
386
+ ...editableTextProps.filter(
387
+ (prop) => !PREFERRED_INLINE_TEXT_PROPS.includes(prop) && !INLINE_TECHNICAL_TEXT_PROPS.has(prop)
388
+ )
389
+ ] : [];
390
+ const getTextValue = canResolveInlineText ? (propName) => getEditableTextValue({
391
+ node,
392
+ nodeProps,
393
+ propName,
394
+ runtime,
395
+ resolveTranslationValue
396
+ }) : () => null;
397
+ const candidateInlineProp = canResolveInlineText ? selectCandidateInlineProp({
398
+ node,
399
+ isWizardStepNode,
400
+ orderedEditableTextProps,
401
+ getTextValue
402
+ }) : null;
403
+ const effectiveCandidateInlineProp = canResolveInlineText ? selectEffectiveInlineProp({
404
+ node,
405
+ isWizardStepNode,
406
+ hasRenderableChildren: ((_e = (_d = node.children) == null ? void 0 : _d.length) != null ? _e : 0) > 0,
407
+ childrenInlineEntry: getTextValue("children"),
408
+ candidateInlineProp
409
+ }) : null;
410
+ return {
411
+ canResolveInlineText,
412
+ isWizardStepNode,
413
+ orderedEditableTextProps,
414
+ getTextValue,
415
+ effectiveCandidateInlineProp
416
+ };
417
+ };
418
+
419
+ // src/studio-bridge/interactions/studioClick.ts
420
+ var isInteractiveSelectionTarget = ({
421
+ targetElement,
422
+ nodeType,
423
+ isFormInteractiveTarget
424
+ }) => isFormInteractiveTarget(targetElement) && nodeType !== "Button" && nodeType !== "Link";
425
+ var resolveButtonOverlayTarget = ({
426
+ clickEvent,
427
+ boundTargetNodeId,
428
+ overlayCandidates
429
+ }) => {
430
+ var _a, _b, _c;
431
+ const actionLabel = clickEvent && typeof clickEvent === "object" ? "id" in clickEvent ? String((_a = clickEvent.id) != null ? _a : "") : "type" in clickEvent ? String((_b = clickEvent.type) != null ? _b : "") : "" : "";
432
+ const payload = clickEvent && typeof clickEvent === "object" && "payload" in clickEvent && clickEvent.payload && typeof clickEvent.payload === "object" ? clickEvent.payload : null;
433
+ const requestedTargetNodeId = String((_c = payload == null ? void 0 : payload.targetNodeId) != null ? _c : boundTargetNodeId).trim();
434
+ const targetNodeId = requestedTargetNodeId || (overlayCandidates.length === 1 ? overlayCandidates[0] : "");
435
+ return {
436
+ actionLabel,
437
+ payload,
438
+ targetNodeId
439
+ };
440
+ };
441
+ var buildNormalizedActionRef = ({
442
+ clickEvent,
443
+ payload,
444
+ targetNodeId
445
+ }) => {
446
+ const basePayload = payload && typeof payload === "object" ? payload : {};
447
+ const normalizedPayload = targetNodeId && !("targetNodeId" in basePayload) ? __spreadProps(__spreadValues({}, basePayload), { targetNodeId }) : basePayload;
448
+ return clickEvent && typeof clickEvent === "object" && "id" in clickEvent ? __spreadProps(__spreadValues({}, clickEvent), { payload: normalizedPayload }) : clickEvent && typeof clickEvent === "object" && "type" in clickEvent ? __spreadProps(__spreadValues({}, clickEvent), { payload: normalizedPayload }) : clickEvent;
449
+ };
450
+ var syncOverlayStateFromAction = ({
451
+ targetNodeId,
452
+ actionLabel,
453
+ runtime,
454
+ onInlineTextEdit,
455
+ findNodeById: findNodeById2,
456
+ schemaNodes
457
+ }) => {
458
+ if (!targetNodeId || !onInlineTextEdit) return;
459
+ const targetNode = findNodeById2(targetNodeId, schemaNodes);
460
+ if (!targetNode) return;
461
+ const overlaysRaw = runtime.get("overlays.byNodeId");
462
+ const overlaysByNodeId = overlaysRaw && typeof overlaysRaw === "object" ? overlaysRaw : {};
463
+ if (!actionLabel) {
464
+ if (targetNode.type === "Popin") {
465
+ onInlineTextEdit(targetNodeId, "displayedPopin", true);
466
+ } else if (targetNode.type === "Drawer") {
467
+ onInlineTextEdit(targetNodeId, "open", true);
468
+ }
469
+ runtime.dispatch({
470
+ id: "overlay.open",
471
+ payload: { targetNodeId }
472
+ });
473
+ return;
474
+ }
475
+ if (targetNode.type === "Popin") {
476
+ if (actionLabel === "overlay.open") {
477
+ onInlineTextEdit(targetNodeId, "displayedPopin", true);
478
+ } else if (actionLabel === "overlay.close") {
479
+ onInlineTextEdit(targetNodeId, "displayedPopin", false);
480
+ } else if (actionLabel === "overlay.toggle") {
481
+ const current = Boolean(overlaysByNodeId[targetNodeId]);
482
+ onInlineTextEdit(targetNodeId, "displayedPopin", !current);
483
+ }
484
+ }
485
+ if (targetNode.type === "Drawer") {
486
+ if (actionLabel === "overlay.open") {
487
+ onInlineTextEdit(targetNodeId, "open", true);
488
+ } else if (actionLabel === "overlay.close") {
489
+ onInlineTextEdit(targetNodeId, "open", false);
490
+ } else if (actionLabel === "overlay.toggle") {
491
+ const current = Boolean(overlaysByNodeId[targetNodeId]);
492
+ onInlineTextEdit(targetNodeId, "open", !current);
493
+ }
494
+ }
495
+ };
496
+ var resolveClickedNodeId = ({
497
+ targetElement,
498
+ fallbackNodeId
499
+ }) => {
500
+ var _a;
501
+ const closestNode = targetElement == null ? void 0 : targetElement.closest("[data-node-id]");
502
+ return (_a = closestNode == null ? void 0 : closestNode.dataset.nodeId) != null ? _a : fallbackNodeId;
503
+ };
504
+
505
+ // src/studio-bridge/nodes/studioNodeEditing.ts
506
+ var suppressStudioClickUntil = 0;
507
+ var shouldSuppressStudioClick = () => Date.now() <= suppressStudioClickUntil;
508
+
509
+ // src/utils/schemaTraversal.ts
510
+ var findNodeById = (nodeId, nodes) => {
511
+ var _a;
512
+ for (const candidate of nodes) {
513
+ if (candidate.id === nodeId) return candidate;
514
+ const nested = findNodeById(nodeId, (_a = candidate.children) != null ? _a : []);
515
+ if (nested) return nested;
516
+ }
517
+ return null;
518
+ };
519
+ var buildAncestorTypeMembership = (nodes, ancestorTypes) => {
520
+ const lookup = Object.fromEntries(
521
+ ancestorTypes.map((type) => [type, /* @__PURE__ */ new Set()])
522
+ );
523
+ const walk = (items, lineage = []) => {
524
+ var _a;
525
+ for (const item of items) {
526
+ for (const ancestorType of ancestorTypes) {
527
+ if (lineage.includes(ancestorType)) {
528
+ lookup[ancestorType].add(item.id);
529
+ }
530
+ }
531
+ if ((_a = item.children) == null ? void 0 : _a.length) {
532
+ walk(item.children, [...lineage, item.type]);
533
+ }
534
+ }
535
+ };
536
+ walk(nodes);
537
+ return lookup;
538
+ };
539
+ var collectOverlayNodeIds = (nodes) => {
540
+ const ids = [];
541
+ const walk = (items) => {
542
+ var _a;
543
+ for (const item of items) {
544
+ if (item.type === "Popin" || item.type === "Drawer") ids.push(item.id);
545
+ if ((_a = item.children) == null ? void 0 : _a.length) walk(item.children);
546
+ }
547
+ };
548
+ walk(nodes);
549
+ return ids;
550
+ };
551
+
552
+ // src/studio-bridge/interactions/resizeStudio.ts
553
+ var computeMouseResizeSize = ({
554
+ state,
555
+ clientX,
556
+ clientY,
557
+ minWidthPct,
558
+ minHeightPct,
559
+ minHeightPx
560
+ }) => {
561
+ const deltaX = clientX - state.startX;
562
+ const deltaY = clientY - state.startY;
563
+ const nextWidth = state.startWidthPct + deltaX / state.containerWidth * 100;
564
+ const nextHeight = state.startHeightPct + deltaY / state.containerHeight * 100;
565
+ const nextHeightPx = state.startHeightPx + deltaY;
566
+ return {
567
+ widthPct: Math.max(minWidthPct, Math.min(100, Number(nextWidth.toFixed(2)))),
568
+ heightPct: Math.max(minHeightPct, Math.min(100, Number(nextHeight.toFixed(2)))),
569
+ heightPx: Math.max(minHeightPx, Number(nextHeightPx.toFixed(0)))
570
+ };
571
+ };
572
+ var computePinchResizeSize = ({
573
+ state,
574
+ distance,
575
+ minWidthPct,
576
+ minHeightPct
577
+ }) => {
578
+ if (!state.startDistance) return null;
579
+ const scale = distance / state.startDistance;
580
+ const nextWidth = state.startWidthPct * scale;
581
+ const nextHeight = state.startHeightPct * scale;
582
+ return {
583
+ widthPct: Math.max(minWidthPct, Math.min(100, Number(nextWidth.toFixed(2)))),
584
+ heightPct: Math.max(minHeightPct, Math.min(100, Number(nextHeight.toFixed(2))))
585
+ };
586
+ };
587
+ var createMouseResizeState = ({
588
+ nodeId,
589
+ clientX,
590
+ clientY,
591
+ widthPct,
592
+ heightPct,
593
+ heightPx,
594
+ elementRect,
595
+ parentRect,
596
+ minHeightPx
597
+ }) => ({
598
+ nodeId,
599
+ startX: clientX,
600
+ startY: clientY,
601
+ startWidthPct: widthPct != null ? widthPct : elementRect.width / Math.max(parentRect.width, 1) * 100,
602
+ startHeightPct: heightPct != null ? heightPct : elementRect.height / Math.max(parentRect.height, 1) * 100,
603
+ startHeightPx: heightPx != null ? heightPx : Math.max(minHeightPx, elementRect.height),
604
+ containerWidth: Math.max(parentRect.width, 1),
605
+ containerHeight: Math.max(parentRect.height, 1)
606
+ });
607
+ var createPinchResizeState = ({
608
+ nodeId,
609
+ widthPct,
610
+ heightPct,
611
+ distance
612
+ }) => ({
613
+ nodeId,
614
+ startDistance: distance,
615
+ startWidthPct: widthPct != null ? widthPct : 100,
616
+ startHeightPct: heightPct != null ? heightPct : 100
617
+ });
618
+
619
+ // src/studio-bridge/nodes/nodeWrapperHandlers.ts
620
+ var createTouchResizeHandlers = ({
621
+ node,
622
+ widthPct,
623
+ heightPct,
624
+ onNodeResize,
625
+ onNodeResizeStart,
626
+ onNodeResizeEnd,
627
+ pinchStateRef,
628
+ minWidthPct,
629
+ minHeightPct
630
+ }) => ({
631
+ onTouchStart: (event) => {
632
+ if (!onNodeResize) return;
633
+ if (event.touches.length < 2) return;
634
+ onNodeResizeStart == null ? void 0 : onNodeResizeStart(node.id);
635
+ const [firstTouch, secondTouch] = [event.touches[0], event.touches[1]];
636
+ const dx = secondTouch.clientX - firstTouch.clientX;
637
+ const dy = secondTouch.clientY - firstTouch.clientY;
638
+ const distance = Math.hypot(dx, dy);
639
+ pinchStateRef.current = createPinchResizeState({
640
+ nodeId: node.id,
641
+ widthPct,
642
+ heightPct,
643
+ distance
644
+ });
645
+ },
646
+ onTouchMove: (event) => {
647
+ if (!onNodeResize) return;
648
+ const state = pinchStateRef.current;
649
+ if (!state || state.nodeId !== node.id) return;
650
+ if (event.touches.length < 2) return;
651
+ const [firstTouch, secondTouch] = [event.touches[0], event.touches[1]];
652
+ const dx = secondTouch.clientX - firstTouch.clientX;
653
+ const dy = secondTouch.clientY - firstTouch.clientY;
654
+ const distance = Math.hypot(dx, dy);
655
+ const nextSize = computePinchResizeSize({
656
+ state,
657
+ distance,
658
+ minWidthPct,
659
+ minHeightPct
660
+ });
661
+ if (!nextSize) return;
662
+ pinchStateRef.current = __spreadProps(__spreadValues({}, state), {
663
+ lastSize: nextSize
664
+ });
665
+ onNodeResize(node.id, nextSize);
666
+ },
667
+ onTouchEnd: () => {
668
+ const state = pinchStateRef.current;
669
+ if (state == null ? void 0 : state.lastSize) {
670
+ onNodeResizeEnd == null ? void 0 : onNodeResizeEnd(node.id, state.lastSize);
671
+ }
672
+ pinchStateRef.current = null;
673
+ }
674
+ });
675
+ var createMouseResizeHandler = ({
676
+ node,
677
+ widthPct,
678
+ heightPct,
679
+ heightPx,
680
+ onNodeResize,
681
+ onNodeResizeStart,
682
+ resizeStateRef,
683
+ minHeightPx
684
+ }) => onNodeResize ? (event) => {
685
+ event.preventDefault();
686
+ event.stopPropagation();
687
+ const element = event.currentTarget.closest("[data-node-id]");
688
+ if (!element) return;
689
+ const parent = element.parentElement;
690
+ if (!parent) return;
691
+ const parentRect = parent.getBoundingClientRect();
692
+ const elementRect = element.getBoundingClientRect();
693
+ onNodeResizeStart == null ? void 0 : onNodeResizeStart(node.id);
694
+ resizeStateRef.current = createMouseResizeState({
695
+ nodeId: node.id,
696
+ clientX: event.clientX,
697
+ clientY: event.clientY,
698
+ widthPct,
699
+ heightPct,
700
+ heightPx,
701
+ elementRect,
702
+ parentRect,
703
+ minHeightPx
704
+ });
705
+ } : void 0;
706
+ var createStudioNodeClickHandler = ({
707
+ node,
708
+ nodeProps,
709
+ schemaNodes,
710
+ runtime,
711
+ onNodeClick,
712
+ onInlineTextEdit,
713
+ isInlineEditingNode,
714
+ enableEventOnClick,
715
+ isFormInteractiveTarget
716
+ }) => (event) => {
717
+ var _a, _b;
718
+ if (shouldSuppressStudioClick()) {
719
+ event.preventDefault();
720
+ event.stopPropagation();
721
+ return;
722
+ }
723
+ if (!onNodeClick) return;
724
+ if (isInlineEditingNode) return;
725
+ const targetElement = event.target;
726
+ if (node.type === "Button" && enableEventOnClick && Boolean(targetElement == null ? void 0 : targetElement.closest("button"))) {
727
+ const clickEvent = (_a = node.events) == null ? void 0 : _a.onClick;
728
+ const boundTargetNodeId = String((_b = nodeProps.buttonTargetNodeId) != null ? _b : "").trim();
729
+ const overlayCandidates = collectOverlayNodeIds(schemaNodes);
730
+ const { actionLabel, payload, targetNodeId } = resolveButtonOverlayTarget({
731
+ clickEvent,
732
+ boundTargetNodeId,
733
+ overlayCandidates
734
+ });
735
+ if (clickEvent) {
736
+ const normalizedActionRef = buildNormalizedActionRef({
737
+ clickEvent,
738
+ payload,
739
+ targetNodeId
740
+ });
741
+ runtime.dispatch(normalizedActionRef);
742
+ }
743
+ syncOverlayStateFromAction({
744
+ targetNodeId,
745
+ actionLabel: clickEvent ? actionLabel : "",
746
+ runtime,
747
+ onInlineTextEdit,
748
+ findNodeById,
749
+ schemaNodes
750
+ });
751
+ event.stopPropagation();
752
+ return;
753
+ }
754
+ if (isInteractiveSelectionTarget({
755
+ targetElement,
756
+ nodeType: node.type,
757
+ isFormInteractiveTarget
758
+ })) {
759
+ event.stopPropagation();
760
+ return;
761
+ }
762
+ const clickedNodeId = resolveClickedNodeId({
763
+ targetElement,
764
+ fallbackNodeId: node.id
765
+ });
766
+ if (clickedNodeId && clickedNodeId !== node.id) {
767
+ event.stopPropagation();
768
+ onNodeClick(clickedNodeId);
769
+ return;
770
+ }
771
+ event.stopPropagation();
772
+ onNodeClick(node.id);
773
+ };
774
+ var createStudioNodeDoubleClickHandler = ({
775
+ node,
776
+ onInlineTextEdit,
777
+ effectiveCandidateInlineProp,
778
+ getTextValue,
779
+ setInlineEditing
780
+ }) => (event) => {
781
+ if (!onInlineTextEdit) return;
782
+ openInlineEditorFromDoubleClick({
783
+ event,
784
+ nodeId: node.id,
785
+ nodeType: node.type,
786
+ effectiveCandidateInlineProp,
787
+ getTextValue,
788
+ setInlineEditing
789
+ });
790
+ };
791
+
792
+ // src/studio-bridge/nodes/nodeWrapperStudio.tsx
793
+ import { jsx as jsx3 } from "react/jsx-runtime";
794
+ var getNodeWrapperPresentation = ({
795
+ isOpenStudioOverlayNode,
796
+ wrapperClassName,
797
+ widthPct,
798
+ shouldForceFullWidth
799
+ }) => {
800
+ const wrapperStyle = isOpenStudioOverlayNode ? {
801
+ position: "absolute",
802
+ inset: 0,
803
+ width: "100%",
804
+ height: "100%"
805
+ } : widthPct !== null || shouldForceFullWidth ? { width: `${widthPct != null ? widthPct : 100}%` } : void 0;
806
+ const overlayWrapperClassName = isOpenStudioOverlayNode ? [wrapperClassName, "absolute inset-0 h-full w-full"].filter(Boolean).join(" ") : wrapperClassName;
807
+ return {
808
+ wrapperStyle,
809
+ overlayWrapperClassName,
810
+ requiresPlainWrapper: Boolean(overlayWrapperClassName) || Boolean(wrapperStyle)
811
+ };
812
+ };
813
+ var getStudioNodeInteractionState = ({
814
+ node,
815
+ selectedNodeId,
816
+ effectiveCandidateInlineProp,
817
+ isInlineEditingNode,
818
+ isOpenStudioOverlayNode,
819
+ isInsideForm,
820
+ isInsideFormWizard,
821
+ isInsideStepForm,
822
+ inlinePropName
823
+ }) => {
824
+ var _a, _b, _c;
825
+ const nodeLayoutRecord = node.props && typeof node.props === "object" && !Array.isArray(node.props) && node.props.layout && typeof node.props.layout === "object" && !Array.isArray(node.props.layout) ? node.props.layout : {};
826
+ const isSelected = selectedNodeId === node.id;
827
+ const isFormFieldNode = node.type === "FormField" && String((_a = nodeLayoutRecord.formRole) != null ? _a : "field").trim() === "field";
828
+ const isTitleLikeInternalNode = String((_b = nodeLayoutRecord.formRole) != null ? _b : "").trim() === "title" || String((_c = nodeLayoutRecord.wizardStepRole) != null ? _c : "").trim() === "title" || ["H1", "H2", "H3", "H4", "H5", "H6"].includes(node.type);
829
+ const isActionButtonLikeNode = node.type === "Button" && (isInsideForm || isInsideFormWizard || isInsideStepForm);
830
+ const studioFormFieldWrapperClassName = isFormFieldNode ? "rounded-lg border-dashed border-sky-400/70 bg-sky-500/5 p-2 hover:border-sky-500 hover:bg-sky-500/10" : "";
831
+ const allowNodeHandles = (() => {
832
+ if (isInsideForm) return isFormFieldNode;
833
+ if (isInsideFormWizard || isInsideStepForm) {
834
+ if (isTitleLikeInternalNode) return false;
835
+ if (isActionButtonLikeNode) return false;
836
+ return true;
837
+ }
838
+ return true;
839
+ })();
840
+ return {
841
+ isSelected,
842
+ allowNodeHandles,
843
+ studioFormFieldWrapperClassName,
844
+ cursorClassName: effectiveCandidateInlineProp ? "cursor-text" : "cursor-pointer",
845
+ preserveContentWhileInlineEditing: isInlineEditingNode && isOpenStudioOverlayNode && (inlinePropName === "title" || inlinePropName === "closeText")
846
+ };
847
+ };
848
+ var renderPlainWrappedNode = ({
849
+ nodeId,
850
+ overlayWrapperClassName,
851
+ wrapperStyle,
852
+ nodeContent
853
+ }) => /* @__PURE__ */ jsx3(
854
+ "div",
855
+ {
856
+ "data-node-id": nodeId,
857
+ className: ["relative min-w-0 max-w-full flex-none", overlayWrapperClassName].filter(Boolean).join(" "),
858
+ style: wrapperStyle,
859
+ children: nodeContent
860
+ },
861
+ nodeId
862
+ );
863
+
864
+ // src/render-layer/renderDirectives.ts
865
+ var RENDER_BINDING_PROP_NAMES = /* @__PURE__ */ new Set([
866
+ "bindingEnabled",
867
+ "valueBindingKey",
868
+ "optionsBindingKey",
869
+ "useBindingData",
870
+ "entitiesBindingKey",
871
+ "videoBindingKey",
872
+ "mapBindingKey",
873
+ "productBindingKey",
874
+ "useTranslationKeys",
875
+ "tagContentTranslationKey",
876
+ "tagContentTranslationValue",
877
+ "hrefTranslationKey",
878
+ "hrefTranslationValue",
879
+ "mediaSource",
880
+ "mediaSrc",
881
+ "mediaAlt",
882
+ "rowsBindingKey",
883
+ "columnsBindingKey"
884
+ ]);
885
+ var STUDIO_INTERNAL_PROP_NAMES = /* @__PURE__ */ new Set([
886
+ ...RENDER_BINDING_PROP_NAMES
887
+ ]);
888
+ var getRenderBindingProps = (props) => {
889
+ if (!props || typeof props !== "object" || Array.isArray(props)) {
890
+ return {};
891
+ }
892
+ const source = props;
893
+ const embedded = source.__studio && typeof source.__studio === "object" && !Array.isArray(source.__studio) ? source.__studio : {};
894
+ const legacy = Array.from(RENDER_BINDING_PROP_NAMES).reduce(
895
+ (accumulator, key) => {
896
+ if (source[key] !== void 0) {
897
+ accumulator[key] = source[key];
898
+ }
899
+ return accumulator;
900
+ },
901
+ {}
902
+ );
903
+ return Array.from(RENDER_BINDING_PROP_NAMES).reduce((accumulator, key) => {
904
+ if (legacy[key] !== void 0) {
905
+ accumulator[key] = legacy[key];
906
+ } else if (embedded[key] !== void 0) {
907
+ accumulator[key] = embedded[key];
908
+ }
909
+ return accumulator;
910
+ }, {});
911
+ };
912
+ var omitStudioProps = (props) => {
913
+ const next = __spreadValues({}, props);
914
+ delete next.__studio;
915
+ for (const propName of STUDIO_INTERNAL_PROP_NAMES) {
916
+ delete next[propName];
917
+ }
918
+ return next;
919
+ };
920
+
921
+ // src/utils/renderChildren.tsx
922
+ import { normalizeRenderableChild, toBoolean } from "@arkcit/engine-react";
923
+
924
+ // src/studio-bridge/overlay/overlayStudio.ts
925
+ var toBoolean2 = (value) => {
926
+ if (typeof value === "boolean") return value;
927
+ if (typeof value === "string") return value.toLowerCase() === "true";
928
+ return Boolean(value);
929
+ };
930
+ var readOverlayState = (runtime) => {
931
+ const overlaysRaw = runtime.get("overlays.byNodeId");
932
+ return overlaysRaw && typeof overlaysRaw === "object" ? overlaysRaw : {};
933
+ };
934
+ var applyStudioOverlayComponentProps = ({
935
+ node,
936
+ componentProps,
937
+ runtime,
938
+ overlaysByNodeId,
939
+ renderBindingProps,
940
+ resolvedChildContent,
941
+ onInlineTextEdit,
942
+ isStudioRendererContext,
943
+ dropdownOpenByNodeId,
944
+ setDropdownOpenByNodeId
945
+ }) => {
946
+ if (node.type === "Popin") {
947
+ const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
948
+ const rawOverlayOpen = overlaysByNodeId[node.id];
949
+ const fallbackOpen = Boolean(componentProps.displayedPopin);
950
+ const isOpen = bindingEnabled ? typeof rawOverlayOpen === "boolean" ? rawOverlayOpen : fallbackOpen : fallbackOpen;
951
+ componentProps.displayedPopin = isOpen;
952
+ componentProps.setDisplayedPopin = (next) => {
953
+ const nextOpen = typeof next === "function" ? next(isOpen) : next;
954
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "displayedPopin", nextOpen);
955
+ if (bindingEnabled) {
956
+ runtime.dispatch({
957
+ id: nextOpen ? "overlay.open" : "overlay.close",
958
+ payload: { targetNodeId: node.id }
959
+ });
960
+ }
961
+ };
962
+ componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
963
+ }
964
+ if (node.type === "Drawer") {
965
+ const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
966
+ const rawOverlayOpen = overlaysByNodeId[node.id];
967
+ const fallbackOpen = Boolean(componentProps.open);
968
+ const isOpen = bindingEnabled ? typeof rawOverlayOpen === "boolean" ? rawOverlayOpen : fallbackOpen : fallbackOpen;
969
+ componentProps.open = isOpen;
970
+ componentProps.onClose = () => {
971
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "open", false);
972
+ if (bindingEnabled) {
973
+ runtime.dispatch({
974
+ id: "overlay.close",
975
+ payload: { targetNodeId: node.id }
976
+ });
977
+ }
978
+ };
979
+ componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
980
+ }
981
+ if (node.type === "Dropdown") {
982
+ const fallbackOpen = Boolean(componentProps.open);
983
+ const isOpen = isStudioRendererContext && node.id in dropdownOpenByNodeId ? Boolean(dropdownOpenByNodeId[node.id]) : fallbackOpen;
984
+ componentProps.open = isOpen;
985
+ componentProps.onOpenChange = (nextOpen) => {
986
+ setDropdownOpenByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
987
+ [node.id]: Boolean(nextOpen)
988
+ }));
989
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "open", Boolean(nextOpen));
990
+ };
991
+ if (resolvedChildContent !== null) {
992
+ componentProps.children = resolvedChildContent;
993
+ }
994
+ }
995
+ if (node.type === "Tooltip") {
996
+ componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
997
+ }
998
+ };
999
+ var getOpenStudioOverlayState = ({
1000
+ node,
1001
+ nodeProps,
1002
+ overlaysByNodeId
1003
+ }) => {
1004
+ const renderBindingProps = getRenderBindingProps(nodeProps);
1005
+ const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
1006
+ return Boolean(
1007
+ node.type === "Popin" && Boolean(bindingEnabled ? overlaysByNodeId[node.id] : nodeProps.displayedPopin) || node.type === "Drawer" && Boolean(bindingEnabled ? overlaysByNodeId[node.id] : nodeProps.open)
1008
+ );
1009
+ };
1010
+
1011
+ // src/studio-bridge/overlay/renderNodeFrame.tsx
1012
+ import { createPortal } from "react-dom";
1013
+ import { jsx as jsx4 } from "react/jsx-runtime";
1014
+ var renderNodeFrame = ({
1015
+ node,
1016
+ nodeProps,
1017
+ nodeContent,
1018
+ selectedNodeId,
1019
+ onNodeClick,
1020
+ onInlineTextEdit,
1021
+ onNodeResize,
1022
+ onNodeResizeStart,
1023
+ onNodeResizeEnd,
1024
+ widthPct,
1025
+ heightPct,
1026
+ heightPx,
1027
+ wrapperClassName,
1028
+ isOpenStudioOverlayNode,
1029
+ shouldForceFullWidth,
1030
+ effectiveCandidateInlineProp,
1031
+ inlineEditing,
1032
+ isInlineEditingNode,
1033
+ ancestorTypeMembership,
1034
+ schemaNodes,
1035
+ runtime,
1036
+ enableEventOnClick,
1037
+ isFormInteractiveTarget,
1038
+ getTextValue,
1039
+ setInlineEditing,
1040
+ inlineEditor,
1041
+ NodeWrapper,
1042
+ overlaysByNodeId,
1043
+ getOpenStudioOverlayState: getOpenStudioOverlayState2,
1044
+ resizeStateRef,
1045
+ pinchStateRef,
1046
+ minWidthPct,
1047
+ minHeightPct,
1048
+ minHeightPx,
1049
+ overlayRootId
1050
+ }) => {
1051
+ var _a;
1052
+ const { wrapperStyle, overlayWrapperClassName, requiresPlainWrapper } = getNodeWrapperPresentation({
1053
+ isOpenStudioOverlayNode,
1054
+ wrapperClassName,
1055
+ widthPct,
1056
+ shouldForceFullWidth
1057
+ });
1058
+ if (!onNodeClick && !selectedNodeId) {
1059
+ if (!requiresPlainWrapper) return nodeContent;
1060
+ return renderPlainWrappedNode({
1061
+ nodeId: node.id,
1062
+ overlayWrapperClassName,
1063
+ wrapperStyle,
1064
+ nodeContent
1065
+ });
1066
+ }
1067
+ const {
1068
+ isSelected,
1069
+ allowNodeHandles,
1070
+ studioFormFieldWrapperClassName,
1071
+ cursorClassName,
1072
+ preserveContentWhileInlineEditing
1073
+ } = getStudioNodeInteractionState({
1074
+ node,
1075
+ selectedNodeId,
1076
+ effectiveCandidateInlineProp,
1077
+ isInlineEditingNode,
1078
+ isOpenStudioOverlayNode,
1079
+ isInsideForm: ancestorTypeMembership.Form.has(node.id),
1080
+ isInsideFormWizard: ancestorTypeMembership.FormWizard.has(node.id),
1081
+ isInsideStepForm: ancestorTypeMembership.StepForm.has(node.id),
1082
+ inlinePropName: inlineEditing == null ? void 0 : inlineEditing.propName
1083
+ });
1084
+ const touchResizeHandlers = createTouchResizeHandlers({
1085
+ node,
1086
+ widthPct,
1087
+ heightPct,
1088
+ onNodeResize,
1089
+ onNodeResizeStart,
1090
+ onNodeResizeEnd,
1091
+ pinchStateRef,
1092
+ minWidthPct,
1093
+ minHeightPct
1094
+ });
1095
+ const onResizeMouseDown = createMouseResizeHandler({
1096
+ node,
1097
+ widthPct,
1098
+ heightPct,
1099
+ heightPx,
1100
+ onNodeResize,
1101
+ onNodeResizeStart,
1102
+ resizeStateRef,
1103
+ minHeightPx
1104
+ });
1105
+ const onClick = createStudioNodeClickHandler({
1106
+ node,
1107
+ nodeProps,
1108
+ schemaNodes,
1109
+ runtime,
1110
+ onNodeClick,
1111
+ onInlineTextEdit,
1112
+ isInlineEditingNode,
1113
+ enableEventOnClick,
1114
+ isFormInteractiveTarget
1115
+ });
1116
+ const onDoubleClick = createStudioNodeDoubleClickHandler({
1117
+ node,
1118
+ onInlineTextEdit,
1119
+ effectiveCandidateInlineProp,
1120
+ getTextValue,
1121
+ setInlineEditing
1122
+ });
1123
+ const wrappedNode = /* @__PURE__ */ jsx4(
1124
+ NodeWrapper,
1125
+ {
1126
+ nodeId: node.id,
1127
+ wrapperClassName: [overlayWrapperClassName, studioFormFieldWrapperClassName].filter(Boolean).join(" "),
1128
+ cursorClassName: onNodeClick ? cursorClassName : "",
1129
+ isSelected,
1130
+ allowDragHandle: allowNodeHandles,
1131
+ allowResizeHandle: allowNodeHandles,
1132
+ style: wrapperStyle,
1133
+ onTouchStart: touchResizeHandlers.onTouchStart,
1134
+ onTouchMove: touchResizeHandlers.onTouchMove,
1135
+ onTouchEnd: touchResizeHandlers.onTouchEnd,
1136
+ onClick,
1137
+ onDoubleClick,
1138
+ showResizeHandle: isSelected && Boolean(onNodeResize) && allowNodeHandles,
1139
+ onResizeMouseDown,
1140
+ isInlineEditing: isInlineEditingNode,
1141
+ preserveContentWhileInlineEditing,
1142
+ inlineEditor,
1143
+ children: nodeContent
1144
+ }
1145
+ );
1146
+ if (getOpenStudioOverlayState2({
1147
+ node,
1148
+ nodeProps,
1149
+ overlaysByNodeId
1150
+ })) {
1151
+ const overlayRoot = (_a = globalThis.document) == null ? void 0 : _a.getElementById(overlayRootId);
1152
+ if (overlayRoot) {
1153
+ return createPortal(wrappedNode, overlayRoot);
1154
+ }
1155
+ }
1156
+ return wrappedNode;
1157
+ };
1158
+
1159
+ // src/studio-bridge/preview-form/previewFormRenderer.tsx
1160
+ import React from "react";
1161
+
1162
+ // src/form/engineFormValidation.ts
1163
+ var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1164
+ var isEmptyValue = (value) => {
1165
+ if (value == null) return true;
1166
+ if (typeof value === "string") return value.trim().length === 0;
1167
+ if (Array.isArray(value)) return value.length === 0;
1168
+ return false;
1169
+ };
1170
+ var toNumber = (value) => {
1171
+ if (typeof value === "number" && Number.isFinite(value)) return value;
1172
+ if (typeof value === "string") {
1173
+ const parsed = Number(value);
1174
+ return Number.isFinite(parsed) ? parsed : null;
1175
+ }
1176
+ return null;
1177
+ };
1178
+ var defaultDeclarativeValidatorRegistry = {
1179
+ required: (value) => isEmptyValue(value) ? { code: "required" } : null,
1180
+ minLength: (value, params) => {
1181
+ var _a;
1182
+ if (isEmptyValue(value)) return null;
1183
+ const min = toNumber((_a = params == null ? void 0 : params.min) != null ? _a : params == null ? void 0 : params.value);
1184
+ if (min == null) return null;
1185
+ return String(value).length < min ? { code: "minLength", params: { min } } : null;
1186
+ },
1187
+ maxLength: (value, params) => {
1188
+ var _a;
1189
+ if (isEmptyValue(value)) return null;
1190
+ const max = toNumber((_a = params == null ? void 0 : params.max) != null ? _a : params == null ? void 0 : params.value);
1191
+ if (max == null) return null;
1192
+ return String(value).length > max ? { code: "maxLength", params: { max } } : null;
1193
+ },
1194
+ email: (value) => {
1195
+ if (isEmptyValue(value)) return null;
1196
+ return EMAIL_REGEX.test(String(value)) ? null : { code: "email" };
1197
+ },
1198
+ pattern: (value, params) => {
1199
+ var _a, _b;
1200
+ if (isEmptyValue(value)) return null;
1201
+ const rawPattern = String((_b = (_a = params == null ? void 0 : params.pattern) != null ? _a : params == null ? void 0 : params.value) != null ? _b : "").trim();
1202
+ if (!rawPattern) return null;
1203
+ try {
1204
+ const regex = new RegExp(rawPattern);
1205
+ return regex.test(String(value)) ? null : { code: "pattern", params: { pattern: rawPattern } };
1206
+ } catch (e) {
1207
+ return { code: "pattern" };
1208
+ }
1209
+ }
1210
+ };
1211
+ var buildLegacyValidators = (field) => {
1212
+ var _a, _b, _c;
1213
+ const validators = [];
1214
+ if (field.required) {
1215
+ validators.push({
1216
+ id: `${String((_a = field.name) != null ? _a : "field")}:required`,
1217
+ type: "required",
1218
+ stopOnFailure: true
1219
+ });
1220
+ }
1221
+ if (String((_b = field.pattern) != null ? _b : "").trim()) {
1222
+ validators.push({
1223
+ id: `${String((_c = field.name) != null ? _c : "field")}:pattern`,
1224
+ type: "pattern",
1225
+ params: { pattern: String(field.pattern) }
1226
+ });
1227
+ }
1228
+ return validators;
1229
+ };
1230
+ var normalizeValidators = (field, options) => {
1231
+ const explicit = Array.isArray(field.validators) ? field.validators : [];
1232
+ if (explicit.length > 0) return explicit;
1233
+ if (!(options == null ? void 0 : options.useLegacyFieldConstraints)) return [];
1234
+ return buildLegacyValidators(field);
1235
+ };
1236
+ var toIssueArray = (issue) => {
1237
+ if (!issue) return [];
1238
+ return Array.isArray(issue) ? issue : [issue];
1239
+ };
1240
+ var validateFieldWithConfig = (field, value, values, config, registry) => {
1241
+ if (config.enabled === false) return [];
1242
+ const validate = registry[config.type];
1243
+ if (!validate) return [];
1244
+ const baseIssues = toIssueArray(
1245
+ validate(value, config.params, {
1246
+ field,
1247
+ values
1248
+ })
1249
+ );
1250
+ return baseIssues.map((baseIssue) => {
1251
+ var _a, _b, _c, _d, _e;
1252
+ return {
1253
+ field: String((_a = field.name) != null ? _a : ""),
1254
+ validatorId: config.id || baseIssue.validatorId,
1255
+ code: baseIssue.code,
1256
+ messageKey: (_b = baseIssue.messageKey) != null ? _b : config.messageKey,
1257
+ message: (_c = baseIssue.message) != null ? _c : config.message,
1258
+ params: __spreadValues(__spreadValues({}, (_d = config.params) != null ? _d : {}), (_e = baseIssue.params) != null ? _e : {})
1259
+ };
1260
+ });
1261
+ };
1262
+ var resolveIssueMessage = (issue, t) => {
1263
+ const defaultMessageByCode = () => {
1264
+ var _a, _b, _c, _d, _e, _f;
1265
+ switch (issue.code) {
1266
+ case "required":
1267
+ return "This field is required";
1268
+ case "email":
1269
+ return "Invalid email address";
1270
+ case "pattern":
1271
+ return "Invalid format";
1272
+ case "minLength": {
1273
+ const min = (_c = (_a = issue.params) == null ? void 0 : _a.min) != null ? _c : (_b = issue.params) == null ? void 0 : _b.value;
1274
+ return min != null ? `Minimum ${String(min)} characters` : "Value is too short";
1275
+ }
1276
+ case "maxLength": {
1277
+ const max = (_f = (_d = issue.params) == null ? void 0 : _d.max) != null ? _f : (_e = issue.params) == null ? void 0 : _e.value;
1278
+ return max != null ? `Maximum ${String(max)} characters` : "Value is too long";
1279
+ }
1280
+ default:
1281
+ return void 0;
1282
+ }
1283
+ };
1284
+ if (issue.messageKey && t) {
1285
+ const translated = t(issue.messageKey, issue.params);
1286
+ if (typeof translated === "string" && translated.trim().length > 0) {
1287
+ return translated;
1288
+ }
1289
+ }
1290
+ if (issue.message && issue.message.trim().length > 0) return issue.message;
1291
+ if (issue.messageKey && issue.messageKey.trim().length > 0) return issue.messageKey;
1292
+ return defaultMessageByCode();
1293
+ };
1294
+ var validateFormValues = (fields, values, options) => {
1295
+ var _a;
1296
+ const mergedRegistry = __spreadValues(__spreadValues({}, defaultDeclarativeValidatorRegistry), (_a = options == null ? void 0 : options.registry) != null ? _a : {});
1297
+ const issues = [];
1298
+ fields.forEach((field) => {
1299
+ var _a2;
1300
+ const fieldName = String((_a2 = field.name) != null ? _a2 : "").trim();
1301
+ if (!fieldName) return;
1302
+ const fieldValue = values[fieldName];
1303
+ const validators = normalizeValidators(field, options);
1304
+ if (validators.length === 0) return;
1305
+ for (const validatorConfig of validators) {
1306
+ const fieldIssues = validateFieldWithConfig(
1307
+ field,
1308
+ fieldValue,
1309
+ values,
1310
+ validatorConfig,
1311
+ mergedRegistry
1312
+ );
1313
+ if (fieldIssues.length > 0) {
1314
+ issues.push(...fieldIssues);
1315
+ if (validatorConfig.stopOnFailure) break;
1316
+ }
1317
+ }
1318
+ });
1319
+ const errors = {};
1320
+ issues.forEach((issue) => {
1321
+ if (errors[issue.field]) return;
1322
+ errors[issue.field] = resolveIssueMessage(issue, options == null ? void 0 : options.t);
1323
+ });
1324
+ return { issues, errors };
1325
+ };
1326
+
1327
+ // src/utils/formStudio.ts
1328
+ var getLayoutRecord = (props) => {
1329
+ if (!props) return {};
1330
+ const layout = props.layout;
1331
+ if (!layout || typeof layout !== "object" || Array.isArray(layout)) {
1332
+ return {};
1333
+ }
1334
+ return layout;
1335
+ };
1336
+ var normalizeStudioFormChild = (child) => {
1337
+ var _a, _b, _c, _d, _e;
1338
+ const childProps = (_a = child.props) != null ? _a : {};
1339
+ const childLayout = getLayoutRecord(childProps);
1340
+ if (child.type === "__studio_form_field") {
1341
+ return __spreadProps(__spreadValues({}, child), {
1342
+ type: "FormField",
1343
+ props: __spreadProps(__spreadValues({}, childProps), {
1344
+ layout: __spreadProps(__spreadValues({}, childLayout), {
1345
+ formRole: "field"
1346
+ })
1347
+ })
1348
+ });
1349
+ }
1350
+ if (child.type === "__studio_form_title") {
1351
+ return __spreadProps(__spreadValues({}, child), {
1352
+ type: "Text",
1353
+ props: __spreadProps(__spreadValues({}, childProps), {
1354
+ layout: __spreadProps(__spreadValues({}, childLayout), {
1355
+ formRole: "title"
1356
+ })
1357
+ })
1358
+ });
1359
+ }
1360
+ if (child.type === "__studio_form_submit") {
1361
+ return __spreadProps(__spreadValues({}, child), {
1362
+ type: "Button",
1363
+ props: __spreadProps(__spreadValues({}, childProps), {
1364
+ intent: String((_b = childProps.intent) != null ? _b : "primary"),
1365
+ variant: String((_c = childProps.variant) != null ? _c : "solid"),
1366
+ layout: __spreadProps(__spreadValues({}, childLayout), {
1367
+ formRole: "submit"
1368
+ })
1369
+ })
1370
+ });
1371
+ }
1372
+ if (child.type === "__studio_form_reset") {
1373
+ return __spreadProps(__spreadValues({}, child), {
1374
+ type: "Button",
1375
+ props: __spreadProps(__spreadValues({}, childProps), {
1376
+ intent: String((_d = childProps.intent) != null ? _d : "neutral"),
1377
+ variant: String((_e = childProps.variant) != null ? _e : "outline"),
1378
+ layout: __spreadProps(__spreadValues({}, childLayout), {
1379
+ formRole: "reset"
1380
+ })
1381
+ })
1382
+ });
1383
+ }
1384
+ return child;
1385
+ };
1386
+ var getStudioFormChildRole = (child) => {
1387
+ var _a, _b;
1388
+ if (child.type === "__studio_form_field") return "field";
1389
+ if (child.type === "__studio_form_title") return "title";
1390
+ if (child.type === "__studio_form_submit") return "submit";
1391
+ if (child.type === "__studio_form_reset") return "reset";
1392
+ const layout = getLayoutRecord(
1393
+ (_a = child.props) != null ? _a : {}
1394
+ );
1395
+ return String((_b = layout.formRole) != null ? _b : "").trim();
1396
+ };
1397
+ var buildFormFieldConfig = (rawProps, nestedField = {}) => {
1398
+ var _a, _b, _c, _d;
1399
+ const fieldName = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
1400
+ return __spreadProps(__spreadValues(__spreadValues({}, nestedField), rawProps), {
1401
+ name: fieldName,
1402
+ label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : fieldName)
1403
+ });
1404
+ };
1405
+ var buildWizardFieldConfig = (rawProps, nestedField) => {
1406
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1407
+ const name = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
1408
+ return {
1409
+ name,
1410
+ label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : name || "Field"),
1411
+ type: (_e = rawProps.type) != null ? _e : nestedField.type,
1412
+ required: Boolean((_g = (_f = rawProps.required) != null ? _f : nestedField.required) != null ? _g : false),
1413
+ pattern: rawProps.pattern != null ? String(rawProps.pattern) : nestedField.pattern != null ? String(nestedField.pattern) : void 0,
1414
+ placeholder: (_h = rawProps.placeholder) != null ? _h : nestedField.placeholder,
1415
+ validators: Array.isArray(rawProps.validators) && rawProps.validators.length > 0 ? rawProps.validators : Array.isArray(nestedField.validators) && nestedField.validators.length > 0 ? nestedField.validators : void 0,
1416
+ options: (_i = rawProps.options) != null ? _i : nestedField.options,
1417
+ helperText: (_j = rawProps.helperText) != null ? _j : nestedField.helperText,
1418
+ defaultValue: (_k = rawProps.defaultValue) != null ? _k : nestedField.defaultValue,
1419
+ rows: (_l = rawProps.rows) != null ? _l : nestedField.rows,
1420
+ accept: (_m = rawProps.accept) != null ? _m : nestedField.accept
1421
+ };
1422
+ };
1423
+
1424
+ // src/layout/nodeLayout.ts
1425
+ var toPositiveNumber = (value) => {
1426
+ const numeric = Number(value);
1427
+ if (!Number.isFinite(numeric) || numeric <= 0) return void 0;
1428
+ return numeric;
1429
+ };
1430
+ var toColSpan = (value) => {
1431
+ const numeric = Number(value);
1432
+ if (!Number.isInteger(numeric) || numeric < 1 || numeric > 12) return void 0;
1433
+ return numeric;
1434
+ };
1435
+ var toCardSection = (value) => {
1436
+ if (value === "header" || value === "body" || value === "footer") return value;
1437
+ return void 0;
1438
+ };
1439
+ var readNodeLayout = (props) => {
1440
+ var _a, _b, _c, _d, _e, _f, _g;
1441
+ if (!props) return {};
1442
+ const rawLayout = props.layout && typeof props.layout === "object" && !Array.isArray(props.layout) ? props.layout : {};
1443
+ return {
1444
+ widthPct: toPositiveNumber((_a = rawLayout.widthPct) != null ? _a : props.__studioWidthPct),
1445
+ heightPct: toPositiveNumber((_b = rawLayout.heightPct) != null ? _b : props.__studioHeightPct),
1446
+ heightPx: toPositiveNumber((_c = rawLayout.heightPx) != null ? _c : props.__studioHeightPx),
1447
+ colSpan: toColSpan((_d = rawLayout.colSpan) != null ? _d : props.__studioColSpan),
1448
+ wrapperClassName: String(
1449
+ (_f = (_e = rawLayout.wrapperClassName) != null ? _e : props.__studioWrapperClassName) != null ? _f : ""
1450
+ ).trim(),
1451
+ cardSection: toCardSection((_g = rawLayout.cardSection) != null ? _g : props.__studioCardSection)
1452
+ };
1453
+ };
1454
+
1455
+ // src/studio-bridge/preview-form/previewFormState.ts
1456
+ var resolveStudioFormNextValues = ({
1457
+ formValues,
1458
+ fieldName,
1459
+ nextValue
1460
+ }) => __spreadProps(__spreadValues({}, formValues), {
1461
+ [fieldName]: nextValue
1462
+ });
1463
+ var resolveStudioFormResetValues = (normalizedFormFields) => normalizedFormFields.reduce((accumulator, field) => {
1464
+ var _a, _b;
1465
+ const fieldName = String((_a = field.name) != null ? _a : "").trim();
1466
+ if (!fieldName) return accumulator;
1467
+ accumulator[fieldName] = (_b = field.defaultValue) != null ? _b : "";
1468
+ return accumulator;
1469
+ }, {});
1470
+ var patchStudioFormFieldNode = ({
1471
+ child,
1472
+ formValues,
1473
+ formErrors,
1474
+ formDict,
1475
+ formLoaderType,
1476
+ fieldOnChange
1477
+ }) => {
1478
+ var _a, _b, _c;
1479
+ const rawChildProps = (_a = child.props) != null ? _a : {};
1480
+ const childLayout = readNodeLayout(rawChildProps);
1481
+ const rawLayout = rawChildProps.layout && typeof rawChildProps.layout === "object" && !Array.isArray(rawChildProps.layout) ? __spreadValues({}, rawChildProps.layout) : {};
1482
+ const existingWrapperClassName = String((_b = rawLayout.wrapperClassName) != null ? _b : "").trim();
1483
+ rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
1484
+ delete rawLayout.widthPct;
1485
+ delete rawLayout.heightPct;
1486
+ delete rawLayout.heightPx;
1487
+ const fieldBasis = childLayout.widthPct !== null ? `${childLayout.widthPct}%` : "100%";
1488
+ const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
1489
+ const fieldConfig = buildFormFieldConfig(rawChildProps, nestedField);
1490
+ const fieldName = String((_c = fieldConfig.name) != null ? _c : "").trim();
1491
+ const value = fieldName && fieldName in formValues ? formValues[fieldName] : rawChildProps.defaultValue;
1492
+ const patchedFieldNode = __spreadProps(__spreadValues({}, child), {
1493
+ props: __spreadValues(__spreadProps(__spreadValues({}, rawChildProps), {
1494
+ layout: rawLayout,
1495
+ field: fieldConfig,
1496
+ value,
1497
+ error: fieldName ? formErrors[fieldName] : void 0,
1498
+ onChange: fieldOnChange,
1499
+ dict: formDict
1500
+ }), formLoaderType !== void 0 ? { loaderType: formLoaderType } : {})
1501
+ });
1502
+ return {
1503
+ patchedFieldNode,
1504
+ fieldBasis
1505
+ };
1506
+ };
1507
+
1508
+ // src/studio-bridge/preview-form/previewFormStructure.ts
1509
+ var DEFAULT_FORM_DICT = {
1510
+ submit: "Submit",
1511
+ reset: "Reset",
1512
+ loading: "Loading...",
1513
+ success: "Saved",
1514
+ search: "Search...",
1515
+ noResultToShow: "No result"
1516
+ };
1517
+ var resolveStudioFormStructure = ({
1518
+ componentProps,
1519
+ visibleChildren
1520
+ }) => {
1521
+ const normalizedChildren = visibleChildren.map((child) => normalizeStudioFormChild(child));
1522
+ const titleNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "title");
1523
+ const fieldNodes = normalizedChildren.filter((child) => getStudioFormChildRole(child) === "field");
1524
+ const submitNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "submit");
1525
+ const resetNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "reset");
1526
+ const externalChildren = normalizedChildren.filter((child) => {
1527
+ const role = getStudioFormChildRole(child);
1528
+ return role !== "title" && role !== "field" && role !== "submit" && role !== "reset";
1529
+ });
1530
+ const formValues = componentProps.values && typeof componentProps.values === "object" && !Array.isArray(componentProps.values) ? componentProps.values : {};
1531
+ const formErrors = componentProps.errors && typeof componentProps.errors === "object" && !Array.isArray(componentProps.errors) ? componentProps.errors : {};
1532
+ const formDict = componentProps.dict && typeof componentProps.dict === "object" && !Array.isArray(componentProps.dict) ? componentProps.dict : DEFAULT_FORM_DICT;
1533
+ const normalizedFormFields = fieldNodes.map((child) => {
1534
+ var _a;
1535
+ const rawChildProps = (_a = child.props) != null ? _a : {};
1536
+ const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
1537
+ return buildFormFieldConfig(rawChildProps, nestedField);
1538
+ }).filter((field) => {
1539
+ var _a;
1540
+ return String((_a = field.name) != null ? _a : "").trim().length > 0;
1541
+ });
1542
+ return {
1543
+ normalizedChildren,
1544
+ titleNode,
1545
+ fieldNodes,
1546
+ submitNode,
1547
+ resetNode,
1548
+ externalChildren,
1549
+ normalizedFormFields,
1550
+ formValues,
1551
+ formErrors,
1552
+ formDict,
1553
+ formLoaderType: componentProps.loaderType
1554
+ };
1555
+ };
1556
+
1557
+ // src/studio-bridge/preview-form/previewFormRenderer.tsx
1558
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1559
+ var materializePreviewForm = ({
1560
+ node,
1561
+ componentProps,
1562
+ visibleChildren,
1563
+ runtime,
1564
+ onInlineTextEdit,
1565
+ captureFieldFocus,
1566
+ renderSafeNode: renderSafeNode2
1567
+ }) => {
1568
+ var _a, _b, _c, _d, _e, _f, _g;
1569
+ const {
1570
+ titleNode,
1571
+ fieldNodes,
1572
+ submitNode,
1573
+ resetNode,
1574
+ externalChildren,
1575
+ normalizedFormFields,
1576
+ formValues,
1577
+ formErrors,
1578
+ formDict,
1579
+ formLoaderType
1580
+ } = resolveStudioFormStructure({
1581
+ componentProps,
1582
+ visibleChildren
1583
+ });
1584
+ if (!(fieldNodes.length > 0 || titleNode || submitNode || resetNode)) {
1585
+ return null;
1586
+ }
1587
+ const validateAndSetErrors = (nextValues) => {
1588
+ const validation = validateFormValues(normalizedFormFields, nextValues, {
1589
+ t: runtime.t,
1590
+ useLegacyFieldConstraints: true
1591
+ });
1592
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", validation.errors);
1593
+ return validation;
1594
+ };
1595
+ const fieldOnChange = (event) => {
1596
+ var _a2;
1597
+ captureFieldFocus(event.target);
1598
+ const fieldName = String((_a2 = event.target.name) != null ? _a2 : "").trim();
1599
+ if (!fieldName) return;
1600
+ const target = event.target;
1601
+ const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
1602
+ const nextValues = resolveStudioFormNextValues({
1603
+ formValues,
1604
+ fieldName,
1605
+ nextValue
1606
+ });
1607
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", nextValues);
1608
+ validateAndSetErrors(nextValues);
1609
+ };
1610
+ const openInlineEditorForFormDictProp = (propName, fallbackValue) => {
1611
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, propName, fallbackValue);
1612
+ };
1613
+ const openInlineEditorForFormNodeProp = (targetNodeId, fallbackValue) => {
1614
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(targetNodeId, "children", fallbackValue);
1615
+ };
1616
+ return /* @__PURE__ */ jsxs2("div", { className: "mx-auto mt-10 w-full min-w-0 rounded-2xl border border-border bg-background p-6 shadow-sm", children: [
1617
+ titleNode ? /* @__PURE__ */ jsx5("div", { className: "mb-6 text-center", children: renderSafeNode2(__spreadProps(__spreadValues({}, titleNode), {
1618
+ type: "H3",
1619
+ props: __spreadProps(__spreadValues({}, (_a = titleNode.props) != null ? _a : {}), {
1620
+ className: "text-center text-2xl font-semibold text-foreground",
1621
+ layout: __spreadProps(__spreadValues({}, getLayoutRecord(
1622
+ (_b = titleNode.props) != null ? _b : {}
1623
+ )), {
1624
+ formRole: "title"
1625
+ })
1626
+ })
1627
+ })) }) : /* @__PURE__ */ jsx5("h3", { className: "mb-6 text-center text-2xl font-semibold text-foreground", children: String((_c = componentProps.title) != null ? _c : "Form") }),
1628
+ /* @__PURE__ */ jsxs2(
1629
+ "form",
1630
+ {
1631
+ className: "flex flex-wrap items-start gap-x-3 gap-y-3",
1632
+ role: "form",
1633
+ onSubmit: (event) => {
1634
+ event.preventDefault();
1635
+ const validation = validateAndSetErrors(formValues);
1636
+ if (Object.keys(validation.errors).length > 0) return;
1637
+ },
1638
+ children: [
1639
+ fieldNodes.map((child) => {
1640
+ const { patchedFieldNode, fieldBasis } = patchStudioFormFieldNode({
1641
+ child,
1642
+ formValues,
1643
+ formErrors,
1644
+ formDict,
1645
+ formLoaderType,
1646
+ fieldOnChange
1647
+ });
1648
+ return /* @__PURE__ */ jsx5("div", { className: "contents", children: /* @__PURE__ */ jsx5("div", { style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }, children: /* @__PURE__ */ jsx5("div", { className: "min-w-0", children: renderSafeNode2(patchedFieldNode) }) }) }, child.id);
1649
+ }),
1650
+ submitNode || resetNode ? /* @__PURE__ */ jsxs2("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
1651
+ submitNode ? renderSafeNode2(__spreadProps(__spreadValues({}, submitNode), {
1652
+ props: __spreadProps(__spreadValues({}, (_d = submitNode.props) != null ? _d : {}), {
1653
+ type: "submit",
1654
+ onDoubleClick: (event) => {
1655
+ var _a2, _b2, _c2;
1656
+ event.preventDefault();
1657
+ event.stopPropagation();
1658
+ openInlineEditorForFormNodeProp(
1659
+ submitNode.id,
1660
+ String(
1661
+ (_c2 = (_b2 = (_a2 = submitNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.submit) != null ? _c2 : "Submit"
1662
+ )
1663
+ );
1664
+ }
1665
+ })
1666
+ })) : null,
1667
+ resetNode ? renderSafeNode2(__spreadProps(__spreadValues({}, resetNode), {
1668
+ props: __spreadProps(__spreadValues({}, (_e = resetNode.props) != null ? _e : {}), {
1669
+ type: "button",
1670
+ onClick: () => {
1671
+ const resetValues = resolveStudioFormResetValues(normalizedFormFields);
1672
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
1673
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
1674
+ },
1675
+ onDoubleClick: (event) => {
1676
+ var _a2, _b2, _c2;
1677
+ event.preventDefault();
1678
+ event.stopPropagation();
1679
+ openInlineEditorForFormNodeProp(
1680
+ resetNode.id,
1681
+ String(
1682
+ (_c2 = (_b2 = (_a2 = resetNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.reset) != null ? _c2 : "Reset"
1683
+ )
1684
+ );
1685
+ }
1686
+ })
1687
+ })) : null
1688
+ ] }) : componentProps.onSubmit || componentProps.onReset ? /* @__PURE__ */ jsxs2("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
1689
+ componentProps.onSubmit ? /* @__PURE__ */ jsx5(
1690
+ "button",
1691
+ {
1692
+ type: "submit",
1693
+ className: "inline-flex items-center justify-center rounded-md border border-primary bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
1694
+ onDoubleClick: (event) => {
1695
+ var _a2;
1696
+ event.preventDefault();
1697
+ event.stopPropagation();
1698
+ openInlineEditorForFormDictProp("dict.submit", String((_a2 = formDict.submit) != null ? _a2 : "Submit"));
1699
+ },
1700
+ children: String((_f = formDict.submit) != null ? _f : "Submit")
1701
+ }
1702
+ ) : null,
1703
+ componentProps.onReset ? /* @__PURE__ */ jsx5(
1704
+ "button",
1705
+ {
1706
+ type: "button",
1707
+ className: "inline-flex items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium text-foreground",
1708
+ onClick: () => {
1709
+ const resetValues = resolveStudioFormResetValues(normalizedFormFields);
1710
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
1711
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
1712
+ },
1713
+ onDoubleClick: (event) => {
1714
+ var _a2;
1715
+ event.preventDefault();
1716
+ event.stopPropagation();
1717
+ openInlineEditorForFormDictProp("dict.reset", String((_a2 = formDict.reset) != null ? _a2 : "Reset"));
1718
+ },
1719
+ children: String((_g = formDict.reset) != null ? _g : "Reset")
1720
+ }
1721
+ ) : null
1722
+ ] }) : null,
1723
+ externalChildren.map((child) => /* @__PURE__ */ jsx5(React.Fragment, { children: renderSafeNode2(child) }, child.id))
1724
+ ]
1725
+ }
1726
+ )
1727
+ ] });
1728
+ };
1729
+
1730
+ // src/utils/navigationStudio.tsx
1731
+ import {
1732
+ buildAccordionItems,
1733
+ buildExpandablePanelChildren
1734
+ } from "@arkcit/engine-react";
1735
+
1736
+ // src/runtime/bindings.ts
1737
+ var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1738
+ var MISSING_TRANSLATION_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
1739
+ var MISSING_REF_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
1740
+ var isPlainObject = (value) => {
1741
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
1742
+ const prototype = Object.getPrototypeOf(value);
1743
+ return prototype === Object.prototype || prototype === null;
1744
+ };
1745
+ var isReactElementLike = (value) => isPlainObject(value) && typeof value.$$typeof === "symbol" && "props" in value;
1746
+ var isTranslationValue = (value) => isPlainObject(value) && typeof value.$t === "string";
1747
+ var isRefValue = (value) => isPlainObject(value) && typeof value.$ref === "string";
1748
+ var isExprValue = (value) => isPlainObject(value) && typeof value.$expr === "string";
1749
+ var parseStructuredString = (value) => {
1750
+ if (typeof value !== "string") return value;
1751
+ const trimmed = value.trim();
1752
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return value;
1753
+ try {
1754
+ const parsed = JSON.parse(trimmed);
1755
+ if (!isPlainObject(parsed)) return value;
1756
+ if ((typeof parsed.$ref === "string" || typeof parsed.$t === "string") && Object.keys(parsed).length >= 1) {
1757
+ return parsed;
1758
+ }
1759
+ return value;
1760
+ } catch (e) {
1761
+ return value;
1762
+ }
1763
+ };
1764
+ var resolveUIValue = (value, runtime) => {
1765
+ const normalizedValue = parseStructuredString(value);
1766
+ if (isTranslationValue(normalizedValue)) {
1767
+ const fallback = typeof normalizedValue.defaultValue === "string" && normalizedValue.defaultValue.trim() ? normalizedValue.defaultValue : normalizedValue.$t;
1768
+ if (!runtime.t) return fallback || MISSING_TRANSLATION_FALLBACK;
1769
+ const translated = runtime.t(normalizedValue.$t, normalizedValue.values);
1770
+ if (typeof translated !== "string") return fallback || MISSING_TRANSLATION_FALLBACK;
1771
+ if (!translated.trim()) return fallback || MISSING_TRANSLATION_FALLBACK;
1772
+ if (translated === normalizedValue.$t) return fallback || MISSING_TRANSLATION_FALLBACK;
1773
+ return translated;
1774
+ }
1775
+ if (isRefValue(normalizedValue)) {
1776
+ const resolved = runtime.get(normalizedValue.$ref);
1777
+ if (resolved == null) return MISSING_REF_FALLBACK;
1778
+ if (typeof resolved === "string" && !resolved.trim()) return MISSING_REF_FALLBACK;
1779
+ return resolved;
1780
+ }
1781
+ if (isExprValue(normalizedValue)) {
1782
+ return void 0;
1783
+ }
1784
+ if (Array.isArray(normalizedValue)) {
1785
+ return normalizedValue.map((item) => resolveUIValue(item, runtime));
1786
+ }
1787
+ if (isReactElementLike(normalizedValue)) {
1788
+ return normalizedValue;
1789
+ }
1790
+ if (isPlainObject(normalizedValue)) {
1791
+ const next = {};
1792
+ Object.entries(normalizedValue).forEach(([key, childValue]) => {
1793
+ if (DANGEROUS_KEYS.has(key)) return;
1794
+ next[key] = resolveUIValue(childValue, runtime);
1795
+ });
1796
+ return next;
1797
+ }
1798
+ return normalizedValue;
1799
+ };
1800
+
1801
+ // src/studio-bridge/preview-navigation/previewTabs.ts
1802
+ var normalizeStudioTabsProps = (props) => {
1803
+ var _a;
1804
+ const rawTabs = Array.isArray(props.tabs) ? props.tabs : [];
1805
+ const tabs = rawTabs.length ? rawTabs.map((tab, index) => {
1806
+ var _a2, _b, _c;
1807
+ const rawTab = tab && typeof tab === "object" && !Array.isArray(tab) ? tab : {};
1808
+ const id = String((_a2 = rawTab.id) != null ? _a2 : `tab-${index + 1}`);
1809
+ const title = (_c = (_b = rawTab.title) != null ? _b : rawTab.label) != null ? _c : `Tab ${index + 1}`;
1810
+ return __spreadProps(__spreadValues({}, rawTab), {
1811
+ id,
1812
+ title,
1813
+ label: title
1814
+ });
1815
+ }) : [
1816
+ {
1817
+ id: "overview",
1818
+ title: "Overview",
1819
+ label: "Overview",
1820
+ content: "Overview content"
1821
+ }
1822
+ ];
1823
+ const rawDict = props.dict && typeof props.dict === "object" && !Array.isArray(props.dict) ? props.dict : {};
1824
+ const rawUrlSync = props.urlSync && typeof props.urlSync === "object" && !Array.isArray(props.urlSync) ? props.urlSync : null;
1825
+ const rawNavigation = (rawUrlSync == null ? void 0 : rawUrlSync.navigation) && typeof rawUrlSync.navigation === "object" && !Array.isArray(rawUrlSync.navigation) ? rawUrlSync.navigation : null;
1826
+ const normalizedUrlSync = rawNavigation && typeof rawNavigation.getSearch === "function" && typeof rawNavigation.replaceSearch === "function" ? __spreadProps(__spreadValues({}, rawUrlSync), {
1827
+ navigation: rawNavigation
1828
+ }) : void 0;
1829
+ return __spreadProps(__spreadValues({}, props), {
1830
+ tabs,
1831
+ dict: __spreadProps(__spreadValues({}, rawDict), {
1832
+ noContentYet: typeof rawDict.noContentYet === "string" && rawDict.noContentYet.trim().length > 0 ? rawDict.noContentYet : "No content yet"
1833
+ }),
1834
+ defaultActive: typeof props.defaultActive === "string" && props.defaultActive.trim().length > 0 ? props.defaultActive : String((_a = tabs[0].id) != null ? _a : "overview"),
1835
+ keepMounted: typeof props.keepMounted === "boolean" ? props.keepMounted : true,
1836
+ urlSync: normalizedUrlSync
1837
+ });
1838
+ };
1839
+ var resolveStudioTabsContent = ({
1840
+ tabItems,
1841
+ rawChildren,
1842
+ runtime,
1843
+ renderChild,
1844
+ normalizeRenderableChild: normalizeRenderableChild2
1845
+ }) => {
1846
+ const childrenByTabId = /* @__PURE__ */ new Map();
1847
+ const unassignedChildren = [];
1848
+ rawChildren.forEach((child) => {
1849
+ var _a, _b, _c;
1850
+ const childProps = (_a = child.props) != null ? _a : {};
1851
+ const rawLayout = childProps.layout && typeof childProps.layout === "object" && !Array.isArray(childProps.layout) ? childProps.layout : {};
1852
+ const tabIdFromLayout = (_b = rawLayout.tabId) != null ? _b : childProps.__studioTabId;
1853
+ const resolvedTabId = resolveUIValue(tabIdFromLayout, runtime);
1854
+ const normalizedTabId = String(resolvedTabId != null ? resolvedTabId : "").trim();
1855
+ if (!normalizedTabId) {
1856
+ unassignedChildren.push(child);
1857
+ return;
1858
+ }
1859
+ const existing = (_c = childrenByTabId.get(normalizedTabId)) != null ? _c : [];
1860
+ existing.push(child);
1861
+ childrenByTabId.set(normalizedTabId, existing);
1862
+ });
1863
+ return tabItems.map((item, index) => {
1864
+ var _a, _b, _c, _d;
1865
+ const rawId = (_a = item.id) != null ? _a : `tab-${index + 1}`;
1866
+ const resolvedId = resolveUIValue(rawId, runtime);
1867
+ const normalizedId = String(
1868
+ resolvedId == null || String(resolvedId).trim().length === 0 ? rawId : resolvedId
1869
+ );
1870
+ const rawTitle = (_b = item.title) != null ? _b : item.label;
1871
+ const resolvedTitle = resolveUIValue(rawTitle, runtime);
1872
+ const normalizedTitle = (_c = resolvedTitle != null ? resolvedTitle : rawTitle) != null ? _c : `Tab ${index + 1}`;
1873
+ const mappedChildren = (_d = childrenByTabId.get(normalizedId)) != null ? _d : [];
1874
+ const fallbackChildren = index === 0 ? unassignedChildren : [];
1875
+ const contentNodes = [...mappedChildren, ...fallbackChildren];
1876
+ const contentFromChildren = contentNodes.length > 0 ? contentNodes.length === 1 ? renderChild(contentNodes[0]) : contentNodes.map((child) => renderChild(child)) : null;
1877
+ return __spreadProps(__spreadValues({}, item), {
1878
+ id: normalizedId,
1879
+ title: normalizedTitle,
1880
+ label: normalizedTitle,
1881
+ content: contentFromChildren != null ? contentFromChildren : normalizeRenderableChild2(item.content)
1882
+ });
1883
+ });
1884
+ };
1885
+ var resolveStudioTabsProps = ({
1886
+ componentProps,
1887
+ tabItems,
1888
+ rawChildren,
1889
+ runtime,
1890
+ renderChild,
1891
+ normalizeRenderableChild: normalizeRenderableChild2
1892
+ }) => {
1893
+ const normalizedProps = normalizeStudioTabsProps(componentProps);
1894
+ const resolvedTabs = resolveStudioTabsContent({
1895
+ tabItems: Array.isArray(normalizedProps.tabs) ? normalizedProps.tabs : tabItems,
1896
+ rawChildren,
1897
+ runtime,
1898
+ renderChild,
1899
+ normalizeRenderableChild: normalizeRenderableChild2
1900
+ });
1901
+ return {
1902
+ normalizedProps,
1903
+ resolvedTabs
1904
+ };
1905
+ };
1906
+
1907
+ // src/studio-bridge/preview-navigation/previewNavigationState.ts
1908
+ var findContainingNodeId = (targetNodeId, candidates, idResolver) => {
1909
+ const containsNode = (candidate) => {
1910
+ var _a;
1911
+ if (candidate.id === targetNodeId) return true;
1912
+ return ((_a = candidate.children) != null ? _a : []).some((nested) => containsNode(nested));
1913
+ };
1914
+ for (const candidate of candidates) {
1915
+ if (containsNode(candidate)) {
1916
+ return idResolver(candidate);
1917
+ }
1918
+ }
1919
+ return null;
1920
+ };
1921
+ var resolveAccordionOpenIds = ({
1922
+ itemIds,
1923
+ persistedOpenIds,
1924
+ selectedItemId,
1925
+ allowMultiple
1926
+ }) => {
1927
+ let effectiveOpenIds = persistedOpenIds.filter((id) => itemIds.includes(id));
1928
+ if (selectedItemId) {
1929
+ effectiveOpenIds = allowMultiple ? Array.from(/* @__PURE__ */ new Set([...effectiveOpenIds, selectedItemId])) : [selectedItemId];
1930
+ } else if (effectiveOpenIds.length === 0 && itemIds[0]) {
1931
+ effectiveOpenIds = [itemIds[0]];
1932
+ }
1933
+ return effectiveOpenIds;
1934
+ };
1935
+ var resolveStudioAccordionState = ({
1936
+ nodeId,
1937
+ accordionChildren,
1938
+ itemIds,
1939
+ selectedNodeId,
1940
+ accordionOpenIdsByNodeId,
1941
+ allowMultiple
1942
+ }) => {
1943
+ var _a;
1944
+ const validItemIds = new Set(itemIds);
1945
+ const persistedOpenIds = ((_a = accordionOpenIdsByNodeId[nodeId]) != null ? _a : []).filter(
1946
+ (id) => validItemIds.has(id)
1947
+ );
1948
+ const selectedItemId = selectedNodeId != null ? findContainingNodeId(
1949
+ selectedNodeId,
1950
+ accordionChildren,
1951
+ (candidate) => {
1952
+ var _a2, _b;
1953
+ return String((_b = ((_a2 = candidate.props) != null ? _a2 : {}).id) != null ? _b : candidate.id);
1954
+ }
1955
+ ) : null;
1956
+ const effectiveOpenIds = resolveAccordionOpenIds({
1957
+ itemIds,
1958
+ persistedOpenIds,
1959
+ selectedItemId,
1960
+ allowMultiple
1961
+ });
1962
+ return {
1963
+ validItemIds,
1964
+ effectiveOpenIds
1965
+ };
1966
+ };
1967
+ var resolveStudioExpandablePanelState = ({
1968
+ nodeId,
1969
+ expandablePanelOpenByNodeId
1970
+ }) => {
1971
+ var _a;
1972
+ return {
1973
+ controlledOpen: (_a = expandablePanelOpenByNodeId[nodeId]) != null ? _a : true,
1974
+ defaultOpen: true,
1975
+ disableAnimation: true
1976
+ };
1977
+ };
1978
+
1979
+ // src/studio-bridge/preview-navigation/previewNavigationConfigurators.tsx
1980
+ var configurePreviewAccordion = ({
1981
+ node,
1982
+ componentProps,
1983
+ accordionChildren,
1984
+ selectedNodeId,
1985
+ accordionOpenIdsByNodeId,
1986
+ setAccordionOpenIdsByNodeId,
1987
+ renderSafeNode: renderSafeNode2
1988
+ }) => {
1989
+ const items = buildAccordionItems(accordionChildren, renderSafeNode2);
1990
+ componentProps.items = items;
1991
+ const { validItemIds, effectiveOpenIds } = resolveStudioAccordionState({
1992
+ nodeId: node.id,
1993
+ accordionChildren,
1994
+ itemIds: items.map((item) => item.id),
1995
+ selectedNodeId,
1996
+ accordionOpenIdsByNodeId,
1997
+ allowMultiple: Boolean(componentProps.allowMultiple)
1998
+ });
1999
+ componentProps.openIds = effectiveOpenIds;
2000
+ componentProps.defaultOpenIds = effectiveOpenIds;
2001
+ componentProps.onOpenIdsChange = (nextOpenIds) => {
2002
+ setAccordionOpenIdsByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
2003
+ [node.id]: nextOpenIds.filter((id) => validItemIds.has(id))
2004
+ }));
2005
+ };
2006
+ };
2007
+ var configurePreviewExpandablePanel = ({
2008
+ node,
2009
+ componentProps,
2010
+ panelChildren,
2011
+ expandablePanelOpenByNodeId,
2012
+ setExpandablePanelOpenByNodeId,
2013
+ renderSafeNode: renderSafeNode2
2014
+ }) => {
2015
+ const { controlledOpen, defaultOpen, disableAnimation } = resolveStudioExpandablePanelState({
2016
+ nodeId: node.id,
2017
+ expandablePanelOpenByNodeId
2018
+ });
2019
+ componentProps.open = controlledOpen;
2020
+ componentProps.defaultOpen = defaultOpen;
2021
+ componentProps.disableAnimation = disableAnimation;
2022
+ componentProps.onOpenChange = (nextOpen) => {
2023
+ setExpandablePanelOpenByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
2024
+ [node.id]: Boolean(nextOpen)
2025
+ }));
2026
+ };
2027
+ const panelContent = buildExpandablePanelChildren(panelChildren, renderSafeNode2);
2028
+ if (panelContent) {
2029
+ componentProps.children = panelContent;
2030
+ }
2031
+ };
2032
+ var configurePreviewTabs = ({
2033
+ componentProps,
2034
+ tabItems,
2035
+ rawChildren,
2036
+ runtime,
2037
+ renderSafeNode: renderSafeNode2,
2038
+ normalizeRenderableChild: normalizeRenderableChild2
2039
+ }) => {
2040
+ const { normalizedProps, resolvedTabs } = resolveStudioTabsProps({
2041
+ componentProps,
2042
+ tabItems,
2043
+ rawChildren,
2044
+ runtime,
2045
+ renderChild: renderSafeNode2,
2046
+ normalizeRenderableChild: normalizeRenderableChild2
2047
+ });
2048
+ Object.assign(componentProps, normalizedProps);
2049
+ componentProps.tabs = resolvedTabs;
2050
+ delete componentProps.children;
2051
+ };
2052
+
2053
+ // src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
2054
+ import React2 from "react";
2055
+
2056
+ // src/studio-bridge/preview-wizard/previewWizardFormState.ts
2057
+ var resolveStudioWizardNextValues = ({
2058
+ rawWizardValues,
2059
+ fieldName,
2060
+ nextValue
2061
+ }) => __spreadProps(__spreadValues({}, rawWizardValues), {
2062
+ [fieldName]: nextValue
2063
+ });
2064
+ var resolveStudioWizardActiveStepFields = ({
2065
+ stepId,
2066
+ stepIdToNode
2067
+ }) => {
2068
+ var _a;
2069
+ const activeStepNode = stepIdToNode[stepId];
2070
+ return ((_a = activeStepNode == null ? void 0 : activeStepNode.children) != null ? _a : []).filter((child) => child.type === "FormField").map((child) => {
2071
+ var _a2;
2072
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
2073
+ const childFieldObj = childProps.field && typeof childProps.field === "object" && !Array.isArray(childProps.field) ? childProps.field : {};
2074
+ return buildWizardFieldConfig(childProps, childFieldObj);
2075
+ }).filter((field) => {
2076
+ var _a2;
2077
+ return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
2078
+ });
2079
+ };
2080
+ var resolveStudioWizardNextErrors = ({
2081
+ currentWizardErrors,
2082
+ activeStepFields,
2083
+ nextValues,
2084
+ runtime
2085
+ }) => {
2086
+ const validation = validateFormValues(activeStepFields, nextValues, {
2087
+ t: runtime.t,
2088
+ useLegacyFieldConstraints: true
2089
+ });
2090
+ const activeStepFieldNames = new Set(
2091
+ activeStepFields.map((field) => {
2092
+ var _a;
2093
+ return String((_a = field.name) != null ? _a : "").trim();
2094
+ }).filter(Boolean)
2095
+ );
2096
+ const nextErrors = Object.entries(currentWizardErrors).reduce(
2097
+ (accumulator, [key, value]) => {
2098
+ if (activeStepFieldNames.has(key)) return accumulator;
2099
+ accumulator[key] = value;
2100
+ return accumulator;
2101
+ },
2102
+ {}
2103
+ );
2104
+ Object.entries(validation.errors).forEach(([key, value]) => {
2105
+ if (!value) return;
2106
+ nextErrors[key] = value;
2107
+ });
2108
+ return nextErrors;
2109
+ };
2110
+ var patchStudioWizardFieldNode = ({
2111
+ nested,
2112
+ rawWizardValues,
2113
+ currentWizardErrors,
2114
+ fieldOnChange
2115
+ }) => {
2116
+ var _a, _b, _c, _d, _e;
2117
+ const nestedProps = (_a = nested.props) != null ? _a : {};
2118
+ const fieldObj = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
2119
+ const fieldName = String((_c = (_b = nestedProps.name) != null ? _b : fieldObj.name) != null ? _c : "").trim();
2120
+ const fieldConfig = __spreadProps(__spreadValues(__spreadValues({}, fieldObj), nestedProps), {
2121
+ name: fieldName,
2122
+ label: String((_e = (_d = nestedProps.label) != null ? _d : fieldObj.label) != null ? _e : fieldName || "Field")
2123
+ });
2124
+ const patchedNode = __spreadProps(__spreadValues({}, nested), {
2125
+ props: __spreadProps(__spreadValues({}, nestedProps), {
2126
+ layout: (() => {
2127
+ var _a2;
2128
+ const rawLayout = nestedProps.layout && typeof nestedProps.layout === "object" && !Array.isArray(nestedProps.layout) ? __spreadValues({}, nestedProps.layout) : {};
2129
+ const existingWrapperClassName = String((_a2 = rawLayout.wrapperClassName) != null ? _a2 : "").trim();
2130
+ rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
2131
+ delete rawLayout.widthPct;
2132
+ delete rawLayout.heightPct;
2133
+ delete rawLayout.heightPx;
2134
+ return rawLayout;
2135
+ })(),
2136
+ field: fieldConfig,
2137
+ value: fieldName ? rawWizardValues[fieldName] : void 0,
2138
+ error: fieldName ? currentWizardErrors[fieldName] : void 0,
2139
+ onChange: fieldOnChange
2140
+ })
2141
+ });
2142
+ const nestedLayout = readNodeLayout(nestedProps);
2143
+ const fieldBasis = nestedLayout.widthPct !== null ? `${nestedLayout.widthPct}%` : "100%";
2144
+ return {
2145
+ patchedNode,
2146
+ fieldBasis
2147
+ };
2148
+ };
2149
+
2150
+ // src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
2151
+ var renderStudioWizardStepContent = ({
2152
+ step,
2153
+ nodeId,
2154
+ existingFormConfig,
2155
+ rawWizardValues,
2156
+ stepIdToNode,
2157
+ runtime,
2158
+ renderSafeNode: renderSafeNode2,
2159
+ captureFieldFocus,
2160
+ onInlineTextEdit
2161
+ }) => {
2162
+ if (step.contentType === "content") {
2163
+ if (step.contentNode) {
2164
+ return renderSafeNode2(step.contentNode);
2165
+ }
2166
+ return step.contentValue;
2167
+ }
2168
+ if (step.stepRenderableContent.length === 0) {
2169
+ return step.contentValue;
2170
+ }
2171
+ return React2.createElement(
2172
+ "div",
2173
+ { className: "flex flex-wrap items-start gap-x-3 gap-y-3" },
2174
+ step.stepRenderableContent.map((nested) => {
2175
+ if (nested.type !== "FormField") {
2176
+ return React2.createElement(
2177
+ "div",
2178
+ { key: nested.id, className: "basis-full" },
2179
+ renderSafeNode2(nested)
2180
+ );
2181
+ }
2182
+ const currentWizardErrors = existingFormConfig.errors && typeof existingFormConfig.errors === "object" && !Array.isArray(existingFormConfig.errors) ? existingFormConfig.errors : {};
2183
+ const { patchedNode, fieldBasis } = patchStudioWizardFieldNode({
2184
+ nested,
2185
+ rawWizardValues,
2186
+ currentWizardErrors,
2187
+ fieldOnChange: (event) => {
2188
+ var _a;
2189
+ captureFieldFocus(event.target);
2190
+ const nextFieldName = String((_a = event.target.name) != null ? _a : "").trim();
2191
+ if (!nextFieldName) return;
2192
+ const target = event.target;
2193
+ const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
2194
+ const nextValues = resolveStudioWizardNextValues({
2195
+ rawWizardValues,
2196
+ fieldName: nextFieldName,
2197
+ nextValue
2198
+ });
2199
+ const activeStepFields = resolveStudioWizardActiveStepFields({
2200
+ stepId: step.id,
2201
+ stepIdToNode
2202
+ });
2203
+ const nextErrors = resolveStudioWizardNextErrors({
2204
+ currentWizardErrors,
2205
+ activeStepFields,
2206
+ nextValues,
2207
+ runtime
2208
+ });
2209
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.values", nextValues);
2210
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.errors", nextErrors);
2211
+ }
2212
+ });
2213
+ return React2.createElement(
2214
+ "div",
2215
+ {
2216
+ key: nested.id,
2217
+ className: "min-w-0",
2218
+ style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }
2219
+ },
2220
+ renderSafeNode2(patchedNode)
2221
+ );
2222
+ })
2223
+ );
2224
+ };
2225
+ var materializeStudioWizardSteps = ({
2226
+ nodeId,
2227
+ currentSteps,
2228
+ existingFormConfig,
2229
+ rawWizardValues,
2230
+ stepIdToNode,
2231
+ runtime,
2232
+ renderSafeNode: renderSafeNode2,
2233
+ captureFieldFocus,
2234
+ onInlineTextEdit
2235
+ }) => currentSteps.map((step) => ({
2236
+ id: step.id,
2237
+ title: step.title,
2238
+ description: step.description,
2239
+ titleNode: step.titleNode ? renderSafeNode2(step.titleNode) : void 0,
2240
+ descriptionNode: step.descriptionNode ? renderSafeNode2(step.descriptionNode) : void 0,
2241
+ isValid: step.isValid,
2242
+ content: renderStudioWizardStepContent({
2243
+ step,
2244
+ nodeId,
2245
+ currentSteps,
2246
+ existingFormConfig,
2247
+ rawWizardValues,
2248
+ stepIdToNode,
2249
+ runtime,
2250
+ renderSafeNode: renderSafeNode2,
2251
+ captureFieldFocus,
2252
+ onInlineTextEdit
2253
+ })
2254
+ }));
2255
+
2256
+ // src/studio-bridge/preview-wizard/wizardEditingHandlers.ts
2257
+ var findWizardStepRoleNode = (stepNode, role) => {
2258
+ var _a;
2259
+ const nestedChildren = Array.isArray(stepNode.children) ? stepNode.children : [];
2260
+ return (_a = nestedChildren.find((child) => {
2261
+ var _a2, _b;
2262
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
2263
+ return String((_b = getLayoutRecord(childProps).wizardStepRole) != null ? _b : "").trim() === role;
2264
+ })) != null ? _a : null;
2265
+ };
2266
+ var createStudioWizardOnStepChange = ({
2267
+ nodeId,
2268
+ stepIdToNode,
2269
+ setWizardActiveStepByNodeId,
2270
+ existingOnStepChange,
2271
+ onNodeClick
2272
+ }) => {
2273
+ return (stepId) => {
2274
+ setWizardActiveStepByNodeId((previous) => {
2275
+ if (previous[nodeId] === stepId) return previous;
2276
+ return __spreadProps(__spreadValues({}, previous), {
2277
+ [nodeId]: stepId
2278
+ });
2279
+ });
2280
+ if (typeof existingOnStepChange === "function") {
2281
+ existingOnStepChange(stepId);
2282
+ }
2283
+ const stepNode = stepIdToNode[stepId];
2284
+ if (stepNode && onNodeClick) {
2285
+ onNodeClick(stepNode.id);
2286
+ }
2287
+ };
2288
+ };
2289
+ var attachStudioWizardEditingHandlers = ({
2290
+ studioConfig,
2291
+ node,
2292
+ stepIdToNode,
2293
+ openInlineEditorForNodeProp
2294
+ }) => {
2295
+ studioConfig.onStepTitleDoubleClick = (stepId) => {
2296
+ var _a, _b, _c, _d, _e;
2297
+ const stepNode = stepIdToNode[stepId];
2298
+ if (!stepNode) return;
2299
+ const stepProps = (_a = stepNode.props) != null ? _a : {};
2300
+ const titleNode = findWizardStepRoleNode(stepNode, "title");
2301
+ if (titleNode) {
2302
+ const titleNodeProps = (_b = titleNode.props) != null ? _b : {};
2303
+ openInlineEditorForNodeProp(
2304
+ titleNode.id,
2305
+ "children",
2306
+ (_d = (_c = titleNodeProps.children) != null ? _c : stepProps.title) != null ? _d : stepId
2307
+ );
2308
+ return;
2309
+ }
2310
+ openInlineEditorForNodeProp(stepNode.id, "title", (_e = stepProps.title) != null ? _e : stepId);
2311
+ };
2312
+ studioConfig.onStepDescriptionDoubleClick = (stepId) => {
2313
+ var _a, _b, _c, _d, _e;
2314
+ const stepNode = stepIdToNode[stepId];
2315
+ if (!stepNode) return;
2316
+ const stepProps = (_a = stepNode.props) != null ? _a : {};
2317
+ const descriptionNode = findWizardStepRoleNode(stepNode, "description");
2318
+ if (descriptionNode) {
2319
+ const descriptionNodeProps = (_b = descriptionNode.props) != null ? _b : {};
2320
+ openInlineEditorForNodeProp(
2321
+ descriptionNode.id,
2322
+ "children",
2323
+ (_d = (_c = descriptionNodeProps.children) != null ? _c : stepProps.description) != null ? _d : ""
2324
+ );
2325
+ return;
2326
+ }
2327
+ openInlineEditorForNodeProp(stepNode.id, "description", (_e = stepProps.description) != null ? _e : "");
2328
+ };
2329
+ studioConfig.onBackLabelDoubleClick = () => {
2330
+ var _a, _b, _c;
2331
+ return openInlineEditorForNodeProp(
2332
+ node.id,
2333
+ "labels.back",
2334
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.back) != null ? _c : "Back"
2335
+ );
2336
+ };
2337
+ studioConfig.onNextLabelDoubleClick = () => {
2338
+ var _a, _b, _c;
2339
+ return openInlineEditorForNodeProp(
2340
+ node.id,
2341
+ "labels.next",
2342
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.next) != null ? _c : "Next"
2343
+ );
2344
+ };
2345
+ studioConfig.onFinishLabelDoubleClick = () => {
2346
+ var _a, _b, _c;
2347
+ return openInlineEditorForNodeProp(
2348
+ node.id,
2349
+ "labels.finish",
2350
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.finish) != null ? _c : "Finish"
2351
+ );
2352
+ };
2353
+ return studioConfig;
2354
+ };
2355
+
2356
+ // src/utils/wizardStudio.ts
2357
+ var getWizardStepRole = (node) => {
2358
+ var _a, _b;
2359
+ const props = (_a = node.props) != null ? _a : {};
2360
+ const layout = getLayoutRecord(props);
2361
+ return String((_b = layout.wizardStepRole) != null ? _b : "").trim();
2362
+ };
2363
+ var getWizardRenderableChildren = (nodes) => nodes.filter((nested) => {
2364
+ const stepRole = getWizardStepRole(nested);
2365
+ return stepRole !== "title" && stepRole !== "description";
2366
+ });
2367
+ var findSelectedWizardStepId = (stepChildren, selectedNodeId) => {
2368
+ var _a, _b, _c;
2369
+ if (!selectedNodeId) return null;
2370
+ const selectedStep = stepChildren.find((stepChild) => {
2371
+ var _a2;
2372
+ if (stepChild.id === selectedNodeId) return true;
2373
+ return ((_a2 = stepChild.children) != null ? _a2 : []).some((nested) => {
2374
+ const stepRole = getWizardStepRole(nested);
2375
+ return nested.id === selectedNodeId && (stepRole === "title" || stepRole === "description");
2376
+ });
2377
+ });
2378
+ if (!selectedStep) return null;
2379
+ const stepProps = (_a = selectedStep.props) != null ? _a : {};
2380
+ return String((_c = (_b = stepProps.id) != null ? _b : selectedStep.id) != null ? _c : "").trim() || null;
2381
+ };
2382
+ var buildFieldsByStep = (stepIdToNode, currentSteps) => currentSteps.reduce((accumulator, step) => {
2383
+ var _a, _b;
2384
+ const stepId = String((_a = step.id) != null ? _a : "").trim();
2385
+ if (!stepId) return accumulator;
2386
+ const stepNode = stepIdToNode[stepId];
2387
+ const stepRenderableChildren = getWizardRenderableChildren((_b = stepNode == null ? void 0 : stepNode.children) != null ? _b : []);
2388
+ const fields = stepRenderableChildren.filter((nested) => nested.type === "FormField").map((nested) => {
2389
+ var _a2;
2390
+ const nestedProps = (_a2 = nested.props) != null ? _a2 : {};
2391
+ const nestedField = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
2392
+ return buildWizardFieldConfig(nestedProps, nestedField);
2393
+ }).filter((field) => {
2394
+ var _a2;
2395
+ return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
2396
+ });
2397
+ accumulator[stepId] = fields;
2398
+ return accumulator;
2399
+ }, {});
2400
+ var resolveActiveWizardStepId = ({
2401
+ selectedStepId,
2402
+ stepIds,
2403
+ activeStepFromProps,
2404
+ activeStepFromMemory
2405
+ }) => {
2406
+ var _a;
2407
+ if (selectedStepId && stepIds.includes(selectedStepId)) return selectedStepId;
2408
+ if (activeStepFromProps && stepIds.includes(activeStepFromProps)) {
2409
+ return activeStepFromProps;
2410
+ }
2411
+ if (activeStepFromMemory && stepIds.includes(activeStepFromMemory)) {
2412
+ return activeStepFromMemory;
2413
+ }
2414
+ return (_a = stepIds[0]) != null ? _a : "";
2415
+ };
2416
+ var validateWizardStepFields = ({
2417
+ stepRenderableContent,
2418
+ values,
2419
+ runtime
2420
+ }) => {
2421
+ const normalizedFields = stepRenderableContent.filter((nested) => nested.type === "FormField").map((nested) => {
2422
+ var _a;
2423
+ const nestedProps = (_a = nested.props) != null ? _a : {};
2424
+ const fieldObject = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
2425
+ return buildWizardFieldConfig(nestedProps, fieldObject);
2426
+ });
2427
+ const filteredFields = normalizedFields.filter((field) => field.name.length > 0);
2428
+ const validation = validateFormValues(filteredFields, values, {
2429
+ t: runtime.t,
2430
+ useLegacyFieldConstraints: true
2431
+ });
2432
+ return validation.issues.length === 0;
2433
+ };
2434
+
2435
+ // src/studio-bridge/preview-wizard/previewWizardStructure.ts
2436
+ var resolveStudioWizardStructure = ({
2437
+ node,
2438
+ componentProps,
2439
+ selectedNodeId,
2440
+ wizardActiveStepByNodeId,
2441
+ runtime,
2442
+ internalStudioNodeTypes
2443
+ }) => {
2444
+ var _a, _b, _c, _d, _e, _f;
2445
+ const existingFormConfig = componentProps.form && typeof componentProps.form === "object" && !Array.isArray(componentProps.form) ? __spreadValues({}, componentProps.form) : {};
2446
+ const existingStudioConfig = componentProps.studio && typeof componentProps.studio === "object" && !Array.isArray(componentProps.studio) ? __spreadValues({}, componentProps.studio) : {};
2447
+ const stepChildren = ((_a = node.children) != null ? _a : []).filter((child) => {
2448
+ var _a2;
2449
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
2450
+ const layout = getLayoutRecord(childProps);
2451
+ const isWizardStepFlag = layout.wizardStep === true;
2452
+ const isSupportedStepType = child.type === "Container" || child.type === "StepForm";
2453
+ return isSupportedStepType && isWizardStepFlag;
2454
+ });
2455
+ const stepIdToNode = stepChildren.reduce(
2456
+ (accumulator, stepChild) => {
2457
+ var _a2, _b2, _c2;
2458
+ const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
2459
+ const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim();
2460
+ const fallbackId = String((_c2 = stepChild.id) != null ? _c2 : "").trim();
2461
+ if (stepId) accumulator[stepId] = stepChild;
2462
+ if (fallbackId) accumulator[fallbackId] = stepChild;
2463
+ return accumulator;
2464
+ },
2465
+ {}
2466
+ );
2467
+ const selectedStepId = findSelectedWizardStepId(stepChildren, selectedNodeId);
2468
+ const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
2469
+ const currentSteps = stepChildren.map((stepChild) => {
2470
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k;
2471
+ const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
2472
+ const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim() || stepChild.id;
2473
+ const stepContent = ((_c2 = stepChild.children) != null ? _c2 : []).filter(
2474
+ (nested) => !internalStudioNodeTypes.has(nested.type)
2475
+ );
2476
+ const stepTitleNode = stepContent.find(
2477
+ (nested) => {
2478
+ var _a3, _b3;
2479
+ return String(
2480
+ (_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
2481
+ ).trim() === "title";
2482
+ }
2483
+ );
2484
+ const stepDescriptionNode = stepContent.find(
2485
+ (nested) => {
2486
+ var _a3, _b3;
2487
+ return String(
2488
+ (_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
2489
+ ).trim() === "description";
2490
+ }
2491
+ );
2492
+ const stepTitleNodeValue = (_d2 = stepTitleNode == null ? void 0 : stepTitleNode.props) == null ? void 0 : _d2.children;
2493
+ const stepDescriptionNodeValue = (_e2 = stepDescriptionNode == null ? void 0 : stepDescriptionNode.props) == null ? void 0 : _e2.children;
2494
+ const title = resolveUIValue((_f2 = stepTitleNodeValue != null ? stepTitleNodeValue : stepProps.title) != null ? _f2 : stepId, runtime);
2495
+ const description = resolveUIValue((_g = stepDescriptionNodeValue != null ? stepDescriptionNodeValue : stepProps.description) != null ? _g : "", runtime);
2496
+ const rawContentType = String((_h = stepProps.contentType) != null ? _h : "content");
2497
+ const stepRenderableContent = getWizardRenderableChildren(stepContent);
2498
+ const hasFieldChildren = stepRenderableContent.some((nested) => {
2499
+ var _a3, _b3;
2500
+ if (nested.type !== "FormField") return false;
2501
+ const nestedProps = (_a3 = nested.props) != null ? _a3 : {};
2502
+ return String((_b3 = getLayoutRecord(nestedProps).formRole) != null ? _b3 : "field").trim() === "field";
2503
+ });
2504
+ const contentType = hasFieldChildren ? "form" : rawContentType;
2505
+ const isValid = !hasFieldChildren ? stepProps.isValid !== false : validateWizardStepFields({
2506
+ stepRenderableContent,
2507
+ values: rawWizardValues,
2508
+ runtime
2509
+ });
2510
+ const explicitContentNode = stepRenderableContent.find(
2511
+ (nested) => {
2512
+ var _a3;
2513
+ return getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardContent === true;
2514
+ }
2515
+ );
2516
+ const contentNode = explicitContentNode != null ? explicitContentNode : contentType === "content" ? stepRenderableContent[0] : void 0;
2517
+ return {
2518
+ id: stepId,
2519
+ title,
2520
+ description,
2521
+ titleNode: stepTitleNode,
2522
+ descriptionNode: stepDescriptionNode,
2523
+ contentNode,
2524
+ isValid,
2525
+ contentType,
2526
+ stepRenderableContent,
2527
+ contentValue: contentType === "content" ? resolveUIValue(
2528
+ (_k = (_j = (_i = contentNode == null ? void 0 : contentNode.props) == null ? void 0 : _i.children) != null ? _j : stepProps.content) != null ? _k : title,
2529
+ runtime
2530
+ ) : null
2531
+ };
2532
+ });
2533
+ const normalizedFieldsByStep = buildFieldsByStep(
2534
+ stepIdToNode,
2535
+ currentSteps
2536
+ );
2537
+ const stepIds = currentSteps.map((step) => step.id).filter(Boolean);
2538
+ const activeStepFromMemory = String((_b = wizardActiveStepByNodeId[node.id]) != null ? _b : "").trim();
2539
+ const activeStepFromProps = String(
2540
+ (_f = (_e = (_c = node.props) == null ? void 0 : _c.activeStepId) != null ? _e : (_d = node.props) == null ? void 0 : _d.initialStepId) != null ? _f : ""
2541
+ ).trim();
2542
+ const resolvedActiveStepId = resolveActiveWizardStepId({
2543
+ selectedStepId,
2544
+ stepIds,
2545
+ activeStepFromProps,
2546
+ activeStepFromMemory
2547
+ });
2548
+ return {
2549
+ stepChildren,
2550
+ stepIdToNode,
2551
+ selectedStepId,
2552
+ currentSteps,
2553
+ normalizedFieldsByStep,
2554
+ resolvedActiveStepId,
2555
+ existingFormConfig,
2556
+ existingStudioConfig
2557
+ };
2558
+ };
2559
+
2560
+ // src/studio-bridge/preview-wizard/previewWizardConfigurator.ts
2561
+ var configurePreviewFormWizard = ({
2562
+ node,
2563
+ componentProps,
2564
+ isStudioRendererContext,
2565
+ selectedNodeId,
2566
+ wizardActiveStepByNodeId,
2567
+ runtime,
2568
+ setWizardActiveStepByNodeId,
2569
+ onNodeClick,
2570
+ onInlineTextEdit,
2571
+ renderSafeNode: renderSafeNode2,
2572
+ captureFieldFocus,
2573
+ openInlineEditorForNodeProp,
2574
+ internalStudioNodeTypes
2575
+ }) => {
2576
+ var _a;
2577
+ if (isStudioRendererContext) {
2578
+ const existingClassName = String((_a = componentProps.className) != null ? _a : "").trim();
2579
+ componentProps.className = [
2580
+ existingClassName,
2581
+ "w-full",
2582
+ "[&_[data-step-form-wrapper]>section]:max-w-full",
2583
+ "[&_[data-step-form-wrapper]>section]:mx-0"
2584
+ ].filter(Boolean).join(" ");
2585
+ }
2586
+ const {
2587
+ existingFormConfig,
2588
+ existingStudioConfig,
2589
+ currentSteps,
2590
+ normalizedFieldsByStep,
2591
+ resolvedActiveStepId,
2592
+ stepIdToNode
2593
+ } = resolveStudioWizardStructure({
2594
+ node,
2595
+ componentProps,
2596
+ selectedNodeId,
2597
+ wizardActiveStepByNodeId,
2598
+ runtime,
2599
+ internalStudioNodeTypes
2600
+ });
2601
+ const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
2602
+ const materializedSteps = materializeStudioWizardSteps({
2603
+ nodeId: node.id,
2604
+ currentSteps,
2605
+ existingFormConfig,
2606
+ rawWizardValues,
2607
+ stepIdToNode,
2608
+ runtime,
2609
+ renderSafeNode: renderSafeNode2,
2610
+ captureFieldFocus,
2611
+ onInlineTextEdit
2612
+ });
2613
+ if (materializedSteps.length > 0) {
2614
+ componentProps.steps = materializedSteps;
2615
+ }
2616
+ existingFormConfig.fieldsByStep = normalizedFieldsByStep;
2617
+ if (resolvedActiveStepId) {
2618
+ componentProps.activeStepId = resolvedActiveStepId;
2619
+ }
2620
+ componentProps.onStepChange = createStudioWizardOnStepChange({
2621
+ nodeId: node.id,
2622
+ stepIdToNode,
2623
+ setWizardActiveStepByNodeId,
2624
+ existingOnStepChange: componentProps.onStepChange,
2625
+ onNodeClick
2626
+ });
2627
+ attachStudioWizardEditingHandlers({
2628
+ studioConfig: existingStudioConfig,
2629
+ node,
2630
+ stepIdToNode,
2631
+ openInlineEditorForNodeProp
2632
+ });
2633
+ componentProps.form = isStudioRendererContext ? void 0 : existingFormConfig;
2634
+ componentProps.studio = existingStudioConfig;
2635
+ };
2636
+
2637
+ // src/utils/nodeResetToken.ts
2638
+ import { buildNodeResetToken } from "@arkcit/engine-react";
2639
+
2640
+ // src/studio-bridge/overlay/renderSafeNode.tsx
2641
+ import { jsx as jsx6 } from "react/jsx-runtime";
2642
+ var FallbackInlineTextEditor = ({
2643
+ editing,
2644
+ onChange,
2645
+ onCancel,
2646
+ onCommit
2647
+ }) => editing.multiline ? /* @__PURE__ */ jsx6(
2648
+ "textarea",
2649
+ {
2650
+ style: editing.editorStyle,
2651
+ value: editing.value,
2652
+ autoFocus: true,
2653
+ "aria-label": "Inline text editor",
2654
+ onChange: (event) => onChange(event.target.value),
2655
+ onBlur: onCommit,
2656
+ onKeyDown: (event) => {
2657
+ if (event.key === "Escape") {
2658
+ event.preventDefault();
2659
+ onCancel();
2660
+ return;
2661
+ }
2662
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
2663
+ event.preventDefault();
2664
+ onCommit();
2665
+ }
2666
+ }
2667
+ }
2668
+ ) : /* @__PURE__ */ jsx6(
2669
+ "input",
2670
+ {
2671
+ style: editing.editorStyle,
2672
+ value: editing.value,
2673
+ autoFocus: true,
2674
+ "aria-label": "Inline text editor",
2675
+ onChange: (event) => onChange(event.target.value),
2676
+ onBlur: onCommit,
2677
+ onKeyDown: (event) => {
2678
+ if (event.key === "Escape") {
2679
+ event.preventDefault();
2680
+ onCancel();
2681
+ return;
2682
+ }
2683
+ if (event.key === "Enter") {
2684
+ event.preventDefault();
2685
+ onCommit();
2686
+ }
2687
+ }
2688
+ }
2689
+ );
2690
+ var renderSafeNode = ({
2691
+ node,
2692
+ registry,
2693
+ runtime,
2694
+ schemaNodes,
2695
+ renderNode,
2696
+ isStudioRendererContext,
2697
+ overlaysByNodeId,
2698
+ selectedNodeId,
2699
+ onNodeClick,
2700
+ onInlineTextEdit,
2701
+ onNodeResize,
2702
+ onNodeResizeStart,
2703
+ onNodeResizeEnd,
2704
+ inlineEditing,
2705
+ setInlineEditing,
2706
+ ancestorTypeMembership,
2707
+ resizeStateRef,
2708
+ pinchStateRef,
2709
+ minWidthPct,
2710
+ minHeightPct,
2711
+ minHeightPx,
2712
+ overlayRootId,
2713
+ NodeWrapper,
2714
+ InlineTextEditorComponent,
2715
+ isFormInteractiveTarget
2716
+ }) => {
2717
+ var _a, _b, _c, _d, _e, _f, _g;
2718
+ const nodeProps = (_a = node.props) != null ? _a : {};
2719
+ const nodeLayout = readNodeLayout(nodeProps);
2720
+ const wrapperClassName = (_b = nodeLayout.wrapperClassName) != null ? _b : "";
2721
+ const resetToken = buildNodeResetToken(node);
2722
+ const widthPct = (_c = nodeLayout.widthPct) != null ? _c : null;
2723
+ const heightPct = (_d = nodeLayout.heightPct) != null ? _d : null;
2724
+ const heightPx = (_e = nodeLayout.heightPx) != null ? _e : null;
2725
+ const isOpenStudioOverlayNode = isStudioRendererContext && getOpenStudioOverlayState({
2726
+ node,
2727
+ nodeProps,
2728
+ overlaysByNodeId
2729
+ });
2730
+ const shouldForceFullWidth = shouldForceStudioNodeFullWidth({
2731
+ widthPct,
2732
+ nodeType: node.type,
2733
+ isStudioRendererContext,
2734
+ colSpan: nodeLayout.colSpan
2735
+ });
2736
+ const enableEventOnClick = toBoolean(nodeProps.buttonEnableEventOnClick);
2737
+ const nodeRegistryMeta = (_f = registry[node.type]) == null ? void 0 : _f.meta;
2738
+ const editableTextProps = ((_g = nodeRegistryMeta == null ? void 0 : nodeRegistryMeta.editableTextProps) != null ? _g : []).filter(
2739
+ (propName) => propName !== "className"
2740
+ );
2741
+ const { getTextValue, effectiveCandidateInlineProp } = resolveInlineEditingTarget({
2742
+ node,
2743
+ nodeProps,
2744
+ runtime,
2745
+ editableTextProps,
2746
+ resolveTranslationValue: resolveUIValue
2747
+ });
2748
+ const isInlineEditingNode = (inlineEditing == null ? void 0 : inlineEditing.nodeId) === node.id;
2749
+ const nodeContent = /* @__PURE__ */ jsx6(NodeErrorBoundary, { nodeId: node.id, nodeType: node.type, resetToken, children: renderNode(node, { widthPct, heightPct, heightPx }) }, node.id);
2750
+ const commitInlineEditing = () => {
2751
+ if (!inlineEditing) return;
2752
+ applyInlineEditingValue({
2753
+ editingState: inlineEditing,
2754
+ rawValue: inlineEditing.value,
2755
+ schemaNodes,
2756
+ onInlineTextEdit,
2757
+ findNodeById
2758
+ });
2759
+ setInlineEditing(null);
2760
+ };
2761
+ const InlineEditorComponent = InlineTextEditorComponent != null ? InlineTextEditorComponent : FallbackInlineTextEditor;
2762
+ const inlineEditor = isInlineEditingNode && inlineEditing ? /* @__PURE__ */ jsx6(
2763
+ InlineEditorComponent,
2764
+ {
2765
+ editing: inlineEditing,
2766
+ onChange: (value) => setInlineEditing((previous) => {
2767
+ if (!previous) return previous;
2768
+ return __spreadProps(__spreadValues({}, previous), {
2769
+ value
2770
+ });
2771
+ }),
2772
+ onCancel: () => setInlineEditing(null),
2773
+ onCommit: commitInlineEditing
2774
+ }
2775
+ ) : null;
2776
+ return renderNodeFrame({
2777
+ node,
2778
+ nodeProps,
2779
+ nodeContent,
2780
+ selectedNodeId,
2781
+ onNodeClick,
2782
+ onInlineTextEdit,
2783
+ onNodeResize,
2784
+ onNodeResizeStart,
2785
+ onNodeResizeEnd,
2786
+ widthPct,
2787
+ heightPct,
2788
+ heightPx,
2789
+ wrapperClassName,
2790
+ isOpenStudioOverlayNode,
2791
+ shouldForceFullWidth,
2792
+ effectiveCandidateInlineProp,
2793
+ inlineEditing,
2794
+ isInlineEditingNode,
2795
+ ancestorTypeMembership,
2796
+ schemaNodes,
2797
+ runtime,
2798
+ enableEventOnClick,
2799
+ isFormInteractiveTarget,
2800
+ getTextValue,
2801
+ setInlineEditing,
2802
+ inlineEditor,
2803
+ NodeWrapper,
2804
+ overlaysByNodeId,
2805
+ getOpenStudioOverlayState,
2806
+ resizeStateRef,
2807
+ pinchStateRef,
2808
+ minWidthPct,
2809
+ minHeightPct,
2810
+ minHeightPx,
2811
+ overlayRootId
2812
+ });
2813
+ };
2814
+
2815
+ // src/react-web/hooks/useUIEngineEffects.ts
2816
+ import { useUIEngineEffects as useUIEngineEffectsImpl } from "@arkcit/engine-react";
2817
+
2818
+ // src/react-web/previewLinkBehavior.ts
2819
+ import { configurePreviewLinkBehavior } from "@arkcit/engine-react";
2820
+
2821
+ // src/react-web/materializeBoundTable.tsx
2822
+ import { materializeBoundTable } from "@arkcit/engine-react";
2823
+
2824
+ // src/renderers/preview/renderStudioForm.tsx
2825
+ var renderStudioForm = materializePreviewForm;
2826
+
2827
+ // src/renderers/preview/configureStudioFormWizard.tsx
2828
+ var configureStudioFormWizard = configurePreviewFormWizard;
2829
+
2830
+ // src/renderers/studio/configureStudioNavigation.tsx
2831
+ var configureStudioAccordion = configurePreviewAccordion;
2832
+ var configureStudioExpandablePanel = configurePreviewExpandablePanel;
2833
+ var configureStudioTabs = configurePreviewTabs;
2834
+
2835
+ // src/utils/contentStudio.tsx
2836
+ import {
2837
+ buildCoverContent,
2838
+ buildCoverMedia,
2839
+ buildScrollRevealChildren
2840
+ } from "@arkcit/engine-react";
2841
+
2842
+ // src/utils/dataBinding.ts
2843
+ var applyRowsAndColumnsBinding = ({
2844
+ componentProps,
2845
+ runtime,
2846
+ rowsBindingKey,
2847
+ columnsBindingKey
2848
+ }) => {
2849
+ if (rowsBindingKey && columnsBindingKey) {
2850
+ const boundRows = runtime.get(rowsBindingKey);
2851
+ if (Array.isArray(boundRows)) {
2852
+ componentProps.rows = boundRows;
2853
+ }
2854
+ const boundColumns = runtime.get(columnsBindingKey);
2855
+ if (Array.isArray(boundColumns)) {
2856
+ componentProps.columns = boundColumns;
2857
+ }
2858
+ }
2859
+ };
2860
+ var filterRowsByRuntimeQuery = ({
2861
+ nodeId,
2862
+ componentProps,
2863
+ runtime
2864
+ }) => {
2865
+ var _a, _b;
2866
+ const tableQueriesRaw = runtime.get("table.queriesByNodeId");
2867
+ const tableQueries = tableQueriesRaw && typeof tableQueriesRaw === "object" ? tableQueriesRaw : {};
2868
+ const queryRaw = String((_b = (_a = tableQueries[nodeId]) != null ? _a : tableQueries.__all__) != null ? _b : "").trim().toLowerCase();
2869
+ if (queryRaw.length === 0) return;
2870
+ const rows = Array.isArray(componentProps.rows) ? componentProps.rows : [];
2871
+ const columns = Array.isArray(componentProps.columns) ? componentProps.columns : [];
2872
+ const filteredRows = rows.filter((row) => {
2873
+ if (columns.length > 0) {
2874
+ return columns.some((column) => {
2875
+ var _a2, _b2;
2876
+ const key = String((_a2 = column.key) != null ? _a2 : "").trim();
2877
+ if (!key) return false;
2878
+ return String((_b2 = row[key]) != null ? _b2 : "").toLowerCase().includes(queryRaw);
2879
+ });
2880
+ }
2881
+ return Object.values(row).some(
2882
+ (value) => String(value != null ? value : "").toLowerCase().includes(queryRaw)
2883
+ );
2884
+ });
2885
+ componentProps.rows = filteredRows;
2886
+ };
2887
+ var applyObjectBinding = ({
2888
+ componentProps,
2889
+ runtime,
2890
+ bindingKey
2891
+ }) => {
2892
+ if (!bindingKey) return;
2893
+ const boundObject = runtime.get(bindingKey);
2894
+ if (boundObject && typeof boundObject === "object" && !Array.isArray(boundObject)) {
2895
+ Object.assign(componentProps, boundObject);
2896
+ }
2897
+ };
2898
+ var applyDecodeTranslationBinding = ({
2899
+ componentProps,
2900
+ runtime,
2901
+ tagContentTranslationKey,
2902
+ tagContentTranslationValue,
2903
+ hrefTranslationKey,
2904
+ hrefTranslationValue
2905
+ }) => {
2906
+ if (tagContentTranslationKey) {
2907
+ componentProps.tagContent = runtime.t ? runtime.t(tagContentTranslationKey, { value: tagContentTranslationValue }) : tagContentTranslationValue || tagContentTranslationKey;
2908
+ }
2909
+ if (hrefTranslationKey) {
2910
+ componentProps.href = runtime.t ? runtime.t(hrefTranslationKey, { value: hrefTranslationValue }) : hrefTranslationValue || hrefTranslationKey;
2911
+ }
2912
+ };
2913
+
2914
+ // src/utils/fieldFocus.ts
2915
+ var capturePendingFieldFocus = (target) => {
2916
+ if (!(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) {
2917
+ return null;
2918
+ }
2919
+ return {
2920
+ id: target.id || null,
2921
+ name: target.name || null,
2922
+ selectionStart: target.selectionStart,
2923
+ selectionEnd: target.selectionEnd
2924
+ };
2925
+ };
2926
+ var escapeCss = (value) => typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(value) : value.replace(/([\\.#:[\\],>+~*'"()])/g, "\\$1");
2927
+ var restorePendingFieldFocus = (pending) => {
2928
+ var _a;
2929
+ if (!pending) return false;
2930
+ let target = null;
2931
+ if (pending.id) {
2932
+ target = document.getElementById(pending.id);
2933
+ }
2934
+ if (!target && pending.name) {
2935
+ target = document.querySelector(
2936
+ `[name="${escapeCss(pending.name)}"]`
2937
+ );
2938
+ }
2939
+ if (!target) return false;
2940
+ target.focus({ preventScroll: true });
2941
+ if ("setSelectionRange" in target && typeof target.setSelectionRange === "function" && pending.selectionStart !== null) {
2942
+ const start = pending.selectionStart;
2943
+ const end = (_a = pending.selectionEnd) != null ? _a : start;
2944
+ try {
2945
+ target.setSelectionRange(start, end);
2946
+ } catch (e) {
2947
+ }
2948
+ }
2949
+ return true;
2950
+ };
2951
+
2952
+ // src/react-web/hooks/useUIEngineEffects.ts
2953
+ var useUIEngineEffects = ({
2954
+ schema,
2955
+ runtime,
2956
+ onNodeResize,
2957
+ onNodeResizeEnd,
2958
+ resizeStateRef,
2959
+ pendingFieldFocusRef,
2960
+ setVersion,
2961
+ minWidthPct,
2962
+ minHeightPct,
2963
+ minHeightPx
2964
+ }) => {
2965
+ return useUIEngineEffectsImpl({
2966
+ schema,
2967
+ runtime,
2968
+ onNodeResize,
2969
+ onNodeResizeEnd,
2970
+ resizeStateRef,
2971
+ pendingFieldFocusRef,
2972
+ setVersion,
2973
+ minWidthPct,
2974
+ minHeightPct,
2975
+ minHeightPx,
2976
+ dependencies: {
2977
+ buildAncestorTypeMembership,
2978
+ readOverlayState,
2979
+ capturePendingFieldFocus,
2980
+ restorePendingFieldFocus: (pending) => restorePendingFieldFocus(pending),
2981
+ computeMouseResizeSize: (args) => computeMouseResizeSize(__spreadProps(__spreadValues({}, args), {
2982
+ state: args.state
2983
+ }))
2984
+ }
2985
+ });
2986
+ };
2987
+
2988
+ // src/react-web/applyContentComposition.tsx
2989
+ import { applyContentComposition as applyContentCompositionImpl } from "@arkcit/engine-react";
2990
+
2991
+ // src/react-web/resolveContentCompositionPlan.ts
2992
+ import { resolveContentCompositionPlan } from "@arkcit/engine-render-layer";
2993
+
2994
+ // src/react-web/applyContentComposition.tsx
2995
+ var applyContentComposition = ({
2996
+ node,
2997
+ componentProps,
2998
+ isStudioRendererContext,
2999
+ internalStudioNodeTypes,
3000
+ schemaNodes,
3001
+ onInlineTextEdit,
3002
+ captureFieldFocus,
3003
+ renderSafeNode: renderSafeNode2,
3004
+ normalizeRenderableChild: normalizeRenderableChild2,
3005
+ findNodeById: findNodeById2,
3006
+ runtime,
3007
+ plans: providedPlans
3008
+ }) => {
3009
+ return applyContentCompositionImpl({
3010
+ node,
3011
+ componentProps,
3012
+ isStudioRendererContext,
3013
+ internalStudioNodeTypes,
3014
+ schemaNodes,
3015
+ onInlineTextEdit,
3016
+ captureFieldFocus,
3017
+ renderSafeNode: renderSafeNode2,
3018
+ normalizeRenderableChild: normalizeRenderableChild2,
3019
+ findNodeById: findNodeById2,
3020
+ runtime,
3021
+ plans: providedPlans,
3022
+ dependencies: {
3023
+ resolveContentCompositionPlan,
3024
+ renderStudioForm,
3025
+ buildScrollRevealChildren: (args) => buildScrollRevealChildren(__spreadProps(__spreadValues({}, args), {
3026
+ rawChildren: args.rawChildren
3027
+ }))
3028
+ }
3029
+ });
3030
+ };
3031
+
3032
+ // src/react-web/applyNavigationComposition.tsx
3033
+ import { applyNavigationComposition as applyNavigationCompositionImpl } from "@arkcit/engine-react";
3034
+
3035
+ // src/react-web/resolveNavigationCompositionPlan.ts
3036
+ import { resolveNavigationCompositionPlan } from "@arkcit/engine-render-layer";
3037
+
3038
+ // src/react-web/applyNavigationComposition.tsx
3039
+ var applyNavigationComposition = ({
3040
+ node,
3041
+ componentProps,
3042
+ isStudioRendererContext,
3043
+ selectedNodeId,
3044
+ wizardActiveStepByNodeId,
3045
+ accordionOpenIdsByNodeId,
3046
+ expandablePanelOpenByNodeId,
3047
+ runtime,
3048
+ setWizardActiveStepByNodeId,
3049
+ setAccordionOpenIdsByNodeId,
3050
+ setExpandablePanelOpenByNodeId,
3051
+ onNodeClick,
3052
+ onInlineTextEdit,
3053
+ renderSafeNode: renderSafeNode2,
3054
+ normalizeRenderableChild: normalizeRenderableChild2,
3055
+ captureFieldFocus,
3056
+ setInlineEditing,
3057
+ internalStudioNodeTypes,
3058
+ plans: providedPlans
3059
+ }) => {
3060
+ return applyNavigationCompositionImpl({
3061
+ node,
3062
+ componentProps,
3063
+ isStudioRendererContext,
3064
+ selectedNodeId,
3065
+ wizardActiveStepByNodeId,
3066
+ accordionOpenIdsByNodeId,
3067
+ expandablePanelOpenByNodeId,
3068
+ runtime,
3069
+ setWizardActiveStepByNodeId,
3070
+ setAccordionOpenIdsByNodeId,
3071
+ setExpandablePanelOpenByNodeId,
3072
+ onNodeClick,
3073
+ onInlineTextEdit,
3074
+ renderSafeNode: renderSafeNode2,
3075
+ normalizeRenderableChild: normalizeRenderableChild2,
3076
+ captureFieldFocus,
3077
+ setInlineEditing,
3078
+ internalStudioNodeTypes,
3079
+ plans: providedPlans,
3080
+ dependencies: {
3081
+ resolveNavigationCompositionPlan,
3082
+ createInlineEditingState,
3083
+ configureStudioFormWizard,
3084
+ configureStudioAccordion,
3085
+ configureStudioExpandablePanel,
3086
+ configureStudioTabs: (args) => configureStudioTabs(__spreadProps(__spreadValues({}, args), {
3087
+ rawChildren: normalizeNavigationChildren(args.rawChildren)
3088
+ }))
3089
+ }
3090
+ });
3091
+ };
3092
+
3093
+ // src/react-web/applyRenderDirectives.ts
3094
+ import { applyRenderDirectives as applyRenderDirectivesImpl } from "@arkcit/engine-react";
3095
+
3096
+ // src/react-web/resolveRenderDirectivePlan.ts
3097
+ import { resolveRenderDirectivePlan } from "@arkcit/engine-render-layer";
3098
+
3099
+ // src/react-web/applyRenderDirectives.ts
3100
+ var applyRenderDirectives = ({
3101
+ node,
3102
+ componentProps,
3103
+ renderBindingProps,
3104
+ runtime,
3105
+ plans: providedPlans
3106
+ }) => {
3107
+ return applyRenderDirectivesImpl({
3108
+ node,
3109
+ componentProps,
3110
+ renderBindingProps,
3111
+ runtime,
3112
+ plans: providedPlans,
3113
+ dependencies: {
3114
+ resolveRenderDirectivePlan,
3115
+ applyRowsAndColumnsBinding,
3116
+ filterRowsByRuntimeQuery,
3117
+ buildCoverMedia: (args) => buildCoverMedia({
3118
+ mediaSource: args.mediaSource,
3119
+ mediaSrc: args.mediaSrc,
3120
+ mediaAlt: args.mediaAlt
3121
+ }),
3122
+ applyObjectBinding,
3123
+ applyDecodeTranslationBinding: (args) => {
3124
+ var _a, _b, _c, _d;
3125
+ return applyDecodeTranslationBinding({
3126
+ componentProps: args.componentProps,
3127
+ runtime,
3128
+ tagContentTranslationKey: (_a = args.tagContentTranslationKey) != null ? _a : "",
3129
+ tagContentTranslationValue: (_b = args.tagContentTranslationValue) != null ? _b : "",
3130
+ hrefTranslationKey: (_c = args.hrefTranslationKey) != null ? _c : "",
3131
+ hrefTranslationValue: (_d = args.hrefTranslationValue) != null ? _d : ""
3132
+ });
3133
+ }
3134
+ }
3135
+ });
3136
+ };
3137
+
3138
+ // src/react-web/finalizeRenderedNode.tsx
3139
+ import { finalizeRenderedNode as finalizeRenderedNodeImpl } from "@arkcit/engine-react";
3140
+
3141
+ // src/react-web/resolveFinalRenderPlan.ts
3142
+ import { resolveFinalRenderPlan } from "@arkcit/engine-render-layer";
3143
+
3144
+ // src/react-web/finalizeRenderedNode.tsx
3145
+ var finalizeRenderedNode = ({
3146
+ node,
3147
+ children,
3148
+ componentProps,
3149
+ registryComponent,
3150
+ runtime,
3151
+ isStudioRendererContext,
3152
+ studioSizing,
3153
+ plans: providedPlans
3154
+ }) => {
3155
+ return finalizeRenderedNodeImpl({
3156
+ node,
3157
+ children,
3158
+ componentProps,
3159
+ registryComponent,
3160
+ runtime,
3161
+ isStudioRendererContext,
3162
+ studioSizing,
3163
+ plans: providedPlans,
3164
+ dependencies: {
3165
+ resolveFinalRenderPlan,
3166
+ omitStudioProps
3167
+ }
3168
+ });
3169
+ };
3170
+
3171
+ // src/react-web/renderReactNodeDependencies.ts
3172
+ var createRenderReactNodeDependencies = () => ({
3173
+ applyStudioOverlayComponentProps,
3174
+ applyContentComposition,
3175
+ applyRenderDirectives,
3176
+ applyNavigationComposition,
3177
+ finalizeRenderedNode,
3178
+ normalizeRenderableChild,
3179
+ findNodeById
3180
+ });
3181
+ var createInlineEditingState = (targetNodeId, propName, rawValue) => {
3182
+ let mode = "primitive";
3183
+ let value = "";
3184
+ if (typeof rawValue === "string") {
3185
+ value = rawValue;
3186
+ } else if (typeof rawValue === "number" || typeof rawValue === "boolean") {
3187
+ value = String(rawValue);
3188
+ } else if (rawValue && typeof rawValue === "object") {
3189
+ if (!Array.isArray(rawValue) && typeof rawValue.$t === "string") {
3190
+ const translationValue = rawValue;
3191
+ mode = "translation";
3192
+ value = translationValue.$t;
3193
+ } else {
3194
+ mode = "json";
3195
+ try {
3196
+ value = JSON.stringify(rawValue, null, 2);
3197
+ } catch (e) {
3198
+ value = "";
3199
+ }
3200
+ }
3201
+ }
3202
+ return {
3203
+ nodeId: targetNodeId,
3204
+ propName,
3205
+ value,
3206
+ multiline: mode === "json" || value.length > 64,
3207
+ mode
3208
+ };
3209
+ };
3210
+ var normalizeNavigationChildren = (rawChildren) => Array.isArray(rawChildren) ? rawChildren : [];
3211
+
3212
+ // src/react-web/engine/rootDependencies.ts
3213
+ var createReactWebEngineRootDependencies = () => ({
3214
+ useUIEngineEffects: (args) => useUIEngineEffects(__spreadProps(__spreadValues({}, args), {
3215
+ resizeStateRef: args.resizeStateRef,
3216
+ pendingFieldFocusRef: args.pendingFieldFocusRef
3217
+ })),
3218
+ renderSafeNode: (args) => renderSafeNode(__spreadProps(__spreadValues({}, args), {
3219
+ resizeStateRef: args.resizeStateRef,
3220
+ pinchStateRef: args.pinchStateRef
3221
+ })),
3222
+ InlineTextEditor,
3223
+ StudioNodeWrapper,
3224
+ renderReactNodeDependencies: createRenderReactNodeDependencies()
3225
+ });
3226
+
3227
+ // src/react-web/engine/ReactWebEngineRoot.tsx
3228
+ import { jsx as jsx7 } from "react/jsx-runtime";
3229
+ var ReactWebEngineRoot = (props) => {
3230
+ return /* @__PURE__ */ jsx7(
3231
+ ReactWebEngineRootImpl,
3232
+ __spreadProps(__spreadValues({}, props), {
3233
+ dependencies: createReactWebEngineRootDependencies()
3234
+ })
3235
+ );
3236
+ };
3237
+
3238
+ // src/react-web/materialization/index.ts
3239
+ import { resolveBoundTableData } from "@arkcit/engine-react";
3240
+ export {
3241
+ EngineWarningFallback,
3242
+ NodeErrorBoundary,
3243
+ ReactWebEngineRoot,
3244
+ configurePreviewLinkBehavior,
3245
+ materializeBoundTable
3246
+ };