@storyblok/vue 8.1.5 → 8.1.7

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,6 +1,12 @@
1
- import { defineComponent as K, ref as C, resolveDynamicComponent as N, inject as ne, openBlock as J, createBlock as Y, mergeProps as ie, h as X, createTextVNode as ae, watch as le, onMounted as ce, defineAsyncComponent as he } from "vue";
1
+ /**
2
+ * name: @storyblok/vue
3
+ * (c) 2024
4
+ * description: SDK to integrate Storyblok into your project using Vue.
5
+ * author: Storyblok
6
+ */
7
+ import { defineComponent as G, ref as O, resolveDynamicComponent as N, inject as oe, openBlock as K, createBlock as J, mergeProps as ne, h as Y, createTextVNode as ie, watch as ae, onMounted as le, defineAsyncComponent as ce } from "vue";
2
8
  let D = !1;
3
- const z = [], ue = (r) => new Promise((e, t) => {
9
+ const z = [], he = (r) => new Promise((e, t) => {
4
10
  if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
5
11
  if (window.location === window.parent.location) {
6
12
  console.warn("You are not in Draft Mode or in the Visual Editor.");
@@ -13,53 +19,57 @@ const z = [], ue = (r) => new Promise((e, t) => {
13
19
  z.forEach((n) => n()), D = !0, e(o);
14
20
  }, document.getElementsByTagName("head")[0].appendChild(s);
15
21
  });
16
- var pe = Object.defineProperty, de = (r, e, t) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
17
- function B(r) {
18
- return !(r !== r || r === 1 / 0 || r === -1 / 0);
22
+ var ue = Object.defineProperty, de = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
23
+ class pe extends Error {
24
+ constructor(e) {
25
+ super(e), this.name = "AbortError";
26
+ }
19
27
  }
20
28
  function ge(r, e, t) {
21
- if (!B(e))
29
+ if (!Number.isFinite(e))
22
30
  throw new TypeError("Expected `limit` to be a finite number");
23
- if (!B(t))
31
+ if (!Number.isFinite(t))
24
32
  throw new TypeError("Expected `interval` to be a finite number");
25
33
  const s = [];
26
- let o = [], n = 0;
27
- const i = function() {
34
+ let o = [], n = 0, i = !1;
35
+ const a = async () => {
28
36
  n++;
29
- const a = setTimeout(function() {
30
- n--, s.length > 0 && i(), o = o.filter(function(u) {
31
- return u !== a;
32
- });
33
- }, t);
34
- o.indexOf(a) < 0 && o.push(a);
35
37
  const h = s.shift();
36
- h.resolve(r.apply(h.self, h.args));
37
- }, l = function(...a) {
38
- const h = this;
39
- return new Promise(function(u, d) {
40
- s.push({
41
- resolve: u,
42
- reject: d,
43
- args: a,
44
- self: h
45
- }), n < e && i();
46
- });
47
- };
48
- return l.abort = function() {
49
- o.forEach(clearTimeout), o = [], s.forEach(function(a) {
50
- a.reject(function() {
51
- Error.call(this, "Throttled function aborted"), this.name = "AbortError";
52
- });
53
- }), s.length = 0;
38
+ if (h)
39
+ try {
40
+ const d = await r(...h.args);
41
+ h.resolve(d);
42
+ } catch (d) {
43
+ h.reject(d);
44
+ }
45
+ const u = setTimeout(() => {
46
+ n--, s.length > 0 && a(), o = o.filter((d) => d !== u);
47
+ }, t);
48
+ o.includes(u) || o.push(u);
49
+ }, l = (...h) => i ? Promise.reject(
50
+ new Error(
51
+ "Throttled function is already aborted and not accepting new promises"
52
+ )
53
+ ) : new Promise((u, d) => {
54
+ s.push({
55
+ resolve: u,
56
+ reject: d,
57
+ args: h
58
+ }), n < e && a();
59
+ });
60
+ return l.abort = () => {
61
+ i = !0, o.forEach(clearTimeout), o = [], s.forEach(
62
+ (h) => h.reject(() => new pe("Throttle function aborted"))
63
+ ), s.length = 0;
54
64
  }, l;
55
65
  }
56
66
  let A = class {
57
67
  constructor() {
58
- p(this, "isCDNUrl", (r = "") => r.indexOf("/cdn/") > -1), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
68
+ p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
59
69
  ...r,
60
70
  per_page: e,
61
71
  page: t
62
- })), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => [...Array(r)].map(e)), p(this, "range", (r = 0, e = r) => {
72
+ })), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
63
73
  const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
64
74
  return this.arrayFrom(t, (o, n) => n * s + r);
65
75
  }), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
@@ -69,16 +79,16 @@ let A = class {
69
79
  ">": "&gt;",
70
80
  '"': "&quot;",
71
81
  "'": "&#39;"
72
- }, t = /[&<>"']/g, s = RegExp(t.source);
82
+ }, t = /[&<>"']/g, s = new RegExp(t.source);
73
83
  return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
74
84
  });
75
85
  }
