@builder.io/sdk-react 1.0.25 → 1.0.27

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 (63) hide show
  1. package/lib/browser/blocks-exports.cjs +1 -1
  2. package/lib/browser/blocks-exports.mjs +1 -1
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/init.cjs +2 -2
  6. package/lib/browser/init.mjs +6 -5
  7. package/lib/browser/server-entry-60c3f2b2.cjs +2 -0
  8. package/lib/browser/{server-entry-d15ee928.js → server-entry-805a2c2a.js} +142 -135
  9. package/lib/browser/server-entry.cjs +1 -1
  10. package/lib/browser/server-entry.mjs +1 -1
  11. package/lib/edge/{blocks-7c1422af.js → blocks-a1399a78.js} +2 -2
  12. package/lib/edge/{blocks-8c31869c.cjs → blocks-af5c8ecf.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-3439cb1b.js → button-0820a5bc.js} +2 -2
  16. package/lib/edge/{button-96857fcf.cjs → button-16076ac7.cjs} +1 -1
  17. package/lib/edge/{columns-0d152875.js → columns-688cc205.js} +3 -3
  18. package/lib/edge/{columns-930c3d9a.cjs → columns-6b8c03be.cjs} +1 -1
  19. package/lib/edge/{content-variants-d62785c6.cjs → content-variants-4679172a.cjs} +1 -1
  20. package/lib/edge/{content-variants-1ff6980e.js → content-variants-efa4f81b.js} +9 -9
  21. package/lib/edge/{form-69ed6cc5.cjs → form-91166ed6.cjs} +1 -1
  22. package/lib/edge/{form-1dbd32d7.js → form-cbe7d822.js} +3 -3
  23. package/lib/edge/{get-class-prop-name-c793129b.cjs → get-class-prop-name-47012c9c.cjs} +1 -1
  24. package/lib/edge/{get-class-prop-name-58140fb7.js → get-class-prop-name-4a1bad2b.js} +1 -1
  25. package/lib/edge/{img-d4b1130f.js → img-14849a5b.js} +1 -1
  26. package/lib/edge/{img-305b1676.cjs → img-d3420f5d.cjs} +1 -1
  27. package/lib/edge/index.cjs +1 -1
  28. package/lib/edge/index.mjs +1 -1
  29. package/lib/edge/init.cjs +2 -2
  30. package/lib/edge/init.mjs +6 -5
  31. package/lib/edge/{input-28dd9b60.cjs → input-07becc4d.cjs} +1 -1
  32. package/lib/edge/{input-a7054c28.js → input-534b9f95.js} +1 -1
  33. package/lib/edge/{select-dd83a040.js → select-b05ef24f.js} +1 -1
  34. package/lib/edge/{select-57b6e444.cjs → select-e576d7d0.cjs} +1 -1
  35. package/lib/edge/{server-entry-cb8ad418.js → server-entry-6aaf6054.js} +137 -130
  36. package/lib/edge/server-entry-ee324b22.cjs +2 -0
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-7dbe2bcb.js → slot-944437dd.js} +3 -3
  40. package/lib/edge/{slot-3f6aff1b.cjs → slot-e139f9b4.cjs} +1 -1
  41. package/lib/edge/{symbol-a20aae0e.js → symbol-75d1c60d.js} +2 -2
  42. package/lib/edge/{symbol-63f3b56e.cjs → symbol-f7f42446.cjs} +1 -1
  43. package/lib/edge/{tabs-f559c3bf.cjs → tabs-4860ef6d.cjs} +1 -1
  44. package/lib/edge/{tabs-f5fd67a5.js → tabs-62e415e1.js} +3 -3
  45. package/lib/node/blocks-exports.cjs +1 -1
  46. package/lib/node/blocks-exports.mjs +2 -2
  47. package/lib/node/index.cjs +1 -1
  48. package/lib/node/index.mjs +2 -2
  49. package/lib/node/init.cjs +1 -1
  50. package/lib/node/init.mjs +8 -7
  51. package/lib/node/{node-runtime-79a56b80.cjs → node-runtime-1bee7133.cjs} +1 -1
  52. package/lib/node/{node-runtime-def43b7b.js → node-runtime-e167306c.js} +1 -1
  53. package/lib/node/{server-entry-28bf4f4c.js → server-entry-38fb2258.js} +142 -135
  54. package/lib/node/server-entry-db936548.cjs +2 -0
  55. package/lib/node/server-entry.cjs +1 -1
  56. package/lib/node/server-entry.mjs +1 -1
  57. package/package.json +1 -1
  58. package/types/constants/sdk-version.d.ts +1 -1
  59. package/types/functions/evaluate/node-runtime/init.d.ts +1 -1
  60. package/types/helpers/flatten.d.ts +10 -0
  61. package/lib/browser/server-entry-f28ec73b.cjs +0 -2
  62. package/lib/edge/server-entry-d9413c6f.cjs +0 -2
  63. package/lib/node/server-entry-c4d16d70.cjs +0 -2
