@storyblok/js 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,35 +4,35 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- let B = !1;
8
- const U = [], F = (i) => new Promise((e, t) => {
7
+ let z = !1;
8
+ const D = [], J = (i) => new Promise((e, t) => {
9
9
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
10
10
  if (window.location === window.parent.location) {
11
11
  console.warn("You are not in Draft Mode or in the Visual Editor.");
12
12
  return;
13
13
  }
14
- B ? r() : U.push(r);
14
+ z ? r() : D.push(r);
15
15
  }, document.getElementById("storyblok-javascript-bridge")))
16
16
  return;
17
17
  const s = document.createElement("script");
18
18
  s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
19
- U.forEach((o) => o()), B = !0, e(r);
19
+ D.forEach((o) => o()), z = !0, e(r);
20
20
  }, document.getElementsByTagName("head")[0].appendChild(s);
21
21
  });
22
- var se = Object.defineProperty, re = (i, e, t) => e in i ? se(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, g = (i, e, t) => re(i, typeof e != "symbol" ? e + "" : e, t);
23
- class ie extends Error {
22
+ var ie = Object.defineProperty, oe = (i, e, t) => e in i ? ie(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e, t) => oe(i, typeof e != "symbol" ? e + "" : e, t);
23
+ class ne extends Error {
24
24
  constructor(e) {
25
25
  super(e), this.name = "AbortError";
26
26
  }
27
27
  }
28
- function oe(i, e, t) {
28
+ function ae(i, e, t) {
29
29
  if (!Number.isFinite(e))
30
30
  throw new TypeError("Expected `limit` to be a finite number");
31
31
  if (!Number.isFinite(t))
32
32
  throw new TypeError("Expected `interval` to be a finite number");
33
33
  const s = [];
34
34
  let r = [], o = 0, n = !1;
35
- const l = async () => {
35
+ const c = async () => {
36
36
  o++;
37
37
  const h = s.shift();
38
38
  if (h)
@@ -43,7 +43,7 @@ function oe(i, e, t) {
43
43
  h.reject(p);
44
44
  }
45
45
  const u = setTimeout(() => {
46
- o--, s.length > 0 && l(), r = r.filter((p) => p !== u);
46
+ o--, s.length > 0 && c(), r = r.filter((p) => p !== u);
47
47
  }, t);
48
48
  r.includes(u) || r.push(u);
49
49
  }, a = (...h) => n ? Promise.reject(
@@ -55,24 +55,24 @@ function oe(i, e, t) {
55
55
  resolve: u,
56
56
  reject: p,
57
57
  args: h
58
- }), o < e && l();
58
+ }), o < e && c();
59
59
  });
60
60
  return a.abort = () => {
61
61
  n = !0, r.forEach(clearTimeout), r = [], s.forEach(
62
- (h) => h.reject(() => new ie("Throttle function aborted"))
62
+ (h) => h.reject(() => new ne("Throttle function aborted"))
63
63
  ), s.length = 0;
64
64
  }, a;
65
65
  }
66
- class L {
66
+ class C {
67
67
  constructor() {
68
- g(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), g(this, "getOptionsPage", (e, t = 25, s = 1) => ({
68
+ m(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), m(this, "getOptionsPage", (e, t = 25, s = 1) => ({
69
69
  ...e,
70
70
  per_page: t,
71
71
  page: s
72
- })), 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) => {
72
+ })), 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) => {
73
73
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
74
74
  return this.arrayFrom(s, (o, n) => n * r + e);
75
- }), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), g(this, "escapeHTML", function(e) {
75
+ }), m(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), m(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), m(this, "escapeHTML", function(e) {
76
76
  const t = {
77
77
  "&": "&amp;",
78
78
  "<": "&lt;",
@@ -98,13 +98,13 @@ class L {
98
98
  const n = e[o];
99
99
  if (n == null)
100
100
  continue;
101
- const l = s ? "" : encodeURIComponent(o);
101
+ const c = s ? "" : encodeURIComponent(o);
102
102
  let a;
103
103
  typeof n == "object" ? a = this.stringify(
104
104
  n,
105
- t ? t + encodeURIComponent(`[${l}]`) : l,
105
+ t ? t + encodeURIComponent(`[${c}]`) : c,
106
106
  Array.isArray(n)
107
- ) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, r.push(a);
107
+ ) : a = `${t ? t + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(n)}`, r.push(a);
108
108
  }
109
109
  return r.join("&");
110
110
  }
@@ -129,20 +129,20 @@ class L {
129
129
  }
130
130
  }
131
131
  }
