@storyblok/vue 8.2.1 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,84 +4,84 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- import { defineComponent as J, ref as O, resolveDynamicComponent as H, inject as he, createBlock as K, openBlock as Y, mergeProps as ue, h as W, createTextVNode as de, watch as pe, onMounted as ge, defineAsyncComponent as me } from "vue";
8
- let B = !1;
9
- const z = [], fe = (s) => new Promise((e, t) => {
7
+ import { defineComponent as J, ref as O, resolveDynamicComponent as H, inject as de, createBlock as Y, openBlock as W, mergeProps as pe, h as X, createTextVNode as ge, watch as fe, onMounted as me, defineAsyncComponent as ye } from "vue";
8
+ let z = !1;
9
+ const F = [], be = (r) => new Promise((e, t) => {
10
10
  if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
11
11
  if (window.location === window.parent.location) {
12
12
  console.warn("You are not in Draft Mode or in the Visual Editor.");
13
13
  return;
14
14
  }
15
- B ? o() : z.push(o);
15
+ z ? o() : F.push(o);
16
16
  }, document.getElementById("storyblok-javascript-bridge")))
17
17
  return;
18
- const r = document.createElement("script");
19
- r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (o) => t(o), r.onload = (o) => {
20
- z.forEach((n) => n()), B = !0, e(o);
21
- }, document.getElementsByTagName("head")[0].appendChild(r);
18
+ const s = document.createElement("script");
19
+ s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
20
+ F.forEach((n) => n()), z = !0, e(o);
21
+ }, document.getElementsByTagName("head")[0].appendChild(s);
22
22
  });
