@builder.io/sdk-react 2.0.29 → 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 (69) hide show
  1. package/lib/browser/blocks-exports.cjs +18 -18
  2. package/lib/browser/blocks-exports.mjs +584 -587
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/{edge/server-entry-05dd3f4b.js → browser/server-entry-77f4513c.js} +245 -228
  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-200ac141.cjs → accordion-696fad97.cjs} +1 -1
  10. package/lib/edge/{accordion-1fae9bd5.js → accordion-d1213549.js} +1 -1
  11. package/lib/edge/{blocks-b47cd3fc.js → blocks-9ef79098.js} +3 -3
  12. package/lib/edge/{blocks-fd9e445c.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-ffe70d17.cjs → button-2ed05d22.cjs} +1 -1
  16. package/lib/edge/{button-5cc9a94f.js → button-b41f1129.js} +2 -2
  17. package/lib/edge/{columns-9ad996bb.js → columns-5f8497fb.js} +4 -4
  18. package/lib/edge/{columns-7651ba21.cjs → columns-ca9ac444.cjs} +1 -1
  19. package/lib/edge/{content-variants-a9017964.cjs → content-variants-2f5a6ccd.cjs} +4 -4
  20. package/lib/edge/{content-variants-0ece6057.js → content-variants-9c4db669.js} +118 -118
  21. package/lib/edge/{evaluate-73e0df40.cjs → evaluate-8453ffc0.cjs} +1 -1
  22. package/lib/edge/{evaluate-5cfe10b0.js → evaluate-f626f584.js} +1 -1
  23. package/lib/edge/{form-186bf59f.js → form-a5407307.js} +30 -33
  24. package/lib/edge/form-b0c5418b.cjs +1 -0
  25. package/lib/edge/{get-class-prop-name-7d6a77a4.js → get-class-prop-name-40d6defb.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-11734dbc.cjs → get-class-prop-name-86f0330a.cjs} +1 -1
  27. package/lib/edge/{img-ef160d2b.cjs → img-83ed868e.cjs} +1 -1
  28. package/lib/edge/{img-6c1f4ea4.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-97dc199a.cjs → input-3106b577.cjs} +1 -1
  32. package/lib/edge/{input-b4ee4339.js → input-93e42e28.js} +1 -1
  33. package/lib/edge/{select-2cdf2c8f.cjs → select-29495824.cjs} +1 -1
  34. package/lib/edge/{select-e79d6e1b.js → select-4cf4356a.js} +1 -1
  35. package/lib/edge/server-entry-4cd5389e.cjs +2 -0
  36. package/lib/{node/server-entry-00c52924.js → edge/server-entry-ea35faa6.js} +243 -231
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-680234a8.js → slot-6ad4152e.js} +4 -4
  40. package/lib/edge/{slot-66ba436b.cjs → slot-c8ab71b6.cjs} +1 -1
  41. package/lib/edge/{symbol-4d0b1228.cjs → symbol-74313a4b.cjs} +1 -1
  42. package/lib/edge/{symbol-e920f028.js → symbol-d2b48e54.js} +2 -2
  43. package/lib/edge/{tabs-1bea88d1.js → tabs-6d924c90.js} +4 -4
  44. package/lib/edge/{tabs-1f3f45cf.cjs → tabs-f699b318.cjs} +1 -1
  45. package/lib/edge/{text-9533b278.cjs → text-7120ee0c.cjs} +1 -1
  46. package/lib/edge/{text-fd78274f.js → text-7137a306.js} +2 -2
  47. package/lib/node/blocks-exports.cjs +20 -20
  48. package/lib/node/blocks-exports.mjs +576 -579
  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-712b1faa.js → node/server-entry-32ef60c0.js} +213 -197
  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-156def75.js → setIvm-26e65816.js} +1 -1
  58. package/lib/node/{setIvm-ca4d1590.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-bc24fcdd.cjs → should-force-browser-runtime-in-node-000957e3.cjs} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-eb3eac6a.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/types/functions/log-fetch.d.ts +1 -0
  66. package/lib/browser/server-entry-3e3279b7.cjs +0 -2
  67. package/lib/edge/form-c98c7fc1.cjs +0 -1
  68. package/lib/edge/server-entry-0224e0bb.cjs +0 -2
  69. package/lib/node/server-entry-0b1fe826.cjs +0 -2