132
- const ne = function(i, e) {
132
+ const le = function(i, e) {
133
133
  const t = {};
134
134
  for (const s in i) {
135
135
  const r = i[s];
136
136
  e.includes(s) && r !== null && (t[s] = r);
137
137
  }
138
138
  return t;
139
- }, ae = (i) => i === "email", le = () => ({
139
+ }, ce = (i) => i === "email", he = () => ({
140
140
  singleTag: "hr"
141
- }), ce = () => ({
141
+ }), ue = () => ({
142
142
  tag: "blockquote"
143
- }), he = () => ({
143
+ }), de = () => ({
144
144
  tag: "ul"
145
- }), ue = (i) => ({
145
+ }), pe = (i) => ({
146
146
  tag: [
147
147
  "pre",
148
148
  {
@@ -150,24 +150,24 @@ const ne = function(i, e) {
150
150
  attrs: i.attrs
151
151
  }
152
152
  ]
153
- }), de = () => ({
153
+ }), ge = () => ({
154
154
  singleTag: "br"
155
- }), pe = (i) => ({
155
+ }), fe = (i) => ({
156
156
  tag: `h${i.attrs.level}`
157
- }), ge = (i) => ({
157
+ }), me = (i) => ({
158
158
  singleTag: [
159
159
  {
160
160
  tag: "img",
161
- attrs: ne(i.attrs, ["src", "alt", "title"])
161
+ attrs: le(i.attrs, ["src", "alt", "title"])
162
162
  }
163
163
  ]
164
- }), fe = () => ({
164
+ }), ye = () => ({
165
165
  tag: "li"
166
- }), me = () => ({
166
+ }), be = () => ({
167
167
  tag: "ol"
168
- }), ye = () => ({
168
+ }), ke = () => ({
169
169
  tag: "p"
170
- }), be = (i) => ({
170
+ }), ve = (i) => ({
171
171
  tag: [
172
172
  {
173
173
  tag: "span",
@@ -178,25 +178,25 @@ const ne = function(i, e) {
178
178
  }
179
179
  }
180
180
  ]
181
- }), ke = () => ({
182
- tag: "b"
183
181
  }), $e = () => ({
182
+ tag: "b"
183
+ }), Te = () => ({
184
184
  tag: "s"
185
- }), ve = () => ({
185
+ }), we = () => ({
186
186
  tag: "u"
187
- }), Te = () => ({
187
+ }), Re = () => ({
188
188
  tag: "strong"
189
- }), we = () => ({
189
+ }), Ee = () => ({
190
190
  tag: "code"
191
- }), Re = () => ({
191
+ }), _e = () => ({
192
192
  tag: "i"
193
- }), Ee = (i) => {
193
+ }), Se = (i) => {
194
194
  if (!i.attrs)
195
195
  return {
196
196
  tag: ""
197
197
  };
198
- const e = new L().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
199
- if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), ae(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
198
+ const e = new C().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
199
+ if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), ce(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
200
200
  for (const r in t.custom)
201
201
  t[r] = t.custom[r];
202
202
  delete t.custom;
@@ -209,25 +209,25 @@ const ne = function(i, e) {
209
209
  }
210
210
  ]
211
211
  };
212
- }, _e = (i) => ({
212
+ }, je = (i) => ({
213
213
  tag: [
214
214
  {
215
215
  tag: "span",
216
216
  attrs: i.attrs
217
217
  }
218
218
  ]
219
- }), Se = () => ({
219
+ }), Ie = () => ({
220
220
  tag: "sub"
221
- }), je = () => ({
221
+ }), xe = () => ({
222
222
  tag: "sup"
223
- }), Ie = (i) => ({
223
+ }), Ae = (i) => ({
224
224
  tag: [
225
225
  {
226
226
  tag: "span",
227
227
  attrs: i.attrs
228
228
  }
229
229
  ]
230
- }), Ae = (i) => {
230
+ }), Oe = (i) => {
231
231
  var e;
232
232
  return (e = i.attrs) != null && e.color ? {
233
233
  tag: [
@@ -241,7 +241,7 @@ const ne = function(i, e) {
241
241
  } : {
242
242
  tag: ""
243
243
  };
244
- }, xe = (i) => {
244
+ }, Le = (i) => {
245
245
  var e;
246
246
  return (e = i.attrs) != null && e.color ? {
247
247
  tag: [
@@ -255,36 +255,36 @@ const ne = function(i, e) {
255
255
  } : {
256
256
  tag: ""
257
257
  };
258
- }, Oe = {
258
+ }, Ce = {
259
259
  nodes: {
260
- horizontal_rule: le,
261
- blockquote: ce,
262
- bullet_list: he,
263
- code_block: ue,
264
- hard_break: de,
265
- heading: pe,
266
- image: ge,
267
- list_item: fe,
268
- ordered_list: me,
269
- paragraph: ye,
270
- emoji: be
260
+ horizontal_rule: he,
261
+ blockquote: ue,
262
+ bullet_list: de,
263
+ code_block: pe,
264
+ hard_break: ge,
265
+ heading: fe,
266
+ image: me,
267
+ list_item: ye,
268
+ ordered_list: be,
269
+ paragraph: ke,
270
+ emoji: ve
271
271
  },
272
272
  marks: {
273
- bold: ke,
274
- strike: $e,
275
- underline: ve,
276
- strong: Te,
277
- code: we,
278
- italic: Re,
279
- link: Ee,
280
- styled: _e,
281
- subscript: Se,
282
- superscript: je,
283
- anchor: Ie,
284
- highlight: Ae,
285
- textStyle: xe
286
- }
287
- }, Le = function(i) {
273
+ bold: $e,
274
+ strike: Te,
275
+ underline: we,
276
+ strong: Re,
277
+ code: Ee,
278
+ italic: _e,
279
+ link: Se,
280
+ styled: je,
281
+ subscript: Ie,
282
+ superscript: xe,
283
+ anchor: Ae,
284
+ highlight: Oe,
285
+ textStyle: Le
286
+ }
287
+ }, Pe = function(i) {
288
288
  const e = {
289
289
  "&": "&amp;",
290
290
  "<": "&lt;",
@@ -294,10 +294,9 @@ const ne = function(i, e) {
294
294
  }, t = /[&<>"']/g, s = new RegExp(t.source);
295
295
  return i && s.test(i) ? i.replace(t, (r) => e[r]) : i;
296
296
  };
297
- let z = !1;
298
- class C {
297
+ let q = !1, P = class {
299
298
  constructor(e) {
300
- g(this, "marks"), g(this, "nodes"), e || (e = Oe), this.marks = e.marks || [], this.nodes = e.nodes || [];
299
+ m(this, "marks"), m(this, "nodes"), e || (e = Ce), this.marks = e.marks || [], this.nodes = e.nodes || [];
301
300
  }
302
301
  addNode(e, t) {
303
302
  this.nodes[e] = t;
@@ -306,9 +305,9 @@ class C {
306
305
  this.marks[e] = t;
307
306
  }
308
307
  render(e, t = { optimizeImages: !1 }, s = !0) {
309
- if (!z && s && (console.warn(
308
+ if (!q && s && (console.warn(
310
309
  "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/"
311
- ), z = !0), e && e.content && Array.isArray(e.content)) {
310
+ ), q = !0), e && e.content && Array.isArray(e.content)) {
312
311
  let r = "";
313
312
  return e.content.forEach((o) => {
314
313
  r += this.renderNode(o);
@@ -344,30 +343,30 @@ class C {
344
343
  optimizeImages(e, t) {
345
344
  let s = 0, r = 0, o = "", n = "";
346
345
  typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = `/filters${n}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
347
- const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
346
+ const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
348
347
  return e = e.replace(
349
348
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
350
- `a.storyblok.com/f/$1/$2.$3/m/${l}`
349
+ `a.storyblok.com/f/$1/$2.$3/m/${c}`
351
350
  ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
352
351
  var h, u;
353
352
  const p = a.match(
354
353
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
355
354
  );
356
355
  if (p && p.length > 0) {
357
- const y = {
358
- srcset: (h = t.srcset) == null ? void 0 : h.map((T) => {
359
- if (typeof T == "number")
360
- return `//${p}/m/${T}x0${n} ${T}w`;
361
- if (typeof T == "object" && T.length === 2) {
362
- let _ = 0, j = 0;
363
- return typeof T[0] == "number" && (_ = T[0]), typeof T[1] == "number" && (j = T[1]), `//${p}/m/${_}x${j}${n} ${_}w`;
356
+ const b = {
357
+ srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
358
+ if (typeof y == "number")
359
+ return `//${p}/m/${y}x0${n} ${y}w`;
360
+ if (typeof y == "object" && y.length === 2) {
361
+ let S = 0, x = 0;
362
+ return typeof y[0] == "number" && (S = y[0]), typeof y[1] == "number" && (x = y[1]), `//${p}/m/${S}x${x}${n} ${S}w`;
364
363
  }
365
364
  return "";
366
365
  }).join(", "),
367
- sizes: (u = t.sizes) == null ? void 0 : u.map((T) => T).join(", ")
366
+ sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
368
367
  };
369
- let k = "";
370
- return y.srcset && (k += `srcset="${y.srcset}" `), y.sizes && (k += `sizes="${y.sizes}" `), a.replace(/<img/g, `<img ${k.trim()}`);
368
+ let _ = "";
369
+ return b.srcset && (_ += `srcset="${b.srcset}" `), b.sizes && (_ += `sizes="${b.sizes}" `), a.replace(/<img/g, `<img ${_.trim()}`);
371
370
  }
372
371
  return a;
373
372
  })), e;
@@ -381,7 +380,7 @@ class C {
381
380
  const s = this.getMatchingNode(e);
382
381
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
383
382
  t.push(this.renderNode(r));
384
- }) : e.text ? t.push(Le(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
383
+ }) : e.text ? t.push(Pe(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
385
384
  const o = this.getMatchingMark(r);
386
385
  o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
387
386
  }), t.join("");
@@ -435,10 +434,10 @@ class C {
435
434
  ];
436
435
  return this.renderTag(t, " /");
437
436
  }
438
- }
439
- class Ce {
437
+ };
438
+ class Ne {
440
439
  constructor(e) {
441
- 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 = {};
440
+ 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 = {};
442
441
  }
443
442
  /**
444
443
  *
@@ -475,15 +474,15 @@ class Ce {
475
474
  async _methodHandler(e) {
476
475
  let t = `${this.baseURL}${this.url}`, s = null;
477
476
  if (e === "get") {
478
- const a = new L();
477
+ const a = new C();
479
478
  t = `${this.baseURL}${this.url}?${a.stringify(
480
479
  this.parameters
481
480
  )}`;
482
481
  } else
483
482
  s = JSON.stringify(this.parameters);
484
483
  const r = new URL(t), o = new AbortController(), { signal: n } = o;
485
- let l;
486
- this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
484
+ let c;
485
+ this.timeout && (c = setTimeout(() => o.abort(), this.timeout));
487
486
  try {
488
487
  const a = await this.fetch(`${r}`, {
489
488
  method: e,
@@ -492,7 +491,7 @@ class Ce {
492
491
  signal: n,
493
492
  ...this.fetchOptions
494
493
  });
495
- this.timeout && clearTimeout(l);
494
+ this.timeout && clearTimeout(c);
496
495
  const h = await this._responseHandler(
497
496
  a
498
497
  );
@@ -523,39 +522,39 @@ class Ce {
523
522
  });
524
523
  }
525
524
  }
526
- const D = "SB-Agent", N = {
525
+ const F = "SB-Agent", H = {
527
526
  defaultAgentName: "SB-JS-CLIENT",
528
527
  defaultAgentVersion: "SB-Agent-Version",
529
528
  packageVersion: "6.0.0"
530
529
  };
531
- let x = {};
532
- const S = {};
533
- class Pe {
530
+ let O = {};
531
+ const j = {};
532
+ class He {
534
533
  /**
535
534
  *
536
535
  * @param config ISbConfig interface
537
536
  * @param pEndpoint string, optional
538
537
  */
539
538
  constructor(e, t) {
540
- 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");
539
+ 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
540
  let s = e.endpoint || t;
542
541
  if (!s) {
543
- const n = new L().getRegionURL, l = e.https === !1 ? "http" : "https";
544
- e.oauthToken ? s = `${l}://${n(e.region)}/v1` : s = `${l}://${n(e.region)}/v2`;
542
+ const n = new C().getRegionURL, c = e.https === !1 ? "http" : "https";
543
+ e.oauthToken ? s = `${c}://${n(e.region)}/v1` : s = `${c}://${n(e.region)}/v2`;
545
544
  }
546
545
  const r = new Headers();
547
- r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, l]) => {
548
- r.set(n, l);
549
- }), r.has(D) || (r.set(D, N.defaultAgentName), r.set(
550
- N.defaultAgentVersion,
551
- N.packageVersion
546
+ r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, c]) => {
547
+ r.set(n, c);
548
+ }), r.has(F) || (r.set(F, H.defaultAgentName), r.set(
549
+ H.defaultAgentVersion,
550
+ H.packageVersion
552
551
  ));
553
552
  let o = 5;
554
- e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new C(e.richTextSchema) : this.richTextResolver = new C(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = oe(
553
+ e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new P(e.richTextSchema) : this.richTextResolver = new P(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ae(
555
554
  this.throttledRequest.bind(this),
556
555
  o,
557
556
  1e3
558
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new L(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ce({
557
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new C(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ne({
559
558
  baseURL: s,
560
559
  timeout: e.timeout || 0,
561
560
  headers: r,
@@ -574,7 +573,7 @@ class Pe {
574
573
  });
575
574
  }
576
575
  parseParams(e) {
577
- 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;
576
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = j[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
578
577
  }
579
578
  factoryParamOptions(e, t) {
580
579
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
@@ -592,7 +591,7 @@ class Pe {
592
591
  return this.cacheResponse(r, o, void 0, s);
593
592
  }
594
593
  async getAll(e, t, s, r) {
595
- const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
594
+ const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), c = s ?? n.substring(n.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
596
595
  n,
597
596
  t,
598
597
  o,
@@ -600,9 +599,9 @@ class Pe {
600
599
  r
601
600
  ), u = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
602
601
  this.helpers.range(a, u),
603
- (y) => this.makeRequest(n, t, o, y + 1, r)
602
+ (b) => this.makeRequest(n, t, o, b + 1, r)
604
603
  );
605
- return this.helpers.flatMap([h, ...p], (y) => Object.values(y.data[l]));
604
+ return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[c]));
606
605
  }
607
606
  post(e, t, s) {
608
607
  const r = `/${e}`;
@@ -705,11 +704,11 @@ class Pe {
705
704
  const r = (o, n = "") => {
706
705
  if (!(!o || o._stopResolving)) {
707
706
  if (Array.isArray(o))
708
- o.forEach((l, a) => r(l, `${n}[${a}]`));
707
+ o.forEach((c, a) => r(c, `${n}[${a}]`));
709
708
  else if (typeof o == "object")
710
- for (const l in o) {
711
- const a = n ? `${n}.${l}` : l;
712
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, s), this._insertLinks(o, l, s)), r(o[l], a);
709
+ for (const c in o) {
710
+ const a = n ? `${n}.${c}` : c;
711
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(o, c, t, s), this._insertLinks(o, c, s)), r(o[c], a);
713
712
  }
714
713
  }
715
714
  };
@@ -718,14 +717,14 @@ class Pe {
718
717
  async resolveLinks(e, t, s) {
719
718
  let r = [];
720
719
  if (e.link_uuids) {
721
- const o = e.link_uuids.length, n = [], l = 50;
722
- for (let a = 0; a < o; a += l) {
723
- const h = Math.min(o, a + l);
720
+ const o = e.link_uuids.length, n = [], c = 50;
721
+ for (let a = 0; a < o; a += c) {
722
+ const h = Math.min(o, a + c);
724
723
  n.push(e.link_uuids.slice(a, h));
725
724
  }
726
725
  for (let a = 0; a < n.length; a++)
727
726
  (await this.getStories({
728
- per_page: l,
727
+ per_page: c,
729
728
  language: t.language,
730
729
  version: t.version,
731
730
  starts_with: t.starts_with,
@@ -747,14 +746,14 @@ class Pe {
747
746
  async resolveRelations(e, t, s) {
748
747
  let r = [];
749
748
  if (e.rel_uuids) {
750
- const o = e.rel_uuids.length, n = [], l = 50;
751
- for (let a = 0; a < o; a += l) {
752
- const h = Math.min(o, a + l);
749
+ const o = e.rel_uuids.length, n = [], c = 50;
750
+ for (let a = 0; a < o; a += c) {
751
+ const h = Math.min(o, a + c);
753
752
  n.push(e.rel_uuids.slice(a, h));
754
753
  }
755
754
  for (let a = 0; a < n.length; a++)
756
755
  (await this.getStories({
757
- per_page: l,
756
+ per_page: c,
758
757
  language: t.language,
759
758
  version: t.version,
760
759
  starts_with: t.starts_with,
@@ -785,24 +784,24 @@ class Pe {
785
784
  var r, o;
786
785
  let n = [];
787
786
  if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
788
- for (const l in this.relations[s])
787
+ for (const c in this.relations[s])
789
788
  this.iterateTree(
790
- this.relations[s][l],
789
+ this.relations[s][c],
791
790
  n,
792
791
  s
793
792
  );
794
- e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((l) => {
795
- this.iterateTree(l, n, s);
793
+ e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
794
+ this.iterateTree(c, n, s);
796
795
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
797
796
  }
798
797
  async cacheResponse(e, t, s, r) {
799
798
  const o = this.helpers.stringify({ url: e, params: t }), n = this.cacheProvider();
800
799
  if (t.version === "published" && e !== "/cdn/spaces/me") {
801
- const l = await n.get(o);
802
- if (l)
803
- return Promise.resolve(l);
800
+ const c = await n.get(o);
801
+ if (c)
802
+ return Promise.resolve(c);
804
803
  }
805
- return new Promise(async (l, a) => {
804
+ return new Promise(async (c, a) => {
806
805
  var h;
807
806
  try {
808
807
  const u = await this.throttle(
@@ -818,17 +817,17 @@ class Pe {
818
817
  perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
819
818
  total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
820
819
  })), p.data.story || p.data.stories) {
821
- const k = this.resolveCounter = ++this.resolveCounter % 1e3;
822
- await this.resolveStories(p.data, t, `${k}`);
820
+ const _ = this.resolveCounter = ++this.resolveCounter % 1e3;
821
+ await this.resolveStories(p.data, t, `${_}`);
823
822
  }
824
823
  t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, p);
825
- const y = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
826
- return t.token && p.data.cv && (y && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
824
+ const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
825
+ return t.token && p.data.cv && (b && j[t.token] && j[t.token] !== p.data.cv && await this.flushCache(), j[t.token] = p.data.cv), c(p);
827
826
  } catch (u) {
828
827
  if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
829
828
  return console.log(
830
829
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
831
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
830
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(a);
832
831
  a(u);
833
832
  }
834
833
  });
@@ -837,32 +836,32 @@ class Pe {
837
836
  return this.client.setFetchOptions(r), this.client[e](t, s);
838
837
  }
839
838
  cacheVersions() {
840
- return S;
839
+ return j;
841
840
  }
842
841
  cacheVersion() {
843
- return S[this.accessToken];
842
+ return j[this.accessToken];
844
843
  }
845
844
  setCacheVersion(e) {
846
- this.accessToken && (S[this.accessToken] = e);
845
+ this.accessToken && (j[this.accessToken] = e);
847
846
  }
848
847
  clearCacheVersion() {
849
- this.accessToken && (S[this.accessToken] = 0);
848
+ this.accessToken && (j[this.accessToken] = 0);
850
849
  }
851
850
  cacheProvider() {
852
851
  switch (this.cache.type) {
853
852
  case "memory":
854
853
  return {
855
854
  get(e) {
856
- return Promise.resolve(x[e]);
855
+ return Promise.resolve(O[e]);
857
856
  },
858
857
  getAll() {
859
- return Promise.resolve(x);
858
+ return Promise.resolve(O);
860
859
  },
861
860
  set(e, t) {
862
- return x[e] = t, Promise.resolve(void 0);
861
+ return O[e] = t, Promise.resolve(void 0);
863
862
  },
864
863
  flush() {
865
- return x = {}, Promise.resolve(void 0);
864
+ return O = {}, Promise.resolve(void 0);
866
865
  }
867
866
  };
868
867
  case "custom":
@@ -890,7 +889,7 @@ class Pe {
890
889
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
891
890
  }
892
891
  }
893
- const De = (i = {}) => {
892
+ const Ge = (i = {}) => {
894
893
  const { apiOptions: e } = i;
895
894
  if (!e || !e.accessToken) {
896
895
  console.error(
@@ -898,8 +897,8 @@ const De = (i = {}) => {
898
897
  );
899
898
  return;
900
899
  }
901
- return { storyblokApi: new Pe(e) };
902
- }, qe = (i) => {
900
+ return { storyblokApi: new He(e) };
901
+ }, Je = (i) => {
903
902
  if (typeof i != "object" || typeof i._editable > "u")
904
903
  return {};
905
904
  try {
@@ -914,18 +913,18 @@ const De = (i = {}) => {
914
913
  return {};
915
914
  }
916
915
  };
917
- function Ne(i, e) {
916
+ function Me(i, e) {
918
917
  if (!e)
919
918
  return { src: i, attrs: {} };
920
919
  let t = 0, s = 0;
921
920
  const r = {}, o = [];
922
- function n(a, h, u, p, y) {
923
- typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : y.push(`${p}(${a})`);
921
+ function n(a, h, u, p, b) {
922
+ typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : b.push(`${p}(${a})`);
924
923
  }
925
924
  if (typeof e == "object") {
926
925
  if (typeof e.width == "number" && e.width > 0 ? (r.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 ? (r.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) && (r.loading = e.loading), e.class && (r.class = e.class), e.filters) {
927
- const { filters: a } = e || {}, { blur: h, brightness: u, fill: p, format: y, grayscale: k, quality: T, rotate: _ } = a || {};
928
- h && n(h, 0, 100, "blur", o), T && n(T, 0, 100, "quality", o), u && n(u, 0, 100, "brightness", o), p && o.push(`fill(${p})`), k && o.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${_})`), y && ["webp", "png", "jpeg"].includes(y) && o.push(`format(${y})`);
926
+ const { filters: a } = e || {}, { blur: h, brightness: u, fill: p, format: b, grayscale: _, quality: y, rotate: S } = a || {};
927
+ h && n(h, 0, 100, "blur", o), y && n(y, 0, 100, "quality", o), u && n(u, 0, 100, "brightness", o), p && o.push(`fill(${p})`), _ && o.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${S})`), b && ["webp", "png", "jpeg"].includes(b) && o.push(`format(${b})`);
929
928
  }
930
929
  e.srcset && (r.srcset = e.srcset.map((a) => {
931
930
  if (typeof a == "number")
@@ -939,14 +938,14 @@ function Ne(i, e) {
939
938
  }
940
939
  }).join(", ")), e.sizes && (r.sizes = e.sizes.join(", "));
941
940
  }
942
- let l = `${i}/m/`;
943
- return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
944
- src: l,
941
+ let c = `${i}/m/`;
942
+ return t > 0 && s > 0 && (c = `${c}${t}x${s}/`), o.length > 0 && (c = `${c}filters:${o.join(":")}`), {
943
+ src: c,
945
944
  attrs: r
946
945
  };
947
946
  }
948
- var v = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))(v || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), G = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(G || {}), I = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(I || {});
949
- const He = [
947
+ var $ = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))($ || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), V = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(V || {}), I = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(I || {});
948
+ const Be = [
950
949
  "area",
951
950
  "base",
952
951
  "br",
@@ -961,193 +960,199 @@ const He = [
961
960
  "source",
962
961
  "track",
963
962
  "wbr"
964
- ], Me = (i = {}) => Object.keys(i).map((e) => `${e}="${i[e]}"`).join(" "), Be = (i = {}) => Object.keys(i).map((e) => `${e}: ${i[e]}`).join("; ");
965
- function Ue(i) {
963
+ ], Ue = (i = {}) => Object.keys(i).map((e) => `${e}="${i[e]}"`).join(" "), ze = (i = {}) => Object.keys(i).map((e) => `${e}: ${i[e]}`).join("; ");
964
+ function De(i) {
966
965
  return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
967
966
  }
968
- const O = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
969
- function q(i, e = {}, t) {
970
- const s = Me(e), r = s ? `${i} ${s}` : i, o = Array.isArray(t) ? t.join("") : t || "";
967
+ const L = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
968
+ function G(i, e = {}, t) {
969
+ const s = Ue(e), r = s ? `${i} ${s}` : i, o = Array.isArray(t) ? t.join("") : t || "";
971
970
  if (i) {
972
- if (He.includes(i))
971
+ if (Be.includes(i))
973
972
  return `<${r}>`;
974
973
  } else return o;
975
974
  return `<${r}>${o}</${i}>`;
976
975
  }
977
- function Fe(i = {}) {
978
- let e = 0;
979
- const {
980
- renderFn: t = q,
981
- textFn: s = Ue,
976
+ function Ve(i = {}) {
977
+ const e = /* @__PURE__ */ new Map(), {
978
+ renderFn: t = G,
979
+ textFn: s = De,
982
980
  resolvers: r = {},
983
981
  optimizeImages: o = !1,
984
982
  keyedResolvers: n = !1
985
- } = i, l = t !== q, a = (c) => (d) => {
983
+ } = i, c = t !== G, a = () => ({ render: (l, d = {}, g) => {
984
+ if (n && l) {
985
+ const f = e.get(l) || 0;
986
+ e.set(l, f + 1), d.key = `${l}-${f}`;
987
+ }
988
+ return t(l, d, g);
989
+ } }), h = (l) => (d, g) => {
986
990
  const f = d.attrs || {};
987
- return n && (f.key = `${c}-${e}`), t(c, f, d.children || null);
988
- }, h = (c) => {
989
- const { src: d, alt: f, title: b, srcset: R, sizes: $ } = c.attrs || {};
990
- let m = d, w = {};
991
+ return g.render(l, f, d.children || null);
992
+ }, u = (l, d) => {
993
+ const { src: g, alt: f, title: k, srcset: w, sizes: v } = l.attrs || {};
994
+ let T = g, R = {};
991
995
  if (o) {
992
- const { src: ee, attrs: te } = Ne(d, o);
993
- m = ee, w = te;
996
+ const { src: se, attrs: re } = Me(g, o);
997
+ T = se, R = re;
994
998
  }
995
- n && (w = {
996
- ...w,
997
- key: `img-${e}`
998
- });
999
- const Z = {
1000
- src: m,
999
+ const te = {
1000
+ src: T,
1001
1001
  alt: f,
1002
- title: b,
1003
- srcset: R,
1004
- sizes: $,
1005
- ...w
1006
- };
1007
- return t("img", O(Z));
1008
- }, u = (c) => {
1009
- const { level: d, ...f } = c.attrs || {}, b = {
1010
- ...f
1002
+ title: k,
1003
+ srcset: w,
1004
+ sizes: v,
1005
+ ...R
1011
1006
  };
1012
- return n && (b.key = `h${d}-${e}`), t(`h${d}`, b, c.children);
1013
- }, p = (c) => {
1014
- var d, f, b, R;
1015
- const $ = t("img", {
1016
- src: (d = c.attrs) == null ? void 0 : d.fallbackImage,
1017
- alt: (f = c.attrs) == null ? void 0 : f.alt,
1007
+ return d.render("img", L(te));
1008
+ }, p = (l, d) => {
1009
+ const { level: g, ...f } = l.attrs || {};
1010
+ return d.render(`h${g}`, f, l.children);
1011
+ }, b = (l, d) => {
1012
+ var g, f, k, w;
1013
+ const v = d.render("img", {
1014
+ src: (g = l.attrs) == null ? void 0 : g.fallbackImage,
1015
+ alt: (f = l.attrs) == null ? void 0 : f.alt,
1018
1016
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
1019
1017
  draggable: "false",
1020
1018
  loading: "lazy"
1021
- }), m = {
1019
+ });
1020
+ return d.render("span", {
1022
1021
  "data-type": "emoji",
1023
- "data-name": (b = c.attrs) == null ? void 0 : b.name,
1024
- "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1025
- };
1026
- return n && (m.key = `emoji-${e}`), t("span", m, $);
1027
- }, y = (c) => t("pre", {
1028
- ...c.attrs,
1029
- key: `code-${e}`
1030
- }, t("code", { key: `code-${e}` }, c.children || "")), k = (c, d = !1) => ({ text: f, attrs: b }) => {
1031
- const { class: R, id: $, ...m } = b || {}, w = d ? {
1032
- class: R,
1033
- id: $,
1034
- style: Be(m) || void 0
1035
- } : b || {};
1036
- return n && (w.key = `${c}-${e}`), t(c, O(w), f);
1037
- }, T = (c) => P(c), _ = (c) => {
1038
- const { marks: d, ...f } = c;
1039
- return "text" in c ? d ? d.reduce(
1040
- (b, R) => T({ ...R, text: b }),
1041
- // Fix: Ensure render function returns a string
1042
- T({ ...f, children: f.children })
1043
- // Fix: Cast children to string
1044
- ) : s(f.text) : "";
1045
- }, j = (c) => {
1046
- const { linktype: d, href: f, anchor: b, ...R } = c.attrs || {};
1047
- let $ = "";
1048
- switch (d) {
1022
+ "data-name": (k = l.attrs) == null ? void 0 : k.name,
1023
+ "data-emoji": (w = l.attrs) == null ? void 0 : w.emoji
1024
+ }, v);
1025
+ }, _ = (l, d) => d.render(
1026
+ "pre",
1027
+ l.attrs || {},
1028
+ d.render("code", {}, l.children || "")
1029
+ ), y = (l, d = !1) => ({ text: g, attrs: f }, k) => {
1030
+ const { class: w, id: v, ...T } = f || {}, R = d ? {
1031
+ class: w,
1032
+ id: v,
1033
+ style: ze(T) || void 0
1034
+ } : f || {};
1035
+ return k.render(l, L(R), g);
1036
+ }, S = (l) => N(l), x = (l) => {
1037
+ const { marks: d, ...g } = l;
1038
+ if ("text" in l) {
1039
+ if (d)
1040
+ return d.reduce(
1041
+ (k, w) => S({ ...w, text: k }),
1042
+ S({ ...g, children: g.children })
1043
+ );
1044
+ const f = l.attrs || {};
1045
+ if (n) {
1046
+ const k = e.get("txt") || 0;
1047
+ e.set("txt", k + 1), f.key = `txt-${k}`;
1048
+ }
1049
+ return s(g.text, f);
1050
+ }
1051
+ return "";
1052
+ }, U = (l, d) => {
1053
+ const { linktype: g, href: f, anchor: k, ...w } = l.attrs || {};
1054
+ let v = "";
1055
+ switch (g) {
1049
1056
  case I.ASSET:
1050
1057
  case I.URL:
1051
- $ = f;
1058
+ v = f;
1052
1059
  break;
1053
1060
  case I.EMAIL:
1054
- $ = `mailto:${f}`;
1061
+ v = `mailto:${f}`;
1055
1062
  break;
1056
1063
  case I.STORY:
1057
- $ = f, b && ($ = `${$}#${b}`);
1064
+ v = f, k && (v = `${v}#${k}`);
1058
1065
  break;
1059
1066
  default:
1060
- $ = f;
1067
+ v = f;
1061
1068
  break;
1062
1069
  }
1063
- const m = { ...R };
1064
- return $ && (m.href = $), n && (m.key = `a-${e}`), t("a", m, c.text);
1065
- }, J = (c) => {
1066
- var d, f;
1067
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1068
- blok: (d = c == null ? void 0 : c.attrs) == null ? void 0 : d.body[0],
1069
- id: (f = c.attrs) == null ? void 0 : f.id,
1070
- key: `component-${e}`,
1070
+ const T = { ...w };
1071
+ return v && (T.href = v), d.render("a", T, l.text);
1072
+ }, Y = (l, d) => {
1073
+ var g, f;
1074
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
1075
+ blok: (g = l == null ? void 0 : l.attrs) == null ? void 0 : g.body[0],
1076
+ id: (f = l.attrs) == null ? void 0 : f.id,
1071
1077
  style: "display: none"
1072
1078
  });
1073
- }, K = (c) => {
1074
- const d = {};
1075
- return n && (d.key = `table-${e}`), t("table", d, c.children);
1076
- }, Y = (c) => {
1077
- const d = {};
1078
- return n && (d.key = `tr-${e}`), t("tr", d, c.children);
1079
- }, W = (c) => {
1080
- const { colspan: d, rowspan: f, colwidth: b, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1081
- ...$
1079
+ }, W = (l, d) => {
1080
+ const g = {}, f = d.render("tbody", {}, l.children);
1081
+ return d.render("table", g, f);
1082
+ }, X = (l, d) => {
1083
+ const g = {};
1084
+ return d.render("tr", g, l.children);
1085
+ }, Q = (l, d) => {
1086
+ const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
1087
+ ...v
1082
1088
  };
1083
- d > 1 && (m.colspan = d), f > 1 && (m.rowspan = f);
1084
- const w = [];
1085
- return b && w.push(`width: ${b}px;`), R && w.push(`background-color: ${R};`), w.length > 0 && (m.style = w.join(" ")), n && (m.key = `td-${e}`), t("td", O(m), c.children);
1086
- }, X = (c) => {
1087
- const { colspan: d, rowspan: f, colwidth: b, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1088
- ...$
1089
+ g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
1090
+ const R = [];
1091
+ return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), d.render("td", L(T), l.children);
1092
+ }, Z = (l, d) => {
1093
+ const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
1094
+ ...v
1089
1095
  };
1090
- d > 1 && (m.colspan = d), f > 1 && (m.rowspan = f);
1091
- const w = [];
1092
- return b && w.push(`width: ${b}px;`), R && w.push(`background-color: ${R};`), w.length > 0 && (m.style = w.join(" ")), n && (m.key = `th-${e}`), t("th", O(m), c.children);
1093
- }, Q = new Map([
1094
- [v.DOCUMENT, a("")],
1095
- [v.HEADING, u],
1096
- [v.PARAGRAPH, a("p")],
1097
- [v.UL_LIST, a("ul")],
1098
- [v.OL_LIST, a("ol")],
1099
- [v.LIST_ITEM, a("li")],
1100
- [v.IMAGE, h],
1101
- [v.EMOJI, p],
1102
- [v.CODE_BLOCK, y],
1103
- [v.HR, a("hr")],
1104
- [v.BR, a("br")],
1105
- [v.QUOTE, a("blockquote")],
1106
- [v.COMPONENT, J],
1107
- [G.TEXT, _],
1108
- [E.LINK, j],
1109
- [E.ANCHOR, j],
1110
- [E.STYLED, k("span", !0)],
1111
- [E.BOLD, k("strong")],
1112
- [E.TEXT_STYLE, k("span", !0)],
1113
- [E.ITALIC, k("em")],
1114
- [E.UNDERLINE, k("u")],
1115
- [E.STRIKE, k("s")],
1116
- [E.CODE, k("code")],
1117
- [E.SUPERSCRIPT, k("sup")],
1118
- [E.SUBSCRIPT, k("sub")],
1119
- [E.HIGHLIGHT, k("mark")],
1120
- [v.TABLE, K],
1121
- [v.TABLE_ROW, Y],
1122
- [v.TABLE_CELL, W],
1123
- [v.TABLE_HEADER, X],
1124
- ...Object.entries(r).map(([c, d]) => [c, d])
1096
+ g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
1097
+ const R = [];
1098
+ return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), d.render("th", L(T), l.children);
1099
+ }, ee = new Map([
1100
+ [$.DOCUMENT, h("")],
1101
+ [$.HEADING, p],
1102
+ [$.PARAGRAPH, h("p")],
1103
+ [$.UL_LIST, h("ul")],
1104
+ [$.OL_LIST, h("ol")],
1105
+ [$.LIST_ITEM, h("li")],
1106
+ [$.IMAGE, u],
1107
+ [$.EMOJI, b],
1108
+ [$.CODE_BLOCK, _],
1109
+ [$.HR, h("hr")],
1110
+ [$.BR, h("br")],
1111
+ [$.QUOTE, h("blockquote")],
1112
+ [$.COMPONENT, Y],
1113
+ [V.TEXT, x],
1114
+ [E.LINK, U],
1115
+ [E.ANCHOR, U],
1116
+ [E.STYLED, y("span", !0)],
1117
+ [E.BOLD, y("strong")],
1118
+ [E.TEXT_STYLE, y("span", !0)],
1119
+ [E.ITALIC, y("em")],
1120
+ [E.UNDERLINE, y("u")],
1121
+ [E.STRIKE, y("s")],
1122
+ [E.CODE, y("code")],
1123
+ [E.SUPERSCRIPT, y("sup")],
1124
+ [E.SUBSCRIPT, y("sub")],
1125
+ [E.HIGHLIGHT, y("mark")],
1126
+ [$.TABLE, W],
1127
+ [$.TABLE_ROW, X],
1128
+ [$.TABLE_CELL, Q],
1129
+ [$.TABLE_HEADER, Z],
1130
+ ...Object.entries(r).map(([l, d]) => [l, d])
1125
1131
  ]);
1126
- function A(c) {
1127
- e += 1;
1128
- const d = Q.get(c.type);
1132
+ function A(l) {
1133
+ const d = ee.get(l.type);
1129
1134
  if (!d)
1130
- return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1131
- if (c.type === "text")
1132
- return d(c);
1133
- const f = c.content ? c.content.map(P) : void 0;
1135
+ return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
1136
+ const g = a();
1137
+ if (l.type === "text")
1138
+ return d(l, g);
1139
+ const f = l.content ? l.content.map(N) : void 0;
1134
1140
  return d({
1135
- ...c,
1141
+ ...l,
1136
1142
  children: f
1137
- // Fix: Update the type of 'children' to Node[]
1138
- });
1143
+ }, g);
1139
1144
  }
1140
- function P(c) {
1141
- return c.type === "doc" ? l ? c.content.map(A) : c.content.map(A).join("") : Array.isArray(c) ? c.map(A) : A(c);
1145
+ function N(l) {
1146
+ return l.type === "doc" ? c ? l.content.map(A) : l.content.map(A).join("") : Array.isArray(l) ? l.map(A) : A(l);
1142
1147
  }
1143
1148
  return {
1144
- render: P
1149
+ render: N
1145
1150
  };
1146
1151
  }
1147
- let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1148
- const Ge = (i, e, t = {}) => {
1149
- var l;
1150
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((l = window.location) == null ? void 0 : l.href).searchParams.get(
1152
+ let M, B = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1153
+ const Ke = (i, e, t = {}) => {
1154
+ var c;
1155
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
1151
1156
  "_storyblok"
1152
1157
  ), n = o !== null && +o === i;
1153
1158
  if (!(!r || !n)) {
@@ -1162,7 +1167,7 @@ const Ge = (i, e, t = {}) => {
1162
1167
  });
1163
1168
  });
1164
1169
  }
1165
- }, V = (i, e) => {
1170
+ }, K = (i, e) => {
1166
1171
  i.addNode("blok", (t) => {
1167
1172
  let s = "";
1168
1173
  return t.attrs.body.forEach((r) => {
@@ -1171,8 +1176,8 @@ const Ge = (i, e, t = {}) => {
1171
1176
  html: s
1172
1177
  };
1173
1178
  });
1174
- }, Ve = (i = {}) => {
1175
- var p, y;
1179
+ }, Ye = (i = {}) => {
1180
+ var p, b;
1176
1181
  const {
1177
1182
  bridge: e,
1178
1183
  accessToken: t,
@@ -1182,39 +1187,39 @@ const Ge = (i, e, t = {}) => {
1182
1187
  bridgeUrl: n
1183
1188
  } = i;
1184
1189
  r.accessToken = r.accessToken || t;
1185
- const l = { bridge: e, apiOptions: r };
1190
+ const c = { bridge: e, apiOptions: r };
1186
1191
  let a = {};
1187
- s.forEach((k) => {
1188
- a = { ...a, ...k(l) };
1189
- }), n && (M = n);
1190
- const u = !(typeof window > "u") && ((y = (p = window.location) == null ? void 0 : p.search) == null ? void 0 : y.includes("_storyblok_tk"));
1191
- return e !== !1 && u && F(M), H = new C(o.schema), o.resolver && V(H, o.resolver), a;
1192
- }, ze = (i) => {
1192
+ s.forEach((_) => {
1193
+ a = { ...a, ..._(c) };
1194
+ }), n && (B = n);
1195
+ const u = !(typeof window > "u") && ((b = (p = window.location) == null ? void 0 : p.search) == null ? void 0 : b.includes("_storyblok_tk"));
1196
+ return e !== !1 && u && J(B), M = new P(o.schema), o.resolver && K(M, o.resolver), a;
1197
+ }, qe = (i) => {
1193
1198
  var e;
1194
1199
  return !i || !((e = i == null ? void 0 : i.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1195
- }, Je = (i, e, t) => {
1196
- let s = t || H;
1200
+ }, We = (i, e, t) => {
1201
+ let s = t || M;
1197
1202
  if (!s) {
1198
1203
  console.error(
1199
1204
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1200
1205
  );
1201
1206
  return;
1202
1207
  }
1203
- return ze(i) ? "" : (e && (s = new C(e.schema), e.resolver && V(s, e.resolver)), s.render(i, {}, !1));
1204
- }, Ke = () => F(M);
1208
+ return qe(i) ? "" : (e && (s = new P(e.schema), e.resolver && K(s, e.resolver)), s.render(i, {}, !1));
1209
+ }, Xe = () => J(B);
1205
1210
  export {
1206
- v as BlockTypes,
1211
+ $ as BlockTypes,
1207
1212
  E as MarkTypes,
1208
- C as RichTextResolver,
1209
- Oe as RichTextSchema,
1210
- G as TextTypes,
1211
- De as apiPlugin,
1212
- ze as isRichTextEmpty,
1213
- Ke as loadStoryblokBridge,
1214
- Ge as registerStoryblokBridge,
1215
- Je as renderRichText,
1216
- Fe as richTextResolver,
1217
- qe as storyblokEditable,
1218
- Ve as storyblokInit,
1219
- Ge as useStoryblokBridge
1213
+ P as RichTextResolver,
1214
+ Ce as RichTextSchema,
1215
+ V as TextTypes,
1216
+ Ge as apiPlugin,
1217
+ qe as isRichTextEmpty,
1218
+ Xe as loadStoryblokBridge,
1219
+ Ke as registerStoryblokBridge,
1220
+ We as renderRichText,
1221
+ Ve as richTextResolver,
1222
+ Je as storyblokEditable,
1223
+ Ye as storyblokInit,
1224
+ Ke as useStoryblokBridge
1220
1225
  };