@builder.io/sdk-react 2.0.24 → 2.0.25

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 (67) hide show
  1. package/lib/browser/blocks-exports.cjs +1 -1
  2. package/lib/browser/blocks-exports.mjs +1 -1
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/server-entry-350f7ecc.js +701 -0
  6. package/lib/browser/server-entry-f8b08c1e.cjs +2 -0
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-bb9fa8d9.cjs → accordion-d14d05aa.cjs} +1 -1
  10. package/lib/edge/{accordion-5b929fba.js → accordion-e2aeca0a.js} +1 -1
  11. package/lib/edge/{blocks-cff95ab8.cjs → blocks-5a60a8fa.cjs} +1 -1
  12. package/lib/edge/{blocks-e8701f70.js → blocks-9a763eda.js} +3 -3
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-dd9c397c.js → button-265653d5.js} +2 -2
  16. package/lib/edge/{button-89adbac2.cjs → button-6ab0c490.cjs} +1 -1
  17. package/lib/edge/{columns-acd49f06.js → columns-346d4ab7.js} +4 -4
  18. package/lib/edge/{columns-b0cfdce7.cjs → columns-449335a4.cjs} +1 -1
  19. package/lib/edge/{content-variants-56c457f6.cjs → content-variants-71459280.cjs} +1 -1
  20. package/lib/edge/{content-variants-2cbf3c83.js → content-variants-bdb3d738.js} +11 -11
  21. package/lib/edge/{evaluate-68711886.js → evaluate-be86a5d8.js} +1 -1
  22. package/lib/edge/{evaluate-efa88e4b.cjs → evaluate-db1f9237.cjs} +1 -1
  23. package/lib/edge/{form-060579d1.js → form-41305e00.js} +4 -4
  24. package/lib/edge/{form-85e86f80.cjs → form-90310cab.cjs} +1 -1
  25. package/lib/edge/{get-class-prop-name-d6d04e54.cjs → get-class-prop-name-711d58eb.cjs} +1 -1
  26. package/lib/edge/{get-class-prop-name-bb0664a1.js → get-class-prop-name-b49b7684.js} +1 -1
  27. package/lib/edge/{img-7267e34a.cjs → img-1ab7ba48.cjs} +1 -1
  28. package/lib/edge/{img-cb9a2e73.js → img-a75bf17b.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +1 -1
  31. package/lib/edge/{input-0a7941d1.cjs → input-137d07aa.cjs} +1 -1
  32. package/lib/edge/{input-99f775bd.js → input-6c50146c.js} +1 -1
  33. package/lib/edge/{select-9791ad44.cjs → select-55d2c8fa.cjs} +1 -1
  34. package/lib/edge/{select-88a74342.js → select-b6c2fdd5.js} +1 -1
  35. package/lib/edge/server-entry-ae44ef40.cjs +2 -0
  36. package/lib/edge/server-entry-e914f16e.js +699 -0
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-28b25c84.js → slot-84e40920.js} +4 -4
  40. package/lib/edge/{slot-d3b5cdb8.cjs → slot-8d3b7707.cjs} +1 -1
  41. package/lib/edge/{symbol-f0ba82bf.cjs → symbol-468348d8.cjs} +1 -1
  42. package/lib/edge/{symbol-1ab0fb76.js → symbol-7436ff06.js} +2 -2
  43. package/lib/edge/{tabs-a04af934.js → tabs-65d455da.js} +4 -4
  44. package/lib/edge/{tabs-fad92db1.cjs → tabs-802a32f0.cjs} +1 -1
  45. package/lib/edge/{text-3c4c2e24.js → text-423e3303.js} +2 -2
  46. package/lib/edge/{text-ee3d6be2.cjs → text-450bf7e4.cjs} +1 -1
  47. package/lib/node/blocks-exports.cjs +1 -1
  48. package/lib/node/blocks-exports.mjs +2 -2
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +2 -2
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +2 -2
  53. package/lib/node/server-entry-569f32b2.js +702 -0
  54. package/lib/node/server-entry-781dde88.cjs +2 -0
  55. package/lib/node/server-entry.cjs +1 -1
  56. package/lib/node/server-entry.mjs +1 -1
  57. package/lib/node/{should-force-browser-runtime-in-node-411c24f8.cjs → should-force-browser-runtime-in-node-13070d3a.cjs} +1 -1
  58. package/lib/node/{should-force-browser-runtime-in-node-2251f2e6.js → should-force-browser-runtime-in-node-3f610831.js} +1 -1
  59. package/package.json +1 -1
  60. package/types/constants/sdk-version.d.ts +1 -1
  61. package/types/helpers/sdk-headers.d.ts +5 -0
  62. package/lib/browser/server-entry-0dfca5e0.cjs +0 -2
  63. package/lib/browser/server-entry-578cd6e2.js +0 -690
  64. package/lib/edge/server-entry-a7db0ef9.js +0 -688
  65. package/lib/edge/server-entry-cb6fb618.cjs +0 -2
  66. package/lib/node/server-entry-2ce603a9.cjs +0 -2
  67. package/lib/node/server-entry-bf8bf121.js +0 -691
