@storyblok/vue 8.1.3 → 8.1.5

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