@storyblok/astro 4.1.0-next.1 → 4.1.0

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