@@ -1,33 +1,33 @@
1
- const b = "react", v = "[Builder.io]: ", f = {
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]: ", l = {
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
- }, L = (e) => e instanceof URLSearchParams ? te(e) : e, U = (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
- U(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 He(e) {
56
+ function Je(e) {
57
57
  const t = e || (c() ? window.location.search : void 0);
58
- return t ? U(t).indexOf("builder.preview=") !== -1 : !1;
58
+ return t ? F(t).indexOf("builder.preview=") !== -1 : !1;
59
59
  }
60
- const Xe = (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 Je(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.", M = (e) => {
100
+ const R = "builder.", le = "options.", N = (e) => {
101
101
  if (!e)
102
102
  return {};
103
- const t = L(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 M(e);
115
- }, N = "2.0.29", F = () => ({
114
+ return N(e);
115
+ }, D = "2.0.31", K = () => ({
116
116
  "X-Builder-SDK": b,
117
117
  "X-Builder-SDK-GEN": "2",
118
- "X-Builder-SDK-Version": N
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.", M = (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
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
132
+ l.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,98 +148,103 @@ const T = "builder.", ue = "options.", M = (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
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
158
+ l.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
- }), _ = () => 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 = _()) == 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 = _()) == 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
- }, G = "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: G,
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: G,
238
+ }) => Ie({
239
+ key: X,
240
240
  value: e,
241
241
  canTrack: t
242
- }), Ee = async ({
242
+ });
243
+ function Pe(e) {
244
+ var t;
245
+ typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && l.log(e);
246
+ }
247
+ const Ce = async ({
243
248
  canTrack: e
244
249
  }) => {
245
250
  if (!e)
@@ -247,16 +252,16 @@ const $ = "builderSessionId", me = async ({
247
252
  visitorId: void 0,
248
253
  sessionId: void 0
249
254
  };
250
- const t = await me({
255
+ const t = await Se({
251
256
  canTrack: e
252
- }), n = ve({
257
+ }), n = ke({
253
258
  canTrack: e
254
259
  });
255
260
  return {
256
261
  sessionId: t,
257
262
  visitorId: n
258
263
  };
259
- }, Oe = async ({
264
+ }, xe = async ({
260
265
  type: e,
261
266
  canTrack: t,
262
267
  apiKey: n,
@@ -270,47 +275,50 @@ const $ = "builderSessionId", me = async ({
270
275
  url: location.href,
271
276
  ...r
272
277
  },
273
- ...await Ee({
278
+ ...await Ce({
274
279
  canTrack: t
275
280
  }),
276
- userAttributes: ie(),
281
+ userAttributes: ce(),
277
282
  ownerId: n
278
283
  }
279
284
  });
280
- async function Pe({
285
+ async function Ae({
281
286
  apiHost: e,
282
287
  ...t
283
288
  }) {
284
289
  if (!t.apiKey) {
285
- f.error("Missing API key for track call. Please provide your API key.");
290
+ l.error("Missing API key for track call. Please provide your API key.");
286
291
  return;
287
292
  }
288
- return !t.canTrack || re() || !(c() || b === "reactNative") ? void 0 : fetch(`${e || "https://cdn.builder.io"}/api/v1/track`, {
293
+ if (!t.canTrack || se() || !(c() || b === "reactNative"))
294
+ return;
295
+ const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
296
+ return Pe(r), fetch(r, {
289
297
  method: "POST",
290
298
  body: JSON.stringify({
291
- events: [await Oe(t)]
299
+ events: [await xe(t)]
292
300
  }),
293
301
  headers: {
294
302
  "content-type": "application/json",
295
- ...F()
303
+ ...K()
296
304
  },
297
305
  mode: "cors"
298
- }).catch((r) => {
299
- console.error("Failed to track: ", r);
306
+ }).catch((o) => {
307
+ console.error("Failed to track: ", o);
300
308
  });
301
309
  }
302
- const ze = (e) => Pe({
310
+ const Ye = (e) => Ae({
303
311
  ...e,
304
312
  canTrack: !0
305
- }), Ce = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
306
- function H(e, t) {
313
+ }), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
314
+ function z(e, t) {
307
315
  if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
308
316
  return !1;
309
317
  const n = new URL(t.origin), r = n.hostname;
310
- return (e || Ce).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;
311
319
  }
312
- const qe = () => {
313
- ce("insertMenu", {
320
+ const Ze = () => {
321
+ de("insertMenu", {
314
322
  name: "_default",
315
323
  default: !0,
316
324
  items: [{
@@ -332,14 +340,14 @@ const qe = () => {
332
340
  }]
333
341
  });
334
342
  };
335
- let R = !1;
336
- const xe = (e = {}) => {
343
+ let U = !1;
344
+ const Be = (e = {}) => {
337
345
  var t, n;
338
- R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
346
+ U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
339
347
  type: "builder.sdkInfo",
340
348
  data: {
341
349
  target: b,
342
- version: N,
350
+ version: D,
343
351
  supportsPatchUpdates: !1,
344
352
  // Supports builder-model="..." attribute which is needed to
345
353
  // scope our '+ add block' button styling
@@ -353,7 +361,7 @@ const xe = (e = {}) => {
353
361
  }
354
362
  }, "*"), window.addEventListener("message", (r) => {
355
363
  var s, i;
356
- if (!H(e.trustedHosts, r))
364
+ if (!z(e.trustedHosts, r))
357
365
  return;
358
366
  const {
359
367
  data: o
@@ -361,10 +369,10 @@ const xe = (e = {}) => {
361
369
  if (o != null && o.type)
362
370
  switch (o.type) {
363
371
  case "builder.evaluate": {
364
- 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);
365
373
  let d, h = null;
366
374
  try {
367
- d = I.apply(null, y);
375
+ d = k.apply(null, y);
368
376
  } catch (g) {
369
377
  h = g;
370
378
  }
@@ -394,12 +402,12 @@ const xe = (e = {}) => {
394
402
  }
395
403
  }
396
404
  })));
397
- }, Ae = ({
405
+ }, Re = ({
398
406
  model: e,
399
407
  trustedHosts: t,
400
408
  callbacks: n
401
409
  }) => (r) => {
402
- if (!H(t, r))
410
+ if (!z(t, r))
403
411
  return;
404
412
  const {
405
413
  data: o
@@ -420,12 +428,12 @@ const xe = (e = {}) => {
420
428
  break;
421
429
  }
422
430
  }
423
- }, Qe = (e, t, n) => {
431
+ }, et = (e, t, n) => {
424
432
  if (!c)
425
- return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
433
+ return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
426
434
  };
427
- xe();
428
- const r = Ae({
435
+ Be();
436
+ const r = Re({
429
437
  callbacks: {
430
438
  contentUpdate: t,
431
439
  animation: () => {
@@ -439,24 +447,24 @@ const xe = (e = {}) => {
439
447
  return window.addEventListener("message", r), () => {
440
448
  window.removeEventListener("message", r);
441
449
  };
442
- }, Te = "builder.tests", E = (e) => `${Te}.${e}`, Re = ({
450
+ }, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
443
451
  contentId: e
444
- }) => K({
445
- name: E(e),
452
+ }) => W({
453
+ name: P(e),
446
454
  canTrack: !0
447
- }), Be = ({
455
+ }), Ve = ({
448
456
  contentId: e
449
- }) => D({
450
- name: E(e),
457
+ }) => j({
458
+ name: P(e),
451
459
  canTrack: !0
452
- }), Le = ({
460
+ }), Fe = ({
453
461
  contentId: e,
454
462
  value: t
455
- }) => j({
456
- name: E(e),
463
+ }) => $({
464
+ name: P(e),
457
465
  value: t,
458
466
  canTrack: !0
459
- }), X = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Ue = ({
467
+ }), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
460
468
  id: e,
461
469
  variations: t
462
470
  }) => {
@@ -469,15 +477,15 @@ const xe = (e = {}) => {
469
477
  return s;
470
478
  }
471
479
  return e;
472
- }, J = (e) => {
473
- const t = Ue(e);
474
- return Le({
480
+ }, q = (e) => {
481
+ const t = Me(e);
482
+ return Fe({
475
483
  contentId: e.id,
476
484
  value: t
477
485
  }).catch((n) => {
478
- f.error("could not store A/B test variation: ", n);
486
+ l.error("could not store A/B test variation: ", n);
479
487
  }), t;
480
- }, z = ({
488
+ }, Q = ({
481
489
  item: e,
482
490
  testGroupId: t
483
491
  }) => {
@@ -491,7 +499,7 @@ const xe = (e = {}) => {
491
499
  testVariationId: n.id,
492
500
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
493
501
  };
494
- }, Ye = ({
502
+ }, tt = ({
495
503
  item: e,
496
504
  canTrack: t
497
505
  }) => {
@@ -499,14 +507,14 @@ const xe = (e = {}) => {
499
507
  return e;
500
508
  if (!e)
501
509
  return;
502
- if (!X(e))
510
+ if (!J(e))
503
511
  return e;
504
- const n = Be({
512
+ const n = Ve({
505
513
  contentId: e.id
506
- }) || J({
514
+ }) || q({
507
515
  variations: e.variations,
508
516
  id: e.id
509
- }), r = z({
517
+ }), r = Q({
510
518
  item: e,
511
519
  testGroupId: n
512
520
  });
@@ -514,18 +522,18 @@ const xe = (e = {}) => {
514
522
  ...e,
515
523
  ...r
516
524
  };
517
- }, Ve = async ({
525
+ }, Ne = async ({
518
526
  item: e,
519
527
  canTrack: t
520
528
  }) => {
521
- if (!t || !X(e))
529
+ if (!t || !J(e))
522
530
  return e;
523
- const r = await Re({
531
+ const r = await Le({
524
532
  contentId: e.id
525
- }) || J({
533
+ }) || q({
526
534
  variations: e.variations,
527
535
  id: e.id
528
- }), o = z({
536
+ }), o = Q({
529
537
  item: e,
530
538
  testGroupId: r
531
539
  });
@@ -533,38 +541,38 @@ const xe = (e = {}) => {
533
541
  ...e,
534
542
  ...o
535
543
  };
536
- }, Me = (e) => m(e) ? e : !0;
537
- function Ne() {
544
+ }, De = (e) => m(e) ? e : !0;
545
+ function Ke() {
538
546
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
539
547
  }
540
- function Fe() {
541
- const e = Ne().fetch;
548
+ function je() {
549
+ const e = Ke().fetch;
542
550
  if (typeof e == "undefined")
543
551
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
544
552
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
545
553
  return e;
546
554
  }
547
- const De = Fe();
548
- function k(e, t = null, n = ".") {
555
+ const We = je();
556
+ function O(e, t = null, n = ".") {
549
557
  return Object.keys(e).reduce((r, o) => {
550
558
  const s = e[o], i = [t, o].filter(Boolean).join(n);
551
559
  return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
552
560
  ...r,
553
- ...k(s, i, n)
561
+ ...O(s, i, n)
554
562
  } : {
555
563
  ...r,
556
564
  [i]: s
557
565
  };
558
566
  }, {});
559
567
  }
560
- function q(e, t, n = {}) {
568
+ function Y(e, t, n = {}) {
561
569
  for (const r in e) {
562
570
  const o = e[r], s = t ? t + "." + r : r;
563
- 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;
564
572
  }
565
573
  return n;
566
574
  }
567
- const Ke = "v3", B = (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) => {
568
576
  const {
569
577
  limit: t = 30,
570
578
  userAttributes: n,
@@ -573,90 +581,96 @@ const Ke = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
573
581
  apiKey: s,
574
582
  enrich: i,
575
583
  locale: u,
576
- apiVersion: y = Ke,
584
+ apiVersion: y = $e,
577
585
  fields: p,
578
- omit: I,
586
+ omit: k,
579
587
  offset: d,
580
588
  cacheSeconds: h,
581
589
  staleCacheSeconds: g,
582
590
  sort: S,
583
- includeUnpublished: P,
584
- apiHost: Q
591
+ includeUnpublished: x,
592
+ apiHost: Z
585
593
  } = e;
586
594
  if (!s)
587
595
  throw new Error("Missing API key");
588
596
  if (!["v3"].includes(y))
589
597
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
590
- const Y = t !== 1, Z = Q || "https://cdn.builder.io", a = new URL(`${Z}/api/${y}/content/${o}`);
591
- 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 && B(h) && a.searchParams.set("cacheSeconds", String(h)), g && B(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
592
- const l = 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 f = O({
593
607
  sort: S
594
608
  });
595
- for (const w in l)
596
- a.searchParams.set(w, JSON.stringify(l[w]));
609
+ for (const w in f)
610
+ a.searchParams.set(w, JSON.stringify(f[w]));
597
611
  }
598
- const ee = {
599
- ...de(),
600
- ...L(e.options || {})
601
- }, C = k(ee);
602
- for (const l in C)
603
- a.searchParams.set(l, String(C[l]));
604
- if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
605
- const l = q({
612
+ const ne = {
613
+ ...fe(),
614
+ ...V(e.options || {})
615
+ }, A = O(ne);
616
+ for (const f in A)
617
+ a.searchParams.set(f, String(A[f]));
618
+ if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
619
+ const f = Y({
606
620
  query: r
607
621
  });
608
- for (const w in l)
609
- a.searchParams.set(w, JSON.stringify(l[w]));
622
+ for (const w in f)
623
+ a.searchParams.set(w, JSON.stringify(f[w]));
610
624
  }
611
625
  return a;
612
- }, je = (e) => "results" in e;
613
- async function We(e) {
614
- const t = await Ge({
626
+ }, Ge = (e) => "results" in e;
627
+ async function _e(e) {
628
+ const t = await ze({
615
629
  ...e,
616
630
  limit: 1
617
631
  });
618
632
  return t && t[0] || null;
619
633
  }
620
- const $e = async (e) => {
634
+ const He = async (e) => {
621
635
  var i, u;
622
- const t = O(e), n = (i = e.fetch) != null ? i : De, r = {
636
+ const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
623
637
  ...e.fetchOptions,
624
638
  headers: {
625
639
  ...(u = e.fetchOptions) == null ? void 0 : u.headers,
626
- ...F()
640
+ ...K()
627
641
  }
628
642
  };
629
643
  return await (await n(t.href, r)).json();
630
- }, _e = async (e, t, n = O(e)) => {
631
- const r = Me(e.canTrack);
644
+ }, Xe = async (e, t, n = C(e)) => {
645
+ const r = De(e.canTrack);
632
646
  if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
633
647
  return t.results;
634
648
  try {
635
649
  const o = [];
636
650
  for (const s of t.results)
637
- o.push(await Ve({
651
+ o.push(await Ne({
638
652
  item: s,
639
653
  canTrack: r
640
654
  }));
641
655
  t.results = o;
642
656
  } catch (o) {
643
- f.error("Could not process A/B tests. ", o);
657
+ l.error("Could not process A/B tests. ", o);
644
658
  }
645
659
  return t.results;
646
660
  };
647
- async function Ge(e) {
661
+ async function ze(e) {
648
662
  try {
649
- const t = O(e), n = await $e(e);
650
- return je(n) ? _e(e, n) : (f.error("Error fetching data. ", {
663
+ const t = C(e), n = await He(e);
664
+ return Ge(n) ? Xe(e, n) : (l.error("Error fetching data. ", {
651
665
  url: t,
652
666
  content: n,
653
667
  options: e
654
668
  }), null);
655
669
  } catch (t) {
656
- return f.error("Error fetching data. ", t), null;
670
+ return l.error("Error fetching data. ", t), null;
657
671
  }
658
672
  }
659
- const Ze = async (e) => {
673
+ const nt = async (e) => {
660
674
  var r, o, s;
661
675
  const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
662
676
  ...e,
@@ -668,37 +682,39 @@ const Ze = async (e) => {
668
682
  urlPath: t
669
683
  } : {}
670
684
  },
671
- options: M(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
685
+ options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
672
686
  };
673
687
  return {
674
688
  apiKey: n.apiKey,
675
689
  model: n.model,
676
- content: await We(n)
690
+ content: await _e(n)
677
691
  };
678
692
  };
679
693
  export {
694
+ I as MSG_PREFIX,
680
695
  b as TARGET,
681
- _e as _processContentResult,
682
- Pe as _track,
696
+ Xe as _processContentResult,
697
+ Ae as _track,
683
698
  m as checkIsDefined,
684
- Ae as createEditorListener,
685
- Xe as createRegisterComponentMessage,
686
- Ze as fetchBuilderProps,
687
- Ge as fetchEntries,
688
- We as fetchOneEntry,
689
- M as getBuilderSearchParams,
690
- Me as getDefaultCanTrack,
691
- ie as getUserAttributes,
692
- Ye as handleABTestingSync,
699
+ Re as createEditorListener,
700
+ qe as createRegisterComponentMessage,
701
+ nt as fetchBuilderProps,
702
+ ze as fetchEntries,
703
+ _e as fetchOneEntry,
704
+ N as getBuilderSearchParams,
705
+ De as getDefaultCanTrack,
706
+ ce as getUserAttributes,
707
+ tt as handleABTestingSync,
693
708
  c as isBrowser,
694
- re as isEditing,
695
- He as isPreviewing,
696
- f as logger,
697
- ce as register,
698
- qe as registerInsertMenu,
699
- V as serializeIncludingFunctions,
700
- Je as setEditorSettings,
701
- xe as setupBrowserForEditing,
702
- Qe as subscribeToEditor,
703
- ze as track
709
+ se as isEditing,
710
+ Je as isPreviewing,
711
+ Pe as logFetch,
712
+ l as logger,
713
+ de as register,
714
+ Ze as registerInsertMenu,
715
+ M as serializeIncludingFunctions,
716
+ Qe as setEditorSettings,
717
+ Be as setupBrowserForEditing,
718
+ et as subscribeToEditor,
719
+ Ye as track
704
720
  };