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