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