76
86
  /**
77
87
  * @method stringify
78
- * @param {Object} params
79
- * @param {String} prefix
80
- * @param {Boolean} isArray
81
- * @return {String} Stringified object
88
+ * @param {object} params
89
+ * @param {string} prefix
90
+ * @param {boolean} isArray
91
+ * @return {string} Stringified object
82
92
  */
83
93
  stringify(r, e, t) {
84
94
  const s = [];
@@ -86,19 +96,19 @@ let A = class {
86
96
  if (!Object.prototype.hasOwnProperty.call(r, o))
87
97
  continue;
88
98
  const n = r[o], i = t ? "" : encodeURIComponent(o);
89
- let l;
90
- typeof n == "object" ? l = this.stringify(
99
+ let a;
100
+ typeof n == "object" ? a = this.stringify(
91
101
  n,
92
- e ? e + encodeURIComponent("[" + i + "]") : i,
102
+ e ? e + encodeURIComponent(`[${i}]`) : i,
93
103
  Array.isArray(n)
94
- ) : l = (e ? e + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(n), s.push(l);
104
+ ) : a = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(a);
95
105
  }
96
106
  return s.join("&");
97
107
  }
98
108
  /**
99
109
  * @method getRegionURL
100
- * @param {String} regionCode region code, could be eu, us, cn, ap or ca
101
- * @return {String} The base URL of the region
110
+ * @param {string} regionCode region code, could be eu, us, cn, ap or ca
111
+ * @return {string} The base URL of the region
102
112
  */
103
113
  getRegionURL(r) {
104
114
  const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
@@ -120,7 +130,7 @@ const me = function(r, e) {
120
130
  const t = {};
121
131
  for (const s in r) {
122
132
  const o = r[s];
123
- e.indexOf(s) > -1 && o !== null && (t[s] = o);
133
+ e.includes(s) && o !== null && (t[s] = o);
124
134
  }
125
135
  return t;
126
136
  }, fe = (r) => r === "email", ye = () => ({
@@ -141,14 +151,14 @@ const me = function(r, e) {
141
151
  singleTag: "br"
142
152
  }), Te = (r) => ({
143
153
  tag: `h${r.attrs.level}`
144
- }), Re = (r) => ({
154
+ }), we = (r) => ({
145
155
  singleTag: [
146
156
  {
147
157
  tag: "img",
148
158
  attrs: me(r.attrs, ["src", "alt", "title"])
149
159
  }
150
160
  ]
151
- }), we = () => ({
161
+ }), Re = () => ({
152
162
  tag: "li"
153
163
  }), Se = () => ({
154
164
  tag: "ol"
@@ -165,15 +175,15 @@ const me = function(r, e) {
165
175
  }
166
176
  }
167
177
  ]
168
- }), xe = () => ({
169
- tag: "b"
170
178
  }), je = () => ({
171
- tag: "s"
179
+ tag: "b"
172
180
  }), Ie = () => ({
181
+ tag: "s"
182
+ }), xe = () => ({
173
183
  tag: "u"
174
- }), Oe = () => ({
175
- tag: "strong"
176
184
  }), Ce = () => ({
185
+ tag: "strong"
186
+ }), Oe = () => ({
177
187
  tag: "code"
178
188
  }), Ae = () => ({
179
189
  tag: "i"
@@ -250,18 +260,18 @@ const me = function(r, e) {
250
260
  code_block: ve,
251
261
  hard_break: $e,
252
262
  heading: Te,
253
- image: Re,
254
- list_item: we,
263
+ image: we,
264
+ list_item: Re,
255
265
  ordered_list: Se,
256
266
  paragraph: _e,
257
267
  emoji: Ee
258
268
  },
259
269
  marks: {
260
- bold: xe,
261
- strike: je,
262
- underline: Ie,
263
- strong: Oe,
264
- code: Ce,
270
+ bold: je,
271
+ strike: Ie,
272
+ underline: xe,
273
+ strong: Ce,
274
+ code: Oe,
265
275
  italic: Ae,
266
276
  link: Le,
267
277
  styled: Pe,
@@ -278,10 +288,10 @@ const me = function(r, e) {
278
288
  ">": "&gt;",
279
289
  '"': "&quot;",
280
290
  "'": "&#39;"
281
- }, t = /[&<>"']/g, s = RegExp(t.source);
291
+ }, t = /[&<>"']/g, s = new RegExp(t.source);
282
292
  return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
283
293
  };
284
- let q = !1;
294
+ let B = !1;
285
295
  class qe {
286
296
  constructor(e) {
287
297
  p(this, "marks"), p(this, "nodes"), e || (e = ze), this.marks = e.marks || [], this.nodes = e.nodes || [];
@@ -293,9 +303,9 @@ class qe {
293
303
  this.marks[e] = t;
294
304
  }
295
305
  render(e, t = { optimizeImages: !1 }, s = !0) {
296
- if (!q && s && (console.warn(
306
+ if (!B && s && (console.warn(
297
307
  "Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
298
- ), q = !0), e && e.content && Array.isArray(e.content)) {
308
+ ), B = !0), e && e.content && Array.isArray(e.content)) {
299
309
  let o = "";
300
310
  return e.content.forEach((n) => {
301
311
  o += this.renderNode(n);
@@ -303,42 +313,42 @@ class qe {
303
313
  }
304
314
  return console.warn(
305
315
  `The render method must receive an Object with a "content" field.
306
- The "content" field must be an array of nodes as the type ISbRichtext.
307
- ISbRichtext:
308
- content?: ISbRichtext[]
309
- marks?: ISbRichtext[]
310
- attrs?: any
311
- text?: string
312
- type: string
313
-
314
- Example:
315
- {
316
- content: [
317
- {
318
- content: [
319
- {
320
- text: 'Hello World',
321
- type: 'text'
322
- }
323
- ],
324
- type: 'paragraph'
325
- }
326
- ],
327
- type: 'doc'
328
- }`
316
+ The "content" field must be an array of nodes as the type ISbRichtext.
317
+ ISbRichtext:
318
+ content?: ISbRichtext[]
319
+ marks?: ISbRichtext[]
320
+ attrs?: any
321
+ text?: string
322
+ type: string
323
+
324
+ Example:
325
+ {
326
+ content: [
327
+ {
328
+ content: [
329
+ {
330
+ text: 'Hello World',
331
+ type: 'text'
332
+ }
333
+ ],
334
+ type: 'paragraph'
335
+ }
336
+ ],
337
+ type: 'doc'
338
+ }`
329
339
  ), "";
330
340
  }
331
341
  optimizeImages(e, t) {
332
342
  let s = 0, o = 0, n = "", i = "";
333
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
334
- const l = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
343
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
344
+ const a = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
335
345
  return e = e.replace(
336
- /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
337
- `a.storyblok.com/f/$1/$2.$3/m/${l}`
338
- ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
346
+ /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
347
+ `a.storyblok.com/f/$1/$2.$3/m/${a}`
348
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (l) => {
339
349
  var h, u;
340
- const d = a.match(
341
- /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
350
+ const d = l.match(
351
+ /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
342
352
  );
343
353
  if (d && d.length > 0) {
344
354
  const g = {
@@ -346,16 +356,17 @@ class qe {
346
356
  if (typeof y == "number")
347
357
  return `//${d}/m/${y}x0${i} ${y}w`;
348
358
  if (typeof y == "object" && y.length === 2) {
349
- let w = 0, I = 0;
350
- return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (I = y[1]), `//${d}/m/${w}x${I}${i} ${w}w`;
359
+ let w = 0, x = 0;
360
+ return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (x = y[1]), `//${d}/m/${w}x${x}${i} ${w}w`;
351
361
  }
362
+ return "";
352
363
  }).join(", "),
353
364
  sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
354
365
  };
355
- let $ = "";
356
- return g.srcset && ($ += `srcset="${g.srcset}" `), g.sizes && ($ += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${$.trim()}`);
366
+ let R = "";
367
+ return g.srcset && (R += `srcset="${g.srcset}" `), g.sizes && (R += `sizes="${g.sizes}" `), l.replace(/<img/g, `<img ${R.trim()}`);
357
368
  }
358
- return a;
369
+ return l;
359
370
  })), e;
360
371
  }
361
372
  renderNode(e) {
@@ -423,7 +434,7 @@ class qe {
423
434
  }
424
435
  }
425
436
  const L = qe;
426
- class Ve {
437
+ class Fe {
427
438
  constructor(e) {
428
439
  p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
429
440
  }
@@ -462,31 +473,31 @@ class Ve {
462
473
  async _methodHandler(e) {
463
474
  let t = `${this.baseURL}${this.url}`, s = null;
464
475
  if (e === "get") {
465
- const a = new A();
466
- t = `${this.baseURL}${this.url}?${a.stringify(
476
+ const l = new A();
477
+ t = `${this.baseURL}${this.url}?${l.stringify(
467
478
  this.parameters
468
479
  )}`;
469
480
  } else
470
481
  s = JSON.stringify(this.parameters);
471
482
  const o = new URL(t), n = new AbortController(), { signal: i } = n;
472
- let l;
473
- this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
483
+ let a;
484
+ this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
474
485
  try {
475
- const a = await this.fetch(`${o}`, {
486
+ const l = await this.fetch(`${o}`, {
476
487
  method: e,
477
488
  headers: this.headers,
478
489
  body: s,
479
490
  signal: i,
480
491
  ...this.fetchOptions
481
492
  });
482
- this.timeout && clearTimeout(l);
493
+ this.timeout && clearTimeout(a);
483
494
  const h = await this._responseHandler(
484
- a
495
+ l
485
496
  );
486
497
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
487
- } catch (a) {
498
+ } catch (l) {
488
499
  return {
489
- message: a
500
+ message: l
490
501
  };
491
502
  }
492
503
  }
@@ -510,35 +521,39 @@ class Ve {
510
521
  });
511
522
  }
512
523
  }
513
- const Fe = Ve, V = "SB-Agent", M = {
524
+ const Ve = Fe, q = "SB-Agent", M = {
514
525
  defaultAgentName: "SB-JS-CLIENT",
515
526
  defaultAgentVersion: "SB-Agent-Version",
516
527
  packageVersion: "6.0.0"
517
528
  };
518
- let O = {};
529
+ let C = {};
519
530
  const E = {};
520
531
  class Ge {
521
532
  /**
522
533
  *
523
534
  * @param config ISbConfig interface
524
- * @param endpoint string, optional
535
+ * @param pEndpoint string, optional
525
536
  */
526
537
  constructor(e, t) {
527
538
  p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
528
539
  let s = e.endpoint || t;
529
540
  if (!s) {
530
- const i = new A().getRegionURL, l = e.https === !1 ? "http" : "https";
531
- e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
541
+ const i = new A().getRegionURL, a = e.https === !1 ? "http" : "https";
542
+ e.oauthToken ? s = `${a}://${i(e.region)}/v1` : s = `${a}://${i(e.region)}/v2`;
532
543
  }
533
544
  const o = new Headers();
534
- o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
535
- o.set(i, l);
536
- }), o.has(V) || (o.set(V, M.defaultAgentName), o.set(
545
+ o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, a]) => {
546
+ o.set(i, a);
547
+ }), o.has(q) || (o.set(q, M.defaultAgentName), o.set(
537
548
  M.defaultAgentVersion,
538
549
  M.packageVersion
539
550
  ));
540
551
  let n = 5;
541
- e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Fe({
552
+ e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(
553
+ this.throttledRequest.bind(this),
554
+ n,
555
+ 1e3
556
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ve({
542
557
  baseURL: s,
543
558
  timeout: e.timeout || 0,
544
559
  headers: o,
@@ -575,32 +590,35 @@ class Ge {
575
590
  return this.cacheResponse(o, n, void 0, s);
576
591
  }
577
592
  async getAll(e, t, s, o) {
578
- const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, l = i.split("/"), a = s || l[l.length - 1], h = 1, u = await this.makeRequest(
593
+ const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), a = s ?? i.substring(i.lastIndexOf("/") + 1), l = 1, h = await this.makeRequest(
579
594
  i,
580
595
  t,
581
596
  n,
582
- h,
597
+ l,
583
598
  o
584
- ), d = u.total ? Math.ceil(u.total / n) : 1, g = await this.helpers.asyncMap(
585
- this.helpers.range(h, d),
586
- ($) => this.makeRequest(i, t, n, $ + 1, o)
587
- );
588
- return this.helpers.flatMap(
589
- [u, ...g],
590
- ($) => Object.values($.data[a])
599
+ ), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
600
+ this.helpers.range(l, u),
601
+ (g) => this.makeRequest(i, t, n, g + 1, o)
591
602
  );
603
+ return this.helpers.flatMap([h, ...d], (g) => Object.values(g.data[a]));
592
604
  }
593
605
  post(e, t, s) {
594
606
  const o = `/${e}`;
595
- return Promise.resolve(this.throttle("post", o, t, s));
607
+ return Promise.resolve(
608
+ this.throttle("post", o, t, s)
609
+ );
596
610
  }
597
611
  put(e, t, s) {
598
612
  const o = `/${e}`;
599
- return Promise.resolve(this.throttle("put", o, t, s));
613
+ return Promise.resolve(
614
+ this.throttle("put", o, t, s)
615
+ );
600
616
  }
601
617
  delete(e, t, s) {
602
618
  const o = `/${e}`;
603
- return Promise.resolve(this.throttle("delete", o, t, s));
619
+ return Promise.resolve(
620
+ this.throttle("delete", o, t, s)
621
+ );
604
622
  }
605
623
  getStories(e, t) {
606
624
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
@@ -622,7 +640,7 @@ class Ge {
622
640
  }
623
641
  _insertLinks(e, t, s) {
624
642
  const o = e[t];
625
- o && o.fieldtype == "multilink" && o.linktype == "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
643
+ o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
626
644
  }
627
645
  /**
628
646
  *
@@ -636,7 +654,7 @@ class Ge {
636
654
  )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
637
655
  }
638
656
  _insertRelations(e, t, s, o) {
639
- s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
657
+ s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
640
658
  }
641
659
  iterateTree(e, t, s) {
642
660
  const o = (n) => {
@@ -666,17 +684,17 @@ class Ge {
666
684
  async resolveLinks(e, t, s) {
667
685
  let o = [];
668
686
  if (e.link_uuids) {
669
- const n = e.link_uuids.length, i = [], l = 50;
670
- for (let a = 0; a < n; a += l) {
671
- const h = Math.min(n, a + l);
672
- i.push(e.link_uuids.slice(a, h));
687
+ const n = e.link_uuids.length, i = [], a = 50;
688
+ for (let l = 0; l < n; l += a) {
689
+ const h = Math.min(n, l + a);
690
+ i.push(e.link_uuids.slice(l, h));
673
691
  }
674
- for (let a = 0; a < i.length; a++)
692
+ for (let l = 0; l < i.length; l++)
675
693
  (await this.getStories({
676
- per_page: l,
694
+ per_page: a,
677
695
  language: t.language,
678
696
  version: t.version,
679
- by_uuids: i[a].join(",")
697
+ by_uuids: i[l].join(",")
680
698
  })).data.stories.forEach(
681
699
  (h) => {
682
700
  o.push(h);
@@ -694,17 +712,17 @@ class Ge {
694
712
  async resolveRelations(e, t, s) {
695
713
  let o = [];
696
714
  if (e.rel_uuids) {
697
- const n = e.rel_uuids.length, i = [], l = 50;
698
- for (let a = 0; a < n; a += l) {
699
- const h = Math.min(n, a + l);
700
- i.push(e.rel_uuids.slice(a, h));
715
+ const n = e.rel_uuids.length, i = [], a = 50;
716
+ for (let l = 0; l < n; l += a) {
717
+ const h = Math.min(n, l + a);
718
+ i.push(e.rel_uuids.slice(l, h));
701
719
  }
702
- for (let a = 0; a < i.length; a++)
720
+ for (let l = 0; l < i.length; l++)
703
721
  (await this.getStories({
704
- per_page: l,
722
+ per_page: a,
705
723
  language: t.language,
706
724
  version: t.version,
707
- by_uuids: i[a].join(","),
725
+ by_uuids: i[l].join(","),
708
726
  excluding_fields: t.excluding_fields
709
727
  })).data.stories.forEach((h) => {
710
728
  o.push(h);
@@ -730,45 +748,50 @@ class Ge {
730
748
  async resolveStories(e, t, s) {
731
749
  var o, n;
732
750
  let i = [];
733
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
734
- for (const l in this.relations[s])
751
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
752
+ for (const a in this.relations[s])
735
753
  this.iterateTree(
736
- this.relations[s][l],
754
+ this.relations[s][a],
737
755
  i,
738
756
  s
739
757
  );
740
- e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
741
- this.iterateTree(l, i, s);
758
+ e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((a) => {
759
+ this.iterateTree(a, i, s);
742
760
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
743
761
  }
744
762
  async cacheResponse(e, t, s, o) {
745
763
  const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
746
- if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
747
- const l = await i.get(n);
748
- if (l)
749
- return Promise.resolve(l);
764
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
765
+ const a = await i.get(n);
766
+ if (a)
767
+ return Promise.resolve(a);
750
768
  }
751
- return new Promise(async (l, a) => {
769
+ return new Promise(async (a, l) => {
752
770
  var h;
753
771
  try {
754
- const u = await this.throttle("get", e, t, o);
772
+ const u = await this.throttle(
773
+ "get",
774
+ e,
775
+ t,
776
+ o
777
+ );
755
778
  if (u.status !== 200)
756
- return a(u);
779
+ return l(u);
757
780
  let d = { data: u.data, headers: u.headers };
758
781
  if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
759
- perPage: u.headers["per-page"] ? parseInt(u.headers["per-page"]) : 0,
760
- total: u.headers["per-page"] ? parseInt(u.headers.total) : 0
782
+ perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
783
+ total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
761
784
  })), d.data.story || d.data.stories) {
762
785
  const g = this.resolveCounter = ++this.resolveCounter % 1e3;
763
786
  await this.resolveStories(d.data, t, `${g}`);
764
787
  }
765
- return t.version === "published" && e != "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] != d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), l(d);
788
+ return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), a(d);
766
789
  } catch (u) {
767
790
  if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
768
791
  return console.log(
769
792
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
770
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
771
- a(u);
793
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(a).catch(l);
794
+ l(u);
772
795
  }
773
796
  });
774
797
  }
@@ -792,20 +815,21 @@ class Ge {
792
815
  case "memory":
793
816
  return {
794
817
  get(e) {
795
- return Promise.resolve(O[e]);
818
+ return Promise.resolve(C[e]);
796
819
  },
797
820
  getAll() {
798
- return Promise.resolve(O);
821
+ return Promise.resolve(C);
799
822
  },
800
823
  set(e, t) {
801
- return O[e] = t, Promise.resolve(void 0);
824
+ return C[e] = t, Promise.resolve(void 0);
802
825
  },
803
826
  flush() {
804
- return O = {}, Promise.resolve(void 0);
827
+ return C = {}, Promise.resolve(void 0);
805
828
  }
806
829
  };
807
830
  case "custom":
808
- if (this.cache.custom) return this.cache.custom;
831
+ if (this.cache.custom)
832
+ return this.cache.custom;
809
833
  default:
810
834
  return {
811
835
  get() {
@@ -856,19 +880,19 @@ function Je(r, e) {
856
880
  return { src: r, attrs: {} };
857
881
  let t = 0, s = 0;
858
882
  const o = {}, n = [];
859
- function i(a, h, u, d, g) {
860
- typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${a})`);
883
+ function i(l, h, u, d, g) {
884
+ typeof l != "number" || l <= h || l >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${l})`);
861
885
  }
862
886
  if (typeof e == "object") {
863
887
  if (typeof e.width == "number" && e.width > 0 ? (o.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (o.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
864
- const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: $, quality: y, rotate: w } = a || {};
865
- h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), $ && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
888
+ const { filters: l } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: R, quality: y, rotate: w } = l || {};
889
+ h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
866
890
  }
867
- e.srcset && (o.srcset = e.srcset.map((a) => {
868
- if (typeof a == "number")
869
- return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
870
- if (Array.isArray(a) && a.length === 2) {
871
- const [h, u] = a;
891
+ e.srcset && (o.srcset = e.srcset.map((l) => {
892
+ if (typeof l == "number")
893
+ return `${r}/m/${l}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${l}w`;
894
+ if (Array.isArray(l) && l.length === 2) {
895
+ const [h, u] = l;
872
896
  return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
873
897
  } else {
874
898
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
@@ -876,13 +900,13 @@ function Je(r, e) {
876
900
  }
877
901
  }).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
878
902
  }
879
- let l = `${r}/m/`;
880
- return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
881
- src: l,
903
+ let a = `${r}/m/`;
904
+ return t > 0 && s > 0 && (a = `${a}${t}x${s}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
905
+ src: a,
882
906
  attrs: o
883
907
  };
884
908
  }
885
- var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), W = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(W || {}), x = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(x || {});
909
+ var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), X = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(X || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
886
910
  const Ye = [
887
911
  "area",
888
912
  "base",
@@ -915,37 +939,37 @@ function et(r = {}) {
915
939
  resolvers: o = {},
916
940
  optimizeImages: n = !1,
917
941
  keyedResolvers: i = !1
918
- } = r, l = (c) => (m) => {
942
+ } = r, a = (c) => (m) => {
919
943
  const f = m.attrs || {};
920
944
  return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
921
- }, a = (c) => {
922
- const { src: m, alt: f, title: b, srcset: R, sizes: T } = c.attrs || {};
945
+ }, l = (c) => {
946
+ const { src: m, alt: f, title: b, srcset: T, sizes: $ } = c.attrs || {};
923
947
  let S = m, _ = {};
924
948
  if (n) {
925
- const { src: se, attrs: oe } = Je(m, n);
926
- S = se, _ = oe;
949
+ const { src: re, attrs: se } = Je(m, n);
950
+ S = re, _ = se;
927
951
  }
928
952
  i && (_ = {
929
953
  ..._,
930
954
  key: `img-${e}`
931
955
  });
932
- const re = {
956
+ const te = {
933
957
  src: S,
934
958
  alt: f,
935
959
  title: b,
936
- srcset: R,
937
- sizes: T,
960
+ srcset: T,
961
+ sizes: $,
938
962
  ..._
939
963
  };
940
- return t("img", F(re));
964
+ return t("img", F(te));
941
965
  }, h = (c) => {
942
966
  const { level: m, ...f } = c.attrs || {}, b = {
943
967
  ...f
944
968
  };
945
969
  return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
946
970
  }, u = (c) => {
947
- var m, f, b, R;
948
- const T = t("img", {
971
+ var m, f, b, T;
972
+ const $ = t("img", {
949
973
  src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
950
974
  alt: (f = c.attrs) == null ? void 0 : f.alt,
951
975
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
@@ -954,44 +978,44 @@ function et(r = {}) {
954
978
  }), S = {
955
979
  "data-type": "emoji",
956
980
  "data-name": (b = c.attrs) == null ? void 0 : b.name,
957
- "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
981
+ "data-emoji": (T = c.attrs) == null ? void 0 : T.emoji
958
982
  };
959
- return i && (S.key = `emoji-${e}`), t("span", S, T);
983
+ return i && (S.key = `emoji-${e}`), t("span", S, $);
960
984
  }, d = (c) => t("pre", {
961
985
  ...c.attrs,
962
986
  key: `code-${e}`
963
987
  }, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
964
- const { class: R, id: T, ...S } = b || {}, _ = m ? {
965
- class: R,
966
- id: T,
988
+ const { class: T, id: $, ...S } = b || {}, _ = m ? {
989
+ class: T,
990
+ id: $,
967
991
  style: We(S) || void 0
968
992
  } : b || {};
969
993
  return i && (_.key = `${c}-${e}`), t(c, F(_), f);
970
- }, $ = (c) => P(c), y = (c) => {
994
+ }, R = (c) => P(c), y = (c) => {
971
995
  const { marks: m, ...f } = c;
972
996
  return "text" in c ? m ? m.reduce(
973
- (b, R) => $({ ...R, text: b }),
997
+ (b, T) => R({ ...T, text: b }),
974
998
  // Fix: Ensure render function returns a string
975
- $({ ...f, children: f.children })
999
+ R({ ...f, children: f.children })
976
1000
  // Fix: Cast children to string
977
1001
  ) : s(f.text) : "";
978
1002
  }, w = (c) => {
979
- const { linktype: m, href: f, anchor: b, ...R } = c.attrs || {};
980
- let T = "";
1003
+ const { linktype: m, href: f, anchor: b, ...T } = c.attrs || {};
1004
+ let $ = "";
981
1005
  switch (m) {
982
- case x.ASSET:
983
- case x.URL:
984
- T = f;
1006
+ case j.ASSET:
1007
+ case j.URL:
1008
+ $ = f;
985
1009
  break;
986
- case x.EMAIL:
987
- T = `mailto:${f}`;
1010
+ case j.EMAIL:
1011
+ $ = `mailto:${f}`;
988
1012
  break;
989
- case x.STORY:
990
- T = f;
1013
+ case j.STORY:
1014
+ $ = f;
991
1015
  break;
992
1016
  }
993
- return b && (T = `${T}#${b}`), t("a", { ...R, href: T, key: `a-${e}` }, c.text);
994
- }, I = (c) => {
1017
+ return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
1018
+ }, x = (c) => {
995
1019
  var m, f;
996
1020
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
997
1021
  blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
@@ -999,21 +1023,21 @@ function et(r = {}) {
999
1023
  key: `component-${e}`,
1000
1024
  style: "display: none"
1001
1025
  });
1002
- }, te = new Map([
1003
- [k.DOCUMENT, l("div")],
1026
+ }, ee = new Map([
1027
+ [k.DOCUMENT, a("div")],
1004
1028
  [k.HEADING, h],
1005
- [k.PARAGRAPH, l("p")],
1006
- [k.UL_LIST, l("ul")],
1007
- [k.OL_LIST, l("ol")],
1008
- [k.LIST_ITEM, l("li")],
1009
- [k.IMAGE, a],
1029
+ [k.PARAGRAPH, a("p")],
1030
+ [k.UL_LIST, a("ul")],
1031
+ [k.OL_LIST, a("ol")],
1032
+ [k.LIST_ITEM, a("li")],
1033
+ [k.IMAGE, l],
1010
1034
  [k.EMOJI, u],
1011
1035
  [k.CODE_BLOCK, d],
1012
- [k.HR, l("hr")],
1013
- [k.BR, l("br")],
1014
- [k.QUOTE, l("blockquote")],
1015
- [k.COMPONENT, I],
1016
- [W.TEXT, y],
1036
+ [k.HR, a("hr")],
1037
+ [k.BR, a("br")],
1038
+ [k.QUOTE, a("blockquote")],
1039
+ [k.COMPONENT, x],
1040
+ [X.TEXT, y],
1017
1041
  [v.LINK, w],
1018
1042
  [v.ANCHOR, w],
1019
1043
  [v.STYLED, g("span", !0)],
@@ -1030,7 +1054,7 @@ function et(r = {}) {
1030
1054
  ]);
1031
1055
  function U(c) {
1032
1056
  e += 1;
1033
- const m = te.get(c.type);
1057
+ const m = ee.get(c.type);
1034
1058
  if (!m)
1035
1059
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1036
1060
  if (c.type === "text")
@@ -1049,7 +1073,7 @@ function et(r = {}) {
1049
1073
  render: P
1050
1074
  };
1051
1075
  }
1052
- let H, G = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1076
+ let H, V = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1053
1077
  const tt = (r, e, t = {}) => {
1054
1078
  var s;
1055
1079
  const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
@@ -1073,18 +1097,18 @@ const tt = (r, e, t = {}) => {
1073
1097
  accessToken: o,
1074
1098
  use: n = [],
1075
1099
  apiOptions: i = {},
1076
- richText: l = {},
1077
- bridgeUrl: a
1100
+ richText: a = {},
1101
+ bridgeUrl: l
1078
1102
  } = r;
1079
1103
  i.accessToken = i.accessToken || o;
1080
1104
  const h = { bridge: s, apiOptions: i };
1081
1105
  let u = {};
1082
1106
  n.forEach((g) => {
1083
1107
  u = { ...u, ...g(h) };
1084
- }), a && (G = a);
1108
+ }), l && (V = l);
1085
1109
  const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1086
- return s !== !1 && d && ue(G), H = new L(l.schema), l.resolver && Q(H, l.resolver), u;
1087
- }, Q = (r, e) => {
1110
+ return s !== !1 && d && he(V), H = new L(a.schema), a.resolver && W(H, a.resolver), u;
1111
+ }, W = (r, e) => {
1088
1112
  r.addNode("blok", (t) => {
1089
1113
  let s = "";
1090
1114
  return t.attrs.body.forEach((o) => {
@@ -1101,31 +1125,31 @@ const tt = (r, e, t = {}) => {
1101
1125
  );
1102
1126
  return;
1103
1127
  }
1104
- return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && Q(s, e.resolver)), s.render(r, {}, !1));
1105
- }, Z = /* @__PURE__ */ K({
1128
+ return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && W(s, e.resolver)), s.render(r, {}, !1));
1129
+ }, Q = /* @__PURE__ */ G({
1106
1130
  __name: "StoryblokComponent",
1107
1131
  props: {
1108
1132
  blok: {}
1109
1133
  },
1110
1134
  setup(r, { expose: e }) {
1111
- const t = r, s = C();
1135
+ const t = r, s = O();
1112
1136
  e({
1113
1137
  value: s
1114
1138
  });
1115
- const o = typeof N(t.blok.component) != "string", n = ne("VueSDKOptions"), i = C(t.blok.component);
1116
- return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
1139
+ const o = typeof N(t.blok.component) != "string", n = oe("VueSDKOptions"), i = O(t.blok.component);
1140
+ return !o && n && (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
1117
1141
  `Is the Fallback component "${i.value}" registered properly?`
1118
1142
  )) : console.error(
1119
1143
  `Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
1120
- )), (l, a) => (J(), Y(N(i.value), ie({
1144
+ )), (a, l) => (K(), J(N(i.value), ne({
1121
1145
  ref_key: "blokRef",
1122
1146
  ref: s
1123
- }, { ...l.$props, ...l.$attrs }), null, 16));
1147
+ }, { ...a.$props, ...a.$attrs }), null, 16));
1124
1148
  }
1125
1149
  }), ot = (r) => {
1126
1150
  var e, t;
1127
- return X(
1128
- Z,
1151
+ return Y(
1152
+ Q,
1129
1153
  {
1130
1154
  blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
1131
1155
  id: (t = r.attrs) == null ? void 0 : t.id
@@ -1135,8 +1159,8 @@ const tt = (r, e, t = {}) => {
1135
1159
  };
1136
1160
  function nt(r) {
1137
1161
  const e = {
1138
- renderFn: X,
1139
- textFn: ae,
1162
+ renderFn: Y,
1163
+ textFn: ie,
1140
1164
  keyedResolvers: !0,
1141
1165
  resolvers: {
1142
1166
  [k.COMPONENT]: ot,
@@ -1145,15 +1169,15 @@ function nt(r) {
1145
1169
  };
1146
1170
  return et(e);
1147
1171
  }
1148
- const it = /* @__PURE__ */ K({
1172
+ const it = /* @__PURE__ */ G({
1149
1173
  __name: "StoryblokRichText",
1150
1174
  props: {
1151
1175
  doc: {},
1152
1176
  resolvers: {}
1153
1177
  },
1154
1178
  setup(r) {
1155
- const e = r, t = C(), s = () => t.value;
1156
- return le(
1179
+ const e = r, t = O(), s = () => t.value;
1180
+ return ae(
1157
1181
  [e.doc, e.resolvers],
1158
1182
  ([o, n]) => {
1159
1183
  const { render: i } = nt({
@@ -1164,7 +1188,7 @@ const it = /* @__PURE__ */ K({
1164
1188
  {
1165
1189
  immediate: !0
1166
1190
  }
1167
- ), (o, n) => (J(), Y(s));
1191
+ ), (o, n) => (K(), J(s));
1168
1192
  }
1169
1193
  }), at = {
1170
1194
  beforeMount(r, e) {
@@ -1173,35 +1197,36 @@ const it = /* @__PURE__ */ K({
1173
1197
  Object.keys(t).length > 0 && (r.setAttribute("data-blok-c", t["data-blok-c"]), r.setAttribute("data-blok-uid", t["data-blok-uid"]), r.classList.add("storyblok__outline"));
1174
1198
  }
1175
1199
  }
1176
- }, ee = (r) => {
1200
+ }, Z = (r) => {
1177
1201
  console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
1178
1202
  `);
1179
1203
  };
1180
- let j = null;
1181
- const ut = () => (j || ee("useStoryblokApi"), j), pt = async (r, e = {}, t = {}) => {
1182
- const s = C(null);
1183
- if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, ce(() => {
1204
+ let I = null;
1205
+ const ut = () => (I || Z("useStoryblokApi"), I), dt = async (r, e = {}, t = {}) => {
1206
+ const s = O(null);
1207
+ if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, le(() => {
1184
1208
  s.value && s.value.id && tt(
1185
1209
  s.value.id,
1186
1210
  (o) => s.value = o,
1187
1211
  t
1188
1212
  );
1189
- }), j) {
1190
- const { data: o } = await j.get(
1213
+ }), I) {
1214
+ const { data: o } = await I.get(
1191
1215
  `cdn/stories/${r}`,
1192
1216
  e
1193
1217
  );
1194
1218
  s.value = o.story;
1195
- } else ee("useStoryblok");
1219
+ } else
1220
+ Z("useStoryblok");
1196
1221
  return s;
1197
- }, dt = {
1222
+ }, pt = {
1198
1223
  install(r, e = {}) {
1199
- r.directive("editable", at), r.component("StoryblokComponent", Z), r.component("StoryblokRichText", it), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
1224
+ r.directive("editable", at), r.component("StoryblokComponent", Q), r.component("StoryblokRichText", it), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
1200
1225
  "FallbackComponent",
1201
- he(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
1226
+ ce(() => import("./FallbackComponent-U_HRL08c.js"))
1202
1227
  );
1203
1228
  const { storyblokApi: t } = rt(e);
1204
- j = t, r.provide("VueSDKOptions", e);
1229
+ I = t || null, r.provide("VueSDKOptions", e);
1205
1230
  }
1206
1231
  };
1207
1232
  export {
@@ -1209,14 +1234,14 @@ export {
1209
1234
  v as MarkTypes,
1210
1235
  L as RichTextResolver,
1211
1236
  ze as RichTextSchema,
1212
- Z as StoryblokComponent,
1237
+ Q as StoryblokComponent,
1213
1238
  it as StoryblokRichText,
1214
- dt as StoryblokVue,
1215
- W as TextTypes,
1239
+ pt as StoryblokVue,
1240
+ X as TextTypes,
1216
1241
  ct as apiPlugin,
1217
1242
  ht as renderRichText,
1218
1243
  et as richTextResolver,
1219
- pt as useStoryblok,
1244
+ dt as useStoryblok,
1220
1245
  ut as useStoryblokApi,
1221
1246
  tt as useStoryblokBridge,
1222
1247
  nt as useStoryblokRichText