@storyblok/react 3.0.4 → 3.0.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,59 +1,59 @@
1
- let S = !1;
2
- const E = [], C = (o) => new Promise((e, t) => {
1
+ let I = !1;
2
+ const v = [], w = (i) => new Promise((e, t) => {
3
3
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
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
- S ? r() : E.push(r);
8
+ I ? r() : v.push(r);
9
9
  }, document.getElementById("storyblok-javascript-bridge")))
10
10
  return;
11
11
  const s = document.createElement("script");
12
- s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
13
- E.forEach((i) => i()), S = !0, e(r);
12
+ s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
13
+ v.forEach((o) => o()), I = !0, e(r);
14
14
  }, document.getElementsByTagName("head")[0].appendChild(s);
15
15
  });
16
- var U = Object.defineProperty, I = (o, e, t) => e in o ? U(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, h = (o, e, t) => (I(o, typeof e != "symbol" ? e + "" : e, t), t);
17
- function x(o) {
18
- return !(o !== o || o === 1 / 0 || o === -1 / 0);
16
+ var j = Object.defineProperty, U = (i, e, t) => e in i ? j(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, h = (i, e, t) => (U(i, typeof e != "symbol" ? e + "" : e, t), t);
17
+ function N(i) {
18
+ return !(i !== i || i === 1 / 0 || i === -1 / 0);
19
19
  }
20
- function O(o, e, t) {
21
- if (!x(e))
20
+ function H(i, e, t) {
21
+ if (!N(e))
22
22
  throw new TypeError("Expected `limit` to be a finite number");
23
- if (!x(t))
23
+ if (!N(t))
24
24
  throw new TypeError("Expected `interval` to be a finite number");
25
25
  const s = [];
26
- let r = [], i = 0;
26
+ let r = [], o = 0;
27
27
  const n = function() {
28
- i++;
28
+ o++;
29
29
  const a = setTimeout(function() {
30
- i--, s.length > 0 && n(), r = r.filter(function(u) {
30
+ o--, s.length > 0 && n(), r = r.filter(function(u) {
31
31
  return u !== a;
32
32
  });
33
33
  }, t);
34
34
  r.indexOf(a) < 0 && r.push(a);
35
- const l = s.shift();
36
- l.resolve(o.apply(l.self, l.args));
37
- }, c = function(...a) {
38
- const l = this;
39
- return new Promise(function(u, p) {
35
+ const c = s.shift();
36
+ c.resolve(i.apply(c.self, c.args));
37
+ }, l = function(...a) {
38
+ const c = this;
39
+ return new Promise(function(u, d) {
40
40
  s.push({
41
41
  resolve: u,
42
- reject: p,
42
+ reject: d,
43
43
  args: a,
44
- self: l
45
- }), i < e && n();
44
+ self: c
45
+ }), o < e && n();
46
46
  });
47
47
  };
48
- return c.abort = function() {
48
+ return l.abort = function() {
49
49
  r.forEach(clearTimeout), r = [], s.forEach(function(a) {
50
50
  a.reject(function() {
51
51
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
52
52
  });
53
53
  }), s.length = 0;
54
- }, c;
54
+ }, l;
55
55
  }
56
- class y {
56
+ class b {
57
57
  constructor() {
58
58
  h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
59
59
  ...e,
@@ -61,7 +61,7 @@ class y {
61
61
  page: s
62
62
  })), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
63
63
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
64
- return this.arrayFrom(s, (i, n) => n * r + e);
64
+ return this.arrayFrom(s, (o, n) => n * r + e);
65
65
  }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(e) {
66
66
  const t = {
67
67
  "&": "&amp;",
@@ -70,7 +70,7 @@ class y {
70
70
  '"': "&quot;",
71
71
  "'": "&#39;"
72
72
  }, s = /[&<>"']/g, r = RegExp(s.source);
73
- return e && r.test(e) ? e.replace(s, (i) => t[i]) : e;
73
+ return e && r.test(e) ? e.replace(s, (o) => t[o]) : e;
74
74
  });
75
75
  }
76
76
  /**
@@ -82,16 +82,16 @@ class y {
82
82
  */
83
83
  stringify(e, t, s) {
84
84
  const r = [];
85
- for (const i in e) {
86
- if (!Object.prototype.hasOwnProperty.call(e, i))
85
+ for (const o in e) {
86
+ if (!Object.prototype.hasOwnProperty.call(e, o))
87
87
  continue;
88
- const n = e[i], c = s ? "" : encodeURIComponent(i);
88
+ const n = e[o], l = s ? "" : encodeURIComponent(o);
89
89
  let a;
90
90
  typeof n == "object" ? a = this.stringify(
91
91
  n,
92
- t ? t + encodeURIComponent("[" + c + "]") : c,
92
+ t ? t + encodeURIComponent("[" + l + "]") : l,
93
93
  Array.isArray(n)
94
- ) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
94
+ ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(n), r.push(a);
95
95
  }
96
96
  return r.join("&");
97
97
  }
@@ -101,14 +101,14 @@ class y {
101
101
  * @return {String} The base URL of the region
102
102
  */
103
103
  getRegionURL(e) {
104
- const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", i = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
104
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
105
105
  switch (e) {
106
106
  case "us":
107
107
  return s;
108
108
  case "cn":
109
109
  return r;
110
110
  case "ap":
111
- return i;
111
+ return o;
112
112
  case "ca":
113
113
  return n;
114
114
  default:
@@ -116,74 +116,74 @@ class y {
116
116
  }
117
117
  }
118
118
  }
119
- const N = function(o, e) {
119
+ const P = function(i, e) {
120
120
  const t = {};
121
- for (const s in o) {
122
- const r = o[s];
121
+ for (const s in i) {
122
+ const r = i[s];
123
123
  e.indexOf(s) > -1 && r !== null && (t[s] = r);
124
124
  }
125
125
  return t;
126
- }, P = (o) => o === "email", A = () => ({
126
+ }, x = (i) => i === "email", C = () => ({
127
127
  singleTag: "hr"
128
- }), L = () => ({
128
+ }), G = () => ({
129
129
  tag: "blockquote"
130
- }), M = () => ({
130
+ }), $ = () => ({
131
131
  tag: "ul"
132
- }), D = (o) => ({
132
+ }), M = (i) => ({
133
133
  tag: [
134
134
  "pre",
135
135
  {
136
136
  tag: "code",
137
- attrs: o.attrs
137
+ attrs: i.attrs
138
138
  }
139
139
  ]
140
- }), B = () => ({
140
+ }), L = () => ({
141
141
  singleTag: "br"
142
- }), H = (o) => ({
143
- tag: `h${o.attrs.level}`
144
- }), z = (o) => ({
142
+ }), D = (i) => ({
143
+ tag: `h${i.attrs.level}`
144
+ }), B = (i) => ({
145
145
  singleTag: [
146
146
  {
147
147
  tag: "img",
148
- attrs: N(o.attrs, ["src", "alt", "title"])
148
+ attrs: P(i.attrs, ["src", "alt", "title"])
149
149
  }
150
150
  ]
151
- }), F = () => ({
151
+ }), V = () => ({
152
152
  tag: "li"
153
- }), q = () => ({
153
+ }), F = () => ({
154
154
  tag: "ol"
155
- }), V = () => ({
155
+ }), z = () => ({
156
156
  tag: "p"
157
- }), G = (o) => ({
157
+ }), W = (i) => ({
158
158
  tag: [
159
159
  {
160
160
  tag: "span",
161
161
  attrs: {
162
162
  "data-type": "emoji",
163
- "data-name": o.attrs.name,
164
- emoji: o.attrs.emoji
163
+ "data-name": i.attrs.name,
164
+ emoji: i.attrs.emoji
165
165
  }
166
166
  }
167
167
  ]
168
- }), J = () => ({
168
+ }), K = () => ({
169
169
  tag: "b"
170
- }), Y = () => ({
170
+ }), X = () => ({
171
171
  tag: "s"
172
- }), K = () => ({
172
+ }), J = () => ({
173
173
  tag: "u"
174
- }), W = () => ({
174
+ }), Y = () => ({
175
175
  tag: "strong"
176
- }), X = () => ({
176
+ }), q = () => ({
177
177
  tag: "code"
178
- }), Z = () => ({
178
+ }), Q = () => ({
179
179
  tag: "i"
180
- }), Q = (o) => {
181
- if (!o.attrs)
180
+ }), Z = (i) => {
181
+ if (!i.attrs)
182
182
  return {
183
183
  tag: ""
184
184
  };
185
- const e = new y().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
186
- if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), P(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
185
+ const e = new b().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
186
+ if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), x(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
187
187
  for (const r in t.custom)
188
188
  t[r] = t.custom[r];
189
189
  delete t.custom;
@@ -196,82 +196,82 @@ const N = function(o, e) {
196
196
  }
197
197
  ]
198
198
  };
199
- }, ee = (o) => ({
199
+ }, ee = (i) => ({
200
200
  tag: [
201
201
  {
202
202
  tag: "span",
203
- attrs: o.attrs
203
+ attrs: i.attrs
204
204
  }
205
205
  ]
206
206
  }), te = () => ({
207
207
  tag: "sub"
208
208
  }), se = () => ({
209
209
  tag: "sup"
210
- }), re = (o) => ({
210
+ }), re = (i) => ({
211
211
  tag: [
212
212
  {
213
213
  tag: "span",
214
- attrs: o.attrs
214
+ attrs: i.attrs
215
215
  }
216
216
  ]
217
- }), ie = (o) => {
217
+ }), oe = (i) => {
218
218
  var e;
219
- return (e = o.attrs) != null && e.color ? {
219
+ return (e = i.attrs) != null && e.color ? {
220
220
  tag: [
221
221
  {
222
222
  tag: "span",
223
223
  attrs: {
224
- style: `background-color:${o.attrs.color};`
224
+ style: `background-color:${i.attrs.color};`
225
225
  }
226
226
  }
227
227
  ]
228
228
  } : {
229
229
  tag: ""
230
230
  };
231
- }, ne = (o) => {
231
+ }, ne = (i) => {
232
232
  var e;
233
- return (e = o.attrs) != null && e.color ? {
233
+ return (e = i.attrs) != null && e.color ? {
234
234
  tag: [
235
235
  {
236
236
  tag: "span",
237
237
  attrs: {
238
- style: `color:${o.attrs.color}`
238
+ style: `color:${i.attrs.color}`
239
239
  }
240
240
  }
241
241
  ]
242
242
  } : {
243
243
  tag: ""
244
244
  };
245
- }, oe = {
245
+ }, ie = {
246
246
  nodes: {
247
- horizontal_rule: A,
248
- blockquote: L,
249
- bullet_list: M,
250
- code_block: D,
251
- hard_break: B,
252
- heading: H,
253
- image: z,
254
- list_item: F,
255
- ordered_list: q,
256
- paragraph: V,
257
- emoji: G
247
+ horizontal_rule: C,
248
+ blockquote: G,
249
+ bullet_list: $,
250
+ code_block: M,
251
+ hard_break: L,
252
+ heading: D,
253
+ image: B,
254
+ list_item: V,
255
+ ordered_list: F,
256
+ paragraph: z,
257
+ emoji: W
258
258
  },
259
259
  marks: {
260
- bold: J,
261
- strike: Y,
262
- underline: K,
263
- strong: W,
264
- code: X,
265
- italic: Z,
266
- link: Q,
260
+ bold: K,
261
+ strike: X,
262
+ underline: J,
263
+ strong: Y,
264
+ code: q,
265
+ italic: Q,
266
+ link: Z,
267
267
  styled: ee,
268
268
  subscript: te,
269
269
  superscript: se,
270
270
  anchor: re,
271
- highlight: ie,
271
+ highlight: oe,
272
272
  textStyle: ne
273
273
  }
274
- }, ae = function(o) {
274
+ }, ae = function(i) {
275
275
  const e = {
276
276
  "&": "&amp;",
277
277
  "<": "&lt;",
@@ -279,11 +279,11 @@ const N = function(o, e) {
279
279
  '"': "&quot;",
280
280
  "'": "&#39;"
281
281
  }, t = /[&<>"']/g, s = RegExp(t.source);
282
- return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
282
+ return i && s.test(i) ? i.replace(t, (r) => e[r]) : i;
283
283
  };
284
- class b {
284
+ class T {
285
285
  constructor(e) {
286
- h(this, "marks"), h(this, "nodes"), e || (e = oe), this.marks = e.marks || [], this.nodes = e.nodes || [];
286
+ h(this, "marks"), h(this, "nodes"), e || (e = ie), this.marks = e.marks || [], this.nodes = e.nodes || [];
287
287
  }
288
288
  addNode(e, t) {
289
289
  this.nodes[e] = t;
@@ -326,31 +326,31 @@ class b {
326
326
  ), "";
327
327
  }
328
328
  optimizeImages(e, t) {
329
- let s = 0, r = 0, i = "", n = "";
330
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
331
- const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
329
+ let s = 0, r = 0, o = "", n = "";
330
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
331
+ const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
332
332
  return e = e.replace(
333
333
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
334
- `a.storyblok.com/f/$1/$2.$3/m/${c}`
334
+ `a.storyblok.com/f/$1/$2.$3/m/${l}`
335
335
  ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
336
- var l, u;
337
- const p = a.match(
336
+ var c, u;
337
+ const d = a.match(
338
338
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
339
339
  );
340
- if (p && p.length > 0) {
341
- const g = {
342
- srcset: (l = t.srcset) == null ? void 0 : l.map((d) => {
343
- if (typeof d == "number")
344
- return `//${p}/m/${d}x0${n} ${d}w`;
345
- if (typeof d == "object" && d.length === 2) {
346
- let _ = 0, T = 0;
347
- return typeof d[0] == "number" && (_ = d[0]), typeof d[1] == "number" && (T = d[1]), `//${p}/m/${_}x${T}${n} ${_}w`;
340
+ if (d && d.length > 0) {
341
+ const m = {
342
+ srcset: (c = t.srcset) == null ? void 0 : c.map((p) => {
343
+ if (typeof p == "number")
344
+ return `//${d}/m/${p}x0${n} ${p}w`;
345
+ if (typeof p == "object" && p.length === 2) {
346
+ let y = 0, O = 0;
347
+ return typeof p[0] == "number" && (y = p[0]), typeof p[1] == "number" && (O = p[1]), `//${d}/m/${y}x${O}${n} ${y}w`;
348
348
  }
349
349
  }).join(", "),
350
- sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
350
+ sizes: (u = t.sizes) == null ? void 0 : u.map((p) => p).join(", ")
351
351
  };
352
- let v = "";
353
- return g.srcset && (v += `srcset="${g.srcset}" `), g.sizes && (v += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${v.trim()}`);
352
+ let _ = "";
353
+ return m.srcset && (_ += `srcset="${m.srcset}" `), m.sizes && (_ += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${_.trim()}`);
354
354
  }
355
355
  return a;
356
356
  })), e;
@@ -358,15 +358,15 @@ class b {
358
358
  renderNode(e) {
359
359
  const t = [];
360
360
  e.marks && e.marks.forEach((r) => {
361
- const i = this.getMatchingMark(r);
362
- i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
361
+ const o = this.getMatchingMark(r);
362
+ o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
363
363
  });
364
364
  const s = this.getMatchingNode(e);
365
365
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
366
366
  t.push(this.renderNode(r));
367
367
  }) : e.text ? t.push(ae(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
368
- const i = this.getMatchingMark(r);
369
- i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
368
+ const o = this.getMatchingMark(r);
369
+ o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
370
370
  }), t.join("");
371
371
  }
372
372
  renderTag(e, t) {
@@ -376,9 +376,9 @@ class b {
376
376
  {
377
377
  let r = `<${s.tag}`;
378
378
  if (s.attrs)
379
- for (const i in s.attrs) {
380
- const n = s.attrs[i];
381
- n !== null && (r += ` ${i}="${n}"`);
379
+ for (const o in s.attrs) {
380
+ const n = s.attrs[o];
381
+ n !== null && (r += ` ${o}="${n}"`);
382
382
  }
383
383
  return `${r}${t}>`;
384
384
  }
@@ -419,7 +419,7 @@ class b {
419
419
  }
420
420
  class le {
421
421
  constructor(e) {
422
- h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), 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 = {};
422
+ h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), h(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 = {};
423
423
  }
424
424
  /**
425
425
  *
@@ -456,31 +456,37 @@ class le {
456
456
  async _methodHandler(e) {
457
457
  let t = `${this.baseURL}${this.url}`, s = null;
458
458
  if (e === "get") {
459
- const a = new y();
459
+ const a = new b();
460
460
  t = `${this.baseURL}${this.url}?${a.stringify(
461
461
  this.parameters
462
462
  )}`;
463
463
  } else
464
464
  s = JSON.stringify(this.parameters);
465
- const r = new URL(t), i = new AbortController(), { signal: n } = i;
466
- let c;
467
- this.timeout && (c = setTimeout(() => i.abort(), this.timeout));
465
+ const r = new URL(t), o = new AbortController(), { signal: n } = o;
466
+ let l;
467
+ this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
468
468
  try {
469
469
  const a = await fetch(`${r}`, {
470
470
  method: e,
471
471
  headers: this.headers,
472
472
  body: s,
473
- signal: n
473
+ signal: n,
474
+ ...this.fetchOptions
474
475
  });
475
- this.timeout && clearTimeout(c);
476
- const l = await this._responseHandler(a);
477
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
476
+ this.timeout && clearTimeout(l);
477
+ const c = await this._responseHandler(
478
+ a
479
+ );
480
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
478
481
  } catch (a) {
479
482
  return {
480
483
  message: a
481
484
  };
482
485
  }
483
486
  }
487
+ setFetchOptions(e = {}) {
488
+ Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
489
+ }
484
490
  eject() {
485
491
  this.ejectInterceptor = !0;
486
492
  }
@@ -489,23 +495,23 @@ class le {
489
495
  return new Promise((s, r) => {
490
496
  if (t.test(`${e.status}`))
491
497
  return s(e);
492
- const i = {
498
+ const o = {
493
499
  message: e.statusText,
494
500
  status: e.status,
495
501
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
496
502
  };
497
- r(i);
503
+ r(o);
498
504
  });
499
505
  }
500
506
  }
501
- var ce = { NVM_INC: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/include/node", TERM_PROGRAM: "iTerm.app", NODE: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", NVM_CD_FLAGS: "-q", INIT_CWD: "/Users/lisilinhart/Code/storyblok-js-client", SHELL: "/bin/zsh", TERM: "xterm-256color", TMPDIR: "/var/folders/9v/t3hq3s9n2rj6_x9jlsjjq95w0000gn/T/", npm_config_metrics_registry: "https://registry.npmjs.org/", npm_config_global_prefix: "/Users/lisilinhart/.nvm/versions/node/v18.16.0", TERM_PROGRAM_VERSION: "3.4.20", TERM_SESSION_ID: "w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF", COLOR: "0", npm_config_noproxy: "", ZSH: "/Users/lisilinhart/.oh-my-zsh", npm_config_local_prefix: "/Users/lisilinhart/Code/storyblok-js-client", USER: "lisilinhart", NVM_DIR: "/Users/lisilinhart/.nvm", COMMAND_MODE: "unix2003", npm_config_globalconfig: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/etc/npmrc", SSH_AUTH_SOCK: "/private/tmp/com.apple.launchd.oUounWp9qr/Listeners", __CF_USER_TEXT_ENCODING: "0x1F5:0x0:0x5C", npm_execpath: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/bin/npm-cli.js", PAGER: "less", npm_package_integrity: "null", LSCOLORS: "Gxfxcxdxbxegedabagacad", PATH: "/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.yarn/bin:/Users/lisilinhart/.config/yarn/global/node_modules/.bin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin:/Users/lisilinhart/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/lisilinhart/.cargo/bin", RUBY_CONFIGURE_OPTS: "--with-openssl-dir=/usr/local/opt/openssl@1.1", LaunchInstanceID: "9D2A03D3-35CC-4CDD-810D-0D5C25991BBB", _: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", npm_package_json: "/Users/lisilinhart/Code/storyblok-js-client/package.json", __CFBundleIdentifier: "com.googlecode.iterm2", npm_config_init_module: "/Users/lisilinhart/.npm-init.js", npm_config_userconfig: "/Users/lisilinhart/.npmrc", PWD: "/Users/lisilinhart/Code/storyblok-js-client", npm_command: "run-script", P9K_SSH: "0", EDITOR: "vi", npm_lifecycle_event: "build", LANG: "de_AT.UTF-8", P9K_TTY: "old", npm_package_name: "storyblok-js-client", ITERM_PROFILE: "Default", XPC_FLAGS: "0x0", RBENV_SHELL: "zsh", npm_config_node_gyp: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", XPC_SERVICE_NAME: "0", npm_package_version: "6.4.1", COLORFGBG: "7;0", HOME: "/Users/lisilinhart", SHLVL: "3", npm_package_resolved: "/Users/lisilinhart/Code/storyblok-js-client", LC_TERMINAL_VERSION: "3.4.20", ITERM_SESSION_ID: "w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF", LOGNAME: "lisilinhart", LESS: "-R", npm_config_cache: "/Users/lisilinhart/.npm", npm_lifecycle_script: "node vite.build.mjs && tsc", NVM_BIN: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin", npm_config_user_agent: "npm/9.5.1 node/v18.16.0 darwin x64 workspaces/false", LC_TERMINAL: "iTerm2", SECURITYSESSIONID: "186a1", COLORTERM: "truecolor", npm_config_prefix: "/Users/lisilinhart/.nvm/versions/node/v18.16.0", npm_node_execpath: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", NODE_ENV: "production" };
502
- const $ = "SB-Agent", k = {
507
+ var ce = { GITHUB_TOKEN: "ghs_SY9hAvLQ8nuSfh6VtsLyQYlPrM7NAw095mxm", GITHUB_STATE: "/home/runner/work/_temp/_runner_file_commands/save_state_0680fa51-273e-4603-9ba8-00c19d52aa53", GIT_COMMITTER_NAME: "semantic-release-bot", STATS_TRP: "true", DEPLOYMENT_BASEPATH: "/opt/runner", DOTNET_NOLOGO: "1", USER: "runner", npm_config_user_agent: "npm/10.2.3 node/v18.19.0 linux x64 workspaces/false ci/github-actions", GIT_AUTHOR_EMAIL: "semantic-release-bot@martynus.net", CI: "true", RUNNER_ENVIRONMENT: "github-hosted", GITHUB_ENV: "/home/runner/work/_temp/_runner_file_commands/set_env_0680fa51-273e-4603-9ba8-00c19d52aa53", PIPX_HOME: "/opt/pipx", npm_node_execpath: "/opt/hostedtoolcache/node/18.19.0/x64/bin/node", GIT_ASKPASS: "echo", npm_package_resolved: "/home/runner/work/storyblok-js-client/storyblok-js-client", JAVA_HOME_8_X64: "/usr/lib/jvm/temurin-8-jdk-amd64", SHLVL: "1", npm_config_noproxy: "", HOME: "/home/runner", RUNNER_TEMP: "/home/runner/work/_temp", GITHUB_EVENT_PATH: "/home/runner/work/_temp/_github_workflow/event.json", npm_package_json: "/home/runner/work/storyblok-js-client/storyblok-js-client/package.json", JAVA_HOME_11_X64: "/usr/lib/jvm/temurin-11-jdk-amd64", PIPX_BIN_DIR: "/opt/pipx_bin", GITHUB_REPOSITORY_OWNER: "storyblok", GRADLE_HOME: "/usr/share/gradle-8.5", ANDROID_NDK_LATEST_HOME: "/usr/local/lib/android/sdk/ndk/26.1.10909125", JAVA_HOME_21_X64: "/usr/lib/jvm/temurin-21-jdk-amd64", STATS_RDCL: "true", GITHUB_RETENTION_DAYS: "90", GIT_AUTHOR_NAME: "semantic-release-bot", GITHUB_REPOSITORY_OWNER_ID: "13880908", POWERSHELL_DISTRIBUTION_CHANNEL: "GitHub-Actions-ubuntu22", AZURE_EXTENSION_DIR: "/opt/az/azcliextensions", GITHUB_HEAD_REF: "", npm_config_userconfig: "/tmp/f9cb367b92d80a35a8a750840547b152/.npmrc", npm_config_local_prefix: "/home/runner/work/storyblok-js-client/storyblok-js-client", npm_package_integrity: "null", SYSTEMD_EXEC_PID: "593", GITHUB_GRAPHQL_URL: "https://api.github.com/graphql", COLOR: "0", GOROOT_1_20_X64: "/opt/hostedtoolcache/go/1.20.12/x64", NVM_DIR: "/home/runner/.nvm", NPM_TOKEN: "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", DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1", GOROOT_1_21_X64: "/opt/hostedtoolcache/go/1.21.5/x64", JAVA_HOME_17_X64: "/usr/lib/jvm/temurin-17-jdk-amd64", ImageVersion: "20240107.1.0", RUNNER_OS: "Linux", GITHUB_API_URL: "https://api.github.com", SWIFT_PATH: "/usr/share/swift/usr/bin", RUNNER_USER: "runner", STATS_V3PS: "true", CHROMEWEBDRIVER: "/usr/local/share/chromedriver-linux64", JOURNAL_STREAM: "8:17159", GITHUB_WORKFLOW: "release", _: "/opt/hostedtoolcache/node/18.19.0/x64/bin/npx", npm_config_prefix: "/opt/hostedtoolcache/node/18.19.0/x64", npm_config_npm_version: "10.2.3", ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE: "/opt/actionarchivecache", GITHUB_RUN_ID: "7493474777", npm_config_cache: "/home/runner/.npm", GITHUB_REF_TYPE: "branch", BOOTSTRAP_HASKELL_NONINTERACTIVE: "1", GITHUB_WORKFLOW_SHA: "b51aed5f473d8899277db2413a431150934793bc", GITHUB_BASE_REF: "", ImageOS: "ubuntu22", GITHUB_WORKFLOW_REF: "storyblok/storyblok-js-client/.github/workflows/release.yml@refs/heads/main", PERFLOG_LOCATION_SETTING: "RUNNER_PERFLOG", GITHUB_ACTION_REPOSITORY: "", npm_config_node_gyp: "/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", PATH: "/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/bin:/home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/.bin:/home/runner/work/storyblok-js-client/storyblok-js-client/node_modules/.bin:/home/runner/work/storyblok-js-client/node_modules/.bin:/home/runner/work/node_modules/.bin:/home/runner/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/opt/hostedtoolcache/node/18.19.0/x64/bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin", ANT_HOME: "/usr/share/ant", DOTNET_MULTILEVEL_LOOKUP: "0", RUNNER_TRACKING_ID: "github_bcef4b2d-d4af-4ca4-91ab-56a4509bf353", INVOCATION_ID: "6c9f22e5fd0d4fc98bc67fbac8a9476c", RUNNER_TOOL_CACHE: "/opt/hostedtoolcache", GOROOT_1_19_X64: "/opt/hostedtoolcache/go/1.19.13/x64", NODE: "/opt/hostedtoolcache/node/18.19.0/x64/bin/node", npm_package_name: "storyblok-js-client", GITHUB_ACTION: "__run_2", GITHUB_RUN_NUMBER: "16", GITHUB_TRIGGERING_ACTOR: "thiagosaife", RUNNER_ARCH: "X64", XDG_RUNTIME_DIR: "/run/user/1001", AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache", LANG: "C.UTF-8", VCPKG_INSTALLATION_ROOT: "/usr/local/share/vcpkg", CONDA: "/usr/share/miniconda", RUNNER_NAME: "GitHub Actions 3", XDG_CONFIG_HOME: "/home/runner/.config", STATS_VMD: "true", GITHUB_REF_NAME: "main", GITHUB_REPOSITORY: "storyblok/storyblok-js-client", npm_lifecycle_script: "node vite.build.mjs && tsc", STATS_UE: "true", ANDROID_NDK_ROOT: "/usr/local/lib/android/sdk/ndk/25.2.9519653", GITHUB_ACTION_REF: "", DEBIAN_FRONTEND: "noninteractive", GITHUB_REPOSITORY_ID: "116555786", GITHUB_ACTIONS: "true", npm_package_version: "6.5.0", npm_lifecycle_event: "build", GIT_TERMINAL_PROMPT: "0", GITHUB_REF_PROTECTED: "true", GITHUB_WORKSPACE: "/home/runner/work/storyblok-js-client/storyblok-js-client", ACCEPT_EULA: "Y", GITHUB_JOB: "release", RUNNER_PERFLOG: "/home/runner/perflog", GITHUB_SHA: "b51aed5f473d8899277db2413a431150934793bc", GITHUB_RUN_ATTEMPT: "3", GITHUB_REF: "refs/heads/main", GITHUB_ACTOR: "thiagosaife", ANDROID_SDK_ROOT: "/usr/local/lib/android/sdk", LEIN_HOME: "/usr/local/lib/lein", npm_config_globalconfig: "/opt/hostedtoolcache/node/18.19.0/x64/etc/npmrc", npm_config_init_module: "/home/runner/.npm-init.js", GIT_COMMITTER_EMAIL: "semantic-release-bot@martynus.net", GITHUB_PATH: "/home/runner/work/_temp/_runner_file_commands/add_path_0680fa51-273e-4603-9ba8-00c19d52aa53", JAVA_HOME: "/usr/lib/jvm/temurin-11-jdk-amd64", PWD: "/home/runner/work/storyblok-js-client/storyblok-js-client", GITHUB_ACTOR_ID: "10601682", RUNNER_WORKSPACE: "/home/runner/work/storyblok-js-client", npm_execpath: "/opt/hostedtoolcache/node/18.19.0/x64/lib/node_modules/npm/bin/npm-cli.js", HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: "3650", STATS_TIS: "mining", GITHUB_EVENT_NAME: "push", HOMEBREW_NO_AUTO_UPDATE: "1", ANDROID_HOME: "/usr/local/lib/android/sdk", GITHUB_SERVER_URL: "https://github.com", GECKOWEBDRIVER: "/usr/local/share/gecko_driver", LEIN_JAR: "/usr/local/lib/lein/self-installs/leiningen-2.10.0-standalone.jar", GHCUP_INSTALL_BASE_PREFIX: "/usr/local", GITHUB_OUTPUT: "/home/runner/work/_temp/_runner_file_commands/set_output_0680fa51-273e-4603-9ba8-00c19d52aa53", npm_config_global_prefix: "/opt/hostedtoolcache/node/18.19.0/x64", EDGEWEBDRIVER: "/usr/local/share/edge_driver", STATS_EXT: "true", npm_command: "run-script", ANDROID_NDK: "/usr/local/lib/android/sdk/ndk/25.2.9519653", SGX_AESM_ADDR: "1", CHROME_BIN: "/usr/bin/google-chrome", SELENIUM_JAR_PATH: "/usr/share/java/selenium-server.jar", STATS_EXTP: "https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.154/provjobd.data", ANDROID_NDK_HOME: "/usr/local/lib/android/sdk/ndk/25.2.9519653", GITHUB_STEP_SUMMARY: "/home/runner/work/_temp/_runner_file_commands/step_summary_0680fa51-273e-4603-9ba8-00c19d52aa53", INIT_CWD: "/home/runner/work/storyblok-js-client/storyblok-js-client", EDITOR: "vi", NODE_ENV: "production" };
508
+ const A = "SB-Agent", R = {
503
509
  defaultAgentName: "SB-JS-CLIENT",
504
510
  defaultAgentVersion: "SB-Agent-Version",
505
511
  packageVersion: ce.npm_package_version
506
512
  };
507
513
  let f = {};
508
- const m = {};
514
+ const g = {};
509
515
  class he {
510
516
  /**
511
517
  *
@@ -515,23 +521,21 @@ class he {
515
521
  constructor(e, t) {
516
522
  h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), h(this, "stringifiedStoriesCache");
517
523
  let s = e.endpoint || t;
518
- if (!s) {
519
- const n = new y().getRegionURL, c = e.https === !1 ? "http" : "https";
520
- e.oauthToken ? s = `${c}://${n(e.region)}/v1` : s = `${c}://${n(e.region)}/v2`;
521
- }
522
- const r = new Headers();
523
- if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
524
- for (const n in e.headers)
525
- r.set(n, e.headers[n]);
526
- r.has($) || (r.set($, k.defaultAgentName), r.set(
527
- k.defaultAgentVersion,
528
- k.packageVersion
524
+ const r = new b().getRegionURL, o = e.https === !1 ? "http" : "https";
525
+ e.oauthToken ? s = `${o}://${r(e.region)}/v1` : s = `${o}://${r(e.region)}/v2`;
526
+ const n = new Headers();
527
+ if (n.set("Content-Type", "application/json"), n.set("Accept", "application/json"), e.headers)
528
+ for (const a in e.headers)
529
+ n.set(a, e.headers[a]);
530
+ n.has(A) || (n.set(A, R.defaultAgentName), n.set(
531
+ R.defaultAgentVersion,
532
+ R.packageVersion
529
533
  ));
530
- let i = 5;
531
- e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), e.richTextSchema ? this.richTextResolver = new b(e.richTextSchema) : this.richTextResolver = new b(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = O(this.throttledRequest, i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new y(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new le({
534
+ let l = 5;
535
+ e.oauthToken && (n.set("Authorization", e.oauthToken), l = 3), e.rateLimit && (l = e.rateLimit), e.richTextSchema ? this.richTextResolver = new T(e.richTextSchema) : this.richTextResolver = new T(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = H(this.throttledRequest, l, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new le({
532
536
  baseURL: s,
533
537
  timeout: e.timeout || 0,
534
- headers: r,
538
+ headers: n,
535
539
  responseInterceptor: e.responseInterceptor,
536
540
  fetch: e.fetch
537
541
  });
@@ -547,50 +551,52 @@ class he {
547
551
  });
548
552
  }
549
553
  parseParams(e) {
550
- return e.token || (e.token = this.getToken()), e.cv || (e.cv = m[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
554
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = g[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
551
555
  }
552
556
  factoryParamOptions(e, t) {
553
557
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
554
558
  }
555
559
  makeRequest(e, t, s, r) {
556
- const i = this.factoryParamOptions(
560
+ const o = this.factoryParamOptions(
557
561
  e,
558
562
  this.helpers.getOptionsPage(t, s, r)
559
563
  );
560
- return this.cacheResponse(e, i);
564
+ return this.cacheResponse(e, o);
561
565
  }
562
- get(e, t) {
566
+ get(e, t, s) {
563
567
  t || (t = {});
564
- const s = `/${e}`, r = this.factoryParamOptions(s, t);
565
- return this.cacheResponse(s, r);
566
- }
567
- async getAll(e, t, s) {
568
- const r = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, n = i.split("/"), c = s || n[n.length - 1], a = 1, l = await this.makeRequest(i, t, r, a), u = l.total ? Math.ceil(l.total / r) : 1, p = await this.helpers.asyncMap(
569
- this.helpers.range(a, u),
570
- (g) => this.makeRequest(i, t, r, g + 1)
568
+ const r = `/${e}`, o = this.factoryParamOptions(r, t);
569
+ return this.client.setFetchOptions(s), this.cacheResponse(r, o);
570
+ }
571
+ async getAll(e, t, s, r) {
572
+ const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, l = n.split("/"), a = s || l[l.length - 1], c = 1, u = await this.makeRequest(n, t, o, c), d = u.total ? Math.ceil(u.total / o) : 1;
573
+ this.client.setFetchOptions(r);
574
+ const m = await this.helpers.asyncMap(
575
+ this.helpers.range(c, d),
576
+ (_) => this.makeRequest(n, t, o, _ + 1)
571
577
  );
572
578
  return this.helpers.flatMap(
573
- [l, ...p],
574
- (g) => Object.values(g.data[c])
579
+ [u, ...m],
580
+ (_) => Object.values(_.data[a])
575
581
  );
576
582
  }
577
- post(e, t) {
578
- const s = `/${e}`;
579
- return Promise.resolve(this.throttle("post", s, t));
583
+ post(e, t, s) {
584
+ const r = `/${e}`;
585
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, t));
580
586
  }
581
- put(e, t) {
582
- const s = `/${e}`;
583
- return Promise.resolve(this.throttle("put", s, t));
587
+ put(e, t, s) {
588
+ const r = `/${e}`;
589
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, t));
584
590
  }
585
- delete(e, t) {
586
- const s = `/${e}`;
587
- return Promise.resolve(this.throttle("delete", s, t));
591
+ delete(e, t, s) {
592
+ const r = `/${e}`;
593
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, t));
588
594
  }
589
- getStories(e) {
590
- return this.get("cdn/stories", e);
595
+ getStories(e, t) {
596
+ return this.client.setFetchOptions(t), this.get("cdn/stories", e);
591
597
  }
592
- getStory(e, t) {
593
- return this.get(`cdn/stories/${e}`, t);
598
+ getStory(e, t, s) {
599
+ return this.client.setFetchOptions(s), this.get(`cdn/stories/${e}`, t);
594
600
  }
595
601
  getToken() {
596
602
  return this.accessToken;
@@ -617,28 +623,28 @@ class he {
617
623
  )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
618
624
  }
619
625
  _insertRelations(e, t, s, r) {
620
- s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((i) => this.getStoryReference(r, i)).filter(Boolean)));
626
+ s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((o) => this.getStoryReference(r, o)).filter(Boolean)));
621
627
  }
622
628
  iterateTree(e, t, s) {
623
- const r = (i) => {
624
- if (i != null) {
625
- if (i.constructor === Array)
626
- for (let n = 0; n < i.length; n++)
627
- r(i[n]);
628
- else if (i.constructor === Object) {
629
- if (i._stopResolving)
629
+ const r = (o) => {
630
+ if (o != null) {
631
+ if (o.constructor === Array)
632
+ for (let n = 0; n < o.length; n++)
633
+ r(o[n]);
634
+ else if (o.constructor === Object) {
635
+ if (o._stopResolving)
630
636
  return;
631
- for (const n in i)
632
- (i.component && i._uid || i.type === "link") && (this._insertRelations(
633
- i,
637
+ for (const n in o)
638
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(
639
+ o,
634
640
  n,
635
641
  t,
636
642
  s
637
643
  ), this._insertLinks(
638
- i,
644
+ o,
639
645
  n,
640
646
  s
641
- )), r(i[n]);
647
+ )), r(o[n]);
642
648
  }
643
649
  }
644
650
  };
@@ -647,27 +653,27 @@ class he {
647
653
  async resolveLinks(e, t, s) {
648
654
  let r = [];
649
655
  if (e.link_uuids) {
650
- const i = e.link_uuids.length, n = [], c = 50;
651
- for (let a = 0; a < i; a += c) {
652
- const l = Math.min(i, a + c);
653
- n.push(e.link_uuids.slice(a, l));
656
+ const o = e.link_uuids.length, n = [], l = 50;
657
+ for (let a = 0; a < o; a += l) {
658
+ const c = Math.min(o, a + l);
659
+ n.push(e.link_uuids.slice(a, c));
654
660
  }
655
661
  for (let a = 0; a < n.length; a++)
656
662
  (await this.getStories({
657
- per_page: c,
663
+ per_page: l,
658
664
  language: t.language,
659
665
  version: t.version,
660
666
  by_uuids: n[a].join(",")
661
667
  })).data.stories.forEach(
662
- (l) => {
663
- r.push(l);
668
+ (c) => {
669
+ r.push(c);
664
670
  }
665
671
  );
666
672
  } else
667
673
  r = e.links;
668
- r.forEach((i) => {
669
- this.links[s][i.uuid] = {
670
- ...i,
674
+ r.forEach((o) => {
675
+ this.links[s][o.uuid] = {
676
+ ...o,
671
677
  _stopResolving: !0
672
678
  };
673
679
  });
@@ -675,71 +681,80 @@ class he {
675
681
  async resolveRelations(e, t, s) {
676
682
  let r = [];
677
683
  if (e.rel_uuids) {
678
- const i = e.rel_uuids.length, n = [], c = 50;
679
- for (let a = 0; a < i; a += c) {
680
- const l = Math.min(i, a + c);
681
- n.push(e.rel_uuids.slice(a, l));
684
+ const o = e.rel_uuids.length, n = [], l = 50;
685
+ for (let a = 0; a < o; a += l) {
686
+ const c = Math.min(o, a + l);
687
+ n.push(e.rel_uuids.slice(a, c));
682
688
  }
683
689
  for (let a = 0; a < n.length; a++)
684
690
  (await this.getStories({
685
- per_page: c,
691
+ per_page: l,
686
692
  language: t.language,
687
693
  version: t.version,
688
694
  by_uuids: n[a].join(","),
689
695
  excluding_fields: t.excluding_fields
690
- })).data.stories.forEach((l) => {
691
- r.push(l);
696
+ })).data.stories.forEach((c) => {
697
+ r.push(c);
692
698
  });
693
699
  } else
694
700
  r = e.rels;
695
- r && r.length > 0 && r.forEach((i) => {
696
- this.relations[s][i.uuid] = {
697
- ...i,
701
+ r && r.length > 0 && r.forEach((o) => {
702
+ this.relations[s][o.uuid] = {
703
+ ...o,
698
704
  _stopResolving: !0
699
705
  };
700
706
  });
701
707
  }
708
+ /**
709
+ *
710
+ * @param responseData
711
+ * @param params
712
+ * @param resolveId
713
+ * @description Resolves the relations and links of the stories
714
+ * @returns Promise<void>
715
+ *
716
+ */
702
717
  async resolveStories(e, t, s) {
703
- var r, i;
718
+ var r, o;
704
719
  let n = [];
705
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
706
- for (const c in this.relations[s])
720
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
721
+ for (const l in this.relations[s])
707
722
  this.iterateTree(
708
- this.relations[s][c],
723
+ this.relations[s][l],
709
724
  n,
710
725
  s
711
726
  );
712
- e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
713
- this.iterateTree(c, n, s);
727
+ e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((l) => {
728
+ this.iterateTree(l, n, s);
714
729
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
715
730
  }
716
731
  async cacheResponse(e, t, s) {
717
732
  (typeof s > "u" || !s) && (s = 0);
718
- const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
733
+ const r = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
719
734
  if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
720
- const n = await i.get(r);
735
+ const n = await o.get(r);
721
736
  if (n)
722
737
  return Promise.resolve(n);
723
738
  }
724
- return new Promise(async (n, c) => {
739
+ return new Promise(async (n, l) => {
725
740
  var a;
726
741
  try {
727
- const l = await this.throttle("get", e, t);
728
- if (l.status !== 200)
729
- return c(l);
730
- let u = { data: l.data, headers: l.headers };
731
- if ((a = l.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
732
- perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
733
- total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
742
+ const c = await this.throttle("get", e, t);
743
+ if (c.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
744
+ return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(l);
745
+ if (c.status !== 200)
746
+ return l(c);
747
+ let u = { data: c.data, headers: c.headers };
748
+ if ((a = c.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
749
+ perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0,
750
+ total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
734
751
  })), u.data.story || u.data.stories) {
735
- const p = this.resolveCounter = ++this.resolveCounter % 1e3;
736
- await this.resolveStories(u.data, t, `${p}`);
752
+ const d = this.resolveCounter = ++this.resolveCounter % 1e3;
753
+ await this.resolveStories(u.data, t, `${d}`);
737
754
  }
738
- return t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && t.token && (t.version === "draft" && m[t.token] != u.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : u.data.cv), n(u);
739
- } catch (l) {
740
- if (l.response && l.response.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
741
- return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(c);
742
- c(l);
755
+ return t.version === "published" && e != "/cdn/spaces/me" && await o.set(r, u), u.data.cv && t.token && (t.version === "draft" && g[t.token] != u.data.cv && await this.flushCache(), g[t.token] = t.cv ? t.cv : u.data.cv), n(u);
756
+ } catch (c) {
757
+ l(c);
743
758
  }
744
759
  });
745
760
  }
@@ -747,10 +762,13 @@ class he {
747
762
  return this.client[e](t, s);
748
763
  }
749
764
  cacheVersions() {
750
- return m;
765
+ return g;
751
766
  }
752
767
  cacheVersion() {
753
- return m[this.accessToken];
768
+ return g[this.accessToken];
769
+ }
770
+ setCacheVersion(e) {
771
+ this.accessToken && (g[this.accessToken] = e);
754
772
  }
755
773
  cacheProvider() {
756
774
  switch (this.cache.type) {
@@ -793,8 +811,8 @@ class he {
793
811
  return await this.cacheProvider().flush(), this;
794
812
  }
795
813
  }
796
- const pe = (o = {}) => {
797
- const { apiOptions: e } = o;
814
+ const de = (i = {}) => {
815
+ const { apiOptions: e } = i;
798
816
  if (!e.accessToken) {
799
817
  console.error(
800
818
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
@@ -802,12 +820,12 @@ const pe = (o = {}) => {
802
820
  return;
803
821
  }
804
822
  return { storyblokApi: new he(e) };
805
- }, de = (o) => {
806
- if (typeof o != "object" || typeof o._editable > "u")
823
+ }, pe = (i) => {
824
+ if (typeof i != "object" || typeof i._editable > "u")
807
825
  return {};
808
826
  try {
809
827
  const e = JSON.parse(
810
- o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
828
+ i._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
811
829
  );
812
830
  return e ? {
813
831
  "data-blok-c": JSON.stringify(e),
@@ -817,43 +835,43 @@ const pe = (o = {}) => {
817
835
  return {};
818
836
  }
819
837
  };
820
- let R, w = "https://app.storyblok.com/f/storyblok-v2-latest.js";
821
- const ge = (o, e, t = {}) => {
838
+ let k, E = "https://app.storyblok.com/f/storyblok-v2-latest.js";
839
+ const me = (i, e, t = {}) => {
822
840
  var s;
823
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
841
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
824
842
  "_storyblok"
825
- ) === o;
826
- if (!(!r || !i)) {
827
- if (!o) {
843
+ ) === i;
844
+ if (!(!r || !o)) {
845
+ if (!i) {
828
846
  console.warn("Story ID is not defined. Please provide a valid ID.");
829
847
  return;
830
848
  }
831
849
  window.storyblokRegisterEvent(() => {
832
850
  new window.StoryblokBridge(t).on(["input", "published", "change"], (n) => {
833
- n.action === "input" && n.story.id === o ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === o && window.location.reload();
851
+ n.action === "input" && n.story.id === i ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === i && window.location.reload();
834
852
  });
835
853
  });
836
854
  }
837
- }, me = (o = {}) => {
855
+ }, _e = (i = {}) => {
838
856
  var e, t;
839
857
  const {
840
858
  bridge: s,
841
859
  accessToken: r,
842
- use: i = [],
860
+ use: o = [],
843
861
  apiOptions: n = {},
844
- richText: c = {},
862
+ richText: l = {},
845
863
  bridgeUrl: a
846
- } = o;
864
+ } = i;
847
865
  n.accessToken = n.accessToken || r;
848
- const l = { bridge: s, apiOptions: n };
866
+ const c = { bridge: s, apiOptions: n };
849
867
  let u = {};
850
- i.forEach((g) => {
851
- u = { ...u, ...g(l) };
852
- }), a && (w = a);
853
- const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
854
- return s !== !1 && p && C(w), R = new b(c.schema), c.resolver && j(R, c.resolver), u;
855
- }, j = (o, e) => {
856
- o.addNode("blok", (t) => {
868
+ o.forEach((m) => {
869
+ u = { ...u, ...m(c) };
870
+ }), a && (E = a);
871
+ const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
872
+ return s !== !1 && d && w(E), k = new T(l.schema), l.resolver && S(k, l.resolver), u;
873
+ }, S = (i, e) => {
874
+ i.addNode("blok", (t) => {
857
875
  let s = "";
858
876
  return t.attrs.body.forEach((r) => {
859
877
  s += e(r.component, r);
@@ -861,25 +879,25 @@ const ge = (o, e, t = {}) => {
861
879
  html: s
862
880
  };
863
881
  });
864
- }, ue = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), fe = (o, e, t) => {
865
- let s = t || R;
882
+ }, ue = (i) => !i || !(i != null && i.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ge = (i, e, t) => {
883
+ let s = t || k;
866
884
  if (!s) {
867
885
  console.error(
868
886
  "Please initialize the Storyblok SDK before calling the renderRichText function"
869
887
  );
870
888
  return;
871
889
  }
872
- return ue(o) ? "" : (e && (s = new b(e.schema), e.resolver && j(s, e.resolver)), s.render(o));
873
- }, ye = () => C(w);
890
+ return ue(i) ? "" : (e && (s = new T(e.schema), e.resolver && S(s, e.resolver)), s.render(i));
891
+ }, fe = () => w(E);
874
892
  export {
875
- b as RichTextResolver,
876
- oe as RichTextSchema,
877
- pe as apiPlugin,
893
+ T as RichTextResolver,
894
+ ie as RichTextSchema,
895
+ de as apiPlugin,
878
896
  ue as isRichTextEmpty,
879
- ye as loadStoryblokBridge,
880
- ge as registerStoryblokBridge,
881
- fe as renderRichText,
882
- de as storyblokEditable,
883
- me as storyblokInit,
884
- ge as useStoryblokBridge
897
+ fe as loadStoryblokBridge,
898
+ me as registerStoryblokBridge,
899
+ ge as renderRichText,
900
+ pe as storyblokEditable,
901
+ _e as storyblokInit,
902
+ me as useStoryblokBridge
885
903
  };