@storyblok/react 3.0.13 → 3.0.15

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.
@@ -9,24 +9,24 @@ const j = [], O = (n) => new Promise((e, t) => {
9
9
  }, document.getElementById("storyblok-javascript-bridge"))) return;
10
10
  const s = document.createElement("script");
11
11
  s.async = !0, s.src = n, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
12
- j.forEach((i) => i()), _ = !0, e(r);
12
+ j.forEach((o) => o()), _ = !0, e(r);
13
13
  }, document.getElementsByTagName("head")[0].appendChild(s);
14
14
  });
15
- var E = Object.defineProperty, I = (n, e, t) => e in n ? E(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, c = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
15
+ var P = Object.defineProperty, C = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, c = (n, e, t) => C(n, typeof e != "symbol" ? e + "" : e, t);
16
16
  function x(n) {
17
17
  return !(n !== n || n === 1 / 0 || n === -1 / 0);
18
18
  }
19
- function C(n, e, t) {
19
+ function I(n, e, t) {
20
20
  if (!x(e))
21
21
  throw new TypeError("Expected `limit` to be a finite number");
22
22
  if (!x(t))
23
23
  throw new TypeError("Expected `interval` to be a finite number");
24
24
  const s = [];
25
- let r = [], i = 0;
26
- const o = function() {
27
- i++;
25
+ let r = [], o = 0;
26
+ const i = function() {
27
+ o++;
28
28
  const a = setTimeout(function() {
29
- i--, s.length > 0 && o(), r = r.filter(function(h) {
29
+ o--, s.length > 0 && i(), r = r.filter(function(h) {
30
30
  return h !== a;
31
31
  });
32
32
  }, t);
@@ -35,13 +35,13 @@ function C(n, e, t) {
35
35
  u.resolve(n.apply(u.self, u.args));
36
36
  }, l = function(...a) {
37
37
  const u = this;
38
- return new Promise(function(h, p) {
38
+ return new Promise(function(h, d) {
39
39
  s.push({
40
40
  resolve: h,
41
- reject: p,
41
+ reject: d,
42
42
  args: a,
43
43
  self: u
44
- }), i < e && o();
44
+ }), o < e && i();
45
45
  });
46
46
  };
47
47
  return l.abort = function() {
@@ -60,7 +60,7 @@ class b {
60
60
  page: s
61
61
  })), c(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), c(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), c(this, "range", (e = 0, t = e) => {
62
62
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
63
- return this.arrayFrom(s, (i, o) => o * r + e);
63
+ return this.arrayFrom(s, (o, i) => i * r + e);
64
64
  }), c(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), c(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), c(this, "escapeHTML", function(e) {
65
65
  const t = {
66
66
  "&": "&amp;",
@@ -69,7 +69,7 @@ class b {
69
69
  '"': "&quot;",
70
70
  "'": "&#39;"
71
71
  }, s = /[&<>"']/g, r = RegExp(s.source);
72
- return e && r.test(e) ? e.replace(s, (i) => t[i]) : e;
72
+ return e && r.test(e) ? e.replace(s, (o) => t[o]) : e;
73
73
  });
74
74
  }
75
75
  /**
@@ -81,16 +81,16 @@ class b {
81
81
  */
82
82
  stringify(e, t, s) {
83
83
  const r = [];
84
- for (const i in e) {
85
- if (!Object.prototype.hasOwnProperty.call(e, i))
84
+ for (const o in e) {
85
+ if (!Object.prototype.hasOwnProperty.call(e, o))
86
86
  continue;
87
- const o = e[i], l = s ? "" : encodeURIComponent(i);
87
+ const i = e[o], l = s ? "" : encodeURIComponent(o);
88
88
  let a;
89
- typeof o == "object" ? a = this.stringify(
90
- o,
89
+ typeof i == "object" ? a = this.stringify(
90
+ i,
91
91
  t ? t + encodeURIComponent("[" + l + "]") : l,
92
- Array.isArray(o)
93
- ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(o), r.push(a);
92
+ Array.isArray(i)
93
+ ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
94
94
  }
95
95
  return r.join("&");
96
96
  }
@@ -100,16 +100,16 @@ class b {
100
100
  * @return {String} The base URL of the region
101
101
  */
102
102
  getRegionURL(e) {
103
- const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", i = "api-ap.storyblok.com", o = "api-ca.storyblok.com";
103
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", o = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
104
104
  switch (e) {
105
105
  case "us":
106
106
  return s;
107
107
  case "cn":
108
108
  return r;
109
109
  case "ap":
110
- return i;
111
- case "ca":
112
110
  return o;
111
+ case "ca":
112
+ return i;
113
113
  default:
114
114
  return t;
115
115
  }
@@ -126,7 +126,7 @@ const A = function(n, e) {
126
126
  singleTag: "hr"
127
127
  }), M = () => ({
128
128
  tag: "blockquote"
129
- }), z = () => ({
129
+ }), H = () => ({
130
130
  tag: "ul"
131
131
  }), U = (n) => ({
132
132
  tag: [
@@ -136,20 +136,20 @@ const A = function(n, e) {
136
136
  attrs: n.attrs
137
137
  }
138
138
  ]
139
- }), H = () => ({
139
+ }), z = () => ({
140
140
  singleTag: "br"
141
141
  }), q = (n) => ({
142
142
  tag: `h${n.attrs.level}`
143
- }), V = (n) => ({
143
+ }), B = (n) => ({
144
144
  singleTag: [
145
145
  {
146
146
  tag: "img",
147
147
  attrs: A(n.attrs, ["src", "alt", "title"])
148
148
  }
149
149
  ]
150
- }), B = () => ({
151
- tag: "li"
152
150
  }), D = () => ({
151
+ tag: "li"
152
+ }), V = () => ({
153
153
  tag: "ol"
154
154
  }), J = () => ({
155
155
  tag: "p"
@@ -170,13 +170,13 @@ const A = function(n, e) {
170
170
  tag: "s"
171
171
  }), K = () => ({
172
172
  tag: "u"
173
- }), G = () => ({
174
- tag: "strong"
175
173
  }), Q = () => ({
176
- tag: "code"
174
+ tag: "strong"
177
175
  }), X = () => ({
176
+ tag: "code"
177
+ }), Z = () => ({
178
178
  tag: "i"
179
- }), Z = (n) => {
179
+ }), G = (n) => {
180
180
  if (!n.attrs)
181
181
  return {
182
182
  tag: ""
@@ -213,7 +213,7 @@ const A = function(n, e) {
213
213
  attrs: n.attrs
214
214
  }
215
215
  ]
216
- }), ie = (n) => {
216
+ }), oe = (n) => {
217
217
  var e;
218
218
  return (e = n.attrs) != null && e.color ? {
219
219
  tag: [
@@ -227,7 +227,7 @@ const A = function(n, e) {
227
227
  } : {
228
228
  tag: ""
229
229
  };
230
- }, oe = (n) => {
230
+ }, ie = (n) => {
231
231
  var e;
232
232
  return (e = n.attrs) != null && e.color ? {
233
233
  tag: [
@@ -245,13 +245,13 @@ const A = function(n, e) {
245
245
  nodes: {
246
246
  horizontal_rule: L,
247
247
  blockquote: M,
248
- bullet_list: z,
248
+ bullet_list: H,
249
249
  code_block: U,
250
- hard_break: H,
250
+ hard_break: z,
251
251
  heading: q,
252
- image: V,
253
- list_item: B,
254
- ordered_list: D,
252
+ image: B,
253
+ list_item: D,
254
+ ordered_list: V,
255
255
  paragraph: J,
256
256
  emoji: F
257
257
  },
@@ -259,16 +259,16 @@ const A = function(n, e) {
259
259
  bold: W,
260
260
  strike: Y,
261
261
  underline: K,
262
- strong: G,
263
- code: Q,
264
- italic: X,
265
- link: Z,
262
+ strong: Q,
263
+ code: X,
264
+ italic: Z,
265
+ link: G,
266
266
  styled: ee,
267
267
  subscript: te,
268
268
  superscript: se,
269
269
  anchor: re,
270
- highlight: ie,
271
- textStyle: oe
270
+ highlight: oe,
271
+ textStyle: ie
272
272
  }
273
273
  }, ae = function(n) {
274
274
  const e = {
@@ -327,28 +327,28 @@ class le {
327
327
  ), "";
328
328
  }
329
329
  optimizeImages(e, t) {
330
- let s = 0, r = 0, i = "", o = "";
331
- 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 && (o += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (o += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (o += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (o += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (o += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (o += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (o += `:rotate(${t.filters.rotate})`), o.length > 0 && (o = "/filters" + o))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
332
- const l = s > 0 || r > 0 || o.length > 0 ? `${s}x${r}${o}` : "";
330
+ let s = 0, r = 0, o = "", i = "";
331
+ 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 && (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))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
332
+ const l = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
333
333
  return e = e.replace(
334
334
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
335
335
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
336
336
  ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
337
337
  var u, h;
338
- const p = a.match(
338
+ const d = a.match(
339
339
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
340
340
  );
341
- if (p && p.length > 0) {
341
+ if (d && d.length > 0) {
342
342
  const g = {
343
- srcset: (u = t.srcset) == null ? void 0 : u.map((d) => {
344
- if (typeof d == "number")
345
- return `//${p}/m/${d}x0${o} ${d}w`;
346
- if (typeof d == "object" && d.length === 2) {
343
+ srcset: (u = t.srcset) == null ? void 0 : u.map((p) => {
344
+ if (typeof p == "number")
345
+ return `//${d}/m/${p}x0${i} ${p}w`;
346
+ if (typeof p == "object" && p.length === 2) {
347
347
  let k = 0, $ = 0;
348
- return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && ($ = d[1]), `//${p}/m/${k}x${$}${o} ${k}w`;
348
+ return typeof p[0] == "number" && (k = p[0]), typeof p[1] == "number" && ($ = p[1]), `//${d}/m/${k}x${$}${i} ${k}w`;
349
349
  }
350
350
  }).join(", "),
351
- sizes: (h = t.sizes) == null ? void 0 : h.map((d) => d).join(", ")
351
+ sizes: (h = t.sizes) == null ? void 0 : h.map((p) => p).join(", ")
352
352
  };
353
353
  let f = "";
354
354
  return g.srcset && (f += `srcset="${g.srcset}" `), g.sizes && (f += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
@@ -359,15 +359,15 @@ class le {
359
359
  renderNode(e) {
360
360
  const t = [];
361
361
  e.marks && e.marks.forEach((r) => {
362
- const i = this.getMatchingMark(r);
363
- i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
362
+ const o = this.getMatchingMark(r);
363
+ o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
364
364
  });
365
365
  const s = this.getMatchingNode(e);
366
366
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
367
367
  t.push(this.renderNode(r));
368
368
  }) : 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) => {
369
- const i = this.getMatchingMark(r);
370
- i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
369
+ const o = this.getMatchingMark(r);
370
+ o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
371
371
  }), t.join("");
372
372
  }
373
373
  renderTag(e, t) {
@@ -377,10 +377,10 @@ class le {
377
377
  {
378
378
  let r = `<${s.tag}`;
379
379
  if (s.attrs) {
380
- for (const i in s.attrs)
381
- if (Object.prototype.hasOwnProperty.call(s.attrs, i)) {
382
- const o = s.attrs[i];
383
- o !== null && (r += ` ${i}="${o}"`);
380
+ for (const o in s.attrs)
381
+ if (Object.prototype.hasOwnProperty.call(s.attrs, o)) {
382
+ const i = s.attrs[o];
383
+ i !== null && (r += ` ${o}="${i}"`);
384
384
  }
385
385
  }
386
386
  return `${r}${t}>`;
@@ -466,15 +466,15 @@ class ce {
466
466
  )}`;
467
467
  } else
468
468
  s = JSON.stringify(this.parameters);
469
- const r = new URL(t), i = new AbortController(), { signal: o } = i;
469
+ const r = new URL(t), o = new AbortController(), { signal: i } = o;
470
470
  let l;
471
- this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
471
+ this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
472
472
  try {
473
473
  const a = await this.fetch(`${r}`, {
474
474
  method: e,
475
475
  headers: this.headers,
476
476
  body: s,
477
- signal: o,
477
+ signal: i,
478
478
  ...this.fetchOptions
479
479
  });
480
480
  this.timeout && clearTimeout(l);
@@ -499,12 +499,12 @@ class ce {
499
499
  return new Promise((s, r) => {
500
500
  if (t.test(`${e.status}`))
501
501
  return s(e);
502
- const i = {
502
+ const o = {
503
503
  message: e.statusText,
504
504
  status: e.status,
505
505
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
506
506
  };
507
- r(i);
507
+ r(o);
508
508
  });
509
509
  }
510
510
  }
@@ -525,18 +525,18 @@ class ue {
525
525
  c(this, "client"), c(this, "maxRetries"), c(this, "retriesDelay"), c(this, "throttle"), c(this, "accessToken"), c(this, "cache"), c(this, "helpers"), c(this, "resolveCounter"), c(this, "relations"), c(this, "links"), c(this, "richTextResolver"), c(this, "resolveNestedRelations"), c(this, "stringifiedStoriesCache");
526
526
  let s = e.endpoint || t;
527
527
  if (!s) {
528
- const o = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
529
- e.oauthToken ? s = `${l}://${o(e.region)}/v1` : s = `${l}://${o(e.region)}/v2`;
528
+ const i = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
529
+ e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
530
530
  }
531
531
  const r = new Headers();
532
- r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && e.headers.entries().toArray().forEach(([o, l]) => {
533
- r.set(o, l);
532
+ r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
533
+ r.set(i, l);
534
534
  }), r.has(S) || (r.set(S, w.defaultAgentName), r.set(
535
535
  w.defaultAgentVersion,
536
536
  w.packageVersion
537
537
  ));
538
- let i = 5;
539
- e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), e.richTextSchema ? this.richTextResolver = new v(e.richTextSchema) : this.richTextResolver = new v(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = C(this.throttledRequest, i, 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 he({
538
+ let o = 5;
539
+ e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new v(e.richTextSchema) : this.richTextResolver = new v(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = I(this.throttledRequest, o, 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 he({
540
540
  baseURL: s,
541
541
  timeout: e.timeout || 0,
542
542
  headers: r,
@@ -560,28 +560,28 @@ class ue {
560
560
  factoryParamOptions(e, t) {
561
561
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
562
562
  }
563
- makeRequest(e, t, s, r, i) {
564
- const o = this.factoryParamOptions(
563
+ makeRequest(e, t, s, r, o) {
564
+ const i = this.factoryParamOptions(
565
565
  e,
566
566
  this.helpers.getOptionsPage(t, s, r)
567
567
  );
568
- return this.cacheResponse(e, o, void 0, i);
568
+ return this.cacheResponse(e, i, void 0, o);
569
569
  }
570
570
  get(e, t, s) {
571
571
  t || (t = {});
572
- const r = `/${e}`, i = this.factoryParamOptions(r, t);
573
- return this.cacheResponse(r, i, void 0, s);
572
+ const r = `/${e}`, o = this.factoryParamOptions(r, t);
573
+ return this.cacheResponse(r, o, void 0, s);
574
574
  }
575
575
  async getAll(e, t, s, r) {
576
- const i = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`, l = o.split("/"), a = s || l[l.length - 1], u = 1, h = await this.makeRequest(
577
- o,
578
- t,
576
+ const o = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, l = i.split("/"), a = s || l[l.length - 1], u = 1, h = await this.makeRequest(
579
577
  i,
578
+ t,
579
+ o,
580
580
  u,
581
581
  r
582
- ), p = h.total ? Math.ceil(h.total / i) : 1, g = await this.helpers.asyncMap(
583
- this.helpers.range(u, p),
584
- (f) => this.makeRequest(o, t, i, f + 1, r)
582
+ ), d = h.total ? Math.ceil(h.total / o) : 1, g = await this.helpers.asyncMap(
583
+ this.helpers.range(u, d),
584
+ (f) => this.makeRequest(i, t, o, f + 1, r)
585
585
  );
586
586
  return this.helpers.flatMap(
587
587
  [h, ...g],
@@ -634,28 +634,28 @@ class ue {
634
634
  )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
635
635
  }
636
636
  _insertRelations(e, t, s, r) {
637
- 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)));
637
+ 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)));
638
638
  }
639
639
  iterateTree(e, t, s) {
640
- const r = (i) => {
641
- if (i != null) {
642
- if (i.constructor === Array)
643
- for (let o = 0; o < i.length; o++)
644
- r(i[o]);
645
- else if (i.constructor === Object) {
646
- if (i._stopResolving)
640
+ const r = (o) => {
641
+ if (o != null) {
642
+ if (o.constructor === Array)
643
+ for (let i = 0; i < o.length; i++)
644
+ r(o[i]);
645
+ else if (o.constructor === Object) {
646
+ if (o._stopResolving)
647
647
  return;
648
- for (const o in i)
649
- (i.component && i._uid || i.type === "link") && (this._insertRelations(
650
- i,
648
+ for (const i in o)
649
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(
651
650
  o,
651
+ i,
652
652
  t,
653
653
  s
654
654
  ), this._insertLinks(
655
- i,
656
655
  o,
656
+ i,
657
657
  s
658
- )), r(i[o]);
658
+ )), r(o[i]);
659
659
  }
660
660
  }
661
661
  };
@@ -664,17 +664,17 @@ class ue {
664
664
  async resolveLinks(e, t, s) {
665
665
  let r = [];
666
666
  if (e.link_uuids) {
667
- const i = e.link_uuids.length, o = [], l = 50;
668
- for (let a = 0; a < i; a += l) {
669
- const u = Math.min(i, a + l);
670
- o.push(e.link_uuids.slice(a, u));
667
+ const o = e.link_uuids.length, i = [], l = 50;
668
+ for (let a = 0; a < o; a += l) {
669
+ const u = Math.min(o, a + l);
670
+ i.push(e.link_uuids.slice(a, u));
671
671
  }
672
- for (let a = 0; a < o.length; a++)
672
+ for (let a = 0; a < i.length; a++)
673
673
  (await this.getStories({
674
674
  per_page: l,
675
675
  language: t.language,
676
676
  version: t.version,
677
- by_uuids: o[a].join(",")
677
+ by_uuids: i[a].join(",")
678
678
  })).data.stories.forEach(
679
679
  (u) => {
680
680
  r.push(u);
@@ -682,9 +682,9 @@ class ue {
682
682
  );
683
683
  } else
684
684
  r = e.links;
685
- r.forEach((i) => {
686
- this.links[s][i.uuid] = {
687
- ...i,
685
+ r.forEach((o) => {
686
+ this.links[s][o.uuid] = {
687
+ ...o,
688
688
  _stopResolving: !0
689
689
  };
690
690
  });
@@ -692,26 +692,26 @@ class ue {
692
692
  async resolveRelations(e, t, s) {
693
693
  let r = [];
694
694
  if (e.rel_uuids) {
695
- const i = e.rel_uuids.length, o = [], l = 50;
696
- for (let a = 0; a < i; a += l) {
697
- const u = Math.min(i, a + l);
698
- o.push(e.rel_uuids.slice(a, u));
695
+ const o = e.rel_uuids.length, i = [], l = 50;
696
+ for (let a = 0; a < o; a += l) {
697
+ const u = Math.min(o, a + l);
698
+ i.push(e.rel_uuids.slice(a, u));
699
699
  }
700
- for (let a = 0; a < o.length; a++)
700
+ for (let a = 0; a < i.length; a++)
701
701
  (await this.getStories({
702
702
  per_page: l,
703
703
  language: t.language,
704
704
  version: t.version,
705
- by_uuids: o[a].join(","),
705
+ by_uuids: i[a].join(","),
706
706
  excluding_fields: t.excluding_fields
707
707
  })).data.stories.forEach((u) => {
708
708
  r.push(u);
709
709
  });
710
710
  } else
711
711
  r = e.rels;
712
- r && r.length > 0 && r.forEach((i) => {
713
- this.relations[s][i.uuid] = {
714
- ...i,
712
+ r && r.length > 0 && r.forEach((o) => {
713
+ this.relations[s][o.uuid] = {
714
+ ...o,
715
715
  _stopResolving: !0
716
716
  };
717
717
  });
@@ -726,23 +726,23 @@ class ue {
726
726
  *
727
727
  */
728
728
  async resolveStories(e, t, s) {
729
- var r, i;
730
- let o = [];
731
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (o = 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)
729
+ var r, o;
730
+ let i = [];
731
+ 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 && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
732
732
  for (const l in this.relations[s])
733
733
  this.iterateTree(
734
734
  this.relations[s][l],
735
- o,
735
+ i,
736
736
  s
737
737
  );
738
- e.story ? this.iterateTree(e.story, o, s) : e.stories.forEach((l) => {
739
- this.iterateTree(l, o, s);
738
+ e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
739
+ this.iterateTree(l, i, s);
740
740
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
741
741
  }
742
742
  async cacheResponse(e, t, s, r) {
743
- const i = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
743
+ const o = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
744
744
  if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
745
- const l = await o.get(i);
745
+ const l = await i.get(o);
746
746
  if (l)
747
747
  return Promise.resolve(l);
748
748
  }
@@ -752,15 +752,15 @@ class ue {
752
752
  const h = await this.throttle("get", e, t, r);
753
753
  if (h.status !== 200)
754
754
  return a(h);
755
- let p = { data: h.data, headers: h.headers };
756
- if ((u = h.headers) != null && u["per-page"] && (p = Object.assign({}, p, {
755
+ let d = { data: h.data, headers: h.headers };
756
+ if ((u = h.headers) != null && u["per-page"] && (d = Object.assign({}, d, {
757
757
  perPage: h.headers["per-page"] ? parseInt(h.headers["per-page"]) : 0,
758
758
  total: h.headers["per-page"] ? parseInt(h.headers.total) : 0
759
- })), p.data.story || p.data.stories) {
759
+ })), d.data.story || d.data.stories) {
760
760
  const g = this.resolveCounter = ++this.resolveCounter % 1e3;
761
- await this.resolveStories(p.data, t, `${g}`);
761
+ await this.resolveStories(d.data, t, `${g}`);
762
762
  }
763
- return t.version === "published" && e != "/cdn/spaces/me" && await o.set(i, p), p.data.cv && t.token && (t.version === "draft" && m[t.token] != p.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : p.data.cv), l(p);
763
+ return t.version === "published" && e != "/cdn/spaces/me" && await i.set(o, d), d.data.cv && t.token && (t.version === "draft" && m[t.token] != d.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : d.data.cv), l(d);
764
764
  } catch (h) {
765
765
  if (h.response && h.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
766
766
  return console.log(
@@ -825,7 +825,7 @@ class ue {
825
825
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
826
826
  }
827
827
  }
828
- const de = (n = {}) => {
828
+ const pe = (n = {}) => {
829
829
  const { apiOptions: e } = n;
830
830
  if (!e.accessToken) {
831
831
  console.error(
@@ -852,17 +852,17 @@ const de = (n = {}) => {
852
852
  let R, T = "https://app.storyblok.com/f/storyblok-v2-latest.js";
853
853
  const fe = (n, e, t = {}) => {
854
854
  var s;
855
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
855
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
856
856
  "_storyblok"
857
857
  ) === n;
858
- if (!(!r || !i)) {
858
+ if (!(!r || !o)) {
859
859
  if (!n) {
860
860
  console.warn("Story ID is not defined. Please provide a valid ID.");
861
861
  return;
862
862
  }
863
863
  window.storyblokRegisterEvent(() => {
864
- new window.StoryblokBridge(t).on(["input", "published", "change"], (o) => {
865
- o.action === "input" && o.story.id === n ? e(o.story) : (o.action === "change" || o.action === "published") && o.storyId === n && window.location.reload();
864
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
865
+ i.action === "input" && i.story.id === n ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === n && window.location.reload();
866
866
  });
867
867
  });
868
868
  }
@@ -871,20 +871,20 @@ const fe = (n, e, t = {}) => {
871
871
  const {
872
872
  bridge: s,
873
873
  accessToken: r,
874
- use: i = [],
875
- apiOptions: o = {},
874
+ use: o = [],
875
+ apiOptions: i = {},
876
876
  richText: l = {},
877
877
  bridgeUrl: a
878
878
  } = n;
879
- o.accessToken = o.accessToken || r;
880
- const u = { bridge: s, apiOptions: o };
879
+ i.accessToken = i.accessToken || r;
880
+ const u = { bridge: s, apiOptions: i };
881
881
  let h = {};
882
- i.forEach((g) => {
882
+ o.forEach((g) => {
883
883
  h = { ...h, ...g(u) };
884
884
  }), a && (T = a);
885
- const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
886
- return s !== !1 && p && O(T), R = new v(l.schema), l.resolver && P(R, l.resolver), h;
887
- }, P = (n, e) => {
885
+ const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
886
+ return s !== !1 && d && O(T), R = new v(l.schema), l.resolver && E(R, l.resolver), h;
887
+ }, E = (n, e) => {
888
888
  n.addNode("blok", (t) => {
889
889
  let s = "";
890
890
  return t.attrs.body.forEach((r) => {
@@ -893,7 +893,7 @@ const fe = (n, e, t = {}) => {
893
893
  html: s
894
894
  };
895
895
  });
896
- }, pe = (n) => !n || !(n != null && n.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ye = (n, e, t) => {
896
+ }, de = (n) => !n || !(n != null && n.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ye = (n, e, t) => {
897
897
  let s = t || R;
898
898
  if (!s) {
899
899
  console.error(
@@ -901,13 +901,13 @@ const fe = (n, e, t = {}) => {
901
901
  );
902
902
  return;
903
903
  }
904
- return pe(n) ? "" : (e && (s = new v(e.schema), e.resolver && P(s, e.resolver)), s.render(n));
904
+ return de(n) ? "" : (e && (s = new v(e.schema), e.resolver && E(s, e.resolver)), s.render(n));
905
905
  }, be = () => O(T);
906
906
  export {
907
907
  v as RichTextResolver,
908
908
  ne as RichTextSchema,
909
- de as apiPlugin,
910
- pe as isRichTextEmpty,
909
+ pe as apiPlugin,
910
+ de as isRichTextEmpty,
911
911
  be as loadStoryblokBridge,
912
912
  fe as registerStoryblokBridge,
913
913
  ye as renderRichText,
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { StoryblokBridgeConfigV2 } from "./types";
1
+ import React from 'react';
2
+ import type { StoryblokBridgeConfigV2 } from './types';
3
3
  interface StoryblokBridgeLoaderProps {
4
4
  options: StoryblokBridgeConfigV2;
5
5
  [key: string]: unknown;
@@ -1,2 +1,2 @@
1
- import type { TUseStoryblokState } from "../types";
1
+ import type { TUseStoryblokState } from '../types';
2
2
  export declare const useStoryblokState: TUseStoryblokState;