@builder.io/sdk-react 3.0.5 → 3.0.6

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 (77) hide show
  1. package/lib/browser/blocks-exports.cjs +166 -29
  2. package/lib/browser/blocks-exports.mjs +1179 -765
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +17 -16
  5. package/lib/browser/server-entry-a1c64831.cjs +2 -0
  6. package/lib/browser/{server-entry-785c0408.js → server-entry-df5e89e5.js} +279 -237
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-cd6e0363.js → accordion-289f3464.js} +1 -1
  10. package/lib/edge/{accordion-190c4426.cjs → accordion-fbfb71f4.cjs} +1 -1
  11. package/lib/edge/{blocks-766e8d45.cjs → blocks-459a090b.cjs} +10 -10
  12. package/lib/edge/{blocks-fe2d7c1a.js → blocks-582a7fd7.js} +87 -87
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +13 -12
  15. package/lib/edge/{button-6a27481c.js → button-9b112da6.js} +2 -2
  16. package/lib/edge/{button-694fcd4f.cjs → button-da357144.cjs} +1 -1
  17. package/lib/edge/{columns-b38bf0f7.cjs → columns-a211113f.cjs} +1 -1
  18. package/lib/edge/{columns-90e6407e.js → columns-aba58dda.js} +3 -3
  19. package/lib/edge/{content-variants-cbb89349.js → content-variants-08f4371c.js} +165 -124
  20. package/lib/edge/content-variants-4b5899b5.cjs +134 -0
  21. package/lib/edge/dynamic-blocks-exports.cjs +3 -1
  22. package/lib/edge/dynamic-blocks-exports.mjs +5 -2
  23. package/lib/edge/{form-16bbf874.js → form-4d4553c2.js} +3 -3
  24. package/lib/edge/{form-547645eb.cjs → form-e3a3afd4.cjs} +1 -1
  25. package/lib/edge/{get-class-prop-name-8b719c6b.js → get-class-prop-name-38c2baca.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-58770197.cjs → get-class-prop-name-fbe244e3.cjs} +1 -1
  27. package/lib/edge/{img-8859c851.cjs → img-8d549af8.cjs} +1 -1
  28. package/lib/edge/{img-d3351743.js → img-c49066fa.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +18 -17
  31. package/lib/edge/{input-4fe0fc6d.cjs → input-1ae3842f.cjs} +1 -1
  32. package/lib/edge/{input-24c601b4.js → input-e7301f4e.js} +1 -1
  33. package/lib/edge/personalization-container-035be6ba.js +384 -0
  34. package/lib/edge/personalization-container-25cd8b5e.cjs +138 -0
  35. package/lib/edge/{select-af05377b.js → select-4187b229.js} +1 -1
  36. package/lib/edge/{select-c73bd418.cjs → select-64fdaa79.cjs} +1 -1
  37. package/lib/edge/server-entry-2ef4e66a.cjs +2 -0
  38. package/lib/edge/{server-entry-67bfc740.js → server-entry-61fca4f7.js} +322 -280
  39. package/lib/edge/server-entry.cjs +1 -1
  40. package/lib/edge/server-entry.mjs +1 -1
  41. package/lib/edge/{slot-759c8dd9.cjs → slot-995f63c2.cjs} +1 -1
  42. package/lib/edge/{slot-32a4df0c.js → slot-d6c46a42.js} +3 -3
  43. package/lib/edge/{symbol-8d63aa7d.cjs → symbol-498daa97.cjs} +1 -1
  44. package/lib/edge/{symbol-50360a37.js → symbol-623dc717.js} +2 -2
  45. package/lib/edge/{tabs-6535c934.js → tabs-12ba41b1.js} +3 -3
  46. package/lib/edge/{tabs-fc6c1700.cjs → tabs-d39499cd.cjs} +1 -1
  47. package/lib/node/blocks-exports.cjs +168 -31
  48. package/lib/node/blocks-exports.mjs +1292 -878
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +17 -16
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +3 -3
  53. package/lib/node/{server-entry-ffc70868.js → server-entry-27d9d31e.js} +279 -237
  54. package/lib/node/server-entry-98ebff74.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-2cea7252.js → setIvm-2dde9074.js} +1 -1
  58. package/lib/node/{setIvm-4ce0db03.cjs → setIvm-784fe19f.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-c0d50009.js → should-force-browser-runtime-in-node-80f081c8.js} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-d3e6df07.cjs → should-force-browser-runtime-in-node-cd6baa94.cjs} +1 -1
  63. package/package.json +1 -1
  64. package/types/blocks/personalization-container/component-info.d.ts +2 -0
  65. package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +8 -0
  66. package/types/blocks/personalization-container/helpers.d.ts +27 -0
  67. package/types/blocks/personalization-container/index.d.ts +1 -0
  68. package/types/blocks/personalization-container/personalization-container.d.ts +4 -0
  69. package/types/blocks/personalization-container/personalization-container.types.d.ts +14 -0
  70. package/types/constants/sdk-version.d.ts +1 -1
  71. package/types/helpers/user-attributes.d.ts +17 -0
  72. package/types/index-helpers/blocks-exports.d.ts +1 -0
  73. package/types/types/input.d.ts +1 -0
  74. package/lib/browser/server-entry-101d66b8.cjs +0 -2
  75. package/lib/edge/content-variants-4e385c19.cjs +0 -134
  76. package/lib/edge/server-entry-3c7fa63a.cjs +0 -2
  77. package/lib/node/server-entry-95273908.cjs +0 -2
