@builder.io/sdk-react-nextjs 0.14.29 → 0.14.30

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 (100) hide show
  1. package/lib/browser/blocks-exports.cjs +188 -0
  2. package/lib/browser/blocks-exports.mjs +2812 -0
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +25 -26
  5. package/lib/browser/init.cjs +8 -0
  6. package/lib/browser/init.mjs +60 -0
  7. package/lib/browser/server-entry-24a8bb57.js +720 -0
  8. package/lib/browser/server-entry-6927b611.cjs +2 -0
  9. package/lib/browser/server-entry.cjs +1 -0
  10. package/lib/browser/server-entry.mjs +16 -0
  11. package/lib/edge/blocks-exports.cjs +208 -0
  12. package/lib/edge/{bundle-f748b05a.js → blocks-exports.mjs} +2381 -2401
  13. package/lib/edge/index.cjs +1 -1
  14. package/lib/edge/index.mjs +25 -26
  15. package/lib/edge/init.cjs +8 -0
  16. package/lib/edge/init.mjs +60 -0
  17. package/lib/edge/server-entry-24a8bb57.js +720 -0
  18. package/lib/edge/server-entry-6927b611.cjs +2 -0
  19. package/lib/edge/server-entry.cjs +1 -0
  20. package/lib/edge/server-entry.mjs +16 -0
  21. package/lib/node/blocks-exports.cjs +188 -0
  22. package/lib/node/blocks-exports.mjs +2788 -0
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +23 -23
  25. package/lib/node/init.cjs +1 -0
  26. package/lib/node/init.mjs +13 -0
  27. package/lib/node/node-runtime-39bc20c5.cjs +48 -0
  28. package/lib/node/node-runtime-bf50fca0.js +167 -0
  29. package/lib/node/server-entry-3cc55723.js +720 -0
  30. package/lib/node/server-entry-8112afc1.cjs +2 -0
  31. package/lib/node/server-entry.cjs +1 -0
  32. package/lib/node/server-entry.mjs +16 -0
  33. package/package.json +14 -9
  34. package/types/cjs/blocks/BaseText.d.ts +6 -0
  35. package/types/cjs/blocks/raw-text/component-info.d.ts +2 -0
  36. package/types/cjs/blocks/raw-text/index.d.ts +1 -0
  37. package/types/cjs/blocks/raw-text/raw-text.d.ts +7 -0
  38. package/types/cjs/blocks/textarea/component-info.d.ts +2 -0
  39. package/types/cjs/blocks/textarea/index.d.ts +1 -0
  40. package/types/cjs/blocks/textarea/textarea.d.ts +13 -0
  41. package/types/cjs/components/content/index.d.ts +1 -0
  42. package/types/cjs/components/error-boundary.d.ts +11 -0
  43. package/types/cjs/constants/sdk-name.d.ts +1 -0
  44. package/types/cjs/constants/sdk-version.d.ts +1 -1
  45. package/types/cjs/functions/apply-patch-with-mutation.d.ts +10 -0
  46. package/types/cjs/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  47. package/types/cjs/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  48. package/types/cjs/functions/evaluate/edge-runtime/index.d.ts +1 -0
  49. package/types/cjs/functions/evaluate/node-runtime/index.d.ts +1 -0
  50. package/types/cjs/functions/evaluate/node-runtime/init.d.ts +13 -0
  51. package/types/cjs/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  52. package/types/cjs/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  53. package/types/cjs/functions/evaluate/placeholder-runtime.d.ts +2 -0
  54. package/types/cjs/functions/extract-css-var-default-value.d.ts +1 -0
  55. package/types/cjs/functions/is-edge-runtime.d.ts +4 -0
  56. package/types/cjs/functions/on-change.d.ts +7 -0
  57. package/types/cjs/helpers/omit.d.ts +1 -0
  58. package/types/cjs/helpers/time.d.ts +1 -0
  59. package/types/esm/blocks/BaseText.d.ts +6 -0
  60. package/types/esm/blocks/raw-text/component-info.d.ts +2 -0
  61. package/types/esm/blocks/raw-text/index.d.ts +1 -0
  62. package/types/esm/blocks/raw-text/raw-text.d.ts +7 -0
  63. package/types/esm/blocks/textarea/component-info.d.ts +2 -0
  64. package/types/esm/blocks/textarea/index.d.ts +1 -0
  65. package/types/esm/blocks/textarea/textarea.d.ts +13 -0
  66. package/types/esm/components/content/index.d.ts +1 -0
  67. package/types/esm/components/error-boundary.d.ts +11 -0
  68. package/types/esm/constants/sdk-name.d.ts +1 -0
  69. package/types/esm/constants/sdk-version.d.ts +1 -1
  70. package/types/esm/functions/apply-patch-with-mutation.d.ts +10 -0
  71. package/types/esm/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  72. package/types/esm/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  73. package/types/esm/functions/evaluate/edge-runtime/index.d.ts +1 -0
  74. package/types/esm/functions/evaluate/node-runtime/index.d.ts +1 -0
  75. package/types/esm/functions/evaluate/node-runtime/init.d.ts +13 -0
  76. package/types/esm/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  77. package/types/esm/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  78. package/types/esm/functions/evaluate/placeholder-runtime.d.ts +2 -0
  79. package/types/esm/functions/extract-css-var-default-value.d.ts +1 -0
  80. package/types/esm/functions/is-edge-runtime.d.ts +4 -0
  81. package/types/esm/functions/on-change.d.ts +7 -0
  82. package/types/esm/helpers/omit.d.ts +1 -0
  83. package/types/esm/helpers/time.d.ts +1 -0
  84. package/lib/browser/USE_CLIENT_BUNDLE-2675ec3a.js +0 -703
  85. package/lib/browser/USE_CLIENT_BUNDLE-d62c0e9f.cjs +0 -21
  86. package/lib/browser/USE_SERVER_BUNDLE-22146bcb.cjs +0 -1
  87. package/lib/browser/USE_SERVER_BUNDLE-a878761a.js +0 -11
  88. package/lib/browser/bundle-4aca3c04.cjs +0 -169
  89. package/lib/browser/bundle-9acde1f6.js +0 -2832
  90. package/lib/edge/USE_CLIENT_BUNDLE-744a0d92.js +0 -703
  91. package/lib/edge/USE_CLIENT_BUNDLE-ad07ada0.cjs +0 -21
  92. package/lib/edge/USE_SERVER_BUNDLE-50d2bf59.cjs +0 -1
  93. package/lib/edge/USE_SERVER_BUNDLE-d2138019.js +0 -11
  94. package/lib/edge/bundle-6770809f.cjs +0 -189
  95. package/lib/node/USE_CLIENT_BUNDLE-2f8a2b0f.cjs +0 -21
  96. package/lib/node/USE_CLIENT_BUNDLE-bdfd3683.js +0 -703
  97. package/lib/node/USE_SERVER_BUNDLE-786cc2c7.cjs +0 -1
  98. package/lib/node/USE_SERVER_BUNDLE-a6561926.js +0 -11
  99. package/lib/node/bundle-8b02f7d4.cjs +0 -216
  100. package/lib/node/bundle-ca4c205c.js +0 -2953
