@storyblok/react 4.3.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,79 +1,80 @@
1
1
  let H = !1;
2
- const U = [], q = (r) => new Promise((e, t) => {
3
- if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
2
+ const U = [], F = (o) => new Promise((e, t) => {
3
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
4
4
  if (window.location === window.parent.location) {
5
5
  console.warn("You are not in Draft Mode or in the Visual Editor.");
6
6
  return;
7
7
  }
8
- H ? o() : U.push(o);
9
- }, document.getElementById("storyblok-javascript-bridge"))) return;
10
- const s = document.createElement("script");
11
- s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
12
- U.forEach((n) => n()), H = !0, e(o);
13
- }, document.getElementsByTagName("head")[0].appendChild(s);
8
+ H ? s() : U.push(s);
9
+ }, document.getElementById("storyblok-javascript-bridge")))
10
+ return;
11
+ const r = document.createElement("script");
12
+ r.async = !0, r.src = o, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
13
+ U.forEach((n) => n()), H = !0, e(s);
14
+ }, document.getElementsByTagName("head")[0].appendChild(r);
14
15
  });
15
- var X = Object.defineProperty, W = (r, e, t) => e in r ? X(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => W(r, typeof e != "symbol" ? e + "" : e, t);
16
- class Q extends Error {
16
+ var Q = Object.defineProperty, Z = (o, e, t) => e in o ? Q(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, p = (o, e, t) => Z(o, typeof e != "symbol" ? e + "" : e, t);
17
+ class ee extends Error {
17
18
  constructor(e) {
18
19
  super(e), this.name = "AbortError";
19
20
  }
20
21
  }
21
- function Z(r, e, t) {
22
+ function te(o, e, t) {
22
23
  if (!Number.isFinite(e))
23
24
  throw new TypeError("Expected `limit` to be a finite number");
24
25
  if (!Number.isFinite(t))
25
26
  throw new TypeError("Expected `interval` to be a finite number");
26
- const s = [];
27
- let o = [], n = 0, i = !1;
27
+ const r = [];
28
+ let s = [], n = 0, i = !1;
28
29
  const l = async () => {
29
30
  n++;
30
- const h = s.shift();
31
+ const h = r.shift();
31
32
  if (h)
32
33
  try {
33
- const d = await r(...h.args);
34
+ const d = await o(...h.args);
34
35
  h.resolve(d);
35
36
  } catch (d) {
36
37
  h.reject(d);
37
38
  }
38
39
  const u = setTimeout(() => {
39
- n--, s.length > 0 && l(), o = o.filter((d) => d !== u);
40
+ n--, r.length > 0 && l(), s = s.filter((d) => d !== u);
40
41
  }, t);
41
- o.includes(u) || o.push(u);
42
+ s.includes(u) || s.push(u);
42
43
  }, a = (...h) => i ? Promise.reject(
43
44
  new Error(
44
45
  "Throttled function is already aborted and not accepting new promises"
45
46
  )
46
47
  ) : new Promise((u, d) => {
47
- s.push({
48
+ r.push({
48
49
  resolve: u,
49
50
  reject: d,
50
51
  args: h
51
52
  }), n < e && l();
52
53
  });
53
54
  return a.abort = () => {
54
- i = !0, o.forEach(clearTimeout), o = [], s.forEach(
55
- (h) => h.reject(() => new Q("Throttle function aborted"))
56
- ), s.length = 0;
55
+ i = !0, s.forEach(clearTimeout), s = [], r.forEach(
56
+ (h) => h.reject(() => new ee("Throttle function aborted"))
57
+ ), r.length = 0;
57
58
  }, a;
58
59
  }
59
- let O = class {
60
+ class A {
60
61
  constructor() {
61
- p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
62
- ...r,
63
- per_page: e,
64
- page: t
65
- })), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
66
- const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
67
- return this.arrayFrom(t, (o, n) => n * s + r);
68
- }), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
69
- const e = {
62
+ p(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), p(this, "getOptionsPage", (e, t = 25, r = 1) => ({
63
+ ...e,
64
+ per_page: t,
65
+ page: r
66
+ })), p(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), p(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), p(this, "range", (e = 0, t = e) => {
67
+ const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
68
+ return this.arrayFrom(r, (n, i) => i * s + e);
69
+ }), p(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), p(this, "flatMap", (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], [])), p(this, "escapeHTML", function(e) {
70
+ const t = {
70
71
  "&": "&amp;",
71
72
  "<": "&lt;",
72
73
  ">": "&gt;",
73
74
  '"': "&quot;",
74
75
  "'": "&#39;"
75
- }, t = /[&<>"']/g, s = new RegExp(t.source);
76
- return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
76
+ }, r = /[&<>"']/g, s = new RegExp(r.source);
77
+ return e && s.test(e) ? e.replace(r, (n) => t[n]) : e;
77
78
  });
78
79
  }
79
80
  /**
@@ -83,18 +84,18 @@ let O = class {
83
84
  * @param {boolean} isArray
84
85
  * @return {string} Stringified object
85
86
  */
86
- stringify(r, e, t) {
87
+ stringify(e, t, r) {
87
88
  const s = [];
88
- for (const o in r) {
89
- if (!Object.prototype.hasOwnProperty.call(r, o))
89
+ for (const n in e) {
90
+ if (!Object.prototype.hasOwnProperty.call(e, n))
90
91
  continue;
91
- const n = r[o], i = t ? "" : encodeURIComponent(o);
92
- let l;
93
- typeof n == "object" ? l = this.stringify(
94
- n,
95
- e ? e + encodeURIComponent(`[${i}]`) : i,
96
- Array.isArray(n)
97
- ) : l = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(l);
92
+ const i = e[n], l = r ? "" : encodeURIComponent(n);
93
+ let a;
94
+ typeof i == "object" ? a = this.stringify(
95
+ i,
96
+ t ? t + encodeURIComponent(`[${l}]`) : l,
97
+ Array.isArray(i)
98
+ ) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(i)}`, s.push(a);
98
99
  }
99
100
  return s.join("&");
100
101
  }
@@ -103,92 +104,92 @@ let O = class {
103
104
  * @param {string} regionCode region code, could be eu, us, cn, ap or ca
104
105
  * @return {string} The base URL of the region
105
106
  */
106
- getRegionURL(r) {
107
- const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
108
- switch (r) {
107
+ getRegionURL(e) {
108
+ const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", n = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
109
+ switch (e) {
109
110
  case "us":
110
- return t;
111
+ return r;
111
112
  case "cn":
112
113
  return s;
113
114
  case "ap":
114
- return o;
115
- case "ca":
116
115
  return n;
116
+ case "ca":
117
+ return i;
117
118
  default:
118
- return e;
119
+ return t;
119
120
  }
120
121
  }
121
- };
122
- const ee = function(r, e) {
122
+ }
123
+ const re = function(o, e) {
123
124
  const t = {};
124
- for (const s in r) {
125
- const o = r[s];
126
- e.includes(s) && o !== null && (t[s] = o);
125
+ for (const r in o) {
126
+ const s = o[r];
127
+ e.includes(r) && s !== null && (t[r] = s);
127
128
  }
128
129
  return t;
129
- }, te = (r) => r === "email", re = () => ({
130
+ }, se = (o) => o === "email", oe = () => ({
130
131
  singleTag: "hr"
131
- }), se = () => ({
132
+ }), ne = () => ({
132
133
  tag: "blockquote"
133
- }), oe = () => ({
134
+ }), ie = () => ({
134
135
  tag: "ul"
135
- }), ne = (r) => ({
136
+ }), ae = (o) => ({
136
137
  tag: [
137
138
  "pre",
138
139
  {
139
140
  tag: "code",
140
- attrs: r.attrs
141
+ attrs: o.attrs
141
142
  }
142
143
  ]
143
- }), ie = () => ({
144
+ }), le = () => ({
144
145
  singleTag: "br"
145
- }), ae = (r) => ({
146
- tag: `h${r.attrs.level}`
147
- }), le = (r) => ({
146
+ }), ce = (o) => ({
147
+ tag: `h${o.attrs.level}`
148
+ }), he = (o) => ({
148
149
  singleTag: [
149
150
  {
150
151
  tag: "img",
151
- attrs: ee(r.attrs, ["src", "alt", "title"])
152
+ attrs: re(o.attrs, ["src", "alt", "title"])
152
153
  }
153
154
  ]
154
- }), ce = () => ({
155
+ }), ue = () => ({
155
156
  tag: "li"
156
- }), he = () => ({
157
+ }), de = () => ({
157
158
  tag: "ol"
158
- }), ue = () => ({
159
+ }), pe = () => ({
159
160
  tag: "p"
160
- }), de = (r) => ({
161
+ }), ge = (o) => ({
161
162
  tag: [
162
163
  {
163
164
  tag: "span",
164
165
  attrs: {
165
166
  "data-type": "emoji",
166
- "data-name": r.attrs.name,
167
- emoji: r.attrs.emoji
167
+ "data-name": o.attrs.name,
168
+ emoji: o.attrs.emoji
168
169
  }
169
170
  }
170
171
  ]
171
- }), pe = () => ({
172
+ }), me = () => ({
172
173
  tag: "b"
173
- }), ge = () => ({
174
+ }), fe = () => ({
174
175
  tag: "s"
175
- }), me = () => ({
176
+ }), ye = () => ({
176
177
  tag: "u"
177
- }), fe = () => ({
178
+ }), be = () => ({
178
179
  tag: "strong"
179
- }), ye = () => ({
180
+ }), ke = () => ({
180
181
  tag: "code"
181
- }), be = () => ({
182
+ }), ve = () => ({
182
183
  tag: "i"
183
- }), ke = (r) => {
184
- if (!r.attrs)
184
+ }), $e = (o) => {
185
+ if (!o.attrs)
185
186
  return {
186
187
  tag: ""
187
188
  };
188
- const e = new O().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
189
- if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), te(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
190
- for (const o in t.custom)
191
- t[o] = t.custom[o];
189
+ const e = new A().escapeHTML, t = { ...o.attrs }, { linktype: r = "url" } = o.attrs;
190
+ if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), se(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
191
+ for (const s in t.custom)
192
+ t[s] = t.custom[s];
192
193
  delete t.custom;
193
194
  }
194
195
  return {
@@ -199,95 +200,95 @@ const ee = function(r, e) {
199
200
  }
200
201
  ]
201
202
  };
202
- }, ve = (r) => ({
203
+ }, Te = (o) => ({
203
204
  tag: [
204
205
  {
205
206
  tag: "span",
206
- attrs: r.attrs
207
+ attrs: o.attrs
207
208
  }
208
209
  ]
209
- }), $e = () => ({
210
+ }), we = () => ({
210
211
  tag: "sub"
211
- }), Te = () => ({
212
+ }), Re = () => ({
212
213
  tag: "sup"
213
- }), we = (r) => ({
214
+ }), _e = (o) => ({
214
215
  tag: [
215
216
  {
216
217
  tag: "span",
217
- attrs: r.attrs
218
+ attrs: o.attrs
218
219
  }
219
220
  ]
220
- }), Re = (r) => {
221
+ }), Se = (o) => {
221
222
  var e;
222
- return (e = r.attrs) != null && e.color ? {
223
+ return (e = o.attrs) != null && e.color ? {
223
224
  tag: [
224
225
  {
225
226
  tag: "span",
226
227
  attrs: {
227
- style: `background-color:${r.attrs.color};`
228
+ style: `background-color:${o.attrs.color};`
228
229
  }
229
230
  }
230
231
  ]
231
232
  } : {
232
233
  tag: ""
233
234
  };
234
- }, Se = (r) => {
235
+ }, Ee = (o) => {
235
236
  var e;
236
- return (e = r.attrs) != null && e.color ? {
237
+ return (e = o.attrs) != null && e.color ? {
237
238
  tag: [
238
239
  {
239
240
  tag: "span",
240
241
  attrs: {
241
- style: `color:${r.attrs.color}`
242
+ style: `color:${o.attrs.color}`
242
243
  }
243
244
  }
244
245
  ]
245
246
  } : {
246
247
  tag: ""
247
248
  };
248
- }, _e = {
249
+ }, je = {
249
250
  nodes: {
250
- horizontal_rule: re,
251
- blockquote: se,
252
- bullet_list: oe,
253
- code_block: ne,
254
- hard_break: ie,
255
- heading: ae,
256
- image: le,
257
- list_item: ce,
258
- ordered_list: he,
259
- paragraph: ue,
260
- emoji: de
251
+ horizontal_rule: oe,
252
+ blockquote: ne,
253
+ bullet_list: ie,
254
+ code_block: ae,
255
+ hard_break: le,
256
+ heading: ce,
257
+ image: he,
258
+ list_item: ue,
259
+ ordered_list: de,
260
+ paragraph: pe,
261
+ emoji: ge
261
262
  },
262
263
  marks: {
263
- bold: pe,
264
- strike: ge,
265
- underline: me,
266
- strong: fe,
267
- code: ye,
268
- italic: be,
269
- link: ke,
270
- styled: ve,
271
- subscript: $e,
272
- superscript: Te,
273
- anchor: we,
274
- highlight: Re,
275
- textStyle: Se
276
- }
277
- }, Ee = function(r) {
264
+ bold: me,
265
+ strike: fe,
266
+ underline: ye,
267
+ strong: be,
268
+ code: ke,
269
+ italic: ve,
270
+ link: $e,
271
+ styled: Te,
272
+ subscript: we,
273
+ superscript: Re,
274
+ anchor: _e,
275
+ highlight: Se,
276
+ textStyle: Ee
277
+ }
278
+ }, Ie = function(o) {
278
279
  const e = {
279
280
  "&": "&amp;",
280
281
  "<": "&lt;",
281
282
  ">": "&gt;",
282
283
  '"': "&quot;",
283
284
  "'": "&#39;"
284
- }, t = /[&<>"']/g, s = new RegExp(t.source);
285
- return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
285
+ }, t = /[&<>"']/g, r = new RegExp(t.source);
286
+ return o && r.test(o) ? o.replace(t, (s) => e[s]) : o;
286
287
  };
287
288
  let z = !1;
288
- class je {
289
+ class xe {
289
290
  constructor(e) {
290
- p(this, "marks"), p(this, "nodes"), e || (e = _e), this.marks = e.marks || [], this.nodes = e.nodes || [];
291
+ p(this, "marks"), p(this, "nodes"), e || (e = je), this.marks = e.marks || [], this.nodes = e.nodes || [];
291
292
  }
292
293
  addNode(e, t) {
293
294
  this.nodes[e] = t;
@@ -295,14 +296,14 @@ class je {
295
296
  addMark(e, t) {
296
297
  this.marks[e] = t;
297
298
  }
298
- render(e, t = { optimizeImages: !1 }, s = !0) {
299
- if (!z && s && (console.warn(
299
+ render(e, t = { optimizeImages: !1 }, r = !0) {
300
+ if (!z && r && (console.warn(
300
301
  "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/"
301
302
  ), z = !0), e && e.content && Array.isArray(e.content)) {
302
- let o = "";
303
+ let s = "";
303
304
  return e.content.forEach((n) => {
304
- o += this.renderNode(n);
305
- }), t.optimizeImages ? this.optimizeImages(o, t.optimizeImages) : o;
305
+ s += this.renderNode(n);
306
+ }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
306
307
  }
307
308
  return console.warn(
308
309
  `The render method must receive an Object with a "content" field.
@@ -332,9 +333,9 @@ class je {
332
333
  ), "";
333
334
  }
334
335
  optimizeImages(e, t) {
335
- let s = 0, o = 0, n = "", i = "";
336
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
337
- const l = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
336
+ let r = 0, s = 0, n = "", i = "";
337
+ 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}" `, s = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
338
+ const l = r > 0 || s > 0 || i.length > 0 ? `${r}x${s}${i}` : "";
338
339
  return e = e.replace(
339
340
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
340
341
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
@@ -344,52 +345,52 @@ class je {
344
345
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
345
346
  );
346
347
  if (d && d.length > 0) {
347
- const g = {
348
+ const f = {
348
349
  srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
349
350
  if (typeof y == "number")
350
351
  return `//${d}/m/${y}x0${i} ${y}w`;
351
352
  if (typeof y == "object" && y.length === 2) {
352
- let w = 0, I = 0;
353
- return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (I = y[1]), `//${d}/m/${w}x${I}${i} ${w}w`;
353
+ let _ = 0, j = 0;
354
+ return typeof y[0] == "number" && (_ = y[0]), typeof y[1] == "number" && (j = y[1]), `//${d}/m/${_}x${j}${i} ${_}w`;
354
355
  }
355
356
  return "";
356
357
  }).join(", "),
357
358
  sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
358
359
  };
359
- let R = "";
360
- return g.srcset && (R += `srcset="${g.srcset}" `), g.sizes && (R += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${R.trim()}`);
360
+ let b = "";
361
+ return f.srcset && (b += `srcset="${f.srcset}" `), f.sizes && (b += `sizes="${f.sizes}" `), a.replace(/<img/g, `<img ${b.trim()}`);
361
362
  }
362
363
  return a;
363
364
  })), e;
364
365
  }
365
366
  renderNode(e) {
366
367
  const t = [];
367
- e.marks && e.marks.forEach((o) => {
368
- const n = this.getMatchingMark(o);
368
+ e.marks && e.marks.forEach((s) => {
369
+ const n = this.getMatchingMark(s);
369
370
  n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
370
371
  });
371
- const s = this.getMatchingNode(e);
372
- return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((o) => {
373
- t.push(this.renderNode(o));
374
- }) : e.text ? t.push(Ee(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((o) => {
375
- const n = this.getMatchingMark(o);
372
+ const r = this.getMatchingNode(e);
373
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((s) => {
374
+ t.push(this.renderNode(s));
375
+ }) : e.text ? t.push(Ie(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((s) => {
376
+ const n = this.getMatchingMark(s);
376
377
  n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
377
378
  }), t.join("");
378
379
  }
379
380
  renderTag(e, t) {
380
- return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
381
- if (s.constructor === String)
382
- return `<${s}${t}>`;
381
+ return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
382
+ if (r.constructor === String)
383
+ return `<${r}${t}>`;
383
384
  {
384
- let o = `<${s.tag}`;
385
- if (s.attrs) {
386
- for (const n in s.attrs)
387
- if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
388
- const i = s.attrs[n];
389
- i !== null && (o += ` ${n}="${i}"`);
385
+ let s = `<${r.tag}`;
386
+ if (r.attrs) {
387
+ for (const n in r.attrs)
388
+ if (Object.prototype.hasOwnProperty.call(r.attrs, n)) {
389
+ const i = r.attrs[n];
390
+ i !== null && (s += ` ${n}="${i}"`);
390
391
  }
391
392
  }
392
- return `${o}${t}>`;
393
+ return `${s}${t}>`;
393
394
  }
394
395
  }).join("");
395
396
  }
@@ -426,8 +427,8 @@ class je {
426
427
  return this.renderTag(t, " /");
427
428
  }
428
429
  }
429
- const A = je;
430
- class Ie {
430
+ const L = xe;
431
+ class Oe {
431
432
  constructor(e) {
432
433
  p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
433
434
  }
@@ -447,39 +448,39 @@ class Ie {
447
448
  return this.url = e, this.parameters = t, this._methodHandler("put");
448
449
  }
449
450
  delete(e, t) {
450
- return this.url = e, this.parameters = t, this._methodHandler("delete");
451
+ return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
451
452
  }
452
453
  async _responseHandler(e) {
453
- const t = [], s = {
454
+ const t = [], r = {
454
455
  data: {},
455
456
  headers: {},
456
457
  status: 0,
457
458
  statusText: ""
458
459
  };
459
- e.status !== 204 && await e.json().then((o) => {
460
- s.data = o;
460
+ e.status !== 204 && await e.json().then((s) => {
461
+ r.data = s;
461
462
  });
462
- for (const o of e.headers.entries())
463
- t[o[0]] = o[1];
464
- return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
463
+ for (const s of e.headers.entries())
464
+ t[s[0]] = s[1];
465
+ return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
465
466
  }
466
467
  async _methodHandler(e) {
467
- let t = `${this.baseURL}${this.url}`, s = null;
468
+ let t = `${this.baseURL}${this.url}`, r = null;
468
469
  if (e === "get") {
469
- const a = new O();
470
+ const a = new A();
470
471
  t = `${this.baseURL}${this.url}?${a.stringify(
471
472
  this.parameters
472
473
  )}`;
473
474
  } else
474
- s = JSON.stringify(this.parameters);
475
- const o = new URL(t), n = new AbortController(), { signal: i } = n;
475
+ r = JSON.stringify(this.parameters);
476
+ const s = new URL(t), n = new AbortController(), { signal: i } = n;
476
477
  let l;
477
478
  this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
478
479
  try {
479
- const a = await this.fetch(`${o}`, {
480
+ const a = await this.fetch(`${s}`, {
480
481
  method: e,
481
482
  headers: this.headers,
482
- body: s,
483
+ body: r,
483
484
  signal: i,
484
485
  ...this.fetchOptions
485
486
  });
@@ -502,26 +503,26 @@ class Ie {
502
503
  }
503
504
  _statusHandler(e) {
504
505
  const t = /20[0-6]/g;
505
- return new Promise((s, o) => {
506
+ return new Promise((r, s) => {
506
507
  if (t.test(`${e.status}`))
507
- return s(e);
508
+ return r(e);
508
509
  const n = {
509
510
  message: e.statusText,
510
511
  status: e.status,
511
512
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
512
513
  };
513
- o(n);
514
+ s(n);
514
515
  });
515
516
  }
516
517
  }
517
- const xe = Ie, D = "SB-Agent", L = {
518
+ const Ae = Oe, D = "SB-Agent", P = {
518
519
  defaultAgentName: "SB-JS-CLIENT",
519
520
  defaultAgentVersion: "SB-Agent-Version",
520
521
  packageVersion: "6.0.0"
521
522
  };
522
- let x = {};
523
+ let O = {};
523
524
  const E = {};
524
- class Oe {
525
+ class Le {
525
526
  /**
526
527
  *
527
528
  * @param config ISbConfig interface
@@ -529,38 +530,38 @@ class Oe {
529
530
  */
530
531
  constructor(e, t) {
531
532
  p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
532
- let s = e.endpoint || t;
533
- if (!s) {
534
- const i = new O().getRegionURL, l = e.https === !1 ? "http" : "https";
535
- e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
533
+ let r = e.endpoint || t;
534
+ if (!r) {
535
+ const i = new A().getRegionURL, l = e.https === !1 ? "http" : "https";
536
+ e.oauthToken ? r = `${l}://${i(e.region)}/v1` : r = `${l}://${i(e.region)}/v2`;
536
537
  }
537
- const o = new Headers();
538
- o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
539
- o.set(i, l);
540
- }), o.has(D) || (o.set(D, L.defaultAgentName), o.set(
541
- L.defaultAgentVersion,
542
- L.packageVersion
538
+ const s = new Headers();
539
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
540
+ s.set(i, l);
541
+ }), s.has(D) || (s.set(D, P.defaultAgentName), s.set(
542
+ P.defaultAgentVersion,
543
+ P.packageVersion
543
544
  ));
544
545
  let n = 5;
545
- e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new A(e.richTextSchema) : this.richTextResolver = new A(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Z(
546
+ e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = te(
546
547
  this.throttledRequest.bind(this),
547
548
  n,
548
549
  1e3
549
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new O(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new xe({
550
- baseURL: s,
550
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ae({
551
+ baseURL: r,
551
552
  timeout: e.timeout || 0,
552
- headers: o,
553
+ headers: s,
553
554
  responseInterceptor: e.responseInterceptor,
554
555
  fetch: e.fetch
555
556
  });
556
557
  }
557
558
  setComponentResolver(e) {
558
559
  this.richTextResolver.addNode("blok", (t) => {
559
- let s = "";
560
- return t.attrs.body && t.attrs.body.forEach((o) => {
561
- s += e(o.component, o);
560
+ let r = "";
561
+ return t.attrs.body && t.attrs.body.forEach((s) => {
562
+ r += e(s.component, s);
562
563
  }), {
563
- html: s
564
+ html: r
564
565
  };
565
566
  });
566
567
  }
@@ -570,54 +571,55 @@ class Oe {
570
571
  factoryParamOptions(e, t) {
571
572
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
572
573
  }
573
- makeRequest(e, t, s, o, n) {
574
+ makeRequest(e, t, r, s, n) {
574
575
  const i = this.factoryParamOptions(
575
576
  e,
576
- this.helpers.getOptionsPage(t, s, o)
577
+ this.helpers.getOptionsPage(t, r, s)
577
578
  );
578
579
  return this.cacheResponse(e, i, void 0, n);
579
580
  }
580
- get(e, t, s) {
581
+ get(e, t, r) {
581
582
  t || (t = {});
582
- const o = `/${e}`, n = this.factoryParamOptions(o, t);
583
- return this.cacheResponse(o, n, void 0, s);
583
+ const s = `/${e}`, n = this.factoryParamOptions(s, t);
584
+ return this.cacheResponse(s, n, void 0, r);
584
585
  }
585
- async getAll(e, t, s, o) {
586
- const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = s ?? i.substring(i.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
586
+ async getAll(e, t, r, s) {
587
+ const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = r ?? i.substring(i.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
587
588
  i,
588
589
  t,
589
590
  n,
590
591
  a,
591
- o
592
+ s
592
593
  ), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
593
594
  this.helpers.range(a, u),
594
- (g) => this.makeRequest(i, t, n, g + 1, o)
595
+ (f) => this.makeRequest(i, t, n, f + 1, s)
595
596
  );
596
- return this.helpers.flatMap([h, ...d], (g) => Object.values(g.data[l]));
597
+ return this.helpers.flatMap([h, ...d], (f) => Object.values(f.data[l]));
597
598
  }
598
- post(e, t, s) {
599
- const o = `/${e}`;
599
+ post(e, t, r) {
600
+ const s = `/${e}`;
600
601
  return Promise.resolve(
601
- this.throttle("post", o, t, s)
602
+ this.throttle("post", s, t, r)
602
603
  );
603
604
  }
604
- put(e, t, s) {
605
- const o = `/${e}`;
605
+ put(e, t, r) {
606
+ const s = `/${e}`;
606
607
  return Promise.resolve(
607
- this.throttle("put", o, t, s)
608
+ this.throttle("put", s, t, r)
608
609
  );
609
610
  }
610
- delete(e, t, s) {
611
- const o = `/${e}`;
611
+ delete(e, t, r) {
612
+ t || (t = {});
613
+ const s = `/${e}`;
612
614
  return Promise.resolve(
613
- this.throttle("delete", o, t, s)
615
+ this.throttle("delete", s, t, r)
614
616
  );
615
617
  }
616
618
  getStories(e, t) {
617
619
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
618
620
  }
619
- getStory(e, t, s) {
620
- return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
621
+ getStory(e, t, r) {
622
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
621
623
  }
622
624
  getToken() {
623
625
  return this.accessToken;
@@ -631,9 +633,9 @@ class Oe {
631
633
  _cleanCopy(e) {
632
634
  return JSON.parse(JSON.stringify(e));
633
635
  }
634
- _insertLinks(e, t, s) {
635
- const o = e[t];
636
- 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]));
636
+ _insertLinks(e, t, r) {
637
+ const s = e[t];
638
+ s && s.fieldtype === "multilink" && s.linktype === "story" && typeof s.id == "string" && this.links[r][s.id] ? s.story = this._cleanCopy(this.links[r][s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[r][s.uuid] && (s.story = this._cleanCopy(this.links[r][s.uuid]));
637
639
  }
638
640
  /**
639
641
  *
@@ -642,40 +644,71 @@ class Oe {
642
644
  * @returns string | object
643
645
  */
644
646
  getStoryReference(e, t) {
645
- return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
646
- this.relations[e][t]
647
- )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
648
- }
649
- _insertRelations(e, t, s, o) {
650
- s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
651
- }
652
- iterateTree(e, t, s) {
653
- const o = (n) => {
654
- if (n != null) {
655
- if (n.constructor === Array)
656
- for (let i = 0; i < n.length; i++)
657
- o(n[i]);
658
- else if (n.constructor === Object) {
659
- if (n._stopResolving)
660
- return;
661
- for (const i in n)
662
- (n.component && n._uid || n.type === "link") && (this._insertRelations(
663
- n,
664
- i,
665
- t,
666
- s
667
- ), this._insertLinks(
668
- n,
669
- i,
670
- s
671
- )), o(n[i]);
672
- }
647
+ return this.relations[e][t] ? JSON.parse(this.stringifiedStoriesCache[t] || JSON.stringify(this.relations[e][t])) : t;
648
+ }
649
+ /**
650
+ * Resolves a field's value by replacing UUIDs with their corresponding story references
651
+ * @param jtree - The JSON tree object containing the field to resolve
652
+ * @param treeItem - The key of the field to resolve
653
+ * @param resolveId - The unique identifier for the current resolution context
654
+ *
655
+ * This method handles both single string UUIDs and arrays of UUIDs:
656
+ * - For single strings: directly replaces the UUID with the story reference
657
+ * - For arrays: maps through each UUID and replaces with corresponding story references
658
+ */
659
+ _resolveField(e, t, r) {
660
+ const s = e[t];
661
+ typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map(
662
+ (n) => this.getStoryReference(r, n)
663
+ ).filter(Boolean));
664
+ }
665
+ /**
666
+ * Inserts relations into the JSON tree by resolving references
667
+ * @param jtree - The JSON tree object to process
668
+ * @param treeItem - The current field being processed
669
+ * @param fields - The relation patterns to resolve (string or array of strings)
670
+ * @param resolveId - The unique identifier for the current resolution context
671
+ *
672
+ * This method handles two types of relation patterns:
673
+ * 1. Nested relations: matches fields that end with the current field name
674
+ * Example: If treeItem is "event_type", it matches patterns like "*.event_type"
675
+ *
676
+ * 2. Direct component relations: matches exact component.field patterns
677
+ * Example: "event.event_type" for component "event" and field "event_type"
678
+ *
679
+ * The method supports both string and array formats for the fields parameter,
680
+ * allowing flexible specification of relation patterns.
681
+ */
682
+ _insertRelations(e, t, r, s) {
683
+ if (Array.isArray(r) ? r.find((i) => i.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
684
+ this._resolveField(e, t, s);
685
+ return;
686
+ }
687
+ const n = e.component ? `${e.component}.${t}` : t;
688
+ (Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, s);
689
+ }
690
+ /**
691
+ * Recursively traverses and resolves relations in the story content tree
692
+ * @param story - The story object containing the content to process
693
+ * @param fields - The relation patterns to resolve
694
+ * @param resolveId - The unique identifier for the current resolution context
695
+ */
696
+ iterateTree(e, t, r) {
697
+ const s = (n, i = "") => {
698
+ if (!(!n || n._stopResolving)) {
699
+ if (Array.isArray(n))
700
+ n.forEach((l, a) => s(l, `${i}[${a}]`));
701
+ else if (typeof n == "object")
702
+ for (const l in n) {
703
+ const a = i ? `${i}.${l}` : l;
704
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, r), this._insertLinks(n, l, r)), s(n[l], a);
705
+ }
673
706
  }
674
707
  };
675
- o(e.content);
708
+ s(e.content);
676
709
  }
677
- async resolveLinks(e, t, s) {
678
- let o = [];
710
+ async resolveLinks(e, t, r) {
711
+ let s = [];
679
712
  if (e.link_uuids) {
680
713
  const n = e.link_uuids.length, i = [], l = 50;
681
714
  for (let a = 0; a < n; a += l) {
@@ -690,20 +723,20 @@ class Oe {
690
723
  by_uuids: i[a].join(",")
691
724
  })).data.stories.forEach(
692
725
  (h) => {
693
- o.push(h);
726
+ s.push(h);
694
727
  }
695
728
  );
696
729
  } else
697
- o = e.links;
698
- o.forEach((n) => {
699
- this.links[s][n.uuid] = {
730
+ s = e.links;
731
+ s.forEach((n) => {
732
+ this.links[r][n.uuid] = {
700
733
  ...n,
701
734
  _stopResolving: !0
702
735
  };
703
736
  });
704
737
  }
705
- async resolveRelations(e, t, s) {
706
- let o = [];
738
+ async resolveRelations(e, t, r) {
739
+ let s = [];
707
740
  if (e.rel_uuids) {
708
741
  const n = e.rel_uuids.length, i = [], l = 50;
709
742
  for (let a = 0; a < n; a += l) {
@@ -718,12 +751,12 @@ class Oe {
718
751
  by_uuids: i[a].join(","),
719
752
  excluding_fields: t.excluding_fields
720
753
  })).data.stories.forEach((h) => {
721
- o.push(h);
754
+ s.push(h);
722
755
  });
723
756
  } else
724
- o = e.rels;
725
- o && o.length > 0 && o.forEach((n) => {
726
- this.relations[s][n.uuid] = {
757
+ s = e.rels;
758
+ s && s.length > 0 && s.forEach((n) => {
759
+ this.relations[r][n.uuid] = {
727
760
  ...n,
728
761
  _stopResolving: !0
729
762
  };
@@ -738,21 +771,21 @@ class Oe {
738
771
  * @returns Promise<void>
739
772
  *
740
773
  */
741
- async resolveStories(e, t, s) {
742
- var o, n;
774
+ async resolveStories(e, t, r) {
775
+ var s, n;
743
776
  let i = [];
744
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
745
- for (const l in this.relations[s])
777
+ if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
778
+ for (const l in this.relations[r])
746
779
  this.iterateTree(
747
- this.relations[s][l],
780
+ this.relations[r][l],
748
781
  i,
749
- s
782
+ r
750
783
  );
751
- e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
752
- this.iterateTree(l, i, s);
753
- }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
784
+ e.story ? this.iterateTree(e.story, i, r) : e.stories.forEach((l) => {
785
+ this.iterateTree(l, i, r);
786
+ }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
754
787
  }
755
- async cacheResponse(e, t, s, o) {
788
+ async cacheResponse(e, t, r, s) {
756
789
  const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
757
790
  if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
758
791
  const l = await i.get(n);
@@ -766,7 +799,7 @@ class Oe {
766
799
  "get",
767
800
  e,
768
801
  t,
769
- o
802
+ s
770
803
  );
771
804
  if (u.status !== 200)
772
805
  return a(u);
@@ -775,21 +808,21 @@ class Oe {
775
808
  perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
776
809
  total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
777
810
  })), d.data.story || d.data.stories) {
778
- const g = this.resolveCounter = ++this.resolveCounter % 1e3;
779
- await this.resolveStories(d.data, t, `${g}`);
811
+ const f = this.resolveCounter = ++this.resolveCounter % 1e3;
812
+ await this.resolveStories(d.data, t, `${f}`);
780
813
  }
781
814
  return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), l(d);
782
815
  } catch (u) {
783
- if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
816
+ if (u.response && u.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
784
817
  return console.log(
785
818
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
786
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
819
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(a);
787
820
  a(u);
788
821
  }
789
822
  });
790
823
  }
791
- throttledRequest(e, t, s, o) {
792
- return this.client.setFetchOptions(o), this.client[e](t, s);
824
+ throttledRequest(e, t, r, s) {
825
+ return this.client.setFetchOptions(s), this.client[e](t, r);
793
826
  }
794
827
  cacheVersions() {
795
828
  return E;
@@ -808,16 +841,16 @@ class Oe {
808
841
  case "memory":
809
842
  return {
810
843
  get(e) {
811
- return Promise.resolve(x[e]);
844
+ return Promise.resolve(O[e]);
812
845
  },
813
846
  getAll() {
814
- return Promise.resolve(x);
847
+ return Promise.resolve(O);
815
848
  },
816
849
  set(e, t) {
817
- return x[e] = t, Promise.resolve(void 0);
850
+ return O[e] = t, Promise.resolve(void 0);
818
851
  },
819
852
  flush() {
820
- return x = {}, Promise.resolve(void 0);
853
+ return O = {}, Promise.resolve(void 0);
821
854
  }
822
855
  };
823
856
  case "custom":
@@ -844,63 +877,63 @@ class Oe {
844
877
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
845
878
  }
846
879
  }
847
- const Ue = (r = {}) => {
848
- const { apiOptions: e } = r;
849
- if (!e.accessToken) {
880
+ const ze = (o = {}) => {
881
+ const { apiOptions: e } = o;
882
+ if (!e || !e.accessToken) {
850
883
  console.error(
851
884
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
852
885
  );
853
886
  return;
854
887
  }
855
- return { storyblokApi: new Oe(e) };
856
- }, ze = (r) => {
857
- if (typeof r != "object" || typeof r._editable > "u")
888
+ return { storyblokApi: new Le(e) };
889
+ }, De = (o) => {
890
+ if (typeof o != "object" || typeof o._editable > "u")
858
891
  return {};
859
892
  try {
860
893
  const e = JSON.parse(
861
- r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
894
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
862
895
  );
863
896
  return e ? {
864
897
  "data-blok-c": JSON.stringify(e),
865
- "data-blok-uid": e.id + "-" + e.uid
898
+ "data-blok-uid": `${e.id}-${e.uid}`
866
899
  } : {};
867
900
  } catch {
868
901
  return {};
869
902
  }
870
903
  };
871
- function Ae(r, e) {
904
+ function Ce(o, e) {
872
905
  if (!e)
873
- return { src: r, attrs: {} };
874
- let t = 0, s = 0;
875
- const o = {}, n = [];
876
- function i(a, h, u, d, g) {
877
- typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${a})`);
906
+ return { src: o, attrs: {} };
907
+ let t = 0, r = 0;
908
+ const s = {}, n = [];
909
+ function i(a, h, u, d, f) {
910
+ typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : f.push(`${d}(${a})`);
878
911
  }
879
912
  if (typeof e == "object") {
880
- 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) {
881
- const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: R, quality: y, rotate: w } = a || {};
882
- h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
913
+ if (typeof e.width == "number" && e.width > 0 ? (s.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 ? (s.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) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
914
+ const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: f, grayscale: b, quality: y, rotate: _ } = a || {};
915
+ h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), b && n.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${_})`), f && ["webp", "png", "jpeg"].includes(f) && n.push(`format(${f})`);
883
916
  }
884
- e.srcset && (o.srcset = e.srcset.map((a) => {
917
+ e.srcset && (s.srcset = e.srcset.map((a) => {
885
918
  if (typeof a == "number")
886
- return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
919
+ return `${o}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
887
920
  if (Array.isArray(a) && a.length === 2) {
888
921
  const [h, u] = a;
889
- return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
922
+ return `${o}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
890
923
  } else {
891
924
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
892
925
  return;
893
926
  }
894
- }).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
927
+ }).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
895
928
  }
896
- let l = `${r}/m/`;
897
- return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
929
+ let l = `${o}/m/`;
930
+ return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
898
931
  src: l,
899
- attrs: o
932
+ attrs: s
900
933
  };
901
934
  }
902
- var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), G = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(G || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
903
- const Ce = [
935
+ var $ = /* @__PURE__ */ ((o) => (o.DOCUMENT = "doc", o.HEADING = "heading", o.PARAGRAPH = "paragraph", o.QUOTE = "blockquote", o.OL_LIST = "ordered_list", o.UL_LIST = "bullet_list", o.LIST_ITEM = "list_item", o.CODE_BLOCK = "code_block", o.HR = "horizontal_rule", o.BR = "hard_break", o.IMAGE = "image", o.EMOJI = "emoji", o.COMPONENT = "blok", o))($ || {}), T = /* @__PURE__ */ ((o) => (o.BOLD = "bold", o.STRONG = "strong", o.STRIKE = "strike", o.UNDERLINE = "underline", o.ITALIC = "italic", o.CODE = "code", o.LINK = "link", o.ANCHOR = "anchor", o.STYLED = "styled", o.SUPERSCRIPT = "superscript", o.SUBSCRIPT = "subscript", o.TEXT_STYLE = "textStyle", o.HIGHLIGHT = "highlight", o))(T || {}), G = /* @__PURE__ */ ((o) => (o.TEXT = "text", o))(G || {}), I = /* @__PURE__ */ ((o) => (o.URL = "url", o.STORY = "story", o.ASSET = "asset", o.EMAIL = "email", o))(I || {});
936
+ const Pe = [
904
937
  "area",
905
938
  "base",
906
939
  "br",
@@ -915,224 +948,236 @@ const Ce = [
915
948
  "source",
916
949
  "track",
917
950
  "wbr"
918
- ], Le = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), Pe = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
919
- function Ne(r) {
920
- return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
951
+ ], Ne = (o = {}) => Object.keys(o).map((e) => `${e}="${o[e]}"`).join(" "), Me = (o = {}) => Object.keys(o).map((e) => `${e}: ${o[e]}`).join("; ");
952
+ function He(o) {
953
+ return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
921
954
  }
922
- const B = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
923
- function Me(r, e = {}, t) {
924
- const s = Le(e), o = s ? `${r} ${s}` : r;
925
- return Ce.includes(r) ? `<${o}>` : `<${o}>${Array.isArray(t) ? t.join("") : t || ""}</${r}>`;
955
+ const B = (o) => Object.fromEntries(Object.entries(o).filter(([e, t]) => t !== void 0));
956
+ function q(o, e = {}, t) {
957
+ const r = Ne(e), s = r ? `${o} ${r}` : o, n = Array.isArray(t) ? t.join("") : t || "";
958
+ if (o) {
959
+ if (Pe.includes(o))
960
+ return `<${s}>`;
961
+ } else return n;
962
+ return `<${s}>${n}</${o}>`;
926
963
  }
927
- function De(r = {}) {
964
+ function Be(o = {}) {
928
965
  let e = 0;
929
966
  const {
930
- renderFn: t = Me,
931
- textFn: s = Ne,
932
- resolvers: o = {},
967
+ renderFn: t = q,
968
+ textFn: r = He,
969
+ resolvers: s = {},
933
970
  optimizeImages: n = !1,
934
971
  keyedResolvers: i = !1
935
- } = r, l = (c) => (m) => {
936
- const f = m.attrs || {};
937
- return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
938
- }, a = (c) => {
939
- const { src: m, alt: f, title: b, srcset: T, sizes: $ } = c.attrs || {};
940
- let S = m, _ = {};
972
+ } = o, l = t !== q, a = (c) => (g) => {
973
+ const m = g.attrs || {};
974
+ return i && (m.key = `${c}-${e}`), t(c, m, g.children || null);
975
+ }, h = (c) => {
976
+ const { src: g, alt: m, title: k, srcset: R, sizes: v } = c.attrs || {};
977
+ let w = g, S = {};
941
978
  if (n) {
942
- const { src: K, attrs: Y } = Ae(m, n);
943
- S = K, _ = Y;
979
+ const { src: W, attrs: X } = Ce(g, n);
980
+ w = W, S = X;
944
981
  }
945
- i && (_ = {
946
- ..._,
982
+ i && (S = {
983
+ ...S,
947
984
  key: `img-${e}`
948
985
  });
949
- const J = {
950
- src: S,
951
- alt: f,
952
- title: b,
953
- srcset: T,
954
- sizes: $,
955
- ..._
956
- };
957
- return t("img", B(J));
958
- }, h = (c) => {
959
- const { level: m, ...f } = c.attrs || {}, b = {
960
- ...f
986
+ const Y = {
987
+ src: w,
988
+ alt: m,
989
+ title: k,
990
+ srcset: R,
991
+ sizes: v,
992
+ ...S
961
993
  };
962
- return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
994
+ return t("img", B(Y));
963
995
  }, u = (c) => {
964
- var m, f, b, T;
965
- const $ = t("img", {
966
- src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
967
- alt: (f = c.attrs) == null ? void 0 : f.alt,
996
+ const { level: g, ...m } = c.attrs || {}, k = {
997
+ ...m
998
+ };
999
+ return i && (k.key = `h${g}-${e}`), t(`h${g}`, k, c.children);
1000
+ }, d = (c) => {
1001
+ var g, m, k, R;
1002
+ const v = t("img", {
1003
+ src: (g = c.attrs) == null ? void 0 : g.fallbackImage,
1004
+ alt: (m = c.attrs) == null ? void 0 : m.alt,
968
1005
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
969
1006
  draggable: "false",
970
1007
  loading: "lazy"
971
- }), S = {
1008
+ }), w = {
972
1009
  "data-type": "emoji",
973
- "data-name": (b = c.attrs) == null ? void 0 : b.name,
974
- "data-emoji": (T = c.attrs) == null ? void 0 : T.emoji
1010
+ "data-name": (k = c.attrs) == null ? void 0 : k.name,
1011
+ "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
975
1012
  };
976
- return i && (S.key = `emoji-${e}`), t("span", S, $);
977
- }, d = (c) => t("pre", {
1013
+ return i && (w.key = `emoji-${e}`), t("span", w, v);
1014
+ }, f = (c) => t("pre", {
978
1015
  ...c.attrs,
979
1016
  key: `code-${e}`
980
- }, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
981
- const { class: T, id: $, ...S } = b || {}, _ = m ? {
982
- class: T,
983
- id: $,
984
- style: Pe(S) || void 0
985
- } : b || {};
986
- return i && (_.key = `${c}-${e}`), t(c, B(_), f);
987
- }, R = (c) => C(c), y = (c) => {
988
- const { marks: m, ...f } = c;
989
- return "text" in c ? m ? m.reduce(
990
- (b, T) => R({ ...T, text: b }),
1017
+ }, t("code", { key: `code-${e}` }, c.children || "")), b = (c, g = !1) => ({ text: m, attrs: k }) => {
1018
+ const { class: R, id: v, ...w } = k || {}, S = g ? {
1019
+ class: R,
1020
+ id: v,
1021
+ style: Me(w) || void 0
1022
+ } : k || {};
1023
+ return i && (S.key = `${c}-${e}`), t(c, B(S), m);
1024
+ }, y = (c) => C(c), _ = (c) => {
1025
+ const { marks: g, ...m } = c;
1026
+ return "text" in c ? g ? g.reduce(
1027
+ (k, R) => y({ ...R, text: k }),
991
1028
  // Fix: Ensure render function returns a string
992
- R({ ...f, children: f.children })
1029
+ y({ ...m, children: m.children })
993
1030
  // Fix: Cast children to string
994
- ) : s(f.text) : "";
995
- }, w = (c) => {
996
- const { linktype: m, href: f, anchor: b, ...T } = c.attrs || {};
997
- let $ = "";
998
- switch (m) {
999
- case j.ASSET:
1000
- case j.URL:
1001
- $ = f;
1031
+ ) : r(m.text) : "";
1032
+ }, j = (c) => {
1033
+ const { linktype: g, href: m, anchor: k, ...R } = c.attrs || {};
1034
+ let v = "";
1035
+ switch (g) {
1036
+ case I.ASSET:
1037
+ case I.URL:
1038
+ v = m;
1039
+ break;
1040
+ case I.EMAIL:
1041
+ v = `mailto:${m}`;
1002
1042
  break;
1003
- case j.EMAIL:
1004
- $ = `mailto:${f}`;
1043
+ case I.STORY:
1044
+ v = m, k && (v = `${v}#${k}`);
1005
1045
  break;
1006
- case j.STORY:
1007
- $ = f;
1046
+ default:
1047
+ v = m;
1008
1048
  break;
1009
1049
  }
1010
- return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
1011
- }, I = (c) => {
1012
- var m, f;
1050
+ const w = { ...R };
1051
+ return v && (w.href = v), i && (w.key = `a-${e}`), t("a", w, c.text);
1052
+ }, J = (c) => {
1053
+ var g, m;
1013
1054
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1014
- blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
1015
- id: (f = c.attrs) == null ? void 0 : f.id,
1055
+ blok: (g = c == null ? void 0 : c.attrs) == null ? void 0 : g.body[0],
1056
+ id: (m = c.attrs) == null ? void 0 : m.id,
1016
1057
  key: `component-${e}`,
1017
1058
  style: "display: none"
1018
1059
  });
1019
- }, F = new Map([
1020
- [k.DOCUMENT, l("div")],
1021
- [k.HEADING, h],
1022
- [k.PARAGRAPH, l("p")],
1023
- [k.UL_LIST, l("ul")],
1024
- [k.OL_LIST, l("ol")],
1025
- [k.LIST_ITEM, l("li")],
1026
- [k.IMAGE, a],
1027
- [k.EMOJI, u],
1028
- [k.CODE_BLOCK, d],
1029
- [k.HR, l("hr")],
1030
- [k.BR, l("br")],
1031
- [k.QUOTE, l("blockquote")],
1032
- [k.COMPONENT, I],
1033
- [G.TEXT, y],
1034
- [v.LINK, w],
1035
- [v.ANCHOR, w],
1036
- [v.STYLED, g("span", !0)],
1037
- [v.BOLD, g("strong")],
1038
- [v.TEXT_STYLE, g("span", !0)],
1039
- [v.ITALIC, g("em")],
1040
- [v.UNDERLINE, g("u")],
1041
- [v.STRIKE, g("s")],
1042
- [v.CODE, g("code")],
1043
- [v.SUPERSCRIPT, g("sup")],
1044
- [v.SUBSCRIPT, g("sub")],
1045
- [v.HIGHLIGHT, g("mark")],
1046
- ...Object.entries(o).map(([c, m]) => [c, m])
1060
+ }, K = new Map([
1061
+ [$.DOCUMENT, a("")],
1062
+ [$.HEADING, u],
1063
+ [$.PARAGRAPH, a("p")],
1064
+ [$.UL_LIST, a("ul")],
1065
+ [$.OL_LIST, a("ol")],
1066
+ [$.LIST_ITEM, a("li")],
1067
+ [$.IMAGE, h],
1068
+ [$.EMOJI, d],
1069
+ [$.CODE_BLOCK, f],
1070
+ [$.HR, a("hr")],
1071
+ [$.BR, a("br")],
1072
+ [$.QUOTE, a("blockquote")],
1073
+ [$.COMPONENT, J],
1074
+ [G.TEXT, _],
1075
+ [T.LINK, j],
1076
+ [T.ANCHOR, j],
1077
+ [T.STYLED, b("span", !0)],
1078
+ [T.BOLD, b("strong")],
1079
+ [T.TEXT_STYLE, b("span", !0)],
1080
+ [T.ITALIC, b("em")],
1081
+ [T.UNDERLINE, b("u")],
1082
+ [T.STRIKE, b("s")],
1083
+ [T.CODE, b("code")],
1084
+ [T.SUPERSCRIPT, b("sup")],
1085
+ [T.SUBSCRIPT, b("sub")],
1086
+ [T.HIGHLIGHT, b("mark")],
1087
+ ...Object.entries(s).map(([c, g]) => [c, g])
1047
1088
  ]);
1048
- function M(c) {
1089
+ function x(c) {
1049
1090
  e += 1;
1050
- const m = F.get(c.type);
1051
- if (!m)
1091
+ const g = K.get(c.type);
1092
+ if (!g)
1052
1093
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1053
1094
  if (c.type === "text")
1054
- return m(c);
1055
- const f = c.content ? c.content.map(C) : void 0;
1056
- return m({
1095
+ return g(c);
1096
+ const m = c.content ? c.content.map(C) : void 0;
1097
+ return g({
1057
1098
  ...c,
1058
- children: f
1099
+ children: m
1059
1100
  // Fix: Update the type of 'children' to Node[]
1060
1101
  });
1061
1102
  }
1062
1103
  function C(c) {
1063
- return Array.isArray(c) ? c.map(M) : M(c);
1104
+ return c.type === "doc" ? l ? c.content.map(x) : c.content.map(x).join("") : Array.isArray(c) ? c.map(x) : x(c);
1064
1105
  }
1065
1106
  return {
1066
1107
  render: C
1067
1108
  };
1068
1109
  }
1069
- let P, N = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1070
- const Be = (r, e, t = {}) => {
1071
- var s;
1072
- const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
1110
+ let N, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1111
+ const qe = (o, e, t = {}) => {
1112
+ var r;
1113
+ const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
1073
1114
  "_storyblok"
1074
- ) === r;
1075
- if (!(!o || !n)) {
1076
- if (!r) {
1115
+ ), i = n !== null && +n === o;
1116
+ if (!(!s || !i)) {
1117
+ if (!o) {
1077
1118
  console.warn("Story ID is not defined. Please provide a valid ID.");
1078
1119
  return;
1079
1120
  }
1080
1121
  window.storyblokRegisterEvent(() => {
1081
- new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
1082
- i.action === "input" && i.story.id === r ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === r && window.location.reload();
1122
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
1123
+ var a;
1124
+ l && (l.action === "input" && ((a = l.story) == null ? void 0 : a.id) === o ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === o && window.location.reload());
1083
1125
  });
1084
1126
  });
1085
1127
  }
1086
- }, qe = (r = {}) => {
1128
+ }, V = (o, e) => {
1129
+ o.addNode("blok", (t) => {
1130
+ let r = "";
1131
+ return t.attrs.body.forEach((s) => {
1132
+ r += e(s.component, s);
1133
+ }), {
1134
+ html: r
1135
+ };
1136
+ });
1137
+ }, Fe = (o = {}) => {
1087
1138
  var e, t;
1088
1139
  const {
1089
- bridge: s,
1090
- accessToken: o,
1140
+ bridge: r,
1141
+ accessToken: s,
1091
1142
  use: n = [],
1092
1143
  apiOptions: i = {},
1093
1144
  richText: l = {},
1094
1145
  bridgeUrl: a
1095
- } = r;
1096
- i.accessToken = i.accessToken || o;
1097
- const h = { bridge: s, apiOptions: i };
1146
+ } = o;
1147
+ i.accessToken = i.accessToken || s;
1148
+ const h = { bridge: r, apiOptions: i };
1098
1149
  let u = {};
1099
- n.forEach((g) => {
1100
- u = { ...u, ...g(h) };
1101
- }), a && (N = a);
1150
+ n.forEach((f) => {
1151
+ u = { ...u, ...f(h) };
1152
+ }), a && (M = a);
1102
1153
  const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1103
- return s !== !1 && d && q(N), P = new A(l.schema), l.resolver && V(P, l.resolver), u;
1104
- }, V = (r, e) => {
1105
- r.addNode("blok", (t) => {
1106
- let s = "";
1107
- return t.attrs.body.forEach((o) => {
1108
- s += e(o.component, o);
1109
- }), {
1110
- html: s
1111
- };
1112
- });
1113
- }, He = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ge = (r, e, t) => {
1114
- let s = t || P;
1115
- if (!s) {
1154
+ return r !== !1 && d && F(M), N = new L(l.schema), l.resolver && V(N, l.resolver), u;
1155
+ }, Ue = (o) => {
1156
+ var e;
1157
+ return !o || !((e = o == null ? void 0 : o.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1158
+ }, Ge = (o, e, t) => {
1159
+ let r = t || N;
1160
+ if (!r) {
1116
1161
  console.error(
1117
1162
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1118
1163
  );
1119
1164
  return;
1120
1165
  }
1121
- return He(r) ? "" : (e && (s = new A(e.schema), e.resolver && V(s, e.resolver)), s.render(r, {}, !1));
1122
- }, Ve = () => q(N);
1166
+ return Ue(o) ? "" : (e && (r = new L(e.schema), e.resolver && V(r, e.resolver)), r.render(o, {}, !1));
1167
+ }, Ve = () => F(M);
1123
1168
  export {
1124
- k as BlockTypes,
1125
- v as MarkTypes,
1126
- A as RichTextResolver,
1127
- _e as RichTextSchema,
1169
+ $ as BlockTypes,
1170
+ T as MarkTypes,
1171
+ L as RichTextResolver,
1172
+ je as RichTextSchema,
1128
1173
  G as TextTypes,
1129
- Ue as apiPlugin,
1130
- He as isRichTextEmpty,
1174
+ ze as apiPlugin,
1175
+ Ue as isRichTextEmpty,
1131
1176
  Ve as loadStoryblokBridge,
1132
- Be as registerStoryblokBridge,
1177
+ qe as registerStoryblokBridge,
1133
1178
  Ge as renderRichText,
1134
- De as richTextResolver,
1135
- ze as storyblokEditable,
1136
- qe as storyblokInit,
1137
- Be as useStoryblokBridge
1179
+ Be as richTextResolver,
1180
+ De as storyblokEditable,
1181
+ Fe as storyblokInit,
1182
+ qe as useStoryblokBridge
1138
1183
  };