@builder.io/sdk-react 2.0.2 → 2.0.5

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 (85) hide show
  1. package/lib/browser/blocks-exports.cjs +29 -29
  2. package/lib/browser/blocks-exports.mjs +300 -278
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/init.cjs +1 -1
  6. package/lib/browser/init.mjs +1 -1
  7. package/lib/browser/server-entry-0c6c220c.js +688 -0
  8. package/lib/browser/server-entry-7e145817.cjs +2 -0
  9. package/lib/browser/server-entry.cjs +1 -1
  10. package/lib/browser/server-entry.mjs +1 -1
  11. package/lib/edge/{accordion-4f96554c.cjs → accordion-72dab8ce.cjs} +1 -1
  12. package/lib/edge/{accordion-ca081054.js → accordion-99129d68.js} +1 -1
  13. package/lib/edge/blocks-426e0c44.js +808 -0
  14. package/lib/edge/blocks-53ae1b87.cjs +12 -0
  15. package/lib/edge/blocks-exports.cjs +1 -1
  16. package/lib/edge/blocks-exports.mjs +2 -2
  17. package/lib/edge/{button-41169061.js → button-778062cd.js} +2 -2
  18. package/lib/edge/{button-5d140f8e.cjs → button-967d0268.cjs} +1 -1
  19. package/lib/edge/{columns-f8916a18.js → columns-3a8c4d3f.js} +53 -51
  20. package/lib/edge/columns-3b921658.cjs +28 -0
  21. package/lib/edge/{content-variants-71ee0c76.js → content-variants-15d191de.js} +28 -26
  22. package/lib/edge/content-variants-4b8718f8.cjs +134 -0
  23. package/lib/edge/evaluate-26c0fdb7.js +2615 -0
  24. package/lib/edge/evaluate-c0eeb4f8.cjs +21 -0
  25. package/lib/edge/form-9d9dce5d.cjs +1 -0
  26. package/lib/edge/{form-ac2f2a0e.js → form-ccb0b912.js} +8 -7
  27. package/lib/edge/{get-class-prop-name-a677d7a5.js → get-class-prop-name-0a91c3bd.js} +1 -1
  28. package/lib/edge/{get-class-prop-name-a9b4959e.cjs → get-class-prop-name-eae60eae.cjs} +1 -1
  29. package/lib/edge/{image-e3fcd611.js → image-6a074aab.js} +27 -25
  30. package/lib/edge/image-eebfcbac.cjs +17 -0
  31. package/lib/edge/{img-b91cb4fd.cjs → img-183de27d.cjs} +1 -1
  32. package/lib/edge/{img-8fc26395.js → img-75751c89.js} +1 -1
  33. package/lib/edge/index.cjs +1 -1
  34. package/lib/edge/index.mjs +1 -1
  35. package/lib/edge/init.cjs +1 -1
  36. package/lib/edge/init.mjs +1 -1
  37. package/lib/edge/{input-549f090e.js → input-27972020.js} +1 -1
  38. package/lib/edge/{input-ec7c695a.cjs → input-fd18a67d.cjs} +1 -1
  39. package/lib/edge/{select-6a5a28ac.js → select-60ff549c.js} +1 -1
  40. package/lib/edge/{select-3ffa9294.cjs → select-6ea0d59f.cjs} +1 -1
  41. package/lib/edge/server-entry-4133a544.cjs +2 -0
  42. package/lib/edge/server-entry-feff6177.js +689 -0
  43. package/lib/edge/server-entry.cjs +1 -1
  44. package/lib/edge/server-entry.mjs +1 -1
  45. package/lib/edge/{slot-40de071b.js → slot-2347377e.js} +12 -11
  46. package/lib/edge/slot-a4509cae.cjs +1 -0
  47. package/lib/edge/{symbol-76e76298.cjs → symbol-98650b06.cjs} +1 -1
  48. package/lib/edge/{symbol-e6515a5f.js → symbol-dcef0d8e.js} +2 -2
  49. package/lib/edge/{tabs-b75be82d.js → tabs-0784574b.js} +10 -9
  50. package/lib/edge/tabs-4c131e17.cjs +1 -0
  51. package/lib/edge/text-1c1986aa.cjs +1 -0
  52. package/lib/edge/text-6f7cbc35.js +38 -0
  53. package/lib/node/blocks-exports.cjs +16 -16
  54. package/lib/node/blocks-exports.mjs +255 -233
  55. package/lib/node/index.cjs +1 -1
  56. package/lib/node/index.mjs +2 -2
  57. package/lib/node/init.cjs +1 -1
  58. package/lib/node/init.mjs +2 -2
  59. package/lib/node/{node-runtime-0e37d6f7.cjs → node-runtime-4978bc21.cjs} +2 -2
  60. package/lib/node/{node-runtime-0f3a5df1.js → node-runtime-ce5c71e5.js} +3 -2
  61. package/lib/node/server-entry-0c6c220c.js +688 -0
  62. package/lib/node/server-entry-7e145817.cjs +2 -0
  63. package/lib/node/server-entry.cjs +1 -1
  64. package/lib/node/server-entry.mjs +1 -1
  65. package/package.json +1 -1
  66. package/types/blocks/image/image.types.d.ts +2 -0
  67. package/types/blocks/symbol/symbol.types.d.ts +1 -0
  68. package/types/constants/sdk-version.d.ts +1 -1
  69. package/types/functions/register-component.d.ts +2 -2
  70. package/lib/browser/server-entry-419c051e.cjs +0 -2
  71. package/lib/browser/server-entry-825b4408.js +0 -695
  72. package/lib/edge/blocks-078044bc.cjs +0 -32
  73. package/lib/edge/blocks-f55c7d3e.js +0 -3418
  74. package/lib/edge/columns-354bf349.cjs +0 -28
  75. package/lib/edge/content-variants-89a9389a.cjs +0 -134
  76. package/lib/edge/form-f2d2c2bf.cjs +0 -1
  77. package/lib/edge/image-344ddbb0.cjs +0 -17
  78. package/lib/edge/server-entry-966ac144.cjs +0 -2
  79. package/lib/edge/server-entry-d2020acf.js +0 -695
  80. package/lib/edge/slot-8b27e15e.cjs +0 -1
  81. package/lib/edge/tabs-9c5af0ec.cjs +0 -1
  82. package/lib/edge/text-5915f038.js +0 -17
  83. package/lib/edge/text-e6dbb721.cjs +0 -1
  84. package/lib/node/server-entry-5ebd1c9b.js +0 -695
  85. package/lib/node/server-entry-8002325b.cjs +0 -2
