@builder.io/sdk-react 0.13.4 → 1.0.2

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.
@@ -1,26 +1,26 @@
1
- const k = "react", v = "[Builder.io]: ", l = {
2
- log: (...e) => console.log(v, ...e),
3
- error: (...e) => console.error(v, ...e),
4
- warn: (...e) => console.warn(v, ...e),
5
- debug: (...e) => console.debug(v, ...e)
1
+ const I = "react", S = "[Builder.io]: ", f = {
2
+ log: (...e) => console.log(S, ...e),
3
+ error: (...e) => console.error(S, ...e),
4
+ warn: (...e) => console.warn(S, ...e),
5
+ debug: (...e) => console.debug(S, ...e)
6
6
  };
7
- function i() {
7
+ function c() {
8
8
  return typeof window != "undefined" && typeof document != "undefined";
9
9
  }
10
- function Z() {
11
- return i() && window.self !== window.top;
10
+ function X() {
11
+ return c() && window.self !== window.top;
12
12
  }
13
- function U() {
14
- return Z() && window.location.search.indexOf("builder.frameEditing=") !== -1;
13
+ function V() {
14
+ return X() && window.location.search.indexOf("builder.frameEditing=") !== -1;
15
15
  }
16
- const ee = () => {
17
- if (i()) {
16
+ const Y = () => {
17
+ if (c()) {
18
18
  const e = new URL(location.href);
19
19
  return e.pathname === "" && (e.pathname = "/"), e;
20
20
  } else
21
21
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
22
- }, te = () => typeof navigator == "object" && navigator.userAgent || "", ne = () => {
23
- const e = te(), t = {
22
+ }, Q = () => typeof navigator == "object" && navigator.userAgent || "", Z = () => {
23
+ const e = Q(), t = {
24
24
  Android() {
25
25
  return e.match(/Android/i);
26
26
  },
@@ -37,20 +37,20 @@ const ee = () => {
37
37
  return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
38
38
  },
39
39
  any() {
40
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || k === "reactNative";
40
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || I === "reactNative";
41
41
  }
42
- }, n = e.match(/Tablet|iPad/i), r = ee();
42
+ }, n = e.match(/Tablet|iPad/i), r = Y();
43
43
  return {
44
44
  urlPath: r == null ? void 0 : r.pathname,
45
45
  host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
46
46
  device: n ? "tablet" : t.any() ? "mobile" : "desktop"
47
47
  };
48
- }, m = (e) => e != null, M = (e) => JSON.parse(JSON.stringify(e)), re = (e) => {
48
+ }, m = (e) => e != null, L = (e) => JSON.parse(JSON.stringify(e)), ee = (e) => {
49
49
  if (e === "localhost" || e === "127.0.0.1")
50
50
  return e;
51
51
  const t = e.split(".");
52
52
  return t.length > 2 ? t.slice(1).join(".") : e;
53
- }, N = ({
53
+ }, U = ({
54
54
  name: e,
55
55
  canTrack: t
56
56
  }) => {
@@ -58,17 +58,17 @@ const ee = () => {
58
58
  try {
59
59
  return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
60
60
  } catch (r) {
61
- l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
61
+ f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
62
62
  return;
63
63
  }
64
- }, F = async (e) => N(e), oe = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), se = [["secure", ""], ["SameSite", "None"]], ae = ({
64
+ }, M = async (e) => U(e), te = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ne = [["secure", ""], ["SameSite", "None"]], re = ({
65
65
  name: e,
66
66
  value: t,
67
67
  expires: n
68
68
  }) => {
69
- const o = (i() ? location.protocol === "https:" : !0) ? se : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", re(window.location.hostname)], ...o];
70
- return oe(a);
71
- }, $ = async ({
69
+ const o = (c() ? location.protocol === "https:" : !0) ? ne : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", ee(window.location.hostname)], ...o];
70
+ return te(i);
71
+ }, N = async ({
72
72
  name: e,
73
73
  value: t,
74
74
  expires: n,
@@ -77,33 +77,33 @@ const ee = () => {
77
77
  try {
78
78
  if (!r)
79
79
  return;
80
- const o = ae({
80
+ const o = re({
81
81
  name: e,
82
82
  value: t,
83
83
  expires: n
84
84
  });
85
85
  document.cookie = o;
86
86
  } catch (o) {
87
- l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
87
+ f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
88
88
  }
89
- }, ie = "builder.tests", C = (e) => `${ie}.${e}`, ce = ({
89
+ }, oe = "builder.tests", E = (e) => `${oe}.${e}`, se = ({
90
90
  contentId: e
91
- }) => F({
92
- name: C(e),
91
+ }) => M({
92
+ name: E(e),
93
93
  canTrack: !0
94
- }), ue = ({
94
+ }), ae = ({
95
95
  contentId: e
96
- }) => N({
97
- name: C(e),
96
+ }) => U({
97
+ name: E(e),
98
98
  canTrack: !0
99
- }), de = ({
99
+ }), ie = ({
100
100
  contentId: e,
101
101
  value: t
102
- }) => $({
103
- name: C(e),
102
+ }) => N({
103
+ name: E(e),
104
104
  value: t,
105
105
  canTrack: !0
106
- }), j = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, le = ({
106
+ }), F = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, ce = ({
107
107
  id: e,
108
108
  variations: t
109
109
  }) => {
@@ -111,20 +111,20 @@ const ee = () => {
111
111
  let n = 0;
112
112
  const r = Math.random();
113
113
  for (const s in t) {
114
- const a = (o = t[s]) == null ? void 0 : o.testRatio;
115
- if (n += a, r < n)
114
+ const i = (o = t[s]) == null ? void 0 : o.testRatio;
115
+ if (n += i, r < n)
116
116
  return s;
117
117
  }
118
118
  return e;
119
- }, D = (e) => {
120
- const t = le(e);
121
- return de({
119
+ }, j = (e) => {
120
+ const t = ce(e);
121
+ return ie({
122
122
  contentId: e.id,
123
123
  value: t
124
124
  }).catch((n) => {
125
- l.error("could not store A/B test variation: ", n);
125
+ f.error("could not store A/B test variation: ", n);
126
126
  }), t;
127
- }, K = ({
127
+ }, D = ({
128
128
  item: e,
129
129
  testGroupId: t
130
130
  }) => {
@@ -146,14 +146,14 @@ const ee = () => {
146
146
  return e;
147
147
  if (!e)
148
148
  return;
149
- if (!j(e))
149
+ if (!F(e))
150
150
  return e;
151
- const n = ue({
151
+ const n = ae({
152
152
  contentId: e.id
153
- }) || D({
153
+ }) || j({
154
154
  variations: e.variations,
155
155
  id: e.id
156
- }), r = K({
156
+ }), r = D({
157
157
  item: e,
158
158
  testGroupId: n
159
159
  });
@@ -161,18 +161,18 @@ const ee = () => {
161
161
  ...e,
162
162
  ...r
163
163
  };
164
- }, fe = async ({
164
+ }, ue = async ({
165
165
  item: e,
166
166
  canTrack: t
167
167
  }) => {
168
- if (!t || !j(e))
168
+ if (!t || !F(e))
169
169
  return e;
170
- const r = await ce({
170
+ const r = await se({
171
171
  contentId: e.id
172
- }) || D({
172
+ }) || j({
173
173
  variations: e.variations,
174
174
  id: e.id
175
- }), o = K({
175
+ }), o = D({
176
176
  item: e,
177
177
  testGroupId: r
178
178
  });
@@ -180,240 +180,234 @@ const ee = () => {
180
180
  ...e,
181
181
  ...o
182
182
  };
183
- }, ge = (e) => m(e) ? e : !0, Ge = [], Je = (e) => ({
183
+ }, de = (e) => m(e) ? e : !0, $e = (e) => ({
184
184
  type: "builder.registerComponent",
185
- data: me(e)
186
- }), he = (e) => {
185
+ data: he(e)
186
+ }), le = (e) => {
187
187
  const t = e.toString().trim();
188
188
  return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
189
- }, pe = (e) => typeof e == "function" ? he(e) : M(e), me = ({
189
+ }, fe = (e) => typeof e == "function" ? le(e) : L(e), he = ({
190
190
  inputs: e,
191
191
  ...t
192
192
  }) => ({
193
- ...M(t),
193
+ ...L(t),
194
194
  inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
195
195
  ...r,
196
- [o]: pe(s)
196
+ [o]: fe(s)
197
197
  }), {}))
198
198
  });
199
- function ye() {
199
+ function ge() {
200
200
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
201
201
  }
202
- function we() {
203
- const e = ye().fetch;
202
+ function pe() {
203
+ const e = ge().fetch;
204
204
  if (typeof e == "undefined")
205
205
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
206
206
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
207
207
  return e;
208
208
  }
209
- const be = we();
210
- function I(e, t = null, n = ".") {
209
+ const me = pe();
210
+ function v(e, t = null, n = ".") {
211
211
  return Object.keys(e).reduce((r, o) => {
212
- const s = e[o], a = [t, o].filter(Boolean).join(n);
212
+ const s = e[o], i = [t, o].filter(Boolean).join(n);
213
213
  return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
214
214
  ...r,
215
- ...I(s, a, n)
215
+ ...v(s, i, n)
216
216
  } : {
217
217
  ...r,
218
- [a]: s
218
+ [i]: s
219
219
  };
220
220
  }, {});
221
221
  }
222
- const Se = "v3", T = "builder.", ve = "options.", Ie = (e) => {
222
+ const ye = "v3", x = "builder.", we = "options.", be = (e) => {
223
223
  const t = {};
224
224
  return e.forEach((n, r) => {
225
225
  t[r] = n;
226
226
  }), t;
227
- }, _ = (e) => {
227
+ }, K = (e) => {
228
228
  if (!e)
229
229
  return {};
230
- const t = W(e), n = {};
230
+ const t = _(e), n = {};
231
231
  return Object.keys(t).forEach((r) => {
232
- if (r.startsWith(T)) {
233
- const o = r.replace(T, "").replace(ve, "");
232
+ if (r.startsWith(x)) {
233
+ const o = r.replace(x, "").replace(we, "");
234
234
  n[o] = t[r];
235
235
  }
236
236
  }), n;
237
- }, ke = () => {
238
- if (!i())
237
+ }, Se = () => {
238
+ if (!c())
239
239
  return {};
240
240
  const e = new URLSearchParams(window.location.search);
241
- return _(e);
242
- }, W = (e) => e instanceof URLSearchParams ? Ie(e) : e, R = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
243
- let {
244
- noTraverse: t = !1
245
- } = e;
241
+ return K(e);
242
+ }, _ = (e) => e instanceof URLSearchParams ? be(e) : e, T = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
246
243
  const {
247
- limit: n = 30,
248
- userAttributes: r,
249
- query: o,
250
- model: s,
251
- apiKey: a,
252
- includeRefs: f = !0,
253
- enrich: S,
254
- locale: h,
255
- apiVersion: y = Se,
256
- fields: u,
257
- omit: w,
258
- offset: g,
259
- cacheSeconds: p,
260
- staleCacheSeconds: E,
261
- sort: x,
262
- includeUnpublished: A
244
+ limit: t = 30,
245
+ userAttributes: n,
246
+ query: r,
247
+ model: o,
248
+ apiKey: s,
249
+ enrich: i,
250
+ locale: d,
251
+ apiVersion: y = ye,
252
+ fields: p,
253
+ omit: k,
254
+ offset: u,
255
+ cacheSeconds: h,
256
+ staleCacheSeconds: g,
257
+ sort: w,
258
+ includeUnpublished: O
263
259
  } = e;
264
- if (!a)
260
+ if (!s)
265
261
  throw new Error("Missing API key");
266
262
  if (!["v3"].includes(y))
267
263
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
268
- (e.limit === void 0 || e.limit > 1) && !("noTraverse" in e) && (t = !0);
269
- const c = new URL(`https://cdn.builder.io/api/${y}/content/${s}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${f}${h ? `&locale=${h}` : ""}${S ? `&enrich=${S}` : ""}`);
270
- if (c.searchParams.set("omit", w || "meta.componentsUsed"), u && c.searchParams.set("fields", u), Number.isFinite(g) && g > -1 && c.searchParams.set("offset", String(Math.floor(g))), typeof A == "boolean" && c.searchParams.set("includeUnpublished", String(A)), p && R(p) && c.searchParams.set("cacheSeconds", String(p)), E && R(E) && c.searchParams.set("staleCacheSeconds", String(E)), x) {
271
- const d = I({
272
- sort: x
264
+ const q = t !== 1, a = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
265
+ if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(q)), a.searchParams.set("includeRefs", String(!0)), d && a.searchParams.set("locale", d), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && a.searchParams.set("offset", String(Math.floor(u))), typeof O == "boolean" && a.searchParams.set("includeUnpublished", String(O)), h && T(h) && a.searchParams.set("cacheSeconds", String(h)), g && T(g) && a.searchParams.set("staleCacheSeconds", String(g)), w) {
266
+ const l = v({
267
+ sort: w
273
268
  });
274
- for (const b in d)
275
- c.searchParams.set(b, JSON.stringify(d[b]));
269
+ for (const b in l)
270
+ a.searchParams.set(b, JSON.stringify(l[b]));
276
271
  }
277
- const Q = {
278
- ...ke(),
279
- ...W(e.options || {})
280
- }, P = I(Q);
281
- for (const d in P)
282
- c.searchParams.set(d, String(P[d]));
283
- if (r && c.searchParams.set("userAttributes", JSON.stringify(r)), o) {
284
- const d = I({
285
- query: o
272
+ const z = {
273
+ ...Se(),
274
+ ..._(e.options || {})
275
+ }, P = v(z);
276
+ for (const l in P)
277
+ a.searchParams.set(l, String(P[l]));
278
+ if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
279
+ const l = v({
280
+ query: r
286
281
  });
287
- for (const b in d)
288
- c.searchParams.set(b, JSON.stringify(d[b]));
282
+ for (const b in l)
283
+ a.searchParams.set(b, JSON.stringify(l[b]));
289
284
  }
290
- return c;
291
- }, Ee = (e) => "results" in e;
292
- async function G(e) {
293
- const t = await J({
285
+ return a;
286
+ }, ve = (e) => "results" in e;
287
+ async function Ie(e) {
288
+ const t = await Ce({
294
289
  ...e,
295
290
  limit: 1
296
291
  });
297
292
  return t && t[0] || null;
298
293
  }
299
- const ze = G, Ce = async (e) => {
300
- const t = O(e);
301
- return await (await be(t.href)).json();
302
- }, Oe = async (e, t, n = O(e)) => {
303
- const r = ge(e.canTrack);
304
- if (n.search.includes("preview="), !r || !(i() || k === "reactNative"))
294
+ const ke = async (e) => {
295
+ const t = C(e);
296
+ return await (await me(t.href)).json();
297
+ }, Ee = async (e, t, n = C(e)) => {
298
+ const r = de(e.canTrack);
299
+ if (n.search.includes("preview="), !r || !(c() || I === "reactNative"))
305
300
  return t.results;
306
301
  try {
307
302
  const o = [];
308
303
  for (const s of t.results)
309
- o.push(await fe({
304
+ o.push(await ue({
310
305
  item: s,
311
306
  canTrack: r
312
307
  }));
313
308
  t.results = o;
314
309
  } catch (o) {
315
- l.error("Could not process A/B tests. ", o);
310
+ f.error("Could not process A/B tests. ", o);
316
311
  }
317
312
  return t.results;
318
313
  };
319
- async function J(e) {
314
+ async function Ce(e) {
320
315
  try {
321
- const t = O(e), n = await Ce(e);
322
- return Ee(n) ? Oe(e, n) : (l.error("Error fetching data. ", {
316
+ const t = C(e), n = await ke(e);
317
+ return ve(n) ? Ee(e, n) : (f.error("Error fetching data. ", {
323
318
  url: t,
324
319
  content: n,
325
320
  options: e
326
321
  }), null);
327
322
  } catch (t) {
328
- return l.error("Error fetching data. ", t), null;
323
+ return f.error("Error fetching data. ", t), null;
329
324
  }
330
325
  }
331
- const He = J;
332
- function qe() {
333
- return !i() || U() ? !1 : location.search.indexOf("builder.preview=") !== -1;
326
+ function Ge() {
327
+ return !c() || V() ? !1 : location.search.indexOf("builder.preview=") !== -1;
334
328
  }
335
- function xe() {
329
+ function Oe() {
336
330
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
337
331
  const t = Math.random() * 16 | 0;
338
332
  return (e == "x" ? t : t & 3 | 8).toString(16);
339
333
  });
340
334
  }
341
- function z() {
342
- return xe().replace(/-/g, "");
335
+ function W() {
336
+ return Oe().replace(/-/g, "");
343
337
  }
344
- const H = "builderSessionId", Ae = async ({
338
+ const $ = "builderSessionId", Pe = async ({
345
339
  canTrack: e
346
340
  }) => {
347
341
  if (!e)
348
342
  return;
349
- const t = await F({
350
- name: H,
343
+ const t = await M({
344
+ name: $,
351
345
  canTrack: e
352
346
  });
353
347
  if (m(t))
354
348
  return t;
355
349
  {
356
- const n = Pe();
350
+ const n = xe();
357
351
  return Te({
358
352
  id: n,
359
353
  canTrack: e
360
354
  }), n;
361
355
  }
362
- }, Pe = () => z(), Te = ({
356
+ }, xe = () => W(), Te = ({
363
357
  id: e,
364
358
  canTrack: t
365
- }) => $({
366
- name: H,
359
+ }) => N({
360
+ name: $,
367
361
  value: e,
368
362
  canTrack: t
369
- }), q = () => i() && typeof localStorage != "undefined" ? localStorage : void 0, Re = ({
363
+ }), G = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Ae = ({
370
364
  key: e,
371
365
  canTrack: t
372
366
  }) => {
373
367
  var n;
374
368
  try {
375
- return t ? (n = q()) == null ? void 0 : n.getItem(e) : void 0;
369
+ return t ? (n = G()) == null ? void 0 : n.getItem(e) : void 0;
376
370
  } catch (r) {
377
371
  console.debug("[LocalStorage] GET error: ", r);
378
372
  return;
379
373
  }
380
- }, Be = ({
374
+ }, Re = ({
381
375
  key: e,
382
376
  canTrack: t,
383
377
  value: n
384
378
  }) => {
385
379
  var r;
386
380
  try {
387
- t && ((r = q()) == null || r.setItem(e, n));
381
+ t && ((r = G()) == null || r.setItem(e, n));
388
382
  } catch (o) {
389
383
  console.debug("[LocalStorage] SET error: ", o);
390
384
  }
391
- }, X = "builderVisitorId", Ve = ({
385
+ }, J = "builderVisitorId", Be = ({
392
386
  canTrack: e
393
387
  }) => {
394
388
  if (!e)
395
389
  return;
396
- const t = Re({
397
- key: X,
390
+ const t = Ae({
391
+ key: J,
398
392
  canTrack: e
399
393
  });
400
394
  if (m(t))
401
395
  return t;
402
396
  {
403
- const n = Le();
404
- return Ue({
397
+ const n = Ve();
398
+ return Le({
405
399
  id: n,
406
400
  canTrack: e
407
401
  }), n;
408
402
  }
409
- }, Le = () => z(), Ue = ({
403
+ }, Ve = () => W(), Le = ({
410
404
  id: e,
411
405
  canTrack: t
412
- }) => Be({
413
- key: X,
406
+ }) => Re({
407
+ key: J,
414
408
  value: e,
415
409
  canTrack: t
416
- }), Me = async ({
410
+ }), Ue = async ({
417
411
  canTrack: e
418
412
  }) => {
419
413
  if (!e)
@@ -421,16 +415,16 @@ const H = "builderSessionId", Ae = async ({
421
415
  visitorId: void 0,
422
416
  sessionId: void 0
423
417
  };
424
- const t = await Ae({
418
+ const t = await Pe({
425
419
  canTrack: e
426
- }), n = Ve({
420
+ }), n = Be({
427
421
  canTrack: e
428
422
  });
429
423
  return {
430
424
  sessionId: t,
431
425
  visitorId: n
432
426
  };
433
- }, Ne = async ({
427
+ }, Me = async ({
434
428
  type: e,
435
429
  canTrack: t,
436
430
  apiKey: n,
@@ -444,23 +438,23 @@ const H = "builderSessionId", Ae = async ({
444
438
  url: location.href,
445
439
  ...r
446
440
  },
447
- ...await Me({
441
+ ...await Ue({
448
442
  canTrack: t
449
443
  }),
450
- userAttributes: ne(),
444
+ userAttributes: Z(),
451
445
  ownerId: n
452
446
  }
453
447
  });
454
- async function Fe(e) {
448
+ async function Ne(e) {
455
449
  if (!e.apiKey) {
456
- l.error("Missing API key for track call. Please provide your API key.");
450
+ f.error("Missing API key for track call. Please provide your API key.");
457
451
  return;
458
452
  }
459
- if (e.canTrack && !U() && (i() || k === "reactNative"))
453
+ if (e.canTrack && !V() && (c() || I === "reactNative"))
460
454
  return fetch("https://cdn.builder.io/api/v1/track", {
461
455
  method: "POST",
462
456
  body: JSON.stringify({
463
- events: [await Ne(e)]
457
+ events: [await Me(e)]
464
458
  }),
465
459
  headers: {
466
460
  "content-type": "application/json"
@@ -470,18 +464,18 @@ async function Fe(e) {
470
464
  console.error("Failed to track: ", t);
471
465
  });
472
466
  }
473
- const Xe = (e) => Fe({
467
+ const Je = (e) => Ne({
474
468
  ...e,
475
469
  canTrack: !0
476
- }), $e = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
477
- function Y(e, t) {
470
+ }), Fe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
471
+ function H(e, t) {
478
472
  const n = new URL(t.origin), r = n.hostname;
479
- return (e || $e).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
473
+ return (e || Fe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
480
474
  }
481
- const je = "0.13.4", B = {};
475
+ const je = "1.0.2", A = {};
482
476
  function De(e, t) {
483
- let n = B[e];
484
- if (n || (n = B[e] = []), n.push(t), i()) {
477
+ let n = A[e];
478
+ if (n || (n = A[e] = []), n.push(t), c()) {
485
479
  const r = {
486
480
  type: "builder.register",
487
481
  data: {
@@ -496,7 +490,7 @@ function De(e, t) {
496
490
  }
497
491
  }
498
492
  }
499
- const Ye = () => {
493
+ const He = () => {
500
494
  De("insertMenu", {
501
495
  name: "_default",
502
496
  default: !0,
@@ -519,13 +513,13 @@ const Ye = () => {
519
513
  }]
520
514
  });
521
515
  };
522
- let V = !1;
516
+ let R = !1;
523
517
  const Ke = (e = {}) => {
524
518
  var t, n;
525
- V || (V = !0, i() && ((t = window.parent) == null || t.postMessage({
519
+ R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
526
520
  type: "builder.sdkInfo",
527
521
  data: {
528
- target: k,
522
+ target: I,
529
523
  version: je,
530
524
  supportsPatchUpdates: !1,
531
525
  // Supports builder-model="..." attribute which is needed to
@@ -539,8 +533,8 @@ const Ke = (e = {}) => {
539
533
  options: e
540
534
  }
541
535
  }, "*"), window.addEventListener("message", (r) => {
542
- var s, a;
543
- if (!Y(e.trustedHosts, r))
536
+ var s, i;
537
+ if (!H(e.trustedHosts, r))
544
538
  return;
545
539
  const {
546
540
  data: o
@@ -548,33 +542,33 @@ const Ke = (e = {}) => {
548
542
  if (o != null && o.type)
549
543
  switch (o.type) {
550
544
  case "builder.evaluate": {
551
- const f = o.data.text, S = o.data.arguments || [], h = o.data.id, y = new Function(f);
552
- let u, w = null;
545
+ const d = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(d);
546
+ let u, h = null;
553
547
  try {
554
- u = y.apply(null, S);
548
+ u = k.apply(null, y);
555
549
  } catch (g) {
556
- w = g;
550
+ h = g;
557
551
  }
558
- w ? (s = window.parent) == null || s.postMessage({
552
+ h ? (s = window.parent) == null || s.postMessage({
559
553
  type: "builder.evaluateError",
560
554
  data: {
561
- id: h,
562
- error: w.message
555
+ id: p,
556
+ error: h.message
563
557
  }
564
558
  }, "*") : u && typeof u.then == "function" ? u.then((g) => {
565
- var p;
566
- (p = window.parent) == null || p.postMessage({
559
+ var w;
560
+ (w = window.parent) == null || w.postMessage({
567
561
  type: "builder.evaluateResult",
568
562
  data: {
569
- id: h,
563
+ id: p,
570
564
  result: g
571
565
  }
572
566
  }, "*");
573
- }).catch(console.error) : (a = window.parent) == null || a.postMessage({
567
+ }).catch(console.error) : (i = window.parent) == null || i.postMessage({
574
568
  type: "builder.evaluateResult",
575
569
  data: {
576
570
  result: u,
577
- id: h
571
+ id: p
578
572
  }
579
573
  }, "*");
580
574
  break;
@@ -586,7 +580,7 @@ const Ke = (e = {}) => {
586
580
  trustedHosts: t,
587
581
  callbacks: n
588
582
  }) => (r) => {
589
- if (!Y(t, r))
583
+ if (!H(t, r))
590
584
  return;
591
585
  const {
592
586
  data: o
@@ -602,14 +596,14 @@ const Ke = (e = {}) => {
602
596
  break;
603
597
  }
604
598
  case "builder.contentUpdate": {
605
- const s = o.data, a = s.key || s.alias || s.entry || s.modelName, f = s.data;
606
- a === e && n.contentUpdate(f);
599
+ const s = o.data, i = s.key || s.alias || s.entry || s.modelName, d = s.data;
600
+ i === e && n.contentUpdate(d);
607
601
  break;
608
602
  }
609
603
  }
610
- }, Qe = (e, t, n) => {
611
- if (!i)
612
- return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
604
+ }, qe = (e, t, n) => {
605
+ if (!c)
606
+ return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
613
607
  };
614
608
  Ke();
615
609
  const r = _e({
@@ -626,18 +620,18 @@ const Ke = (e = {}) => {
626
620
  return window.addEventListener("message", r), () => {
627
621
  window.removeEventListener("message", r);
628
622
  };
629
- }, L = {};
630
- function Ze(e) {
631
- if (i()) {
632
- Object.assign(L, e);
623
+ }, B = {};
624
+ function ze(e) {
625
+ if (c()) {
626
+ Object.assign(B, e);
633
627
  const t = {
634
628
  type: "builder.settingsChange",
635
- data: L
629
+ data: B
636
630
  };
637
631
  parent.postMessage(t, "*");
638
632
  }
639
633
  }
640
- const et = async (e) => {
634
+ const Xe = async (e) => {
641
635
  var r, o, s;
642
636
  const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
643
637
  ...e,
@@ -649,42 +643,39 @@ const et = async (e) => {
649
643
  urlPath: t
650
644
  } : {}
651
645
  },
652
- options: _(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
646
+ options: K(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
653
647
  };
654
648
  return {
655
649
  apiKey: n.apiKey,
656
650
  model: n.model,
657
- content: await G(n)
651
+ content: await Ie(n)
658
652
  };
659
653
  };
660
654
  export {
661
- We as A,
662
- k as T,
663
- Oe as _,
664
- qe as a,
665
- Qe as b,
666
- Je as c,
667
- J as d,
668
- G as e,
669
- et as f,
670
- _ as g,
671
- He as h,
672
- U as i,
673
- ze as j,
674
- i as k,
675
- ne as l,
676
- m,
677
- l as n,
678
- M as o,
679
- ge as p,
680
- Fe as q,
655
+ I as T,
656
+ Ee as _,
657
+ Ge as a,
658
+ qe as b,
659
+ $e as c,
660
+ Ce as d,
661
+ Ie as e,
662
+ Xe as f,
663
+ K as g,
664
+ c as h,
665
+ V as i,
666
+ Z as j,
667
+ m as k,
668
+ f as l,
669
+ L as m,
670
+ de as n,
671
+ Ne as o,
672
+ _e as p,
673
+ He as q,
681
674
  De as r,
682
- Ze as s,
683
- Xe as t,
684
- _e as u,
685
- Ye as v,
686
- Ke as w,
687
- be as x,
688
- Ge as y,
689
- me as z
675
+ ze as s,
676
+ Je as t,
677
+ Ke as u,
678
+ me as v,
679
+ he as w,
680
+ We as x
690
681
  };