@@ -1,6 +1,6 @@
1
1
  import { jsx as u } from "react/jsx-runtime";
2
2
  import { createElement as m } from "react";
3
- import { isEditing as n } from "./server-entry-cb8ad418.js";
3
+ import { isEditing as n } from "./server-entry-6aaf6054.js";
4
4
  function r(e) {
5
5
  var t;
6
6
  return /* @__PURE__ */ m(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-d9413c6f.cjs");function i(e){var a;return n.createElement("select",{...e.attributes,value:e.value,key:r.isEditing()&&e.defaultValue?e.defaultValue:"default-key",defaultValue:e.defaultValue,name:e.name},(a=e.options)==null?void 0:a.map((t,u)=>l.jsx("option",{value:t.value,children:t.name||t.value},`${t.name}-${u}`)))}exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-ee324b22.cjs");function i(e){var a;return n.createElement("select",{...e.attributes,value:e.value,key:r.isEditing()&&e.defaultValue?e.defaultValue:"default-key",defaultValue:e.defaultValue,name:e.name},(a=e.options)==null?void 0:a.map((t,u)=>l.jsx("option",{value:t.value,children:t.name||t.value},`${t.name}-${u}`)))}exports.default=i;
@@ -1,40 +1,40 @@
1
- const I = "react", q = (e) => {
1
+ const v = "react", Q = (e) => {
2
2
  const t = {};
3
3
  return e.forEach((n, r) => {
4
4
  t[r] = n;
5
5
  }), t;
6
- }, L = (e) => e instanceof URLSearchParams ? q(e) : e, V = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
6
+ }, L = (e) => e instanceof URLSearchParams ? Q(e) : e, V = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
7
7
  function c() {
8
8
  return typeof window != "undefined" && typeof document != "undefined";
9
9
  }
10
10
  function Y() {
11
11
  return c() && window.self !== window.top;
12
12
  }
13
- function Q(e) {
13
+ function Z(e) {
14
14
  return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
15
15
  V(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
16
16
  }
17
- function $e(e) {
17
+ function Ge(e) {
18
18
  const t = e || (c() ? window.location.search : void 0);
19
19
  return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
20
20
  }
21
- const U = (e) => JSON.parse(JSON.stringify(e)), Ge = (e) => ({
21
+ const U = (e) => JSON.parse(JSON.stringify(e)), ze = (e) => ({
22
22
  type: "builder.registerComponent",
23
- data: te(e)
24
- }), Z = (e) => {
23
+ data: ne(e)
24
+ }), ee = (e) => {
25
25
  const t = e.toString().trim();
26
26
  return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
27
- }, ee = (e) => typeof e == "function" ? Z(e) : U(e), te = ({
27
+ }, te = (e) => typeof e == "function" ? ee(e) : U(e), ne = ({
28
28
  inputs: e,
29
29
  ...t
30
30
  }) => ({
31
31
  ...U(t),
32
32
  inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
33
33
  ...r,
34
- [o]: ee(s)
34
+ [o]: te(s)
35
35
  }), {}))
36
36
  }), x = {};
37
- function ne(e, t) {
37
+ function re(e, t) {
38
38
  let n = x[e];
39
39
  if (n || (n = x[e] = []), n.push(t), c()) {
40
40
  const r = {
@@ -52,7 +52,7 @@ function ne(e, t) {
52
52
  }
53
53
  }
54
54
  const A = {};
55
- function ze(e) {
55
+ function Je(e) {
56
56
  if (c()) {
57
57
  Object.assign(A, e);
58
58
  const t = {
@@ -62,17 +62,17 @@ function ze(e) {
62
62
  parent.postMessage(t, "*");
63
63
  }
64
64
  }
65
- const T = "builder.", re = "options.", M = (e) => {
65
+ const T = "builder.", oe = "options.", M = (e) => {
66
66
  if (!e)
67
67
  return {};
68
68
  const t = L(e), n = {};
69
69
  return Object.keys(t).forEach((r) => {
70
70
  if (r.startsWith(T)) {
71
- const o = r.replace(T, "").replace(re, "");
71
+ const o = r.replace(T, "").replace(oe, "");
72
72
  n[o] = t[r];
73
73
  }
74
74
  }), n;
75
- }, oe = () => {
75
+ }, se = () => {
76
76
  if (!c())
77
77
  return {};
78
78
  const e = new URLSearchParams(window.location.search);
@@ -82,7 +82,7 @@ const T = "builder.", re = "options.", M = (e) => {
82
82
  error: (...e) => console.error(b, ...e),
83
83
  warn: (...e) => console.warn(b, ...e),
84
84
  debug: (...e) => console.debug(b, ...e)
85
- }, m = (e) => e != null, se = (e) => {
85
+ }, m = (e) => e != null, ie = (e) => {
86
86
  if (e === "localhost" || e === "127.0.0.1")
87
87
  return e;
88
88
  const t = e.split(".");
@@ -98,13 +98,13 @@ const T = "builder.", re = "options.", M = (e) => {
98
98
  f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
99
99
  return;
100
100
  }
101
- }, F = async (e) => N(e), ie = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ae = [["secure", ""], ["SameSite", "None"]], ce = ({
101
+ }, F = async (e) => N(e), ae = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ce = [["secure", ""], ["SameSite", "None"]], ue = ({
102
102
  name: e,
103
103
  value: t,
104
104
  expires: n
105
105
  }) => {
106
- const o = (c() ? location.protocol === "https:" : !0) ? ae : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", se(window.location.hostname)], ...o];
107
- return ie(a);
106
+ const o = (c() ? location.protocol === "https:" : !0) ? ce : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", ie(window.location.hostname)], ...o];
107
+ return ae(a);
108
108
  }, j = async ({
109
109
  name: e,
110
110
  value: t,
@@ -114,7 +114,7 @@ const T = "builder.", re = "options.", M = (e) => {
114
114
  try {
115
115
  if (!r)
116
116
  return;
117
- const o = ce({
117
+ const o = ue({
118
118
  name: e,
119
119
  value: t,
120
120
  expires: n
@@ -124,16 +124,16 @@ const T = "builder.", re = "options.", M = (e) => {
124
124
  f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
125
125
  }
126
126
  };
127
- function ue() {
127
+ function de() {
128
128
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
129
129
  const t = Math.random() * 16 | 0;
130
130
  return (e == "x" ? t : t & 3 | 8).toString(16);
131
131
  });
132
132
  }
133
133
  function D() {
134
- return ue().replace(/-/g, "");
134
+ return de().replace(/-/g, "");
135
135
  }
136
- const K = "builderSessionId", de = async ({
136
+ const K = "builderSessionId", le = async ({
137
137
  canTrack: e
138
138
  }) => {
139
139
  if (!e)
@@ -145,64 +145,64 @@ const K = "builderSessionId", de = async ({
145
145
  if (m(t))
146
146
  return t;
147
147
  {
148
- const n = le();
149
- return fe({
148
+ const n = fe();
149
+ return he({
150
150
  id: n,
151
151
  canTrack: e
152
152
  }), n;
153
153
  }
154
- }, le = () => D(), fe = ({
154
+ }, fe = () => D(), he = ({
155
155
  id: e,
156
156
  canTrack: t
157
157
  }) => j({
158
158
  name: K,
159
159
  value: e,
160
160
  canTrack: t
161
- }), _ = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, he = ({
161
+ }), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ge = ({
162
162
  key: e,
163
163
  canTrack: t
164
164
  }) => {
165
165
  var n;
166
166
  try {
167
- return t ? (n = _()) == null ? void 0 : n.getItem(e) : void 0;
167
+ return t ? (n = W()) == null ? void 0 : n.getItem(e) : void 0;
168
168
  } catch (r) {
169
169
  console.debug("[LocalStorage] GET error: ", r);
170
170
  return;
171
171
  }
172
- }, ge = ({
172
+ }, pe = ({
173
173
  key: e,
174
174
  canTrack: t,
175
175
  value: n
176
176
  }) => {
177
177
  var r;
178
178
  try {
179
- t && ((r = _()) == null || r.setItem(e, n));
179
+ t && ((r = W()) == null || r.setItem(e, n));
180
180
  } catch (o) {
181
181
  console.debug("[LocalStorage] SET error: ", o);
182
182
  }
183
- }, W = "builderVisitorId", pe = ({
183
+ }, _ = "builderVisitorId", me = ({
184
184
  canTrack: e
185
185
  }) => {
186
186
  if (!e)
187
187
  return;
188
- const t = he({
189
- key: W,
188
+ const t = ge({
189
+ key: _,
190
190
  canTrack: e
191
191
  });
192
192
  if (m(t))
193
193
  return t;
194
194
  {
195
- const n = me();
196
- return ye({
195
+ const n = ye();
196
+ return we({
197
197
  id: n,
198
198
  canTrack: e
199
199
  }), n;
200
200
  }
201
- }, me = () => D(), ye = ({
201
+ }, ye = () => D(), we = ({
202
202
  id: e,
203
203
  canTrack: t
204
- }) => ge({
205
- key: W,
204
+ }) => pe({
205
+ key: _,
206
206
  value: e,
207
207
  canTrack: t
208
208
  }), Se = () => {
@@ -211,8 +211,8 @@ const K = "builderSessionId", de = async ({
211
211
  return e.pathname === "" && (e.pathname = "/"), e;
212
212
  } else
213
213
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
214
- }, we = () => typeof navigator == "object" && navigator.userAgent || "", be = () => {
215
- const e = we(), t = {
214
+ }, be = () => typeof navigator == "object" && navigator.userAgent || "", ve = () => {
215
+ const e = be(), t = {
216
216
  Android() {
217
217
  return e.match(/Android/i);
218
218
  },
@@ -229,7 +229,7 @@ const K = "builderSessionId", de = async ({
229
229
  return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
230
230
  },
231
231
  any() {
232
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || I === "reactNative";
232
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
233
233
  }
234
234
  }, n = e.match(/Tablet|iPad/i), r = Se();
235
235
  return {
@@ -237,7 +237,7 @@ const K = "builderSessionId", de = async ({
237
237
  host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
238
238
  device: n ? "tablet" : t.any() ? "mobile" : "desktop"
239
239
  };
240
- }, ve = async ({
240
+ }, Ie = async ({
241
241
  canTrack: e
242
242
  }) => {
243
243
  if (!e)
@@ -245,16 +245,16 @@ const K = "builderSessionId", de = async ({
245
245
  visitorId: void 0,
246
246
  sessionId: void 0
247
247
  };
248
- const t = await de({
248
+ const t = await le({
249
249
  canTrack: e
250
- }), n = pe({
250
+ }), n = me({
251
251
  canTrack: e
252
252
  });
253
253
  return {
254
254
  sessionId: t,
255
255
  visitorId: n
256
256
  };
257
- }, Ie = async ({
257
+ }, ke = async ({
258
258
  type: e,
259
259
  canTrack: t,
260
260
  apiKey: n,
@@ -268,23 +268,23 @@ const K = "builderSessionId", de = async ({
268
268
  url: location.href,
269
269
  ...r
270
270
  },
271
- ...await ve({
271
+ ...await Ie({
272
272
  canTrack: t
273
273
  }),
274
- userAttributes: be(),
274
+ userAttributes: ve(),
275
275
  ownerId: n
276
276
  }
277
277
  });
278
- async function ke(e) {
278
+ async function Ee(e) {
279
279
  if (!e.apiKey) {
280
280
  f.error("Missing API key for track call. Please provide your API key.");
281
281
  return;
282
282
  }
283
- if (e.canTrack && !Q() && (c() || I === "reactNative"))
283
+ if (e.canTrack && !Z() && (c() || v === "reactNative"))
284
284
  return fetch("https://cdn.builder.io/api/v1/track", {
285
285
  method: "POST",
286
286
  body: JSON.stringify({
287
- events: [await Ie(e)]
287
+ events: [await ke(e)]
288
288
  }),
289
289
  headers: {
290
290
  "content-type": "application/json"
@@ -294,16 +294,16 @@ async function ke(e) {
294
294
  console.error("Failed to track: ", t);
295
295
  });
296
296
  }
297
- const Je = (e) => ke({
297
+ const He = (e) => Ee({
298
298
  ...e,
299
299
  canTrack: !0
300
- }), Ee = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
300
+ }), Oe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
301
301
  function $(e, t) {
302
302
  const n = new URL(t.origin), r = n.hostname;
303
- return (e || Ee).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
303
+ return (e || Oe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
304
304
  }
305
- const Pe = "1.0.25", He = () => {
306
- ne("insertMenu", {
305
+ const Pe = "1.0.27", Xe = () => {
306
+ re("insertMenu", {
307
307
  name: "_default",
308
308
  default: !0,
309
309
  items: [{
@@ -331,7 +331,7 @@ const Ce = (e = {}) => {
331
331
  R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
332
332
  type: "builder.sdkInfo",
333
333
  data: {
334
- target: I,
334
+ target: v,
335
335
  version: Pe,
336
336
  supportsPatchUpdates: !1,
337
337
  // Supports builder-model="..." attribute which is needed to
@@ -354,10 +354,10 @@ const Ce = (e = {}) => {
354
354
  if (o != null && o.type)
355
355
  switch (o.type) {
356
356
  case "builder.evaluate": {
357
- const d = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(d);
357
+ const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
358
358
  let u, h = null;
359
359
  try {
360
- u = k.apply(null, y);
360
+ u = I.apply(null, y);
361
361
  } catch (g) {
362
362
  h = g;
363
363
  }
@@ -368,8 +368,8 @@ const Ce = (e = {}) => {
368
368
  error: h.message
369
369
  }
370
370
  }, "*") : u && typeof u.then == "function" ? u.then((g) => {
371
- var S;
372
- (S = window.parent) == null || S.postMessage({
371
+ var w;
372
+ (w = window.parent) == null || w.postMessage({
373
373
  type: "builder.evaluateResult",
374
374
  data: {
375
375
  id: p,
@@ -387,7 +387,7 @@ const Ce = (e = {}) => {
387
387
  }
388
388
  }
389
389
  })));
390
- }, Oe = ({
390
+ }, xe = ({
391
391
  model: e,
392
392
  trustedHosts: t,
393
393
  callbacks: n
@@ -413,12 +413,12 @@ const Ce = (e = {}) => {
413
413
  break;
414
414
  }
415
415
  }
416
- }, Xe = (e, t, n) => {
416
+ }, qe = (e, t, n) => {
417
417
  if (!c)
418
418
  return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
419
419
  };
420
420
  Ce();
421
- const r = Oe({
421
+ const r = xe({
422
422
  callbacks: {
423
423
  contentUpdate: t,
424
424
  animation: () => {
@@ -432,24 +432,24 @@ const Ce = (e = {}) => {
432
432
  return window.addEventListener("message", r), () => {
433
433
  window.removeEventListener("message", r);
434
434
  };
435
- }, xe = "builder.tests", E = (e) => `${xe}.${e}`, Ae = ({
435
+ }, Ae = "builder.tests", E = (e) => `${Ae}.${e}`, Te = ({
436
436
  contentId: e
437
437
  }) => F({
438
438
  name: E(e),
439
439
  canTrack: !0
440
- }), Te = ({
440
+ }), Re = ({
441
441
  contentId: e
442
442
  }) => N({
443
443
  name: E(e),
444
444
  canTrack: !0
445
- }), Re = ({
445
+ }), Be = ({
446
446
  contentId: e,
447
447
  value: t
448
448
  }) => j({
449
449
  name: E(e),
450
450
  value: t,
451
451
  canTrack: !0
452
- }), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Be = ({
452
+ }), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Le = ({
453
453
  id: e,
454
454
  variations: t
455
455
  }) => {
@@ -463,8 +463,8 @@ const Ce = (e = {}) => {
463
463
  }
464
464
  return e;
465
465
  }, z = (e) => {
466
- const t = Be(e);
467
- return Re({
466
+ const t = Le(e);
467
+ return Be({
468
468
  contentId: e.id,
469
469
  value: t
470
470
  }).catch((n) => {
@@ -484,7 +484,7 @@ const Ce = (e = {}) => {
484
484
  testVariationId: n.id,
485
485
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
486
486
  };
487
- }, qe = ({
487
+ }, Qe = ({
488
488
  item: e,
489
489
  canTrack: t
490
490
  }) => {
@@ -494,7 +494,7 @@ const Ce = (e = {}) => {
494
494
  return;
495
495
  if (!G(e))
496
496
  return e;
497
- const n = Te({
497
+ const n = Re({
498
498
  contentId: e.id
499
499
  }) || z({
500
500
  variations: e.variations,
@@ -507,13 +507,13 @@ const Ce = (e = {}) => {
507
507
  ...e,
508
508
  ...r
509
509
  };
510
- }, Le = async ({
510
+ }, Ve = async ({
511
511
  item: e,
512
512
  canTrack: t
513
513
  }) => {
514
514
  if (!t || !G(e))
515
515
  return e;
516
- const r = await Ae({
516
+ const r = await Te({
517
517
  contentId: e.id
518
518
  }) || z({
519
519
  variations: e.variations,
@@ -526,31 +526,38 @@ const Ce = (e = {}) => {
526
526
  ...e,
527
527
  ...o
528
528
  };
529
- }, Ve = (e) => m(e) ? e : !0;
530
- function Ue() {
529
+ }, Ue = (e) => m(e) ? e : !0;
530
+ function Me() {
531
531
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
532
532
  }
533
- function Me() {
534
- const e = Ue().fetch;
533
+ function Ne() {
534
+ const e = Me().fetch;
535
535
  if (typeof e == "undefined")
536
536
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
537
537
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
538
538
  return e;
539
539
  }
540
- const Ne = Me();
541
- function v(e, t = null, n = ".") {
540
+ const Fe = Ne();
541
+ function k(e, t = null, n = ".") {
542
542
  return Object.keys(e).reduce((r, o) => {
543
543
  const s = e[o], a = [t, o].filter(Boolean).join(n);
544
544
  return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
545
545
  ...r,
546
- ...v(s, a, n)
546
+ ...k(s, a, n)
547
547
  } : {
548
548
  ...r,
549
549
  [a]: s
550
550
  };
551
551
  }, {});
552
552
  }
553
- const Fe = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, P = (e) => {
553
+ function H(e, t, n = {}) {
554
+ for (const r in e) {
555
+ const o = e[r], s = t ? t + "." + r : r;
556
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
557
+ }
558
+ return n;
559
+ }
560
+ const je = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
554
561
  const {
555
562
  limit: t = 30,
556
563
  userAttributes: n,
@@ -559,61 +566,61 @@ const Fe = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, P = (e)
559
566
  apiKey: s,
560
567
  enrich: a,
561
568
  locale: d,
562
- apiVersion: y = Fe,
569
+ apiVersion: y = je,
563
570
  fields: p,
564
- omit: k,
571
+ omit: I,
565
572
  offset: u,
566
573
  cacheSeconds: h,
567
574
  staleCacheSeconds: g,
568
- sort: S,
569
- includeUnpublished: C
575
+ sort: w,
576
+ includeUnpublished: P
570
577
  } = e;
571
578
  if (!s)
572
579
  throw new Error("Missing API key");
573
580
  if (!["v3"].includes(y))
574
581
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
575
- const H = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
576
- if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(H)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", k || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof C == "boolean" && i.searchParams.set("includeUnpublished", String(C)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), S) {
577
- const l = v({
578
- sort: S
582
+ const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
583
+ if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
584
+ const l = k({
585
+ sort: w
579
586
  });
580
- for (const w in l)
581
- i.searchParams.set(w, JSON.stringify(l[w]));
587
+ for (const S in l)
588
+ i.searchParams.set(S, JSON.stringify(l[S]));
582
589
  }
583
- const X = {
584
- ...oe(),
590
+ const q = {
591
+ ...se(),
585
592
  ...L(e.options || {})
586
- }, O = v(X);
587
- for (const l in O)
588
- i.searchParams.set(l, String(O[l]));
593
+ }, C = k(q);
594
+ for (const l in C)
595
+ i.searchParams.set(l, String(C[l]));
589
596
  if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
590
- const l = v({
597
+ const l = H({
591
598
  query: r
592
599
  });
593
- for (const w in l)
594
- i.searchParams.set(w, JSON.stringify(l[w]));
600
+ for (const S in l)
601
+ i.searchParams.set(S, JSON.stringify(l[S]));
595
602
  }
596
603
  return i;
597
- }, je = (e) => "results" in e;
598
- async function De(e) {
599
- const t = await We({
604
+ }, De = (e) => "results" in e;
605
+ async function Ke(e) {
606
+ const t = await $e({
600
607
  ...e,
601
608
  limit: 1
602
609
  });
603
610
  return t && t[0] || null;
604
611
  }
605
- const Ke = async (e) => {
612
+ const We = async (e) => {
606
613
  var s;
607
- const t = P(e);
608
- return await (await ((s = e.fetch) != null ? s : Ne)(t.href, e.fetchOptions)).json();
609
- }, _e = async (e, t, n = P(e)) => {
610
- const r = Ve(e.canTrack);
611
- if (n.search.includes("preview="), !r || !(c() || I === "reactNative"))
614
+ const t = O(e);
615
+ return await (await ((s = e.fetch) != null ? s : Fe)(t.href, e.fetchOptions)).json();
616
+ }, _e = async (e, t, n = O(e)) => {
617
+ const r = Ue(e.canTrack);
618
+ if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
612
619
  return t.results;
613
620
  try {
614
621
  const o = [];
615
622
  for (const s of t.results)
616
- o.push(await Le({
623
+ o.push(await Ve({
617
624
  item: s,
618
625
  canTrack: r
619
626
  }));
@@ -623,10 +630,10 @@ const Ke = async (e) => {
623
630
  }
624
631
  return t.results;
625
632
  };
626
- async function We(e) {
633
+ async function $e(e) {
627
634
  try {
628
- const t = P(e), n = await Ke(e);
629
- return je(n) ? _e(e, n) : (f.error("Error fetching data. ", {
635
+ const t = O(e), n = await We(e);
636
+ return De(n) ? _e(e, n) : (f.error("Error fetching data. ", {
630
637
  url: t,
631
638
  content: n,
632
639
  options: e
@@ -652,35 +659,35 @@ const Ye = async (e) => {
652
659
  return {
653
660
  apiKey: n.apiKey,
654
661
  model: n.model,
655
- content: await De(n)
662
+ content: await Ke(n)
656
663
  };
657
664
  };
658
665
  export {
659
666
  b as MSG_PREFIX,
660
- I as TARGET,
667
+ v as TARGET,
661
668
  _e as _processContentResult,
662
- ke as _track,
669
+ Ee as _track,
663
670
  m as checkIsDefined,
664
- Oe as createEditorListener,
665
- Ge as createRegisterComponentMessage,
671
+ xe as createEditorListener,
672
+ ze as createRegisterComponentMessage,
666
673
  U as fastClone,
667
- Ne as fetch,
674
+ Fe as fetch,
668
675
  Ye as fetchBuilderProps,
669
- We as fetchEntries,
670
- De as fetchOneEntry,
676
+ $e as fetchEntries,
677
+ Ke as fetchOneEntry,
671
678
  M as getBuilderSearchParams,
672
- Ve as getDefaultCanTrack,
673
- be as getUserAttributes,
674
- qe as handleABTestingSync,
679
+ Ue as getDefaultCanTrack,
680
+ ve as getUserAttributes,
681
+ Qe as handleABTestingSync,
675
682
  c as isBrowser,
676
- Q as isEditing,
677
- $e as isPreviewing,
683
+ Z as isEditing,
684
+ Ge as isPreviewing,
678
685
  f as logger,
679
- ne as register,
680
- He as registerInsertMenu,
681
- te as serializeComponentInfo,
682
- ze as setEditorSettings,
686
+ re as register,
687
+ Xe as registerInsertMenu,
688
+ ne as serializeComponentInfo,
689
+ Je as setEditorSettings,
683
690
  Ce as setupBrowserForEditing,
684
- Xe as subscribeToEditor,
685
- Je as track
691
+ qe as subscribeToEditor,
692
+ He as track
686
693
  };