@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.
package/dist/index.js ADDED
@@ -0,0 +1,725 @@
1
+ // src/resolvedNode.ts
2
+ import {
3
+ createResolvedNode,
4
+ createResolvedNodeBase
5
+ } from "@arkcit/engine-core";
6
+
7
+ // src/nodeLayout.ts
8
+ var toPositiveNumber = (value) => {
9
+ const numeric = Number(value);
10
+ if (!Number.isFinite(numeric) || numeric <= 0) return void 0;
11
+ return numeric;
12
+ };
13
+ var toColSpan = (value) => {
14
+ const numeric = Number(value);
15
+ if (!Number.isInteger(numeric) || numeric < 1 || numeric > 12) return void 0;
16
+ return numeric;
17
+ };
18
+ var toCardSection = (value) => {
19
+ if (value === "header" || value === "body" || value === "footer") return value;
20
+ return void 0;
21
+ };
22
+ var readRenderLayerNodeLayout = (props) => {
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ if (!props) return {};
25
+ const rawLayout = props.layout && typeof props.layout === "object" && !Array.isArray(props.layout) ? props.layout : {};
26
+ return {
27
+ widthPct: toPositiveNumber((_a = rawLayout.widthPct) != null ? _a : props.__studioWidthPct),
28
+ heightPct: toPositiveNumber((_b = rawLayout.heightPct) != null ? _b : props.__studioHeightPct),
29
+ heightPx: toPositiveNumber((_c = rawLayout.heightPx) != null ? _c : props.__studioHeightPx),
30
+ colSpan: toColSpan((_d = rawLayout.colSpan) != null ? _d : props.__studioColSpan),
31
+ wrapperClassName: String(
32
+ (_f = (_e = rawLayout.wrapperClassName) != null ? _e : props.__studioWrapperClassName) != null ? _f : ""
33
+ ).trim(),
34
+ cardSection: toCardSection((_g = rawLayout.cardSection) != null ? _g : props.__studioCardSection),
35
+ wizardStep: rawLayout.wizardStep === true ? true : void 0,
36
+ wizardStepRole: rawLayout.wizardStepRole === "title" || rawLayout.wizardStepRole === "description" ? rawLayout.wizardStepRole : void 0,
37
+ wizardContent: rawLayout.wizardContent === true ? true : void 0,
38
+ accordionItem: rawLayout.accordionItem === true ? true : void 0,
39
+ 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,
40
+ tabId: typeof rawLayout.tabId === "string" || typeof rawLayout.tabId === "number" ? String(rawLayout.tabId) : void 0
41
+ };
42
+ };
43
+
44
+ // src/normalizeTabsProps.ts
45
+ var normalizeRenderLayerTabsProps = (props) => {
46
+ var _a;
47
+ const rawTabs = Array.isArray(props.tabs) ? props.tabs : [];
48
+ const tabs = rawTabs.length ? rawTabs.map((tab, index) => {
49
+ var _a2, _b, _c;
50
+ const rawTab = tab && typeof tab === "object" && !Array.isArray(tab) ? tab : {};
51
+ const id = String((_a2 = rawTab.id) != null ? _a2 : `tab-${index + 1}`);
52
+ const title = (_c = (_b = rawTab.title) != null ? _b : rawTab.label) != null ? _c : `Tab ${index + 1}`;
53
+ return {
54
+ ...rawTab,
55
+ id,
56
+ title,
57
+ label: title
58
+ };
59
+ }) : [
60
+ {
61
+ id: "overview",
62
+ title: "Overview",
63
+ label: "Overview",
64
+ content: "Overview content"
65
+ }
66
+ ];
67
+ const rawDict = props.dict && typeof props.dict === "object" && !Array.isArray(props.dict) ? props.dict : {};
68
+ const rawUrlSync = props.urlSync && typeof props.urlSync === "object" && !Array.isArray(props.urlSync) ? props.urlSync : null;
69
+ const rawNavigation = (rawUrlSync == null ? void 0 : rawUrlSync.navigation) && typeof rawUrlSync.navigation === "object" && !Array.isArray(rawUrlSync.navigation) ? rawUrlSync.navigation : null;
70
+ const normalizedUrlSync = rawNavigation && typeof rawNavigation.getSearch === "function" && typeof rawNavigation.replaceSearch === "function" ? {
71
+ ...rawUrlSync,
72
+ navigation: rawNavigation
73
+ } : void 0;
74
+ return {
75
+ ...props,
76
+ tabs,
77
+ dict: {
78
+ ...rawDict,
79
+ noContentYet: typeof rawDict.noContentYet === "string" && rawDict.noContentYet.trim().length > 0 ? rawDict.noContentYet : "No content yet"
80
+ },
81
+ defaultActive: typeof props.defaultActive === "string" && props.defaultActive.trim().length > 0 ? props.defaultActive : String((_a = tabs[0].id) != null ? _a : "overview"),
82
+ keepMounted: typeof props.keepMounted === "boolean" ? props.keepMounted : true,
83
+ urlSync: normalizedUrlSync
84
+ };
85
+ };
86
+
87
+ // src/renderBindingProps.ts
88
+ var RENDER_BINDING_PROP_NAMES = /* @__PURE__ */ new Set([
89
+ "bindingEnabled",
90
+ "valueBindingKey",
91
+ "optionsBindingKey",
92
+ "useBindingData",
93
+ "entitiesBindingKey",
94
+ "videoBindingKey",
95
+ "mapBindingKey",
96
+ "productBindingKey",
97
+ "useTranslationKeys",
98
+ "tagContentTranslationKey",
99
+ "tagContentTranslationValue",
100
+ "hrefTranslationKey",
101
+ "hrefTranslationValue",
102
+ "mediaSource",
103
+ "mediaSrc",
104
+ "mediaAlt",
105
+ "rowsBindingKey",
106
+ "columnsBindingKey"
107
+ ]);
108
+ var getRenderLayerBindingProps = (props) => {
109
+ if (!props || typeof props !== "object" || Array.isArray(props)) {
110
+ return {};
111
+ }
112
+ const source = props;
113
+ const embedded = source.__studio && typeof source.__studio === "object" && !Array.isArray(source.__studio) ? source.__studio : {};
114
+ const legacy = Array.from(RENDER_BINDING_PROP_NAMES).reduce(
115
+ (accumulator, key) => {
116
+ if (source[key] !== void 0) {
117
+ accumulator[key] = source[key];
118
+ }
119
+ return accumulator;
120
+ },
121
+ {}
122
+ );
123
+ return Array.from(RENDER_BINDING_PROP_NAMES).reduce((accumulator, key) => {
124
+ if (legacy[key] !== void 0) {
125
+ accumulator[key] = legacy[key];
126
+ } else if (embedded[key] !== void 0) {
127
+ accumulator[key] = embedded[key];
128
+ }
129
+ return accumulator;
130
+ }, {});
131
+ };
132
+
133
+ // src/runtimeBindings.ts
134
+ var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
135
+ var MISSING_TRANSLATION_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
136
+ var MISSING_REF_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
137
+ var isPlainObject = (value) => {
138
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
139
+ const prototype = Object.getPrototypeOf(value);
140
+ return prototype === Object.prototype || prototype === null;
141
+ };
142
+ var isReactElementLike = (value) => isPlainObject(value) && typeof value.$$typeof === "symbol" && "props" in value;
143
+ var isTranslationValue = (value) => isPlainObject(value) && typeof value.$t === "string";
144
+ var isRefValue = (value) => isPlainObject(value) && typeof value.$ref === "string";
145
+ var isExprValue = (value) => isPlainObject(value) && typeof value.$expr === "string";
146
+ var parseStructuredString = (value) => {
147
+ if (typeof value !== "string") return value;
148
+ const trimmed = value.trim();
149
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return value;
150
+ try {
151
+ const parsed = JSON.parse(trimmed);
152
+ if (!isPlainObject(parsed)) return value;
153
+ if ((typeof parsed.$ref === "string" || typeof parsed.$t === "string") && Object.keys(parsed).length >= 1) {
154
+ return parsed;
155
+ }
156
+ return value;
157
+ } catch {
158
+ return value;
159
+ }
160
+ };
161
+ var resolveRenderLayerValue = (value, runtime) => {
162
+ const normalizedValue = parseStructuredString(value);
163
+ if (isTranslationValue(normalizedValue)) {
164
+ const fallback = typeof normalizedValue.defaultValue === "string" && normalizedValue.defaultValue.trim() ? normalizedValue.defaultValue : normalizedValue.$t;
165
+ if (!runtime.t) return fallback || MISSING_TRANSLATION_FALLBACK;
166
+ const translated = runtime.t(normalizedValue.$t, normalizedValue.values);
167
+ if (typeof translated !== "string") return fallback || MISSING_TRANSLATION_FALLBACK;
168
+ if (!translated.trim()) return fallback || MISSING_TRANSLATION_FALLBACK;
169
+ if (translated === normalizedValue.$t) return fallback || MISSING_TRANSLATION_FALLBACK;
170
+ return translated;
171
+ }
172
+ if (isRefValue(normalizedValue)) {
173
+ const resolved = runtime.get(normalizedValue.$ref);
174
+ if (resolved == null) return MISSING_REF_FALLBACK;
175
+ if (typeof resolved === "string" && !resolved.trim()) return MISSING_REF_FALLBACK;
176
+ return resolved;
177
+ }
178
+ if (isExprValue(normalizedValue)) {
179
+ return void 0;
180
+ }
181
+ if (Array.isArray(normalizedValue)) {
182
+ return normalizedValue.map((item) => resolveRenderLayerValue(item, runtime));
183
+ }
184
+ if (isReactElementLike(normalizedValue)) {
185
+ return normalizedValue;
186
+ }
187
+ if (isPlainObject(normalizedValue)) {
188
+ const next = {};
189
+ Object.entries(normalizedValue).forEach(([key, childValue]) => {
190
+ if (DANGEROUS_KEYS.has(key)) return;
191
+ next[key] = resolveRenderLayerValue(childValue, runtime);
192
+ });
193
+ return next;
194
+ }
195
+ return normalizedValue;
196
+ };
197
+ var resolveRenderLayerNodeProps = (props, runtime) => {
198
+ if (!props) return {};
199
+ const resolved = {};
200
+ Object.entries(props).forEach(([key, value]) => {
201
+ if (DANGEROUS_KEYS.has(key)) return;
202
+ resolved[key] = resolveRenderLayerValue(value, runtime);
203
+ });
204
+ return resolved;
205
+ };
206
+ var bindRenderLayerNodeEvents = (events, runtime) => {
207
+ if (!events) return {};
208
+ const handlers = {};
209
+ const extractDynamicPayload = (eventName, args) => {
210
+ var _a;
211
+ if (eventName !== "onChange") return void 0;
212
+ const firstArg = args[0];
213
+ if (!firstArg || typeof firstArg !== "object" || !("target" in firstArg)) {
214
+ return void 0;
215
+ }
216
+ const target = firstArg.target;
217
+ if (!target) return void 0;
218
+ const isCheckboxType = String((_a = target.type) != null ? _a : "").toLowerCase() === "checkbox";
219
+ const query = isCheckboxType ? target.checked : target.value;
220
+ return {
221
+ query,
222
+ value: target.value,
223
+ checked: target.checked
224
+ };
225
+ };
226
+ Object.entries(events).forEach(([eventName, action]) => {
227
+ if (!action) return;
228
+ handlers[eventName] = (...args) => {
229
+ const actionRef = action;
230
+ const dynamicPayload = extractDynamicPayload(eventName, args);
231
+ if (!dynamicPayload) {
232
+ runtime.dispatch(actionRef);
233
+ return;
234
+ }
235
+ if ("id" in actionRef) {
236
+ const basePayload = actionRef.payload && typeof actionRef.payload === "object" ? actionRef.payload : {};
237
+ runtime.dispatch({
238
+ ...actionRef,
239
+ payload: {
240
+ ...basePayload,
241
+ ...dynamicPayload
242
+ }
243
+ });
244
+ return;
245
+ }
246
+ if ("type" in actionRef) {
247
+ const basePayload = actionRef.payload && typeof actionRef.payload === "object" ? actionRef.payload : {};
248
+ runtime.dispatch({
249
+ ...actionRef,
250
+ payload: {
251
+ ...basePayload,
252
+ ...dynamicPayload
253
+ }
254
+ });
255
+ return;
256
+ }
257
+ runtime.dispatch(actionRef);
258
+ };
259
+ });
260
+ return handlers;
261
+ };
262
+
263
+ // src/resolveChildContentDescriptor.ts
264
+ var resolveChildContentDescriptor = ({
265
+ childDescriptors
266
+ }) => {
267
+ if (childDescriptors.length === 0) {
268
+ return { kind: "empty" };
269
+ }
270
+ if (childDescriptors.length === 1) {
271
+ return {
272
+ kind: "single",
273
+ child: childDescriptors[0]
274
+ };
275
+ }
276
+ return {
277
+ kind: "list",
278
+ children: childDescriptors
279
+ };
280
+ };
281
+
282
+ // src/resolveChildDescriptors.ts
283
+ var resolveChildDescriptors = ({
284
+ node,
285
+ internalStudioNodeTypes
286
+ }) => {
287
+ var _a, _b;
288
+ const renderableChildren = (_a = node.children) == null ? void 0 : _a.filter(
289
+ (child) => !internalStudioNodeTypes.has(child.type)
290
+ );
291
+ return (_b = renderableChildren == null ? void 0 : renderableChildren.map((child) => {
292
+ var _a2, _b2;
293
+ if (node.type === "Grid") {
294
+ const childLayout = readRenderLayerNodeLayout(
295
+ (_a2 = child.props) != null ? _a2 : {}
296
+ );
297
+ return {
298
+ kind: "grid-item",
299
+ child,
300
+ colSpan: (_b2 = childLayout.colSpan) != null ? _b2 : 12
301
+ };
302
+ }
303
+ return {
304
+ kind: "node",
305
+ child
306
+ };
307
+ })) != null ? _b : [];
308
+ };
309
+
310
+ // src/resolveCoverContentDescriptor.ts
311
+ var resolveCoverContentDescriptor = ({
312
+ rawChildren
313
+ }) => ({
314
+ actionNodes: rawChildren.filter((child) => child.type === "Button" || child.type === "Link"),
315
+ contentNodes: rawChildren.filter((child) => child.type !== "Button" && child.type !== "Link")
316
+ });
317
+
318
+ // src/resolveContentCompositionPlan.ts
319
+ var resolveContentCompositionPlan = ({
320
+ node,
321
+ isStudioRendererContext,
322
+ internalStudioNodeTypes
323
+ }) => {
324
+ var _a, _b, _c, _d;
325
+ const plans = [];
326
+ if (node.type === "Button") {
327
+ const rawEnableEventOnClick = (_a = node.props) == null ? void 0 : _a.buttonEnableEventOnClick;
328
+ const hasExplicitToggle = rawEnableEventOnClick !== void 0;
329
+ const enableEventOnClick = typeof rawEnableEventOnClick === "boolean" ? rawEnableEventOnClick : typeof rawEnableEventOnClick === "string" ? rawEnableEventOnClick.toLowerCase() === "true" : Boolean(rawEnableEventOnClick);
330
+ if (hasExplicitToggle && !enableEventOnClick) {
331
+ plans.push({
332
+ kind: "button-toggle",
333
+ disableOnClick: true
334
+ });
335
+ }
336
+ }
337
+ if (node.type === "FormField") {
338
+ plans.push({ kind: "form-field" });
339
+ }
340
+ if (node.type === "Form" && isStudioRendererContext) {
341
+ plans.push({
342
+ kind: "studio-form",
343
+ visibleChildren: ((_b = node.children) != null ? _b : []).filter(
344
+ (child) => !internalStudioNodeTypes.has(child.type)
345
+ )
346
+ });
347
+ }
348
+ if (node.type === "Cover") {
349
+ const rawChildren = ((_c = node.children) != null ? _c : []).filter(
350
+ (child) => !internalStudioNodeTypes.has(child.type)
351
+ );
352
+ plans.push({
353
+ kind: "cover-content",
354
+ rawChildren,
355
+ descriptor: resolveCoverContentDescriptor({
356
+ rawChildren
357
+ })
358
+ });
359
+ }
360
+ if (node.type === "ScrollReveal") {
361
+ plans.push({
362
+ kind: "scroll-reveal",
363
+ rawChildren: ((_d = node.children) != null ? _d : []).filter(
364
+ (child) => !internalStudioNodeTypes.has(child.type)
365
+ )
366
+ });
367
+ }
368
+ return plans;
369
+ };
370
+
371
+ // src/resolveFinalRenderPlan.ts
372
+ var resolveFinalRenderPlan = ({
373
+ node,
374
+ componentProps,
375
+ isStudioRendererContext,
376
+ studioSizing
377
+ }) => {
378
+ const plans = [];
379
+ if (studioSizing) {
380
+ const existingStyle = componentProps.style && typeof componentProps.style === "object" && !Array.isArray(componentProps.style) ? componentProps.style : {};
381
+ const nextStyle = { ...existingStyle };
382
+ if (studioSizing.widthPct !== null) {
383
+ nextStyle.width = "100%";
384
+ nextStyle.maxWidth = "100%";
385
+ }
386
+ if (studioSizing.heightPx !== null) {
387
+ nextStyle.height = `${studioSizing.heightPx}px`;
388
+ } else if (studioSizing.heightPct !== null) {
389
+ nextStyle.height = `${studioSizing.heightPct}%`;
390
+ }
391
+ plans.push({
392
+ kind: "style-sizing",
393
+ style: nextStyle
394
+ });
395
+ }
396
+ if (node.type === "Link" && isStudioRendererContext) {
397
+ plans.push({ kind: "configure-studio-link" });
398
+ }
399
+ plans.push({ kind: "cleanup-studio-props" });
400
+ if (node.type === "Table") {
401
+ plans.push({ kind: "table-fallback" });
402
+ }
403
+ return plans;
404
+ };
405
+
406
+ // src/resolveNodeBase.ts
407
+ var shouldInferImplicitGridCols = (node, componentProps, childDescriptors) => {
408
+ if (node.type !== "Grid") return false;
409
+ const explicitCols = componentProps.cols;
410
+ if (explicitCols !== void 0 && explicitCols !== null && String(explicitCols).trim() !== "") {
411
+ return false;
412
+ }
413
+ return childDescriptors.some(
414
+ (descriptor) => descriptor.kind === "grid-item" && typeof descriptor.colSpan === "number"
415
+ );
416
+ };
417
+ var resolveNodeBase = ({
418
+ node,
419
+ runtime,
420
+ internalStudioNodeTypes
421
+ }) => {
422
+ const resolvedProps = resolveRenderLayerNodeProps(node.props, runtime);
423
+ const eventHandlers = bindRenderLayerNodeEvents(node.events, runtime);
424
+ const childDescriptors = resolveChildDescriptors({
425
+ node,
426
+ internalStudioNodeTypes
427
+ });
428
+ const childContentDescriptor = resolveChildContentDescriptor({
429
+ childDescriptors
430
+ });
431
+ const componentProps = {
432
+ ...resolvedProps,
433
+ ...eventHandlers
434
+ };
435
+ if (shouldInferImplicitGridCols(node, componentProps, childDescriptors)) {
436
+ componentProps.cols = 12;
437
+ }
438
+ const renderBindingProps = getRenderLayerBindingProps(componentProps);
439
+ return createResolvedNodeBase({
440
+ node,
441
+ componentProps,
442
+ renderBindingProps,
443
+ childDescriptors,
444
+ childContentDescriptor
445
+ });
446
+ };
447
+
448
+ // src/resolveNavigationContentDescriptors.ts
449
+ var resolveAccordionItemDescriptors = ({
450
+ accordionChildren
451
+ }) => accordionChildren.map((child, index) => {
452
+ var _a, _b, _c, _d, _e, _f;
453
+ const childProps = (_a = child.props) != null ? _a : {};
454
+ const contentNodes = (_b = child.children) != null ? _b : [];
455
+ const hasContentNodes = contentNodes.length > 0;
456
+ return {
457
+ id: String((_d = (_c = childProps.id) != null ? _c : child.id) != null ? _d : `item-${index + 1}`),
458
+ title: String((_e = childProps.title) != null ? _e : `Section ${index + 1}`),
459
+ disabled: Boolean(childProps.disabled),
460
+ contentKind: hasContentNodes ? "nodes" : "text",
461
+ contentText: hasContentNodes ? null : String((_f = childProps.content) != null ? _f : ""),
462
+ contentNodes
463
+ };
464
+ });
465
+ var resolveExpandablePanelContentDescriptor = ({
466
+ panelChildren
467
+ }) => panelChildren.length === 0 ? {
468
+ kind: "empty",
469
+ nodes: []
470
+ } : {
471
+ kind: "nodes",
472
+ nodes: panelChildren
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
+ RENDER_BINDING_PROP_NAMES,
705
+ bindRenderLayerNodeEvents,
706
+ createResolvedNode,
707
+ createResolvedNodeBase,
708
+ getRenderLayerBindingProps,
709
+ normalizeRenderLayerTabsProps,
710
+ readRenderLayerNodeLayout,
711
+ resolveAccordionItemDescriptors,
712
+ resolveChildContentDescriptor,
713
+ resolveChildDescriptors,
714
+ resolveContentCompositionPlan,
715
+ resolveCoverContentDescriptor,
716
+ resolveExpandablePanelContentDescriptor,
717
+ resolveFinalRenderPlan,
718
+ resolveNavigationCompositionPlan,
719
+ resolveNodeBase,
720
+ resolveRenderDirectivePlan,
721
+ resolveRenderLayerNodeProps,
722
+ resolveRenderLayerValue,
723
+ resolveResolvedNode,
724
+ resolveTabsContentDescriptors
725
+ };