@builder.io/sdk-react 2.0.30 → 2.0.31

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/{edge/server-entry-e26008c1.js → browser/server-entry-77f4513c.js} +225 -217
  6. package/lib/browser/server-entry-d7a13b14.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-93512a19.cjs → accordion-696fad97.cjs} +1 -1
  10. package/lib/edge/{accordion-359367e6.js → accordion-d1213549.js} +1 -1
  11. package/lib/edge/{blocks-d7ba8f6a.js → blocks-9ef79098.js} +3 -3
  12. package/lib/edge/{blocks-44a0617b.cjs → blocks-aa67fee8.cjs} +1 -1
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-0ae65c1d.cjs → button-2ed05d22.cjs} +1 -1
  16. package/lib/edge/{button-ae26a553.js → button-b41f1129.js} +2 -2
  17. package/lib/edge/{columns-957c0468.js → columns-5f8497fb.js} +4 -4
  18. package/lib/edge/{columns-f7da8908.cjs → columns-ca9ac444.cjs} +1 -1
  19. package/lib/edge/{content-variants-9bb0b7e9.cjs → content-variants-2f5a6ccd.cjs} +1 -1
  20. package/lib/edge/{content-variants-d8a859a2.js → content-variants-9c4db669.js} +11 -11
  21. package/lib/edge/{evaluate-21c48a1d.cjs → evaluate-8453ffc0.cjs} +1 -1
  22. package/lib/edge/{evaluate-8e8c9fec.js → evaluate-f626f584.js} +1 -1
  23. package/lib/edge/{form-68fc4d5a.js → form-a5407307.js} +4 -4
  24. package/lib/edge/{form-0b09120c.cjs → form-b0c5418b.cjs} +1 -1
  25. package/lib/edge/{get-class-prop-name-a6f0f92d.js → get-class-prop-name-40d6defb.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-ffeda28e.cjs → get-class-prop-name-86f0330a.cjs} +1 -1
  27. package/lib/edge/{img-89e32a84.cjs → img-83ed868e.cjs} +1 -1
  28. package/lib/edge/{img-912b190b.js → img-fa36f926.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +1 -1
  31. package/lib/edge/{input-5ff8ae2e.cjs → input-3106b577.cjs} +1 -1
  32. package/lib/edge/{input-96ba83eb.js → input-93e42e28.js} +1 -1
  33. package/lib/edge/{select-5f5fed1c.cjs → select-29495824.cjs} +1 -1
  34. package/lib/edge/{select-f66026e1.js → select-4cf4356a.js} +1 -1
  35. package/lib/edge/server-entry-4cd5389e.cjs +2 -0
  36. package/lib/{node/server-entry-c7147616.js → edge/server-entry-ea35faa6.js} +223 -220
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-d09faa0a.js → slot-6ad4152e.js} +4 -4
  40. package/lib/edge/{slot-d3473421.cjs → slot-c8ab71b6.cjs} +1 -1
  41. package/lib/edge/{symbol-ebccca9b.cjs → symbol-74313a4b.cjs} +1 -1
  42. package/lib/edge/{symbol-285d196c.js → symbol-d2b48e54.js} +2 -2
  43. package/lib/edge/{tabs-39d86f86.js → tabs-6d924c90.js} +4 -4
  44. package/lib/edge/{tabs-61c59e0f.cjs → tabs-f699b318.cjs} +1 -1
  45. package/lib/edge/{text-40a616f5.cjs → text-7120ee0c.cjs} +1 -1
  46. package/lib/edge/{text-dce27428.js → text-7137a306.js} +2 -2
  47. package/lib/node/blocks-exports.cjs +1 -1
  48. package/lib/node/blocks-exports.mjs +3 -3
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +3 -3
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +3 -3
  53. package/lib/{browser/server-entry-d133a206.js → node/server-entry-32ef60c0.js} +193 -186
  54. package/lib/node/server-entry-9c026e49.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/{setIvm-5ab140ad.js → setIvm-26e65816.js} +1 -1
  58. package/lib/node/{setIvm-a85e255e.cjs → setIvm-bf1ad328.cjs} +1 -1
  59. package/lib/node/setIvm.cjs +1 -1
  60. package/lib/node/setIvm.mjs +2 -2
  61. package/lib/node/{should-force-browser-runtime-in-node-16ceec99.cjs → should-force-browser-runtime-in-node-000957e3.cjs} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-1d3a044a.js → should-force-browser-runtime-in-node-343fd6c7.js} +1 -1
  63. package/package.json +1 -1
  64. package/types/constants/sdk-version.d.ts +1 -1
  65. package/lib/browser/server-entry-d4ea1a12.cjs +0 -2
  66. package/lib/edge/server-entry-f09ee4f4.cjs +0 -2
  67. package/lib/node/server-entry-8e901e75.cjs +0 -2
