@builder.io/sdk-react 3.0.3-0 → 3.0.5

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