23
- var ye = Object.defineProperty, be = (s, e, t) => e in s ? ye(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, g = (s, e, t) => be(s, typeof e != "symbol" ? e + "" : e, t);
24
- class ke extends Error {
23
+ var ke = Object.defineProperty, ve = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e, t) => ve(r, typeof e != "symbol" ? e + "" : e, t);
24
+ class $e extends Error {
25
25
  constructor(e) {
26
26
  super(e), this.name = "AbortError";
27
27
  }
28
28
  }
29
- function ve(s, e, t) {
29
+ function Te(r, e, t) {
30
30
  if (!Number.isFinite(e))
31
31
  throw new TypeError("Expected `limit` to be a finite number");
32
32
  if (!Number.isFinite(t))
33
33
  throw new TypeError("Expected `interval` to be a finite number");
34
- const r = [];
34
+ const s = [];
35
35
  let o = [], n = 0, a = !1;
36
- const l = async () => {
36
+ const i = async () => {
37
37
  n++;
38
- const h = r.shift();
38
+ const h = s.shift();
39
39
  if (h)
40
40
  try {
41
- const p = await s(...h.args);
41
+ const p = await r(...h.args);
42
42
  h.resolve(p);
43
43
  } catch (p) {
44
44
  h.reject(p);
45
45
  }
46
- const d = setTimeout(() => {
47
- n--, r.length > 0 && l(), o = o.filter((p) => p !== d);
46
+ const u = setTimeout(() => {
47
+ n--, s.length > 0 && i(), o = o.filter((p) => p !== u);
48
48
  }, t);
49
- o.includes(d) || o.push(d);
50
- }, i = (...h) => a ? Promise.reject(
49
+ o.includes(u) || o.push(u);
50
+ }, l = (...h) => a ? Promise.reject(
51
51
  new Error(
52
52
  "Throttled function is already aborted and not accepting new promises"
53
53
  )
54
- ) : new Promise((d, p) => {
55
- r.push({
56
- resolve: d,
54
+ ) : new Promise((u, p) => {
55
+ s.push({
56
+ resolve: u,
57
57
  reject: p,
58
58
  args: h
59
- }), n < e && l();
59
+ }), n < e && i();
60
60
  });
61
- return i.abort = () => {
62
- a = !0, o.forEach(clearTimeout), o = [], r.forEach(
63
- (h) => h.reject(() => new ke("Throttle function aborted"))
64
- ), r.length = 0;
65
- }, i;
61
+ return l.abort = () => {
62
+ a = !0, o.forEach(clearTimeout), o = [], s.forEach(
63
+ (h) => h.reject(() => new $e("Throttle function aborted"))
64
+ ), s.length = 0;
65
+ }, l;
66
66
  }
67
67
  class P {
68
68
  constructor() {
69
- g(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), g(this, "getOptionsPage", (e, t = 25, r = 1) => ({
69
+ m(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), m(this, "getOptionsPage", (e, t = 25, s = 1) => ({
70
70
  ...e,
71
71
  per_page: t,
72
- page: r
73
- })), g(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), g(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), g(this, "range", (e = 0, t = e) => {
74
- const r = Math.abs(t - e) || 0, o = e < t ? 1 : -1;
75
- return this.arrayFrom(r, (n, a) => a * o + e);
76
- }), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((r, o) => [...r, ...o], [])), g(this, "escapeHTML", function(e) {
72
+ page: s
73
+ })), m(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), m(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), m(this, "range", (e = 0, t = e) => {
74
+ const s = Math.abs(t - e) || 0, o = e < t ? 1 : -1;
75
+ return this.arrayFrom(s, (n, a) => a * o + e);
76
+ }), m(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), m(this, "flatMap", (e = [], t) => e.map(t).reduce((s, o) => [...s, ...o], [])), m(this, "escapeHTML", function(e) {
77
77
  const t = {
78
78
  "&": "&amp;",
79
79
  "<": "&lt;",
80
80
  ">": "&gt;",
81
81
  '"': "&quot;",
82
82
  "'": "&#39;"
83
- }, r = /[&<>"']/g, o = new RegExp(r.source);
84
- return e && o.test(e) ? e.replace(r, (n) => t[n]) : e;
83
+ }, s = /[&<>"']/g, o = new RegExp(s.source);
84
+ return e && o.test(e) ? e.replace(s, (n) => t[n]) : e;
85
85
  });
86
86
  }
87
87
  /**
@@ -91,7 +91,7 @@ class P {
91
91
  * @param {boolean} isArray
92
92
  * @return {string} Stringified object
93
93
  */
94
- stringify(e, t, r) {
94
+ stringify(e, t, s) {
95
95
  const o = [];
96
96
  for (const n in e) {
97
97
  if (!Object.prototype.hasOwnProperty.call(e, n))
@@ -99,13 +99,13 @@ class P {
99
99
  const a = e[n];
100
100
  if (a == null)
101
101
  continue;
102
- const l = r ? "" : encodeURIComponent(n);
103
- let i;
104
- typeof a == "object" ? i = this.stringify(
102
+ const i = s ? "" : encodeURIComponent(n);
103
+ let l;
104
+ typeof a == "object" ? l = this.stringify(
105
105
  a,
106
- t ? t + encodeURIComponent(`[${l}]`) : l,
106
+ t ? t + encodeURIComponent(`[${i}]`) : i,
107
107
  Array.isArray(a)
108
- ) : i = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(a)}`, o.push(i);
108
+ ) : l = `${t ? t + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(a)}`, o.push(l);
109
109
  }
110
110
  return o.join("&");
111
111
  }
@@ -115,10 +115,10 @@ class P {
115
115
  * @return {string} The base URL of the region
116
116
  */
117
117
  getRegionURL(e) {
118
- const t = "api.storyblok.com", r = "api-us.storyblok.com", o = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
118
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", o = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
119
119
  switch (e) {
120
120
  case "us":
121
- return r;
121
+ return s;
122
122
  case "cn":
123
123
  return o;
124
124
  case "ap":
@@ -130,74 +130,74 @@ class P {
130
130
  }
131
131
  }
132
132
  }
133
- const $e = function(s, e) {
133
+ const we = function(r, e) {
134
134
  const t = {};
135
- for (const r in s) {
136
- const o = s[r];
137
- e.includes(r) && o !== null && (t[r] = o);
135
+ for (const s in r) {
136
+ const o = r[s];
137
+ e.includes(s) && o !== null && (t[s] = o);
138
138
  }
139
139
  return t;
140
- }, we = (s) => s === "email", Te = () => ({
140
+ }, Re = (r) => r === "email", _e = () => ({
141
141
  singleTag: "hr"
142
- }), Re = () => ({
142
+ }), Se = () => ({
143
143
  tag: "blockquote"
144
- }), _e = () => ({
144
+ }), Ee = () => ({
145
145
  tag: "ul"
146
- }), Ee = (s) => ({
146
+ }), xe = (r) => ({
147
147
  tag: [
148
148
  "pre",
149
149
  {
150
150
  tag: "code",
151
- attrs: s.attrs
151
+ attrs: r.attrs
152
152
  }
153
153
  ]
154
- }), Se = () => ({
154
+ }), je = () => ({
155
155
  singleTag: "br"
156
- }), je = (s) => ({
157
- tag: `h${s.attrs.level}`
158
- }), Ae = (s) => ({
156
+ }), Ae = (r) => ({
157
+ tag: `h${r.attrs.level}`
158
+ }), Ie = (r) => ({
159
159
  singleTag: [
160
160
  {
161
161
  tag: "img",
162
- attrs: $e(s.attrs, ["src", "alt", "title"])
162
+ attrs: we(r.attrs, ["src", "alt", "title"])
163
163
  }
164
164
  ]
165
- }), xe = () => ({
165
+ }), Ce = () => ({
166
166
  tag: "li"
167
- }), Ie = () => ({
167
+ }), Le = () => ({
168
168
  tag: "ol"
169
- }), Ce = () => ({
169
+ }), Oe = () => ({
170
170
  tag: "p"
171
- }), Le = (s) => ({
171
+ }), Pe = (r) => ({
172
172
  tag: [
173
173
  {
174
174
  tag: "span",
175
175
  attrs: {
176
176
  "data-type": "emoji",
177
- "data-name": s.attrs.name,
178
- emoji: s.attrs.emoji
177
+ "data-name": r.attrs.name,
178
+ emoji: r.attrs.emoji
179
179
  }
180
180
  }
181
181
  ]
182
- }), Oe = () => ({
182
+ }), Ne = () => ({
183
183
  tag: "b"
184
- }), Pe = () => ({
184
+ }), Me = () => ({
185
185
  tag: "s"
186
- }), Ne = () => ({
186
+ }), He = () => ({
187
187
  tag: "u"
188
- }), Me = () => ({
188
+ }), De = () => ({
189
189
  tag: "strong"
190
- }), He = () => ({
190
+ }), Ue = () => ({
191
191
  tag: "code"
192
- }), De = () => ({
192
+ }), Be = () => ({
193
193
  tag: "i"
194
- }), Ue = (s) => {
195
- if (!s.attrs)
194
+ }), ze = (r) => {
195
+ if (!r.attrs)
196
196
  return {
197
197
  tag: ""
198
198
  };
199
- const e = new P().escapeHTML, t = { ...s.attrs }, { linktype: r = "url" } = s.attrs;
200
- if (delete t.linktype, t.href && (t.href = e(s.attrs.href || "")), we(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
199
+ const e = new P().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
200
+ if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), Re(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
201
201
  for (const o in t.custom)
202
202
  t[o] = t.custom[o];
203
203
  delete t.custom;
@@ -210,110 +210,109 @@ const $e = function(s, e) {
210
210
  }
211
211
  ]
212
212
  };
213
- }, Be = (s) => ({
213
+ }, Fe = (r) => ({
214
214
  tag: [
215
215
  {
216
216
  tag: "span",
217
- attrs: s.attrs
217
+ attrs: r.attrs
218
218
  }
219
219
  ]
220
- }), ze = () => ({
220
+ }), qe = () => ({
221
221
  tag: "sub"
222
- }), Fe = () => ({
222
+ }), Ve = () => ({
223
223
  tag: "sup"
224
- }), qe = (s) => ({
224
+ }), Ge = (r) => ({
225
225
  tag: [
226
226
  {
227
227
  tag: "span",
228
- attrs: s.attrs
228
+ attrs: r.attrs
229
229
  }
230
230
  ]
231
- }), Ve = (s) => {
231
+ }), Ke = (r) => {
232
232
  var e;
233
- return (e = s.attrs) != null && e.color ? {
233
+ return (e = r.attrs) != null && e.color ? {
234
234
  tag: [
235
235
  {
236
236
  tag: "span",
237
237
  attrs: {
238
- style: `background-color:${s.attrs.color};`
238
+ style: `background-color:${r.attrs.color};`
239
239
  }
240
240
  }
241
241
  ]
242
242
  } : {
243
243
  tag: ""
244
244
  };
245
- }, Ge = (s) => {
245
+ }, Je = (r) => {
246
246
  var e;
247
- return (e = s.attrs) != null && e.color ? {
247
+ return (e = r.attrs) != null && e.color ? {
248
248
  tag: [
249
249
  {
250
250
  tag: "span",
251
251
  attrs: {
252
- style: `color:${s.attrs.color}`
252
+ style: `color:${r.attrs.color}`
253
253
  }
254
254
  }
255
255
  ]
256
256
  } : {
257
257
  tag: ""
258
258
  };
259
- }, Je = {
259
+ }, Ye = {
260
260
  nodes: {
261
- horizontal_rule: Te,
262
- blockquote: Re,
263
- bullet_list: _e,
264
- code_block: Ee,
265
- hard_break: Se,
266
- heading: je,
267
- image: Ae,
268
- list_item: xe,
269
- ordered_list: Ie,
270
- paragraph: Ce,
271
- emoji: Le
261
+ horizontal_rule: _e,
262
+ blockquote: Se,
263
+ bullet_list: Ee,
264
+ code_block: xe,
265
+ hard_break: je,
266
+ heading: Ae,
267
+ image: Ie,
268
+ list_item: Ce,
269
+ ordered_list: Le,
270
+ paragraph: Oe,
271
+ emoji: Pe
272
272
  },
273
273
  marks: {
274
- bold: Oe,
275
- strike: Pe,
276
- underline: Ne,
277
- strong: Me,
278
- code: He,
279
- italic: De,
280
- link: Ue,
281
- styled: Be,
282
- subscript: ze,
283
- superscript: Fe,
284
- anchor: qe,
285
- highlight: Ve,
286
- textStyle: Ge
287
- }
288
- }, Ke = function(s) {
274
+ bold: Ne,
275
+ strike: Me,
276
+ underline: He,
277
+ strong: De,
278
+ code: Ue,
279
+ italic: Be,
280
+ link: ze,
281
+ styled: Fe,
282
+ subscript: qe,
283
+ superscript: Ve,
284
+ anchor: Ge,
285
+ highlight: Ke,
286
+ textStyle: Je
287
+ }
288
+ }, We = function(r) {
289
289
  const e = {
290
290
  "&": "&amp;",
291
291
  "<": "&lt;",
292
292
  ">": "&gt;",
293
293
  '"': "&quot;",
294
294
  "'": "&#39;"
295
- }, t = /[&<>"']/g, r = new RegExp(t.source);
296
- return s && r.test(s) ? s.replace(t, (o) => e[o]) : s;
295
+ }, t = /[&<>"']/g, s = new RegExp(t.source);
296
+ return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
297
297
  };
298
- let F = !1;
299
- class N {
300
- constructor(e) {
301
- g(this, "marks"), g(this, "nodes"), e || (e = Je), this.marks = e.marks || [], this.nodes = e.nodes || [];
298
+ let q = !1, N = class {
299
+ constructor(r) {
300
+ m(this, "marks"), m(this, "nodes"), r || (r = Ye), this.marks = r.marks || [], this.nodes = r.nodes || [];
302
301
  }
303
- addNode(e, t) {
304
- this.nodes[e] = t;
302
+ addNode(r, e) {
303
+ this.nodes[r] = e;
305
304
  }
306
- addMark(e, t) {
307
- this.marks[e] = t;
305
+ addMark(r, e) {
306
+ this.marks[r] = e;
308
307
  }
309
- render(e, t = { optimizeImages: !1 }, r = !0) {
310
- if (!F && r && (console.warn(
308
+ render(r, e = { optimizeImages: !1 }, t = !0) {
309
+ if (!q && t && (console.warn(
311
310
  "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/"
312
- ), F = !0), e && e.content && Array.isArray(e.content)) {
313
- let o = "";
314
- return e.content.forEach((n) => {
315
- o += this.renderNode(n);
316
- }), t.optimizeImages ? this.optimizeImages(o, t.optimizeImages) : o;
311
+ ), q = !0), r && r.content && Array.isArray(r.content)) {
312
+ let s = "";
313
+ return r.content.forEach((o) => {
314
+ s += this.renderNode(o);
315
+ }), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
317
316
  }
318
317
  return console.warn(
319
318
  `The render method must receive an Object with a "content" field.
@@ -342,104 +341,104 @@ class N {
342
341
  }`
343
342
  ), "";
344
343
  }
345
- optimizeImages(e, t) {
346
- let r = 0, o = 0, n = "", a = "";
347
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, r = 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 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
348
- const l = r > 0 || o > 0 || a.length > 0 ? `${r}x${o}${a}` : "";
349
- return e = e.replace(
344
+ optimizeImages(r, e) {
345
+ let t = 0, s = 0, o = "", n = "";
346
+ typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (o += `width="${e.width}" `, t = e.width), typeof e.height == "number" && e.height > 0 && (o += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (o += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (o += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (n += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (n += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-F]{6}/gi) || e.filters.fill === "transparent") && (n += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (n += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (n += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (n += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (n += `:rotate(${e.filters.rotate})`), n.length > 0 && (n = `/filters${n}`))), o.length > 0 && (r = r.replace(/<img/g, `<img ${o.trim()}`));
347
+ const a = t > 0 || s > 0 || n.length > 0 ? `${t}x${s}${n}` : "";
348
+ return r = r.replace(
350
349
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
351
- `a.storyblok.com/f/$1/$2.$3/m/${l}`
352
- ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
353
- var h, d;
354
- const p = i.match(
350
+ `a.storyblok.com/f/$1/$2.$3/m/${a}`
351
+ ), typeof e != "boolean" && (e.sizes || e.srcset) && (r = r.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
352
+ var l, h;
353
+ const u = i.match(
355
354
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
356
355
  );
357
- if (p && p.length > 0) {
358
- const b = {
359
- srcset: (h = t.srcset) == null ? void 0 : h.map((w) => {
360
- if (typeof w == "number")
361
- return `//${p}/m/${w}x0${a} ${w}w`;
362
- if (typeof w == "object" && w.length === 2) {
363
- let E = 0, j = 0;
364
- return typeof w[0] == "number" && (E = w[0]), typeof w[1] == "number" && (j = w[1]), `//${p}/m/${E}x${j}${a} ${E}w`;
356
+ if (u && u.length > 0) {
357
+ const p = {
358
+ srcset: (l = e.srcset) == null ? void 0 : l.map(($) => {
359
+ if (typeof $ == "number")
360
+ return `//${u}/m/${$}x0${n} ${$}w`;
361
+ if (typeof $ == "object" && $.length === 2) {
362
+ let T = 0, E = 0;
363
+ return typeof $[0] == "number" && (T = $[0]), typeof $[1] == "number" && (E = $[1]), `//${u}/m/${T}x${E}${n} ${T}w`;
365
364
  }
366
365
  return "";
367
366
  }).join(", "),
368
- sizes: (d = t.sizes) == null ? void 0 : d.map((w) => w).join(", ")
367
+ sizes: (h = e.sizes) == null ? void 0 : h.map(($) => $).join(", ")
369
368
  };
370
- let v = "";
371
- return b.srcset && (v += `srcset="${b.srcset}" `), b.sizes && (v += `sizes="${b.sizes}" `), i.replace(/<img/g, `<img ${v.trim()}`);
369
+ let b = "";
370
+ return p.srcset && (b += `srcset="${p.srcset}" `), p.sizes && (b += `sizes="${p.sizes}" `), i.replace(/<img/g, `<img ${b.trim()}`);
372
371
  }
373
372
  return i;
374
- })), e;
373
+ })), r;
375
374
  }
376
- renderNode(e) {
377
- const t = [];
378
- e.marks && e.marks.forEach((o) => {
379
- const n = this.getMatchingMark(o);
380
- n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
375
+ renderNode(r) {
376
+ const e = [];
377
+ r.marks && r.marks.forEach((s) => {
378
+ const o = this.getMatchingMark(s);
379
+ o && o.tag !== "" && e.push(this.renderOpeningTag(o.tag));
381
380
  });
382
- const r = this.getMatchingNode(e);
383
- return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
384
- t.push(this.renderNode(o));
385
- }) : e.text ? t.push(Ke(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html ? t.push(r.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
386
- const n = this.getMatchingMark(o);
387
- n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
388
- }), t.join("");
389
- }
390
- renderTag(e, t) {
391
- return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
392
- if (r.constructor === String)
393
- return `<${r}${t}>`;
381
+ const t = this.getMatchingNode(r);
382
+ return t && t.tag && e.push(this.renderOpeningTag(t.tag)), r.content ? r.content.forEach((s) => {
383
+ e.push(this.renderNode(s));
384
+ }) : r.text ? e.push(We(r.text)) : t && t.singleTag ? e.push(this.renderTag(t.singleTag, " /")) : t && t.html ? e.push(t.html) : r.type === "emoji" && e.push(this.renderEmoji(r)), t && t.tag && e.push(this.renderClosingTag(t.tag)), r.marks && r.marks.slice(0).reverse().forEach((s) => {
385
+ const o = this.getMatchingMark(s);
386
+ o && o.tag !== "" && e.push(this.renderClosingTag(o.tag));
387
+ }), e.join("");
388
+ }
389
+ renderTag(r, e) {
390
+ return r.constructor === String ? `<${r}${e}>` : r.map((t) => {
391
+ if (t.constructor === String)
392
+ return `<${t}${e}>`;
394
393
  {
395
- let o = `<${r.tag}`;
396
- if (r.attrs) {
397
- for (const n in r.attrs)
398
- if (Object.prototype.hasOwnProperty.call(r.attrs, n)) {
399
- const a = r.attrs[n];
400
- a !== null && (o += ` ${n}="${a}"`);
394
+ let s = `<${t.tag}`;
395
+ if (t.attrs) {
396
+ for (const o in t.attrs)
397
+ if (Object.prototype.hasOwnProperty.call(t.attrs, o)) {
398
+ const n = t.attrs[o];
399
+ n !== null && (s += ` ${o}="${n}"`);
401
400
  }
402
401
  }
403
- return `${o}${t}>`;
402
+ return `${s}${e}>`;
404
403
  }
405
404
  }).join("");
406
405
  }
407
- renderOpeningTag(e) {
408
- return this.renderTag(e, "");
406
+ renderOpeningTag(r) {
407
+ return this.renderTag(r, "");
409
408
  }
410
- renderClosingTag(e) {
411
- return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
409
+ renderClosingTag(r) {
410
+ return r.constructor === String ? `</${r}>` : r.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
412
411
  }
413
- getMatchingNode(e) {
414
- const t = this.nodes[e.type];
415
- if (typeof t == "function")
416
- return t(e);
412
+ getMatchingNode(r) {
413
+ const e = this.nodes[r.type];
414
+ if (typeof e == "function")
415
+ return e(r);
417
416
  }
418
- getMatchingMark(e) {
419
- const t = this.marks[e.type];
420
- if (typeof t == "function")
421
- return t(e);
417
+ getMatchingMark(r) {
418
+ const e = this.marks[r.type];
419
+ if (typeof e == "function")
420
+ return e(r);
422
421
  }
423
- renderEmoji(e) {
424
- if (e.attrs.emoji)
425
- return e.attrs.emoji;
426
- const t = [
422
+ renderEmoji(r) {
423
+ if (r.attrs.emoji)
424
+ return r.attrs.emoji;
425
+ const e = [
427
426
  {
428
427
  tag: "img",
429
428
  attrs: {
430
- src: e.attrs.fallbackImage,
429
+ src: r.attrs.fallbackImage,
431
430
  draggable: "false",
432
431
  loading: "lazy",
433
432
  align: "absmiddle"
434
433
  }
435
434
  }
436
435
  ];
437
- return this.renderTag(t, " /");
436
+ return this.renderTag(e, " /");
438
437
  }
439
- }
440
- class Ye {
438
+ };
439
+ class Xe {
441
440
  constructor(e) {
442
- g(this, "baseURL"), g(this, "timeout"), g(this, "headers"), g(this, "responseInterceptor"), g(this, "fetch"), g(this, "ejectInterceptor"), g(this, "url"), g(this, "parameters"), g(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 = {};
441
+ m(this, "baseURL"), m(this, "timeout"), m(this, "headers"), m(this, "responseInterceptor"), m(this, "fetch"), m(this, "ejectInterceptor"), m(this, "url"), m(this, "parameters"), m(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 = {};
443
442
  }
444
443
  /**
445
444
  *
@@ -460,47 +459,47 @@ class Ye {
460
459
  return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
461
460
  }
462
461
  async _responseHandler(e) {
463
- const t = [], r = {
462
+ const t = [], s = {
464
463
  data: {},
465
464
  headers: {},
466
465
  status: 0,
467
466
  statusText: ""
468
467
  };
469
468
  e.status !== 204 && await e.json().then((o) => {
470
- r.data = o;
469
+ s.data = o;
471
470
  });
472
471
  for (const o of e.headers.entries())
473
472
  t[o[0]] = o[1];
474
- return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
473
+ return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
475
474
  }
476
475
  async _methodHandler(e) {
477
- let t = `${this.baseURL}${this.url}`, r = null;
476
+ let t = `${this.baseURL}${this.url}`, s = null;
478
477
  if (e === "get") {
479
- const i = new P();
480
- t = `${this.baseURL}${this.url}?${i.stringify(
478
+ const l = new P();
479
+ t = `${this.baseURL}${this.url}?${l.stringify(
481
480
  this.parameters
482
481
  )}`;
483
482
  } else
484
- r = JSON.stringify(this.parameters);
483
+ s = JSON.stringify(this.parameters);
485
484
  const o = new URL(t), n = new AbortController(), { signal: a } = n;
486
- let l;
487
- this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
485
+ let i;
486
+ this.timeout && (i = setTimeout(() => n.abort(), this.timeout));
488
487
  try {
489
- const i = await this.fetch(`${o}`, {
488
+ const l = await this.fetch(`${o}`, {
490
489
  method: e,
491
490
  headers: this.headers,
492
- body: r,
491
+ body: s,
493
492
  signal: a,
494
493
  ...this.fetchOptions
495
494
  });
496
- this.timeout && clearTimeout(l);
495
+ this.timeout && clearTimeout(i);
497
496
  const h = await this._responseHandler(
498
- i
497
+ l
499
498
  );
500
499
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
501
- } catch (i) {
500
+ } catch (l) {
502
501
  return {
503
- message: i
502
+ message: l
504
503
  };
505
504
  }
506
505
  }
@@ -512,9 +511,9 @@ class Ye {
512
511
  }
513
512
  _statusHandler(e) {
514
513
  const t = /20[0-6]/g;
515
- return new Promise((r, o) => {
514
+ return new Promise((s, o) => {
516
515
  if (t.test(`${e.status}`))
517
- return r(e);
516
+ return s(e);
518
517
  const n = {
519
518
  message: e.statusText,
520
519
  status: e.status,
@@ -524,40 +523,40 @@ class Ye {
524
523
  });
525
524
  }
526
525
  }
527
- const q = "SB-Agent", D = {
526
+ const V = "SB-Agent", D = {
528
527
  defaultAgentName: "SB-JS-CLIENT",
529
528
  defaultAgentVersion: "SB-Agent-Version",
530
529
  packageVersion: "6.0.0"
531
530
  };
532
531
  let C = {};
533
- const S = {};
534
- class We {
532
+ const x = {};
533
+ class Qe {
535
534
  /**
536
535
  *
537
536
  * @param config ISbConfig interface
538
537
  * @param pEndpoint string, optional
539
538
  */
540
539
  constructor(e, t) {
541
- g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "helpers"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache");
542
- let r = e.endpoint || t;
543
- if (!r) {
544
- const a = new P().getRegionURL, l = e.https === !1 ? "http" : "https";
545
- e.oauthToken ? r = `${l}://${a(e.region)}/v1` : r = `${l}://${a(e.region)}/v2`;
540
+ m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "helpers"), m(this, "resolveCounter"), m(this, "relations"), m(this, "links"), m(this, "richTextResolver"), m(this, "resolveNestedRelations"), m(this, "stringifiedStoriesCache");
541
+ let s = e.endpoint || t;
542
+ if (!s) {
543
+ const a = new P().getRegionURL, i = e.https === !1 ? "http" : "https";
544
+ e.oauthToken ? s = `${i}://${a(e.region)}/v1` : s = `${i}://${a(e.region)}/v2`;
546
545
  }
547
546
  const o = new Headers();
548
- 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(([a, l]) => {
549
- o.set(a, l);
550
- }), o.has(q) || (o.set(q, D.defaultAgentName), o.set(
547
+ 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(([a, i]) => {
548
+ o.set(a, i);
549
+ }), o.has(V) || (o.set(V, D.defaultAgentName), o.set(
551
550
  D.defaultAgentVersion,
552
551
  D.packageVersion
553
552
  ));
554
553
  let n = 5;
555
- e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new N(e.richTextSchema) : this.richTextResolver = new N(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ve(
554
+ e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new N(e.richTextSchema) : this.richTextResolver = new N(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Te(
556
555
  this.throttledRequest.bind(this),
557
556
  n,
558
557
  1e3
559
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new P(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ye({
560
- baseURL: r,
558
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new P(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Xe({
559
+ baseURL: s,
561
560
  timeout: e.timeout || 0,
562
561
  headers: o,
563
562
  responseInterceptor: e.responseInterceptor,
@@ -566,69 +565,69 @@ class We {
566
565
  }
567
566
  setComponentResolver(e) {
568
567
  this.richTextResolver.addNode("blok", (t) => {
569
- let r = "";
568
+ let s = "";
570
569
  return t.attrs.body && t.attrs.body.forEach((o) => {
571
- r += e(o.component, o);
570
+ s += e(o.component, o);
572
571
  }), {
573
- html: r
572
+ html: s
574
573
  };
575
574
  });
576
575
  }
577
576
  parseParams(e) {
578
- return e.token || (e.token = this.getToken()), e.cv || (e.cv = S[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
577
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = x[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
579
578
  }
580
579
  factoryParamOptions(e, t) {
581
580
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
582
581
  }
583
- makeRequest(e, t, r, o, n) {
582
+ makeRequest(e, t, s, o, n) {
584
583
  const a = this.factoryParamOptions(
585
584
  e,
586
- this.helpers.getOptionsPage(t, r, o)
585
+ this.helpers.getOptionsPage(t, s, o)
587
586
  );
588
587
  return this.cacheResponse(e, a, void 0, n);
589
588
  }
590
- get(e, t, r) {
589
+ get(e, t, s) {
591
590
  t || (t = {});
592
591
  const o = `/${e}`, n = this.factoryParamOptions(o, t);
593
- return this.cacheResponse(o, n, void 0, r);
592
+ return this.cacheResponse(o, n, void 0, s);
594
593
  }
595
- async getAll(e, t, r, o) {
596
- const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = r ?? a.substring(a.lastIndexOf("/") + 1), i = 1, h = await this.makeRequest(
594
+ async getAll(e, t, s, o) {
595
+ const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), i = s ?? a.substring(a.lastIndexOf("/") + 1), l = 1, h = await this.makeRequest(
597
596
  a,
598
597
  t,
599
598
  n,
600
- i,
599
+ l,
601
600
  o
602
- ), d = h.total ? Math.ceil(h.total / n) : 1, p = await this.helpers.asyncMap(
603
- this.helpers.range(i, d),
601
+ ), u = h.total ? Math.ceil(h.total / n) : 1, p = await this.helpers.asyncMap(
602
+ this.helpers.range(l, u),
604
603
  (b) => this.makeRequest(a, t, n, b + 1, o)
605
604
  );
606
- return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[l]));
605
+ return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[i]));
607
606
  }
608
- post(e, t, r) {
607
+ post(e, t, s) {
609
608
  const o = `/${e}`;
610
609
  return Promise.resolve(
611
- this.throttle("post", o, t, r)
610
+ this.throttle("post", o, t, s)
612
611
  );
613
612
  }
614
- put(e, t, r) {
613
+ put(e, t, s) {
615
614
  const o = `/${e}`;
616
615
  return Promise.resolve(
617
- this.throttle("put", o, t, r)
616
+ this.throttle("put", o, t, s)
618
617
  );
619
618
  }
620
- delete(e, t, r) {
619
+ delete(e, t, s) {
621
620
  t || (t = {});
622
621
  const o = `/${e}`;
623
622
  return Promise.resolve(
624
- this.throttle("delete", o, t, r)
623
+ this.throttle("delete", o, t, s)
625
624
  );
626
625
  }
627
626
  getStories(e, t) {
628
627
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
629
628
  }
630
- getStory(e, t, r) {
631
- return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
629
+ getStory(e, t, s) {
630
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
632
631
  }
633
632
  getToken() {
634
633
  return this.accessToken;
@@ -642,9 +641,9 @@ class We {
642
641
  _cleanCopy(e) {
643
642
  return JSON.parse(JSON.stringify(e));
644
643
  }
645
- _insertLinks(e, t, r) {
644
+ _insertLinks(e, t, s) {
646
645
  const o = e[t];
647
- o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[r][o.id] ? o.story = this._cleanCopy(this.links[r][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[r][o.uuid] && (o.story = this._cleanCopy(this.links[r][o.uuid]));
646
+ 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]));
648
647
  }
649
648
  /**
650
649
  *
@@ -665,10 +664,10 @@ class We {
665
664
  * - For single strings: directly replaces the UUID with the story reference
666
665
  * - For arrays: maps through each UUID and replaces with corresponding story references
667
666
  */
668
- _resolveField(e, t, r) {
667
+ _resolveField(e, t, s) {
669
668
  const o = e[t];
670
- typeof o == "string" ? e[t] = this.getStoryReference(r, o) : Array.isArray(o) && (e[t] = o.map(
671
- (n) => this.getStoryReference(r, n)
669
+ typeof o == "string" ? e[t] = this.getStoryReference(s, o) : Array.isArray(o) && (e[t] = o.map(
670
+ (n) => this.getStoryReference(s, n)
672
671
  ).filter(Boolean));
673
672
  }
674
673
  /**
@@ -688,13 +687,13 @@ class We {
688
687
  * The method supports both string and array formats for the fields parameter,
689
688
  * allowing flexible specification of relation patterns.
690
689
  */
691
- _insertRelations(e, t, r, o) {
692
- if (Array.isArray(r) ? r.find((a) => a.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
690
+ _insertRelations(e, t, s, o) {
691
+ if (Array.isArray(s) ? s.find((a) => a.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
693
692
  this._resolveField(e, t, o);
694
693
  return;
695
694
  }
696
695
  const n = e.component ? `${e.component}.${t}` : t;
697
- (Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, o);
696
+ (Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, o);
698
697
  }
699
698
  /**
700
699
  * Recursively traverses and resolves relations in the story content tree
@@ -702,35 +701,35 @@ class We {
702
701
  * @param fields - The relation patterns to resolve
703
702
  * @param resolveId - The unique identifier for the current resolution context
704
703
  */
705
- iterateTree(e, t, r) {
704
+ iterateTree(e, t, s) {
706
705
  const o = (n, a = "") => {
707
706
  if (!(!n || n._stopResolving)) {
708
707
  if (Array.isArray(n))
709
- n.forEach((l, i) => o(l, `${a}[${i}]`));
708
+ n.forEach((i, l) => o(i, `${a}[${l}]`));
710
709
  else if (typeof n == "object")
711
- for (const l in n) {
712
- const i = a ? `${a}.${l}` : l;
713
- (n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, r), this._insertLinks(n, l, r)), o(n[l], i);
710
+ for (const i in n) {
711
+ const l = a ? `${a}.${i}` : i;
712
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, i, t, s), this._insertLinks(n, i, s)), o(n[i], l);
714
713
  }
715
714
  }
716
715
  };
717
716
  o(e.content);
718
717
  }
719
- async resolveLinks(e, t, r) {
718
+ async resolveLinks(e, t, s) {
720
719
  let o = [];
721
720
  if (e.link_uuids) {
722
- const n = e.link_uuids.length, a = [], l = 50;
723
- for (let i = 0; i < n; i += l) {
724
- const h = Math.min(n, i + l);
725
- a.push(e.link_uuids.slice(i, h));
721
+ const n = e.link_uuids.length, a = [], i = 50;
722
+ for (let l = 0; l < n; l += i) {
723
+ const h = Math.min(n, l + i);
724
+ a.push(e.link_uuids.slice(l, h));
726
725
  }
727
- for (let i = 0; i < a.length; i++)
726
+ for (let l = 0; l < a.length; l++)
728
727
  (await this.getStories({
729
- per_page: l,
728
+ per_page: i,
730
729
  language: t.language,
731
730
  version: t.version,
732
731
  starts_with: t.starts_with,
733
- by_uuids: a[i].join(",")
732
+ by_uuids: a[l].join(",")
734
733
  })).data.stories.forEach(
735
734
  (h) => {
736
735
  o.push(h);
@@ -739,27 +738,27 @@ class We {
739
738
  } else
740
739
  o = e.links;
741
740
  o.forEach((n) => {
742
- this.links[r][n.uuid] = {
741
+ this.links[s][n.uuid] = {
743
742
  ...n,
744
743
  _stopResolving: !0
745
744
  };
746
745
  });
747
746
  }
748
- async resolveRelations(e, t, r) {
747
+ async resolveRelations(e, t, s) {
749
748
  let o = [];
750
749
  if (e.rel_uuids) {
751
- const n = e.rel_uuids.length, a = [], l = 50;
752
- for (let i = 0; i < n; i += l) {
753
- const h = Math.min(n, i + l);
754
- a.push(e.rel_uuids.slice(i, h));
750
+ const n = e.rel_uuids.length, a = [], i = 50;
751
+ for (let l = 0; l < n; l += i) {
752
+ const h = Math.min(n, l + i);
753
+ a.push(e.rel_uuids.slice(l, h));
755
754
  }
756
- for (let i = 0; i < a.length; i++)
755
+ for (let l = 0; l < a.length; l++)
757
756
  (await this.getStories({
758
- per_page: l,
757
+ per_page: i,
759
758
  language: t.language,
760
759
  version: t.version,
761
760
  starts_with: t.starts_with,
762
- by_uuids: a[i].join(","),
761
+ by_uuids: a[l].join(","),
763
762
  excluding_fields: t.excluding_fields
764
763
  })).data.stories.forEach((h) => {
765
764
  o.push(h);
@@ -767,7 +766,7 @@ class We {
767
766
  } else
768
767
  o = e.rels;
769
768
  o && o.length > 0 && o.forEach((n) => {
770
- this.relations[r][n.uuid] = {
769
+ this.relations[s][n.uuid] = {
771
770
  ...n,
772
771
  _stopResolving: !0
773
772
  };
@@ -782,72 +781,72 @@ class We {
782
781
  * @returns Promise<void>
783
782
  *
784
783
  */
785
- async resolveStories(e, t, r) {
784
+ async resolveStories(e, t, s) {
786
785
  var o, n;
787
786
  let a = [];
788
- if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), 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, r), this.resolveNestedRelations)
789
- for (const l in this.relations[r])
787
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = 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)
788
+ for (const i in this.relations[s])
790
789
  this.iterateTree(
791
- this.relations[r][l],
790
+ this.relations[s][i],
792
791
  a,
793
- r
792
+ s
794
793
  );
795
- e.story ? this.iterateTree(e.story, a, r) : e.stories.forEach((l) => {
796
- this.iterateTree(l, a, r);
797
- }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
794
+ e.story ? this.iterateTree(e.story, a, s) : e.stories.forEach((i) => {
795
+ this.iterateTree(i, a, s);
796
+ }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
798
797
  }
799
- async cacheResponse(e, t, r, o) {
798
+ async cacheResponse(e, t, s, o) {
800
799
  const n = this.helpers.stringify({ url: e, params: t }), a = this.cacheProvider();
801
800
  if (t.version === "published" && e !== "/cdn/spaces/me") {
802
- const l = await a.get(n);
803
- if (l)
804
- return Promise.resolve(l);
801
+ const i = await a.get(n);
802
+ if (i)
803
+ return Promise.resolve(i);
805
804
  }
806
- return new Promise(async (l, i) => {
805
+ return new Promise(async (i, l) => {
807
806
  var h;
808
807
  try {
809
- const d = await this.throttle(
808
+ const u = await this.throttle(
810
809
  "get",
811
810
  e,
812
811
  t,
813
812
  o
814
813
  );
815
- if (d.status !== 200)
816
- return i(d);
817
- let p = { data: d.data, headers: d.headers };
818
- if ((h = d.headers) != null && h["per-page"] && (p = Object.assign({}, p, {
819
- perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
820
- total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
814
+ if (u.status !== 200)
815
+ return l(u);
816
+ let p = { data: u.data, headers: u.headers };
817
+ if ((h = u.headers) != null && h["per-page"] && (p = Object.assign({}, p, {
818
+ perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
819
+ total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
821
820
  })), p.data.story || p.data.stories) {
822
- const v = this.resolveCounter = ++this.resolveCounter % 1e3;
823
- await this.resolveStories(p.data, t, `${v}`);
821
+ const $ = this.resolveCounter = ++this.resolveCounter % 1e3;
822
+ await this.resolveStories(p.data, t, `${$}`);
824
823
  }
825
824
  t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, p);
826
825
  const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
827
- return t.token && p.data.cv && (b && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
828
- } catch (d) {
829
- if (d.response && d.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
826
+ return t.token && p.data.cv && (b && x[t.token] && x[t.token] !== p.data.cv && await this.flushCache(), x[t.token] = p.data.cv), i(p);
827
+ } catch (u) {
828
+ if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
830
829
  return console.log(
831
830
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
832
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(i);
833
- i(d);
831
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(i).catch(l);
832
+ l(u);
834
833
  }
835
834
  });
836
835
  }
837
- throttledRequest(e, t, r, o) {
838
- return this.client.setFetchOptions(o), this.client[e](t, r);
836
+ throttledRequest(e, t, s, o) {
837
+ return this.client.setFetchOptions(o), this.client[e](t, s);
839
838
  }
840
839
  cacheVersions() {
841
- return S;
840
+ return x;
842
841
  }
843
842
  cacheVersion() {
844
- return S[this.accessToken];
843
+ return x[this.accessToken];
845
844
  }
846
845
  setCacheVersion(e) {
847
- this.accessToken && (S[this.accessToken] = e);
846
+ this.accessToken && (x[this.accessToken] = e);
848
847
  }
849
848
  clearCacheVersion() {
850
- this.accessToken && (S[this.accessToken] = 0);
849
+ this.accessToken && (x[this.accessToken] = 0);
851
850
  }
852
851
  cacheProvider() {
853
852
  switch (this.cache.type) {
@@ -891,21 +890,21 @@ class We {
891
890
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
892
891
  }
893
892
  }
894
- const dt = (s = {}) => {
895
- const { apiOptions: e } = s;
893
+ const gt = (r = {}) => {
894
+ const { apiOptions: e } = r;
896
895
  if (!e || !e.accessToken) {
897
896
  console.error(
898
897
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
899
898
  );
900
899
  return;
901
900
  }
902
- return { storyblokApi: new We(e) };
903
- }, Xe = (s) => {
904
- if (typeof s != "object" || typeof s._editable > "u")
901
+ return { storyblokApi: new Qe(e) };
902
+ }, Ze = (r) => {
903
+ if (typeof r != "object" || typeof r._editable > "u")
905
904
  return {};
906
905
  try {
907
906
  const e = JSON.parse(
908
- s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
907
+ r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
909
908
  );
910
909
  return e ? {
911
910
  "data-blok-c": JSON.stringify(e),
@@ -915,39 +914,39 @@ const dt = (s = {}) => {
915
914
  return {};
916
915
  }
917
916
  };
918
- function Qe(s, e) {
917
+ function et(r, e) {
919
918
  if (!e)
920
- return { src: s, attrs: {} };
921
- let t = 0, r = 0;
919
+ return { src: r, attrs: {} };
920
+ let t = 0, s = 0;
922
921
  const o = {}, n = [];
923
- function a(i, h, d, p, b) {
924
- typeof i != "number" || i <= h || i >= d ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`) : b.push(`${p}(${i})`);
922
+ function a(l, h, u, p, b) {
923
+ typeof l != "number" || l <= h || l >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : b.push(`${p}(${l})`);
925
924
  }
926
925
  if (typeof e == "object") {
927
- 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, r = 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) {
928
- const { filters: i } = e || {}, { blur: h, brightness: d, fill: p, format: b, grayscale: v, quality: w, rotate: E } = i || {};
929
- h && a(h, 0, 100, "blur", n), w && a(w, 0, 100, "quality", n), d && a(d, 0, 100, "brightness", n), p && n.push(`fill(${p})`), v && n.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
926
+ 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) {
927
+ const { filters: l } = e || {}, { blur: h, brightness: u, fill: p, format: b, grayscale: $, quality: T, rotate: E } = l || {};
928
+ h && a(h, 0, 100, "blur", n), T && a(T, 0, 100, "quality", n), u && a(u, 0, 100, "brightness", n), p && n.push(`fill(${p})`), $ && n.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
930
929
  }
931
- e.srcset && (o.srcset = e.srcset.map((i) => {
932
- if (typeof i == "number")
933
- return `${s}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
934
- if (Array.isArray(i) && i.length === 2) {
935
- const [h, d] = i;
936
- return `${s}/m/${h}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
930
+ e.srcset && (o.srcset = e.srcset.map((l) => {
931
+ if (typeof l == "number")
932
+ return `${r}/m/${l}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${l}w`;
933
+ if (Array.isArray(l) && l.length === 2) {
934
+ const [h, u] = l;
935
+ return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
937
936
  } else {
938
937
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
939
938
  return;
940
939
  }
941
940
  }).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
942
941
  }
943
- let l = `${s}/m/`;
944
- return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
945
- src: l,
942
+ let i = `${r}/m/`;
943
+ return t > 0 && s > 0 && (i = `${i}${t}x${s}/`), n.length > 0 && (i = `${i}filters:${n.join(":")}`), {
944
+ src: i,
946
945
  attrs: o
947
946
  };
948
947
  }
949
- var k = /* @__PURE__ */ ((s) => (s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s.TABLE = "table", s.TABLE_ROW = "tableRow", s.TABLE_CELL = "tableCell", s.TABLE_HEADER = "tableHeader", s))(k || {}), _ = /* @__PURE__ */ ((s) => (s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s))(_ || {}), X = /* @__PURE__ */ ((s) => (s.TEXT = "text", s))(X || {}), A = /* @__PURE__ */ ((s) => (s.URL = "url", s.STORY = "story", s.ASSET = "asset", s.EMAIL = "email", s))(A || {});
950
- const Ze = [
948
+ 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.TABLE = "table", r.TABLE_ROW = "tableRow", r.TABLE_CELL = "tableCell", r.TABLE_HEADER = "tableHeader", r))(k || {}), S = /* @__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))(S || {}), Q = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(Q || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
949
+ const tt = [
951
950
  "area",
952
951
  "base",
953
952
  "br",
@@ -962,360 +961,366 @@ const Ze = [
962
961
  "source",
963
962
  "track",
964
963
  "wbr"
965
- ], et = (s = {}) => Object.keys(s).map((e) => `${e}="${s[e]}"`).join(" "), tt = (s = {}) => Object.keys(s).map((e) => `${e}: ${s[e]}`).join("; ");
966
- function rt(s) {
967
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
964
+ ], rt = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), st = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
965
+ function ot(r) {
966
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
968
967
  }
969
- const L = (s) => Object.fromEntries(Object.entries(s).filter(([e, t]) => t !== void 0));
970
- function V(s, e = {}, t) {
971
- const r = et(e), o = r ? `${s} ${r}` : s, n = Array.isArray(t) ? t.join("") : t || "";
972
- if (s) {
973
- if (Ze.includes(s))
968
+ const L = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
969
+ function G(r, e = {}, t) {
970
+ const s = rt(e), o = s ? `${r} ${s}` : r, n = Array.isArray(t) ? t.join("") : t || "";
971
+ if (r) {
972
+ if (tt.includes(r))
974
973
  return `<${o}>`;
975
974
  } else return n;
976
- return `<${o}>${n}</${s}>`;
975
+ return `<${o}>${n}</${r}>`;
977
976
  }
978
- function st(s = {}) {
979
- let e = 0;
980
- const {
981
- renderFn: t = V,
982
- textFn: r = rt,
977
+ function nt(r = {}) {
978
+ const e = /* @__PURE__ */ new Map(), {
979
+ renderFn: t = G,
980
+ textFn: s = ot,
983
981
  resolvers: o = {},
984
982
  optimizeImages: n = !1,
985
983
  keyedResolvers: a = !1
986
- } = s, l = t !== V, i = (c) => (u) => {
987
- const m = u.attrs || {};
988
- return a && (m.key = `${c}-${e}`), t(c, m, u.children || null);
989
- }, h = (c) => {
990
- const { src: u, alt: m, title: y, srcset: R, sizes: $ } = c.attrs || {};
991
- let f = u, T = {};
984
+ } = r, i = t !== G, l = () => ({ render: (c, d = {}, g) => {
985
+ if (a && c) {
986
+ const f = e.get(c) || 0;
987
+ e.set(c, f + 1), d.key = `${c}-${f}`;
988
+ }
989
+ return t(c, d, g);
990
+ } }), h = (c) => (d, g) => {
991
+ const f = d.attrs || {};
992
+ return g.render(c, f, d.children || null);
993
+ }, u = (c, d) => {
994
+ const { src: g, alt: f, title: y, srcset: R, sizes: v } = c.attrs || {};
995
+ let w = g, _ = {};
992
996
  if (n) {
993
- const { src: le, attrs: ce } = Qe(u, n);
994
- f = le, T = ce;
997
+ const { src: he, attrs: ue } = et(g, n);
998
+ w = he, _ = ue;
995
999
  }
996
- a && (T = {
997
- ...T,
998
- key: `img-${e}`
999
- });
1000
- const ie = {
1001
- src: f,
1002
- alt: m,
1000
+ const ce = {
1001
+ src: w,
1002
+ alt: f,
1003
1003
  title: y,
1004
1004
  srcset: R,
1005
- sizes: $,
1006
- ...T
1005
+ sizes: v,
1006
+ ..._
1007
1007
  };
1008
- return t("img", L(ie));
1009
- }, d = (c) => {
1010
- const { level: u, ...m } = c.attrs || {}, y = {
1011
- ...m
1012
- };
1013
- return a && (y.key = `h${u}-${e}`), t(`h${u}`, y, c.children);
1014
- }, p = (c) => {
1015
- var u, m, y, R;
1016
- const $ = t("img", {
1017
- src: (u = c.attrs) == null ? void 0 : u.fallbackImage,
1018
- alt: (m = c.attrs) == null ? void 0 : m.alt,
1008
+ return d.render("img", L(ce));
1009
+ }, p = (c, d) => {
1010
+ const { level: g, ...f } = c.attrs || {};
1011
+ return d.render(`h${g}`, f, c.children);
1012
+ }, b = (c, d) => {
1013
+ var g, f, y, R;
1014
+ const v = d.render("img", {
1015
+ src: (g = c.attrs) == null ? void 0 : g.fallbackImage,
1016
+ alt: (f = c.attrs) == null ? void 0 : f.alt,
1019
1017
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
1020
1018
  draggable: "false",
1021
1019
  loading: "lazy"
1022
- }), f = {
1020
+ });
1021
+ return d.render("span", {
1023
1022
  "data-type": "emoji",
1024
1023
  "data-name": (y = c.attrs) == null ? void 0 : y.name,
1025
1024
  "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1026
- };
1027
- return a && (f.key = `emoji-${e}`), t("span", f, $);
1028
- }, b = (c) => t("pre", {
1029
- ...c.attrs,
1030
- key: `code-${e}`
1031
- }, t("code", { key: `code-${e}` }, c.children || "")), v = (c, u = !1) => ({ text: m, attrs: y }) => {
1032
- const { class: R, id: $, ...f } = y || {}, T = u ? {
1025
+ }, v);
1026
+ }, $ = (c, d) => d.render(
1027
+ "pre",
1028
+ c.attrs || {},
1029
+ d.render("code", {}, c.children || "")
1030
+ ), T = (c, d = !1) => ({ text: g, attrs: f }, y) => {
1031
+ const { class: R, id: v, ...w } = f || {}, _ = d ? {
1033
1032
  class: R,
1034
- id: $,
1035
- style: tt(f) || void 0
1036
- } : y || {};
1037
- return a && (T.key = `${c}-${e}`), t(c, L(T), m);
1038
- }, w = (c) => M(c), E = (c) => {
1039
- const { marks: u, ...m } = c;
1040
- return "text" in c ? u ? u.reduce(
1041
- (y, R) => w({ ...R, text: y }),
1042
- // Fix: Ensure render function returns a string
1043
- w({ ...m, children: m.children })
1044
- // Fix: Cast children to string
1045
- ) : r(m.text) : "";
1046
- }, j = (c) => {
1047
- const { linktype: u, href: m, anchor: y, ...R } = c.attrs || {};
1048
- let $ = "";
1049
- switch (u) {
1050
- case A.ASSET:
1051
- case A.URL:
1052
- $ = m;
1033
+ id: v,
1034
+ style: st(w) || void 0
1035
+ } : f || {};
1036
+ return y.render(c, L(_), g);
1037
+ }, E = (c) => M(c), re = (c) => {
1038
+ const { marks: d, ...g } = c;
1039
+ if ("text" in c) {
1040
+ if (d)
1041
+ return d.reduce(
1042
+ (y, R) => E({ ...R, text: y }),
1043
+ E({ ...g, children: g.children })
1044
+ );
1045
+ const f = c.attrs || {};
1046
+ if (a) {
1047
+ const y = e.get("txt") || 0;
1048
+ e.set("txt", y + 1), f.key = `txt-${y}`;
1049
+ }
1050
+ return s(g.text, f);
1051
+ }
1052
+ return "";
1053
+ }, B = (c, d) => {
1054
+ const { linktype: g, href: f, anchor: y, ...R } = c.attrs || {};
1055
+ let v = "";
1056
+ switch (g) {
1057
+ case j.ASSET:
1058
+ case j.URL:
1059
+ v = f;
1053
1060
  break;
1054
- case A.EMAIL:
1055
- $ = `mailto:${m}`;
1061
+ case j.EMAIL:
1062
+ v = `mailto:${f}`;
1056
1063
  break;
1057
- case A.STORY:
1058
- $ = m, y && ($ = `${$}#${y}`);
1064
+ case j.STORY:
1065
+ v = f, y && (v = `${v}#${y}`);
1059
1066
  break;
1060
1067
  default:
1061
- $ = m;
1068
+ v = f;
1062
1069
  break;
1063
1070
  }
1064
- const f = { ...R };
1065
- return $ && (f.href = $), a && (f.key = `a-${e}`), t("a", f, c.text);
1066
- }, te = (c) => {
1067
- var u, m;
1068
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1069
- blok: (u = c == null ? void 0 : c.attrs) == null ? void 0 : u.body[0],
1070
- id: (m = c.attrs) == null ? void 0 : m.id,
1071
- key: `component-${e}`,
1071
+ const w = { ...R };
1072
+ return v && (w.href = v), d.render("a", w, c.text);
1073
+ }, se = (c, d) => {
1074
+ var g, f;
1075
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
1076
+ blok: (g = c == null ? void 0 : c.attrs) == null ? void 0 : g.body[0],
1077
+ id: (f = c.attrs) == null ? void 0 : f.id,
1072
1078
  style: "display: none"
1073
1079
  });
1074
- }, re = (c) => {
1075
- const u = {};
1076
- return a && (u.key = `table-${e}`), t("table", u, c.children);
1077
- }, se = (c) => {
1078
- const u = {};
1079
- return a && (u.key = `tr-${e}`), t("tr", u, c.children);
1080
- }, oe = (c) => {
1081
- const { colspan: u, rowspan: m, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, f = {
1082
- ...$
1080
+ }, oe = (c, d) => {
1081
+ const g = {}, f = d.render("tbody", {}, c.children);
1082
+ return d.render("table", g, f);
1083
+ }, ne = (c, d) => {
1084
+ const g = {};
1085
+ return d.render("tr", g, c.children);
1086
+ }, ae = (c, d) => {
1087
+ const { colspan: g, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, w = {
1088
+ ...v
1083
1089
  };
1084
- u > 1 && (f.colspan = u), m > 1 && (f.rowspan = m);
1085
- const T = [];
1086
- return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (f.style = T.join(" ")), a && (f.key = `td-${e}`), t("td", L(f), c.children);
1087
- }, ne = (c) => {
1088
- const { colspan: u, rowspan: m, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, f = {
1089
- ...$
1090
+ g > 1 && (w.colspan = g), f > 1 && (w.rowspan = f);
1091
+ const _ = [];
1092
+ return y && _.push(`width: ${y}px;`), R && _.push(`background-color: ${R};`), _.length > 0 && (w.style = _.join(" ")), d.render("td", L(w), c.children);
1093
+ }, ie = (c, d) => {
1094
+ const { colspan: g, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, w = {
1095
+ ...v
1090
1096
  };
1091
- u > 1 && (f.colspan = u), m > 1 && (f.rowspan = m);
1092
- const T = [];
1093
- return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (f.style = T.join(" ")), a && (f.key = `th-${e}`), t("th", L(f), c.children);
1094
- }, ae = new Map([
1095
- [k.DOCUMENT, i("")],
1096
- [k.HEADING, d],
1097
- [k.PARAGRAPH, i("p")],
1098
- [k.UL_LIST, i("ul")],
1099
- [k.OL_LIST, i("ol")],
1100
- [k.LIST_ITEM, i("li")],
1101
- [k.IMAGE, h],
1102
- [k.EMOJI, p],
1103
- [k.CODE_BLOCK, b],
1104
- [k.HR, i("hr")],
1105
- [k.BR, i("br")],
1106
- [k.QUOTE, i("blockquote")],
1107
- [k.COMPONENT, te],
1108
- [X.TEXT, E],
1109
- [_.LINK, j],
1110
- [_.ANCHOR, j],
1111
- [_.STYLED, v("span", !0)],
1112
- [_.BOLD, v("strong")],
1113
- [_.TEXT_STYLE, v("span", !0)],
1114
- [_.ITALIC, v("em")],
1115
- [_.UNDERLINE, v("u")],
1116
- [_.STRIKE, v("s")],
1117
- [_.CODE, v("code")],
1118
- [_.SUPERSCRIPT, v("sup")],
1119
- [_.SUBSCRIPT, v("sub")],
1120
- [_.HIGHLIGHT, v("mark")],
1121
- [k.TABLE, re],
1122
- [k.TABLE_ROW, se],
1123
- [k.TABLE_CELL, oe],
1124
- [k.TABLE_HEADER, ne],
1125
- ...Object.entries(o).map(([c, u]) => [c, u])
1097
+ g > 1 && (w.colspan = g), f > 1 && (w.rowspan = f);
1098
+ const _ = [];
1099
+ return y && _.push(`width: ${y}px;`), R && _.push(`background-color: ${R};`), _.length > 0 && (w.style = _.join(" ")), d.render("th", L(w), c.children);
1100
+ }, le = new Map([
1101
+ [k.DOCUMENT, h("")],
1102
+ [k.HEADING, p],
1103
+ [k.PARAGRAPH, h("p")],
1104
+ [k.UL_LIST, h("ul")],
1105
+ [k.OL_LIST, h("ol")],
1106
+ [k.LIST_ITEM, h("li")],
1107
+ [k.IMAGE, u],
1108
+ [k.EMOJI, b],
1109
+ [k.CODE_BLOCK, $],
1110
+ [k.HR, h("hr")],
1111
+ [k.BR, h("br")],
1112
+ [k.QUOTE, h("blockquote")],
1113
+ [k.COMPONENT, se],
1114
+ [Q.TEXT, re],
1115
+ [S.LINK, B],
1116
+ [S.ANCHOR, B],
1117
+ [S.STYLED, T("span", !0)],
1118
+ [S.BOLD, T("strong")],
1119
+ [S.TEXT_STYLE, T("span", !0)],
1120
+ [S.ITALIC, T("em")],
1121
+ [S.UNDERLINE, T("u")],
1122
+ [S.STRIKE, T("s")],
1123
+ [S.CODE, T("code")],
1124
+ [S.SUPERSCRIPT, T("sup")],
1125
+ [S.SUBSCRIPT, T("sub")],
1126
+ [S.HIGHLIGHT, T("mark")],
1127
+ [k.TABLE, oe],
1128
+ [k.TABLE_ROW, ne],
1129
+ [k.TABLE_CELL, ae],
1130
+ [k.TABLE_HEADER, ie],
1131
+ ...Object.entries(o).map(([c, d]) => [c, d])
1126
1132
  ]);
1127
1133
  function I(c) {
1128
- e += 1;
1129
- const u = ae.get(c.type);
1130
- if (!u)
1134
+ const d = le.get(c.type);
1135
+ if (!d)
1131
1136
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1137
+ const g = l();
1132
1138
  if (c.type === "text")
1133
- return u(c);
1134
- const m = c.content ? c.content.map(M) : void 0;
1135
- return u({
1139
+ return d(c, g);
1140
+ const f = c.content ? c.content.map(M) : void 0;
1141
+ return d({
1136
1142
  ...c,
1137
- children: m
1138
- // Fix: Update the type of 'children' to Node[]
1139
- });
1143
+ children: f
1144
+ }, g);
1140
1145
  }
1141
1146
  function M(c) {
1142
- return c.type === "doc" ? l ? c.content.map(I) : c.content.map(I).join("") : Array.isArray(c) ? c.map(I) : I(c);
1147
+ return c.type === "doc" ? i ? c.content.map(I) : c.content.map(I).join("") : Array.isArray(c) ? c.map(I) : I(c);
1143
1148
  }
1144
1149
  return {
1145
1150
  render: M
1146
1151
  };
1147
1152
  }
1148
- let U, G = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1149
- const ot = (s, e, t = {}) => {
1150
- var r;
1151
- const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
1153
+ let U, K = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1154
+ const at = (r, e, t = {}) => {
1155
+ var s;
1156
+ const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
1152
1157
  "_storyblok"
1153
- ), a = n !== null && +n === s;
1158
+ ), a = n !== null && +n === r;
1154
1159
  if (!(!o || !a)) {
1155
- if (!s) {
1160
+ if (!r) {
1156
1161
  console.warn("Story ID is not defined. Please provide a valid ID.");
1157
1162
  return;
1158
1163
  }
1159
1164
  window.storyblokRegisterEvent(() => {
1160
- new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
1161
- var i;
1162
- l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === s ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === s && window.location.reload());
1165
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
1166
+ var l;
1167
+ i && (i.action === "input" && ((l = i.story) == null ? void 0 : l.id) === r ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === r && window.location.reload());
1163
1168
  });
1164
1169
  });
1165
1170
  }
1166
- }, Q = (s, e) => {
1167
- s.addNode("blok", (t) => {
1168
- let r = "";
1171
+ }, Z = (r, e) => {
1172
+ r.addNode("blok", (t) => {
1173
+ let s = "";
1169
1174
  return t.attrs.body.forEach((o) => {
1170
- r += e(o.component, o);
1175
+ s += e(o.component, o);
1171
1176
  }), {
1172
- html: r
1177
+ html: s
1173
1178
  };
1174
1179
  });
1175
- }, nt = (s = {}) => {
1180
+ }, it = (r = {}) => {
1176
1181
  var e, t;
1177
1182
  const {
1178
- bridge: r,
1183
+ bridge: s,
1179
1184
  accessToken: o,
1180
1185
  use: n = [],
1181
1186
  apiOptions: a = {},
1182
- richText: l = {},
1183
- bridgeUrl: i
1184
- } = s;
1187
+ richText: i = {},
1188
+ bridgeUrl: l
1189
+ } = r;
1185
1190
  a.accessToken = a.accessToken || o;
1186
- const h = { bridge: r, apiOptions: a };
1187
- let d = {};
1191
+ const h = { bridge: s, apiOptions: a };
1192
+ let u = {};
1188
1193
  n.forEach((b) => {
1189
- d = { ...d, ...b(h) };
1190
- }), i && (G = i);
1194
+ u = { ...u, ...b(h) };
1195
+ }), l && (K = l);
1191
1196
  const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1192
- return r !== !1 && p && fe(G), U = new N(l.schema), l.resolver && Q(U, l.resolver), d;
1193
- }, at = (s) => {
1197
+ return s !== !1 && p && be(K), U = new N(i.schema), i.resolver && Z(U, i.resolver), u;
1198
+ }, lt = (r) => {
1194
1199
  var e;
1195
- return !s || !((e = s == null ? void 0 : s.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1196
- }, pt = (s, e, t) => {
1197
- let r = t || U;
1198
- if (!r) {
1200
+ return !r || !((e = r == null ? void 0 : r.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1201
+ }, ft = (r, e, t) => {
1202
+ let s = t || U;
1203
+ if (!s) {
1199
1204
  console.error(
1200
1205
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1201
1206
  );
1202
1207
  return;
1203
1208
  }
1204
- return at(s) ? "" : (e && (r = new N(e.schema), e.resolver && Q(r, e.resolver)), r.render(s, {}, !1));
1205
- }, Z = /* @__PURE__ */ J({
1209
+ return lt(r) ? "" : (e && (s = new N(e.schema), e.resolver && Z(s, e.resolver)), s.render(r, {}, !1));
1210
+ }, ee = /* @__PURE__ */ J({
1206
1211
  __name: "StoryblokComponent",
1207
1212
  props: {
1208
1213
  blok: {}
1209
1214
  },
1210
- setup(s, { expose: e }) {
1211
- const t = s, r = O();
1215
+ setup(r, { expose: e }) {
1216
+ const t = r, s = O();
1212
1217
  e({
1213
- value: r
1218
+ value: s
1214
1219
  });
1215
- const o = typeof H(t.blok.component) != "string", n = he("VueSDKOptions"), a = O(t.blok.component);
1220
+ const o = typeof H(t.blok.component) != "string", n = de("VueSDKOptions"), a = O(t.blok.component);
1216
1221
  return !o && n && (n.enableFallbackComponent ? (a.value = n.customFallbackComponent ?? "FallbackComponent", typeof H(a.value) == "string" && console.error(
1217
1222
  `Is the Fallback component "${a.value}" registered properly?`
1218
1223
  )) : console.error(
1219
1224
  `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});"?`
1220
- )), (l, i) => (Y(), K(H(a.value), ue({
1225
+ )), (i, l) => (W(), Y(H(a.value), pe({
1221
1226
  ref_key: "blokRef",
1222
- ref: r
1223
- }, { ...l.$props, ...l.$attrs }), null, 16));
1227
+ ref: s
1228
+ }, { ...i.$props, ...i.$attrs }), null, 16));
1224
1229
  }
1225
- }), it = (s) => {
1230
+ }), ct = (r) => {
1226
1231
  var e, t;
1227
- return W(
1228
- Z,
1232
+ return X(
1233
+ ee,
1229
1234
  {
1230
- blok: (e = s == null ? void 0 : s.attrs) == null ? void 0 : e.body[0],
1231
- id: (t = s.attrs) == null ? void 0 : t.id
1235
+ blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
1236
+ id: (t = r.attrs) == null ? void 0 : t.id
1232
1237
  },
1233
- s.children
1238
+ r.children
1234
1239
  );
1235
1240
  };
1236
- function lt(s) {
1241
+ function ht(r) {
1237
1242
  const e = {
1238
- renderFn: W,
1239
- textFn: de,
1243
+ renderFn: X,
1244
+ textFn: ge,
1240
1245
  keyedResolvers: !0,
1241
1246
  resolvers: {
1242
- [k.COMPONENT]: it,
1243
- ...s.resolvers
1247
+ [k.COMPONENT]: ct,
1248
+ ...r.resolvers
1244
1249
  }
1245
1250
  };
1246
- return st(e);
1251
+ return nt(e);
1247
1252
  }
1248
- const ct = /* @__PURE__ */ J({
1253
+ const ut = /* @__PURE__ */ J({
1249
1254
  __name: "StoryblokRichText",
1250
1255
  props: {
1251
1256
  doc: {},
1252
1257
  resolvers: {}
1253
1258
  },
1254
- setup(s) {
1255
- const e = s, t = O(), r = () => t.value;
1256
- return pe([() => e.doc, () => e.resolvers], ([o, n]) => {
1257
- const { render: a } = lt({
1259
+ setup(r) {
1260
+ const e = r, t = O(), s = () => t.value;
1261
+ return fe([() => e.doc, () => e.resolvers], ([o, n]) => {
1262
+ const { render: a } = ht({
1258
1263
  resolvers: n ?? {}
1259
1264
  });
1260
1265
  t.value = a(o);
1261
1266
  }, {
1262
1267
  immediate: !0,
1263
1268
  deep: !0
1264
- }), (o, n) => (Y(), K(r));
1269
+ }), (o, n) => (W(), Y(s));
1265
1270
  }
1266
- }), ht = {
1267
- beforeMount(s, e) {
1271
+ }), dt = {
1272
+ beforeMount(r, e) {
1268
1273
  if (e.value) {
1269
- const t = Xe(e.value);
1270
- Object.keys(t).length > 0 && (s.setAttribute("data-blok-c", t["data-blok-c"]), s.setAttribute("data-blok-uid", t["data-blok-uid"]), s.classList.add("storyblok__outline"));
1274
+ const t = Ze(e.value);
1275
+ 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"));
1271
1276
  }
1272
1277
  }
1273
- }, ee = (s) => {
1274
- console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
1278
+ }, te = (r) => {
1279
+ console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
1275
1280
  `);
1276
1281
  };
1277
- let x = null;
1278
- const gt = () => (x || ee("useStoryblokApi"), x), mt = async (s, e = {}, t = {}) => {
1279
- const r = O(null);
1280
- if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, ge(() => {
1281
- r.value && r.value.id && ot(
1282
- r.value.id,
1283
- (o) => r.value = o,
1282
+ let A = null;
1283
+ const mt = () => (A || te("useStoryblokApi"), A), yt = async (r, e = {}, t = {}) => {
1284
+ const s = O(null);
1285
+ if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, me(() => {
1286
+ s.value && s.value.id && at(
1287
+ s.value.id,
1288
+ (o) => s.value = o,
1284
1289
  t
1285
1290
  );
1286
- }), x) {
1287
- const { data: o } = await x.get(
1288
- `cdn/stories/${s}`,
1291
+ }), A) {
1292
+ const { data: o } = await A.get(
1293
+ `cdn/stories/${r}`,
1289
1294
  e
1290
1295
  );
1291
- r.value = o.story;
1296
+ s.value = o.story;
1292
1297
  } else
1293
- ee("useStoryblok");
1294
- return r;
1295
- }, ft = {
1296
- install(s, e = {}) {
1297
- s.directive("editable", ht), s.component("StoryblokComponent", Z), s.component("StoryblokRichText", ct), e.enableFallbackComponent && !e.customFallbackComponent && s.component(
1298
+ te("useStoryblok");
1299
+ return s;
1300
+ }, bt = {
1301
+ install(r, e = {}) {
1302
+ r.directive("editable", dt), r.component("StoryblokComponent", ee), r.component("StoryblokRichText", ut), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
1298
1303
  "FallbackComponent",
1299
- me(() => import("./FallbackComponent-Dky11gEu.js"))
1304
+ ye(() => import("./FallbackComponent-Dky11gEu.js"))
1300
1305
  );
1301
- const { storyblokApi: t } = nt(e);
1302
- x = t || null, s.provide("VueSDKOptions", e);
1306
+ const { storyblokApi: t } = it(e);
1307
+ A = t || null, r.provide("VueSDKOptions", e);
1303
1308
  }
1304
1309
  };
1305
1310
  export {
1306
1311
  k as BlockTypes,
1307
- _ as MarkTypes,
1312
+ S as MarkTypes,
1308
1313
  N as RichTextResolver,
1309
- Je as RichTextSchema,
1310
- Z as StoryblokComponent,
1311
- ct as StoryblokRichText,
1312
- ft as StoryblokVue,
1313
- X as TextTypes,
1314
- dt as apiPlugin,
1315
- pt as renderRichText,
1316
- st as richTextResolver,
1317
- mt as useStoryblok,
1318
- gt as useStoryblokApi,
1319
- ot as useStoryblokBridge,
1320
- lt as useStoryblokRichText
1314
+ Ye as RichTextSchema,
1315
+ ee as StoryblokComponent,
1316
+ ut as StoryblokRichText,
1317
+ bt as StoryblokVue,
1318
+ Q as TextTypes,
1319
+ gt as apiPlugin,
1320
+ ft as renderRichText,
1321
+ nt as richTextResolver,
1322
+ yt as useStoryblok,
1323
+ mt as useStoryblokApi,
1324
+ at as useStoryblokBridge,
1325
+ ht as useStoryblokRichText
1321
1326
  };