@@ -1,77 +1,38 @@
1
- const b = "react", v = "[Builder.io]: ", l = {
2
- log: (...e) => console.log(v, ...e),
3
- error: (...e) => console.error(v, ...e),
4
- warn: (...e) => console.warn(v, ...e),
5
- debug: (...e) => console.debug(v, ...e)
6
- };
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- const te = (e) => {
1
+ const b = "react", re = (e) => {
11
2
  const t = {};
12
3
  return e.forEach((n, r) => {
13
4
  t[r] = n;
14
5
  }), t;
15
- }, U = (e) => e instanceof URLSearchParams ? te(e) : e, L = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
16
- function ne() {
6
+ }, V = (e) => e instanceof URLSearchParams ? re(e) : e, F = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
7
+ function c() {
8
+ return typeof window != "undefined" && typeof document != "undefined";
9
+ }
10
+ function oe() {
17
11
  return c() && window.self !== window.top;
18
12
  }
19
- function re(e) {
20
- return ne() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
21
- L(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
13
+ function se(e) {
14
+ return oe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
15
+ F(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
22
16
  }
23
- const oe = () => {
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
- }, se = () => typeof navigator == "object" && navigator.userAgent || "", ie = () => {
30
- const e = se(), 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() || b === "reactNative";
48
- }
49
- }, n = e.match(/Tablet|iPad/i), r = oe();
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;
56
- function Xe(e) {
17
+ function Je(e) {
57
18
  const t = e || (c() ? window.location.search : void 0);
58
- return t ? L(t).indexOf("builder.preview=") !== -1 : !1;
19
+ return t ? F(t).indexOf("builder.preview=") !== -1 : !1;
59
20
  }
60
- const Je = (e) => ({
21
+ const qe = (e) => ({
61
22
  type: "builder.registerComponent",
62
- data: V(e)
63
- }), ae = (e) => {
64
- const t = e.toString().trim();
65
- return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
23
+ data: M(e)
24
+ }), ie = (e) => {
25
+ const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t);
26
+ return `return (${!t.startsWith("function") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`;
66
27
  };
67
- function V(e) {
68
- return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ae(n) : n));
28
+ function M(e) {
29
+ return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ie(n) : n));
69
30
  }
70
- const x = {};
71
- function ce(e, t) {
72
- e === "plugin" && (t = V(t));
73
- let n = x[e];
74
- if (n || (n = x[e] = []), n.push(t), c()) {
31
+ const T = {};
32
+ function ae(e, t) {
33
+ e === "plugin" && (t = M(t));
34
+ let n = T[e];
35
+ if (n || (n = T[e] = []), n.push(t), c()) {
75
36
  const r = {
76
37
  type: "builder.register",
77
38
  data: {
@@ -86,42 +47,47 @@ function ce(e, t) {
86
47
  }
87
48
  }
88
49
  }
89
- const A = {};
90
- function ze(e) {
50
+ const B = {};
51
+ function Qe(e) {
91
52
  if (c()) {
92
- Object.assign(A, e);
53
+ Object.assign(B, e);
93
54
  const t = {
94
55
  type: "builder.settingsChange",
95
- data: A
56
+ data: B
96
57
  };
97
58
  parent.postMessage(t, "*");
98
59
  }
99
60
  }
100
- const T = "builder.", ue = "options.", F = (e) => {
61
+ const R = "builder.", ce = "options.", N = (e) => {
101
62
  if (!e)
102
63
  return {};
103
- const t = U(e), n = {};
64
+ const t = V(e), n = {};
104
65
  return Object.keys(t).forEach((r) => {
105
- if (r.startsWith(T)) {
106
- const o = r.replace(T, "").replace(ue, "");
66
+ if (r.startsWith(R)) {
67
+ const o = r.replace(R, "").replace(ce, "");
107
68
  n[o] = t[r];
108
69
  }
109
70
  }), n;
110
- }, de = () => {
71
+ }, ue = () => {
111
72
  if (!c())
112
73
  return {};
113
74
  const e = new URLSearchParams(window.location.search);
114
- return F(e);
115
- }, M = "2.0.30", N = () => ({
75
+ return N(e);
76
+ }, I = "[Builder.io]: ", l = {
77
+ log: (...e) => console.log(I, ...e),
78
+ error: (...e) => console.error(I, ...e),
79
+ warn: (...e) => console.warn(I, ...e),
80
+ debug: (...e) => console.debug(I, ...e)
81
+ }, D = "2.0.31", K = () => ({
116
82
  "X-Builder-SDK": b,
117
83
  "X-Builder-SDK-GEN": "2",
118
- "X-Builder-SDK-Version": M
119
- }), le = (e) => {
84
+ "X-Builder-SDK-Version": D
85
+ }), m = (e) => e != null, de = (e) => {
120
86
  if (e === "localhost" || e === "127.0.0.1")
121
87
  return e;
122
88
  const t = e.split(".");
123
89
  return t.length > 2 ? t.slice(1).join(".") : e;
124
- }, D = ({
90
+ }, j = ({
125
91
  name: e,
126
92
  canTrack: t
127
93
  }) => {
@@ -132,14 +98,14 @@ const T = "builder.", ue = "options.", F = (e) => {
132
98
  l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
133
99
  return;
134
100
  }
135
- }, K = async (e) => D(e), fe = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), he = [["secure", ""], ["SameSite", "None"]], ge = ({
101
+ }, W = async (e) => j(e), le = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), fe = [["secure", ""], ["SameSite", "None"]], he = ({
136
102
  name: e,
137
103
  value: t,
138
104
  expires: n
139
105
  }) => {
140
- const o = (c() ? location.protocol === "https:" : !0) ? he : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", le(window.location.hostname)], ...o];
141
- return fe(i);
142
- }, j = async ({
106
+ const o = (c() ? location.protocol === "https:" : !0) ? fe : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", de(window.location.hostname)], ...o];
107
+ return le(i);
108
+ }, $ = async ({
143
109
  name: e,
144
110
  value: t,
145
111
  expires: n,
@@ -148,7 +114,7 @@ const T = "builder.", ue = "options.", F = (e) => {
148
114
  try {
149
115
  if (!r)
150
116
  return;
151
- const o = ge({
117
+ const o = he({
152
118
  name: e,
153
119
  value: t,
154
120
  expires: n
@@ -158,93 +124,125 @@ const T = "builder.", ue = "options.", F = (e) => {
158
124
  l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
159
125
  }
160
126
  };
161
- function pe() {
127
+ function ge() {
162
128
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
163
129
  const t = Math.random() * 16 | 0;
164
130
  return (e == "x" ? t : t & 3 | 8).toString(16);
165
131
  });
166
132
  }
167
- function W() {
168
- return pe().replace(/-/g, "");
133
+ function G() {
134
+ return ge().replace(/-/g, "");
169
135
  }
170
- const $ = "builderSessionId", me = async ({
136
+ const _ = "builderSessionId", pe = async ({
171
137
  canTrack: e
172
138
  }) => {
173
139
  if (!e)
174
140
  return;
175
- const t = await K({
176
- name: $,
141
+ const t = await W({
142
+ name: _,
177
143
  canTrack: e
178
144
  });
179
145
  if (m(t))
180
146
  return t;
181
147
  {
182
- const n = ye();
183
- return Se({
148
+ const n = me();
149
+ return ye({
184
150
  id: n,
185
151
  canTrack: e
186
152
  }), n;
187
153
  }
188
- }, ye = () => W(), Se = ({
154
+ }, me = () => G(), ye = ({
189
155
  id: e,
190
156
  canTrack: t
191
- }) => j({
192
- name: $,
157
+ }) => $({
158
+ name: _,
193
159
  value: e,
194
160
  canTrack: t
195
- }), G = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, we = ({
161
+ }), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Se = ({
196
162
  key: e,
197
163
  canTrack: t
198
164
  }) => {
199
165
  var n;
200
166
  try {
201
- return t ? (n = G()) == null ? void 0 : n.getItem(e) : void 0;
167
+ return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
202
168
  } catch (r) {
203
169
  console.debug("[LocalStorage] GET error: ", r);
204
170
  return;
205
171
  }
206
- }, be = ({
172
+ }, we = ({
207
173
  key: e,
208
174
  canTrack: t,
209
175
  value: n
210
176
  }) => {
211
177
  var r;
212
178
  try {
213
- t && ((r = G()) == null || r.setItem(e, n));
179
+ t && ((r = H()) == null || r.setItem(e, n));
214
180
  } catch (o) {
215
181
  console.debug("[LocalStorage] SET error: ", o);
216
182
  }
217
- }, _ = "builderVisitorId", ve = ({
183
+ }, X = "builderVisitorId", be = ({
218
184
  canTrack: e
219
185
  }) => {
220
186
  if (!e)
221
187
  return;
222
- const t = we({
223
- key: _,
188
+ const t = Se({
189
+ key: X,
224
190
  canTrack: e
225
191
  });
226
192
  if (m(t))
227
193
  return t;
228
194
  {
229
- const n = Ie();
230
- return ke({
195
+ const n = ve();
196
+ return Ie({
231
197
  id: n,
232
198
  canTrack: e
233
199
  }), n;
234
200
  }
235
- }, Ie = () => W(), ke = ({
201
+ }, ve = () => G(), Ie = ({
236
202
  id: e,
237
203
  canTrack: t
238
- }) => be({
239
- key: _,
204
+ }) => we({
205
+ key: X,
240
206
  value: e,
241
207
  canTrack: t
242
208
  });
243
- function Ee(e) {
209
+ function ke(e) {
244
210
  var t;
245
211
  typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && l.log(e);
246
212
  }
247
- const Oe = async ({
213
+ const Ee = () => {
214
+ if (c()) {
215
+ const e = new URL(location.href);
216
+ return e.pathname === "" && (e.pathname = "/"), e;
217
+ } else
218
+ return console.warn("Cannot get location for tracking in non-browser environment"), null;
219
+ }, Oe = () => typeof navigator == "object" && navigator.userAgent || "", Pe = () => {
220
+ const e = Oe(), t = {
221
+ Android() {
222
+ return e.match(/Android/i);
223
+ },
224
+ BlackBerry() {
225
+ return e.match(/BlackBerry/i);
226
+ },
227
+ iOS() {
228
+ return e.match(/iPhone|iPod/i);
229
+ },
230
+ Opera() {
231
+ return e.match(/Opera Mini/i);
232
+ },
233
+ Windows() {
234
+ return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
235
+ },
236
+ any() {
237
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
238
+ }
239
+ }, n = e.match(/Tablet|iPad/i), r = Ee();
240
+ return {
241
+ urlPath: r == null ? void 0 : r.pathname,
242
+ host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
243
+ device: n ? "tablet" : t.any() ? "mobile" : "desktop"
244
+ };
245
+ }, Ce = async ({
248
246
  canTrack: e
249
247
  }) => {
250
248
  if (!e)
@@ -252,16 +250,16 @@ const Oe = async ({
252
250
  visitorId: void 0,
253
251
  sessionId: void 0
254
252
  };
255
- const t = await me({
253
+ const t = await pe({
256
254
  canTrack: e
257
- }), n = ve({
255
+ }), n = be({
258
256
  canTrack: e
259
257
  });
260
258
  return {
261
259
  sessionId: t,
262
260
  visitorId: n
263
261
  };
264
- }, Pe = async ({
262
+ }, xe = async ({
265
263
  type: e,
266
264
  canTrack: t,
267
265
  apiKey: n,
@@ -275,14 +273,14 @@ const Oe = async ({
275
273
  url: location.href,
276
274
  ...r
277
275
  },
278
- ...await Oe({
276
+ ...await Ce({
279
277
  canTrack: t
280
278
  }),
281
- userAttributes: ie(),
279
+ userAttributes: Pe(),
282
280
  ownerId: n
283
281
  }
284
282
  });
285
- async function Ce({
283
+ async function Ae({
286
284
  apiHost: e,
287
285
  ...t
288
286
  }) {
@@ -290,35 +288,35 @@ async function Ce({
290
288
  l.error("Missing API key for track call. Please provide your API key.");
291
289
  return;
292
290
  }
293
- if (!t.canTrack || re() || !(c() || b === "reactNative"))
291
+ if (!t.canTrack || se() || !(c() || b === "reactNative"))
294
292
  return;
295
293
  const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
296
- return Ee(r), fetch(r, {
294
+ return ke(r), fetch(r, {
297
295
  method: "POST",
298
296
  body: JSON.stringify({
299
- events: [await Pe(t)]
297
+ events: [await xe(t)]
300
298
  }),
301
299
  headers: {
302
300
  "content-type": "application/json",
303
- ...N()
301
+ ...K()
304
302
  },
305
303
  mode: "cors"
306
304
  }).catch((o) => {
307
305
  console.error("Failed to track: ", o);
308
306
  });
309
307
  }
310
- const qe = (e) => Ce({
308
+ const Ye = (e) => Ae({
311
309
  ...e,
312
310
  canTrack: !0
313
- }), xe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
314
- function H(e, t) {
311
+ }), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
312
+ function z(e, t) {
315
313
  if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
316
314
  return !1;
317
315
  const n = new URL(t.origin), r = n.hostname;
318
- return (e || xe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
316
+ return (e || Te).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
319
317
  }
320
- const Qe = () => {
321
- ce("insertMenu", {
318
+ const Ze = () => {
319
+ ae("insertMenu", {
322
320
  name: "_default",
323
321
  default: !0,
324
322
  items: [{
@@ -340,14 +338,14 @@ const Qe = () => {
340
338
  }]
341
339
  });
342
340
  };
343
- let B = !1;
344
- const Ae = (e = {}) => {
341
+ let U = !1;
342
+ const Be = (e = {}) => {
345
343
  var t, n;
346
- B || (B = !0, c() && ((t = window.parent) == null || t.postMessage({
344
+ U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
347
345
  type: "builder.sdkInfo",
348
346
  data: {
349
347
  target: b,
350
- version: M,
348
+ version: D,
351
349
  supportsPatchUpdates: !1,
352
350
  // Supports builder-model="..." attribute which is needed to
353
351
  // scope our '+ add block' button styling
@@ -361,7 +359,7 @@ const Ae = (e = {}) => {
361
359
  }
362
360
  }, "*"), window.addEventListener("message", (r) => {
363
361
  var s, i;
364
- if (!H(e.trustedHosts, r))
362
+ if (!z(e.trustedHosts, r))
365
363
  return;
366
364
  const {
367
365
  data: o
@@ -369,10 +367,10 @@ const Ae = (e = {}) => {
369
367
  if (o != null && o.type)
370
368
  switch (o.type) {
371
369
  case "builder.evaluate": {
372
- const u = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(u);
370
+ const u = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(u);
373
371
  let d, h = null;
374
372
  try {
375
- d = I.apply(null, y);
373
+ d = k.apply(null, y);
376
374
  } catch (g) {
377
375
  h = g;
378
376
  }
@@ -402,12 +400,12 @@ const Ae = (e = {}) => {
402
400
  }
403
401
  }
404
402
  })));
405
- }, Te = ({
403
+ }, Re = ({
406
404
  model: e,
407
405
  trustedHosts: t,
408
406
  callbacks: n
409
407
  }) => (r) => {
410
- if (!H(t, r))
408
+ if (!z(t, r))
411
409
  return;
412
410
  const {
413
411
  data: o
@@ -428,12 +426,12 @@ const Ae = (e = {}) => {
428
426
  break;
429
427
  }
430
428
  }
431
- }, Ye = (e, t, n) => {
429
+ }, et = (e, t, n) => {
432
430
  if (!c)
433
431
  return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
434
432
  };
435
- Ae();
436
- const r = Te({
433
+ Be();
434
+ const r = Re({
437
435
  callbacks: {
438
436
  contentUpdate: t,
439
437
  animation: () => {
@@ -447,24 +445,24 @@ const Ae = (e = {}) => {
447
445
  return window.addEventListener("message", r), () => {
448
446
  window.removeEventListener("message", r);
449
447
  };
450
- }, Be = "builder.tests", E = (e) => `${Be}.${e}`, Re = ({
448
+ }, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
451
449
  contentId: e
452
- }) => K({
453
- name: E(e),
450
+ }) => W({
451
+ name: P(e),
454
452
  canTrack: !0
455
- }), Ue = ({
453
+ }), Ve = ({
456
454
  contentId: e
457
- }) => D({
458
- name: E(e),
455
+ }) => j({
456
+ name: P(e),
459
457
  canTrack: !0
460
- }), Le = ({
458
+ }), Fe = ({
461
459
  contentId: e,
462
460
  value: t
463
- }) => j({
464
- name: E(e),
461
+ }) => $({
462
+ name: P(e),
465
463
  value: t,
466
464
  canTrack: !0
467
- }), X = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Ve = ({
465
+ }), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
468
466
  id: e,
469
467
  variations: t
470
468
  }) => {
@@ -477,15 +475,15 @@ const Ae = (e = {}) => {
477
475
  return s;
478
476
  }
479
477
  return e;
480
- }, J = (e) => {
481
- const t = Ve(e);
482
- return Le({
478
+ }, q = (e) => {
479
+ const t = Me(e);
480
+ return Fe({
483
481
  contentId: e.id,
484
482
  value: t
485
483
  }).catch((n) => {
486
484
  l.error("could not store A/B test variation: ", n);
487
485
  }), t;
488
- }, z = ({
486
+ }, Q = ({
489
487
  item: e,
490
488
  testGroupId: t
491
489
  }) => {
@@ -499,7 +497,7 @@ const Ae = (e = {}) => {
499
497
  testVariationId: n.id,
500
498
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
501
499
  };
502
- }, Ze = ({
500
+ }, tt = ({
503
501
  item: e,
504
502
  canTrack: t
505
503
  }) => {
@@ -507,14 +505,14 @@ const Ae = (e = {}) => {
507
505
  return e;
508
506
  if (!e)
509
507
  return;
510
- if (!X(e))
508
+ if (!J(e))
511
509
  return e;
512
- const n = Ue({
510
+ const n = Ve({
513
511
  contentId: e.id
514
- }) || J({
512
+ }) || q({
515
513
  variations: e.variations,
516
514
  id: e.id
517
- }), r = z({
515
+ }), r = Q({
518
516
  item: e,
519
517
  testGroupId: n
520
518
  });
@@ -522,18 +520,18 @@ const Ae = (e = {}) => {
522
520
  ...e,
523
521
  ...r
524
522
  };
525
- }, Fe = async ({
523
+ }, Ne = async ({
526
524
  item: e,
527
525
  canTrack: t
528
526
  }) => {
529
- if (!t || !X(e))
527
+ if (!t || !J(e))
530
528
  return e;
531
- const r = await Re({
529
+ const r = await Le({
532
530
  contentId: e.id
533
- }) || J({
531
+ }) || q({
534
532
  variations: e.variations,
535
533
  id: e.id
536
- }), o = z({
534
+ }), o = Q({
537
535
  item: e,
538
536
  testGroupId: r
539
537
  });
@@ -541,38 +539,38 @@ const Ae = (e = {}) => {
541
539
  ...e,
542
540
  ...o
543
541
  };
544
- }, Me = (e) => m(e) ? e : !0;
545
- function Ne() {
542
+ }, De = (e) => m(e) ? e : !0;
543
+ function Ke() {
546
544
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
547
545
  }
548
- function De() {
549
- const e = Ne().fetch;
546
+ function je() {
547
+ const e = Ke().fetch;
550
548
  if (typeof e == "undefined")
551
549
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
552
550
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
553
551
  return e;
554
552
  }
555
- const Ke = De();
556
- function k(e, t = null, n = ".") {
553
+ const We = je();
554
+ function O(e, t = null, n = ".") {
557
555
  return Object.keys(e).reduce((r, o) => {
558
556
  const s = e[o], i = [t, o].filter(Boolean).join(n);
559
557
  return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
560
558
  ...r,
561
- ...k(s, i, n)
559
+ ...O(s, i, n)
562
560
  } : {
563
561
  ...r,
564
562
  [i]: s
565
563
  };
566
564
  }, {});
567
565
  }
568
- function q(e, t, n = {}) {
566
+ function Y(e, t, n = {}) {
569
567
  for (const r in e) {
570
568
  const o = e[r], s = t ? t + "." + r : r;
571
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? q(o, s, n) : n[s] = o;
569
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? Y(o, s, n) : n[s] = o;
572
570
  }
573
571
  return n;
574
572
  }
575
- const je = "v3", R = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
573
+ const $e = "v3", L = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
576
574
  const {
577
575
  limit: t = 30,
578
576
  userAttributes: n,
@@ -581,68 +579,74 @@ const je = "v3", R = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
581
579
  apiKey: s,
582
580
  enrich: i,
583
581
  locale: u,
584
- apiVersion: y = je,
582
+ apiVersion: y = $e,
585
583
  fields: p,
586
- omit: I,
584
+ omit: k,
587
585
  offset: d,
588
586
  cacheSeconds: h,
589
587
  staleCacheSeconds: g,
590
588
  sort: S,
591
- includeUnpublished: P,
592
- apiHost: Q
589
+ includeUnpublished: x,
590
+ apiHost: Z
593
591
  } = e;
594
592
  if (!s)
595
593
  throw new Error("Missing API key");
596
594
  if (!["v3"].includes(y))
597
595
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
598
- const Y = t !== 1, Z = Q || "https://cdn.builder.io", a = new URL(`${Z}/api/${y}/content/${o}`);
599
- if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(Y)), a.searchParams.set("includeRefs", String(!0)), u && a.searchParams.set("locale", u), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", I || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof P == "boolean" && a.searchParams.set("includeUnpublished", String(P)), h && R(h) && a.searchParams.set("cacheSeconds", String(h)), g && R(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
600
- const f = k({
596
+ const ee = t !== 1, te = Z || "https://cdn.builder.io", a = new URL(`${te}/api/${y}/content/${o}`);
597
+ a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(ee)), a.searchParams.set("includeRefs", String(!0));
598
+ const E = u || (n == null ? void 0 : n.locale);
599
+ let v = n;
600
+ if (E && (a.searchParams.set("locale", E), v = {
601
+ locale: E,
602
+ ...v
603
+ }), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof x == "boolean" && a.searchParams.set("includeUnpublished", String(x)), h && L(h) && a.searchParams.set("cacheSeconds", String(h)), g && L(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
604
+ const f = O({
601
605
  sort: S
602
606
  });
603
607
  for (const w in f)
604
608
  a.searchParams.set(w, JSON.stringify(f[w]));
605
609
  }
606
- const ee = {
607
- ...de(),
608
- ...U(e.options || {})
609
- }, C = k(ee);
610
- for (const f in C)
611
- a.searchParams.set(f, String(C[f]));
612
- if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
613
- const f = q({
610
+ const ne = {
611
+ ...ue(),
612
+ ...V(e.options || {})
613
+ }, A = O(ne);
614
+ for (const f in A)
615
+ a.searchParams.set(f, String(A[f]));
616
+ if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
617
+ const f = Y({
614
618
  query: r
615
619
  });
616
620
  for (const w in f)
617
621
  a.searchParams.set(w, JSON.stringify(f[w]));
618
622
  }
619
623
  return a;
620
- }, We = (e) => "results" in e;
621
- async function $e(e) {
622
- const t = await He({
624
+ }, Ge = (e) => "results" in e;
625
+ async function _e(e) {
626
+ const t = await ze({
623
627
  ...e,
624
628
  limit: 1
625
629
  });
626
630
  return t && t[0] || null;
627
631
  }
628
- const Ge = async (e) => {
632
+ const He = async (e) => {
629
633
  var i, u;
630
- const t = O(e), n = (i = e.fetch) != null ? i : Ke, r = {
634
+ const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
631
635
  ...e.fetchOptions,
632
636
  headers: {
633
637
  ...(u = e.fetchOptions) == null ? void 0 : u.headers,
634
- ...N()
638
+ ...K()
635
639
  }
636
640
  };
637
641
  return await (await n(t.href, r)).json();
638
- }, _e = async (e, t, n = O(e)) => {
639
- const r = Me(e.canTrack);
642
+ }, Xe = async (e, t, n = C(e)) => {
643
+ const r = De(e.canTrack);
640
644
  if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
641
645
  return t.results;
642
646
  try {
643
647
  const o = [];
644
648
  for (const s of t.results)
645
- o.push(await Fe({
649
+ o.push(await Ne({
646
650
  item: s,
647
651
  canTrack: r
648
652
  }));
@@ -652,10 +656,10 @@ const Ge = async (e) => {
652
656
  }
653
657
  return t.results;
654
658
  };
655
- async function He(e) {
659
+ async function ze(e) {
656
660
  try {
657
- const t = O(e), n = await Ge(e);
658
- return We(n) ? _e(e, n) : (l.error("Error fetching data. ", {
661
+ const t = C(e), n = await He(e);
662
+ return Ge(n) ? Xe(e, n) : (l.error("Error fetching data. ", {
659
663
  url: t,
660
664
  content: n,
661
665
  options: e
@@ -664,7 +668,7 @@ async function He(e) {
664
668
  return l.error("Error fetching data. ", t), null;
665
669
  }
666
670
  }
667
- const et = async (e) => {
671
+ const nt = async (e) => {
668
672
  var r, o, s;
669
673
  const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
670
674
  ...e,
@@ -676,39 +680,38 @@ const et = async (e) => {
676
680
  urlPath: t
677
681
  } : {}
678
682
  },
679
- options: F(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
683
+ options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
680
684
  };
681
685
  return {
682
686
  apiKey: n.apiKey,
683
687
  model: n.model,
684
- content: await $e(n)
688
+ content: await _e(n)
685
689
  };
686
690
  };
687
691
  export {
688
- v as MSG_PREFIX,
689
692
  b as TARGET,
690
- _e as _processContentResult,
691
- Ce as _track,
693
+ Xe as _processContentResult,
694
+ Ae as _track,
692
695
  m as checkIsDefined,
693
- Te as createEditorListener,
694
- Je as createRegisterComponentMessage,
695
- et as fetchBuilderProps,
696
- He as fetchEntries,
697
- $e as fetchOneEntry,
698
- F as getBuilderSearchParams,
699
- Me as getDefaultCanTrack,
700
- ie as getUserAttributes,
701
- Ze as handleABTestingSync,
696
+ Re as createEditorListener,
697
+ qe as createRegisterComponentMessage,
698
+ nt as fetchBuilderProps,
699
+ ze as fetchEntries,
700
+ _e as fetchOneEntry,
701
+ N as getBuilderSearchParams,
702
+ De as getDefaultCanTrack,
703
+ Pe as getUserAttributes,
704
+ tt as handleABTestingSync,
702
705
  c as isBrowser,
703
- re as isEditing,
704
- Xe as isPreviewing,
705
- Ee as logFetch,
706
+ se as isEditing,
707
+ Je as isPreviewing,
708
+ ke as logFetch,
706
709
  l as logger,
707
- ce as register,
708
- Qe as registerInsertMenu,
709
- V as serializeIncludingFunctions,
710
- ze as setEditorSettings,
711
- Ae as setupBrowserForEditing,
712
- Ye as subscribeToEditor,
713
- qe as track
710
+ ae as register,
711
+ Ze as registerInsertMenu,
712
+ M as serializeIncludingFunctions,
713
+ Qe as setEditorSettings,
714
+ Be as setupBrowserForEditing,
715
+ et as subscribeToEditor,
716
+ Ye as track
714
717
  };