@@ -1,695 +0,0 @@
1
- const v = "react", b = "[Builder.io]: ", f = {
2
- log: (...e) => console.log(b, ...e),
3
- error: (...e) => console.error(b, ...e),
4
- warn: (...e) => console.warn(b, ...e),
5
- debug: (...e) => console.debug(b, ...e)
6
- };
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- const Q = (e) => {
11
- const t = {};
12
- return e.forEach((n, r) => {
13
- t[r] = n;
14
- }), t;
15
- }, L = (e) => e instanceof URLSearchParams ? Q(e) : e, V = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
16
- function Y() {
17
- return c() && window.self !== window.top;
18
- }
19
- function Z(e) {
20
- return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
21
- V(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
22
- }
23
- const ee = () => {
24
- if (c()) {
25
- const e = new URL(location.href);
26
- return e.pathname === "" && (e.pathname = "/"), e;
27
- } else
28
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
29
- }, te = () => typeof navigator == "object" && navigator.userAgent || "", ne = () => {
30
- const e = te(), t = {
31
- Android() {
32
- return e.match(/Android/i);
33
- },
34
- BlackBerry() {
35
- return e.match(/BlackBerry/i);
36
- },
37
- iOS() {
38
- return e.match(/iPhone|iPod/i);
39
- },
40
- Opera() {
41
- return e.match(/Opera Mini/i);
42
- },
43
- Windows() {
44
- return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
45
- },
46
- any() {
47
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
48
- }
49
- }, n = e.match(/Tablet|iPad/i), r = ee();
50
- return {
51
- urlPath: r == null ? void 0 : r.pathname,
52
- host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
53
- device: n ? "tablet" : t.any() ? "mobile" : "desktop"
54
- };
55
- }, m = (e) => e != null, U = (e) => JSON.parse(JSON.stringify(e)), re = (e) => {
56
- if (e === "localhost" || e === "127.0.0.1")
57
- return e;
58
- const t = e.split(".");
59
- return t.length > 2 ? t.slice(1).join(".") : e;
60
- }, M = ({
61
- name: e,
62
- canTrack: t
63
- }) => {
64
- var n;
65
- try {
66
- return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
67
- } catch (r) {
68
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
69
- return;
70
- }
71
- }, N = async (e) => M(e), oe = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), se = [["secure", ""], ["SameSite", "None"]], ie = ({
72
- name: e,
73
- value: t,
74
- expires: n
75
- }) => {
76
- const o = (c() ? location.protocol === "https:" : !0) ? se : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", re(window.location.hostname)], ...o];
77
- return oe(a);
78
- }, F = async ({
79
- name: e,
80
- value: t,
81
- expires: n,
82
- canTrack: r
83
- }) => {
84
- try {
85
- if (!r)
86
- return;
87
- const o = ie({
88
- name: e,
89
- value: t,
90
- expires: n
91
- });
92
- document.cookie = o;
93
- } catch (o) {
94
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
95
- }
96
- }, ae = "builder.tests", E = (e) => `${ae}.${e}`, ce = ({
97
- contentId: e
98
- }) => N({
99
- name: E(e),
100
- canTrack: !0
101
- }), ue = ({
102
- contentId: e
103
- }) => M({
104
- name: E(e),
105
- canTrack: !0
106
- }), de = ({
107
- contentId: e,
108
- value: t
109
- }) => F({
110
- name: E(e),
111
- value: t,
112
- canTrack: !0
113
- }), j = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, le = ({
114
- id: e,
115
- variations: t
116
- }) => {
117
- var o;
118
- let n = 0;
119
- const r = Math.random();
120
- for (const s in t) {
121
- const a = (o = t[s]) == null ? void 0 : o.testRatio;
122
- if (n += a, r < n)
123
- return s;
124
- }
125
- return e;
126
- }, D = (e) => {
127
- const t = le(e);
128
- return de({
129
- contentId: e.id,
130
- value: t
131
- }).catch((n) => {
132
- f.error("could not store A/B test variation: ", n);
133
- }), t;
134
- }, K = ({
135
- item: e,
136
- testGroupId: t
137
- }) => {
138
- const n = e.variations[t];
139
- return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
140
- !n ? {
141
- testVariationId: e.id,
142
- testVariationName: "Default"
143
- } : {
144
- data: n.data,
145
- testVariationId: n.id,
146
- testVariationName: n.name || (n.id === e.id ? "Default" : "")
147
- };
148
- }, Ge = ({
149
- item: e,
150
- canTrack: t
151
- }) => {
152
- if (!t)
153
- return e;
154
- if (!e)
155
- return;
156
- if (!j(e))
157
- return e;
158
- const n = ue({
159
- contentId: e.id
160
- }) || D({
161
- variations: e.variations,
162
- id: e.id
163
- }), r = K({
164
- item: e,
165
- testGroupId: n
166
- });
167
- return {
168
- ...e,
169
- ...r
170
- };
171
- }, fe = async ({
172
- item: e,
173
- canTrack: t
174
- }) => {
175
- if (!t || !j(e))
176
- return e;
177
- const r = await ce({
178
- contentId: e.id
179
- }) || D({
180
- variations: e.variations,
181
- id: e.id
182
- }), o = K({
183
- item: e,
184
- testGroupId: r
185
- });
186
- return {
187
- ...e,
188
- ...o
189
- };
190
- }, he = (e) => m(e) ? e : !0, ze = (e) => ({
191
- type: "builder.registerComponent",
192
- data: me(e)
193
- }), ge = (e) => {
194
- const t = e.toString().trim();
195
- return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
196
- }, pe = (e) => typeof e == "function" ? ge(e) : U(e), me = ({
197
- inputs: e,
198
- ...t
199
- }) => ({
200
- ...U(t),
201
- inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
202
- ...r,
203
- [o]: pe(s)
204
- }), {}))
205
- });
206
- function ye() {
207
- return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
208
- }
209
- function we() {
210
- const e = ye().fetch;
211
- if (typeof e == "undefined")
212
- throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
213
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
214
- return e;
215
- }
216
- const Se = we();
217
- function k(e, t = null, n = ".") {
218
- return Object.keys(e).reduce((r, o) => {
219
- const s = e[o], a = [t, o].filter(Boolean).join(n);
220
- return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
221
- ...r,
222
- ...k(s, a, n)
223
- } : {
224
- ...r,
225
- [a]: s
226
- };
227
- }, {});
228
- }
229
- function W(e, t, n = {}) {
230
- for (const r in e) {
231
- const o = e[r], s = t ? t + "." + r : r;
232
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? W(o, s, n) : n[s] = o;
233
- }
234
- return n;
235
- }
236
- const be = "v3", x = "builder.", ve = "options.", _ = (e) => {
237
- if (!e)
238
- return {};
239
- const t = L(e), n = {};
240
- return Object.keys(t).forEach((r) => {
241
- if (r.startsWith(x)) {
242
- const o = r.replace(x, "").replace(ve, "");
243
- n[o] = t[r];
244
- }
245
- }), n;
246
- }, Ie = () => {
247
- if (!c())
248
- return {};
249
- const e = new URLSearchParams(window.location.search);
250
- return _(e);
251
- }, A = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
252
- const {
253
- limit: t = 30,
254
- userAttributes: n,
255
- query: r,
256
- model: o,
257
- apiKey: s,
258
- enrich: a,
259
- locale: d,
260
- apiVersion: y = be,
261
- fields: p,
262
- omit: I,
263
- offset: u,
264
- cacheSeconds: h,
265
- staleCacheSeconds: g,
266
- sort: w,
267
- includeUnpublished: P
268
- } = e;
269
- if (!s)
270
- throw new Error("Missing API key");
271
- if (!["v3"].includes(y))
272
- throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
273
- const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
274
- if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && A(h) && i.searchParams.set("cacheSeconds", String(h)), g && A(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
275
- const l = k({
276
- sort: w
277
- });
278
- for (const S in l)
279
- i.searchParams.set(S, JSON.stringify(l[S]));
280
- }
281
- const q = {
282
- ...Ie(),
283
- ...L(e.options || {})
284
- }, C = k(q);
285
- for (const l in C)
286
- i.searchParams.set(l, String(C[l]));
287
- if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
288
- const l = W({
289
- query: r
290
- });
291
- for (const S in l)
292
- i.searchParams.set(S, JSON.stringify(l[S]));
293
- }
294
- return i;
295
- }, ke = (e) => "results" in e;
296
- async function Ee(e) {
297
- const t = await Ce({
298
- ...e,
299
- limit: 1
300
- });
301
- return t && t[0] || null;
302
- }
303
- const Oe = async (e) => {
304
- var s;
305
- const t = O(e);
306
- return await (await ((s = e.fetch) != null ? s : Se)(t.href, e.fetchOptions)).json();
307
- }, Pe = async (e, t, n = O(e)) => {
308
- const r = he(e.canTrack);
309
- if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
310
- return t.results;
311
- try {
312
- const o = [];
313
- for (const s of t.results)
314
- o.push(await fe({
315
- item: s,
316
- canTrack: r
317
- }));
318
- t.results = o;
319
- } catch (o) {
320
- f.error("Could not process A/B tests. ", o);
321
- }
322
- return t.results;
323
- };
324
- async function Ce(e) {
325
- try {
326
- const t = O(e), n = await Oe(e);
327
- return ke(n) ? Pe(e, n) : (f.error("Error fetching data. ", {
328
- url: t,
329
- content: n,
330
- options: e
331
- }), null);
332
- } catch (t) {
333
- return f.error("Error fetching data. ", t), null;
334
- }
335
- }
336
- function Je(e) {
337
- const t = e || (c() ? window.location.search : void 0);
338
- return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
339
- }
340
- function xe() {
341
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
342
- const t = Math.random() * 16 | 0;
343
- return (e == "x" ? t : t & 3 | 8).toString(16);
344
- });
345
- }
346
- function $() {
347
- return xe().replace(/-/g, "");
348
- }
349
- const G = "builderSessionId", Ae = async ({
350
- canTrack: e
351
- }) => {
352
- if (!e)
353
- return;
354
- const t = await N({
355
- name: G,
356
- canTrack: e
357
- });
358
- if (m(t))
359
- return t;
360
- {
361
- const n = Te();
362
- return Re({
363
- id: n,
364
- canTrack: e
365
- }), n;
366
- }
367
- }, Te = () => $(), Re = ({
368
- id: e,
369
- canTrack: t
370
- }) => F({
371
- name: G,
372
- value: e,
373
- canTrack: t
374
- }), z = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Be = ({
375
- key: e,
376
- canTrack: t
377
- }) => {
378
- var n;
379
- try {
380
- return t ? (n = z()) == null ? void 0 : n.getItem(e) : void 0;
381
- } catch (r) {
382
- console.debug("[LocalStorage] GET error: ", r);
383
- return;
384
- }
385
- }, Le = ({
386
- key: e,
387
- canTrack: t,
388
- value: n
389
- }) => {
390
- var r;
391
- try {
392
- t && ((r = z()) == null || r.setItem(e, n));
393
- } catch (o) {
394
- console.debug("[LocalStorage] SET error: ", o);
395
- }
396
- }, J = "builderVisitorId", Ve = ({
397
- canTrack: e
398
- }) => {
399
- if (!e)
400
- return;
401
- const t = Be({
402
- key: J,
403
- canTrack: e
404
- });
405
- if (m(t))
406
- return t;
407
- {
408
- const n = Ue();
409
- return Me({
410
- id: n,
411
- canTrack: e
412
- }), n;
413
- }
414
- }, Ue = () => $(), Me = ({
415
- id: e,
416
- canTrack: t
417
- }) => Le({
418
- key: J,
419
- value: e,
420
- canTrack: t
421
- }), Ne = async ({
422
- canTrack: e
423
- }) => {
424
- if (!e)
425
- return {
426
- visitorId: void 0,
427
- sessionId: void 0
428
- };
429
- const t = await Ae({
430
- canTrack: e
431
- }), n = Ve({
432
- canTrack: e
433
- });
434
- return {
435
- sessionId: t,
436
- visitorId: n
437
- };
438
- }, Fe = async ({
439
- type: e,
440
- canTrack: t,
441
- apiKey: n,
442
- metadata: r,
443
- ...o
444
- }) => ({
445
- type: e,
446
- data: {
447
- ...o,
448
- metadata: {
449
- url: location.href,
450
- ...r
451
- },
452
- ...await Ne({
453
- canTrack: t
454
- }),
455
- userAttributes: ne(),
456
- ownerId: n
457
- }
458
- });
459
- async function je(e) {
460
- if (!e.apiKey) {
461
- f.error("Missing API key for track call. Please provide your API key.");
462
- return;
463
- }
464
- if (e.canTrack && !Z() && (c() || v === "reactNative"))
465
- return fetch("https://cdn.builder.io/api/v1/track", {
466
- method: "POST",
467
- body: JSON.stringify({
468
- events: [await Fe(e)]
469
- }),
470
- headers: {
471
- "content-type": "application/json"
472
- },
473
- mode: "cors"
474
- }).catch((t) => {
475
- console.error("Failed to track: ", t);
476
- });
477
- }
478
- const He = (e) => je({
479
- ...e,
480
- canTrack: !0
481
- }), De = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
482
- function H(e, t) {
483
- if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
484
- return !1;
485
- const n = new URL(t.origin), r = n.hostname;
486
- return (e || De).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
487
- }
488
- const Ke = "2.0.2", T = {};
489
- function We(e, t) {
490
- let n = T[e];
491
- if (n || (n = T[e] = []), n.push(t), c()) {
492
- const r = {
493
- type: "builder.register",
494
- data: {
495
- type: e,
496
- info: t
497
- }
498
- };
499
- try {
500
- parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
501
- } catch (o) {
502
- console.debug("Could not postmessage", o);
503
- }
504
- }
505
- }
506
- const Xe = () => {
507
- We("insertMenu", {
508
- name: "_default",
509
- default: !0,
510
- items: [{
511
- name: "Box"
512
- }, {
513
- name: "Text"
514
- }, {
515
- name: "Image"
516
- }, {
517
- name: "Columns"
518
- }, {
519
- name: "Core:Section"
520
- }, {
521
- name: "Core:Button"
522
- }, {
523
- name: "Embed"
524
- }, {
525
- name: "Custom Code"
526
- }]
527
- });
528
- };
529
- let R = !1;
530
- const _e = (e = {}) => {
531
- var t, n;
532
- R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
533
- type: "builder.sdkInfo",
534
- data: {
535
- target: v,
536
- version: Ke,
537
- supportsPatchUpdates: !1,
538
- // Supports builder-model="..." attribute which is needed to
539
- // scope our '+ add block' button styling
540
- supportsAddBlockScoping: !0,
541
- supportsCustomBreakpoints: !0
542
- }
543
- }, "*"), (n = window.parent) == null || n.postMessage({
544
- type: "builder.updateContent",
545
- data: {
546
- options: e
547
- }
548
- }, "*"), window.addEventListener("message", (r) => {
549
- var s, a;
550
- if (!H(e.trustedHosts, r))
551
- return;
552
- const {
553
- data: o
554
- } = r;
555
- if (o != null && o.type)
556
- switch (o.type) {
557
- case "builder.evaluate": {
558
- const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
559
- let u, h = null;
560
- try {
561
- u = I.apply(null, y);
562
- } catch (g) {
563
- h = g;
564
- }
565
- h ? (s = window.parent) == null || s.postMessage({
566
- type: "builder.evaluateError",
567
- data: {
568
- id: p,
569
- error: h.message
570
- }
571
- }, "*") : u && typeof u.then == "function" ? u.then((g) => {
572
- var w;
573
- (w = window.parent) == null || w.postMessage({
574
- type: "builder.evaluateResult",
575
- data: {
576
- id: p,
577
- result: g
578
- }
579
- }, "*");
580
- }).catch(console.error) : (a = window.parent) == null || a.postMessage({
581
- type: "builder.evaluateResult",
582
- data: {
583
- result: u,
584
- id: p
585
- }
586
- }, "*");
587
- break;
588
- }
589
- }
590
- })));
591
- }, $e = ({
592
- model: e,
593
- trustedHosts: t,
594
- callbacks: n
595
- }) => (r) => {
596
- if (!H(t, r))
597
- return;
598
- const {
599
- data: o
600
- } = r;
601
- if (o)
602
- switch (o.type) {
603
- case "builder.configureSdk": {
604
- n.configureSdk(o.data);
605
- break;
606
- }
607
- case "builder.triggerAnimation": {
608
- n.animation(o.data);
609
- break;
610
- }
611
- case "builder.contentUpdate": {
612
- const s = o.data, a = s.key || s.alias || s.entry || s.modelName, d = s.data;
613
- a === e && n.contentUpdate(d);
614
- break;
615
- }
616
- }
617
- }, qe = (e, t, n) => {
618
- if (!c)
619
- return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
620
- };
621
- _e();
622
- const r = $e({
623
- callbacks: {
624
- contentUpdate: t,
625
- animation: () => {
626
- },
627
- configureSdk: () => {
628
- }
629
- },
630
- model: e,
631
- trustedHosts: n == null ? void 0 : n.trustedHosts
632
- });
633
- return window.addEventListener("message", r), () => {
634
- window.removeEventListener("message", r);
635
- };
636
- }, B = {};
637
- function Qe(e) {
638
- if (c()) {
639
- Object.assign(B, e);
640
- const t = {
641
- type: "builder.settingsChange",
642
- data: B
643
- };
644
- parent.postMessage(t, "*");
645
- }
646
- }
647
- const Ye = async (e) => {
648
- var r, o, s;
649
- const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
650
- ...e,
651
- apiKey: e.apiKey,
652
- model: e.model || "page",
653
- userAttributes: {
654
- ...e.userAttributes,
655
- ...t ? {
656
- urlPath: t
657
- } : {}
658
- },
659
- options: _(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
660
- };
661
- return {
662
- apiKey: n.apiKey,
663
- model: n.model,
664
- content: await Ee(n)
665
- };
666
- };
667
- export {
668
- b as MSG_PREFIX,
669
- v as TARGET,
670
- Pe as _processContentResult,
671
- je as _track,
672
- m as checkIsDefined,
673
- $e as createEditorListener,
674
- ze as createRegisterComponentMessage,
675
- U as fastClone,
676
- Se as fetch,
677
- Ye as fetchBuilderProps,
678
- Ce as fetchEntries,
679
- Ee as fetchOneEntry,
680
- _ as getBuilderSearchParams,
681
- he as getDefaultCanTrack,
682
- ne as getUserAttributes,
683
- Ge as handleABTestingSync,
684
- c as isBrowser,
685
- Z as isEditing,
686
- Je as isPreviewing,
687
- f as logger,
688
- We as register,
689
- Xe as registerInsertMenu,
690
- me as serializeComponentInfo,
691
- Qe as setEditorSettings,
692
- _e as setupBrowserForEditing,
693
- qe as subscribeToEditor,
694
- He as track
695
- };