@arkcit/engine-render-layer 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.
@@ -0,0 +1,716 @@
1
+ // src/resolveChildContentDescriptor.ts
2
+ var resolveChildContentDescriptor = ({
3
+ childDescriptors
4
+ }) => {
5
+ if (childDescriptors.length === 0) {
6
+ return { kind: "empty" };
7
+ }
8
+ if (childDescriptors.length === 1) {
9
+ return {
10
+ kind: "single",
11
+ child: childDescriptors[0]
12
+ };
13
+ }
14
+ return {
15
+ kind: "list",
16
+ children: childDescriptors
17
+ };
18
+ };
19
+
20
+ // src/nodeLayout.ts
21
+ var toPositiveNumber = (value) => {
22
+ const numeric = Number(value);
23
+ if (!Number.isFinite(numeric) || numeric <= 0) return void 0;
24
+ return numeric;
25
+ };
26
+ var toColSpan = (value) => {
27
+ const numeric = Number(value);
28
+ if (!Number.isInteger(numeric) || numeric < 1 || numeric > 12) return void 0;
29
+ return numeric;
30
+ };
31
+ var toCardSection = (value) => {
32
+ if (value === "header" || value === "body" || value === "footer") return value;
33
+ return void 0;
34
+ };
35
+ var readRenderLayerNodeLayout = (props) => {
36
+ var _a, _b, _c, _d, _e, _f, _g;
37
+ if (!props) return {};
38
+ const rawLayout = props.layout && typeof props.layout === "object" && !Array.isArray(props.layout) ? props.layout : {};
39
+ return {
40
+ widthPct: toPositiveNumber((_a = rawLayout.widthPct) != null ? _a : props.__studioWidthPct),
41
+ heightPct: toPositiveNumber((_b = rawLayout.heightPct) != null ? _b : props.__studioHeightPct),
42
+ heightPx: toPositiveNumber((_c = rawLayout.heightPx) != null ? _c : props.__studioHeightPx),
43
+ colSpan: toColSpan((_d = rawLayout.colSpan) != null ? _d : props.__studioColSpan),
44
+ wrapperClassName: String(
45
+ (_f = (_e = rawLayout.wrapperClassName) != null ? _e : props.__studioWrapperClassName) != null ? _f : ""
46
+ ).trim(),
47
+ cardSection: toCardSection((_g = rawLayout.cardSection) != null ? _g : props.__studioCardSection),
48
+ wizardStep: rawLayout.wizardStep === true ? true : void 0,
49
+ wizardStepRole: rawLayout.wizardStepRole === "title" || rawLayout.wizardStepRole === "description" ? rawLayout.wizardStepRole : void 0,
50
+ wizardContent: rawLayout.wizardContent === true ? true : void 0,
51
+ accordionItem: rawLayout.accordionItem === true ? true : void 0,
52
+ formRole: rawLayout.formRole === "field" || rawLayout.formRole === "title" || rawLayout.formRole === "submit" || rawLayout.formRole === "reset" || rawLayout.formRole === "step" || rawLayout.formRole === "step-content" || rawLayout.formRole === "trigger" || rawLayout.formRole === "content" ? rawLayout.formRole : void 0,
53
+ tabId: typeof rawLayout.tabId === "string" || typeof rawLayout.tabId === "number" ? String(rawLayout.tabId) : void 0
54
+ };
55
+ };
56
+
57
+ // src/resolveChildDescriptors.ts
58
+ var resolveChildDescriptors = ({
59
+ node,
60
+ internalStudioNodeTypes
61
+ }) => {
62
+ var _a, _b;
63
+ const renderableChildren = (_a = node.children) == null ? void 0 : _a.filter(
64
+ (child) => !internalStudioNodeTypes.has(child.type)
65
+ );
66
+ return (_b = renderableChildren == null ? void 0 : renderableChildren.map((child) => {
67
+ var _a2, _b2;
68
+ if (node.type === "Grid") {
69
+ const childLayout = readRenderLayerNodeLayout(
70
+ (_a2 = child.props) != null ? _a2 : {}
71
+ );
72
+ return {
73
+ kind: "grid-item",
74
+ child,
75
+ colSpan: (_b2 = childLayout.colSpan) != null ? _b2 : 12
76
+ };
77
+ }
78
+ return {
79
+ kind: "node",
80
+ child
81
+ };
82
+ })) != null ? _b : [];
83
+ };
84
+
85
+ // src/resolveCoverContentDescriptor.ts
86
+ var resolveCoverContentDescriptor = ({
87
+ rawChildren
88
+ }) => ({
89
+ actionNodes: rawChildren.filter((child) => child.type === "Button" || child.type === "Link"),
90
+ contentNodes: rawChildren.filter((child) => child.type !== "Button" && child.type !== "Link")
91
+ });
92
+
93
+ // src/resolveContentCompositionPlan.ts
94
+ var resolveContentCompositionPlan = ({
95
+ node,
96
+ isStudioRendererContext,
97
+ internalStudioNodeTypes
98
+ }) => {
99
+ var _a, _b, _c, _d;
100
+ const plans = [];
101
+ if (node.type === "Button") {
102
+ const rawEnableEventOnClick = (_a = node.props) == null ? void 0 : _a.buttonEnableEventOnClick;
103
+ const hasExplicitToggle = rawEnableEventOnClick !== void 0;
104
+ const enableEventOnClick = typeof rawEnableEventOnClick === "boolean" ? rawEnableEventOnClick : typeof rawEnableEventOnClick === "string" ? rawEnableEventOnClick.toLowerCase() === "true" : Boolean(rawEnableEventOnClick);
105
+ if (hasExplicitToggle && !enableEventOnClick) {
106
+ plans.push({
107
+ kind: "button-toggle",
108
+ disableOnClick: true
109
+ });
110
+ }
111
+ }
112
+ if (node.type === "FormField") {
113
+ plans.push({ kind: "form-field" });
114
+ }
115
+ if (node.type === "Form" && isStudioRendererContext) {
116
+ plans.push({
117
+ kind: "studio-form",
118
+ visibleChildren: ((_b = node.children) != null ? _b : []).filter(
119
+ (child) => !internalStudioNodeTypes.has(child.type)
120
+ )
121
+ });
122
+ }
123
+ if (node.type === "Cover") {
124
+ const rawChildren = ((_c = node.children) != null ? _c : []).filter(
125
+ (child) => !internalStudioNodeTypes.has(child.type)
126
+ );
127
+ plans.push({
128
+ kind: "cover-content",
129
+ rawChildren,
130
+ descriptor: resolveCoverContentDescriptor({
131
+ rawChildren
132
+ })
133
+ });
134
+ }
135
+ if (node.type === "ScrollReveal") {
136
+ plans.push({
137
+ kind: "scroll-reveal",
138
+ rawChildren: ((_d = node.children) != null ? _d : []).filter(
139
+ (child) => !internalStudioNodeTypes.has(child.type)
140
+ )
141
+ });
142
+ }
143
+ return plans;
144
+ };
145
+
146
+ // src/resolveFinalRenderPlan.ts
147
+ var resolveFinalRenderPlan = ({
148
+ node,
149
+ componentProps,
150
+ isStudioRendererContext,
151
+ studioSizing
152
+ }) => {
153
+ const plans = [];
154
+ if (studioSizing) {
155
+ const existingStyle = componentProps.style && typeof componentProps.style === "object" && !Array.isArray(componentProps.style) ? componentProps.style : {};
156
+ const nextStyle = { ...existingStyle };
157
+ if (studioSizing.widthPct !== null) {
158
+ nextStyle.width = "100%";
159
+ nextStyle.maxWidth = "100%";
160
+ }
161
+ if (studioSizing.heightPx !== null) {
162
+ nextStyle.height = `${studioSizing.heightPx}px`;
163
+ } else if (studioSizing.heightPct !== null) {
164
+ nextStyle.height = `${studioSizing.heightPct}%`;
165
+ }
166
+ plans.push({
167
+ kind: "style-sizing",
168
+ style: nextStyle
169
+ });
170
+ }
171
+ if (node.type === "Link" && isStudioRendererContext) {
172
+ plans.push({ kind: "configure-studio-link" });
173
+ }
174
+ plans.push({ kind: "cleanup-studio-props" });
175
+ if (node.type === "Table") {
176
+ plans.push({ kind: "table-fallback" });
177
+ }
178
+ return plans;
179
+ };
180
+
181
+ // src/runtimeBindings.ts
182
+ var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
183
+ var MISSING_TRANSLATION_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
184
+ var MISSING_REF_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
185
+ var isPlainObject = (value) => {
186
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
187
+ const prototype = Object.getPrototypeOf(value);
188
+ return prototype === Object.prototype || prototype === null;
189
+ };
190
+ var isReactElementLike = (value) => isPlainObject(value) && typeof value.$$typeof === "symbol" && "props" in value;
191
+ var isTranslationValue = (value) => isPlainObject(value) && typeof value.$t === "string";
192
+ var isRefValue = (value) => isPlainObject(value) && typeof value.$ref === "string";
193
+ var isExprValue = (value) => isPlainObject(value) && typeof value.$expr === "string";
194
+ var parseStructuredString = (value) => {
195
+ if (typeof value !== "string") return value;
196
+ const trimmed = value.trim();
197
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return value;
198
+ try {
199
+ const parsed = JSON.parse(trimmed);
200
+ if (!isPlainObject(parsed)) return value;
201
+ if ((typeof parsed.$ref === "string" || typeof parsed.$t === "string") && Object.keys(parsed).length >= 1) {
202
+ return parsed;
203
+ }
204
+ return value;
205
+ } catch {
206
+ return value;
207
+ }
208
+ };
209
+ var resolveRenderLayerValue = (value, runtime) => {
210
+ const normalizedValue = parseStructuredString(value);
211
+ if (isTranslationValue(normalizedValue)) {
212
+ const fallback = typeof normalizedValue.defaultValue === "string" && normalizedValue.defaultValue.trim() ? normalizedValue.defaultValue : normalizedValue.$t;
213
+ if (!runtime.t) return fallback || MISSING_TRANSLATION_FALLBACK;
214
+ const translated = runtime.t(normalizedValue.$t, normalizedValue.values);
215
+ if (typeof translated !== "string") return fallback || MISSING_TRANSLATION_FALLBACK;
216
+ if (!translated.trim()) return fallback || MISSING_TRANSLATION_FALLBACK;
217
+ if (translated === normalizedValue.$t) return fallback || MISSING_TRANSLATION_FALLBACK;
218
+ return translated;
219
+ }
220
+ if (isRefValue(normalizedValue)) {
221
+ const resolved = runtime.get(normalizedValue.$ref);
222
+ if (resolved == null) return MISSING_REF_FALLBACK;
223
+ if (typeof resolved === "string" && !resolved.trim()) return MISSING_REF_FALLBACK;
224
+ return resolved;
225
+ }
226
+ if (isExprValue(normalizedValue)) {
227
+ return void 0;
228
+ }
229
+ if (Array.isArray(normalizedValue)) {
230
+ return normalizedValue.map((item) => resolveRenderLayerValue(item, runtime));
231
+ }
232
+ if (isReactElementLike(normalizedValue)) {
233
+ return normalizedValue;
234
+ }
235
+ if (isPlainObject(normalizedValue)) {
236
+ const next = {};
237
+ Object.entries(normalizedValue).forEach(([key, childValue]) => {
238
+ if (DANGEROUS_KEYS.has(key)) return;
239
+ next[key] = resolveRenderLayerValue(childValue, runtime);
240
+ });
241
+ return next;
242
+ }
243
+ return normalizedValue;
244
+ };
245
+ var resolveRenderLayerNodeProps = (props, runtime) => {
246
+ if (!props) return {};
247
+ const resolved = {};
248
+ Object.entries(props).forEach(([key, value]) => {
249
+ if (DANGEROUS_KEYS.has(key)) return;
250
+ resolved[key] = resolveRenderLayerValue(value, runtime);
251
+ });
252
+ return resolved;
253
+ };
254
+ var bindRenderLayerNodeEvents = (events, runtime) => {
255
+ if (!events) return {};
256
+ const handlers = {};
257
+ const extractDynamicPayload = (eventName, args) => {
258
+ var _a;
259
+ if (eventName !== "onChange") return void 0;
260
+ const firstArg = args[0];
261
+ if (!firstArg || typeof firstArg !== "object" || !("target" in firstArg)) {
262
+ return void 0;
263
+ }
264
+ const target = firstArg.target;
265
+ if (!target) return void 0;
266
+ const isCheckboxType = String((_a = target.type) != null ? _a : "").toLowerCase() === "checkbox";
267
+ const query = isCheckboxType ? target.checked : target.value;
268
+ return {
269
+ query,
270
+ value: target.value,
271
+ checked: target.checked
272
+ };
273
+ };
274
+ Object.entries(events).forEach(([eventName, action]) => {
275
+ if (!action) return;
276
+ handlers[eventName] = (...args) => {
277
+ const actionRef = action;
278
+ const dynamicPayload = extractDynamicPayload(eventName, args);
279
+ if (!dynamicPayload) {
280
+ runtime.dispatch(actionRef);
281
+ return;
282
+ }
283
+ if ("id" in actionRef) {
284
+ const basePayload = actionRef.payload && typeof actionRef.payload === "object" ? actionRef.payload : {};
285
+ runtime.dispatch({
286
+ ...actionRef,
287
+ payload: {
288
+ ...basePayload,
289
+ ...dynamicPayload
290
+ }
291
+ });
292
+ return;
293
+ }
294
+ if ("type" in actionRef) {
295
+ const basePayload = actionRef.payload && typeof actionRef.payload === "object" ? actionRef.payload : {};
296
+ runtime.dispatch({
297
+ ...actionRef,
298
+ payload: {
299
+ ...basePayload,
300
+ ...dynamicPayload
301
+ }
302
+ });
303
+ return;
304
+ }
305
+ runtime.dispatch(actionRef);
306
+ };
307
+ });
308
+ return handlers;
309
+ };
310
+
311
+ // src/renderBindingProps.ts
312
+ var RENDER_BINDING_PROP_NAMES = /* @__PURE__ */ new Set([
313
+ "bindingEnabled",
314
+ "valueBindingKey",
315
+ "optionsBindingKey",
316
+ "useBindingData",
317
+ "entitiesBindingKey",
318
+ "videoBindingKey",
319
+ "mapBindingKey",
320
+ "productBindingKey",
321
+ "useTranslationKeys",
322
+ "tagContentTranslationKey",
323
+ "tagContentTranslationValue",
324
+ "hrefTranslationKey",
325
+ "hrefTranslationValue",
326
+ "mediaSource",
327
+ "mediaSrc",
328
+ "mediaAlt",
329
+ "rowsBindingKey",
330
+ "columnsBindingKey"
331
+ ]);
332
+ var getRenderLayerBindingProps = (props) => {
333
+ if (!props || typeof props !== "object" || Array.isArray(props)) {
334
+ return {};
335
+ }
336
+ const source = props;
337
+ const embedded = source.__studio && typeof source.__studio === "object" && !Array.isArray(source.__studio) ? source.__studio : {};
338
+ const legacy = Array.from(RENDER_BINDING_PROP_NAMES).reduce(
339
+ (accumulator, key) => {
340
+ if (source[key] !== void 0) {
341
+ accumulator[key] = source[key];
342
+ }
343
+ return accumulator;
344
+ },
345
+ {}
346
+ );
347
+ return Array.from(RENDER_BINDING_PROP_NAMES).reduce((accumulator, key) => {
348
+ if (legacy[key] !== void 0) {
349
+ accumulator[key] = legacy[key];
350
+ } else if (embedded[key] !== void 0) {
351
+ accumulator[key] = embedded[key];
352
+ }
353
+ return accumulator;
354
+ }, {});
355
+ };
356
+
357
+ // src/resolvedNode.ts
358
+ import {
359
+ createResolvedNode,
360
+ createResolvedNodeBase
361
+ } from "@arkcit/engine-core";
362
+
363
+ // src/resolveNodeBase.ts
364
+ var shouldInferImplicitGridCols = (node, componentProps, childDescriptors) => {
365
+ if (node.type !== "Grid") return false;
366
+ const explicitCols = componentProps.cols;
367
+ if (explicitCols !== void 0 && explicitCols !== null && String(explicitCols).trim() !== "") {
368
+ return false;
369
+ }
370
+ return childDescriptors.some(
371
+ (descriptor) => descriptor.kind === "grid-item" && typeof descriptor.colSpan === "number"
372
+ );
373
+ };
374
+ var resolveNodeBase = ({
375
+ node,
376
+ runtime,
377
+ internalStudioNodeTypes
378
+ }) => {
379
+ const resolvedProps = resolveRenderLayerNodeProps(node.props, runtime);
380
+ const eventHandlers = bindRenderLayerNodeEvents(node.events, runtime);
381
+ const childDescriptors = resolveChildDescriptors({
382
+ node,
383
+ internalStudioNodeTypes
384
+ });
385
+ const childContentDescriptor = resolveChildContentDescriptor({
386
+ childDescriptors
387
+ });
388
+ const componentProps = {
389
+ ...resolvedProps,
390
+ ...eventHandlers
391
+ };
392
+ if (shouldInferImplicitGridCols(node, componentProps, childDescriptors)) {
393
+ componentProps.cols = 12;
394
+ }
395
+ const renderBindingProps = getRenderLayerBindingProps(componentProps);
396
+ return createResolvedNodeBase({
397
+ node,
398
+ componentProps,
399
+ renderBindingProps,
400
+ childDescriptors,
401
+ childContentDescriptor
402
+ });
403
+ };
404
+
405
+ // src/resolveNavigationContentDescriptors.ts
406
+ var resolveAccordionItemDescriptors = ({
407
+ accordionChildren
408
+ }) => accordionChildren.map((child, index) => {
409
+ var _a, _b, _c, _d, _e, _f;
410
+ const childProps = (_a = child.props) != null ? _a : {};
411
+ const contentNodes = (_b = child.children) != null ? _b : [];
412
+ const hasContentNodes = contentNodes.length > 0;
413
+ return {
414
+ id: String((_d = (_c = childProps.id) != null ? _c : child.id) != null ? _d : `item-${index + 1}`),
415
+ title: String((_e = childProps.title) != null ? _e : `Section ${index + 1}`),
416
+ disabled: Boolean(childProps.disabled),
417
+ contentKind: hasContentNodes ? "nodes" : "text",
418
+ contentText: hasContentNodes ? null : String((_f = childProps.content) != null ? _f : ""),
419
+ contentNodes
420
+ };
421
+ });
422
+ var resolveExpandablePanelContentDescriptor = ({
423
+ panelChildren
424
+ }) => panelChildren.length === 0 ? {
425
+ kind: "empty",
426
+ nodes: []
427
+ } : {
428
+ kind: "nodes",
429
+ nodes: panelChildren
430
+ };
431
+
432
+ // src/normalizeTabsProps.ts
433
+ var normalizeRenderLayerTabsProps = (props) => {
434
+ var _a;
435
+ const rawTabs = Array.isArray(props.tabs) ? props.tabs : [];
436
+ const tabs = rawTabs.length ? rawTabs.map((tab, index) => {
437
+ var _a2, _b, _c;
438
+ const rawTab = tab && typeof tab === "object" && !Array.isArray(tab) ? tab : {};
439
+ const id = String((_a2 = rawTab.id) != null ? _a2 : `tab-${index + 1}`);
440
+ const title = (_c = (_b = rawTab.title) != null ? _b : rawTab.label) != null ? _c : `Tab ${index + 1}`;
441
+ return {
442
+ ...rawTab,
443
+ id,
444
+ title,
445
+ label: title
446
+ };
447
+ }) : [
448
+ {
449
+ id: "overview",
450
+ title: "Overview",
451
+ label: "Overview",
452
+ content: "Overview content"
453
+ }
454
+ ];
455
+ const rawDict = props.dict && typeof props.dict === "object" && !Array.isArray(props.dict) ? props.dict : {};
456
+ const rawUrlSync = props.urlSync && typeof props.urlSync === "object" && !Array.isArray(props.urlSync) ? props.urlSync : null;
457
+ const rawNavigation = (rawUrlSync == null ? void 0 : rawUrlSync.navigation) && typeof rawUrlSync.navigation === "object" && !Array.isArray(rawUrlSync.navigation) ? rawUrlSync.navigation : null;
458
+ const normalizedUrlSync = rawNavigation && typeof rawNavigation.getSearch === "function" && typeof rawNavigation.replaceSearch === "function" ? {
459
+ ...rawUrlSync,
460
+ navigation: rawNavigation
461
+ } : void 0;
462
+ return {
463
+ ...props,
464
+ tabs,
465
+ dict: {
466
+ ...rawDict,
467
+ noContentYet: typeof rawDict.noContentYet === "string" && rawDict.noContentYet.trim().length > 0 ? rawDict.noContentYet : "No content yet"
468
+ },
469
+ defaultActive: typeof props.defaultActive === "string" && props.defaultActive.trim().length > 0 ? props.defaultActive : String((_a = tabs[0].id) != null ? _a : "overview"),
470
+ keepMounted: typeof props.keepMounted === "boolean" ? props.keepMounted : true,
471
+ urlSync: normalizedUrlSync
472
+ };
473
+ };
474
+
475
+ // src/resolveTabsContentDescriptors.ts
476
+ var resolveTabsContentDescriptors = ({
477
+ tabItems,
478
+ rawChildren,
479
+ runtime
480
+ }) => {
481
+ const childrenByTabId = /* @__PURE__ */ new Map();
482
+ const unassignedChildren = [];
483
+ rawChildren.forEach((child) => {
484
+ var _a, _b, _c;
485
+ const childProps = (_a = child.props) != null ? _a : {};
486
+ const rawLayout = childProps.layout && typeof childProps.layout === "object" && !Array.isArray(childProps.layout) ? childProps.layout : {};
487
+ const tabIdFromLayout = (_b = rawLayout.tabId) != null ? _b : childProps.__studioTabId;
488
+ const resolvedTabId = resolveRenderLayerValue(tabIdFromLayout, runtime);
489
+ const normalizedTabId = String(resolvedTabId != null ? resolvedTabId : "").trim();
490
+ if (!normalizedTabId) {
491
+ unassignedChildren.push(child);
492
+ return;
493
+ }
494
+ const existing = (_c = childrenByTabId.get(normalizedTabId)) != null ? _c : [];
495
+ existing.push(child);
496
+ childrenByTabId.set(normalizedTabId, existing);
497
+ });
498
+ return tabItems.map((item, index) => {
499
+ var _a, _b, _c, _d;
500
+ const rawId = (_a = item.id) != null ? _a : `tab-${index + 1}`;
501
+ const resolvedId = resolveRenderLayerValue(rawId, runtime);
502
+ const normalizedId = String(
503
+ resolvedId == null || String(resolvedId).trim().length === 0 ? rawId : resolvedId
504
+ );
505
+ const rawTitle = (_b = item.title) != null ? _b : item.label;
506
+ const resolvedTitle = resolveRenderLayerValue(rawTitle, runtime);
507
+ const normalizedTitle = (_c = resolvedTitle != null ? resolvedTitle : rawTitle) != null ? _c : `Tab ${index + 1}`;
508
+ const mappedChildren = (_d = childrenByTabId.get(normalizedId)) != null ? _d : [];
509
+ const fallbackChildren = index === 0 ? unassignedChildren : [];
510
+ const contentNodes = [...mappedChildren, ...fallbackChildren];
511
+ return {
512
+ id: normalizedId,
513
+ title: normalizedTitle,
514
+ label: normalizedTitle,
515
+ contentKind: contentNodes.length > 0 ? "nodes" : "fallback",
516
+ contentNodes,
517
+ fallbackContent: item.content
518
+ };
519
+ });
520
+ };
521
+
522
+ // src/resolveNavigationCompositionPlan.ts
523
+ var resolveNavigationCompositionPlan = ({
524
+ node,
525
+ componentProps,
526
+ internalStudioNodeTypes,
527
+ runtime
528
+ }) => {
529
+ var _a, _b, _c;
530
+ const plans = [];
531
+ if (node.type === "FormWizard") {
532
+ plans.push({ kind: "form-wizard" });
533
+ }
534
+ if (node.type === "Accordion") {
535
+ const accordionChildren = ((_a = node.children) != null ? _a : []).filter(
536
+ (child) => !internalStudioNodeTypes.has(child.type)
537
+ );
538
+ plans.push({
539
+ kind: "accordion",
540
+ accordionChildren,
541
+ itemDescriptors: resolveAccordionItemDescriptors({
542
+ accordionChildren
543
+ })
544
+ });
545
+ }
546
+ if (node.type === "ExpandablePanel") {
547
+ const panelChildren = ((_b = node.children) != null ? _b : []).filter(
548
+ (child) => !internalStudioNodeTypes.has(child.type)
549
+ );
550
+ plans.push({
551
+ kind: "expandable-panel",
552
+ panelChildren,
553
+ contentDescriptor: resolveExpandablePanelContentDescriptor({
554
+ panelChildren
555
+ })
556
+ });
557
+ }
558
+ if (node.type === "Tabs") {
559
+ const rawChildren = ((_c = node.children) != null ? _c : []).filter(
560
+ (child) => !internalStudioNodeTypes.has(child.type)
561
+ );
562
+ const normalizedComponentProps = normalizeRenderLayerTabsProps(componentProps);
563
+ const normalizedTabs = Array.isArray(normalizedComponentProps.tabs) ? normalizedComponentProps.tabs : [];
564
+ plans.push({
565
+ kind: "tabs",
566
+ normalizedComponentProps,
567
+ rawChildren,
568
+ tabDescriptors: resolveTabsContentDescriptors({
569
+ tabItems: normalizedTabs,
570
+ rawChildren,
571
+ runtime
572
+ })
573
+ });
574
+ }
575
+ return plans;
576
+ };
577
+
578
+ // src/resolveRenderDirectivePlan.ts
579
+ var resolveRenderDirectivePlan = ({
580
+ node,
581
+ renderBindingProps
582
+ }) => {
583
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
584
+ const directives = [];
585
+ if (node.type === "DataGrid") {
586
+ const useBindingData = Boolean(renderBindingProps.useBindingData);
587
+ if (useBindingData) {
588
+ const rowsBindingKey = String((_a = renderBindingProps.rowsBindingKey) != null ? _a : "").trim();
589
+ const columnsBindingKey = String((_b = renderBindingProps.columnsBindingKey) != null ? _b : "").trim();
590
+ directives.push({
591
+ kind: "rows-columns-binding",
592
+ rowsBindingKey,
593
+ columnsBindingKey
594
+ });
595
+ }
596
+ directives.push({
597
+ kind: "filter-rows-by-query",
598
+ nodeId: node.id
599
+ });
600
+ }
601
+ if (node.type === "Cover") {
602
+ directives.push({
603
+ kind: "cover-media",
604
+ mediaSource: String((_c = renderBindingProps.mediaSource) != null ? _c : "").trim().toLowerCase(),
605
+ mediaSrc: String((_d = renderBindingProps.mediaSrc) != null ? _d : "").trim(),
606
+ mediaAlt: String((_e = renderBindingProps.mediaAlt) != null ? _e : "Cover media").trim()
607
+ });
608
+ }
609
+ if (node.type === "Table") {
610
+ const useBindingData = Boolean(renderBindingProps.useBindingData);
611
+ if (useBindingData) {
612
+ const rowsBindingKey = String((_f = renderBindingProps.rowsBindingKey) != null ? _f : "").trim();
613
+ const columnsBindingKey = String((_g = renderBindingProps.columnsBindingKey) != null ? _g : "").trim();
614
+ directives.push({
615
+ kind: "rows-columns-binding",
616
+ rowsBindingKey,
617
+ columnsBindingKey
618
+ });
619
+ }
620
+ }
621
+ if (node.type === "EmbeddedVideo") {
622
+ const useBindingData = Boolean(renderBindingProps.useBindingData);
623
+ if (useBindingData) {
624
+ directives.push({
625
+ kind: "object-binding",
626
+ bindingKey: String((_h = renderBindingProps.videoBindingKey) != null ? _h : "").trim()
627
+ });
628
+ }
629
+ }
630
+ if (node.type === "MapCard") {
631
+ const useBindingData = Boolean(renderBindingProps.useBindingData);
632
+ if (useBindingData) {
633
+ directives.push({
634
+ kind: "object-binding",
635
+ bindingKey: String((_i = renderBindingProps.mapBindingKey) != null ? _i : "").trim()
636
+ });
637
+ }
638
+ }
639
+ if (node.type === "Product") {
640
+ const useBindingData = Boolean(renderBindingProps.useBindingData);
641
+ if (useBindingData) {
642
+ directives.push({
643
+ kind: "object-binding",
644
+ bindingKey: String((_j = renderBindingProps.productBindingKey) != null ? _j : "").trim()
645
+ });
646
+ }
647
+ }
648
+ if (node.type === "DecodeTranslation") {
649
+ const useTranslationKeys = Boolean(renderBindingProps.useTranslationKeys);
650
+ if (useTranslationKeys) {
651
+ directives.push({
652
+ kind: "decode-translation-binding",
653
+ tagContentTranslationKey: String(
654
+ (_k = renderBindingProps.tagContentTranslationKey) != null ? _k : ""
655
+ ).trim(),
656
+ tagContentTranslationValue: String((_l = renderBindingProps.tagContentTranslationValue) != null ? _l : ""),
657
+ hrefTranslationKey: String((_m = renderBindingProps.hrefTranslationKey) != null ? _m : "").trim(),
658
+ hrefTranslationValue: String((_n = renderBindingProps.hrefTranslationValue) != null ? _n : "")
659
+ });
660
+ }
661
+ }
662
+ return directives;
663
+ };
664
+
665
+ // src/resolveResolvedNode.ts
666
+ var resolveResolvedNode = ({
667
+ node,
668
+ runtime,
669
+ internalStudioNodeTypes,
670
+ isStudioRendererContext,
671
+ studioSizing
672
+ }) => {
673
+ const baseNode = resolveNodeBase({
674
+ node,
675
+ runtime,
676
+ internalStudioNodeTypes
677
+ });
678
+ return createResolvedNode({
679
+ ...baseNode,
680
+ contentPlans: resolveContentCompositionPlan({
681
+ node,
682
+ isStudioRendererContext,
683
+ internalStudioNodeTypes
684
+ }),
685
+ navigationPlans: resolveNavigationCompositionPlan({
686
+ node,
687
+ componentProps: baseNode.componentProps,
688
+ internalStudioNodeTypes,
689
+ runtime
690
+ }),
691
+ renderDirectivePlans: resolveRenderDirectivePlan({
692
+ node,
693
+ renderBindingProps: baseNode.renderBindingProps
694
+ }),
695
+ finalRenderPlans: resolveFinalRenderPlan({
696
+ node,
697
+ componentProps: baseNode.componentProps,
698
+ isStudioRendererContext,
699
+ studioSizing
700
+ })
701
+ });
702
+ };
703
+ export {
704
+ resolveAccordionItemDescriptors,
705
+ resolveChildContentDescriptor,
706
+ resolveChildDescriptors,
707
+ resolveContentCompositionPlan,
708
+ resolveCoverContentDescriptor,
709
+ resolveExpandablePanelContentDescriptor,
710
+ resolveFinalRenderPlan,
711
+ resolveNavigationCompositionPlan,
712
+ resolveNodeBase,
713
+ resolveRenderDirectivePlan,
714
+ resolveResolvedNode,
715
+ resolveTabsContentDescriptors
716
+ };