@@ -1,703 +0,0 @@
1
- "use client";
2
- import { jsx as a, Fragment as w, jsxs as I } from "react/jsx-runtime";
3
- import { i as Z, g as H, a as $, b as O, c as E, d as R, e as p, f as _, h as V, _ as D, j as ee, l as te, k as ne, m as ie, t as ae, n as U, o as ce, p as re, q as le, r as oe, s as de, u as se, v as ue } from "./bundle-f748b05a.js";
4
- import { useRef as T, useState as C, useEffect as b, createContext as me } from "react";
5
- import { p as ge } from "./USE_SERVER_BUNDLE-d2138019.js";
6
- import { useRouter as fe } from "next/navigation";
7
- function J(e) {
8
- return /* @__PURE__ */ a(w, { children: Z(e.TagName) ? /* @__PURE__ */ a(w, { children: /* @__PURE__ */ a(e.TagName, { ...e.attributes, ...e.actionAttributes }) }) : /* @__PURE__ */ a(w, { children: typeof e.TagName == "string" ? /* @__PURE__ */ a(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) : /* @__PURE__ */ a(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) }) });
9
- }
10
- function ke(e) {
11
- function i() {
12
- return {
13
- ...e.attributes,
14
- [H()]: `${e.link ? "" : "builder-button"} ${e.attributes[H()] || ""}`,
15
- ...e.link ? {
16
- href: e.link,
17
- target: e.openLinkInNewTab ? "_blank" : void 0,
18
- role: "link"
19
- } : {
20
- role: "button"
21
- }
22
- };
23
- }
24
- return /* @__PURE__ */ a(
25
- J,
26
- {
27
- attributes: i(),
28
- TagName: e.link ? e.builderLinkComponent || "a" : "button",
29
- actionAttributes: {},
30
- children: e.text
31
- }
32
- );
33
- }
34
- function Ce(e) {
35
- return /* @__PURE__ */ a(
36
- J,
37
- {
38
- TagName: e.Wrapper,
39
- attributes: $({
40
- block: e.block,
41
- context: e.context
42
- }),
43
- actionAttributes: O({
44
- block: e.block,
45
- rootState: e.context.rootState,
46
- rootSetState: e.context.rootSetState,
47
- localState: e.context.localState,
48
- context: e.context.context,
49
- stripPrefix: !0
50
- }),
51
- children: e.children
52
- }
53
- );
54
- }
55
- function Ee(e) {
56
- function i() {
57
- return e.includeBlockProps ? {
58
- ...$({
59
- block: e.block,
60
- context: e.context
61
- }),
62
- ...O({
63
- block: e.block,
64
- rootState: e.context.rootState,
65
- rootSetState: e.context.rootSetState,
66
- localState: e.context.localState,
67
- context: e.context.context
68
- })
69
- } : {};
70
- }
71
- return /* @__PURE__ */ a(e.Wrapper, { ...e.wrapperProps, attributes: i(), children: e.children });
72
- }
73
- function we(e) {
74
- function i() {
75
- var r;
76
- return "builder-blocks" + ((r = e.blocks) != null && r.length ? "" : " no-blocks");
77
- }
78
- function s() {
79
- var r, g;
80
- E() && !((r = e.blocks) != null && r.length) && ((g = window.parent) == null || g.postMessage(
81
- {
82
- type: "builder.clickEmptyBlocks",
83
- data: {
84
- parentElementId: e.parent,
85
- dataPath: e.path
86
- }
87
- },
88
- "*"
89
- ));
90
- }
91
- function S() {
92
- var r, g;
93
- E() && !((r = e.blocks) != null && r.length) && ((g = window.parent) == null || g.postMessage(
94
- {
95
- type: "builder.hoverEmptyBlocks",
96
- data: {
97
- parentElementId: e.parent,
98
- dataPath: e.path
99
- }
100
- },
101
- "*"
102
- ));
103
- }
104
- return /* @__PURE__ */ I(w, { children: [
105
- /* @__PURE__ */ a(
106
- e.BlocksWrapper,
107
- {
108
- className: i() + " props-blocks-wrapper-7cd1560e",
109
- "builder-path": e.path,
110
- "builder-parent-id": e.parent,
111
- style: e.styleProp,
112
- onClick: (r) => s(),
113
- onMouseEnter: (r) => S(),
114
- onKeyPress: (r) => s(),
115
- ...e.BlocksWrapperProps,
116
- children: e.children
117
- }
118
- ),
119
- /* @__PURE__ */ a("style", { children: `.props-blocks-wrapper-7cd1560e {
120
- display: flex;
121
- flex-direction: column;
122
- align-items: stretch;
123
- }` })
124
- ] });
125
- }
126
- function Ie(e) {
127
- return /* @__PURE__ */ a("span", { children: e.children });
128
- }
129
- function Pe(e) {
130
- var r, g, v, h, f, o;
131
- function i() {
132
- var x;
133
- const d = e.image || e.src;
134
- if (!d || // We can auto add srcset for cdn.builder.io and shopify
135
- // images, otherwise you can supply this prop manually
136
- !(d.match(/builder\.io/) || d.match(/cdn\.shopify\.com/)))
137
- return e.srcset;
138
- if (e.srcset && ((x = e.image) != null && x.includes("builder.io/api/v1/image"))) {
139
- if (!e.srcset.includes(e.image.split("?")[0]))
140
- return console.debug("Removed given srcset"), R(d);
141
- } else if (e.image && !e.srcset)
142
- return R(d);
143
- return R(d);
144
- }
145
- function s() {
146
- var m;
147
- return (m = i == null ? void 0 : i()) != null && m.match(/builder\.io/) && !e.noWebp ? i().replace(/\?/g, "?format=webp&") : "";
148
- }
149
- function S() {
150
- const m = {
151
- position: "absolute",
152
- height: "100%",
153
- width: "100%",
154
- left: "0px",
155
- top: "0px"
156
- };
157
- return e.aspectRatio ? m : void 0;
158
- }
159
- return /* @__PURE__ */ I(w, { children: [
160
- /* @__PURE__ */ I(w, { children: [
161
- /* @__PURE__ */ I("picture", { children: [
162
- s() ? /* @__PURE__ */ a("source", { type: "image/webp", srcSet: s() }) : null,
163
- /* @__PURE__ */ a(
164
- "img",
165
- {
166
- loading: e.highPriority ? "eager" : "lazy",
167
- fetchPriority: e.highPriority ? "high" : "auto",
168
- alt: e.altText,
169
- role: e.altText ? void 0 : "presentation",
170
- style: {
171
- objectPosition: e.backgroundPosition || "center",
172
- objectFit: e.backgroundSize || "cover",
173
- ...S()
174
- },
175
- className: "builder-image" + (e.className ? " " + e.className : "") + " img-ac3dff4a",
176
- src: e.image,
177
- srcSet: i(),
178
- sizes: e.sizes
179
- }
180
- )
181
- ] }),
182
- e.aspectRatio && !((g = (r = e.builderBlock) == null ? void 0 : r.children) != null && g.length && e.fitContent) ? /* @__PURE__ */ a(
183
- "div",
184
- {
185
- className: "builder-image-sizer div-ac3dff4a",
186
- style: {
187
- paddingTop: e.aspectRatio * 100 + "%"
188
- }
189
- }
190
- ) : null,
191
- (h = (v = e.builderBlock) == null ? void 0 : v.children) != null && h.length && e.fitContent ? /* @__PURE__ */ a(w, { children: e.children }) : null,
192
- !e.fitContent && ((o = (f = e.builderBlock) == null ? void 0 : f.children) != null && o.length) ? /* @__PURE__ */ a("div", { className: "div-ac3dff4a-2", children: e.children }) : null
193
- ] }),
194
- /* @__PURE__ */ a("style", { children: `.img-ac3dff4a {
195
- opacity: 1;
196
- transition: opacity 0.2s ease-in-out;
197
- }.div-ac3dff4a {
198
- width: 100%;
199
- pointer-events: none;
200
- font-size: 0;
201
- }.div-ac3dff4a-2 {
202
- display: flex;
203
- flex-direction: column;
204
- align-items: stretch;
205
- position: absolute;
206
- top: 0;
207
- left: 0;
208
- width: 100%;
209
- height: 100%;
210
- }` })
211
- ] });
212
- }
213
- function Re(e) {
214
- return /* @__PURE__ */ a(
215
- "section",
216
- {
217
- ...e.attributes,
218
- style: {
219
- width: "100%",
220
- alignSelf: "stretch",
221
- flexGrow: 1,
222
- boxSizing: "border-box",
223
- maxWidth: e.maxWidth || 1200,
224
- display: "flex",
225
- flexDirection: "column",
226
- alignItems: "stretch",
227
- marginLeft: "auto",
228
- marginRight: "auto"
229
- },
230
- children: e.children
231
- }
232
- );
233
- }
234
- function Te(e) {
235
- const i = T(null), [s, S] = C(() => []), [r, g] = C(() => []);
236
- return b(() => {
237
- var h;
238
- if (!((h = i.current) != null && h.getElementsByTagName) || typeof window > "u")
239
- return;
240
- const v = i.current.getElementsByTagName("script");
241
- for (let f = 0; f < v.length; f++) {
242
- const o = v[f];
243
- if (o.src) {
244
- if (s.includes(o.src))
245
- continue;
246
- s.push(o.src);
247
- const m = document.createElement("script");
248
- m.async = !0, m.src = o.src, document.head.appendChild(m);
249
- } else if (!o.type || [
250
- "text/javascript",
251
- "application/javascript",
252
- "application/ecmascript"
253
- ].includes(o.type)) {
254
- if (r.includes(o.innerText))
255
- continue;
256
- try {
257
- r.push(o.innerText), new Function(o.innerText)();
258
- } catch (m) {
259
- console.warn("`CustomCode`: Error running script:", m);
260
- }
261
- }
262
- }
263
- }, []), /* @__PURE__ */ a(
264
- "div",
265
- {
266
- ref: i,
267
- className: "builder-custom-code" + (e.replaceNodes ? " replace-nodes" : ""),
268
- dangerouslySetInnerHTML: { __html: e.code }
269
- }
270
- );
271
- }
272
- function Ne(e) {
273
- const i = T(null), [s, S] = C(() => []), [r, g] = C(() => []), [v, h] = C(() => !1);
274
- function f() {
275
- if (!i.current || !i.current.getElementsByTagName)
276
- return;
277
- const o = i.current.getElementsByTagName("script");
278
- for (let m = 0; m < o.length; m++) {
279
- const d = o[m];
280
- if (d.src && !s.includes(d.src)) {
281
- s.push(d.src);
282
- const x = document.createElement("script");
283
- x.async = !0, x.src = d.src, document.head.appendChild(x);
284
- } else if (p(d) && !r.includes(d.innerText))
285
- try {
286
- r.push(d.innerText), new Function(d.innerText)();
287
- } catch (x) {
288
- console.warn("`Embed`: Error running script:", x);
289
- }
290
- }
291
- }
292
- return b(() => {
293
- i.current && !v && (h(!0), f());
294
- }, [i.current, v]), /* @__PURE__ */ a(
295
- "div",
296
- {
297
- className: "builder-embed",
298
- ref: i,
299
- dangerouslySetInnerHTML: { __html: e.content }
300
- }
301
- );
302
- }
303
- function Be(e) {
304
- return /* @__PURE__ */ a(
305
- "img",
306
- {
307
- style: {
308
- objectFit: e.backgroundSize || "cover",
309
- objectPosition: e.backgroundPosition || "center"
310
- },
311
- alt: e.altText,
312
- src: e.imgSrc || e.image,
313
- ...e.attributes
314
- },
315
- E() && e.imgSrc || "default-key"
316
- );
317
- }
318
- function Le(e) {
319
- var S, r, g, v, h, f, o;
320
- function i() {
321
- return {
322
- ...e.autoPlay === !0 ? {
323
- autoPlay: !0
324
- } : {},
325
- ...e.muted === !0 ? {
326
- muted: !0
327
- } : {},
328
- ...e.controls === !0 ? {
329
- controls: !0
330
- } : {},
331
- ...e.loop === !0 ? {
332
- loop: !0
333
- } : {},
334
- ...e.playsInline === !0 ? {
335
- playsInline: !0
336
- } : {}
337
- };
338
- }
339
- function s() {
340
- return {
341
- ...i()
342
- };
343
- }
344
- return /* @__PURE__ */ I(
345
- "div",
346
- {
347
- style: {
348
- position: "relative"
349
- },
350
- children: [
351
- /* @__PURE__ */ a(
352
- "video",
353
- {
354
- className: "builder-video",
355
- ...s(),
356
- preload: e.preload || "metadata",
357
- style: {
358
- width: "100%",
359
- height: "100%",
360
- ...(S = e.attributes) == null ? void 0 : S.style,
361
- objectFit: e.fit,
362
- objectPosition: e.position,
363
- // Hack to get object fit to work as expected and
364
- // not have the video overflow
365
- zIndex: 2,
366
- borderRadius: "1px",
367
- ...e.aspectRatio ? {
368
- position: "absolute"
369
- } : null
370
- },
371
- src: e.video || "no-src",
372
- poster: e.posterImage,
373
- children: e.lazyLoad ? null : /* @__PURE__ */ a("source", { type: "video/mp4", src: e.video })
374
- }
375
- ),
376
- e.aspectRatio && !(e.fitContent && ((g = (r = e.builderBlock) == null ? void 0 : r.children) != null && g.length)) ? /* @__PURE__ */ a(
377
- "div",
378
- {
379
- style: {
380
- width: "100%",
381
- paddingTop: e.aspectRatio * 100 + "%",
382
- pointerEvents: "none",
383
- fontSize: "0px"
384
- }
385
- }
386
- ) : null,
387
- (h = (v = e.builderBlock) == null ? void 0 : v.children) != null && h.length && e.fitContent ? /* @__PURE__ */ a(
388
- "div",
389
- {
390
- style: {
391
- display: "flex",
392
- flexDirection: "column",
393
- alignItems: "stretch"
394
- },
395
- children: e.children
396
- }
397
- ) : null,
398
- (o = (f = e.builderBlock) == null ? void 0 : f.children) != null && o.length && !e.fitContent ? /* @__PURE__ */ a(
399
- "div",
400
- {
401
- style: {
402
- pointerEvents: "none",
403
- display: "flex",
404
- flexDirection: "column",
405
- alignItems: "stretch",
406
- position: "absolute",
407
- top: "0",
408
- left: "0",
409
- width: "100%",
410
- height: "100%"
411
- },
412
- children: e.children
413
- }
414
- ) : null
415
- ]
416
- }
417
- );
418
- }
419
- const he = me({
420
- content: null,
421
- context: {},
422
- localState: void 0,
423
- rootSetState() {
424
- },
425
- rootState: {},
426
- apiKey: null,
427
- apiVersion: void 0,
428
- componentInfos: {},
429
- inheritedStyles: {},
430
- BlocksWrapper: "div",
431
- BlocksWrapperProps: {}
432
- });
433
- function je(e) {
434
- var W, K, A, F, z, M, q;
435
- const i = T(null);
436
- function s(n) {
437
- var l, c;
438
- const t = {
439
- ...e.builderContextSignal.rootState,
440
- ...n
441
- };
442
- e.builderContextSignal.rootSetState ? (c = (l = e.builderContextSignal).rootSetState) == null || c.call(l, t) : e.builderContextSignal.rootState = t;
443
- }
444
- function S(n) {
445
- var l, c, u, y, k;
446
- const t = {
447
- ...e.builderContextSignal.content,
448
- ...n,
449
- data: {
450
- ...(l = e.builderContextSignal.content) == null ? void 0 : l.data,
451
- ...n == null ? void 0 : n.data
452
- },
453
- meta: {
454
- ...(c = e.builderContextSignal.content) == null ? void 0 : c.meta,
455
- ...n == null ? void 0 : n.meta,
456
- breakpoints: ((u = n == null ? void 0 : n.meta) == null ? void 0 : u.breakpoints) || ((k = (y = e.builderContextSignal.content) == null ? void 0 : y.meta) == null ? void 0 : k.breakpoints)
457
- }
458
- };
459
- ge({
460
- value: t,
461
- key: t.id
462
- }).then(() => {
463
- X.refresh();
464
- });
465
- }
466
- function r() {
467
- return e.showContent ? {} : {
468
- hidden: !0,
469
- "aria-hidden": !0
470
- };
471
- }
472
- const [g, v] = C(
473
- () => e.contentWrapper || "div"
474
- );
475
- function h(n) {
476
- return ie({
477
- model: e.model,
478
- trustedHosts: e.trustedHosts,
479
- callbacks: {
480
- configureSdk: (t) => {
481
- var u;
482
- const { breakpoints: l, contentId: c } = t;
483
- !c || c !== ((u = e.builderContextSignal.content) == null ? void 0 : u.id) || l && S({
484
- meta: {
485
- breakpoints: l
486
- }
487
- });
488
- },
489
- animation: (t) => {
490
- ae(t);
491
- },
492
- contentUpdate: (t) => {
493
- S(t);
494
- }
495
- }
496
- })(n);
497
- }
498
- function f() {
499
- var t, l;
500
- const n = (l = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : l.jsCode;
501
- n && U({
502
- code: n,
503
- context: e.context || {},
504
- localState: void 0,
505
- rootState: e.builderContextSignal.rootState,
506
- rootSetState: e.builderContextSignal.rootSetState,
507
- /**
508
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
509
- */
510
- enableCache: !1
511
- });
512
- }
513
- const [o, m] = C(() => ({})), [d, x] = C(() => ({})), [N, G] = C(() => !1);
514
- function Q(n) {
515
- var t, l;
516
- if (e.builderContextSignal.content) {
517
- const c = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, u = (l = e.builderContextSignal.content) == null ? void 0 : l.id;
518
- D({
519
- type: "click",
520
- canTrack: V(e.canTrack),
521
- contentId: u,
522
- apiKey: e.apiKey,
523
- variationId: c !== u ? c : void 0,
524
- ...ce(n),
525
- unique: !N
526
- });
527
- }
528
- N || G(!0);
529
- }
530
- function B() {
531
- var t, l;
532
- const n = ((l = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : l.httpRequests) ?? {};
533
- Object.entries(n).forEach(([c, u]) => {
534
- if (!u || d[c] || o[c] && !E())
535
- return;
536
- d[c] = !0;
537
- const y = u.replace(
538
- /{{([^}]+)}}/g,
539
- (k, Y) => String(
540
- U({
541
- code: Y,
542
- context: e.context || {},
543
- localState: void 0,
544
- rootState: e.builderContextSignal.rootState,
545
- rootSetState: e.builderContextSignal.rootSetState,
546
- enableCache: !0
547
- })
548
- )
549
- );
550
- re(y).then((k) => k.json()).then((k) => {
551
- s({
552
- [c]: k
553
- }), o[c] = !0;
554
- }).catch((k) => {
555
- console.error("error fetching dynamic data", u, k);
556
- }).finally(() => {
557
- d[c] = !1;
558
- });
559
- });
560
- }
561
- function P() {
562
- E() && window.dispatchEvent(
563
- new CustomEvent(
564
- "builder:component:stateChange",
565
- {
566
- detail: {
567
- state: le(e.builderContextSignal.rootState),
568
- ref: {
569
- name: e.model
570
- }
571
- }
572
- }
573
- )
574
- );
575
- }
576
- function L(n) {
577
- window.addEventListener("message", h), oe(), de({
578
- ...e.locale ? {
579
- locale: e.locale
580
- } : {},
581
- ...e.enrich ? {
582
- enrich: e.enrich
583
- } : {},
584
- ...e.trustedHosts ? {
585
- trustedHosts: e.trustedHosts
586
- } : {}
587
- }), Object.values(
588
- e.builderContextSignal.componentInfos
589
- ).forEach((t) => {
590
- var c;
591
- const l = se(t);
592
- (c = window.parent) == null || c.postMessage(l, "*");
593
- }), window.addEventListener(
594
- "builder:component:stateChangeListenerActivated",
595
- P
596
- );
597
- }
598
- function j(n) {
599
- const t = new URL(location.href).searchParams, l = t.get("builder.preview"), c = t.get(
600
- `builder.overrides.${l}`
601
- ), u = t.get("apiKey") || t.get("builder.space");
602
- l === e.model && u === e.apiKey && (!e.content || c === e.content.id) && ue({
603
- model: e.model,
604
- apiKey: e.apiKey,
605
- apiVersion: e.builderContextSignal.apiVersion
606
- }).then((y) => {
607
- y && S(y);
608
- });
609
- }
610
- const X = fe();
611
- return b(() => {
612
- var n;
613
- return (n = i.current) == null || n.addEventListener(
614
- "initeditingbldr",
615
- L
616
- ), () => {
617
- var t;
618
- return (t = i.current) == null ? void 0 : t.removeEventListener(
619
- "initeditingbldr",
620
- L
621
- );
622
- };
623
- }, []), b(() => {
624
- var n;
625
- return (n = i.current) == null || n.addEventListener(
626
- "initpreviewingbldr",
627
- j
628
- ), () => {
629
- var t;
630
- return (t = i.current) == null ? void 0 : t.removeEventListener(
631
- "initpreviewingbldr",
632
- j
633
- );
634
- };
635
- }, []), b(() => {
636
- var n, t;
637
- if (_()) {
638
- if (E() && i.current && i.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && V(e.canTrack)) {
639
- const c = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, u = (t = e.builderContextSignal.content) == null ? void 0 : t.id, y = e.apiKey;
640
- D({
641
- type: "impression",
642
- canTrack: !0,
643
- contentId: u,
644
- apiKey: y,
645
- variationId: c !== u ? c : void 0
646
- });
647
- }
648
- ee() && E();
649
- }
650
- }, []), b(() => {
651
- e.apiKey || te.error(
652
- "No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
653
- ), f(), B(), P();
654
- }, []), b(() => {
655
- }, [e.content]), b(() => {
656
- f();
657
- }, [(K = (W = e.builderContextSignal.content) == null ? void 0 : W.data) == null ? void 0 : K.jsCode]), b(() => {
658
- B();
659
- }, [(F = (A = e.builderContextSignal.content) == null ? void 0 : A.data) == null ? void 0 : F.httpRequests]), b(() => {
660
- P();
661
- }, [e.builderContextSignal.rootState]), b(() => {
662
- e.data && s(e.data);
663
- }, [e.data]), b(() => {
664
- e.locale && s({
665
- locale: e.locale
666
- });
667
- }, [e.locale]), b(() => () => {
668
- _() && (window.removeEventListener("message", h), window.removeEventListener(
669
- "builder:component:stateChangeListenerActivated",
670
- P
671
- ));
672
- }, []), /* @__PURE__ */ a(he.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ a(
673
- g,
674
- {
675
- ref: i,
676
- onClick: (n) => Q(n),
677
- "builder-content-id": (z = e.builderContextSignal.content) == null ? void 0 : z.id,
678
- "builder-model": e.model,
679
- ...r(),
680
- ...e.contentWrapperProps,
681
- className: ne(
682
- ((M = e.content) == null ? void 0 : M.testVariationId) || ((q = e.content) == null ? void 0 : q.id)
683
- ),
684
- children: e.children
685
- }
686
- ) : null });
687
- }
688
- export {
689
- Ce as B,
690
- Te as C,
691
- J as D,
692
- Ne as E,
693
- Ie as F,
694
- Ee as I,
695
- Re as S,
696
- Le as V,
697
- we as a,
698
- Be as b,
699
- ke as c,
700
- Pe as d,
701
- je as e,
702
- he as f
703
- };