@bravostudioai/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/bin/encore-lib.js +3 -0
  2. package/dist/_virtual/_commonjsHelpers.js +7 -0
  3. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  4. package/dist/_virtual/main.js +8 -0
  5. package/dist/_virtual/main.js.map +1 -0
  6. package/dist/_virtual/main2.js +5 -0
  7. package/dist/_virtual/main2.js.map +1 -0
  8. package/dist/app.js +9 -0
  9. package/dist/app.js.map +1 -0
  10. package/dist/cli/commands/download.js +82 -0
  11. package/dist/cli/commands/download.js.map +1 -0
  12. package/dist/cli/commands/generate.js +1526 -0
  13. package/dist/cli/commands/generate.js.map +1 -0
  14. package/dist/cli.js +25 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/components/DynamicComponent.js +24 -0
  17. package/dist/components/DynamicComponent.js.map +1 -0
  18. package/dist/components/EncoreApp.js +259 -0
  19. package/dist/components/EncoreApp.js.map +1 -0
  20. package/dist/components/EncoreErrorBoundary.js +33 -0
  21. package/dist/components/EncoreErrorBoundary.js.map +1 -0
  22. package/dist/components/EncoreLoadingFallback.js +20 -0
  23. package/dist/components/EncoreLoadingFallback.js.map +1 -0
  24. package/dist/components.js +1454 -0
  25. package/dist/components.js.map +1 -0
  26. package/dist/constants.d.ts +3 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/contexts/EncoreActionContext.js +6 -0
  29. package/dist/contexts/EncoreActionContext.js.map +1 -0
  30. package/dist/contexts/EncoreAppContext.js +9 -0
  31. package/dist/contexts/EncoreAppContext.js.map +1 -0
  32. package/dist/contexts/EncoreBindingContext.js +6 -0
  33. package/dist/contexts/EncoreBindingContext.js.map +1 -0
  34. package/dist/contexts/EncoreComponentIdContext.js +8 -0
  35. package/dist/contexts/EncoreComponentIdContext.js.map +1 -0
  36. package/dist/contexts/EncoreRepeatingContainerContext.js +6 -0
  37. package/dist/contexts/EncoreRepeatingContainerContext.js.map +1 -0
  38. package/dist/hooks/usePusherUpdates.js +60 -0
  39. package/dist/hooks/usePusherUpdates.js.map +1 -0
  40. package/dist/index.js +16 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/lib/dynamicModules.js +132 -0
  43. package/dist/lib/dynamicModules.js.map +1 -0
  44. package/dist/lib/fetcher.js +58 -0
  45. package/dist/lib/fetcher.js.map +1 -0
  46. package/dist/lib/localMode.js +21 -0
  47. package/dist/lib/localMode.js.map +1 -0
  48. package/dist/lib/packages.js +18 -0
  49. package/dist/lib/packages.js.map +1 -0
  50. package/dist/node_modules/dotenv/lib/main.js +198 -0
  51. package/dist/node_modules/dotenv/lib/main.js.map +1 -0
  52. package/dist/node_modules/dotenv/package.json.js +8 -0
  53. package/dist/node_modules/dotenv/package.json.js.map +1 -0
  54. package/dist/packages/encore-lib/constants.js +6 -0
  55. package/dist/packages/encore-lib/constants.js.map +1 -0
  56. package/dist/src/app.d.ts +5 -0
  57. package/dist/src/app.d.ts.map +1 -0
  58. package/dist/src/cli/commands/download.d.ts +2 -0
  59. package/dist/src/cli/commands/download.d.ts.map +1 -0
  60. package/dist/src/cli/commands/generate.d.ts +2 -0
  61. package/dist/src/cli/commands/generate.d.ts.map +1 -0
  62. package/dist/src/cli/index.d.ts +2 -0
  63. package/dist/src/cli/index.d.ts.map +1 -0
  64. package/dist/src/components/DynamicComponent.d.ts +12 -0
  65. package/dist/src/components/DynamicComponent.d.ts.map +1 -0
  66. package/dist/src/components/EncoreApp.d.ts +27 -0
  67. package/dist/src/components/EncoreApp.d.ts.map +1 -0
  68. package/dist/src/components/EncoreErrorBoundary.d.ts +17 -0
  69. package/dist/src/components/EncoreErrorBoundary.d.ts.map +1 -0
  70. package/dist/src/components/EncoreLoadingFallback.d.ts +4 -0
  71. package/dist/src/components/EncoreLoadingFallback.d.ts.map +1 -0
  72. package/dist/src/components.d.ts +4 -0
  73. package/dist/src/components.d.ts.map +1 -0
  74. package/dist/src/contexts/EncoreActionContext.d.ts +13 -0
  75. package/dist/src/contexts/EncoreActionContext.d.ts.map +1 -0
  76. package/dist/src/contexts/EncoreAppContext.d.ts +8 -0
  77. package/dist/src/contexts/EncoreAppContext.d.ts.map +1 -0
  78. package/dist/src/contexts/EncoreBindingContext.d.ts +5 -0
  79. package/dist/src/contexts/EncoreBindingContext.d.ts.map +1 -0
  80. package/dist/src/contexts/EncoreComponentIdContext.d.ts +8 -0
  81. package/dist/src/contexts/EncoreComponentIdContext.d.ts.map +1 -0
  82. package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts +21 -0
  83. package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts.map +1 -0
  84. package/dist/src/hooks/useAuthRedirect.d.ts +3 -0
  85. package/dist/src/hooks/useAuthRedirect.d.ts.map +1 -0
  86. package/dist/src/hooks/usePusherUpdates.d.ts +18 -0
  87. package/dist/src/hooks/usePusherUpdates.d.ts.map +1 -0
  88. package/dist/src/index.d.ts +8 -0
  89. package/dist/src/index.d.ts.map +1 -0
  90. package/dist/src/lib/dynamicModules.d.ts +8 -0
  91. package/dist/src/lib/dynamicModules.d.ts.map +1 -0
  92. package/dist/src/lib/fetcher.d.ts +5 -0
  93. package/dist/src/lib/fetcher.d.ts.map +1 -0
  94. package/dist/src/lib/localMode.d.ts +3 -0
  95. package/dist/src/lib/localMode.d.ts.map +1 -0
  96. package/dist/src/lib/packages.d.ts +6 -0
  97. package/dist/src/lib/packages.d.ts.map +1 -0
  98. package/dist/src/stores/useEncoreState.d.ts +33 -0
  99. package/dist/src/stores/useEncoreState.d.ts.map +1 -0
  100. package/dist/stores/useEncoreState.js +70 -0
  101. package/dist/stores/useEncoreState.js.map +1 -0
  102. package/package.json +60 -0
  103. package/src/AGENTS.md +161 -0
  104. package/src/README.md +110 -0
  105. package/src/app.ts +5 -0
  106. package/src/cli/commands/download.ts +133 -0
  107. package/src/cli/commands/generate.ts +3045 -0
  108. package/src/cli/index.ts +35 -0
  109. package/src/components/DynamicComponent.tsx +40 -0
  110. package/src/components/EncoreApp.tsx +759 -0
  111. package/src/components/EncoreErrorBoundary.tsx +49 -0
  112. package/src/components/EncoreLoadingFallback.tsx +25 -0
  113. package/src/components.tsx +3155 -0
  114. package/src/contexts/EncoreActionContext.ts +18 -0
  115. package/src/contexts/EncoreAppContext.ts +13 -0
  116. package/src/contexts/EncoreBindingContext.ts +6 -0
  117. package/src/contexts/EncoreComponentIdContext.ts +12 -0
  118. package/src/contexts/EncoreRepeatingContainerContext.ts +30 -0
  119. package/src/hooks/useAuthRedirect.ts +63 -0
  120. package/src/hooks/usePusherUpdates.ts +156 -0
  121. package/src/index.ts +16 -0
  122. package/src/lib/dynamicModules.ts +193 -0
  123. package/src/lib/fetcher.ts +108 -0
  124. package/src/lib/localMode.ts +30 -0
  125. package/src/lib/moduleRegistry.ts +24 -0
  126. package/src/lib/packages.ts +33 -0
  127. package/src/stores/useEncoreState.ts +121 -0
