@storyblok/astro 5.0.2 → 5.1.0-alpha.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,18 +1,18 @@
1
- function Or(o, r, t) {
2
- const s = "virtual:storyblok-init", i = "\0" + s;
1
+ function B(o, e, t) {
2
+ const s = "virtual:storyblok-init", r = "\0" + s;
3
3
  return {
4
4
  name: "vite-plugin-storyblok-init",
5
- async resolveId(l) {
6
- if (l === s)
7
- return i;
5
+ async resolveId(n) {
6
+ if (n === s)
7
+ return r;
8
8
  },
9
- async load(l) {
10
- if (l === i)
9
+ async load(n) {
10
+ if (n === r)
11
11
  return `
12
12
  import { storyblokInit, apiPlugin } from "@storyblok/js";
13
13
  const { storyblokApi } = storyblokInit({
14
14
  accessToken: "${o}",
15
- use: ${r ? "[]" : "[apiPlugin]"},
15
+ use: ${e ? "[]" : "[apiPlugin]"},
16
16
  apiOptions: ${JSON.stringify(t)},
17
17
  });
18
18
  export const storyblokApiInstance = storyblokApi;
@@ -20,71 +20,71 @@ function Or(o, r, t) {
20
20
  }
21
21
  };
22
22
  }
23
- const Cr = /[\p{Lu}]/u, jr = /[\p{Ll}]/u, Ne = /^[\p{Lu}](?![\p{Lu}])/gu, Ge = /([\p{Alpha}\p{N}_]|$)/u, fe = /[_.\- ]+/, xr = new RegExp("^" + fe.source), ze = new RegExp(fe.source + Ge.source, "gu"), Le = new RegExp("\\d+" + Ge.source, "gu"), $r = (o, r, t, s) => {
24
- let i = !1, l = !1, u = !1, f = !1;
25
- for (let p = 0; p < o.length; p++) {
26
- const y = o[p];
27
- f = p > 2 ? o[p - 3] === "-" : !0, i && Cr.test(y) ? (o = o.slice(0, p) + "-" + o.slice(p), i = !1, u = l, l = !0, p++) : l && u && jr.test(y) && (!f || s) ? (o = o.slice(0, p - 1) + "-" + o.slice(p - 1), u = l, l = !1, i = !0) : (i = r(y) === y && t(y) !== y, u = l, l = t(y) === y && r(y) !== y);
23
+ const H = /[\p{Lu}]/u, z = /[\p{Ll}]/u, R = /^[\p{Lu}](?![\p{Lu}])/gu, N = /([\p{Alpha}\p{N}_]|$)/u, C = /[_.\- ]+/, D = new RegExp("^" + C.source), _ = new RegExp(C.source + N.source, "gu"), A = new RegExp("\\d+" + N.source, "gu"), F = (o, e, t, s) => {
24
+ let r = !1, n = !1, i = !1, l = !1;
25
+ for (let a = 0; a < o.length; a++) {
26
+ const c = o[a];
27
+ l = a > 2 ? o[a - 3] === "-" : !0, r && H.test(c) ? (o = o.slice(0, a) + "-" + o.slice(a), r = !1, i = n, n = !0, a++) : n && i && z.test(c) && (!l || s) ? (o = o.slice(0, a - 1) + "-" + o.slice(a - 1), i = n, n = !1, r = !0) : (r = e(c) === c && t(c) !== c, i = n, n = t(c) === c && e(c) !== c);
28
28
  }
29
29
  return o;
30
- }, Er = (o, r) => (Ne.lastIndex = 0, o.replaceAll(Ne, (t) => r(t))), Rr = (o, r) => (ze.lastIndex = 0, Le.lastIndex = 0, o.replaceAll(Le, (t, s, i) => ["_", "-"].includes(o.charAt(i + t.length)) ? t : r(t)).replaceAll(ze, (t, s) => r(s)));
31
- function De(o, r) {
30
+ }, J = (o, e) => (R.lastIndex = 0, o.replaceAll(R, (t) => e(t))), q = (o, e) => (_.lastIndex = 0, A.lastIndex = 0, o.replaceAll(A, (t, s, r) => ["_", "-"].includes(o.charAt(r + t.length)) ? t : e(t)).replaceAll(_, (t, s) => e(s)));
31
+ function I(o, e) {
32
32
  if (!(typeof o == "string" || Array.isArray(o)))
33
33
  throw new TypeError("Expected the input to be `string | string[]`");
34
- if (r = {
34
+ if (e = {
35
35
  pascalCase: !1,
36
36
  preserveConsecutiveUppercase: !1,
37
- ...r
38
- }, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
37
+ ...e
38
+ }, Array.isArray(o) ? o = o.map((n) => n.trim()).filter((n) => n.length).join("-") : o = o.trim(), o.length === 0)
39
39
  return "";
40
- const t = r.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(r.locale), s = r.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(r.locale);
41
- return o.length === 1 ? fe.test(o) ? "" : r.pascalCase ? s(o) : t(o) : (o !== t(o) && (o = $r(o, t, s, r.preserveConsecutiveUppercase)), o = o.replace(xr, ""), o = r.preserveConsecutiveUppercase ? Er(o, t) : t(o), r.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), Rr(o, s));
40
+ const t = e.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(e.locale), s = e.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(e.locale);
41
+ return o.length === 1 ? C.test(o) ? "" : e.pascalCase ? s(o) : t(o) : (o !== t(o) && (o = F(o, t, s, e.preserveConsecutiveUppercase)), o = o.replace(D, ""), o = e.preserveConsecutiveUppercase ? J(o, t) : t(o), e.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), q(o, s));
42
42
  }
43
- function Pr(o, r, t, s) {
44
- const i = "virtual:storyblok-components", l = "\0" + i;
43
+ function V(o, e, t, s) {
44
+ const r = "virtual:storyblok-components", n = "\0" + r;
45
45
  return {
46
46
  name: "vite-plugin-storyblok-components",
47
- async resolveId(u) {
48
- if (u === i)
49
- return l;
47
+ async resolveId(i) {
48
+ if (i === r)
49
+ return n;
50
50
  },
51
- async load(u) {
52
- if (u === l) {
53
- const f = [], p = [];
54
- for await (const [_, k] of Object.entries(r)) {
55
- const A = await this.resolve(
56
- "/" + o + "/" + k + ".astro"
51
+ async load(i) {
52
+ if (i === n) {
53
+ const l = [], a = [];
54
+ for await (const [h, u] of Object.entries(e)) {
55
+ const p = await this.resolve(
56
+ "/" + o + "/" + u + ".astro"
57
57
  );
58
- if (A)
59
- f.push(`import ${De(_)} from "${A.id}"`);
58
+ if (p)
59
+ l.push(`import ${I(h)} from "${p.id}"`);
60
60
  else if (t)
61
- p.push(_);
61
+ a.push(h);
62
62
  else
63
63
  throw new Error(
64
- `Component could not be found for blok "${_}"! Does "${"/" + o + "/" + k}.astro" exist?`
64
+ `Component could not be found for blok "${h}"! Does "${"/" + o + "/" + u}.astro" exist?`
65
65
  );
66
66
  }
67
- let y = "";
67
+ let c = "";
68
68
  if (t)
69
- if (y = ",FallbackComponent", s) {
70
- const _ = await this.resolve(
69
+ if (c = ",FallbackComponent", s) {
70
+ const h = await this.resolve(
71
71
  "/" + o + "/" + s + ".astro"
72
72
  );
73
- if (!_)
73
+ if (!h)
74
74
  throw new Error(
75
75
  `Custom fallback component could not be found. Does "${"/" + o + "/" + s}.astro" exist?`
76
76
  );
77
- f.push(
78
- `import FallbackComponent from "${_.id}"`
77
+ l.push(
78
+ `import FallbackComponent from "${h.id}"`
79
79
  );
80
80
  } else
81
- f.push(
81
+ l.push(
82
82
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
83
83
  );
84
- if (Object.values(r).length)
85
- return `${f.join(";")};export default {${Object.keys(r).filter((_) => !p.includes(_)).map((_) => De(_)).join(",")}${y}}`;
84
+ if (Object.values(e).length)
85
+ return `${l.join(";")};export default {${Object.keys(e).filter((h) => !a.includes(h)).map((h) => I(h)).join(",")}${c}}`;
86
86
  if (t)
87
- return `${f[0]}; export default {${y.replace(",", "")}}`;
87
+ return `${l[0]}; export default {${c.replace(",", "")}}`;
88
88
  throw new Error(
89
89
  `Currently, no Storyblok components are registered in astro.config.mjs.
90
90
  Please register your components or enable the fallback component.
@@ -94,12 +94,12 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
94
94
  }
95
95
  };
96
96
  }
97
- function Mr(o) {
98
- const r = "virtual:storyblok-options", t = "\0" + r;
97
+ function K(o) {
98
+ const e = "virtual:storyblok-options", t = "\0" + e;
99
99
  return {
100
100
  name: "vite-plugin-storyblok-options",
101
101
  async resolveId(s) {
102
- if (s === r)
102
+ if (s === e)
103
103
  return t;
104
104
  },
105
105
  async load(s) {
@@ -108,39 +108,78 @@ function Mr(o) {
108
108
  }
109
109
  };
110
110
  }
111
- let Ue = !1;
112
- const Be = [], Nr = (o) => new Promise((r, t) => {
113
- if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
111
+ let x = !1;
112
+ const O = [], M = (o) => new Promise((e, t) => {
113
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
114
114
  if (window.location === window.parent.location) {
115
115
  console.warn("You are not in Draft Mode or in the Visual Editor.");
116
116
  return;
117
117
  }
118
- Ue ? i() : Be.push(i);
118
+ x ? r() : O.push(r);
119
119
  }, document.getElementById("storyblok-javascript-bridge"))) return;
120
120
  const s = document.createElement("script");
121
- s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => t(i), s.onload = (i) => {
122
- Be.forEach((l) => l()), Ue = !0, r(i);
121
+ s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
122
+ O.forEach((n) => n()), x = !0, e(r);
123
123
  }, document.getElementsByTagName("head")[0].appendChild(s);
124
124
  });
125
- var zr = Object.defineProperty, Lr = (o, r, t) => r in o ? zr(o, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[r] = t, S = (o, r, t) => Lr(o, typeof r != "symbol" ? r + "" : r, t);
126
- class Dr {
125
+ var W = Object.defineProperty, Z = (o, e, t) => e in o ? W(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, d = (o, e, t) => Z(o, typeof e != "symbol" ? e + "" : e, t);
126
+ function E(o) {
127
+ return !(o !== o || o === 1 / 0 || o === -1 / 0);
128
+ }
129
+ function Y(o, e, t) {
130
+ if (!E(e))
131
+ throw new TypeError("Expected `limit` to be a finite number");
132
+ if (!E(t))
133
+ throw new TypeError("Expected `interval` to be a finite number");
134
+ const s = [];
135
+ let r = [], n = 0;
136
+ const i = function() {
137
+ n++;
138
+ const a = setTimeout(function() {
139
+ n--, s.length > 0 && i(), r = r.filter(function(h) {
140
+ return h !== a;
141
+ });
142
+ }, t);
143
+ r.indexOf(a) < 0 && r.push(a);
144
+ const c = s.shift();
145
+ c.resolve(o.apply(c.self, c.args));
146
+ }, l = function(...a) {
147
+ const c = this;
148
+ return new Promise(function(h, u) {
149
+ s.push({
150
+ resolve: h,
151
+ reject: u,
152
+ args: a,
153
+ self: c
154
+ }), n < e && i();
155
+ });
156
+ };
157
+ return l.abort = function() {
158
+ r.forEach(clearTimeout), r = [], s.forEach(function(a) {
159
+ a.reject(function() {
160
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
161
+ });
162
+ }), s.length = 0;
163
+ }, l;
164
+ }
165
+ class b {
127
166
  constructor() {
128
- S(this, "isCDNUrl", (r = "") => r.indexOf("/cdn/") > -1), S(this, "getOptionsPage", (r, t = 25, s = 1) => ({
129
- ...r,
167
+ d(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), d(this, "getOptionsPage", (e, t = 25, s = 1) => ({
168
+ ...e,
130
169
  per_page: t,
131
170
  page: s
132
- })), S(this, "delay", (r) => new Promise((t) => setTimeout(t, r))), S(this, "arrayFrom", (r = 0, t) => [...Array(r)].map(t)), S(this, "range", (r = 0, t = r) => {
133
- const s = Math.abs(t - r) || 0, i = r < t ? 1 : -1;
134
- return this.arrayFrom(s, (l, u) => u * i + r);
135
- }), S(this, "asyncMap", async (r, t) => Promise.all(r.map(t))), S(this, "flatMap", (r = [], t) => r.map(t).reduce((s, i) => [...s, ...i], [])), S(this, "escapeHTML", function(r) {
171
+ })), d(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), d(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), d(this, "range", (e = 0, t = e) => {
172
+ const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
173
+ return this.arrayFrom(s, (n, i) => i * r + e);
174
+ }), d(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), d(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), d(this, "escapeHTML", function(e) {
136
175
  const t = {
137
176
  "&": "&amp;",
138
177
  "<": "&lt;",
139
178
  ">": "&gt;",
140
179
  '"': "&quot;",
141
180
  "'": "&#39;"
142
- }, s = /[&<>"']/g, i = RegExp(s.source);
143
- return r && i.test(r) ? r.replace(s, (l) => t[l]) : r;
181
+ }, s = /[&<>"']/g, r = RegExp(s.source);
182
+ return e && r.test(e) ? e.replace(s, (n) => t[n]) : e;
144
183
  });
145
184
  }
146
185
  /**
@@ -150,56 +189,56 @@ class Dr {
150
189
  * @param {Boolean} isArray
151
190
  * @return {String} Stringified object
152
191
  */
153
- stringify(r, t, s) {
154
- const i = [];
155
- for (const l in r) {
156
- if (!Object.prototype.hasOwnProperty.call(r, l))
192
+ stringify(e, t, s) {
193
+ const r = [];
194
+ for (const n in e) {
195
+ if (!Object.prototype.hasOwnProperty.call(e, n))
157
196
  continue;
158
- const u = r[l], f = s ? "" : encodeURIComponent(l);
159
- let p;
160
- typeof u == "object" ? p = this.stringify(
161
- u,
162
- t ? t + encodeURIComponent("[" + f + "]") : f,
163
- Array.isArray(u)
164
- ) : p = (t ? t + encodeURIComponent("[" + f + "]") : f) + "=" + encodeURIComponent(u), i.push(p);
197
+ const i = e[n], l = s ? "" : encodeURIComponent(n);
198
+ let a;
199
+ typeof i == "object" ? a = this.stringify(
200
+ i,
201
+ t ? t + encodeURIComponent("[" + l + "]") : l,
202
+ Array.isArray(i)
203
+ ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
165
204
  }
166
- return i.join("&");
205
+ return r.join("&");
167
206
  }
168
207
  /**
169
208
  * @method getRegionURL
170
209
  * @param {String} regionCode region code, could be eu, us, cn, ap or ca
171
210
  * @return {String} The base URL of the region
172
211
  */
173
- getRegionURL(r) {
174
- const t = "api.storyblok.com", s = "api-us.storyblok.com", i = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
175
- switch (r) {
212
+ getRegionURL(e) {
213
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", n = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
214
+ switch (e) {
176
215
  case "us":
177
216
  return s;
178
217
  case "cn":
179
- return i;
218
+ return r;
180
219
  case "ap":
181
- return l;
220
+ return n;
182
221
  case "ca":
183
- return u;
222
+ return i;
184
223
  default:
185
224
  return t;
186
225
  }
187
226
  }
188
227
  }
189
- const Ur = function(o, r) {
228
+ const G = function(o, e) {
190
229
  const t = {};
191
230
  for (const s in o) {
192
- const i = o[s];
193
- r.indexOf(s) > -1 && i !== null && (t[s] = i);
231
+ const r = o[s];
232
+ e.indexOf(s) > -1 && r !== null && (t[s] = r);
194
233
  }
195
234
  return t;
196
- }, Br = (o) => o === "email", Fr = () => ({
235
+ }, Q = (o) => o === "email", X = () => ({
197
236
  singleTag: "hr"
198
- }), Hr = () => ({
237
+ }), ee = () => ({
199
238
  tag: "blockquote"
200
- }), qr = () => ({
239
+ }), te = () => ({
201
240
  tag: "ul"
202
- }), Gr = (o) => ({
241
+ }), se = (o) => ({
203
242
  tag: [
204
243
  "pre",
205
244
  {
@@ -207,24 +246,24 @@ const Ur = function(o, r) {
207
246
  attrs: o.attrs
208
247
  }
209
248
  ]
210
- }), Jr = () => ({
249
+ }), re = () => ({
211
250
  singleTag: "br"
212
- }), Kr = (o) => ({
251
+ }), oe = (o) => ({
213
252
  tag: `h${o.attrs.level}`
214
- }), Wr = (o) => ({
253
+ }), ne = (o) => ({
215
254
  singleTag: [
216
255
  {
217
256
  tag: "img",
218
- attrs: Ur(o.attrs, ["src", "alt", "title"])
257
+ attrs: G(o.attrs, ["src", "alt", "title"])
219
258
  }
220
259
  ]
221
- }), Xr = () => ({
260
+ }), ie = () => ({
222
261
  tag: "li"
223
- }), Yr = () => ({
262
+ }), ae = () => ({
224
263
  tag: "ol"
225
- }), Zr = () => ({
264
+ }), le = () => ({
226
265
  tag: "p"
227
- }), Qr = (o) => ({
266
+ }), ce = (o) => ({
228
267
  tag: [
229
268
  {
230
269
  tag: "span",
@@ -235,27 +274,27 @@ const Ur = function(o, r) {
235
274
  }
236
275
  }
237
276
  ]
238
- }), Vr = () => ({
277
+ }), he = () => ({
239
278
  tag: "b"
240
- }), en = () => ({
279
+ }), ue = () => ({
241
280
  tag: "s"
242
- }), tn = () => ({
281
+ }), de = () => ({
243
282
  tag: "u"
244
- }), rn = () => ({
283
+ }), pe = () => ({
245
284
  tag: "strong"
246
- }), nn = () => ({
285
+ }), ge = () => ({
247
286
  tag: "code"
248
- }), on = () => ({
287
+ }), fe = () => ({
249
288
  tag: "i"
250
- }), an = (o) => {
289
+ }), ye = (o) => {
251
290
  if (!o.attrs)
252
291
  return {
253
292
  tag: ""
254
293
  };
255
- const r = new Dr().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
256
- if (delete t.linktype, t.href && (t.href = r(o.attrs.href || "")), Br(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
257
- for (const i in t.custom)
258
- t[i] = t.custom[i];
294
+ const e = new b().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
295
+ if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), Q(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
296
+ for (const r in t.custom)
297
+ t[r] = t.custom[r];
259
298
  delete t.custom;
260
299
  }
261
300
  return {
@@ -266,27 +305,27 @@ const Ur = function(o, r) {
266
305
  }
267
306
  ]
268
307
  };
269
- }, sn = (o) => ({
308
+ }, me = (o) => ({
270
309
  tag: [
271
310
  {
272
311
  tag: "span",
273
312
  attrs: o.attrs
274
313
  }
275
314
  ]
276
- }), ln = () => ({
315
+ }), be = () => ({
277
316
  tag: "sub"
278
- }), cn = () => ({
317
+ }), ke = () => ({
279
318
  tag: "sup"
280
- }), un = (o) => ({
319
+ }), ve = (o) => ({
281
320
  tag: [
282
321
  {
283
322
  tag: "span",
284
323
  attrs: o.attrs
285
324
  }
286
325
  ]
287
- }), fn = (o) => {
288
- var r;
289
- return (r = o.attrs) != null && r.color ? {
326
+ }), we = (o) => {
327
+ var e;
328
+ return (e = o.attrs) != null && e.color ? {
290
329
  tag: [
291
330
  {
292
331
  tag: "span",
@@ -298,9 +337,9 @@ const Ur = function(o, r) {
298
337
  } : {
299
338
  tag: ""
300
339
  };
301
- }, dn = (o) => {
302
- var r;
303
- return (r = o.attrs) != null && r.color ? {
340
+ }, Se = (o) => {
341
+ var e;
342
+ return (e = o.attrs) != null && e.color ? {
304
343
  tag: [
305
344
  {
306
345
  tag: "span",
@@ -312,64 +351,64 @@ const Ur = function(o, r) {
312
351
  } : {
313
352
  tag: ""
314
353
  };
315
- }, pn = {
354
+ }, Te = {
316
355
  nodes: {
317
- horizontal_rule: Fr,
318
- blockquote: Hr,
319
- bullet_list: qr,
320
- code_block: Gr,
321
- hard_break: Jr,
322
- heading: Kr,
323
- image: Wr,
324
- list_item: Xr,
325
- ordered_list: Yr,
326
- paragraph: Zr,
327
- emoji: Qr
356
+ horizontal_rule: X,
357
+ blockquote: ee,
358
+ bullet_list: te,
359
+ code_block: se,
360
+ hard_break: re,
361
+ heading: oe,
362
+ image: ne,
363
+ list_item: ie,
364
+ ordered_list: ae,
365
+ paragraph: le,
366
+ emoji: ce
328
367
  },
329
368
  marks: {
330
- bold: Vr,
331
- strike: en,
332
- underline: tn,
333
- strong: rn,
334
- code: nn,
335
- italic: on,
336
- link: an,
337
- styled: sn,
338
- subscript: ln,
339
- superscript: cn,
340
- anchor: un,
341
- highlight: fn,
342
- textStyle: dn
343
- }
344
- }, gn = function(o) {
345
- const r = {
369
+ bold: he,
370
+ strike: ue,
371
+ underline: de,
372
+ strong: pe,
373
+ code: ge,
374
+ italic: fe,
375
+ link: ye,
376
+ styled: me,
377
+ subscript: be,
378
+ superscript: ke,
379
+ anchor: ve,
380
+ highlight: we,
381
+ textStyle: Se
382
+ }
383
+ }, Ce = function(o) {
384
+ const e = {
346
385
  "&": "&amp;",
347
386
  "<": "&lt;",
348
387
  ">": "&gt;",
349
388
  '"': "&quot;",
350
389
  "'": "&#39;"
351
390
  }, t = /[&<>"']/g, s = RegExp(t.source);
352
- return o && s.test(o) ? o.replace(t, (i) => r[i]) : o;
391
+ return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
353
392
  };
354
- let Fe = !1;
355
- class hn {
356
- constructor(r) {
357
- S(this, "marks"), S(this, "nodes"), r || (r = pn), this.marks = r.marks || [], this.nodes = r.nodes || [];
393
+ let L = !1;
394
+ class $e {
395
+ constructor(e) {
396
+ d(this, "marks"), d(this, "nodes"), e || (e = Te), this.marks = e.marks || [], this.nodes = e.nodes || [];
358
397
  }
359
- addNode(r, t) {
360
- this.nodes[r] = t;
398
+ addNode(e, t) {
399
+ this.nodes[e] = t;
361
400
  }
362
- addMark(r, t) {
363
- this.marks[r] = t;
401
+ addMark(e, t) {
402
+ this.marks[e] = t;
364
403
  }
365
- render(r, t = { optimizeImages: !1 }, s = !0) {
366
- if (!Fe && s && (console.warn(
404
+ render(e, t = { optimizeImages: !1 }, s = !0) {
405
+ if (!L && s && (console.warn(
367
406
  "Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
368
- ), Fe = !0), r && r.content && Array.isArray(r.content)) {
369
- let i = "";
370
- return r.content.forEach((l) => {
371
- i += this.renderNode(l);
372
- }), t.optimizeImages ? this.optimizeImages(i, t.optimizeImages) : i;
407
+ ), L = !0), e && e.content && Array.isArray(e.content)) {
408
+ let r = "";
409
+ return e.content.forEach((n) => {
410
+ r += this.renderNode(n);
411
+ }), t.optimizeImages ? this.optimizeImages(r, t.optimizeImages) : r;
373
412
  }
374
413
  return console.warn(
375
414
  `The render method must receive an Object with a "content" field.
@@ -398,91 +437,91 @@ class hn {
398
437
  }`
399
438
  ), "";
400
439
  }
401
- optimizeImages(r, t) {
402
- let s = 0, i = 0, l = "", u = "";
403
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (l += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (l += `height="${t.height}" `, i = t.height), (t.loading === "lazy" || t.loading === "eager") && (l += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (l += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (u += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (u += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (u += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (u += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (u += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (u += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (u += `:rotate(${t.filters.rotate})`), u.length > 0 && (u = "/filters" + u))), l.length > 0 && (r = r.replace(/<img/g, `<img ${l.trim()}`));
404
- const f = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${u}` : "";
405
- return r = r.replace(
440
+ optimizeImages(e, t) {
441
+ let s = 0, r = 0, n = "", i = "";
442
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
443
+ const l = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
444
+ return e = e.replace(
406
445
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
407
- `a.storyblok.com/f/$1/$2.$3/m/${f}`
408
- ), typeof t != "boolean" && (t.sizes || t.srcset) && (r = r.replace(/<img.*?src=["|'](.*?)["|']/g, (p) => {
409
- var y, _;
410
- const k = p.match(
446
+ `a.storyblok.com/f/$1/$2.$3/m/${l}`
447
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
448
+ var c, h;
449
+ const u = a.match(
411
450
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
412
451
  );
413
- if (k && k.length > 0) {
414
- const A = {
415
- srcset: (y = t.srcset) == null ? void 0 : y.map((w) => {
416
- if (typeof w == "number")
417
- return `//${k}/m/${w}x0${u} ${w}w`;
418
- if (typeof w == "object" && w.length === 2) {
419
- let M = 0, F = 0;
420
- return typeof w[0] == "number" && (M = w[0]), typeof w[1] == "number" && (F = w[1]), `//${k}/m/${M}x${F}${u} ${M}w`;
452
+ if (u && u.length > 0) {
453
+ const p = {
454
+ srcset: (c = t.srcset) == null ? void 0 : c.map((g) => {
455
+ if (typeof g == "number")
456
+ return `//${u}/m/${g}x0${i} ${g}w`;
457
+ if (typeof g == "object" && g.length === 2) {
458
+ let v = 0, $ = 0;
459
+ return typeof g[0] == "number" && (v = g[0]), typeof g[1] == "number" && ($ = g[1]), `//${u}/m/${v}x${$}${i} ${v}w`;
421
460
  }
422
461
  }).join(", "),
423
- sizes: (_ = t.sizes) == null ? void 0 : _.map((w) => w).join(", ")
462
+ sizes: (h = t.sizes) == null ? void 0 : h.map((g) => g).join(", ")
424
463
  };
425
- let O = "";
426
- return A.srcset && (O += `srcset="${A.srcset}" `), A.sizes && (O += `sizes="${A.sizes}" `), p.replace(/<img/g, `<img ${O.trim()}`);
464
+ let f = "";
465
+ return p.srcset && (f += `srcset="${p.srcset}" `), p.sizes && (f += `sizes="${p.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
427
466
  }
428
- return p;
429
- })), r;
467
+ return a;
468
+ })), e;
430
469
  }
431
- renderNode(r) {
470
+ renderNode(e) {
432
471
  const t = [];
433
- r.marks && r.marks.forEach((i) => {
434
- const l = this.getMatchingMark(i);
435
- l && l.tag !== "" && t.push(this.renderOpeningTag(l.tag));
472
+ e.marks && e.marks.forEach((r) => {
473
+ const n = this.getMatchingMark(r);
474
+ n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
436
475
  });
437
- const s = this.getMatchingNode(r);
438
- return s && s.tag && t.push(this.renderOpeningTag(s.tag)), r.content ? r.content.forEach((i) => {
439
- t.push(this.renderNode(i));
440
- }) : r.text ? t.push(gn(r.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : r.type === "emoji" && t.push(this.renderEmoji(r)), s && s.tag && t.push(this.renderClosingTag(s.tag)), r.marks && r.marks.slice(0).reverse().forEach((i) => {
441
- const l = this.getMatchingMark(i);
442
- l && l.tag !== "" && t.push(this.renderClosingTag(l.tag));
476
+ const s = this.getMatchingNode(e);
477
+ return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
478
+ t.push(this.renderNode(r));
479
+ }) : e.text ? t.push(Ce(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
480
+ const n = this.getMatchingMark(r);
481
+ n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
443
482
  }), t.join("");
444
483
  }
445
- renderTag(r, t) {
446
- return r.constructor === String ? `<${r}${t}>` : r.map((s) => {
484
+ renderTag(e, t) {
485
+ return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
447
486
  if (s.constructor === String)
448
487
  return `<${s}${t}>`;
449
488
  {
450
- let i = `<${s.tag}`;
489
+ let r = `<${s.tag}`;
451
490
  if (s.attrs) {
452
- for (const l in s.attrs)
453
- if (Object.prototype.hasOwnProperty.call(s.attrs, l)) {
454
- const u = s.attrs[l];
455
- u !== null && (i += ` ${l}="${u}"`);
491
+ for (const n in s.attrs)
492
+ if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
493
+ const i = s.attrs[n];
494
+ i !== null && (r += ` ${n}="${i}"`);
456
495
  }
457
496
  }
458
- return `${i}${t}>`;
497
+ return `${r}${t}>`;
459
498
  }
460
499
  }).join("");
461
500
  }
462
- renderOpeningTag(r) {
463
- return this.renderTag(r, "");
501
+ renderOpeningTag(e) {
502
+ return this.renderTag(e, "");
464
503
  }
465
- renderClosingTag(r) {
466
- return r.constructor === String ? `</${r}>` : r.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
504
+ renderClosingTag(e) {
505
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
467
506
  }
468
- getMatchingNode(r) {
469
- const t = this.nodes[r.type];
507
+ getMatchingNode(e) {
508
+ const t = this.nodes[e.type];
470
509
  if (typeof t == "function")
471
- return t(r);
510
+ return t(e);
472
511
  }
473
- getMatchingMark(r) {
474
- const t = this.marks[r.type];
512
+ getMatchingMark(e) {
513
+ const t = this.marks[e.type];
475
514
  if (typeof t == "function")
476
- return t(r);
515
+ return t(e);
477
516
  }
478
- renderEmoji(r) {
479
- if (r.attrs.emoji)
480
- return r.attrs.emoji;
517
+ renderEmoji(e) {
518
+ if (e.attrs.emoji)
519
+ return e.attrs.emoji;
481
520
  const t = [
482
521
  {
483
522
  tag: "img",
484
523
  attrs: {
485
- src: r.attrs.fallbackImage,
524
+ src: e.attrs.fallbackImage,
486
525
  draggable: "false",
487
526
  loading: "lazy",
488
527
  align: "absmiddle"
@@ -492,652 +531,510 @@ class hn {
492
531
  return this.renderTag(t, " /");
493
532
  }
494
533
  }
495
- const bn = hn, $n = (o) => {
496
- if (typeof o != "object" || typeof o._editable > "u")
497
- return {};
498
- try {
499
- const r = JSON.parse(
500
- o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
501
- );
502
- return r ? {
503
- "data-blok-c": JSON.stringify(r),
504
- "data-blok-uid": r.id + "-" + r.uid
505
- } : {};
506
- } catch {
507
- return {};
534
+ const k = $e;
535
+ class Re {
536
+ constructor(e) {
537
+ d(this, "baseURL"), d(this, "timeout"), d(this, "headers"), d(this, "responseInterceptor"), d(this, "fetch"), d(this, "ejectInterceptor"), d(this, "url"), d(this, "parameters"), d(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
508
538
  }
509
- };
510
- let yn, mn = "https://app.storyblok.com/f/storyblok-v2-latest.js";
511
- const vn = (o, r) => {
512
- o.addNode("blok", (t) => {
513
- let s = "";
514
- return t.attrs.body.forEach((i) => {
515
- s += r(i.component, i);
516
- }), {
517
- html: s
518
- };
519
- });
520
- }, _n = (o) => !o || !(o != null && o.content.some((r) => r.content || r.type === "blok" || r.type === "horizontal_rule")), wn = (o, r, t) => {
521
- let s = t || yn;
522
- if (!s) {
523
- console.error(
524
- "Please initialize the Storyblok SDK before calling the renderRichText function"
525
- );
526
- return;
527
- }
528
- return _n(o) ? "" : (r && (s = new bn(r.schema), r.resolver && vn(s, r.resolver)), s.render(o, {}, !1));
529
- }, En = () => Nr(mn);
530
- function Tn(o) {
531
- let r = {
532
- resolveRelations: []
533
- };
534
- function t(s) {
535
- s && Array.isArray(r.resolveRelations) && r.resolveRelations.push(
536
- ...Array.isArray(s) ? s : [s]
537
- );
538
- }
539
- for (const s of o)
540
- if (s.options) {
541
- const { apiOptions: i, bridgeOptions: l } = s.options;
542
- if (t(i == null ? void 0 : i.resolve_relations), l) {
543
- const { resolveRelations: u, ...f } = l;
544
- t(u), Object.assign(r, f);
545
- }
546
- }
547
- return r.resolveRelations = [...new Set(r.resolveRelations)], r;
548
- }
549
- var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
550
- function kn(o) {
551
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
552
- }
553
- var Q = { exports: {} };
554
- Q.exports;
555
- (function(o, r) {
556
- var t = 200, s = "__lodash_hash_undefined__", i = 800, l = 16, u = 9007199254740991, f = "[object Arguments]", p = "[object Array]", y = "[object AsyncFunction]", _ = "[object Boolean]", k = "[object Date]", A = "[object Error]", O = "[object Function]", w = "[object GeneratorFunction]", M = "[object Map]", F = "[object Number]", Je = "[object Null]", de = "[object Object]", Ke = "[object Proxy]", We = "[object RegExp]", Xe = "[object Set]", Ye = "[object String]", Ze = "[object Undefined]", Qe = "[object WeakMap]", Ve = "[object ArrayBuffer]", et = "[object DataView]", tt = "[object Float32Array]", rt = "[object Float64Array]", nt = "[object Int8Array]", ot = "[object Int16Array]", at = "[object Int32Array]", st = "[object Uint8Array]", it = "[object Uint8ClampedArray]", lt = "[object Uint16Array]", ct = "[object Uint32Array]", ut = /[\\^$.*+?()[\]{}|]/g, ft = /^\[object .+?Constructor\]$/, dt = /^(?:0|[1-9]\d*)$/, b = {};
557
- b[tt] = b[rt] = b[nt] = b[ot] = b[at] = b[st] = b[it] = b[lt] = b[ct] = !0, b[f] = b[p] = b[Ve] = b[_] = b[et] = b[k] = b[A] = b[O] = b[M] = b[F] = b[de] = b[We] = b[Xe] = b[Ye] = b[Qe] = !1;
558
- var pe = typeof Z == "object" && Z && Z.Object === Object && Z, pt = typeof self == "object" && self && self.Object === Object && self, N = pe || pt || Function("return this")(), ge = r && !r.nodeType && r, z = ge && !0 && o && !o.nodeType && o, he = z && z.exports === ge, V = he && pe.process, be = function() {
559
- try {
560
- var e = z && z.require && z.require("util").types;
561
- return e || V && V.binding && V.binding("util");
562
- } catch {
563
- }
564
- }(), ye = be && be.isTypedArray;
565
- function gt(e, n, a) {
566
- switch (a.length) {
567
- case 0:
568
- return e.call(n);
569
- case 1:
570
- return e.call(n, a[0]);
571
- case 2:
572
- return e.call(n, a[0], a[1]);
573
- case 3:
574
- return e.call(n, a[0], a[1], a[2]);
575
- }
576
- return e.apply(n, a);
539
+ /**
540
+ *
541
+ * @param url string
542
+ * @param params ISbStoriesParams
543
+ * @returns Promise<ISbResponse | Error>
544
+ */
545
+ get(e, t) {
546
+ return this.url = e, this.parameters = t, this._methodHandler("get");
577
547
  }
578
- function ht(e, n) {
579
- for (var a = -1, c = Array(e); ++a < e; )
580
- c[a] = n(a);
581
- return c;
548
+ post(e, t) {
549
+ return this.url = e, this.parameters = t, this._methodHandler("post");
582
550
  }
583
- function bt(e) {
584
- return function(n) {
585
- return e(n);
586
- };
551
+ put(e, t) {
552
+ return this.url = e, this.parameters = t, this._methodHandler("put");
587
553
  }
588
- function yt(e, n) {
589
- return e == null ? void 0 : e[n];
554
+ delete(e, t) {
555
+ return this.url = e, this.parameters = t, this._methodHandler("delete");
590
556
  }
591
- function mt(e, n) {
592
- return function(a) {
593
- return e(n(a));
557
+ async _responseHandler(e) {
558
+ const t = [], s = {
559
+ data: {},
560
+ headers: {},
561
+ status: 0,
562
+ statusText: ""
594
563
  };
595
- }
596
- var vt = Array.prototype, _t = Function.prototype, H = Object.prototype, ee = N["__core-js_shared__"], q = _t.toString, j = H.hasOwnProperty, me = function() {
597
- var e = /[^.]+$/.exec(ee && ee.keys && ee.keys.IE_PROTO || "");
598
- return e ? "Symbol(src)_1." + e : "";
599
- }(), ve = H.toString, wt = q.call(Object), Tt = RegExp(
600
- "^" + q.call(j).replace(ut, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
601
- ), G = he ? N.Buffer : void 0, _e = N.Symbol, we = N.Uint8Array;
602
- G && G.allocUnsafe;
603
- var Te = mt(Object.getPrototypeOf, Object), ke = Object.create, kt = H.propertyIsEnumerable, At = vt.splice, x = _e ? _e.toStringTag : void 0, J = function() {
564
+ e.status !== 204 && await e.json().then((r) => {
565
+ s.data = r;
566
+ });
567
+ for (const r of e.headers.entries())
568
+ t[r[0]] = r[1];
569
+ return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
570
+ }
571
+ async _methodHandler(e) {
572
+ let t = `${this.baseURL}${this.url}`, s = null;
573
+ if (e === "get") {
574
+ const a = new b();
575
+ t = `${this.baseURL}${this.url}?${a.stringify(
576
+ this.parameters
577
+ )}`;
578
+ } else
579
+ s = JSON.stringify(this.parameters);
580
+ const r = new URL(t), n = new AbortController(), { signal: i } = n;
581
+ let l;
582
+ this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
604
583
  try {
605
- var e = ne(Object, "defineProperty");
606
- return e({}, "", {}), e;
607
- } catch {
608
- }
609
- }(), It = G ? G.isBuffer : void 0, Ae = Math.max, St = Date.now, Ie = ne(N, "Map"), L = ne(Object, "create"), Ot = /* @__PURE__ */ function() {
610
- function e() {
611
- }
612
- return function(n) {
613
- if (!E(n))
614
- return {};
615
- if (ke)
616
- return ke(n);
617
- e.prototype = n;
618
- var a = new e();
619
- return e.prototype = void 0, a;
620
- };
621
- }();
622
- function $(e) {
623
- var n = -1, a = e == null ? 0 : e.length;
624
- for (this.clear(); ++n < a; ) {
625
- var c = e[n];
626
- this.set(c[0], c[1]);
584
+ const a = await this.fetch(`${r}`, {
585
+ method: e,
586
+ headers: this.headers,
587
+ body: s,
588
+ signal: i,
589
+ ...this.fetchOptions
590
+ });
591
+ this.timeout && clearTimeout(l);
592
+ const c = await this._responseHandler(
593
+ a
594
+ );
595
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
596
+ } catch (a) {
597
+ return {
598
+ message: a
599
+ };
627
600
  }
628
601
  }
629
- function Ct() {
630
- this.__data__ = L ? L(null) : {}, this.size = 0;
631
- }
632
- function jt(e) {
633
- var n = this.has(e) && delete this.__data__[e];
634
- return this.size -= n ? 1 : 0, n;
602
+ setFetchOptions(e = {}) {
603
+ Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
604
+ }
605
+ eject() {
606
+ this.ejectInterceptor = !0;
607
+ }
608
+ _statusHandler(e) {
609
+ const t = /20[0-6]/g;
610
+ return new Promise((s, r) => {
611
+ if (t.test(`${e.status}`))
612
+ return s(e);
613
+ const n = {
614
+ message: e.statusText,
615
+ status: e.status,
616
+ response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
617
+ };
618
+ r(n);
619
+ });
635
620
  }
636
- function xt(e) {
637
- var n = this.__data__;
638
- if (L) {
639
- var a = n[e];
640
- return a === s ? void 0 : a;
641
- }
642
- return j.call(n, e) ? n[e] : void 0;
643
- }
644
- function $t(e) {
645
- var n = this.__data__;
646
- return L ? n[e] !== void 0 : j.call(n, e);
647
- }
648
- function Et(e, n) {
649
- var a = this.__data__;
650
- return this.size += this.has(e) ? 0 : 1, a[e] = L && n === void 0 ? s : n, this;
651
- }
652
- $.prototype.clear = Ct, $.prototype.delete = jt, $.prototype.get = xt, $.prototype.has = $t, $.prototype.set = Et;
653
- function C(e) {
654
- var n = -1, a = e == null ? 0 : e.length;
655
- for (this.clear(); ++n < a; ) {
656
- var c = e[n];
657
- this.set(c[0], c[1]);
621
+ }
622
+ const _e = Re, j = "SB-Agent", w = {
623
+ defaultAgentName: "SB-JS-CLIENT",
624
+ defaultAgentVersion: "SB-Agent-Version",
625
+ packageVersion: "6.0.0"
626
+ };
627
+ let m = {};
628
+ const y = {};
629
+ class Ae {
630
+ /**
631
+ *
632
+ * @param config ISbConfig interface
633
+ * @param endpoint string, optional
634
+ */
635
+ constructor(e, t) {
636
+ d(this, "client"), d(this, "maxRetries"), d(this, "retriesDelay"), d(this, "throttle"), d(this, "accessToken"), d(this, "cache"), d(this, "helpers"), d(this, "resolveCounter"), d(this, "relations"), d(this, "links"), d(this, "richTextResolver"), d(this, "resolveNestedRelations"), d(this, "stringifiedStoriesCache");
637
+ let s = e.endpoint || t;
638
+ if (!s) {
639
+ const i = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
640
+ e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
658
641
  }
642
+ const r = new Headers();
643
+ r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
644
+ r.set(i, l);
645
+ }), r.has(j) || (r.set(j, w.defaultAgentName), r.set(
646
+ w.defaultAgentVersion,
647
+ w.packageVersion
648
+ ));
649
+ let n = 5;
650
+ e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Y(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new _e({
651
+ baseURL: s,
652
+ timeout: e.timeout || 0,
653
+ headers: r,
654
+ responseInterceptor: e.responseInterceptor,
655
+ fetch: e.fetch
656
+ });
659
657
  }
660
- function Rt() {
661
- this.__data__ = [], this.size = 0;
662
- }
663
- function Pt(e) {
664
- var n = this.__data__, a = K(n, e);
665
- if (a < 0)
666
- return !1;
667
- var c = n.length - 1;
668
- return a == c ? n.pop() : At.call(n, a, 1), --this.size, !0;
669
- }
670
- function Mt(e) {
671
- var n = this.__data__, a = K(n, e);
672
- return a < 0 ? void 0 : n[a][1];
673
- }
674
- function Nt(e) {
675
- return K(this.__data__, e) > -1;
676
- }
677
- function zt(e, n) {
678
- var a = this.__data__, c = K(a, e);
679
- return c < 0 ? (++this.size, a.push([e, n])) : a[c][1] = n, this;
680
- }
681
- C.prototype.clear = Rt, C.prototype.delete = Pt, C.prototype.get = Mt, C.prototype.has = Nt, C.prototype.set = zt;
682
- function R(e) {
683
- var n = -1, a = e == null ? 0 : e.length;
684
- for (this.clear(); ++n < a; ) {
685
- var c = e[n];
686
- this.set(c[0], c[1]);
687
- }
658
+ setComponentResolver(e) {
659
+ this.richTextResolver.addNode("blok", (t) => {
660
+ let s = "";
661
+ return t.attrs.body && t.attrs.body.forEach((r) => {
662
+ s += e(r.component, r);
663
+ }), {
664
+ html: s
665
+ };
666
+ });
688
667
  }
689
- function Lt() {
690
- this.size = 0, this.__data__ = {
691
- hash: new $(),
692
- map: new (Ie || C)(),
693
- string: new $()
694
- };
668
+ parseParams(e) {
669
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = y[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
695
670
  }
696
- function Dt(e) {
697
- var n = X(this, e).delete(e);
698
- return this.size -= n ? 1 : 0, n;
671
+ factoryParamOptions(e, t) {
672
+ return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
699
673
  }
700
- function Ut(e) {
701
- return X(this, e).get(e);
674
+ makeRequest(e, t, s, r, n) {
675
+ const i = this.factoryParamOptions(
676
+ e,
677
+ this.helpers.getOptionsPage(t, s, r)
678
+ );
679
+ return this.cacheResponse(e, i, void 0, n);
680
+ }
681
+ get(e, t, s) {
682
+ t || (t = {});
683
+ const r = `/${e}`, n = this.factoryParamOptions(r, t);
684
+ return this.cacheResponse(r, n, void 0, s);
685
+ }
686
+ async getAll(e, t, s, r) {
687
+ const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, l = i.split("/"), a = s || l[l.length - 1], c = 1, h = await this.makeRequest(
688
+ i,
689
+ t,
690
+ n,
691
+ c,
692
+ r
693
+ ), u = h.total ? Math.ceil(h.total / n) : 1, p = await this.helpers.asyncMap(
694
+ this.helpers.range(c, u),
695
+ (f) => this.makeRequest(i, t, n, f + 1, r)
696
+ );
697
+ return this.helpers.flatMap(
698
+ [h, ...p],
699
+ (f) => Object.values(f.data[a])
700
+ );
702
701
  }
703
- function Bt(e) {
704
- return X(this, e).has(e);
702
+ post(e, t, s) {
703
+ const r = `/${e}`;
704
+ return Promise.resolve(this.throttle("post", r, t, s));
705
705
  }
706
- function Ft(e, n) {
707
- var a = X(this, e), c = a.size;
708
- return a.set(e, n), this.size += a.size == c ? 0 : 1, this;
706
+ put(e, t, s) {
707
+ const r = `/${e}`;
708
+ return Promise.resolve(this.throttle("put", r, t, s));
709
709
  }
710
- R.prototype.clear = Lt, R.prototype.delete = Dt, R.prototype.get = Ut, R.prototype.has = Bt, R.prototype.set = Ft;
711
- function P(e) {
712
- var n = this.__data__ = new C(e);
713
- this.size = n.size;
710
+ delete(e, t, s) {
711
+ const r = `/${e}`;
712
+ return Promise.resolve(this.throttle("delete", r, t, s));
714
713
  }
715
- function Ht() {
716
- this.__data__ = new C(), this.size = 0;
714
+ getStories(e, t) {
715
+ return this._addResolveLevel(e), this.get("cdn/stories", e, t);
717
716
  }
718
- function qt(e) {
719
- var n = this.__data__, a = n.delete(e);
720
- return this.size = n.size, a;
717
+ getStory(e, t, s) {
718
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
721
719
  }
722
- function Gt(e) {
723
- return this.__data__.get(e);
720
+ getToken() {
721
+ return this.accessToken;
724
722
  }
725
- function Jt(e) {
726
- return this.__data__.has(e);
723
+ ejectInterceptor() {
724
+ this.client.eject();
727
725
  }
728
- function Kt(e, n) {
729
- var a = this.__data__;
730
- if (a instanceof C) {
731
- var c = a.__data__;
732
- if (!Ie || c.length < t - 1)
733
- return c.push([e, n]), this.size = ++a.size, this;
734
- a = this.__data__ = new R(c);
735
- }
736
- return a.set(e, n), this.size = a.size, this;
737
- }
738
- P.prototype.clear = Ht, P.prototype.delete = qt, P.prototype.get = Gt, P.prototype.has = Jt, P.prototype.set = Kt;
739
- function Wt(e, n) {
740
- var a = se(e), c = !a && ae(e), d = !a && !c && xe(e), h = !a && !c && !d && Ee(e), m = a || c || d || h, g = m ? ht(e.length, String) : [], v = g.length;
741
- for (var I in e)
742
- m && // Safari 9 has enumerable `arguments.length` in strict mode.
743
- (I == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
744
- d && (I == "offset" || I == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
745
- h && (I == "buffer" || I == "byteLength" || I == "byteOffset") || // Skip index properties.
746
- Ce(I, v)) || g.push(I);
747
- return g;
748
- }
749
- function te(e, n, a) {
750
- (a !== void 0 && !Y(e[n], a) || a === void 0 && !(n in e)) && re(e, n, a);
751
- }
752
- function Xt(e, n, a) {
753
- var c = e[n];
754
- (!(j.call(e, n) && Y(c, a)) || a === void 0 && !(n in e)) && re(e, n, a);
755
- }
756
- function K(e, n) {
757
- for (var a = e.length; a--; )
758
- if (Y(e[a][0], n))
759
- return a;
760
- return -1;
761
- }
762
- function re(e, n, a) {
763
- n == "__proto__" && J ? J(e, n, {
764
- configurable: !0,
765
- enumerable: !0,
766
- value: a,
767
- writable: !0
768
- }) : e[n] = a;
769
- }
770
- var Yt = cr();
771
- function W(e) {
772
- return e == null ? e === void 0 ? Ze : Je : x && x in Object(e) ? ur(e) : br(e);
773
- }
774
- function Se(e) {
775
- return D(e) && W(e) == f;
776
- }
777
- function Zt(e) {
778
- if (!E(e) || gr(e))
779
- return !1;
780
- var n = le(e) ? Tt : ft;
781
- return n.test(_r(e));
782
- }
783
- function Qt(e) {
784
- return D(e) && $e(e.length) && !!b[W(e)];
785
- }
786
- function Vt(e) {
787
- if (!E(e))
788
- return hr(e);
789
- var n = je(e), a = [];
790
- for (var c in e)
791
- c == "constructor" && (n || !j.call(e, c)) || a.push(c);
792
- return a;
793
- }
794
- function Oe(e, n, a, c, d) {
795
- e !== n && Yt(n, function(h, m) {
796
- if (d || (d = new P()), E(h))
797
- er(e, n, m, a, Oe, c, d);
798
- else {
799
- var g = c ? c(oe(e, m), h, m + "", e, n, d) : void 0;
800
- g === void 0 && (g = h), te(e, m, g);
801
- }
802
- }, Re);
726
+ _addResolveLevel(e) {
727
+ typeof e.resolve_relations < "u" && (e.resolve_level = 2);
803
728
  }
804
- function er(e, n, a, c, d, h, m) {
805
- var g = oe(e, a), v = oe(n, a), I = m.get(v);
806
- if (I) {
807
- te(e, a, I);
808
- return;
809
- }
810
- var T = h ? h(g, v, a + "", e, n, m) : void 0, U = T === void 0;
811
- if (U) {
812
- var ce = se(v), ue = !ce && xe(v), Me = !ce && !ue && Ee(v);
813
- T = v, ce || ue || Me ? se(g) ? T = g : wr(g) ? T = sr(g) : ue ? (U = !1, T = nr(v)) : Me ? (U = !1, T = ar(v)) : T = [] : Tr(v) || ae(v) ? (T = g, ae(g) ? T = kr(g) : (!E(g) || le(g)) && (T = fr(v))) : U = !1;
814
- }
815
- U && (m.set(v, T), d(T, v, c, h, m), m.delete(v)), te(e, a, T);
729
+ _cleanCopy(e) {
730
+ return JSON.parse(JSON.stringify(e));
816
731
  }
817
- function tr(e, n) {
818
- return mr(yr(e, n, Pe), e + "");
732
+ _insertLinks(e, t, s) {
733
+ const r = e[t];
734
+ r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
819
735
  }
820
- var rr = J ? function(e, n) {
821
- return J(e, "toString", {
822
- configurable: !0,
823
- enumerable: !1,
824
- value: Ir(n),
825
- writable: !0
826
- });
827
- } : Pe;
828
- function nr(e, n) {
829
- return e.slice();
830
- }
831
- function or(e) {
832
- var n = new e.constructor(e.byteLength);
833
- return new we(n).set(new we(e)), n;
834
- }
835
- function ar(e, n) {
836
- var a = or(e.buffer);
837
- return new e.constructor(a, e.byteOffset, e.length);
838
- }
839
- function sr(e, n) {
840
- var a = -1, c = e.length;
841
- for (n || (n = Array(c)); ++a < c; )
842
- n[a] = e[a];
843
- return n;
844
- }
845
- function ir(e, n, a, c) {
846
- var d = !a;
847
- a || (a = {});
848
- for (var h = -1, m = n.length; ++h < m; ) {
849
- var g = n[h], v = void 0;
850
- v === void 0 && (v = e[g]), d ? re(a, g, v) : Xt(a, g, v);
851
- }
852
- return a;
853
- }
854
- function lr(e) {
855
- return tr(function(n, a) {
856
- var c = -1, d = a.length, h = d > 1 ? a[d - 1] : void 0, m = d > 2 ? a[2] : void 0;
857
- for (h = e.length > 3 && typeof h == "function" ? (d--, h) : void 0, m && dr(a[0], a[1], m) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
858
- var g = a[c];
859
- g && e(n, g, c, h);
736
+ /**
737
+ *
738
+ * @param resolveId A counter number as a string
739
+ * @param uuid The uuid of the story
740
+ * @returns string | object
741
+ */
742
+ getStoryReference(e, t) {
743
+ return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
744
+ this.relations[e][t]
745
+ )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
746
+ }
747
+ _insertRelations(e, t, s, r) {
748
+ s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(r, n)).filter(Boolean)));
749
+ }
750
+ iterateTree(e, t, s) {
751
+ const r = (n) => {
752
+ if (n != null) {
753
+ if (n.constructor === Array)
754
+ for (let i = 0; i < n.length; i++)
755
+ r(n[i]);
756
+ else if (n.constructor === Object) {
757
+ if (n._stopResolving)
758
+ return;
759
+ for (const i in n)
760
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(
761
+ n,
762
+ i,
763
+ t,
764
+ s
765
+ ), this._insertLinks(
766
+ n,
767
+ i,
768
+ s
769
+ )), r(n[i]);
770
+ }
860
771
  }
861
- return n;
772
+ };
773
+ r(e.content);
774
+ }
775
+ async resolveLinks(e, t, s) {
776
+ let r = [];
777
+ if (e.link_uuids) {
778
+ const n = e.link_uuids.length, i = [], l = 50;
779
+ for (let a = 0; a < n; a += l) {
780
+ const c = Math.min(n, a + l);
781
+ i.push(e.link_uuids.slice(a, c));
782
+ }
783
+ for (let a = 0; a < i.length; a++)
784
+ (await this.getStories({
785
+ per_page: l,
786
+ language: t.language,
787
+ version: t.version,
788
+ by_uuids: i[a].join(",")
789
+ })).data.stories.forEach(
790
+ (c) => {
791
+ r.push(c);
792
+ }
793
+ );
794
+ } else
795
+ r = e.links;
796
+ r.forEach((n) => {
797
+ this.links[s][n.uuid] = {
798
+ ...n,
799
+ _stopResolving: !0
800
+ };
862
801
  });
863
802
  }
864
- function cr(e) {
865
- return function(n, a, c) {
866
- for (var d = -1, h = Object(n), m = c(n), g = m.length; g--; ) {
867
- var v = m[++d];
868
- if (a(h[v], v, h) === !1)
869
- break;
803
+ async resolveRelations(e, t, s) {
804
+ let r = [];
805
+ if (e.rel_uuids) {
806
+ const n = e.rel_uuids.length, i = [], l = 50;
807
+ for (let a = 0; a < n; a += l) {
808
+ const c = Math.min(n, a + l);
809
+ i.push(e.rel_uuids.slice(a, c));
870
810
  }
871
- return n;
872
- };
873
- }
874
- function X(e, n) {
875
- var a = e.__data__;
876
- return pr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
877
- }
878
- function ne(e, n) {
879
- var a = yt(e, n);
880
- return Zt(a) ? a : void 0;
811
+ for (let a = 0; a < i.length; a++)
812
+ (await this.getStories({
813
+ per_page: l,
814
+ language: t.language,
815
+ version: t.version,
816
+ by_uuids: i[a].join(","),
817
+ excluding_fields: t.excluding_fields
818
+ })).data.stories.forEach((c) => {
819
+ r.push(c);
820
+ });
821
+ } else
822
+ r = e.rels;
823
+ r && r.length > 0 && r.forEach((n) => {
824
+ this.relations[s][n.uuid] = {
825
+ ...n,
826
+ _stopResolving: !0
827
+ };
828
+ });
881
829
  }
882
- function ur(e) {
883
- var n = j.call(e, x), a = e[x];
884
- try {
885
- e[x] = void 0;
886
- var c = !0;
887
- } catch {
830
+ /**
831
+ *
832
+ * @param responseData
833
+ * @param params
834
+ * @param resolveId
835
+ * @description Resolves the relations and links of the stories
836
+ * @returns Promise<void>
837
+ *
838
+ */
839
+ async resolveStories(e, t, s) {
840
+ var r, n;
841
+ let i = [];
842
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
843
+ for (const l in this.relations[s])
844
+ this.iterateTree(
845
+ this.relations[s][l],
846
+ i,
847
+ s
848
+ );
849
+ e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
850
+ this.iterateTree(l, i, s);
851
+ }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
852
+ }
853
+ async cacheResponse(e, t, s, r) {
854
+ const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
855
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
856
+ const l = await i.get(n);
857
+ if (l)
858
+ return Promise.resolve(l);
888
859
  }
889
- var d = ve.call(e);
890
- return c && (n ? e[x] = a : delete e[x]), d;
891
- }
892
- function fr(e) {
893
- return typeof e.constructor == "function" && !je(e) ? Ot(Te(e)) : {};
894
- }
895
- function Ce(e, n) {
896
- var a = typeof e;
897
- return n = n ?? u, !!n && (a == "number" || a != "symbol" && dt.test(e)) && e > -1 && e % 1 == 0 && e < n;
898
- }
899
- function dr(e, n, a) {
900
- if (!E(a))
901
- return !1;
902
- var c = typeof n;
903
- return (c == "number" ? ie(a) && Ce(n, a.length) : c == "string" && n in a) ? Y(a[n], e) : !1;
904
- }
905
- function pr(e) {
906
- var n = typeof e;
907
- return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? e !== "__proto__" : e === null;
908
- }
909
- function gr(e) {
910
- return !!me && me in e;
911
- }
912
- function je(e) {
913
- var n = e && e.constructor, a = typeof n == "function" && n.prototype || H;
914
- return e === a;
915
- }
916
- function hr(e) {
917
- var n = [];
918
- if (e != null)
919
- for (var a in Object(e))
920
- n.push(a);
921
- return n;
922
- }
923
- function br(e) {
924
- return ve.call(e);
925
- }
926
- function yr(e, n, a) {
927
- return n = Ae(n === void 0 ? e.length - 1 : n, 0), function() {
928
- for (var c = arguments, d = -1, h = Ae(c.length - n, 0), m = Array(h); ++d < h; )
929
- m[d] = c[n + d];
930
- d = -1;
931
- for (var g = Array(n + 1); ++d < n; )
932
- g[d] = c[d];
933
- return g[n] = a(m), gt(e, this, g);
934
- };
935
- }
936
- function oe(e, n) {
937
- if (!(n === "constructor" && typeof e[n] == "function") && n != "__proto__")
938
- return e[n];
939
- }
940
- var mr = vr(rr);
941
- function vr(e) {
942
- var n = 0, a = 0;
943
- return function() {
944
- var c = St(), d = l - (c - a);
945
- if (a = c, d > 0) {
946
- if (++n >= i)
947
- return arguments[0];
948
- } else
949
- n = 0;
950
- return e.apply(void 0, arguments);
951
- };
952
- }
953
- function _r(e) {
954
- if (e != null) {
955
- try {
956
- return q.call(e);
957
- } catch {
958
- }
860
+ return new Promise(async (l, a) => {
861
+ var c;
959
862
  try {
960
- return e + "";
961
- } catch {
863
+ const h = await this.throttle("get", e, t, r);
864
+ if (h.status !== 200)
865
+ return a(h);
866
+ let u = { data: h.data, headers: h.headers };
867
+ if ((c = h.headers) != null && c["per-page"] && (u = Object.assign({}, u, {
868
+ perPage: h.headers["per-page"] ? parseInt(h.headers["per-page"]) : 0,
869
+ total: h.headers["per-page"] ? parseInt(h.headers.total) : 0
870
+ })), u.data.story || u.data.stories) {
871
+ const p = this.resolveCounter = ++this.resolveCounter % 1e3;
872
+ await this.resolveStories(u.data, t, `${p}`);
873
+ }
874
+ return t.version === "published" && e != "/cdn/spaces/me" && await i.set(n, u), u.data.cv && t.token && (t.version === "draft" && y[t.token] != u.data.cv && await this.flushCache(), y[t.token] = t.cv ? t.cv : u.data.cv), l(u);
875
+ } catch (h) {
876
+ if (h.response && h.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
877
+ return console.log(
878
+ `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
879
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
880
+ a(h);
962
881
  }
963
- }
964
- return "";
965
- }
966
- function Y(e, n) {
967
- return e === n || e !== e && n !== n;
968
- }
969
- var ae = Se(/* @__PURE__ */ function() {
970
- return arguments;
971
- }()) ? Se : function(e) {
972
- return D(e) && j.call(e, "callee") && !kt.call(e, "callee");
973
- }, se = Array.isArray;
974
- function ie(e) {
975
- return e != null && $e(e.length) && !le(e);
976
- }
977
- function wr(e) {
978
- return D(e) && ie(e);
979
- }
980
- var xe = It || Sr;
981
- function le(e) {
982
- if (!E(e))
983
- return !1;
984
- var n = W(e);
985
- return n == O || n == w || n == y || n == Ke;
986
- }
987
- function $e(e) {
988
- return typeof e == "number" && e > -1 && e % 1 == 0 && e <= u;
989
- }
990
- function E(e) {
991
- var n = typeof e;
992
- return e != null && (n == "object" || n == "function");
993
- }
994
- function D(e) {
995
- return e != null && typeof e == "object";
996
- }
997
- function Tr(e) {
998
- if (!D(e) || W(e) != de)
999
- return !1;
1000
- var n = Te(e);
1001
- if (n === null)
1002
- return !0;
1003
- var a = j.call(n, "constructor") && n.constructor;
1004
- return typeof a == "function" && a instanceof a && q.call(a) == wt;
1005
- }
1006
- var Ee = ye ? bt(ye) : Qt;
1007
- function kr(e) {
1008
- return ir(e, Re(e));
1009
- }
1010
- function Re(e) {
1011
- return ie(e) ? Wt(e) : Vt(e);
1012
- }
1013
- var Ar = lr(function(e, n, a, c) {
1014
- Oe(e, n, a, c);
1015
- });
1016
- function Ir(e) {
1017
- return function() {
1018
- return e;
1019
- };
882
+ });
1020
883
  }
1021
- function Pe(e) {
1022
- return e;
1023
- }
1024
- function Sr() {
1025
- return !1;
1026
- }
1027
- o.exports = Ar;
1028
- })(Q, Q.exports);
1029
- var An = Q.exports;
1030
- const In = /* @__PURE__ */ kn(An);
1031
- function Sn(o) {
1032
- let r = {};
1033
- function t(s, i) {
1034
- if ((i == null ? void 0 : i.type) === "AwaitExpression" && i.argument.type === "CallExpression" && i.argument.callee.type === "Identifier" && i.argument.callee.name === "useStoryblok") {
1035
- const l = i.argument.arguments;
1036
- if (l && l[1].type === "ObjectExpression") {
1037
- const u = He(l[1].properties);
1038
- r = {
1039
- ...r,
1040
- apiOptions: u
884
+ throttledRequest(e, t, s, r) {
885
+ return this.client.setFetchOptions(r), this.client[e](t, s);
886
+ }
887
+ cacheVersions() {
888
+ return y;
889
+ }
890
+ cacheVersion() {
891
+ return y[this.accessToken];
892
+ }
893
+ setCacheVersion(e) {
894
+ this.accessToken && (y[this.accessToken] = e);
895
+ }
896
+ clearCacheVersion() {
897
+ this.accessToken && (y[this.accessToken] = 0);
898
+ }
899
+ cacheProvider() {
900
+ switch (this.cache.type) {
901
+ case "memory":
902
+ return {
903
+ get(e) {
904
+ return Promise.resolve(m[e]);
905
+ },
906
+ getAll() {
907
+ return Promise.resolve(m);
908
+ },
909
+ set(e, t) {
910
+ return m[e] = t, Promise.resolve(void 0);
911
+ },
912
+ flush() {
913
+ return m = {}, Promise.resolve(void 0);
914
+ }
1041
915
  };
1042
- }
1043
- if (l && l[2].type === "ObjectExpression") {
1044
- const u = He(l[2].properties);
1045
- r = {
1046
- ...r,
1047
- bridgeOptions: u
916
+ case "custom":
917
+ if (this.cache.custom) return this.cache.custom;
918
+ default:
919
+ return {
920
+ get() {
921
+ return Promise.resolve();
922
+ },
923
+ getAll() {
924
+ return Promise.resolve(void 0);
925
+ },
926
+ set() {
927
+ return Promise.resolve(void 0);
928
+ },
929
+ flush() {
930
+ return Promise.resolve(void 0);
931
+ }
1048
932
  };
1049
- }
1050
933
  }
1051
934
  }
1052
- return In({}, o, t), r;
1053
- }
1054
- function He(o) {
1055
- const r = {};
1056
- return o.reduce((t, s) => {
1057
- if (s.type !== "Property") return t;
1058
- const { key: i, value: l } = s, { type: u } = l;
1059
- if (i.type !== "Identifier") return t;
1060
- if (u === "Literal")
1061
- t[i.name] = l.value;
1062
- else if (u === "ArrayExpression") {
1063
- const f = l.elements.reduce((p, y) => y.type === "Literal" && y.value ? [...p, y.value] : p, []);
1064
- t[i.name] = f;
1065
- }
1066
- return t;
1067
- }, r);
935
+ async flushCache() {
936
+ return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
937
+ }
1068
938
  }
1069
- let B = [];
1070
- function On(o, r) {
1071
- const t = "virtual:storyblok-bridge", s = "\0" + t;
1072
- if (!o || r !== "server")
1073
- return {
1074
- name: "vite-plugin-storyblok-bridge",
1075
- resolveId(f) {
1076
- if (f === t)
1077
- return s;
1078
- },
1079
- load(f) {
1080
- if (f === s)
1081
- return "export const bridgeOptions = null";
1082
- }
939
+ const Ie = (o = {}) => {
940
+ const { apiOptions: e } = o;
941
+ if (!e.accessToken) {
942
+ console.error(
943
+ "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
944
+ );
945
+ return;
946
+ }
947
+ return { storyblokApi: new Ae(e) };
948
+ }, Me = (o) => {
949
+ if (typeof o != "object" || typeof o._editable > "u")
950
+ return {};
951
+ try {
952
+ const e = JSON.parse(
953
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
954
+ );
955
+ return e ? {
956
+ "data-blok-c": JSON.stringify(e),
957
+ "data-blok-uid": e.id + "-" + e.uid
958
+ } : {};
959
+ } catch {
960
+ return {};
961
+ }
962
+ };
963
+ let S, T = "https://app.storyblok.com/f/storyblok-v2-latest.js";
964
+ const xe = (o = {}) => {
965
+ var e, t;
966
+ const {
967
+ bridge: s,
968
+ accessToken: r,
969
+ use: n = [],
970
+ apiOptions: i = {},
971
+ richText: l = {},
972
+ bridgeUrl: a
973
+ } = o;
974
+ i.accessToken = i.accessToken || r;
975
+ const c = { bridge: s, apiOptions: i };
976
+ let h = {};
977
+ n.forEach((p) => {
978
+ h = { ...h, ...p(c) };
979
+ }), a && (T = a);
980
+ const u = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
981
+ return s !== !1 && u && M(T), S = new k(l.schema), l.resolver && U(S, l.resolver), h;
982
+ }, U = (o, e) => {
983
+ o.addNode("blok", (t) => {
984
+ let s = "";
985
+ return t.attrs.body.forEach((r) => {
986
+ s += e(r.component, r);
987
+ }), {
988
+ html: s
1083
989
  };
1084
- let i = [], l = null, u;
1085
- return {
1086
- name: "vite-plugin-storyblok-bridge",
1087
- async resolveId(f) {
1088
- if (f === t)
1089
- return s;
1090
- },
1091
- async transform(f, p) {
1092
- var O;
1093
- if (p.includes("node_modules") && !p.includes("/pages/") || !f.includes("useStoryblok") || !((O = this.getModuleInfo(p).meta) != null && O.astro)) return;
1094
- const [, ..._] = p.split("src/pages/"), k = _.join("/").replace(".astro", ""), A = Sn(this.parse(f));
1095
- B.length && (i = B.filter((w) => w.url !== k)), i.push({
1096
- url: k,
1097
- options: A
1098
- }), l && (u && clearTimeout(u), u = setTimeout(() => {
1099
- Cn(B, i) || (B.length !== 0 && (l.restart(), console.info("Bridge options updated. Restarting...")), B = [...i]);
1100
- }, 1e3));
1101
- },
1102
- async load(f) {
1103
- if (f === s)
1104
- return `export const bridgeOptions = ${JSON.stringify(Tn(i))}`;
1105
- },
1106
- configureServer(f) {
1107
- l = f;
1108
- }
1109
- };
1110
- }
1111
- function Cn(o = [], r = []) {
1112
- return r.every(({ url: t, options: s }) => {
1113
- const i = o.find((l) => (l == null ? void 0 : l.url) === t);
1114
- return i && JSON.stringify(s) === JSON.stringify(i.options);
1115
990
  });
991
+ }, Oe = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ee = (o, e, t) => {
992
+ let s = t || S;
993
+ if (!s) {
994
+ console.error(
995
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
996
+ );
997
+ return;
998
+ }
999
+ return Oe(o) ? "" : (e && (s = new k(e.schema), e.resolver && U(s, e.resolver)), s.render(o, {}, !1));
1000
+ }, Ue = () => M(T);
1001
+ function Le(o) {
1002
+ return typeof o == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(o)});` : "const storyblokInstance = new StoryblokBridge();";
1116
1003
  }
1117
- let qe;
1118
- async function Rn(o) {
1119
- const { action: r, story: t } = o || {};
1120
- if (r === "input" && t) {
1004
+ const je = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1005
+ <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1006
+ <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
1007
+ <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
1008
+ <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
1009
+ <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
1010
+ </g>
1011
+ </g>
1012
+ </g>
1013
+ </svg>`;
1014
+ let P;
1015
+ async function Be(o) {
1016
+ const { action: e, story: t } = o || {};
1017
+ if (e === "input" && t) {
1121
1018
  const s = async () => {
1122
- const l = await xn(t), u = document.body;
1123
- if (l.outerHTML === u.outerHTML) return;
1124
- const f = document.querySelector('[data-blok-focused="true"]');
1125
- jn(u, l, f);
1019
+ const n = await Ne(t), i = document.body;
1020
+ if (n.outerHTML === i.outerHTML) return;
1021
+ const l = document.querySelector('[data-blok-focused="true"]');
1022
+ Pe(i, n, l), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
1126
1023
  };
1127
- clearTimeout(qe), qe = setTimeout(s, 500);
1024
+ clearTimeout(P), P = setTimeout(s, 500);
1128
1025
  }
1129
1026
  ["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
1130
1027
  }
1131
- function jn(o, r, t) {
1028
+ function Pe(o, e, t) {
1132
1029
  if (t) {
1133
- const s = t.getAttribute("data-blok-uid"), i = r.querySelector(
1030
+ const s = t.getAttribute("data-blok-uid"), r = e.querySelector(
1134
1031
  `[data-blok-uid="${s}"]`
1135
1032
  );
1136
- i && (i.setAttribute("data-blok-focused", "true"), t.replaceWith(i));
1033
+ r && (r.setAttribute("data-blok-focused", "true"), t.replaceWith(r));
1137
1034
  } else
1138
- o.replaceWith(r);
1035
+ o.replaceWith(e);
1139
1036
  }
1140
- async function xn(o) {
1037
+ async function Ne(o) {
1141
1038
  const t = await (await fetch(location.href, {
1142
1039
  method: "POST",
1143
1040
  body: JSON.stringify({
@@ -1150,25 +1047,60 @@ async function xn(o) {
1150
1047
  })).text();
1151
1048
  return new DOMParser().parseFromString(t, "text/html").body;
1152
1049
  }
1153
- function Pn() {
1050
+ async function He(o) {
1051
+ const { story: e } = o || {};
1052
+ await fetch(location.origin + "/_refresh", {
1053
+ method: "POST",
1054
+ body: JSON.stringify(e),
1055
+ headers: {
1056
+ "Content-Type": "application/json"
1057
+ }
1058
+ });
1059
+ }
1060
+ function ze(o) {
1061
+ const { storyblokApi: e } = xe({
1062
+ accessToken: o.STORYBLOK_TOKEN,
1063
+ use: [Ie]
1064
+ });
1065
+ return {
1066
+ name: "story-loader",
1067
+ load: async ({ store: t, meta: s, logger: r, refreshContextData: n }) => {
1068
+ if (!e)
1069
+ throw new Error("storyblokApi is not loaded");
1070
+ if (n != null && n.story) {
1071
+ r.info("Syncing... story updated in Storyblok");
1072
+ const h = n.story;
1073
+ t.set({
1074
+ data: h,
1075
+ id: h.uuid
1076
+ });
1077
+ return;
1078
+ }
1079
+ r.info("Loading stories");
1080
+ const i = s.get("lastPublishedAt"), l = i && o.version === "published" ? { published_at_gt: i } : {}, a = await (e == null ? void 0 : e.getAll("cdn/stories", {
1081
+ version: o.version,
1082
+ ...l
1083
+ }));
1084
+ console.log("total = ", a.length), r.info("Clearing store"), o.version === "draft" && t.clear();
1085
+ let c = i ? new Date(i) : null;
1086
+ for (const h of a) {
1087
+ const u = h.published_at ? new Date(h.published_at) : null;
1088
+ u && (!c || u > c) && (c = u), t.set({
1089
+ data: h,
1090
+ id: h.uuid
1091
+ }), c && s.set("lastPublishedAt", c.toISOString());
1092
+ }
1093
+ }
1094
+ };
1095
+ }
1096
+ function De() {
1154
1097
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
1155
1098
  }
1156
- async function Mn(o, r = {}, t = {}, s) {
1157
- globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
1158
- let i = null;
1159
- if (s && s.locals._storyblok_preview_data)
1160
- i = s.locals._storyblok_preview_data;
1161
- else {
1162
- const { data: l } = await globalThis.storyblokApiInstance.get(
1163
- o,
1164
- r,
1165
- t
1166
- );
1167
- i = l.story;
1168
- }
1169
- return i;
1099
+ async function Fe(o) {
1100
+ let e = null;
1101
+ return o && o.locals._storyblok_preview_data && (e = o.locals._storyblok_preview_data), e;
1170
1102
  }
1171
- function Nn(o, r) {
1103
+ function Je(o, e) {
1172
1104
  const t = globalThis.storyblokApiInstance.richTextResolver;
1173
1105
  if (!t) {
1174
1106
  console.error(
@@ -1176,75 +1108,70 @@ function Nn(o, r) {
1176
1108
  );
1177
1109
  return;
1178
1110
  }
1179
- return wn(o, r, t);
1111
+ return Ee(o, e, t);
1180
1112
  }
1181
- function zn(o) {
1182
- const r = {
1183
- useCustomApi: !1,
1184
- bridge: !0,
1185
- componentsDir: "src",
1186
- enableFallbackComponent: !1,
1187
- livePreview: !1,
1188
- ...o
1189
- };
1113
+ function qe({
1114
+ useCustomApi: o = !1,
1115
+ bridge: e = !0,
1116
+ componentsDir: t = "src",
1117
+ enableFallbackComponent: s = !1,
1118
+ livePreview: r = !1,
1119
+ contentLayer: n = !1,
1120
+ ...i
1121
+ }) {
1122
+ const l = {
1123
+ useCustomApi: o,
1124
+ bridge: e,
1125
+ componentsDir: t,
1126
+ enableFallbackComponent: s,
1127
+ livePreview: r,
1128
+ contentLayer: n,
1129
+ ...i
1130
+ }, a = Le(e);
1190
1131
  return {
1191
1132
  name: "@storyblok/astro",
1192
1133
  hooks: {
1193
1134
  "astro:config:setup": ({
1194
- injectScript: t,
1195
- updateConfig: s,
1196
- addDevToolbarApp: i,
1197
- addMiddleware: l,
1198
- config: u
1135
+ injectScript: c,
1136
+ updateConfig: h,
1137
+ addDevToolbarApp: u,
1138
+ addMiddleware: p,
1139
+ config: f
1199
1140
  }) => {
1200
- if (s({
1141
+ if (h({
1201
1142
  vite: {
1202
1143
  plugins: [
1203
- Or(
1204
- r.accessToken,
1205
- r.useCustomApi,
1206
- r.apiOptions
1144
+ B(
1145
+ l.accessToken,
1146
+ l.useCustomApi,
1147
+ l.apiOptions
1207
1148
  ),
1208
- Pr(
1209
- r.componentsDir,
1210
- r.components,
1211
- r.enableFallbackComponent,
1212
- r.customFallbackComponent
1149
+ V(
1150
+ l.componentsDir,
1151
+ l.components,
1152
+ l.enableFallbackComponent,
1153
+ l.customFallbackComponent
1213
1154
  ),
1214
- Mr(r),
1215
- On(
1216
- r.livePreview,
1217
- u.output
1218
- )
1155
+ K(l)
1219
1156
  ]
1220
1157
  }
1221
- }), r.livePreview && (u == null ? void 0 : u.output) !== "server")
1158
+ }), l.livePreview && (f == null ? void 0 : f.output) !== "server")
1222
1159
  throw new Error(
1223
1160
  "To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
1224
1161
  );
1225
- if (t(
1162
+ c(
1226
1163
  "page-ssr",
1227
1164
  `
1228
1165
  import { storyblokApiInstance } from "virtual:storyblok-init";
1229
1166
  globalThis.storyblokApiInstance = storyblokApiInstance;
1230
1167
  `
1231
- ), r.bridge && !r.livePreview) {
1232
- let f = "";
1233
- if (typeof r.bridge == "object") {
1234
- const p = { ...r.bridge };
1235
- f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
1236
- p
1237
- )});`;
1238
- } else
1239
- f = "const storyblokInstance = new StoryblokBridge()";
1240
- t(
1241
- "page",
1242
- `
1168
+ ), e && !r && c(
1169
+ "page",
1170
+ `
1243
1171
  import { loadStoryblokBridge } from "@storyblok/astro";
1244
1172
  loadStoryblokBridge().then(() => {
1245
1173
  const { StoryblokBridge, location } = window;
1246
- ${f}
1247
-
1174
+ ${a}
1248
1175
  storyblokInstance.on(["published", "change"], (event) => {
1249
1176
  if (!event.slugChanged) {
1250
1177
  location.reload(true);
@@ -1252,38 +1179,80 @@ function zn(o) {
1252
1179
  });
1253
1180
  });
1254
1181
  `
1255
- );
1256
- }
1257
- r.livePreview && (t(
1182
+ ), r && (c(
1258
1183
  "page",
1259
1184
  `
1260
1185
  import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
1261
- import { bridgeOptions } from "virtual:storyblok-bridge";
1262
1186
  console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
1263
1187
  loadStoryblokBridge().then(() => {
1264
1188
  const { StoryblokBridge, location } = window;
1265
- if(bridgeOptions){
1266
- const storyblokInstance = new StoryblokBridge(bridgeOptions);
1267
- storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
1268
- };
1189
+ ${a}
1190
+ storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
1269
1191
  });
1270
1192
  `
1271
- ), l({
1193
+ ), p({
1272
1194
  entrypoint: "@storyblok/astro/middleware.ts",
1273
1195
  order: "pre"
1274
- })), i("@storyblok/astro/toolbarApp.ts");
1275
- }
1196
+ })), n && c(
1197
+ "page",
1198
+ `
1199
+ import { loadStoryblokBridge, syncContentUpdate } from "@storyblok/astro";
1200
+ loadStoryblokBridge().then(() => {
1201
+ const { StoryblokBridge } = window;
1202
+ const storyblokInstance = new StoryblokBridge()
1203
+ storyblokInstance.on(["published", "change", "input"], syncContentUpdate);
1204
+ });
1205
+ `
1206
+ ), u({
1207
+ id: "storyblok",
1208
+ name: "Storyblok",
1209
+ icon: je,
1210
+ entrypoint: "@storyblok/astro/toolbarApp.ts"
1211
+ });
1212
+ },
1213
+ ...n ? {
1214
+ "astro:server:setup": async ({ server: c, refreshContent: h }) => {
1215
+ c.middlewares.use("/_refresh", async (u, p) => {
1216
+ if (u.method !== "POST") {
1217
+ p.writeHead(405, { "Content-Type": "application/json" }), p.end(JSON.stringify({ error: "Method Not Allowed" }));
1218
+ return;
1219
+ }
1220
+ let f = [];
1221
+ u.on("data", (g) => f.push(g)), u.on("end", async () => {
1222
+ try {
1223
+ const g = JSON.parse(Buffer.concat(f).toString());
1224
+ await (h == null ? void 0 : h({
1225
+ context: { story: g },
1226
+ loaders: ["story-loader"]
1227
+ })), p.writeHead(200, { "Content-Type": "application/json" }), p.end(
1228
+ JSON.stringify({
1229
+ message: "Content refreshed successfully"
1230
+ })
1231
+ );
1232
+ } catch (g) {
1233
+ p.writeHead(500, { "Content-Type": "application/json" }), p.end(
1234
+ JSON.stringify({
1235
+ error: `Failed to refresh content: ${g.message}`
1236
+ })
1237
+ );
1238
+ }
1239
+ });
1240
+ });
1241
+ }
1242
+ } : {}
1276
1243
  }
1277
1244
  };
1278
1245
  }
1279
1246
  export {
1280
- bn as RichTextResolver,
1281
- pn as RichTextSchema,
1282
- zn as default,
1283
- Rn as handleStoryblokMessage,
1284
- En as loadStoryblokBridge,
1285
- Nn as renderRichText,
1286
- $n as storyblokEditable,
1287
- Mn as useStoryblok,
1288
- Pn as useStoryblokApi
1247
+ k as RichTextResolver,
1248
+ Te as RichTextSchema,
1249
+ qe as default,
1250
+ Fe as getLiveStory,
1251
+ Be as handleStoryblokMessage,
1252
+ Ue as loadStoryblokBridge,
1253
+ Je as renderRichText,
1254
+ Me as storyblokEditable,
1255
+ ze as storyblokLoader,
1256
+ He as syncContentUpdate,
1257
+ De as useStoryblokApi
1289
1258
  };