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