@@ -1,38 +1,120 @@
1
- const v = "react", rt = (t) => {
1
+ function c() {
2
+ return typeof window != "undefined" && typeof document != "undefined";
3
+ }
4
+ const I = "[Builder.io]: ", f = {
5
+ log: (...t) => console.log(I, ...t),
6
+ error: (...t) => console.error(I, ...t),
7
+ warn: (...t) => console.warn(I, ...t),
8
+ debug: (...t) => console.debug(I, ...t)
9
+ }, y = (t) => t != null, ot = (t) => {
10
+ if (t === "localhost" || t === "127.0.0.1")
11
+ return t;
12
+ const e = t.split(".");
13
+ return e.length > 2 ? e.slice(1).join(".") : t;
14
+ }, O = ({
15
+ name: t,
16
+ canTrack: e
17
+ }) => {
18
+ var n;
19
+ try {
20
+ return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
21
+ } catch (r) {
22
+ f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
23
+ return;
24
+ }
25
+ }, M = async (t) => O(t), it = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(y).join("; "), at = [["secure", ""], ["SameSite", "None"]], ct = ({
26
+ name: t,
27
+ value: e,
28
+ expires: n
29
+ }) => {
30
+ const s = (c() ? location.protocol === "https:" : !0) ? at : [[]], o = n ? [["expires", n.toUTCString()]] : [[]], i = [[t, e], ...o, ["path", "/"], ["domain", ot(window.location.hostname)], ...s];
31
+ return it(i);
32
+ }, P = async ({
33
+ name: t,
34
+ value: e,
35
+ expires: n,
36
+ canTrack: r
37
+ }) => {
38
+ try {
39
+ if (!r)
40
+ return;
41
+ const s = ct({
42
+ name: t,
43
+ value: e,
44
+ expires: n
45
+ });
46
+ document.cookie = s;
47
+ } catch (s) {
48
+ f.warn("[COOKIE] SET error: ", (s == null ? void 0 : s.message) || s);
49
+ }
50
+ }, B = "builder.userAttributes";
51
+ function ut() {
52
+ let t = !0;
53
+ const e = /* @__PURE__ */ new Set();
54
+ return {
55
+ setUserAttributes(n) {
56
+ if (!c())
57
+ return;
58
+ const r = {
59
+ ...this.getUserAttributes(),
60
+ ...n
61
+ };
62
+ P({
63
+ name: B,
64
+ value: JSON.stringify(r),
65
+ canTrack: t
66
+ }), e.forEach((s) => s(r));
67
+ },
68
+ getUserAttributes() {
69
+ return c() ? JSON.parse(O({
70
+ name: B,
71
+ canTrack: t
72
+ }) || "{}") : {};
73
+ },
74
+ subscribeOnUserAttributesChange(n) {
75
+ return e.add(n), () => {
76
+ e.delete(n);
77
+ };
78
+ },
79
+ setCanTrack(n) {
80
+ t = n;
81
+ }
82
+ };
83
+ }
84
+ const K = ut(), ee = (t) => {
85
+ K.setUserAttributes(t);
86
+ }, v = "react", lt = (t) => {
2
87
  const e = {};
3
88
  return t.forEach((n, r) => {
4
89
  e[r] = n;
5
90
  }), e;
6
- }, F = (t) => t instanceof URLSearchParams ? rt(t) : t, D = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- function ot() {
91
+ }, j = (t) => t instanceof URLSearchParams ? lt(t) : t, W = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
92
+ function dt() {
11
93
  return c() && window.self !== window.top;
12
94
  }
13
- function st(t) {
14
- return ot() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
15
- D(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
95
+ function ft(t) {
96
+ return dt() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
97
+ W(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
16
98
  }
17
- function Zt(t) {
99
+ function ne(t) {
18
100
  const e = t || (c() ? window.location.search : void 0);
19
- return e ? D(e).indexOf("builder.preview=") !== -1 : !1;
101
+ return e ? W(e).indexOf("builder.preview=") !== -1 : !1;
20
102
  }
21
- const qt = (t) => ({
103
+ const re = (t) => ({
22
104
  type: "builder.registerComponent",
23
- data: N(t)
24
- }), it = (t) => {
105
+ data: _(t)
106
+ }), ht = (t) => {
25
107
  const e = t.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(e);
26
108
  return `return (${!e.startsWith("function") && !e.startsWith("async") && !e.startsWith("(") && !n ? "function " : ""}${e}).apply(this, arguments)`;
27
109
  };
28
- function N(t) {
29
- return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? it(n) : n));
110
+ function _(t) {
111
+ return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? ht(n) : n));
30
112
  }
31
- const U = {};
32
- function at(t, e) {
33
- t === "plugin" && (e = N(e));
34
- let n = U[t];
35
- if (n || (n = U[t] = []), n.push(e), c()) {
113
+ const L = {};
114
+ function gt(t, e) {
115
+ t === "plugin" && (e = _(e));
116
+ let n = L[t];
117
+ if (n || (n = L[t] = []), n.push(e), c()) {
36
118
  const r = {
37
119
  type: "builder.register",
38
120
  data: {
@@ -42,182 +124,136 @@ function at(t, e) {
42
124
  };
43
125
  try {
44
126
  parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
45
- } catch (o) {
46
- console.debug("Could not postmessage", o);
127
+ } catch (s) {
128
+ console.debug("Could not postmessage", s);
47
129
  }
48
130
  }
49
131
  }
50
- const B = {};
51
- function te(t) {
132
+ const V = {};
133
+ function se(t) {
52
134
  if (c()) {
53
- Object.assign(B, t);
135
+ Object.assign(V, t);
54
136
  const e = {
55
137
  type: "builder.settingsChange",
56
- data: B
138
+ data: V
57
139
  };
58
140
  parent.postMessage(e, "*");
59
141
  }
60
142
  }
61
- const R = "builder.", ct = "options.", M = (t) => {
143
+ const N = "builder.", pt = "options.", $ = (t) => {
62
144
  if (!t)
63
145
  return {};
64
- const e = F(t), n = {};
146
+ const e = j(t), n = {};
65
147
  return Object.keys(e).forEach((r) => {
66
- if (r.startsWith(R)) {
67
- const o = r.replace(R, "").replace(ct, "");
68
- n[o] = e[r];
148
+ if (r.startsWith(N)) {
149
+ const s = r.replace(N, "").replace(pt, "");
150
+ n[s] = e[r];
69
151
  }
70
152
  }), n;
71
- }, ut = () => {
153
+ }, mt = () => {
72
154
  if (!c())
73
155
  return {};
74
156
  const t = new URLSearchParams(window.location.search);
75
- return M(t);
76
- }, I = "[Builder.io]: ", f = {
77
- log: (...t) => console.log(I, ...t),
78
- error: (...t) => console.error(I, ...t),
79
- warn: (...t) => console.warn(I, ...t),
80
- debug: (...t) => console.debug(I, ...t)
81
- }, K = "3.0.5", j = () => ({
157
+ return $(t);
158
+ }, G = "3.0.6", J = () => ({
82
159
  "X-Builder-SDK": v,
83
160
  "X-Builder-SDK-GEN": "2",
84
- "X-Builder-SDK-Version": K
85
- }), y = (t) => t != null, lt = (t) => {
86
- if (t === "localhost" || t === "127.0.0.1")
87
- return t;
88
- const e = t.split(".");
89
- return e.length > 2 ? e.slice(1).join(".") : t;
90
- }, W = ({
91
- name: t,
92
- canTrack: e
93
- }) => {
94
- var n;
95
- try {
96
- return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
97
- } catch (r) {
98
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
99
- return;
100
- }
101
- }, $ = async (t) => W(t), dt = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(y).join("; "), ft = [["secure", ""], ["SameSite", "None"]], ht = ({
102
- name: t,
103
- value: e,
104
- expires: n
105
- }) => {
106
- const o = (c() ? location.protocol === "https:" : !0) ? ft : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[t, e], ...s, ["path", "/"], ["domain", lt(window.location.hostname)], ...o];
107
- return dt(i);
108
- }, _ = async ({
109
- name: t,
110
- value: e,
111
- expires: n,
112
- canTrack: r
113
- }) => {
114
- try {
115
- if (!r)
116
- return;
117
- const o = ht({
118
- name: t,
119
- value: e,
120
- expires: n
121
- });
122
- document.cookie = o;
123
- } catch (o) {
124
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
125
- }
126
- };
127
- function gt() {
161
+ "X-Builder-SDK-Version": G
162
+ });
163
+ function yt() {
128
164
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
129
165
  const e = Math.random() * 16 | 0;
130
166
  return (t == "x" ? e : e & 3 | 8).toString(16);
131
167
  });
132
168
  }
133
- function G() {
134
- return gt().replace(/-/g, "");
169
+ function z() {
170
+ return yt().replace(/-/g, "");
135
171
  }
136
- const H = "builderSessionId", pt = async ({
172
+ const H = "builderSessionId", bt = async ({
137
173
  canTrack: t
138
174
  }) => {
139
175
  if (!t)
140
176
  return;
141
- const e = await $({
177
+ const e = await M({
142
178
  name: H,
143
179
  canTrack: t
144
180
  });
145
181
  if (y(e))
146
182
  return e;
147
183
  {
148
- const n = mt();
149
- return yt({
184
+ const n = St();
185
+ return wt({
150
186
  id: n,
151
187
  canTrack: t
152
188
  }), n;
153
189
  }
154
- }, mt = () => G(), yt = ({
190
+ }, St = () => z(), wt = ({
155
191
  id: t,
156
192
  canTrack: e
157
- }) => _({
193
+ }) => P({
158
194
  name: H,
159
195
  value: t,
160
196
  canTrack: e
161
- }), J = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, wt = ({
197
+ }), X = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, vt = ({
162
198
  key: t,
163
199
  canTrack: e
164
200
  }) => {
165
201
  var n;
166
202
  try {
167
- return e ? (n = J()) == null ? void 0 : n.getItem(t) : void 0;
203
+ return e ? (n = X()) == null ? void 0 : n.getItem(t) : void 0;
168
204
  } catch (r) {
169
205
  console.debug("[LocalStorage] GET error: ", r);
170
206
  return;
171
207
  }
172
- }, St = ({
208
+ }, It = ({
173
209
  key: t,
174
210
  canTrack: e,
175
211
  value: n
176
212
  }) => {
177
213
  var r;
178
214
  try {
179
- e && ((r = J()) == null || r.setItem(t, n));
180
- } catch (o) {
181
- console.debug("[LocalStorage] SET error: ", o);
215
+ e && ((r = X()) == null || r.setItem(t, n));
216
+ } catch (s) {
217
+ console.debug("[LocalStorage] SET error: ", s);
182
218
  }
183
- }, X = "builderVisitorId", bt = ({
219
+ }, Q = "builderVisitorId", kt = ({
184
220
  canTrack: t
185
221
  }) => {
186
222
  if (!t)
187
223
  return;
188
- const e = wt({
189
- key: X,
224
+ const e = vt({
225
+ key: Q,
190
226
  canTrack: t
191
227
  });
192
228
  if (y(e))
193
229
  return e;
194
230
  {
195
- const n = vt();
196
- return It({
231
+ const n = At();
232
+ return Et({
197
233
  id: n,
198
234
  canTrack: t
199
235
  }), n;
200
236
  }
201
- }, vt = () => G(), It = ({
237
+ }, At = () => z(), Et = ({
202
238
  id: t,
203
239
  canTrack: e
204
- }) => St({
205
- key: X,
240
+ }) => It({
241
+ key: Q,
206
242
  value: t,
207
243
  canTrack: e
208
244
  });
209
- function kt(t) {
245
+ function Ot(t) {
210
246
  var e;
211
247
  typeof process != "undefined" && ((e = process.env) != null && e.DEBUG) && String(process.env.DEBUG) == "true" && f.log(t);
212
248
  }
213
- const Et = () => {
249
+ const Pt = () => {
214
250
  if (c()) {
215
251
  const t = new URL(location.href);
216
252
  return t.pathname === "" && (t.pathname = "/"), t;
217
253
  } else
218
254
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
219
- }, At = () => typeof navigator == "object" && navigator.userAgent || "", Pt = () => {
220
- const t = At(), e = {
255
+ }, Ct = () => typeof navigator == "object" && navigator.userAgent || "", Ut = () => {
256
+ const t = Ct(), e = {
221
257
  Android() {
222
258
  return t.match(/Android/i);
223
259
  },
@@ -236,13 +272,13 @@ const Et = () => {
236
272
  any() {
237
273
  return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || v === "reactNative";
238
274
  }
239
- }, n = t.match(/Tablet|iPad/i), r = Et();
275
+ }, n = t.match(/Tablet|iPad/i), r = Pt();
240
276
  return {
241
277
  urlPath: r == null ? void 0 : r.pathname,
242
278
  host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
243
279
  device: n ? "tablet" : e.any() ? "mobile" : "desktop"
244
280
  };
245
- }, Ot = async ({
281
+ }, Tt = async ({
246
282
  canTrack: t
247
283
  }) => {
248
284
  if (!t)
@@ -250,37 +286,37 @@ const Et = () => {
250
286
  visitorId: void 0,
251
287
  sessionId: void 0
252
288
  };
253
- const e = await pt({
289
+ const e = await bt({
254
290
  canTrack: t
255
- }), n = bt({
291
+ }), n = kt({
256
292
  canTrack: t
257
293
  });
258
294
  return {
259
295
  sessionId: e,
260
296
  visitorId: n
261
297
  };
262
- }, Ct = async ({
298
+ }, xt = async ({
263
299
  type: t,
264
300
  canTrack: e,
265
301
  apiKey: n,
266
302
  metadata: r,
267
- ...o
303
+ ...s
268
304
  }) => ({
269
305
  type: t,
270
306
  data: {
271
- ...o,
307
+ ...s,
272
308
  metadata: {
273
309
  url: location.href,
274
310
  ...r
275
311
  },
276
- ...await Ot({
312
+ ...await Tt({
277
313
  canTrack: e
278
314
  }),
279
- userAttributes: Pt(),
315
+ userAttributes: Ut(),
280
316
  ownerId: n
281
317
  }
282
318
  });
283
- async function xt({
319
+ async function Rt({
284
320
  apiHost: t,
285
321
  ...e
286
322
  }) {
@@ -288,35 +324,35 @@ async function xt({
288
324
  f.error("Missing API key for track call. Please provide your API key.");
289
325
  return;
290
326
  }
291
- if (!e.canTrack || st() || !(c() || v === "reactNative"))
327
+ if (!e.canTrack || ft() || !(c() || v === "reactNative"))
292
328
  return;
293
329
  const r = `${t || "https://cdn.builder.io"}/api/v1/track`;
294
- return kt(r), fetch(r, {
330
+ return Ot(r), fetch(r, {
295
331
  method: "POST",
296
332
  body: JSON.stringify({
297
- events: [await Ct(e)]
333
+ events: [await xt(e)]
298
334
  }),
299
335
  headers: {
300
336
  "content-type": "application/json",
301
- ...j()
337
+ ...J()
302
338
  },
303
339
  mode: "cors"
304
- }).catch((o) => {
305
- console.error("Failed to track: ", o);
340
+ }).catch((s) => {
341
+ console.error("Failed to track: ", s);
306
342
  });
307
343
  }
308
- const ee = (t) => xt({
344
+ const oe = (t) => Rt({
309
345
  ...t,
310
346
  canTrack: !0
311
- }), Tt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
312
- function z(t, e) {
347
+ }), Bt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
348
+ function Y(t, e) {
313
349
  if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
314
350
  return !1;
315
351
  const n = new URL(e.origin), r = n.hostname;
316
- return (t || Tt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
352
+ return (t || Bt).findIndex((s) => s.startsWith("*.") ? r.endsWith(s.slice(1)) : s === r) > -1;
317
353
  }
318
- const ne = () => {
319
- at("insertMenu", {
354
+ const ie = () => {
355
+ gt("insertMenu", {
320
356
  name: "_default",
321
357
  default: !0,
322
358
  items: [{
@@ -338,19 +374,20 @@ const ne = () => {
338
374
  }]
339
375
  });
340
376
  };
341
- let L = !1;
342
- const Ut = (t = {}) => {
377
+ let F = !1;
378
+ const Lt = (t = {}) => {
343
379
  var e, n;
344
- L || (L = !0, c() && ((e = window.parent) == null || e.postMessage({
380
+ F || (F = !0, c() && ((e = window.parent) == null || e.postMessage({
345
381
  type: "builder.sdkInfo",
346
382
  data: {
347
383
  target: v,
348
- version: K,
384
+ version: G,
349
385
  supportsPatchUpdates: !1,
350
386
  // Supports builder-model="..." attribute which is needed to
351
387
  // scope our '+ add block' button styling
352
388
  supportsAddBlockScoping: !0,
353
- supportsCustomBreakpoints: !0
389
+ supportsCustomBreakpoints: !0,
390
+ blockLevelPersonalization: !0
354
391
  }
355
392
  }, "*"), (n = window.parent) == null || n.postMessage({
356
393
  type: "builder.updateContent",
@@ -358,23 +395,23 @@ const Ut = (t = {}) => {
358
395
  options: t
359
396
  }
360
397
  }, "*"), window.addEventListener("message", (r) => {
361
- var s, i;
362
- if (!z(t.trustedHosts, r))
398
+ var o, i;
399
+ if (!Y(t.trustedHosts, r))
363
400
  return;
364
401
  const {
365
- data: o
402
+ data: s
366
403
  } = r;
367
- if (o != null && o.type)
368
- switch (o.type) {
404
+ if (s != null && s.type)
405
+ switch (s.type) {
369
406
  case "builder.evaluate": {
370
- const u = o.data.text, w = o.data.arguments || [], p = o.data.id, k = new Function(u);
407
+ const u = s.data.text, b = s.data.arguments || [], p = s.data.id, k = new Function(u);
371
408
  let l, h = null;
372
409
  try {
373
- l = k.apply(null, w);
410
+ l = k.apply(null, b);
374
411
  } catch (g) {
375
412
  h = g;
376
413
  }
377
- h ? (s = window.parent) == null || s.postMessage({
414
+ h ? (o = window.parent) == null || o.postMessage({
378
415
  type: "builder.evaluateError",
379
416
  data: {
380
417
  id: p,
@@ -400,38 +437,38 @@ const Ut = (t = {}) => {
400
437
  }
401
438
  }
402
439
  })));
403
- }, Bt = ({
440
+ }, Vt = ({
404
441
  model: t,
405
442
  trustedHosts: e,
406
443
  callbacks: n
407
444
  }) => (r) => {
408
- if (!z(e, r))
445
+ if (!Y(e, r))
409
446
  return;
410
447
  const {
411
- data: o
448
+ data: s
412
449
  } = r;
413
- if (o)
414
- switch (o.type) {
450
+ if (s)
451
+ switch (s.type) {
415
452
  case "builder.configureSdk": {
416
- n.configureSdk(o.data);
453
+ n.configureSdk(s.data);
417
454
  break;
418
455
  }
419
456
  case "builder.triggerAnimation": {
420
- n.animation(o.data);
457
+ n.animation(s.data);
421
458
  break;
422
459
  }
423
460
  case "builder.contentUpdate": {
424
- const s = o.data, i = s.key || s.alias || s.entry || s.modelName, u = s.data;
461
+ const o = s.data, i = o.key || o.alias || o.entry || o.modelName, u = o.data;
425
462
  i === t && n.contentUpdate(u);
426
463
  break;
427
464
  }
428
465
  }
429
- }, re = (t, e, n) => {
466
+ }, ae = (t, e, n) => {
430
467
  if (!c)
431
468
  return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
432
469
  };
433
- Ut();
434
- const r = Bt({
470
+ Lt();
471
+ const r = Vt({
435
472
  callbacks: {
436
473
  contentUpdate: e,
437
474
  animation: () => {
@@ -445,45 +482,45 @@ const Ut = (t = {}) => {
445
482
  return window.addEventListener("message", r), () => {
446
483
  window.removeEventListener("message", r);
447
484
  };
448
- }, Rt = "builder.tests", P = (t) => `${Rt}.${t}`, Lt = ({
485
+ }, Nt = "builder.tests", C = (t) => `${Nt}.${t}`, Ft = ({
449
486
  contentId: t
450
- }) => $({
451
- name: P(t),
487
+ }) => M({
488
+ name: C(t),
452
489
  canTrack: !0
453
- }), Vt = ({
490
+ }), Dt = ({
454
491
  contentId: t
455
- }) => W({
456
- name: P(t),
492
+ }) => O({
493
+ name: C(t),
457
494
  canTrack: !0
458
- }), Ft = ({
495
+ }), Mt = ({
459
496
  contentId: t,
460
497
  value: e
461
- }) => _({
462
- name: P(t),
498
+ }) => P({
499
+ name: C(t),
463
500
  value: e,
464
501
  canTrack: !0
465
- }), Q = (t) => y(t.id) && y(t.variations) && Object.keys(t.variations).length > 0, Dt = ({
502
+ }), Z = (t) => y(t.id) && y(t.variations) && Object.keys(t.variations).length > 0, Kt = ({
466
503
  id: t,
467
504
  variations: e
468
505
  }) => {
469
- var o;
506
+ var s;
470
507
  let n = 0;
471
508
  const r = Math.random();
472
- for (const s in e) {
473
- const i = (o = e[s]) == null ? void 0 : o.testRatio;
509
+ for (const o in e) {
510
+ const i = (s = e[o]) == null ? void 0 : s.testRatio;
474
511
  if (n += i, r < n)
475
- return s;
512
+ return o;
476
513
  }
477
514
  return t;
478
- }, Y = (t) => {
479
- const e = Dt(t);
480
- return Ft({
515
+ }, q = (t) => {
516
+ const e = Kt(t);
517
+ return Mt({
481
518
  contentId: t.id,
482
519
  value: e
483
520
  }).catch((n) => {
484
521
  f.error("could not store A/B test variation: ", n);
485
522
  }), e;
486
- }, Z = ({
523
+ }, tt = ({
487
524
  item: t,
488
525
  testGroupId: e
489
526
  }) => {
@@ -497,7 +534,7 @@ const Ut = (t = {}) => {
497
534
  testVariationId: n.id,
498
535
  testVariationName: n.name || (n.id === t.id ? "Default" : "")
499
536
  };
500
- }, oe = ({
537
+ }, ce = ({
501
538
  item: t,
502
539
  canTrack: e
503
540
  }) => {
@@ -505,14 +542,14 @@ const Ut = (t = {}) => {
505
542
  return t;
506
543
  if (!t)
507
544
  return;
508
- if (!Q(t))
545
+ if (!Z(t))
509
546
  return t;
510
- const n = Vt({
547
+ const n = Dt({
511
548
  contentId: t.id
512
- }) || Y({
549
+ }) || q({
513
550
  variations: t.variations,
514
551
  id: t.id
515
- }), r = Z({
552
+ }), r = tt({
516
553
  item: t,
517
554
  testGroupId: n
518
555
  });
@@ -520,186 +557,189 @@ const Ut = (t = {}) => {
520
557
  ...t,
521
558
  ...r
522
559
  };
523
- }, Nt = async ({
560
+ }, jt = async ({
524
561
  item: t,
525
562
  canTrack: e
526
563
  }) => {
527
- if (!e || !Q(t))
564
+ if (!e || !Z(t))
528
565
  return t;
529
- const r = await Lt({
566
+ const r = await Ft({
530
567
  contentId: t.id
531
- }) || Y({
568
+ }) || q({
532
569
  variations: t.variations,
533
570
  id: t.id
534
- }), o = Z({
571
+ }), s = tt({
535
572
  item: t,
536
573
  testGroupId: r
537
574
  });
538
575
  return {
539
576
  ...t,
540
- ...o
577
+ ...s
541
578
  };
542
- }, Mt = (t) => y(t) ? t : !0;
543
- function Kt() {
579
+ }, Wt = (t) => {
580
+ const e = y(t) ? t : !0;
581
+ return K.setCanTrack(e), e;
582
+ };
583
+ function _t() {
544
584
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
545
585
  }
546
- function jt() {
547
- const t = Kt().fetch;
586
+ function $t() {
587
+ const t = _t().fetch;
548
588
  if (typeof t == "undefined")
549
589
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
550
590
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
551
591
  return t;
552
592
  }
553
- const Wt = jt();
554
- function A(t, e = null, n = ".") {
555
- return Object.keys(t).reduce((r, o) => {
556
- const s = t[o], i = [e, o].filter(Boolean).join(n);
557
- return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
593
+ const Gt = $t();
594
+ function E(t, e = null, n = ".") {
595
+ return Object.keys(t).reduce((r, s) => {
596
+ const o = t[s], i = [e, s].filter(Boolean).join(n);
597
+ return [typeof o == "object", o !== null, !(Array.isArray(o) && o.length === 0)].every(Boolean) ? {
558
598
  ...r,
559
- ...A(s, i, n)
599
+ ...E(o, i, n)
560
600
  } : {
561
601
  ...r,
562
- [i]: s
602
+ [i]: o
563
603
  };
564
604
  }, {});
565
605
  }
566
- function q(t, e, n = {}) {
606
+ function et(t, e, n = {}) {
567
607
  for (const r in t) {
568
- const o = t[r], s = e ? e + "." + r : r;
569
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? q(o, s, n) : n[s] = o;
608
+ const s = t[r], o = e ? e + "." + r : r;
609
+ s && typeof s == "object" && !Array.isArray(s) && !Object.keys(s).find((i) => i.startsWith("$")) ? et(s, o, n) : n[o] = s;
570
610
  }
571
611
  return n;
572
612
  }
573
- function $t(t) {
613
+ function Jt(t) {
574
614
  const e = {};
575
615
  for (const n in t) {
576
616
  const r = n.split(".");
577
- let o = e;
578
- for (let s = 0; s < r.length; s++) {
579
- const i = r[s];
580
- s === r.length - 1 ? o[i] = t[n] : (o[i] = o[i] || {}, o = o[i]);
617
+ let s = e;
618
+ for (let o = 0; o < r.length; o++) {
619
+ const i = r[o];
620
+ o === r.length - 1 ? s[i] = t[n] : (s[i] = s[i] || {}, s = s[i]);
581
621
  }
582
622
  }
583
623
  return e;
584
624
  }
585
- const _t = "v3", V = (t) => typeof t == "number" && !isNaN(t) && t >= 0, O = (t) => {
625
+ const zt = "v3", D = (t) => typeof t == "number" && !isNaN(t) && t >= 0, U = (t) => {
586
626
  const {
587
627
  limit: e = 30,
588
628
  userAttributes: n,
589
629
  query: r,
590
- model: o,
591
- apiKey: s,
630
+ model: s,
631
+ apiKey: o,
592
632
  enrich: i,
593
633
  locale: u,
594
- apiVersion: w = _t,
634
+ apiVersion: b = zt,
595
635
  fields: p,
596
636
  omit: k,
597
637
  offset: l,
598
638
  cacheSeconds: h,
599
639
  staleCacheSeconds: g,
600
640
  sort: S,
601
- includeUnpublished: C,
602
- apiHost: tt
641
+ includeUnpublished: T,
642
+ apiHost: nt
603
643
  } = t;
604
- if (!s)
644
+ if (!o)
605
645
  throw new Error("Missing API key");
606
- if (!["v3"].includes(w))
607
- throw new Error(`Invalid apiVersion: expected 'v3', received '${w}'`);
608
- const et = e !== 1, nt = tt || "https://cdn.builder.io", a = new URL(`${nt}/api/${w}/content/${o}`);
609
- a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(e)), a.searchParams.set("noTraverse", String(et)), a.searchParams.set("includeRefs", String(!0));
610
- const E = u || (n == null ? void 0 : n.locale);
646
+ if (!["v3"].includes(b))
647
+ throw new Error(`Invalid apiVersion: expected 'v3', received '${b}'`);
648
+ const rt = e !== 1, st = nt || "https://cdn.builder.io", a = new URL(`${st}/api/${b}/content/${s}`);
649
+ a.searchParams.set("apiKey", o), a.searchParams.set("limit", String(e)), a.searchParams.set("noTraverse", String(rt)), a.searchParams.set("includeRefs", String(!0));
650
+ const A = u || (n == null ? void 0 : n.locale);
611
651
  let m = n || {};
612
- if (E && (a.searchParams.set("locale", E), m = {
613
- locale: E,
652
+ if (A && (a.searchParams.set("locale", A), m = {
653
+ locale: A,
614
654
  ...m
615
- }), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(l) && l > -1 && a.searchParams.set("offset", String(Math.floor(l))), typeof C == "boolean" && a.searchParams.set("includeUnpublished", String(C)), h && V(h) && a.searchParams.set("cacheSeconds", String(h)), g && V(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
616
- const d = A({
655
+ }), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(l) && l > -1 && a.searchParams.set("offset", String(Math.floor(l))), typeof T == "boolean" && a.searchParams.set("includeUnpublished", String(T)), h && D(h) && a.searchParams.set("cacheSeconds", String(h)), g && D(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
656
+ const d = E({
617
657
  sort: S
618
658
  });
619
- for (const b in d)
620
- a.searchParams.set(b, JSON.stringify(d[b]));
659
+ for (const w in d)
660
+ a.searchParams.set(w, JSON.stringify(d[w]));
621
661
  }
622
662
  const x = {
623
- ...ut(),
624
- ...F(t.options || {})
663
+ ...mt(),
664
+ ...j(t.options || {})
625
665
  };
626
666
  m = {
627
667
  ...m,
628
- ...Ht(x)
668
+ ...Xt(x)
629
669
  };
630
- const T = A(x);
631
- for (const d in T)
632
- a.searchParams.set(d, String(T[d]));
670
+ const R = E(x);
671
+ for (const d in R)
672
+ a.searchParams.set(d, String(R[d]));
633
673
  if (Object.keys(m).length > 0 && a.searchParams.set("userAttributes", JSON.stringify(m)), r) {
634
- const d = q({
674
+ const d = et({
635
675
  query: r
636
676
  });
637
- for (const b in d)
638
- a.searchParams.set(b, JSON.stringify(d[b]));
677
+ for (const w in d)
678
+ a.searchParams.set(w, JSON.stringify(d[w]));
639
679
  }
640
680
  return a;
641
- }, Gt = (t) => {
681
+ }, Ht = (t) => {
642
682
  const e = {};
643
683
  for (const n in t)
644
684
  n.startsWith("userAttributes.") && (e[n] = t[n], delete t[n]);
645
685
  return e;
646
- }, Ht = (t) => {
686
+ }, Xt = (t) => {
647
687
  if (c() && t.preview === "BUILDER_STUDIO") {
648
688
  t["userAttributes.urlPath"] = window.location.pathname, t["userAttributes.host"] = window.location.host;
649
- const e = Gt(t), {
689
+ const e = Ht(t), {
650
690
  userAttributes: n
651
- } = $t(e);
691
+ } = Jt(e);
652
692
  return n;
653
693
  }
654
694
  return {};
655
- }, Jt = (t) => "results" in t;
656
- async function Xt(t) {
657
- const e = await Yt({
695
+ }, Qt = (t) => "results" in t;
696
+ async function Yt(t) {
697
+ const e = await te({
658
698
  ...t,
659
699
  limit: 1
660
700
  });
661
701
  return e && e[0] || null;
662
702
  }
663
- const zt = async (t) => {
703
+ const Zt = async (t) => {
664
704
  var i, u;
665
- const e = O(t), n = (i = t.fetch) != null ? i : Wt, r = {
705
+ const e = U(t), n = (i = t.fetch) != null ? i : Gt, r = {
666
706
  ...t.fetchOptions,
667
707
  headers: {
668
708
  ...(u = t.fetchOptions) == null ? void 0 : u.headers,
669
- ...j()
709
+ ...J()
670
710
  }
671
711
  };
672
712
  return await (await n(e.href, r)).json();
673
- }, Qt = async (t, e, n = O(t)) => {
674
- const r = Mt(t.canTrack);
713
+ }, qt = async (t, e, n = U(t)) => {
714
+ const r = Wt(t.canTrack);
675
715
  if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
676
716
  return e.results;
677
717
  try {
678
- const o = [];
679
- for (const s of e.results)
680
- o.push(await Nt({
681
- item: s,
718
+ const s = [];
719
+ for (const o of e.results)
720
+ s.push(await jt({
721
+ item: o,
682
722
  canTrack: r
683
723
  }));
684
- e.results = o;
685
- } catch (o) {
686
- f.error("Could not process A/B tests. ", o);
724
+ e.results = s;
725
+ } catch (s) {
726
+ f.error("Could not process A/B tests. ", s);
687
727
  }
688
728
  return e.results;
689
729
  };
690
- async function Yt(t) {
691
- const e = O(t), n = await zt(t);
692
- if (!Jt(n))
730
+ async function te(t) {
731
+ const e = U(t), n = await Zt(t);
732
+ if (!Qt(n))
693
733
  throw f.error("Error fetching data. ", {
694
734
  url: e,
695
735
  content: n,
696
736
  options: t
697
737
  }), n;
698
- return Qt(t, n);
738
+ return qt(t, n);
699
739
  }
700
- const se = async (t) => {
701
- var r, o, s;
702
- const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((o = t.userAttributes) == null ? void 0 : o.urlPath), n = {
740
+ const ue = async (t) => {
741
+ var r, s, o;
742
+ const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((s = t.userAttributes) == null ? void 0 : s.urlPath), n = {
703
743
  ...t,
704
744
  apiKey: t.apiKey,
705
745
  model: t.model || "page",
@@ -709,38 +749,40 @@ const se = async (t) => {
709
749
  urlPath: e
710
750
  } : {}
711
751
  },
712
- options: M(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
752
+ options: $(t.searchParams || ((o = t.url) == null ? void 0 : o.searchParams) || t.options)
713
753
  };
714
754
  return {
715
755
  apiKey: n.apiKey,
716
756
  model: n.model,
717
- content: await Xt(n)
757
+ content: await Yt(n)
718
758
  };
719
759
  };
720
760
  export {
721
761
  v as TARGET,
722
- Qt as _processContentResult,
723
- xt as _track,
762
+ qt as _processContentResult,
763
+ Rt as _track,
724
764
  y as checkIsDefined,
725
- Bt as createEditorListener,
726
- qt as createRegisterComponentMessage,
727
- se as fetchBuilderProps,
728
- Yt as fetchEntries,
729
- Xt as fetchOneEntry,
730
- M as getBuilderSearchParams,
731
- Mt as getDefaultCanTrack,
732
- Pt as getUserAttributes,
733
- oe as handleABTestingSync,
765
+ Vt as createEditorListener,
766
+ re as createRegisterComponentMessage,
767
+ ue as fetchBuilderProps,
768
+ te as fetchEntries,
769
+ Yt as fetchOneEntry,
770
+ $ as getBuilderSearchParams,
771
+ Wt as getDefaultCanTrack,
772
+ Ut as getUserAttributes,
773
+ ce as handleABTestingSync,
734
774
  c as isBrowser,
735
- st as isEditing,
736
- Zt as isPreviewing,
737
- kt as logFetch,
775
+ ft as isEditing,
776
+ ne as isPreviewing,
777
+ Ot as logFetch,
738
778
  f as logger,
739
- at as register,
740
- ne as registerInsertMenu,
741
- N as serializeIncludingFunctions,
742
- te as setEditorSettings,
743
- Ut as setupBrowserForEditing,
744
- re as subscribeToEditor,
745
- ee as track
779
+ gt as register,
780
+ ie as registerInsertMenu,
781
+ _ as serializeIncludingFunctions,
782
+ ee as setClientUserAttributes,
783
+ se as setEditorSettings,
784
+ Lt as setupBrowserForEditing,
785
+ ae as subscribeToEditor,
786
+ oe as track,
787
+ K as userAttributesService
746
788
  };