@storyblok/astro 1.0.1 → 1.1.1

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,57 +1,77 @@
1
- import S from "axios";
2
- function x(n) {
3
- const t = "virtual:storyblok-components", e = "\0" + t;
1
+ import N from "axios";
2
+ const L = /[\p{Lu}]/u, M = /[\p{Ll}]/u, v = /^[\p{Lu}](?![\p{Lu}])/gu, O = /([\p{Alpha}\p{N}_]|$)/u, k = /[_.\- ]+/, U = new RegExp("^" + k.source), b = new RegExp(k.source + O.source, "gu"), T = new RegExp("\\d+" + O.source, "gu"), D = (s, e, t) => {
3
+ let r = !1, o = !1, n = !1;
4
+ for (let i = 0; i < s.length; i++) {
5
+ const a = s[i];
6
+ r && L.test(a) ? (s = s.slice(0, i) + "-" + s.slice(i), r = !1, n = o, o = !0, i++) : o && n && M.test(a) ? (s = s.slice(0, i - 1) + "-" + s.slice(i - 1), n = o, o = !1, r = !0) : (r = e(a) === a && t(a) !== a, n = o, o = t(a) === a && e(a) !== a);
7
+ }
8
+ return s;
9
+ }, q = (s, e) => (v.lastIndex = 0, s.replace(v, (t) => e(t))), B = (s, e) => (b.lastIndex = 0, T.lastIndex = 0, s.replace(b, (t, r) => e(r)).replace(T, (t) => e(t)));
10
+ function _(s, e) {
11
+ if (!(typeof s == "string" || Array.isArray(s)))
12
+ throw new TypeError("Expected the input to be `string | string[]`");
13
+ if (e = {
14
+ pascalCase: !1,
15
+ preserveConsecutiveUppercase: !1,
16
+ ...e
17
+ }, Array.isArray(s) ? s = s.map((n) => n.trim()).filter((n) => n.length).join("-") : s = s.trim(), s.length === 0)
18
+ return "";
19
+ const t = e.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(e.locale), r = e.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(e.locale);
20
+ return s.length === 1 ? k.test(s) ? "" : e.pascalCase ? r(s) : t(s) : (s !== t(s) && (s = D(s, t, r)), s = s.replace(U, ""), s = e.preserveConsecutiveUppercase ? q(s, t) : t(s), e.pascalCase && (s = r(s.charAt(0)) + s.slice(1)), B(s, r));
21
+ }
22
+ function z(s) {
23
+ const e = "virtual:storyblok-components", t = "\0" + e;
4
24
  return {
5
25
  name: "vite-plugin-storyblok",
6
26
  async resolveId(r) {
7
- if (r === t)
8
- return e;
27
+ if (r === e)
28
+ return t;
9
29
  },
10
30
  async load(r) {
11
- if (r === e) {
12
- const s = [];
13
- for await (const [o, a] of Object.entries(n)) {
14
- const { id: i } = await this.resolve("/src/" + a + ".astro");
15
- s.push(`import ${o} from "${i}"`);
31
+ if (r === t) {
32
+ const o = [];
33
+ for await (const [n, i] of Object.entries(s)) {
34
+ const { id: a } = await this.resolve("/src/" + i + ".astro");
35
+ o.push(`import ${_(n)} from "${a}"`);
16
36
  }
17
- return `${s.join(";")};export default {${Object.keys(n).join(",")}}`;
37
+ return `${o.join(";")};export default {${Object.keys(s).map((n) => _(n)).join(",")}}`;
18
38
  }
19
39
  }
20
40
  };
21
41
  }
22
- var A = Object.defineProperty, P = Object.defineProperties, M = Object.getOwnPropertyDescriptors, k = Object.getOwnPropertySymbols, C = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? A(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, u = (n, t) => {
23
- for (var e in t || (t = {}))
24
- C.call(t, e) && b(n, e, t[e]);
25
- if (k)
26
- for (var e of k(t))
27
- I.call(t, e) && b(n, e, t[e]);
28
- return n;
29
- }, y = (n, t) => P(n, M(t));
30
- let v = !1;
31
- const T = [], w = (n) => new Promise((t, e) => {
32
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
42
+ var H = Object.defineProperty, V = Object.defineProperties, F = Object.getOwnPropertyDescriptors, R = Object.getOwnPropertySymbols, J = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable, w = (s, e, t) => e in s ? H(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, u = (s, e) => {
43
+ for (var t in e || (e = {}))
44
+ J.call(e, t) && w(s, t, e[t]);
45
+ if (R)
46
+ for (var t of R(e))
47
+ G.call(e, t) && w(s, t, e[t]);
48
+ return s;
49
+ }, g = (s, e) => V(s, F(e));
50
+ let E = !1;
51
+ const A = [], S = (s) => new Promise((e, t) => {
52
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
33
53
  if (window.location === window.parent.location) {
34
54
  console.warn("You are not in Draft Mode or in the Visual Editor.");
35
55
  return;
36
56
  }
37
- v ? s() : T.push(s);
57
+ E ? o() : A.push(o);
38
58
  }, document.getElementById("storyblok-javascript-bridge")))
39
59
  return;
40
60
  const r = document.createElement("script");
41
- r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
42
- T.forEach((o) => o()), v = !0, t(s);
61
+ r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (o) => t(o), r.onload = (o) => {
62
+ A.forEach((n) => n()), E = !0, e(o);
43
63
  }, document.getElementsByTagName("head")[0].appendChild(r);
44
- }), N = function(n, t) {
45
- if (!n)
64
+ }), K = function(s, e) {
65
+ if (!s)
46
66
  return null;
47
- let e = {};
48
- for (let r in n) {
49
- let s = n[r];
50
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
51
- }
52
- return e;
53
- }, q = (n) => n === "email";
54
- var B = {
67
+ let t = {};
68
+ for (let r in s) {
69
+ let o = s[r];
70
+ e.indexOf(r) > -1 && o !== null && (t[r] = o);
71
+ }
72
+ return t;
73
+ }, Y = (s) => s === "email";
74
+ var W = {
55
75
  nodes: {
56
76
  horizontal_rule() {
57
77
  return {
@@ -68,13 +88,13 @@ var B = {
68
88
  tag: "ul"
69
89
  };
70
90
  },
71
- code_block(n) {
91
+ code_block(s) {
72
92
  return {
73
93
  tag: [
74
94
  "pre",
75
95
  {
76
96
  tag: "code",
77
- attrs: n.attrs
97
+ attrs: s.attrs
78
98
  }
79
99
  ]
80
100
  };
@@ -84,17 +104,17 @@ var B = {
84
104
  singleTag: "br"
85
105
  };
86
106
  },
87
- heading(n) {
107
+ heading(s) {
88
108
  return {
89
- tag: `h${n.attrs.level}`
109
+ tag: `h${s.attrs.level}`
90
110
  };
91
111
  },
92
- image(n) {
112
+ image(s) {
93
113
  return {
94
114
  singleTag: [
95
115
  {
96
116
  tag: "img",
97
- attrs: N(n.attrs, ["src", "alt", "title"])
117
+ attrs: K(s.attrs, ["src", "alt", "title"])
98
118
  }
99
119
  ]
100
120
  };
@@ -146,100 +166,100 @@ var B = {
146
166
  tag: "i"
147
167
  };
148
168
  },
149
- link(n) {
150
- const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
151
- return q(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
169
+ link(s) {
170
+ const e = u({}, s.attrs), { linktype: t = "url" } = s.attrs;
171
+ return Y(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
152
172
  tag: [
153
173
  {
154
174
  tag: "a",
155
- attrs: t
175
+ attrs: e
156
176
  }
157
177
  ]
158
178
  };
159
179
  },
160
- styled(n) {
180
+ styled(s) {
161
181
  return {
162
182
  tag: [
163
183
  {
164
184
  tag: "span",
165
- attrs: n.attrs
185
+ attrs: s.attrs
166
186
  }
167
187
  ]
168
188
  };
169
189
  }
170
190
  }
171
191
  };
172
- const L = function(n) {
173
- const t = {
192
+ const Q = function(s) {
193
+ const e = {
174
194
  "&": "&amp;",
175
195
  "<": "&lt;",
176
196
  ">": "&gt;",
177
197
  '"': "&quot;",
178
198
  "'": "&#39;"
179
- }, e = /[&<>"']/g, r = RegExp(e.source);
180
- return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
199
+ }, t = /[&<>"']/g, r = RegExp(t.source);
200
+ return s && r.test(s) ? s.replace(t, (o) => e[o]) : s;
181
201
  };
182
- class R {
183
- constructor(t) {
184
- t || (t = B), this.marks = t.marks || [], this.nodes = t.nodes || [];
185
- }
186
- addNode(t, e) {
187
- this.nodes[t] = e;
188
- }
189
- addMark(t, e) {
190
- this.marks[t] = e;
191
- }
192
- render(t = {}) {
193
- if (t.content && Array.isArray(t.content)) {
194
- let e = "";
195
- return t.content.forEach((r) => {
196
- e += this.renderNode(r);
197
- }), e;
202
+ class x {
203
+ constructor(e) {
204
+ e || (e = W), this.marks = e.marks || [], this.nodes = e.nodes || [];
205
+ }
206
+ addNode(e, t) {
207
+ this.nodes[e] = t;
208
+ }
209
+ addMark(e, t) {
210
+ this.marks[e] = t;
211
+ }
212
+ render(e = {}) {
213
+ if (e.content && Array.isArray(e.content)) {
214
+ let t = "";
215
+ return e.content.forEach((r) => {
216
+ t += this.renderNode(r);
217
+ }), t;
198
218
  }
199
219
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
200
220
  }
201
- renderNode(t) {
202
- let e = [];
203
- t.marks && t.marks.forEach((s) => {
204
- const o = this.getMatchingMark(s);
205
- o && e.push(this.renderOpeningTag(o.tag));
221
+ renderNode(e) {
222
+ let t = [];
223
+ e.marks && e.marks.forEach((o) => {
224
+ const n = this.getMatchingMark(o);
225
+ n && t.push(this.renderOpeningTag(n.tag));
206
226
  });
207
- const r = this.getMatchingNode(t);
208
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
209
- e.push(this.renderNode(s));
210
- }) : t.text ? e.push(L(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
211
- const o = this.getMatchingMark(s);
212
- o && e.push(this.renderClosingTag(o.tag));
213
- }), e.join("");
214
- }
215
- renderTag(t, e) {
216
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
217
- if (s.constructor === String)
218
- return `<${s}${e}>`;
227
+ const r = this.getMatchingNode(e);
228
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
229
+ t.push(this.renderNode(o));
230
+ }) : e.text ? t.push(Q(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
231
+ const n = this.getMatchingMark(o);
232
+ n && t.push(this.renderClosingTag(n.tag));
233
+ }), t.join("");
234
+ }
235
+ renderTag(e, t) {
236
+ return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
237
+ if (o.constructor === String)
238
+ return `<${o}${t}>`;
219
239
  {
220
- let o = `<${s.tag}`;
221
- if (s.attrs)
222
- for (let a in s.attrs) {
223
- let i = s.attrs[a];
224
- i !== null && (o += ` ${a}="${i}"`);
240
+ let n = `<${o.tag}`;
241
+ if (o.attrs)
242
+ for (let i in o.attrs) {
243
+ let a = o.attrs[i];
244
+ a !== null && (n += ` ${i}="${a}"`);
225
245
  }
226
- return `${o}${e}>`;
246
+ return `${n}${t}>`;
227
247
  }
228
248
  }).join("");
229
249
  }
230
- renderOpeningTag(t) {
231
- return this.renderTag(t, "");
250
+ renderOpeningTag(e) {
251
+ return this.renderTag(e, "");
232
252
  }
233
- renderClosingTag(t) {
234
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
253
+ renderClosingTag(e) {
254
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
235
255
  }
236
- getMatchingNode(t) {
237
- if (typeof this.nodes[t.type] == "function")
238
- return this.nodes[t.type](t);
256
+ getMatchingNode(e) {
257
+ if (typeof this.nodes[e.type] == "function")
258
+ return this.nodes[e.type](e);
239
259
  }
240
- getMatchingMark(t) {
241
- if (typeof this.marks[t.type] == "function")
242
- return this.marks[t.type](t);
260
+ getMatchingMark(e) {
261
+ if (typeof this.marks[e.type] == "function")
262
+ return this.marks[e.type](e);
243
263
  }
244
264
  }
245
265
  /*!
@@ -247,319 +267,319 @@ class R {
247
267
  * Universal JavaScript SDK for Storyblok's API
248
268
  * (c) 2020-2022 Stobylok Team
249
269
  */
250
- function _(n) {
251
- return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
270
+ function $(s) {
271
+ return typeof s == "number" && s == s && s !== 1 / 0 && s !== -1 / 0;
252
272
  }
253
- function $(n, t, e) {
254
- if (!_(t))
273
+ function C(s, e, t) {
274
+ if (!$(e))
255
275
  throw new TypeError("Expected `limit` to be a finite number");
256
- if (!_(e))
276
+ if (!$(t))
257
277
  throw new TypeError("Expected `interval` to be a finite number");
258
- var r = [], s = [], o = 0, a = function() {
259
- o++;
278
+ var r = [], o = [], n = 0, i = function() {
279
+ n++;
260
280
  var c = setTimeout(function() {
261
- o--, r.length > 0 && a(), s = s.filter(function(h) {
281
+ n--, r.length > 0 && i(), o = o.filter(function(h) {
262
282
  return h !== c;
263
283
  });
264
- }, e);
265
- s.indexOf(c) < 0 && s.push(c);
284
+ }, t);
285
+ o.indexOf(c) < 0 && o.push(c);
266
286
  var l = r.shift();
267
- l.resolve(n.apply(l.self, l.args));
268
- }, i = function() {
287
+ l.resolve(s.apply(l.self, l.args));
288
+ }, a = function() {
269
289
  var c = arguments, l = this;
270
290
  return new Promise(function(h, p) {
271
- r.push({ resolve: h, reject: p, args: c, self: l }), o < t && a();
291
+ r.push({ resolve: h, reject: p, args: c, self: l }), n < e && i();
272
292
  });
273
293
  };
274
- return i.abort = function() {
275
- s.forEach(clearTimeout), s = [], r.forEach(function(c) {
294
+ return a.abort = function() {
295
+ o.forEach(clearTimeout), o = [], r.forEach(function(c) {
276
296
  c.reject(new throttle.AbortError());
277
297
  }), r.length = 0;
278
- }, i;
298
+ }, a;
279
299
  }
280
- $.AbortError = function() {
300
+ C.AbortError = function() {
281
301
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
282
302
  };
283
- const z = function(n, t) {
284
- if (!n)
303
+ const X = function(s, e) {
304
+ if (!s)
285
305
  return null;
286
- let e = {};
287
- for (let r in n) {
288
- let s = n[r];
289
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
306
+ let t = {};
307
+ for (let r in s) {
308
+ let o = s[r];
309
+ e.indexOf(r) > -1 && o !== null && (t[r] = o);
290
310
  }
291
- return e;
311
+ return t;
292
312
  };
293
- var U = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: z(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
294
- const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
295
- return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
296
- }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
297
- class H {
298
- constructor(t) {
299
- t || (t = U), this.marks = t.marks || [], this.nodes = t.nodes || [];
300
- }
301
- addNode(t, e) {
302
- this.nodes[t] = e;
303
- }
304
- addMark(t, e) {
305
- this.marks[t] = e;
306
- }
307
- render(t = {}) {
308
- if (t.content && Array.isArray(t.content)) {
309
- let e = "";
310
- return t.content.forEach((r) => {
311
- e += this.renderNode(r);
312
- }), e;
313
+ var Z = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (s) => ({ tag: ["pre", { tag: "code", attrs: s.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (s) => ({ tag: `h${s.attrs.level}` }), image: (s) => ({ singleTag: [{ tag: "img", attrs: X(s.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(s) {
314
+ const e = u({}, s.attrs), { linktype: t = "url" } = s.attrs;
315
+ return t === "email" && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), { tag: [{ tag: "a", attrs: e }] };
316
+ }, styled: (s) => ({ tag: [{ tag: "span", attrs: s.attrs }] }) } };
317
+ class ee {
318
+ constructor(e) {
319
+ e || (e = Z), this.marks = e.marks || [], this.nodes = e.nodes || [];
320
+ }
321
+ addNode(e, t) {
322
+ this.nodes[e] = t;
323
+ }
324
+ addMark(e, t) {
325
+ this.marks[e] = t;
326
+ }
327
+ render(e = {}) {
328
+ if (e.content && Array.isArray(e.content)) {
329
+ let t = "";
330
+ return e.content.forEach((r) => {
331
+ t += this.renderNode(r);
332
+ }), t;
313
333
  }
314
334
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
315
335
  }
316
- renderNode(t) {
317
- let e = [];
318
- t.marks && t.marks.forEach((s) => {
319
- const o = this.getMatchingMark(s);
320
- o && e.push(this.renderOpeningTag(o.tag));
336
+ renderNode(e) {
337
+ let t = [];
338
+ e.marks && e.marks.forEach((o) => {
339
+ const n = this.getMatchingMark(o);
340
+ n && t.push(this.renderOpeningTag(n.tag));
321
341
  });
322
- const r = this.getMatchingNode(t);
323
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
324
- e.push(this.renderNode(s));
325
- }) : t.text ? e.push(function(s) {
326
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
327
- return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
328
- }(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
329
- const o = this.getMatchingMark(s);
330
- o && e.push(this.renderClosingTag(o.tag));
331
- }), e.join("");
332
- }
333
- renderTag(t, e) {
334
- return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
342
+ const r = this.getMatchingNode(e);
343
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
344
+ t.push(this.renderNode(o));
345
+ }) : e.text ? t.push(function(o) {
346
+ const n = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, i = /[&<>"']/g, a = RegExp(i.source);
347
+ return o && a.test(o) ? o.replace(i, (c) => n[c]) : o;
348
+ }(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
349
+ const n = this.getMatchingMark(o);
350
+ n && t.push(this.renderClosingTag(n.tag));
351
+ }), t.join("");
352
+ }
353
+ renderTag(e, t) {
354
+ return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
335
355
  if (r.constructor === String)
336
- return `<${r}${e}>`;
356
+ return `<${r}${t}>`;
337
357
  {
338
- let s = `<${r.tag}`;
358
+ let o = `<${r.tag}`;
339
359
  if (r.attrs)
340
- for (let o in r.attrs) {
341
- let a = r.attrs[o];
342
- a !== null && (s += ` ${o}="${a}"`);
360
+ for (let n in r.attrs) {
361
+ let i = r.attrs[n];
362
+ i !== null && (o += ` ${n}="${i}"`);
343
363
  }
344
- return `${s}${e}>`;
364
+ return `${o}${t}>`;
345
365
  }
346
366
  }).join("");
347
367
  }
348
- renderOpeningTag(t) {
349
- return this.renderTag(t, "");
368
+ renderOpeningTag(e) {
369
+ return this.renderTag(e, "");
350
370
  }
351
- renderClosingTag(t) {
352
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
371
+ renderClosingTag(e) {
372
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
353
373
  }
354
- getMatchingNode(t) {
355
- if (typeof this.nodes[t.type] == "function")
356
- return this.nodes[t.type](t);
374
+ getMatchingNode(e) {
375
+ if (typeof this.nodes[e.type] == "function")
376
+ return this.nodes[e.type](e);
357
377
  }
358
- getMatchingMark(t) {
359
- if (typeof this.marks[t.type] == "function")
360
- return this.marks[t.type](t);
378
+ getMatchingMark(e) {
379
+ if (typeof this.marks[e.type] == "function")
380
+ return this.marks[e.type](e);
361
381
  }
362
382
  }
363
- const V = (n = 0, t = n) => {
364
- const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
365
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
366
- }, m = (n, t, e) => {
383
+ const te = (s = 0, e = s) => {
384
+ const t = Math.abs(e - s) || 0, r = s < e ? 1 : -1;
385
+ return ((o = 0, n) => [...Array(o)].map(n))(t, (o, n) => n * r + s);
386
+ }, y = (s, e, t) => {
367
387
  const r = [];
368
- for (const s in n) {
369
- if (!Object.prototype.hasOwnProperty.call(n, s))
388
+ for (const o in s) {
389
+ if (!Object.prototype.hasOwnProperty.call(s, o))
370
390
  continue;
371
- const o = n[s], a = e ? "" : encodeURIComponent(s);
372
- let i;
373
- i = typeof o == "object" ? m(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
391
+ const n = s[o], i = t ? "" : encodeURIComponent(o);
392
+ let a;
393
+ a = typeof n == "object" ? y(n, e ? e + encodeURIComponent("[" + i + "]") : i, Array.isArray(n)) : (e ? e + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(n), r.push(a);
374
394
  }
375
395
  return r.join("&");
376
396
  };
377
- let g = {}, d = {};
378
- class D {
379
- constructor(t, e) {
380
- if (!e) {
381
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
382
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
397
+ let f = {}, d = {};
398
+ class re {
399
+ constructor(e, t) {
400
+ if (!t) {
401
+ let n = e.region ? `-${e.region}` : "", i = e.https === !1 ? "http" : "https";
402
+ t = e.oauthToken === void 0 ? `${i}://api${n}.storyblok.com/v2` : `${i}://api${n}.storyblok.com/v1`;
383
403
  }
384
- let r = Object.assign({}, t.headers), s = 5;
385
- t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new H(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = S.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
404
+ let r = Object.assign({}, e.headers), o = 5;
405
+ e.oauthToken !== void 0 && (r.Authorization = e.oauthToken, o = 3), e.rateLimit !== void 0 && (o = e.rateLimit), this.richTextResolver = new ee(e.richTextSchema), typeof e.componentResolver == "function" && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = C(this.throttledRequest, o, 1e3), this.accessToken = e.accessToken, this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.client = N.create({ baseURL: t, timeout: e.timeout || 0, headers: r, proxy: e.proxy || !1 }), e.responseInterceptor && this.client.interceptors.response.use((n) => e.responseInterceptor(n)), this.resolveNestedRelations = e.resolveNestedRelations || !0;
386
406
  }
387
- setComponentResolver(t) {
388
- this.richTextResolver.addNode("blok", (e) => {
407
+ setComponentResolver(e) {
408
+ this.richTextResolver.addNode("blok", (t) => {
389
409
  let r = "";
390
- return e.attrs.body.forEach((s) => {
391
- r += t(s.component, s);
410
+ return t.attrs.body.forEach((o) => {
411
+ r += e(o.component, o);
392
412
  }), { html: r };
393
413
  });
394
414
  }
395
- parseParams(t = {}) {
396
- return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
415
+ parseParams(e = {}) {
416
+ return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = d[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
397
417
  }
398
- factoryParamOptions(t, e = {}) {
399
- return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
418
+ factoryParamOptions(e, t = {}) {
419
+ return ((r = "") => r.indexOf("/cdn/") > -1)(e) ? this.parseParams(t) : t;
400
420
  }
401
- makeRequest(t, e, r, s) {
402
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(u({}, a), { per_page: i, page: c }))(e, r, s));
403
- return this.cacheResponse(t, o);
421
+ makeRequest(e, t, r, o) {
422
+ const n = this.factoryParamOptions(e, ((i = {}, a = 25, c = 1) => g(u({}, i), { per_page: a, page: c }))(t, r, o));
423
+ return this.cacheResponse(e, n);
404
424
  }
405
- get(t, e) {
406
- let r = `/${t}`;
407
- const s = this.factoryParamOptions(r, e);
408
- return this.cacheResponse(r, s);
425
+ get(e, t) {
426
+ let r = `/${e}`;
427
+ const o = this.factoryParamOptions(r, t);
428
+ return this.cacheResponse(r, o);
409
429
  }
410
- async getAll(t, e = {}, r) {
411
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
412
- r = r || a[a.length - 1];
413
- const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
414
- return ((l = [], h) => l.map(h).reduce((p, j) => [...p, ...j], []))([i, ...await (async (l = [], h) => Promise.all(l.map(h)))(V(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
430
+ async getAll(e, t = {}, r) {
431
+ const o = t.per_page || 25, n = `/${e}`, i = n.split("/");
432
+ r = r || i[i.length - 1];
433
+ const a = await this.makeRequest(n, t, o, 1), c = Math.ceil(a.total / o);
434
+ return ((l = [], h) => l.map(h).reduce((p, j) => [...p, ...j], []))([a, ...await (async (l = [], h) => Promise.all(l.map(h)))(te(1, c), async (l) => this.makeRequest(n, t, o, l + 1))], (l) => Object.values(l.data[r]));
415
435
  }
416
- post(t, e) {
417
- let r = `/${t}`;
418
- return this.throttle("post", r, e);
436
+ post(e, t) {
437
+ let r = `/${e}`;
438
+ return this.throttle("post", r, t);
419
439
  }
420
- put(t, e) {
421
- let r = `/${t}`;
422
- return this.throttle("put", r, e);
440
+ put(e, t) {
441
+ let r = `/${e}`;
442
+ return this.throttle("put", r, t);
423
443
  }
424
- delete(t, e) {
425
- let r = `/${t}`;
426
- return this.throttle("delete", r, e);
444
+ delete(e, t) {
445
+ let r = `/${e}`;
446
+ return this.throttle("delete", r, t);
427
447
  }
428
- getStories(t) {
429
- return this.get("cdn/stories", t);
448
+ getStories(e) {
449
+ return this.get("cdn/stories", e);
430
450
  }
431
- getStory(t, e) {
432
- return this.get(`cdn/stories/${t}`, e);
451
+ getStory(e, t) {
452
+ return this.get(`cdn/stories/${e}`, t);
433
453
  }
434
- setToken(t) {
435
- this.accessToken = t;
454
+ setToken(e) {
455
+ this.accessToken = e;
436
456
  }
437
457
  getToken() {
438
458
  return this.accessToken;
439
459
  }
440
- _cleanCopy(t) {
441
- return JSON.parse(JSON.stringify(t));
460
+ _cleanCopy(e) {
461
+ return JSON.parse(JSON.stringify(e));
442
462
  }
443
- _insertLinks(t, e) {
444
- const r = t[e];
463
+ _insertLinks(e, t) {
464
+ const r = e[t];
445
465
  r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
446
466
  }
447
- _insertRelations(t, e, r) {
448
- if (r.indexOf(t.component + "." + e) > -1) {
449
- if (typeof t[e] == "string")
450
- this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
451
- else if (t[e].constructor === Array) {
452
- let s = [];
453
- t[e].forEach((o) => {
454
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
455
- }), t[e] = s;
467
+ _insertRelations(e, t, r) {
468
+ if (r.indexOf(e.component + "." + t) > -1) {
469
+ if (typeof e[t] == "string")
470
+ this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
471
+ else if (e[t].constructor === Array) {
472
+ let o = [];
473
+ e[t].forEach((n) => {
474
+ this.relations[n] && o.push(this._cleanCopy(this.relations[n]));
475
+ }), e[t] = o;
456
476
  }
457
477
  }
458
478
  }
459
- _insertAssetsRelations(t, e) {
460
- e.forEach((r) => {
461
- t.id === r.id && (t.original = r, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
479
+ _insertAssetsRelations(e, t) {
480
+ t.forEach((r) => {
481
+ e.id === r.id && (e.original = r, e.original.filename = e.filename, e.original.filename = e.original.filename.includes("https://s3.amazonaws.com/") ? e.original.filename : e.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e.original.s3_filename);
462
482
  });
463
483
  }
464
- iterateTree(t, e) {
465
- let r = (s) => {
466
- if (s != null) {
467
- if (s.constructor === Array)
468
- for (let o = 0; o < s.length; o++)
469
- r(s[o]);
470
- else if (s.constructor === Object) {
471
- if (s._stopResolving)
484
+ iterateTree(e, t) {
485
+ let r = (o) => {
486
+ if (o != null) {
487
+ if (o.constructor === Array)
488
+ for (let n = 0; n < o.length; n++)
489
+ r(o[n]);
490
+ else if (o.constructor === Object) {
491
+ if (o._stopResolving)
472
492
  return;
473
- for (let o in s)
474
- s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
493
+ for (let n in o)
494
+ o.component && o._uid || o.type === "link" ? (this._insertRelations(o, n, t), this._insertLinks(o, n)) : "id" in o && o.fieldtype === "asset" && this._insertAssetsRelations(o, t), r(o[n]);
475
495
  }
476
496
  }
477
497
  };
478
- r(t.content);
498
+ r(e.content);
479
499
  }
480
- async resolveLinks(t, e) {
500
+ async resolveLinks(e, t) {
481
501
  let r = [];
482
- if (t.link_uuids) {
483
- const s = t.link_uuids.length;
484
- let o = [];
485
- const a = 50;
486
- for (let i = 0; i < s; i += a) {
487
- const c = Math.min(s, i + a);
488
- o.push(t.link_uuids.slice(i, c));
502
+ if (e.link_uuids) {
503
+ const o = e.link_uuids.length;
504
+ let n = [];
505
+ const i = 50;
506
+ for (let a = 0; a < o; a += i) {
507
+ const c = Math.min(o, a + i);
508
+ n.push(e.link_uuids.slice(a, c));
489
509
  }
490
- for (let i = 0; i < o.length; i++)
491
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
510
+ for (let a = 0; a < n.length; a++)
511
+ (await this.getStories({ per_page: i, language: t.language, version: t.version, by_uuids: n[a].join(",") })).data.stories.forEach((c) => {
492
512
  r.push(c);
493
513
  });
494
514
  } else
495
- r = t.links;
496
- r.forEach((s) => {
497
- this.links[s.uuid] = y(u({}, s), { _stopResolving: !0 });
515
+ r = e.links;
516
+ r.forEach((o) => {
517
+ this.links[o.uuid] = g(u({}, o), { _stopResolving: !0 });
498
518
  });
499
519
  }
500
- async resolveRelations(t, e) {
520
+ async resolveRelations(e, t) {
501
521
  let r = [];
502
- if (t.rel_uuids) {
503
- const s = t.rel_uuids.length;
504
- let o = [];
505
- const a = 50;
506
- for (let i = 0; i < s; i += a) {
507
- const c = Math.min(s, i + a);
508
- o.push(t.rel_uuids.slice(i, c));
522
+ if (e.rel_uuids) {
523
+ const o = e.rel_uuids.length;
524
+ let n = [];
525
+ const i = 50;
526
+ for (let a = 0; a < o; a += i) {
527
+ const c = Math.min(o, a + i);
528
+ n.push(e.rel_uuids.slice(a, c));
509
529
  }
510
- for (let i = 0; i < o.length; i++)
511
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
530
+ for (let a = 0; a < n.length; a++)
531
+ (await this.getStories({ per_page: i, language: t.language, version: t.version, by_uuids: n[a].join(",") })).data.stories.forEach((c) => {
512
532
  r.push(c);
513
533
  });
514
534
  } else
515
- r = t.rels;
516
- r.forEach((s) => {
517
- this.relations[s.uuid] = y(u({}, s), { _stopResolving: !0 });
535
+ r = e.rels;
536
+ r.forEach((o) => {
537
+ this.relations[o.uuid] = g(u({}, o), { _stopResolving: !0 });
518
538
  });
519
539
  }
520
- async resolveStories(t, e) {
540
+ async resolveStories(e, t) {
521
541
  let r = [];
522
- if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
523
- for (const s in this.relations)
524
- this.iterateTree(this.relations[s], r);
525
- t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
526
- this.iterateTree(s, r);
542
+ if (t.resolve_relations !== void 0 && t.resolve_relations.length > 0 && (e.rels || e.rel_uuids) && (r = t.resolve_relations.split(","), await this.resolveRelations(e, t)), ["1", "story", "url"].indexOf(t.resolve_links) > -1 && (e.links || e.link_uuids) && await this.resolveLinks(e, t), this.resolveNestedRelations)
543
+ for (const o in this.relations)
544
+ this.iterateTree(this.relations[o], r);
545
+ e.story ? this.iterateTree(e.story, r) : e.stories.forEach((o) => {
546
+ this.iterateTree(o, r);
527
547
  });
528
548
  }
529
- resolveAssetsRelations(t) {
530
- const { assets: e, stories: r, story: s } = t;
549
+ resolveAssetsRelations(e) {
550
+ const { assets: t, stories: r, story: o } = e;
531
551
  if (r)
532
- for (const o of r)
533
- this.iterateTree(o, e);
552
+ for (const n of r)
553
+ this.iterateTree(n, t);
534
554
  else {
535
- if (!s)
536
- return t;
537
- this.iterateTree(s, e);
555
+ if (!o)
556
+ return e;
557
+ this.iterateTree(o, t);
538
558
  }
539
559
  }
540
- cacheResponse(t, e, r) {
541
- return r === void 0 && (r = 0), new Promise(async (s, o) => {
542
- let a = m({ url: t, params: e }), i = this.cacheProvider();
543
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
544
- const l = await i.get(a);
560
+ cacheResponse(e, t, r) {
561
+ return r === void 0 && (r = 0), new Promise(async (o, n) => {
562
+ let i = y({ url: e, params: t }), a = this.cacheProvider();
563
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
564
+ const l = await a.get(i);
545
565
  if (l)
546
- return s(l);
566
+ return o(l);
547
567
  }
548
568
  try {
549
- let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => m(p) }), h = { data: l.data, headers: l.headers };
569
+ let l = await this.throttle("get", e, { params: t, paramsSerializer: (p) => y(p) }), h = { data: l.data, headers: l.headers };
550
570
  if (h.data.assets && h.data.assets.length && this.resolveAssetsRelations(h.data), l.headers["per-page"] && (h = Object.assign({}, h, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
551
- return o(l);
552
- (h.data.story || h.data.stories) && await this.resolveStories(h.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, h), h.data.cv && (e.version == "draft" && d[e.token] != h.data.cv && this.flushCache(), d[e.token] = h.data.cv), s(h);
571
+ return n(l);
572
+ (h.data.story || h.data.stories) && await this.resolveStories(h.data, t), t.version === "published" && e != "/cdn/spaces/me" && a.set(i, h), h.data.cv && (t.version == "draft" && d[t.token] != h.data.cv && this.flushCache(), d[t.token] = h.data.cv), o(h);
553
573
  } catch (l) {
554
574
  if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
555
- return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((h) => setTimeout(h, c))), this.cacheResponse(t, e, r).then(s).catch(o);
556
- o(l);
575
+ return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((h) => setTimeout(h, c))), this.cacheResponse(e, t, r).then(o).catch(n);
576
+ n(l);
557
577
  }
558
578
  var c;
559
579
  });
560
580
  }
561
- throttledRequest(t, e, r) {
562
- return this.client[t](e, r);
581
+ throttledRequest(e, t, r) {
582
+ return this.client[e](t, r);
563
583
  }
564
584
  cacheVersions() {
565
585
  return d;
@@ -567,14 +587,14 @@ class D {
567
587
  cacheVersion() {
568
588
  return d[this.accessToken];
569
589
  }
570
- setCacheVersion(t) {
571
- this.accessToken && (d[this.accessToken] = t);
590
+ setCacheVersion(e) {
591
+ this.accessToken && (d[this.accessToken] = e);
572
592
  }
573
593
  cacheProvider() {
574
- return this.cache.type === "memory" ? { get: (t) => g[t], getAll: () => g, set(t, e) {
575
- g[t] = e;
594
+ return this.cache.type === "memory" ? { get: (e) => f[e], getAll: () => f, set(e, t) {
595
+ f[e] = t;
576
596
  }, flush() {
577
- g = {};
597
+ f = {};
578
598
  } } : { get() {
579
599
  }, getAll() {
580
600
  }, set() {
@@ -585,82 +605,91 @@ class D {
585
605
  return await this.cacheProvider().flush(), this;
586
606
  }
587
607
  }
588
- const J = (n = {}) => {
589
- const { apiOptions: t } = n;
590
- if (!t.accessToken) {
608
+ const se = (s = {}) => {
609
+ const { apiOptions: e } = s;
610
+ if (!e.accessToken) {
591
611
  console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
592
612
  return;
593
613
  }
594
- return { storyblokApi: new D(t) };
614
+ return { storyblokApi: new re(e) };
595
615
  };
596
- var G = (n) => {
597
- if (typeof n != "object" || typeof n._editable > "u")
616
+ var le = (s) => {
617
+ if (typeof s != "object" || typeof s._editable > "u")
598
618
  return {};
599
- const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
619
+ const e = JSON.parse(s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
600
620
  return {
601
- "data-blok-c": JSON.stringify(t),
602
- "data-blok-uid": t.id + "-" + t.uid
621
+ "data-blok-c": JSON.stringify(e),
622
+ "data-blok-uid": e.id + "-" + e.uid
603
623
  };
604
624
  };
605
- let f;
606
- const O = "https://app.storyblok.com/f/storyblok-v2-latest.js", F = (n = {}) => {
625
+ let m;
626
+ const I = "https://app.storyblok.com/f/storyblok-v2-latest.js", oe = (s = {}) => {
607
627
  const {
608
- bridge: t,
609
- accessToken: e,
628
+ bridge: e,
629
+ accessToken: t,
610
630
  use: r = [],
611
- apiOptions: s = {},
612
- richText: o = {}
613
- } = n;
614
- s.accessToken = s.accessToken || e;
615
- const a = { bridge: t, apiOptions: s };
616
- let i = {};
631
+ apiOptions: o = {},
632
+ richText: n = {}
633
+ } = s;
634
+ o.accessToken = o.accessToken || t;
635
+ const i = { bridge: e, apiOptions: o };
636
+ let a = {};
617
637
  return r.forEach((c) => {
618
- i = u(u({}, i), c(a));
619
- }), t !== !1 && w(O), f = new R(o.schema), o.resolver && E(f, o.resolver), i;
620
- }, E = (n, t) => {
621
- n.addNode("blok", (e) => {
638
+ a = u(u({}, a), c(i));
639
+ }), e !== !1 && S(I), m = new x(n.schema), n.resolver && P(m, n.resolver), a;
640
+ }, P = (s, e) => {
641
+ s.addNode("blok", (t) => {
622
642
  let r = "";
623
- return e.attrs.body.forEach((s) => {
624
- r += t(s.component, s);
643
+ return t.attrs.body.forEach((o) => {
644
+ r += e(o.component, o);
625
645
  }), {
626
646
  html: r
627
647
  };
628
648
  });
629
- }, Q = (n, t) => {
630
- if (!f) {
649
+ }, ne = (s, e, t) => {
650
+ let r = t || m;
651
+ if (!r) {
631
652
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
632
653
  return;
633
654
  }
634
- if (n === "")
635
- return "";
636
- if (!n)
637
- return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
655
+ return s === "" ? "" : s ? (e && (r = new x(e.schema), e.resolver && P(r, e.resolver)), r.render(s)) : (console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
638
656
 
639
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "";
640
- let e = f;
641
- return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(n);
642
- }, W = () => w(O);
643
- function Y(n, t, e) {
644
- const { storyblokApi: r } = F({
645
- accessToken: n,
646
- use: t || [J],
647
- apiOptions: { ...e }
657
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
658
+ }, ce = () => S(I);
659
+ function ae(s, e, t) {
660
+ const { storyblokApi: r } = oe({
661
+ accessToken: s,
662
+ use: e || [se],
663
+ apiOptions: { ...t }
648
664
  });
649
665
  globalThis.storyblokApiInstance = r;
650
666
  }
651
- function X() {
667
+ function he() {
652
668
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
653
669
  }
654
- function Z(n) {
670
+ function ue(s, e) {
671
+ const t = globalThis.storyblokApiInstance.richTextResolver;
672
+ if (!t) {
673
+ console.error(
674
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
675
+ );
676
+ return;
677
+ }
678
+ return ne(s, e, t);
679
+ }
680
+ function de(s) {
655
681
  return {
656
682
  name: "@storyblok/astro",
657
683
  hooks: {
658
- "astro:config:setup": ({ injectScript: t, updateConfig: e }) => {
659
- e({
684
+ "astro:config:setup": ({ injectScript: e, updateConfig: t }) => {
685
+ var o;
686
+ t({
660
687
  vite: {
661
- plugins: [x(n.components)]
688
+ plugins: [z(s.components)]
662
689
  }
663
- }), Y(n.accessToken, n.use, n.apiOptions), (n.bridge || !0) && t("page", `
690
+ }), ae(s.accessToken, s.use, s.apiOptions), ((o = s.bridge) != null ? o : !0) && e(
691
+ "page",
692
+ `
664
693
  import { loadStoryblokBridge } from "@storyblok/astro";
665
694
  loadStoryblokBridge().then(() => {
666
695
  const { StoryblokBridge, location } = window;
@@ -672,15 +701,17 @@ function Z(n) {
672
701
  }
673
702
  });
674
703
  });
675
- `);
704
+ `
705
+ );
676
706
  }
677
707
  }
678
708
  };
679
709
  }
680
710
  export {
681
- Z as default,
682
- W as loadStoryblokBridge,
683
- Q as renderRichText,
684
- G as storyblokEditable,
685
- X as useStoryblokApi
711
+ W as RichTextSchema,
712
+ de as default,
713
+ ce as loadStoryblokBridge,
714
+ ue as renderRichText,
715
+ le as storyblokEditable,
716
+ he as useStoryblokApi
686
717
  };