@@ -1,691 +0,0 @@
1
- const v = "react", b = "[Builder.io]: ", f = {
2
- log: (...t) => console.log(b, ...t),
3
- error: (...t) => console.error(b, ...t),
4
- warn: (...t) => console.warn(b, ...t),
5
- debug: (...t) => console.debug(b, ...t)
6
- };
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- const Q = (t) => {
11
- const e = {};
12
- return t.forEach((n, r) => {
13
- e[r] = n;
14
- }), e;
15
- }, L = (t) => t instanceof URLSearchParams ? Q(t) : t, V = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
16
- function Y() {
17
- return c() && window.self !== window.top;
18
- }
19
- function Z(t) {
20
- return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
21
- V(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
22
- }
23
- const tt = () => {
24
- if (c()) {
25
- const t = new URL(location.href);
26
- return t.pathname === "" && (t.pathname = "/"), t;
27
- } else
28
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
29
- }, et = () => typeof navigator == "object" && navigator.userAgent || "", nt = () => {
30
- const t = et(), e = {
31
- Android() {
32
- return t.match(/Android/i);
33
- },
34
- BlackBerry() {
35
- return t.match(/BlackBerry/i);
36
- },
37
- iOS() {
38
- return t.match(/iPhone|iPod/i);
39
- },
40
- Opera() {
41
- return t.match(/Opera Mini/i);
42
- },
43
- Windows() {
44
- return t.match(/IEMobile/i) || t.match(/WPDesktop/i);
45
- },
46
- any() {
47
- return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || v === "reactNative";
48
- }
49
- }, n = t.match(/Tablet|iPad/i), r = tt();
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" : e.any() ? "mobile" : "desktop"
54
- };
55
- }, m = (t) => t != null;
56
- function _t(t) {
57
- const e = t || (c() ? window.location.search : void 0);
58
- return e ? V(e).indexOf("builder.preview=") !== -1 : !1;
59
- }
60
- const $t = (t) => ({
61
- type: "builder.registerComponent",
62
- data: U(t)
63
- }), rt = (t) => {
64
- const e = t.toString().trim();
65
- return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
66
- };
67
- function U(t) {
68
- return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? rt(n) : n));
69
- }
70
- const x = {};
71
- function ot(t, e) {
72
- t === "plugin" && (e = U(e));
73
- let n = x[t];
74
- if (n || (n = x[t] = []), n.push(e), c()) {
75
- const r = {
76
- type: "builder.register",
77
- data: {
78
- type: t,
79
- info: e
80
- }
81
- };
82
- try {
83
- parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
84
- } catch (o) {
85
- console.debug("Could not postmessage", o);
86
- }
87
- }
88
- }
89
- const A = {};
90
- function Gt(t) {
91
- if (c()) {
92
- Object.assign(A, t);
93
- const e = {
94
- type: "builder.settingsChange",
95
- data: A
96
- };
97
- parent.postMessage(e, "*");
98
- }
99
- }
100
- const T = "builder.", st = "options.", M = (t) => {
101
- if (!t)
102
- return {};
103
- const e = L(t), n = {};
104
- return Object.keys(e).forEach((r) => {
105
- if (r.startsWith(T)) {
106
- const o = r.replace(T, "").replace(st, "");
107
- n[o] = e[r];
108
- }
109
- }), n;
110
- }, it = () => {
111
- if (!c())
112
- return {};
113
- const t = new URLSearchParams(window.location.search);
114
- return M(t);
115
- }, at = (t) => {
116
- if (t === "localhost" || t === "127.0.0.1")
117
- return t;
118
- const e = t.split(".");
119
- return e.length > 2 ? e.slice(1).join(".") : t;
120
- }, F = ({
121
- name: t,
122
- canTrack: e
123
- }) => {
124
- var n;
125
- try {
126
- return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
127
- } catch (r) {
128
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
129
- return;
130
- }
131
- }, N = async (t) => F(t), ct = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(m).join("; "), ut = [["secure", ""], ["SameSite", "None"]], dt = ({
132
- name: t,
133
- value: e,
134
- expires: n
135
- }) => {
136
- const o = (c() ? location.protocol === "https:" : !0) ? ut : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", at(window.location.hostname)], ...o];
137
- return ct(a);
138
- }, j = async ({
139
- name: t,
140
- value: e,
141
- expires: n,
142
- canTrack: r
143
- }) => {
144
- try {
145
- if (!r)
146
- return;
147
- const o = dt({
148
- name: t,
149
- value: e,
150
- expires: n
151
- });
152
- document.cookie = o;
153
- } catch (o) {
154
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
155
- }
156
- };
157
- function lt() {
158
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
159
- const e = Math.random() * 16 | 0;
160
- return (t == "x" ? e : e & 3 | 8).toString(16);
161
- });
162
- }
163
- function D() {
164
- return lt().replace(/-/g, "");
165
- }
166
- const K = "builderSessionId", ft = async ({
167
- canTrack: t
168
- }) => {
169
- if (!t)
170
- return;
171
- const e = await N({
172
- name: K,
173
- canTrack: t
174
- });
175
- if (m(e))
176
- return e;
177
- {
178
- const n = ht();
179
- return gt({
180
- id: n,
181
- canTrack: t
182
- }), n;
183
- }
184
- }, ht = () => D(), gt = ({
185
- id: t,
186
- canTrack: e
187
- }) => j({
188
- name: K,
189
- value: t,
190
- canTrack: e
191
- }), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, pt = ({
192
- key: t,
193
- canTrack: e
194
- }) => {
195
- var n;
196
- try {
197
- return e ? (n = W()) == null ? void 0 : n.getItem(t) : void 0;
198
- } catch (r) {
199
- console.debug("[LocalStorage] GET error: ", r);
200
- return;
201
- }
202
- }, mt = ({
203
- key: t,
204
- canTrack: e,
205
- value: n
206
- }) => {
207
- var r;
208
- try {
209
- e && ((r = W()) == null || r.setItem(t, n));
210
- } catch (o) {
211
- console.debug("[LocalStorage] SET error: ", o);
212
- }
213
- }, _ = "builderVisitorId", yt = ({
214
- canTrack: t
215
- }) => {
216
- if (!t)
217
- return;
218
- const e = pt({
219
- key: _,
220
- canTrack: t
221
- });
222
- if (m(e))
223
- return e;
224
- {
225
- const n = wt();
226
- return St({
227
- id: n,
228
- canTrack: t
229
- }), n;
230
- }
231
- }, wt = () => D(), St = ({
232
- id: t,
233
- canTrack: e
234
- }) => mt({
235
- key: _,
236
- value: t,
237
- canTrack: e
238
- }), bt = async ({
239
- canTrack: t
240
- }) => {
241
- if (!t)
242
- return {
243
- visitorId: void 0,
244
- sessionId: void 0
245
- };
246
- const e = await ft({
247
- canTrack: t
248
- }), n = yt({
249
- canTrack: t
250
- });
251
- return {
252
- sessionId: e,
253
- visitorId: n
254
- };
255
- }, vt = async ({
256
- type: t,
257
- canTrack: e,
258
- apiKey: n,
259
- metadata: r,
260
- ...o
261
- }) => ({
262
- type: t,
263
- data: {
264
- ...o,
265
- metadata: {
266
- url: location.href,
267
- ...r
268
- },
269
- ...await bt({
270
- canTrack: e
271
- }),
272
- userAttributes: nt(),
273
- ownerId: n
274
- }
275
- });
276
- async function It(t) {
277
- if (!t.apiKey) {
278
- f.error("Missing API key for track call. Please provide your API key.");
279
- return;
280
- }
281
- if (t.canTrack && !Z() && (c() || v === "reactNative"))
282
- return fetch("https://cdn.builder.io/api/v1/track", {
283
- method: "POST",
284
- body: JSON.stringify({
285
- events: [await vt(t)]
286
- }),
287
- headers: {
288
- "content-type": "application/json"
289
- },
290
- mode: "cors"
291
- }).catch((e) => {
292
- console.error("Failed to track: ", e);
293
- });
294
- }
295
- const Jt = (t) => It({
296
- ...t,
297
- canTrack: !0
298
- }), kt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
299
- function $(t, e) {
300
- if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
301
- return !1;
302
- const n = new URL(e.origin), r = n.hostname;
303
- return (t || kt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
304
- }
305
- const Et = "2.0.24", zt = () => {
306
- ot("insertMenu", {
307
- name: "_default",
308
- default: !0,
309
- items: [{
310
- name: "Box"
311
- }, {
312
- name: "Text"
313
- }, {
314
- name: "Image"
315
- }, {
316
- name: "Columns"
317
- }, {
318
- name: "Core:Section"
319
- }, {
320
- name: "Core:Button"
321
- }, {
322
- name: "Embed"
323
- }, {
324
- name: "Custom Code"
325
- }]
326
- });
327
- };
328
- let R = !1;
329
- const Pt = (t = {}) => {
330
- var e, n;
331
- R || (R = !0, c() && ((e = window.parent) == null || e.postMessage({
332
- type: "builder.sdkInfo",
333
- data: {
334
- target: v,
335
- version: Et,
336
- supportsPatchUpdates: !1,
337
- // Supports builder-model="..." attribute which is needed to
338
- // scope our '+ add block' button styling
339
- supportsAddBlockScoping: !0,
340
- supportsCustomBreakpoints: !0
341
- }
342
- }, "*"), (n = window.parent) == null || n.postMessage({
343
- type: "builder.updateContent",
344
- data: {
345
- options: t
346
- }
347
- }, "*"), window.addEventListener("message", (r) => {
348
- var s, a;
349
- if (!$(t.trustedHosts, r))
350
- return;
351
- const {
352
- data: o
353
- } = r;
354
- if (o != null && o.type)
355
- switch (o.type) {
356
- case "builder.evaluate": {
357
- const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
358
- let u, h = null;
359
- try {
360
- u = I.apply(null, y);
361
- } catch (g) {
362
- h = g;
363
- }
364
- h ? (s = window.parent) == null || s.postMessage({
365
- type: "builder.evaluateError",
366
- data: {
367
- id: p,
368
- error: h.message
369
- }
370
- }, "*") : u && typeof u.then == "function" ? u.then((g) => {
371
- var w;
372
- (w = window.parent) == null || w.postMessage({
373
- type: "builder.evaluateResult",
374
- data: {
375
- id: p,
376
- result: g
377
- }
378
- }, "*");
379
- }).catch(console.error) : (a = window.parent) == null || a.postMessage({
380
- type: "builder.evaluateResult",
381
- data: {
382
- result: u,
383
- id: p
384
- }
385
- }, "*");
386
- break;
387
- }
388
- }
389
- })));
390
- }, Ot = ({
391
- model: t,
392
- trustedHosts: e,
393
- callbacks: n
394
- }) => (r) => {
395
- if (!$(e, r))
396
- return;
397
- const {
398
- data: o
399
- } = r;
400
- if (o)
401
- switch (o.type) {
402
- case "builder.configureSdk": {
403
- n.configureSdk(o.data);
404
- break;
405
- }
406
- case "builder.triggerAnimation": {
407
- n.animation(o.data);
408
- break;
409
- }
410
- case "builder.contentUpdate": {
411
- const s = o.data, a = s.key || s.alias || s.entry || s.modelName, d = s.data;
412
- a === t && n.contentUpdate(d);
413
- break;
414
- }
415
- }
416
- }, Ht = (t, e, n) => {
417
- if (!c)
418
- return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
419
- };
420
- Pt();
421
- const r = Ot({
422
- callbacks: {
423
- contentUpdate: e,
424
- animation: () => {
425
- },
426
- configureSdk: () => {
427
- }
428
- },
429
- model: t,
430
- trustedHosts: n == null ? void 0 : n.trustedHosts
431
- });
432
- return window.addEventListener("message", r), () => {
433
- window.removeEventListener("message", r);
434
- };
435
- }, Ct = "builder.tests", E = (t) => `${Ct}.${t}`, xt = ({
436
- contentId: t
437
- }) => N({
438
- name: E(t),
439
- canTrack: !0
440
- }), At = ({
441
- contentId: t
442
- }) => F({
443
- name: E(t),
444
- canTrack: !0
445
- }), Tt = ({
446
- contentId: t,
447
- value: e
448
- }) => j({
449
- name: E(t),
450
- value: e,
451
- canTrack: !0
452
- }), G = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, Rt = ({
453
- id: t,
454
- variations: e
455
- }) => {
456
- var o;
457
- let n = 0;
458
- const r = Math.random();
459
- for (const s in e) {
460
- const a = (o = e[s]) == null ? void 0 : o.testRatio;
461
- if (n += a, r < n)
462
- return s;
463
- }
464
- return t;
465
- }, J = (t) => {
466
- const e = Rt(t);
467
- return Tt({
468
- contentId: t.id,
469
- value: e
470
- }).catch((n) => {
471
- f.error("could not store A/B test variation: ", n);
472
- }), e;
473
- }, z = ({
474
- item: t,
475
- testGroupId: e
476
- }) => {
477
- const n = t.variations[e];
478
- return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
479
- !n ? {
480
- testVariationId: t.id,
481
- testVariationName: "Default"
482
- } : {
483
- data: n.data,
484
- testVariationId: n.id,
485
- testVariationName: n.name || (n.id === t.id ? "Default" : "")
486
- };
487
- }, Xt = ({
488
- item: t,
489
- canTrack: e
490
- }) => {
491
- if (!e)
492
- return t;
493
- if (!t)
494
- return;
495
- if (!G(t))
496
- return t;
497
- const n = At({
498
- contentId: t.id
499
- }) || J({
500
- variations: t.variations,
501
- id: t.id
502
- }), r = z({
503
- item: t,
504
- testGroupId: n
505
- });
506
- return {
507
- ...t,
508
- ...r
509
- };
510
- }, Bt = async ({
511
- item: t,
512
- canTrack: e
513
- }) => {
514
- if (!e || !G(t))
515
- return t;
516
- const r = await xt({
517
- contentId: t.id
518
- }) || J({
519
- variations: t.variations,
520
- id: t.id
521
- }), o = z({
522
- item: t,
523
- testGroupId: r
524
- });
525
- return {
526
- ...t,
527
- ...o
528
- };
529
- }, Lt = (t) => m(t) ? t : !0;
530
- function Vt() {
531
- return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
532
- }
533
- function Ut() {
534
- const t = Vt().fetch;
535
- if (typeof t == "undefined")
536
- throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
537
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
538
- return t;
539
- }
540
- const Mt = Ut();
541
- function k(t, e = null, n = ".") {
542
- return Object.keys(t).reduce((r, o) => {
543
- const s = t[o], a = [e, o].filter(Boolean).join(n);
544
- return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
545
- ...r,
546
- ...k(s, a, n)
547
- } : {
548
- ...r,
549
- [a]: s
550
- };
551
- }, {});
552
- }
553
- function H(t, e, n = {}) {
554
- for (const r in t) {
555
- const o = t[r], s = e ? e + "." + r : r;
556
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
557
- }
558
- return n;
559
- }
560
- const Ft = "v3", B = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t) => {
561
- const {
562
- limit: e = 30,
563
- userAttributes: n,
564
- query: r,
565
- model: o,
566
- apiKey: s,
567
- enrich: a,
568
- locale: d,
569
- apiVersion: y = Ft,
570
- fields: p,
571
- omit: I,
572
- offset: u,
573
- cacheSeconds: h,
574
- staleCacheSeconds: g,
575
- sort: w,
576
- includeUnpublished: O
577
- } = t;
578
- if (!s)
579
- throw new Error("Missing API key");
580
- if (!["v3"].includes(y))
581
- throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
582
- const X = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
583
- if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), 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 O == "boolean" && i.searchParams.set("includeUnpublished", String(O)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
584
- const l = k({
585
- sort: w
586
- });
587
- for (const S in l)
588
- i.searchParams.set(S, JSON.stringify(l[S]));
589
- }
590
- const q = {
591
- ...it(),
592
- ...L(t.options || {})
593
- }, C = k(q);
594
- for (const l in C)
595
- i.searchParams.set(l, String(C[l]));
596
- if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
597
- const l = H({
598
- query: r
599
- });
600
- for (const S in l)
601
- i.searchParams.set(S, JSON.stringify(l[S]));
602
- }
603
- return i;
604
- }, Nt = (t) => "results" in t;
605
- async function jt(t) {
606
- const e = await Wt({
607
- ...t,
608
- limit: 1
609
- });
610
- return e && e[0] || null;
611
- }
612
- const Dt = async (t) => {
613
- var s;
614
- const e = P(t);
615
- return await (await ((s = t.fetch) != null ? s : Mt)(e.href, t.fetchOptions)).json();
616
- }, Kt = async (t, e, n = P(t)) => {
617
- const r = Lt(t.canTrack);
618
- if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
619
- return e.results;
620
- try {
621
- const o = [];
622
- for (const s of e.results)
623
- o.push(await Bt({
624
- item: s,
625
- canTrack: r
626
- }));
627
- e.results = o;
628
- } catch (o) {
629
- f.error("Could not process A/B tests. ", o);
630
- }
631
- return e.results;
632
- };
633
- async function Wt(t) {
634
- try {
635
- const e = P(t), n = await Dt(t);
636
- return Nt(n) ? Kt(t, n) : (f.error("Error fetching data. ", {
637
- url: e,
638
- content: n,
639
- options: t
640
- }), null);
641
- } catch (e) {
642
- return f.error("Error fetching data. ", e), null;
643
- }
644
- }
645
- const qt = async (t) => {
646
- var r, o, s;
647
- const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((o = t.userAttributes) == null ? void 0 : o.urlPath), n = {
648
- ...t,
649
- apiKey: t.apiKey,
650
- model: t.model || "page",
651
- userAttributes: {
652
- ...t.userAttributes,
653
- ...e ? {
654
- urlPath: e
655
- } : {}
656
- },
657
- options: M(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
658
- };
659
- return {
660
- apiKey: n.apiKey,
661
- model: n.model,
662
- content: await jt(n)
663
- };
664
- };
665
- export {
666
- b as MSG_PREFIX,
667
- v as TARGET,
668
- Kt as _processContentResult,
669
- It as _track,
670
- m as checkIsDefined,
671
- Ot as createEditorListener,
672
- $t as createRegisterComponentMessage,
673
- qt as fetchBuilderProps,
674
- Wt as fetchEntries,
675
- jt as fetchOneEntry,
676
- M as getBuilderSearchParams,
677
- Lt as getDefaultCanTrack,
678
- nt as getUserAttributes,
679
- Xt as handleABTestingSync,
680
- c as isBrowser,
681
- Z as isEditing,
682
- _t as isPreviewing,
683
- f as logger,
684
- ot as register,
685
- zt as registerInsertMenu,
686
- U as serializeIncludingFunctions,
687
- Gt as setEditorSettings,
688
- Pt as setupBrowserForEditing,
689
- Ht as subscribeToEditor,
690
- Jt as track
691
- };