@@ -0,0 +1,1454 @@
1
+ import { jsx as h, jsxs as it, Fragment as ut } from "react/jsx-runtime";
2
+ import v, { useContext as G, useMemo as zt, useState as Ht, useCallback as Vt } from "react";
3
+ import Q from "./contexts/EncoreBindingContext.js";
4
+ import z from "./stores/useEncoreState.js";
5
+ import lt from "./contexts/EncoreComponentIdContext.js";
6
+ import Nt from "axios";
7
+ import Lt from "./contexts/EncoreActionContext.js";
8
+ import Ot from "./contexts/EncoreRepeatingContainerContext.js";
9
+ const ct = v.createContext({}), O = v.createContext(
10
+ {}
11
+ ), st = (t) => t.replace(/#(\w{2})(\w{6})/, "#$2$1"), Mt = (t) => t.slice(1, 3) === "00", jt = (t) => {
12
+ if (!Array.isArray(t)) return null;
13
+ const r = t.find((o) => o.startsWith("input-group:"));
14
+ if (!r) return null;
15
+ const e = r.split(":");
16
+ return e.length >= 3 ? { type: e[1], groupName: e[2] } : null;
17
+ }, rt = () => {
18
+ const [t, r] = Ht({ width: 0, height: 0 }), e = v.useRef(null);
19
+ return v.useEffect(() => {
20
+ if (!e.current) return;
21
+ const o = e.current, i = () => {
22
+ const { width: a, height: n } = o.getBoundingClientRect();
23
+ r({ width: a, height: n });
24
+ };
25
+ i(), requestAnimationFrame(() => {
26
+ i();
27
+ });
28
+ const d = new ResizeObserver((a) => {
29
+ for (const n of a) {
30
+ const c = n.contentRect;
31
+ r({ width: c.width, height: c.height });
32
+ }
33
+ });
34
+ return d.observe(o), () => d.disconnect();
35
+ }, []), { dimensions: t, ref: e };
36
+ }, R = (t, r = {}) => {
37
+ let e = !1;
38
+ const o = G(ct), i = G(O), d = {
39
+ width: window.innerWidth,
40
+ height: window.innerHeight
41
+ }, a = Vt(
42
+ (l) => (i.dimensions?.width ?? 0) * 0.01 * l,
43
+ [i.dimensions?.width]
44
+ ), n = {};
45
+ r = { debug: !1, ...r };
46
+ const c = z((l) => l.fontsById || {});
47
+ if (z((l) => l.fontsByIdFull || {}), !t) return;
48
+ const y = i.dimensions?.width ?? d.width, S = i.dimensions?.height ?? d.height;
49
+ if (t.layout?.layoutSizingHorizontal || t.layout?.layoutSizingVertical || (t.width && y > 0 && (n.width = t.width * y * 0.01), t.aspectRatio && t.width ? y > 0 && (n.height = t.width * y * 0.01 / t.aspectRatio) : t.height && S > 0 && (n.height = t.height * S * 0.01)), !(i?.isFlex ?? !1) && t.positioning) {
50
+ const l = t.layout?.layoutSizingHorizontal === "FIXED" || t.layout?.layoutSizingVertical === "FIXED", g = l && t.positioning.top < 0 ? 0 : t.positioning.top, I = l && t.positioning.left < 0 ? 0 : t.positioning.left;
51
+ if (l && t.layout?.layoutSizingHorizontal === "FIXED" && t.layout?.size?.x) {
52
+ const F = t.layout.size.x, E = o.scaleFactor ?? 1, s = F * E, W = i?.dimensions?.width;
53
+ W && typeof W == "number" && W > 0 && s / W >= 0.95 && I >= 15 && I <= 35 && (e = !0);
54
+ }
55
+ n.top = `${g}%`;
56
+ const A = !!t.inset;
57
+ if (e)
58
+ if (A) {
59
+ const F = String(t.inset).split(/\s+/);
60
+ F.length === 3 ? n.inset = `${F[0]} 50% ${F[2]} auto` : F.length === 4 && (n.inset = `${F[0]} 50% ${F[2]} auto`), delete n.left, delete n.right;
61
+ } else
62
+ n.left = "50%", n.right = "auto";
63
+ else
64
+ A ? n.inset = t.inset : n.left = `${I}%`;
65
+ l ? (n.right = "auto", n.bottom = "auto") : (t.positioning.bottom !== void 0 && (n.bottom = `${t.positioning.bottom}%`), t.positioning.right !== void 0 && (n.right = `${t.positioning.right}%`)), n.position = "absolute";
66
+ }
67
+ if (t.layout?.padding) {
68
+ const l = o.scaleFactor ?? 1, g = t.layout.padding;
69
+ g.top !== void 0 && (n.paddingTop = g.top * l), g.right !== void 0 && (n.paddingRight = g.right * l), g.bottom !== void 0 && (n.paddingBottom = g.bottom * l), g.left !== void 0 && (n.paddingLeft = g.left * l);
70
+ }
71
+ if (t.layout?.mode) {
72
+ n.display = "flex";
73
+ const l = (E) => E ? {
74
+ MIN: "flex-start",
75
+ MAX: "flex-end",
76
+ CENTER: "center",
77
+ SPACE_BETWEEN: "space-between",
78
+ SPACE_AROUND: "space-around",
79
+ SPACE_EVENLY: "space-evenly"
80
+ }[E] || E.toLowerCase().replace(/_/g, "-") : void 0;
81
+ t.layout.mode == "HORIZONTAL" ? (n.flexDirection = "row", t.layout.flexWrap && (n.flexWrap = t.layout.flexWrap), n.justifyContent = l(
82
+ t.layout.primaryAxisAlignItems
83
+ ), n.alignItems = t.layout.counterAxisAlignItems) : (n.flexDirection = "column", n.justifyContent = l(
84
+ t.layout.primaryAxisAlignItems
85
+ ), n.alignItems = t.layout.counterAxisAlignItems), n.flexGrow = t.layout.grow, t.layout.wrap === "NO_WRAP" ? n.flexWrap = "nowrap" : t.layout.flexWrap ? n.flexWrap = t.layout.flexWrap : n.flexWrap = "wrap";
86
+ const g = t.layout.itemSpacing, I = o.scaleFactor ?? 1, F = t.layout.primaryAxisAlignItems === "SPACE_BETWEEN" ? 0 : (g !== void 0 ? g : 0) * I;
87
+ n.gap = F === 0 ? "0px" : `${F}px`, n.rowGap = F === 0 ? "0px" : `${F}px`, n.columnGap = F === 0 ? "0px" : `${F}px`, (n.flexWrap === "wrap" || n.flexWrap === "wrap-reverse") && (n.alignContent = "flex-start"), r.debug || t.layout?.mode === "HORIZONTAL" && g === 0 ? console.log("[useEncoreStyle] Setting gap properties:", {
88
+ itemSpacing: g,
89
+ spacing: F,
90
+ gap: n.gap,
91
+ rowGap: n.rowGap,
92
+ columnGap: n.columnGap,
93
+ hasLayout: !!t.layout,
94
+ layoutMode: t.layout?.mode
95
+ }) : console.log(
96
+ "[useEncoreStyle] No gap properties set",
97
+ r.debug,
98
+ t.layout?.mode,
99
+ g
100
+ );
101
+ }
102
+ if (t.layout?.layoutSizingHorizontal === "FILL" && (n.width = "100%"), t.layout?.layoutSizingHorizontal === "FIXED") {
103
+ const l = o.scaleFactor ?? 1;
104
+ n.width = t.layout.size.x * l;
105
+ }
106
+ if (t.layout?.layoutSizingVertical === "FIXED") {
107
+ const l = o.scaleFactor ?? 1;
108
+ n.height = t.layout.size.y * l;
109
+ }
110
+ if (t.layout?.layoutSizingVertical === "FILL")
111
+ if (!(i?.isFlex ?? !1) && t.positioning && t.positioning?.top !== void 0) {
112
+ const A = 100 - t.positioning.top;
113
+ n.height = `${A}%`;
114
+ } else
115
+ n.height = "100%";
116
+ if (t.layout?.layoutSizingVertical, t.backgroundColor && !Mt(t.backgroundColor) && (n.backgroundColor = st(t.backgroundColor)), t.color && (n.color = st(t.color)), t.lineHeightPx && (n.lineHeight = (t.lineHeightPx * (o.scaleFactor ?? 1)).toString() + "px"), t.fontSize && (n.fontSize = t.fontSize * (o.scaleFactor ?? 1)), t.fontWeight && (n.fontWeight = `${t.fontWeight}`), t.opacity && (n.opacity = t.opacity * 0.01), t.fontId) {
117
+ const l = c[t.fontId] || "sans-serif";
118
+ n.fontFamily = l;
119
+ }
120
+ if (t.borderRadius && (n.borderRadius = a(t.borderRadius)), t.cornerRadii) {
121
+ const l = t.cornerRadii.map(a);
122
+ n.borderTopLeftRadius = l[0], n.borderTopRightRadius = l[1], n.borderBottomRightRadius = l[2], n.borderBottomLeftRadius = l[3], delete n.borderRadius;
123
+ }
124
+ if (t.borderWidth && (t.borderWidth > 5 ? n.borderWidth = t.borderWidth * 0.5 : n.borderWidth = t.borderWidth * 1.5), t.borderColor && (n.borderColor = st(t.borderColor)), (t.borderWidth || t.borderColor) && (n.borderStyle = "solid"), t.rotation && (n.transform = `rotate(${t.rotation}deg)`), e) {
125
+ const l = n.transform || "";
126
+ if (n.transform = l ? `${l} translateX(-50%)` : "translateX(-50%)", n.inset) {
127
+ const g = String(n.inset).split(/\s+/);
128
+ g.length === 3 ? n.inset = `${g[0]} 50% ${g[2]} auto` : g.length === 4 && (n.inset = `${g[0]} 50% ${g[2]} auto`);
129
+ } else if (t.inset) {
130
+ const g = String(t.inset).split(/\s+/);
131
+ g.length === 3 ? n.inset = `${g[0]} 50% ${g[2]} auto` : g.length === 4 && (n.inset = `${g[0]} 50% ${g[2]} auto`);
132
+ }
133
+ }
134
+ if (t.textCase === "upper" && (n.textTransform = "uppercase"), t.textCase === "lower" && (n.textTransform = "lowercase"), t.letterSpacing && (n.letterSpacing = t.letterSpacing), t.textAlign && (n.textAlign = t.textAlign), r.debug && (n.borderWidth = 1, n.borderColor = "#FF0000FF", n.borderStyle = "solid"), e && (n.inset || t.inset)) {
135
+ const l = n.inset || t.inset, g = String(l).split(/\s+/);
136
+ g.length === 3 ? n.inset = `${g[0]} 50% ${g[2]} auto` : g.length === 4 && (n.inset = `${g[0]} 50% ${g[2]} auto`);
137
+ }
138
+ return n;
139
+ }, tt = ({ id: t, nodeData: r }) => {
140
+ const e = G(Q), o = e?.nodeData?.[t], { patch: i, list: d } = o ?? { list: null, patch: null }, n = Array.isArray(r?.tags) && (r.tags.includes("encore:data:array") || r.tags.includes("bravo:data:array")) && e?.arrayDataById && e.arrayDataById[t] && Array.isArray(e.arrayDataById[t]) ? e.arrayDataById[t] : null;
141
+ let c = i ? {
142
+ ...r,
143
+ ...i || {},
144
+ ...i && i.data ? { data: { ...r?.data || {}, ...i.data } } : {},
145
+ // Preserve original actions if patch has empty or missing actions
146
+ actions: i.actions && Array.isArray(i.actions) && i.actions.length > 0 ? i.actions : r.actions || i.actions || []
147
+ } : r;
148
+ const y = e?.textOverridesById && e.textOverridesById[t] !== void 0 ? e.textOverridesById[t] : void 0;
149
+ y !== void 0 && Array.isArray(r?.tags) && r.tags.includes("PROP:TEXT_VAR") && (c = {
150
+ ...c,
151
+ data: { ...c?.data || {}, text: String(y) }
152
+ });
153
+ const S = Array.isArray(r?.tags) && (r.tags.includes("encore:data") || r.tags.includes("bravo:data")), f = e?.rootData;
154
+ f && f[t] && typeof f[t] == "object" && (c = {
155
+ ...c,
156
+ data: {
157
+ ...c.data || {},
158
+ ...f[t]
159
+ }
160
+ });
161
+ const b = e?.nodeData && typeof e.nodeData == "object";
162
+ if (S || b) {
163
+ const l = e?.nodeData;
164
+ if (l && typeof l == "object") {
165
+ if (l[t] !== void 0) {
166
+ const I = l[t];
167
+ I && typeof I == "object" && c.data && (c = {
168
+ ...c,
169
+ data: {
170
+ ...c.data,
171
+ ...I
172
+ }
173
+ });
174
+ } else if (S && l.description && c.data && (c = {
175
+ ...c,
176
+ data: {
177
+ ...c.data,
178
+ text: l.description
179
+ }
180
+ }), l.image && c.data) {
181
+ const I = l.image.startsWith("//") ? `https:${l.image}` : l.image;
182
+ c = {
183
+ ...c,
184
+ data: {
185
+ ...c.data,
186
+ imageUrl: I
187
+ }
188
+ };
189
+ }
190
+ c.encoreData = l;
191
+ }
192
+ }
193
+ return {
194
+ patch: i,
195
+ list: d || n,
196
+ // Use arrayData if list is not provided
197
+ patchedNodeData: c,
198
+ arrayData: n
199
+ // Also return separately for components that need it
200
+ };
201
+ }, q = ({
202
+ id: t,
203
+ nodeData: r,
204
+ children: e,
205
+ _parentStatefulSetId: o,
206
+ _parentInputGroupInfo: i,
207
+ _parentName: d
208
+ }) => {
209
+ const a = z((s) => s.baseURL), n = z((s) => s.appId);
210
+ z((s) => s.pageId);
211
+ const { onAction: c } = v.useContext(Lt), { statefulSetId: y } = v.useContext(
212
+ lt
213
+ ), S = o || y, { patchedNodeData: f } = tt({ id: t, nodeData: r }), b = z(
214
+ (s) => s.setStatefulSetVariant
215
+ ), l = z(
216
+ (s) => s.setInputGroupValue
217
+ ), g = z((s) => s.setAccessToken), { app: I } = z((s) => s.app);
218
+ I.data?.app?.startPageId, I.data?.app?.PageId;
219
+ const A = R(
220
+ {
221
+ positioning: r.style?.positioning
222
+ },
223
+ { debug: !1 }
224
+ );
225
+ A.zIndex = 99999, A.backgroundColor = "transparent", A.position = "absolute", A.top = "0", A.left = "0", A.right = "0", A.bottom = "0", A.width = "100%", A.height = "100%", A.pointerEvents = "auto", A.isolation = "isolate";
226
+ const F = async (s) => {
227
+ let W = !1;
228
+ const U = () => {
229
+ W = !1;
230
+ };
231
+ if (typeof c == "function")
232
+ try {
233
+ await c({ bravo: { cancel: U, action: s } }), W = !0;
234
+ } catch {
235
+ }
236
+ else
237
+ W = !0;
238
+ if (W)
239
+ switch (s.action) {
240
+ case "login":
241
+ // TODO firebase
242
+ // TODO oauth
243
+ // TODO actually check if this app has custom login
244
+ // For now, just assume it's a custom login (which is just a form submission)
245
+ // Intentional fallthrough
246
+ case "submit":
247
+ break;
248
+ case "email":
249
+ window.location.href = `mailto:${s.params.email}`;
250
+ break;
251
+ case "goback":
252
+ break;
253
+ case "goto":
254
+ break;
255
+ case "homepage":
256
+ break;
257
+ case "logout":
258
+ g(void 0);
259
+ break;
260
+ case "none":
261
+ break;
262
+ case "openurl":
263
+ window.open(s.params.url, "_blank");
264
+ break;
265
+ case "phone":
266
+ window.location.href = `tel:${s.params.phone}`;
267
+ break;
268
+ case "remote":
269
+ const M = btoa(JSON.stringify(s.params?.data || {})), Z = `${a}/devices/apps/${n}/node/${t}/trigger/${s.event}?params=${M}`, H = await Nt.post(Z);
270
+ H.data?.action && await F(H.data);
271
+ break;
272
+ case "set-access-token":
273
+ g(s.params);
274
+ break;
275
+ case "set-state":
276
+ if (i && d)
277
+ if (console.log("🔵 Input group change:", {
278
+ groupName: i.groupName,
279
+ elementName: d,
280
+ hasOnAction: typeof c == "function"
281
+ }), l(i.groupName, d), typeof c == "function")
282
+ try {
283
+ await c({
284
+ bravo: {
285
+ cancel: () => {
286
+ },
287
+ action: {
288
+ action: "input-group-change",
289
+ params: {
290
+ groupName: i.groupName,
291
+ groupType: i.type,
292
+ value: d
293
+ },
294
+ event: "tap"
295
+ }
296
+ }
297
+ }), console.log("✅ Input group change event fired");
298
+ } catch (P) {
299
+ console.error("❌ Error in onAction callback:", P);
300
+ }
301
+ else
302
+ console.warn("⚠️ No onAction callback provided");
303
+ else {
304
+ let P = S || s.params?.stateSetId || f.data?.stateSetId;
305
+ if (!P) {
306
+ console.error("❌ No stateSetId found in action or nodeData!", {
307
+ actionParams: s.params,
308
+ nodeDataStateSetId: f.data?.stateSetId,
309
+ parentStatefulSetId: S
310
+ });
311
+ break;
312
+ }
313
+ b(P, s.params.state);
314
+ }
315
+ break;
316
+ case "showalert":
317
+ alert(s.params.message);
318
+ break;
319
+ default:
320
+ console.log(s), alert(s.action);
321
+ }
322
+ };
323
+ if (r.href)
324
+ return /* @__PURE__ */ it(ut, { children: [
325
+ /* @__PURE__ */ h(
326
+ "button",
327
+ {
328
+ type: "button",
329
+ onClick: () => F({
330
+ action: "goto",
331
+ params: { href: r.href },
332
+ event: "tap"
333
+ }),
334
+ style: {
335
+ ...A,
336
+ cursor: "pointer",
337
+ background: "transparent",
338
+ border: "none",
339
+ padding: 0
340
+ },
341
+ "aria-label": `Go to ${r.href}`
342
+ }
343
+ ),
344
+ e
345
+ ] });
346
+ let E = f.actions && f.actions.length > 0 ? f.actions : r.actions || [];
347
+ if (S && E.length > 0 && (E = E.map((s) => s.action === "set-state" ? (s.params?.stateSetId, {
348
+ ...s,
349
+ params: {
350
+ ...s.params,
351
+ stateSetId: S
352
+ // Always use parent's id
353
+ }
354
+ }) : s)), E.length === 0 && (f.data?.stateSetId || S))
355
+ if (i && d)
356
+ E = [
357
+ {
358
+ action: "set-state",
359
+ params: {
360
+ state: "active"
361
+ // Will be handled by input group logic
362
+ },
363
+ event: "tap"
364
+ }
365
+ ];
366
+ else {
367
+ const s = S || f.data.stateSetId;
368
+ s ? E = [
369
+ {
370
+ action: "set-state",
371
+ params: {
372
+ state: z.getState().statefulSetVariants[s] === "active" ? "default" : "active",
373
+ stateSetId: s
374
+ // Use parent's id or button's stateSetId
375
+ },
376
+ event: "tap"
377
+ }
378
+ ] : console.warn(
379
+ "⚠️ No stateSetId available for stateful compound component",
380
+ { id: t, name: r.name }
381
+ );
382
+ }
383
+ if (E && E.length > 0) {
384
+ const s = E[0];
385
+ return s.event !== "tap" ? e : /* @__PURE__ */ it(ut, { children: [
386
+ e,
387
+ /* @__PURE__ */ h(
388
+ "div",
389
+ {
390
+ onClick: (W) => {
391
+ W.stopPropagation(), F(s);
392
+ },
393
+ onMouseDown: (W) => W.stopPropagation(),
394
+ onMouseUp: (W) => W.stopPropagation(),
395
+ style: { ...A, cursor: "pointer", pointerEvents: "auto" }
396
+ }
397
+ )
398
+ ] });
399
+ }
400
+ return e;
401
+ }, ht = ({ id: t, name: r, nodeData: e }) => {
402
+ const o = R(e.style, {
403
+ debug: !1
404
+ });
405
+ return /* @__PURE__ */ h(
406
+ "iframe",
407
+ {
408
+ "data-id": t,
409
+ "data-name": r,
410
+ "data-type": "WebViewComponent",
411
+ style: { border: "none", ...o },
412
+ src: e.data?.params?.url
413
+ }
414
+ );
415
+ }, ft = ({ id: t, name: r, nodeData: e }) => {
416
+ const o = R(e.style, {
417
+ debug: !1
418
+ });
419
+ if (!o.backgroundColor && !o.borderColor)
420
+ return null;
421
+ if (o.borderColor && !o.backgroundColor && (o.backgroundColor = "transparent"), o.borderColor && o.borderWidth) {
422
+ const S = Math.max(o.borderWidth || 0, 1);
423
+ (!o.width || typeof o.width == "number" && o.width === 0) && (o.width = S), (!o.height || typeof o.height == "number" && o.height === 0) && (o.height = S), o.boxSizing = "border-box";
424
+ }
425
+ const i = Array.isArray(e.tags) && e.tags.includes("bravo:layer"), d = G(O)?.isFlex ?? !1, a = e.style?.positioning, n = a && typeof a.top == "number" && typeof a.left == "number" && typeof a.right == "number" && typeof a.bottom == "number" && a.top === 0 && a.left === 0 && a.right === 0 && a.bottom === 0, c = i && (d || n), y = r && r.toLowerCase().startsWith("clip");
426
+ return c && (o.position = "absolute", o.top = 0, o.left = 0, o.right = 0, o.bottom = 0, o.zIndex = -1, o.width && typeof o.width == "string" && o.width.includes("%") && delete o.width, o.height && typeof o.height == "string" && o.height.includes("%") && delete o.height), y && (o.backgroundColor = "transparent"), /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h("div", { "data-name": r, "data-type": "ColorComponent", style: o }) });
427
+ }, gt = ({
428
+ id: t,
429
+ name: r,
430
+ nodeData: e
431
+ }) => {
432
+ const o = R(e.style, {
433
+ debug: !1
434
+ }), i = e.style, d = Array.isArray(i?.gradientColorStops) ? i.gradientColorStops.map((a) => {
435
+ if (!a?.color) return null;
436
+ const n = st(a.color);
437
+ if (typeof a.position == "number") {
438
+ const c = a.position * 100;
439
+ return `${n} ${c}%`;
440
+ }
441
+ return n;
442
+ }).filter(Boolean).join(", ") : "";
443
+ if (d) {
444
+ const a = i?.gradientType || "linear";
445
+ o.backgroundImage = a === "radial" ? `radial-gradient(${d})` : `linear-gradient(${d})`, delete o.backgroundColor;
446
+ }
447
+ return /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h("div", { "data-name": r, "data-type": "GradientComponent", style: o }) });
448
+ }, mt = ({ id: t, name: r, nodeData: e }) => {
449
+ const { patchedNodeData: o } = tt({ id: t, nodeData: e });
450
+ e = o;
451
+ const i = R(e.style, {
452
+ debug: !1
453
+ }), d = G(O), a = z((l) => l.assetsById), n = e.style?.scaleMode || "fill";
454
+ n === "fill" ? i.objectFit = "cover" : n === "fit" && (i.objectFit = "contain"), i.objectPosition = "center";
455
+ let c = e.data?.imageUrl;
456
+ !c && e.encoreData?.image && (c = e.encoreData.image.startsWith("//") ? `https:${e.encoreData.image}` : e.encoreData.image), c || (c = a[e.assetId]?.url);
457
+ const y = e.style?.positioning, S = e.style?.aspectRatio, f = d.dimensions?.width || 0, b = d.dimensions?.height || 0;
458
+ if (y && S && f > 0) {
459
+ const l = typeof y.left == "number" && typeof y.right == "number", g = typeof y.top == "number" && typeof y.bottom == "number";
460
+ if (l) {
461
+ const I = 100 - y.left - y.right;
462
+ if (I > 0) {
463
+ const A = I * f / 100;
464
+ i.width = A, i.height = A / S, i.left = `${Math.max(0, y.left)}%`, i.top = `${Math.max(0, y.top)}%`, delete i.right, delete i.bottom;
465
+ }
466
+ } else if (g && b > 0) {
467
+ const I = 100 - y.top - y.bottom;
468
+ if (I > 0) {
469
+ const A = I * b / 100;
470
+ i.height = A, i.width = A * S, i.left = `${Math.max(0, y.left)}%`, i.top = `${Math.max(0, y.top)}%`, delete i.right, delete i.bottom;
471
+ }
472
+ }
473
+ }
474
+ return /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h(
475
+ "img",
476
+ {
477
+ "data-id": t,
478
+ "data-name": r,
479
+ "data-type": "ImageComponent",
480
+ style: i,
481
+ src: c || a[e.assetId]?.url,
482
+ alt: r
483
+ }
484
+ ) });
485
+ }, yt = ({
486
+ id: t,
487
+ name: r,
488
+ nodeData: e
489
+ }) => {
490
+ const o = z((d) => d.setFormInputValue), i = R(e.style, { debug: !1 });
491
+ return /* @__PURE__ */ h(
492
+ "input",
493
+ {
494
+ onChange: (d) => o(t, d.target.value),
495
+ "data-id": t,
496
+ "data-name": r,
497
+ "data-type": "EmailInputComponent",
498
+ placeholder: e.data.text,
499
+ style: i,
500
+ type: "email"
501
+ }
502
+ );
503
+ }, bt = ({
504
+ id: t,
505
+ name: r,
506
+ nodeData: e
507
+ }) => {
508
+ const o = R(e.style);
509
+ return o.visibility = "hidden", /* @__PURE__ */ h(
510
+ "input",
511
+ {
512
+ "data-id": t,
513
+ "data-name": r,
514
+ "data-type": "HiddenInputComponent",
515
+ style: o,
516
+ type: "hidden"
517
+ }
518
+ );
519
+ }, Ct = ({
520
+ id: t,
521
+ name: r,
522
+ nodeData: e
523
+ }) => {
524
+ const o = z((a) => a.setFormInputValue), i = R(e.style, { debug: !1 }), d = z((a) => a.assetsById);
525
+ return /* @__PURE__ */ it(ut, { children: [
526
+ /* @__PURE__ */ h(
527
+ "div",
528
+ {
529
+ style: { ...i, zIndex: 9999, cursor: "pointer" },
530
+ onClick: () => alert("Image picker")
531
+ }
532
+ ),
533
+ /* @__PURE__ */ h(
534
+ "img",
535
+ {
536
+ onChange: (a) => o(t, a.target.value),
537
+ style: i,
538
+ "data-id": t,
539
+ "data-name": r,
540
+ "data-type": "ImageInputComponent",
541
+ src: d[e.assetId]?.url,
542
+ alt: r
543
+ }
544
+ )
545
+ ] });
546
+ }, xt = ({
547
+ id: t,
548
+ name: r,
549
+ nodeData: e
550
+ }) => {
551
+ const o = z((d) => d.setFormInputValue), i = R(e.style, { debug: !1 });
552
+ return /* @__PURE__ */ h(
553
+ "input",
554
+ {
555
+ onChange: (d) => o(t, d.target.value),
556
+ "data-id": t,
557
+ "data-name": r,
558
+ "data-type": "PasswordInputComponent",
559
+ placeholder: e.data.text,
560
+ style: i,
561
+ type: "password"
562
+ }
563
+ );
564
+ }, St = ({
565
+ id: t,
566
+ name: r,
567
+ nodeData: e
568
+ }) => {
569
+ const o = z((f) => f.setFormInputValue), { onAction: i } = v.useContext(Lt), { patchedNodeData: d } = tt({ id: t, nodeData: e }), a = R(d.style, { debug: !1 });
570
+ a.width = "100%", a.flex = "1", a.minWidth = "0", a.boxSizing = "border-box", a.borderColor = a.borderColor ?? "transparent";
571
+ const n = d.data?.value, c = d.data?.options, y = v.useMemo(() => !c || !Array.isArray(c) ? [] : c.map((f) => typeof f == "string" ? { value: f, label: f } : f), [c]);
572
+ return /* @__PURE__ */ it(
573
+ "select",
574
+ {
575
+ "data-id": t,
576
+ "data-name": r,
577
+ "data-type": "SelectInputComponent",
578
+ value: n ?? "",
579
+ style: a,
580
+ onChange: async (f) => {
581
+ const b = f.target.value;
582
+ if (o(t, b), console.log(`Select changed: ${b}`), typeof i == "function")
583
+ try {
584
+ await i({
585
+ bravo: {
586
+ cancel: () => {
587
+ },
588
+ action: {
589
+ action: "select-change",
590
+ nodeId: t,
591
+ params: { value: b }
592
+ }
593
+ }
594
+ });
595
+ } catch {
596
+ }
597
+ },
598
+ children: [
599
+ y.length === 0 && /* @__PURE__ */ h("option", { value: "", disabled: !0, children: "Select an option..." }),
600
+ y.map((f) => /* @__PURE__ */ h("option", { value: f.value, children: f.label }, f.value))
601
+ ]
602
+ }
603
+ );
604
+ }, vt = ({
605
+ id: t,
606
+ name: r,
607
+ nodeData: e
608
+ }) => {
609
+ const o = z((d) => d.setFormInputValue), i = R(e.style, {
610
+ debug: !1
611
+ });
612
+ return /* @__PURE__ */ h(
613
+ "input",
614
+ {
615
+ onChange: (d) => o(t, d.target.value),
616
+ name: t,
617
+ "data-id": t,
618
+ "data-name": r,
619
+ "data-type": "TextInputComponent",
620
+ placeholder: e.data.text,
621
+ style: i,
622
+ type: "text"
623
+ }
624
+ );
625
+ }, It = ({ id: t, name: r, nodeData: e }) => {
626
+ const o = R(e.style);
627
+ return /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h(
628
+ "div",
629
+ {
630
+ "data-id": t,
631
+ "data-name": r,
632
+ "data-type": "LottieComponent",
633
+ style: o,
634
+ children
635
+ }
636
+ ) });
637
+ }, wt = ({ id: t, name: r, nodeData: e }) => {
638
+ const o = R(e.style, {
639
+ debug: !1
640
+ }), i = z((d) => d.assetsById);
641
+ return /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h(
642
+ "img",
643
+ {
644
+ "data-id": t,
645
+ "data-name": r,
646
+ "data-type": "SvgComponent",
647
+ style: o,
648
+ src: i[e.assetId]?.url,
649
+ alt: r
650
+ }
651
+ ) });
652
+ }, At = ({ id: t, name: r, nodeData: e }) => {
653
+ const { patchedNodeData: o } = tt({ id: t, nodeData: e });
654
+ e = o;
655
+ const i = e.data?.text;
656
+ r && r.includes("Purpose") && console.log("TextComponent Debug:", {
657
+ id: t,
658
+ name: r,
659
+ nodeData: e,
660
+ style: e.style,
661
+ color: e.style?.color
662
+ });
663
+ const d = e.style, a = e.fontId ? { ...d, fontId: e.fontId } : d, n = R(a, {
664
+ debug: !1
665
+ });
666
+ n.display = "flex", n.flexDirection = "column", d.verticalPosition && (n.justifyContent = {
667
+ "from-top": "flex-start",
668
+ center: "center",
669
+ "from-bottom": "flex-end"
670
+ }[d.verticalPosition]);
671
+ const c = i && (i.includes(`
672
+ `) || i.includes("\r"));
673
+ let y;
674
+ return c && n.flexDirection === "column" ? y = i.split(/\r?\n/).filter((f) => f.length > 0).map((f, b) => /* @__PURE__ */ h("div", { style: { lineHeight: "inherit" }, children: f }, b)) : y = i, /* @__PURE__ */ h(q, { id: t, nodeData: e, children: /* @__PURE__ */ h(
675
+ "div",
676
+ {
677
+ "data-id": t,
678
+ "data-name": r,
679
+ "data-type": "TextComponent",
680
+ style: n,
681
+ children: y
682
+ }
683
+ ) });
684
+ }, dt = ({
685
+ id: t,
686
+ name: r,
687
+ nodeData: e,
688
+ children: o
689
+ }) => {
690
+ const i = G(Q), { patchedNodeData: d } = tt({ id: t, nodeData: e });
691
+ e = d;
692
+ const a = jt(e.tags), n = a ? z((I) => I.inputGroups[a.groupName]) : null, c = z((I) => I.statefulSetVariants[t]), y = R(e.style, {
693
+ debug: !1
694
+ });
695
+ let S;
696
+ a && n !== null ? S = n === r ? "active" : "default" : S = c || e.data.initialState || "default";
697
+ const f = v.Children.toArray(o).find((I) => v.isValidElement(I) ? I.props?.nodeData?.data?.state === S : !1), b = v.isValidElement(f) ? v.cloneElement(f, {
698
+ _parentStatefulSetId: t,
699
+ _parentInputGroupInfo: a,
700
+ _parentName: r
701
+ // Pass the name so we can identify which element is active
702
+ }) : f, l = /* @__PURE__ */ h(
703
+ "div",
704
+ {
705
+ "data-id": t,
706
+ "data-name": r,
707
+ "data-type": "StatefulSetComponent",
708
+ style: y,
709
+ children: b
710
+ }
711
+ );
712
+ if (e.type === "component:input-stateful-set")
713
+ return l;
714
+ const g = v.useContext(lt);
715
+ return /* @__PURE__ */ h(
716
+ Q.Provider,
717
+ {
718
+ value: { nodeData: i?.nodeData?.[t] || {} },
719
+ children: /* @__PURE__ */ h(
720
+ lt.Provider,
721
+ {
722
+ value: { ...g, statefulSetId: t },
723
+ children: l
724
+ }
725
+ )
726
+ }
727
+ );
728
+ }, Et = ({
729
+ id: t,
730
+ name: r,
731
+ nodeData: e,
732
+ children: o,
733
+ _parentStatefulSetId: i,
734
+ _parentInputGroupInfo: d,
735
+ _parentName: a
736
+ }) => {
737
+ const n = R(e.style, {
738
+ debug: !1
739
+ }), c = {
740
+ ...n,
741
+ position: n.position || "relative"
742
+ };
743
+ return /* @__PURE__ */ h(
744
+ "div",
745
+ {
746
+ "data-id": t,
747
+ "data-name": r,
748
+ "data-type": "StatefulCompoundComponent",
749
+ style: c,
750
+ children: /* @__PURE__ */ h(
751
+ q,
752
+ {
753
+ id: t,
754
+ nodeData: e,
755
+ _parentStatefulSetId: i,
756
+ _parentInputGroupInfo: d,
757
+ _parentName: a,
758
+ children: o
759
+ }
760
+ )
761
+ }
762
+ );
763
+ }, Tt = ({ id: t, name: r, children: e }) => {
764
+ G(O);
765
+ const { dimensions: o, ref: i } = rt(), d = {
766
+ zIndex: 0,
767
+ flex: 1,
768
+ position: "absolute",
769
+ top: 0,
770
+ left: 0,
771
+ width: "100%",
772
+ height: "100%"
773
+ };
774
+ return /* @__PURE__ */ h(O.Provider, { value: { dimensions: o, isFlex: !1 }, children: /* @__PURE__ */ h(
775
+ "div",
776
+ {
777
+ "data-id": t,
778
+ "data-name": r,
779
+ "data-type": "BackgroundContainerComponent",
780
+ ref: i,
781
+ style: d,
782
+ children: e
783
+ }
784
+ ) });
785
+ }, pt = ({
786
+ id: t,
787
+ name: r,
788
+ nodeData: e,
789
+ children: o,
790
+ _arrayItemIndex: i,
791
+ _arrayItemData: d
792
+ }) => {
793
+ t === "01KB929X1KK5TX0K8VBNP6ZDPG" && console.log(
794
+ `[DEBUG] ContainerComponent ${t} (Hero) FULL nodeData:`,
795
+ JSON.stringify(e, null, 2)
796
+ );
797
+ const a = G(Q), { patchedNodeData: n, list: c, arrayData: y } = tt({
798
+ id: t,
799
+ nodeData: e
800
+ });
801
+ e = n;
802
+ const { dimensions: S, ref: f } = rt(), b = R(e.style, {
803
+ debug: !1
804
+ }), l = !!e.style.layout?.mode, g = e.style.layout?.mode === "HORIZONTAL" ? "row" : "column", I = b.width !== void 0, A = b.height !== void 0, F = G(O), E = F?.isFlex ?? !1, s = F?.flexDirection, W = E && s === "row", U = !E && e.style.positioning, M = e.style.layout?.layoutSizingHorizontal === "FIXED" || e.style.layout?.layoutSizingVertical === "FIXED", Z = e.style.layout?.layoutSizingHorizontal === "HUG" || e.style.layout?.layoutSizingVertical === "HUG";
805
+ if (!I && !W && !(U && (M || Z)) && (b.width = "100%"), !A) {
806
+ const k = !E && e.style.positioning, X = e.style.layout?.layoutSizingVertical === "FILL";
807
+ if (!(e.style.layout?.layoutSizingVertical === "HUG")) {
808
+ if (!l) if (k && X && e.style.positioning?.top !== void 0) {
809
+ const ot = 100 - e.style.positioning.top;
810
+ b.height = `${ot}%`;
811
+ } else
812
+ b.height = "100%";
813
+ }
814
+ }
815
+ const H = e.style.layout?.layoutSizingHorizontal || e.style.layout?.layoutSizingVertical, V = e.style.positioning && !l && (H || !0) ? { ...b, position: "absolute" } : b.position === "absolute" ? b : { ...b, position: b.position || "relative" }, N = (k) => typeof k == "number" ? k : typeof k == "string" && k.endsWith("px") && parseFloat(k) || 0, m = N(b.paddingLeft), et = N(b.paddingRight), j = N(b.paddingTop), B = N(b.paddingBottom), L = M && typeof b.width == "number" && typeof b.height == "number" ? {
816
+ width: b.width - m - et,
817
+ height: b.height - j - B
818
+ } : {
819
+ width: S.width - m - et,
820
+ height: S.height - j - B
821
+ };
822
+ if (i != null && c) {
823
+ const k = c[i];
824
+ if (k !== void 0) {
825
+ const X = typeof k == "object" && k !== null ? {
826
+ nodeData: k,
827
+ arrayDataById: a?.arrayDataById,
828
+ textOverridesById: a?.textOverridesById,
829
+ rootData: a?.rootData
830
+ } : { nodeData: k };
831
+ return /* @__PURE__ */ h(Q.Provider, { value: X, children: /* @__PURE__ */ h(
832
+ O.Provider,
833
+ {
834
+ value: { dimensions: L, isFlex: l, flexDirection: g },
835
+ children: /* @__PURE__ */ h(
836
+ "div",
837
+ {
838
+ "data-id": `${t}:${i}`,
839
+ "data-name": r,
840
+ "data-type": "ContainerComponent",
841
+ style: V,
842
+ children: o
843
+ }
844
+ )
845
+ }
846
+ ) });
847
+ }
848
+ }
849
+ if (c) {
850
+ const k = y || c;
851
+ return zt(() => k.map((J, _) => {
852
+ const ot = typeof J == "object" && J !== null ? {
853
+ nodeData: J,
854
+ arrayDataById: a?.arrayDataById,
855
+ textOverridesById: a?.textOverridesById,
856
+ rootData: a?.rootData
857
+ } : { nodeData: J };
858
+ return /* @__PURE__ */ h(
859
+ Q.Provider,
860
+ {
861
+ value: ot,
862
+ children: /* @__PURE__ */ h(
863
+ O.Provider,
864
+ {
865
+ value: { dimensions: L, isFlex: l, flexDirection: g },
866
+ children: /* @__PURE__ */ h(
867
+ "div",
868
+ {
869
+ "data-id": `${t}:${_}`,
870
+ "data-name": r,
871
+ "data-type": "ContainerComponent",
872
+ style: V,
873
+ children: o
874
+ }
875
+ )
876
+ }
877
+ )
878
+ },
879
+ `${t}:${_}`
880
+ );
881
+ }), [k, t]);
882
+ }
883
+ let $ = e.actions || [];
884
+ !Array.isArray($) && typeof $ == "object" && $ !== null && ($ = Object.entries($).map(
885
+ ([k, X]) => ({
886
+ event: k,
887
+ ...typeof X == "object" && X !== null ? X : {}
888
+ })
889
+ ));
890
+ const K = Array.isArray($) && $.length > 0;
891
+ return /* @__PURE__ */ h(
892
+ O.Provider,
893
+ {
894
+ value: { dimensions: L, isFlex: l, flexDirection: g },
895
+ children: /* @__PURE__ */ h(
896
+ "div",
897
+ {
898
+ "data-id": t,
899
+ "data-name": r,
900
+ "data-type": "ContainerComponent",
901
+ ref: f,
902
+ style: V,
903
+ children: K ? /* @__PURE__ */ h(q, { id: t, nodeData: e, children: o }) : o
904
+ }
905
+ )
906
+ }
907
+ );
908
+ }, Ft = pt, Pt = ({ id: t, name: r, nodeData: e, children: o }) => {
909
+ const { dimensions: i, ref: d } = rt(), a = R(e.style, {
910
+ debug: !1
911
+ }), n = !!e.style.layout?.mode, c = e.style.layout?.mode === "HORIZONTAL" ? "row" : "column", y = a.position ? a : { ...a, position: "relative" };
912
+ return /* @__PURE__ */ h(
913
+ O.Provider,
914
+ {
915
+ value: { dimensions: i, isFlex: n, flexDirection: c },
916
+ children: /* @__PURE__ */ h(
917
+ "div",
918
+ {
919
+ "data-id": t,
920
+ "data-name": r,
921
+ "data-type": "TopBarContainerComponent",
922
+ ref: d,
923
+ style: y,
924
+ children: o
925
+ }
926
+ )
927
+ }
928
+ );
929
+ }, Gt = ({ id: t, name: r, nodeData: e, children: o }) => {
930
+ const i = R(e.style, { debug: !1 });
931
+ return /* @__PURE__ */ h(
932
+ "div",
933
+ {
934
+ "data-id": t,
935
+ "data-name": r,
936
+ "data-type": "DefaultLayerComponent",
937
+ style: i,
938
+ children: o
939
+ }
940
+ );
941
+ }, $t = ({ id: t, name: r, nodeData: e, children: o }) => /* @__PURE__ */ h(
942
+ "div",
943
+ {
944
+ "data-id": t,
945
+ "data-name": r,
946
+ "data-type": "TabsMenuComponent",
947
+ style: R(e.style),
948
+ children: o
949
+ }
950
+ ), Wt = ({ id: t, name: r, nodeData: e, children: o }) => {
951
+ const i = R(e.style, {
952
+ debug: !1
953
+ });
954
+ return /* @__PURE__ */ h(
955
+ "div",
956
+ {
957
+ "data-id": t,
958
+ "data-name": r,
959
+ "data-type": "MenuSideComponent",
960
+ style: i,
961
+ children: o
962
+ }
963
+ );
964
+ }, at = ({ id: t, name: r, nodeData: e, children: o }) => {
965
+ t === "01KB929X1DQJN954WNGF5AH38B" && console.log(
966
+ `[DEBUG] SliderComponent ${t} FULL nodeData:`,
967
+ JSON.stringify(e, null, 2)
968
+ );
969
+ const { dimensions: i, ref: d } = rt(), a = v.useRef(null), n = v.useRef(null), c = v.useRef(!1), y = v.useRef(null), S = G(ct), f = G(Ot), [b, l] = v.useState({
970
+ currentIndex: void 0,
971
+ onIndexChange: void 0
972
+ }), [g, I] = v.useState(0), A = v.useRef(null), { patchedNodeData: F } = tt({ id: t, nodeData: e });
973
+ e = F;
974
+ const E = e.data?.params || {}, s = E.infinite === !0, W = E.automatic === !0;
975
+ let M = Array.isArray(e.tags) && e.tags.some((u) => u.includes("container:slider:vertical")) || e.name && e.name.includes("container:slider:vertical");
976
+ if (!M && E.animation === "default") {
977
+ const u = e.style?.width, p = e.style?.height;
978
+ typeof u == "number" && typeof p == "number" && p > u && (M = !0);
979
+ }
980
+ const Z = M ? "vertical" : E.animation === "default" ? "horizontal" : E.animation || "horizontal", H = R(e.style, {
981
+ debug: !1
982
+ }), P = H.width !== void 0, V = H.height !== void 0;
983
+ P || (H.width = "100%"), V || (H.height = "100%"), H.position || (H.position = "relative");
984
+ const N = G(Q), m = v.useMemo(() => {
985
+ const u = [];
986
+ return v.Children.forEach(o, (p) => {
987
+ if (p == null) return;
988
+ const w = p?.props || {}, x = w.nodeData || {};
989
+ if (Array.isArray(x?.tags) && (x.tags.includes("encore:data:array") || x.tags.includes("bravo:data:array")) && w.id && N) {
990
+ const T = N?.arrayDataById && N.arrayDataById[w.id] && Array.isArray(N.arrayDataById[w.id]) ? N.arrayDataById[w.id] : null;
991
+ T && T.length > 0 ? T.forEach((D, nt) => {
992
+ u.push(
993
+ v.cloneElement(p, {
994
+ key: `${w.id}:${nt}`,
995
+ // ContainerComponent will use this to know which item to render
996
+ _arrayItemIndex: nt,
997
+ _arrayItemData: D
998
+ })
999
+ );
1000
+ }) : u.push(p);
1001
+ } else
1002
+ u.push(p);
1003
+ }), u;
1004
+ }, [o, t, N]), et = v.useMemo(() => {
1005
+ if (!s || m.length === 0)
1006
+ return m;
1007
+ const u = m[0], p = m[m.length - 1];
1008
+ return [
1009
+ v.cloneElement(p, {
1010
+ key: `clone-last-${p.key || p.props.id}`
1011
+ }),
1012
+ ...m,
1013
+ v.cloneElement(u, {
1014
+ key: `clone-first-${u.key || u.props.id}`
1015
+ })
1016
+ ];
1017
+ }, [m, s]), j = v.useMemo(() => {
1018
+ if (m.length === 0) return { width: 0, height: 0 };
1019
+ const p = m[0]?.props?.nodeData?.style, w = S.scaleFactor || 1;
1020
+ let x = 0, C = 0;
1021
+ return p?.layout?.layoutSizingHorizontal === "FIXED" && p?.layout?.size?.x ? x = p.layout.size.x * w : x = i.width || 0, p?.layout?.layoutSizingVertical === "FIXED" && p?.layout?.size?.y ? C = p.layout.size.y * w : C = i.height || 0, { width: x, height: C };
1022
+ }, [m, i.width, i.height, S.scaleFactor]), B = j.width, L = j.height, $ = Z === "vertical", K = v.useCallback(() => {
1023
+ if (!a.current || m.length === 0)
1024
+ return 0;
1025
+ const u = a.current;
1026
+ if ($) {
1027
+ if (L === 0) return 0;
1028
+ const p = u.scrollTop;
1029
+ if (s) {
1030
+ const x = p - L;
1031
+ let C = Math.round(x / L);
1032
+ return C < 0 && (C = 0), C >= m.length && (C = m.length - 1), C;
1033
+ } else {
1034
+ const w = Math.round(p / L);
1035
+ return w < 0 ? 0 : w >= m.length ? m.length - 1 : w;
1036
+ }
1037
+ } else {
1038
+ if (B === 0) return 0;
1039
+ const p = u.scrollLeft;
1040
+ if (s) {
1041
+ const x = p - B;
1042
+ let C = Math.round(x / B);
1043
+ return C < 0 && (C = 0), C >= m.length && (C = m.length - 1), C;
1044
+ } else {
1045
+ const w = Math.round(p / B);
1046
+ return w < 0 ? 0 : w >= m.length ? m.length - 1 : w;
1047
+ }
1048
+ }
1049
+ }, [s, m.length, B, L, $]), Y = v.useCallback(
1050
+ (u, p = !0) => {
1051
+ if (!a.current || m.length === 0) return;
1052
+ const w = a.current;
1053
+ if ($) {
1054
+ let x;
1055
+ s ? x = L + u * L : x = u * L, w.scrollTo({
1056
+ top: x,
1057
+ behavior: p ? "smooth" : "auto"
1058
+ });
1059
+ } else {
1060
+ let x;
1061
+ s ? x = B + u * B : x = u * B, w.scrollTo({
1062
+ left: x,
1063
+ behavior: p ? "smooth" : "auto"
1064
+ });
1065
+ }
1066
+ },
1067
+ [B, L, s, m.length, $]
1068
+ ), k = v.useCallback(() => {
1069
+ if (!s || !a.current || m.length === 0) return;
1070
+ const u = a.current, p = 1;
1071
+ if ($) {
1072
+ if (L === 0) return;
1073
+ const w = u.scrollTop, x = L, C = x, T = C + m.length * x;
1074
+ w >= T - p ? u.scrollTop = C : w <= p && (u.scrollTop = T - x);
1075
+ } else {
1076
+ if (B === 0) return;
1077
+ const w = u.scrollLeft, x = B, C = x, T = C + m.length * x;
1078
+ w >= T - p ? u.scrollLeft = C : w <= p && (u.scrollLeft = T - x);
1079
+ }
1080
+ }, [s, m.length, B, L, $]);
1081
+ v.useEffect(() => {
1082
+ if (!W || m.length <= 1 || B === 0) return;
1083
+ const u = () => {
1084
+ if (c.current || !a.current) return;
1085
+ const p = a.current;
1086
+ if ($) {
1087
+ if (L === 0) return;
1088
+ const w = p.scrollTop, x = L;
1089
+ let C;
1090
+ if (s) {
1091
+ const nt = w - x;
1092
+ C = Math.round(nt / x), C < 0 && (C = 0), C >= m.length && (C = m.length - 1);
1093
+ } else
1094
+ C = Math.round(w / x);
1095
+ let T = C + 1;
1096
+ if (s) {
1097
+ T >= m.length && (T = 0);
1098
+ const D = x;
1099
+ p.scrollTo({
1100
+ top: D + T * x,
1101
+ behavior: "smooth"
1102
+ });
1103
+ } else
1104
+ T >= m.length && (T = 0), Y(T);
1105
+ } else {
1106
+ if (B === 0) return;
1107
+ const w = p.scrollLeft, x = B;
1108
+ let C;
1109
+ if (s) {
1110
+ const nt = w - x;
1111
+ C = Math.round(nt / x), C < 0 && (C = 0), C >= m.length && (C = m.length - 1);
1112
+ } else
1113
+ C = Math.round(w / x);
1114
+ let T = C + 1;
1115
+ if (s) {
1116
+ T >= m.length && (T = 0);
1117
+ const D = x;
1118
+ p.scrollTo({
1119
+ left: D + T * x,
1120
+ behavior: "smooth"
1121
+ });
1122
+ } else
1123
+ T >= m.length && (T = 0), Y(T);
1124
+ }
1125
+ };
1126
+ return n.current = setInterval(u, 4e3), () => {
1127
+ n.current && (clearInterval(n.current), n.current = null);
1128
+ };
1129
+ }, [
1130
+ W,
1131
+ m.length,
1132
+ s,
1133
+ B,
1134
+ L,
1135
+ $,
1136
+ Y
1137
+ ]);
1138
+ const X = v.useCallback(() => {
1139
+ c.current = !0, y.current && clearTimeout(y.current), y.current = setTimeout(() => {
1140
+ c.current = !1;
1141
+ }, 3e3);
1142
+ }, []), J = v.useRef(b);
1143
+ v.useEffect(() => {
1144
+ J.current = b;
1145
+ }, [b]);
1146
+ const _ = v.useCallback(
1147
+ (u) => {
1148
+ if (A.current === u) return;
1149
+ A.current = u;
1150
+ const p = J.current;
1151
+ p.currentIndex === void 0 && I(u), p.onIndexChange && p.onIndexChange(u);
1152
+ },
1153
+ []
1154
+ // Empty deps - we use ref to access latest controlProps
1155
+ );
1156
+ v.useEffect(() => {
1157
+ const u = a.current;
1158
+ if (!u) return;
1159
+ let p = null;
1160
+ const w = () => {
1161
+ X(), s ? (p !== null && cancelAnimationFrame(p), p = requestAnimationFrame(() => {
1162
+ k();
1163
+ const T = K();
1164
+ _(T);
1165
+ })) : (p !== null && cancelAnimationFrame(p), p = requestAnimationFrame(() => {
1166
+ const T = K();
1167
+ _(T);
1168
+ }));
1169
+ }, x = () => X(), C = () => X();
1170
+ return u.addEventListener("scroll", w, { passive: !0 }), u.addEventListener("touchstart", x, {
1171
+ passive: !0
1172
+ }), u.addEventListener("mousedown", C), () => {
1173
+ u.removeEventListener("scroll", w), u.removeEventListener("touchstart", x), u.removeEventListener("mousedown", C), y.current && clearTimeout(y.current), p !== null && cancelAnimationFrame(p);
1174
+ };
1175
+ }, [
1176
+ s,
1177
+ X,
1178
+ k,
1179
+ K,
1180
+ _
1181
+ ]), v.useEffect(() => {
1182
+ if (f) {
1183
+ const u = f.getControlProps(t);
1184
+ u && u !== b && l(u);
1185
+ }
1186
+ }, [t, f, b]), v.useEffect(() => {
1187
+ if (b.currentIndex !== void 0 && a.current && m.length > 0 && B > 0) {
1188
+ const u = Math.max(
1189
+ 0,
1190
+ Math.min(b.currentIndex, m.length - 1)
1191
+ ), p = K();
1192
+ u !== p && Y(u, !0);
1193
+ }
1194
+ }, [
1195
+ b.currentIndex,
1196
+ m.length,
1197
+ m.length,
1198
+ B,
1199
+ L,
1200
+ $,
1201
+ Y,
1202
+ K
1203
+ ]), v.useEffect(() => {
1204
+ if (s && a.current && m.length > 0 && m.length > 0 && ($ ? L > 0 : B > 0)) {
1205
+ const u = $ ? L : B;
1206
+ setTimeout(() => {
1207
+ a.current && ($ ? a.current.scrollTop = u : a.current.scrollLeft = u);
1208
+ }, 0);
1209
+ }
1210
+ }, [s, m.length, B, L, $]), v.useEffect(() => {
1211
+ if (!f) return;
1212
+ const { registerContainer: u, unregisterContainer: p } = f;
1213
+ return () => {
1214
+ };
1215
+ }, [
1216
+ t,
1217
+ f?.registerContainer,
1218
+ f?.unregisterContainer,
1219
+ // controlProps, // REMOVED to break infinite loop
1220
+ Y,
1221
+ K
1222
+ ]);
1223
+ const ot = {
1224
+ display: "flex",
1225
+ flexDirection: $ ? "column" : "row",
1226
+ overflowX: $ ? "hidden" : "auto",
1227
+ overflowY: $ ? "auto" : "hidden",
1228
+ scrollSnapType: $ ? "y mandatory" : "x mandatory",
1229
+ scrollBehavior: "smooth",
1230
+ width: "100%",
1231
+ height: "100%",
1232
+ WebkitOverflowScrolling: "touch"
1233
+ // Smooth scrolling on iOS
1234
+ }, kt = {
1235
+ flexShrink: 0,
1236
+ scrollSnapAlign: "start",
1237
+ width: j.width > 0 ? j.width : void 0,
1238
+ height: j.height > 0 ? j.height : void 0,
1239
+ position: "relative"
1240
+ };
1241
+ return /* @__PURE__ */ h(
1242
+ "div",
1243
+ {
1244
+ "data-id": t,
1245
+ "data-name": r,
1246
+ "data-type": "SliderComponent",
1247
+ ref: d,
1248
+ style: H,
1249
+ children: /* @__PURE__ */ h("div", { ref: a, style: ot, children: et.map((u, p) => /* @__PURE__ */ h(
1250
+ O.Provider,
1251
+ {
1252
+ value: {
1253
+ dimensions: {
1254
+ width: j.width,
1255
+ height: j.height
1256
+ },
1257
+ isFlex: !1
1258
+ },
1259
+ children: /* @__PURE__ */ h("div", { style: kt, children: u })
1260
+ },
1261
+ u.key || `slide-${p}`
1262
+ )) })
1263
+ }
1264
+ );
1265
+ }, Rt = (t, r) => {
1266
+ const e = Array.isArray(t) ? t : [t];
1267
+ for (const o of e)
1268
+ if (!(!o || !o.props)) {
1269
+ if (o.props.id === r)
1270
+ return o;
1271
+ if (o.props.children) {
1272
+ const i = Rt(o.props.children, r);
1273
+ if (i) return i;
1274
+ }
1275
+ }
1276
+ return null;
1277
+ }, Bt = ({ id: t, name: r, nodeData: e, children: o }) => {
1278
+ const { dimensions: i, ref: d } = rt(), { componentId: a } = G(lt), n = G(O), c = e.style.originalSize?.[0] || 1, y = e.style.originalSize?.[1] || 1, S = n?.dimensions?.width, f = n?.dimensions?.height, b = window.innerWidth, l = window.innerHeight, g = S && S > 0 && S < b * 0.8;
1279
+ let I, A;
1280
+ i.width > 0 && i.height > 0 ? (I = i.width, A = i.height) : g && S && f || S && f && S > 0 && f > 0 ? (I = S, A = f) : (I = b, A = l);
1281
+ const E = { scaleFactor: Math.min(I / c, A / y) || 1 };
1282
+ if (a) {
1283
+ const P = Rt(o, a);
1284
+ return P ? /* @__PURE__ */ h(ct.Provider, { value: E, children: /* @__PURE__ */ h(
1285
+ O.Provider,
1286
+ {
1287
+ value: {
1288
+ dimensions: {
1289
+ width: "100%",
1290
+ height: "100%"
1291
+ }
1292
+ },
1293
+ children: P
1294
+ }
1295
+ ) }) : (console.warn(`Child with id "${a}" not found`), null);
1296
+ }
1297
+ const s = Array.isArray(o) ? o : [o], { scrollableChildren: W, nonScrollableChildren: U } = s.reduce(
1298
+ (P, V) => {
1299
+ const m = V.props.nodeData.type === "container:top-bar" ? "nonScrollableChildren" : "scrollableChildren";
1300
+ return P[m].push(V), P;
1301
+ },
1302
+ {
1303
+ scrollableChildren: [],
1304
+ nonScrollableChildren: []
1305
+ }
1306
+ );
1307
+ let M = e.style?.layout?.mode;
1308
+ if (!M && t === "01KASW494V02Y8P5JVWV5XK62X" && (console.log("🔧 PATCHING missing layout for page", t), M = "HORIZONTAL"), !M && o) {
1309
+ const P = Array.isArray(o) ? o : [o];
1310
+ let V = 0, N = 0;
1311
+ P.forEach((et) => {
1312
+ const j = et?.props?.nodeData?.style?.width;
1313
+ j && (V += j, j < 99 && N++);
1314
+ }), N > 0 && V >= 99 && (console.log(
1315
+ `[PATCH] Detected HORIZONTAL WRAP layout for page ${t} (Partial width children: ${N}, Total width: ${V})`
1316
+ ), M = "HORIZONTAL", e.style || (e.style = {}), e.style.layout || (e.style.layout = {}), e.style.layout.mode = "HORIZONTAL", e.style.layout.flexWrap = "wrap", e.style.layout.primaryAxisAlignItems = "flex-start", e.style.layout.counterAxisAlignItems = "flex-start");
1317
+ }
1318
+ const Z = M === "HORIZONTAL" ? "row" : "column", H = U.some(
1319
+ (P) => P?.props?.nodeData?.type !== "container:background"
1320
+ );
1321
+ return /* @__PURE__ */ h(ct.Provider, { value: E, children: /* @__PURE__ */ it(
1322
+ "div",
1323
+ {
1324
+ style: {
1325
+ width: "100%",
1326
+ height: "100%",
1327
+ position: "relative",
1328
+ overflow: "hidden",
1329
+ // Only use flex if we have non-background nonScrollableChildren (like top-bar)
1330
+ ...H ? {
1331
+ display: "flex",
1332
+ flexDirection: Z,
1333
+ gap: 0,
1334
+ rowGap: 0,
1335
+ columnGap: 0
1336
+ } : {}
1337
+ },
1338
+ ref: d,
1339
+ children: [
1340
+ U.filter(
1341
+ (P) => P?.props?.nodeData?.type === "container:background"
1342
+ ).map((P, V) => /* @__PURE__ */ h(
1343
+ O.Provider,
1344
+ {
1345
+ value: {
1346
+ dimensions: {
1347
+ width: i.width,
1348
+ height: i.height
1349
+ }
1350
+ },
1351
+ children: P
1352
+ },
1353
+ `bg-${V}`
1354
+ )),
1355
+ H && U.filter(
1356
+ (P) => P?.props?.nodeData?.type !== "container:background"
1357
+ ).map((P, V) => /* @__PURE__ */ h(
1358
+ O.Provider,
1359
+ {
1360
+ value: {
1361
+ dimensions: {
1362
+ width: i.width,
1363
+ height: i.height
1364
+ }
1365
+ },
1366
+ children: P
1367
+ },
1368
+ `non-scroll-${V}`
1369
+ )),
1370
+ /* @__PURE__ */ h(O.Provider, { value: { dimensions: i }, children: /* @__PURE__ */ h(
1371
+ "div",
1372
+ {
1373
+ "data-id": t,
1374
+ "data-name": r,
1375
+ "data-type": "PageComponent",
1376
+ style: {
1377
+ position: "relative",
1378
+ ...H ? {
1379
+ flex: 1,
1380
+ ...Z === "row" ? { alignSelf: "stretch" } : {}
1381
+ // Removed height: "100%" to allow HUG containers to size based on content
1382
+ } : {
1383
+ width: "100%"
1384
+ // Removed height: "100%" to allow HUG containers to size based on content
1385
+ },
1386
+ // Remove overflow: auto in horizontal mode as it causes height collapse
1387
+ ...Z === "column" && { overflow: "auto" },
1388
+ ...R(e.style, {
1389
+ debug: !1
1390
+ })
1391
+ },
1392
+ children: W
1393
+ }
1394
+ ) })
1395
+ ]
1396
+ }
1397
+ ) });
1398
+ }, Dt = {
1399
+ WebViewComponent: ht,
1400
+ ColorComponent: ft,
1401
+ GradientComponent: gt,
1402
+ ImageComponent: mt,
1403
+ EmailInputComponent: yt,
1404
+ HiddenInputComponent: bt,
1405
+ ImageInputComponent: Ct,
1406
+ PasswordInputComponent: xt,
1407
+ SelectInputComponent: St,
1408
+ TextInputComponent: vt,
1409
+ LottieComponent: It,
1410
+ SvgComponent: wt,
1411
+ TextComponent: At,
1412
+ StatefulSetComponent: dt,
1413
+ StatefulCompoundComponent: Et,
1414
+ BackgroundContainerComponent: Tt,
1415
+ ContainerComponent: pt,
1416
+ CompoundComponent: Ft,
1417
+ TopBarContainerComponent: Pt,
1418
+ DefaultLayerComponent: Gt,
1419
+ TabsMenuComponent: $t,
1420
+ MenuSideComponent: Wt,
1421
+ SliderComponent: at,
1422
+ PageComponent: Bt,
1423
+ // Type string mappings for dynamically loaded components
1424
+ "menu:side": Wt,
1425
+ "page:default": Bt,
1426
+ "container:background": Tt,
1427
+ "container:default": pt,
1428
+ "container:top-bar": Pt,
1429
+ "container:slider": at,
1430
+ "component:text": At,
1431
+ "component:color": ft,
1432
+ "component:gradient": gt,
1433
+ "component:image": mt,
1434
+ "component:svg": wt,
1435
+ "component:compound": Ft,
1436
+ "component:input-stateful-set": dt,
1437
+ "component:stateful-set": dt,
1438
+ "component:stateful-compound": Et,
1439
+ "component:slider": at,
1440
+ "component:webview": ht,
1441
+ "component:lottie": It,
1442
+ "component:email-input": yt,
1443
+ "component:text-input": vt,
1444
+ "component:password-input": xt,
1445
+ "component:select-input": St,
1446
+ "component:image-input": Ct,
1447
+ "component:hidden-input": bt,
1448
+ "component:tabs-menu": $t,
1449
+ ContainerSliderComponent: at
1450
+ };
1451
+ export {
1452
+ Dt as default
1453
+ };
1454
+ //# sourceMappingURL=components.js.map