@storyblok/svelte 2.3.8 → 2.4.1

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,167 +1,161 @@
1
- import st from "axios";
2
- var ot = Object.defineProperty, it = Object.defineProperties, at = Object.getOwnPropertyDescriptors, B = Object.getOwnPropertySymbols, lt = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, z = (r, t, e) => t in r ? ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
3
- for (var e in t || (t = {}))
4
- lt.call(t, e) && z(r, e, t[e]);
5
- if (B)
6
- for (var e of B(t))
7
- ct.call(t, e) && z(r, e, t[e]);
8
- return r;
9
- }, T = (r, t) => it(r, at(t));
10
- let D = !1;
11
- const U = [], ut = (r) => new Promise((t, e) => {
12
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
1
+ let U = !1;
2
+ const H = [], tt = (s) => new Promise((t, e) => {
3
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
13
4
  if (window.location === window.parent.location) {
14
5
  console.warn("You are not in Draft Mode or in the Visual Editor.");
15
6
  return;
16
7
  }
17
- D ? s() : U.push(s);
8
+ U ? n() : H.push(n);
18
9
  }, document.getElementById("storyblok-javascript-bridge")))
19
10
  return;
20
- const n = document.createElement("script");
21
- n.async = !0, n.src = r, n.id = "storyblok-javascript-bridge", n.onerror = (s) => e(s), n.onload = (s) => {
22
- U.forEach((o) => o()), D = !0, t(s);
23
- }, document.getElementsByTagName("head")[0].appendChild(n);
24
- }), ht = function(r, t) {
25
- if (!r)
26
- return null;
27
- let e = {};
28
- for (let n in r) {
29
- let s = r[n];
30
- t.indexOf(n) > -1 && s !== null && (e[n] = s);
11
+ const r = document.createElement("script");
12
+ r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (n) => e(n), r.onload = (n) => {
13
+ H.forEach((o) => o()), U = !0, t(n);
14
+ }, document.getElementsByTagName("head")[0].appendChild(r);
15
+ });
16
+ var et = Object.defineProperty, st = (s, t, e) => t in s ? et(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, h = (s, t, e) => (st(s, typeof t != "symbol" ? t + "" : t, e), e);
17
+ function q(s) {
18
+ return !(s !== s || s === 1 / 0 || s === -1 / 0);
19
+ }
20
+ function rt(s, t, e) {
21
+ if (!q(t))
22
+ throw new TypeError("Expected `limit` to be a finite number");
23
+ if (!q(e))
24
+ throw new TypeError("Expected `interval` to be a finite number");
25
+ const r = [];
26
+ let n = [], o = 0;
27
+ const a = function() {
28
+ o++;
29
+ const c = setTimeout(function() {
30
+ o--, r.length > 0 && a(), n = n.filter(function(u) {
31
+ return u !== c;
32
+ });
33
+ }, e);
34
+ n.indexOf(c) < 0 && n.push(c);
35
+ const l = r.shift();
36
+ l.resolve(s.apply(l.self, l.args));
37
+ }, i = function(...c) {
38
+ const l = this;
39
+ return new Promise(function(u, d) {
40
+ r.push({
41
+ resolve: u,
42
+ reject: d,
43
+ args: c,
44
+ self: l
45
+ }), o < t && a();
46
+ });
47
+ };
48
+ return i.abort = function() {
49
+ n.forEach(clearTimeout), n = [], r.forEach(function(c) {
50
+ c.reject(function() {
51
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
52
+ });
53
+ }), r.length = 0;
54
+ }, i;
55
+ }
56
+ const nt = function(s, t) {
57
+ const e = {};
58
+ for (const r in s) {
59
+ const n = s[r];
60
+ t.indexOf(r) > -1 && n !== null && (e[r] = n);
31
61
  }
32
62
  return e;
33
- }, ft = (r) => r === "email";
34
- var dt = {
35
- nodes: {
36
- horizontal_rule() {
37
- return {
38
- singleTag: "hr"
39
- };
40
- },
41
- blockquote() {
42
- return {
43
- tag: "blockquote"
44
- };
45
- },
46
- bullet_list() {
47
- return {
48
- tag: "ul"
49
- };
50
- },
51
- code_block(r) {
52
- return {
53
- tag: [
54
- "pre",
55
- {
56
- tag: "code",
57
- attrs: r.attrs
58
- }
59
- ]
60
- };
61
- },
62
- hard_break() {
63
- return {
64
- singleTag: "br"
65
- };
66
- },
67
- heading(r) {
68
- return {
69
- tag: `h${r.attrs.level}`
70
- };
71
- },
72
- image(r) {
73
- return {
74
- singleTag: [
75
- {
76
- tag: "img",
77
- attrs: ht(r.attrs, ["src", "alt", "title"])
78
- }
79
- ]
80
- };
81
- },
82
- list_item() {
83
- return {
84
- tag: "li"
85
- };
86
- },
87
- ordered_list() {
88
- return {
89
- tag: "ol"
90
- };
91
- },
92
- paragraph() {
93
- return {
94
- tag: "p"
95
- };
63
+ }, ot = (s) => s === "email", it = () => ({
64
+ singleTag: "hr"
65
+ }), at = () => ({
66
+ tag: "blockquote"
67
+ }), ct = () => ({
68
+ tag: "ul"
69
+ }), lt = (s) => ({
70
+ tag: [
71
+ "pre",
72
+ {
73
+ tag: "code",
74
+ attrs: s.attrs
75
+ }
76
+ ]
77
+ }), ht = () => ({
78
+ singleTag: "br"
79
+ }), ut = (s) => ({
80
+ tag: `h${s.attrs.level}`
81
+ }), dt = (s) => ({
82
+ singleTag: [
83
+ {
84
+ tag: "img",
85
+ attrs: nt(s.attrs, ["src", "alt", "title"])
96
86
  }
87
+ ]
88
+ }), ft = () => ({
89
+ tag: "li"
90
+ }), pt = () => ({
91
+ tag: "ol"
92
+ }), gt = () => ({
93
+ tag: "p"
94
+ }), mt = () => ({
95
+ tag: "b"
96
+ }), yt = () => ({
97
+ tag: "strike"
98
+ }), kt = () => ({
99
+ tag: "u"
100
+ }), _t = () => ({
101
+ tag: "strong"
102
+ }), bt = () => ({
103
+ tag: "code"
104
+ }), vt = () => ({
105
+ tag: "i"
106
+ }), wt = (s) => {
107
+ const t = { ...s.attrs }, { linktype: e = "url" } = s.attrs;
108
+ return ot(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
109
+ tag: [
110
+ {
111
+ tag: "a",
112
+ attrs: t
113
+ }
114
+ ]
115
+ };
116
+ }, $t = (s) => ({
117
+ tag: [
118
+ {
119
+ tag: "span",
120
+ attrs: s.attrs
121
+ }
122
+ ]
123
+ }), Tt = {
124
+ nodes: {
125
+ horizontal_rule: it,
126
+ blockquote: at,
127
+ bullet_list: ct,
128
+ code_block: lt,
129
+ hard_break: ht,
130
+ heading: ut,
131
+ image: dt,
132
+ list_item: ft,
133
+ ordered_list: pt,
134
+ paragraph: gt
97
135
  },
98
136
  marks: {
99
- bold() {
100
- return {
101
- tag: "b"
102
- };
103
- },
104
- strike() {
105
- return {
106
- tag: "strike"
107
- };
108
- },
109
- underline() {
110
- return {
111
- tag: "u"
112
- };
113
- },
114
- strong() {
115
- return {
116
- tag: "strong"
117
- };
118
- },
119
- code() {
120
- return {
121
- tag: "code"
122
- };
123
- },
124
- italic() {
125
- return {
126
- tag: "i"
127
- };
128
- },
129
- link(r) {
130
- const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
131
- return ft(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
132
- tag: [
133
- {
134
- tag: "a",
135
- attrs: t
136
- }
137
- ]
138
- };
139
- },
140
- styled(r) {
141
- return {
142
- tag: [
143
- {
144
- tag: "span",
145
- attrs: r.attrs
146
- }
147
- ]
148
- };
149
- }
150
- }
151
- };
152
- const pt = function(r) {
137
+ bold: mt,
138
+ strike: yt,
139
+ underline: kt,
140
+ strong: _t,
141
+ code: bt,
142
+ italic: vt,
143
+ link: wt,
144
+ styled: $t
145
+ }
146
+ }, Rt = function(s) {
153
147
  const t = {
154
148
  "&": "&amp;",
155
149
  "<": "&lt;",
156
150
  ">": "&gt;",
157
151
  '"': "&quot;",
158
152
  "'": "&#39;"
159
- }, e = /[&<>"']/g, n = RegExp(e.source);
160
- return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
153
+ }, e = /[&<>"']/g, r = RegExp(e.source);
154
+ return s && r.test(s) ? s.replace(e, (n) => t[n]) : s;
161
155
  };
162
- class W {
156
+ class T {
163
157
  constructor(t) {
164
- t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
158
+ h(this, "marks"), h(this, "nodes"), t || (t = Tt), this.marks = t.marks || [], this.nodes = t.nodes || [];
165
159
  }
166
160
  addNode(t, e) {
167
161
  this.nodes[t] = e;
@@ -169,41 +163,43 @@ class W {
169
163
  addMark(t, e) {
170
164
  this.marks[t] = e;
171
165
  }
172
- render(t = {}) {
173
- if (t.content && Array.isArray(t.content)) {
166
+ render(t) {
167
+ if (t && t.content && Array.isArray(t.content)) {
174
168
  let e = "";
175
- return t.content.forEach((n) => {
176
- e += this.renderNode(n);
169
+ return t.content.forEach((r) => {
170
+ e += this.renderNode(r);
177
171
  }), e;
178
172
  }
179
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
173
+ return console.warn(
174
+ "The render method must receive an object with a content field, which is an array"
175
+ ), "";
180
176
  }
181
177
  renderNode(t) {
182
- let e = [];
183
- t.marks && t.marks.forEach((s) => {
184
- const o = this.getMatchingMark(s);
178
+ const e = [];
179
+ t.marks && t.marks.forEach((n) => {
180
+ const o = this.getMatchingMark(n);
185
181
  o && e.push(this.renderOpeningTag(o.tag));
186
182
  });
187
- const n = this.getMatchingNode(t);
188
- return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
189
- e.push(this.renderNode(s));
190
- }) : t.text ? e.push(pt(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
191
- const o = this.getMatchingMark(s);
183
+ const r = this.getMatchingNode(t);
184
+ return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((n) => {
185
+ e.push(this.renderNode(n));
186
+ }) : t.text ? e.push(Rt(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((n) => {
187
+ const o = this.getMatchingMark(n);
192
188
  o && e.push(this.renderClosingTag(o.tag));
193
189
  }), e.join("");
194
190
  }
195
191
  renderTag(t, e) {
196
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
197
- if (s.constructor === String)
198
- return `<${s}${e}>`;
192
+ return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
193
+ if (r.constructor === String)
194
+ return `<${r}${e}>`;
199
195
  {
200
- let o = `<${s.tag}`;
201
- if (s.attrs)
202
- for (let a in s.attrs) {
203
- let i = s.attrs[a];
204
- i !== null && (o += ` ${a}="${i}"`);
196
+ let n = `<${r.tag}`;
197
+ if (r.attrs)
198
+ for (const o in r.attrs) {
199
+ const a = r.attrs[o];
200
+ a !== null && (n += ` ${o}="${a}"`);
205
201
  }
206
- return `${o}${e}>`;
202
+ return `${n}${e}>`;
207
203
  }
208
204
  }).join("");
209
205
  }
@@ -211,199 +207,183 @@ class W {
211
207
  return this.renderTag(t, "");
212
208
  }
213
209
  renderClosingTag(t) {
214
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((n) => n.constructor === String ? `</${n}>` : `</${n.tag}>`).join("");
210
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
215
211
  }
216
212
  getMatchingNode(t) {
217
- if (typeof this.nodes[t.type] == "function")
218
- return this.nodes[t.type](t);
213
+ const e = this.nodes[t.type];
214
+ if (typeof e == "function")
215
+ return e(t);
219
216
  }
220
217
  getMatchingMark(t) {
221
- if (typeof this.marks[t.type] == "function")
222
- return this.marks[t.type](t);
218
+ const e = this.marks[t.type];
219
+ if (typeof e == "function")
220
+ return e(t);
221
+ }
222
+ }
223
+ class K {
224
+ constructor() {
225
+ h(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (t, e = 25, r = 1) => ({
226
+ ...t,
227
+ per_page: e,
228
+ page: r
229
+ })), h(this, "delay", (t) => new Promise((e) => setTimeout(e, t))), h(this, "arrayFrom", (t = 0, e) => [...Array(t)].map(e)), h(this, "range", (t = 0, e = t) => {
230
+ const r = Math.abs(e - t) || 0, n = t < e ? 1 : -1;
231
+ return this.arrayFrom(r, (o, a) => a * n + t);
232
+ }), h(this, "asyncMap", async (t, e) => Promise.all(t.map(e))), h(this, "flatMap", (t = [], e) => t.map(e).reduce((r, n) => [...r, ...n], []));
233
+ }
234
+ stringify(t, e, r) {
235
+ const n = [];
236
+ for (const o in t) {
237
+ if (!Object.prototype.hasOwnProperty.call(t, o))
238
+ continue;
239
+ const a = t[o], i = r ? "" : encodeURIComponent(o);
240
+ let c;
241
+ typeof a == "object" ? c = this.stringify(
242
+ a,
243
+ e ? e + encodeURIComponent("[" + i + "]") : i,
244
+ Array.isArray(a)
245
+ ) : c = (e ? e + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(a), n.push(c);
246
+ }
247
+ return n.join("&");
223
248
  }
224
249
  }
225
- /*!
226
- * storyblok-js-client v4.5.2
227
- * Universal JavaScript SDK for Storyblok's API
228
- * (c) 2020-2022 Stobylok Team
229
- */
230
- function H(r) {
231
- return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
232
- }
233
- function X(r, t, e) {
234
- if (!H(t))
235
- throw new TypeError("Expected `limit` to be a finite number");
236
- if (!H(e))
237
- throw new TypeError("Expected `interval` to be a finite number");
238
- var n = [], s = [], o = 0, a = function() {
239
- o++;
240
- var l = setTimeout(function() {
241
- o--, n.length > 0 && a(), s = s.filter(function(u) {
242
- return u !== l;
243
- });
244
- }, e);
245
- s.indexOf(l) < 0 && s.push(l);
246
- var c = n.shift();
247
- c.resolve(r.apply(c.self, c.args));
248
- }, i = function() {
249
- var l = arguments, c = this;
250
- return new Promise(function(u, h) {
251
- n.push({ resolve: u, reject: h, args: l, self: c }), o < t && a();
252
- });
253
- };
254
- return i.abort = function() {
255
- s.forEach(clearTimeout), s = [], n.forEach(function(l) {
256
- l.reject(new throttle.AbortError());
257
- }), n.length = 0;
258
- }, i;
259
- }
260
- X.AbortError = function() {
261
- Error.call(this, "Throttled function aborted"), this.name = "AbortError";
262
- };
263
- const gt = function(r, t) {
264
- if (!r)
265
- return null;
266
- let e = {};
267
- for (let n in r) {
268
- let s = r[n];
269
- t.indexOf(n) > -1 && s !== null && (e[n] = s);
270
- }
271
- return e;
272
- };
273
- var mt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: gt(r.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(r) {
274
- const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
275
- return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
276
- }, styled: (r) => ({ tag: [{ tag: "span", attrs: r.attrs }] }) } };
277
- class yt {
250
+ class xt {
278
251
  constructor(t) {
279
- t || (t = mt), this.marks = t.marks || [], this.nodes = t.nodes || [];
252
+ 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 = t.baseURL, this.headers = t.headers || [], this.timeout = t != null && t.timeout ? t.timeout * 1e3 : 0, this.responseInterceptor = t.responseInterceptor, this.fetch = (...e) => t.fetch ? t.fetch(...e) : fetch(...e), this.ejectInterceptor = !1, this.url = "", this.parameters = {};
280
253
  }
281
- addNode(t, e) {
282
- this.nodes[t] = e;
254
+ get(t, e) {
255
+ return this.url = t, this.parameters = e, this._methodHandler("get");
283
256
  }
284
- addMark(t, e) {
285
- this.marks[t] = e;
257
+ post(t, e) {
258
+ return this.url = t, this.parameters = e, this._methodHandler("post");
286
259
  }
287
- render(t = {}) {
288
- if (t.content && Array.isArray(t.content)) {
289
- let e = "";
290
- return t.content.forEach((n) => {
291
- e += this.renderNode(n);
292
- }), e;
293
- }
294
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
260
+ put(t, e) {
261
+ return this.url = t, this.parameters = e, this._methodHandler("put");
295
262
  }
296
- renderNode(t) {
297
- let e = [];
298
- t.marks && t.marks.forEach((s) => {
299
- const o = this.getMatchingMark(s);
300
- o && e.push(this.renderOpeningTag(o.tag));
263
+ delete(t, e) {
264
+ return this.url = t, this.parameters = e, this._methodHandler("delete");
265
+ }
266
+ async _responseHandler(t) {
267
+ const e = [], r = {
268
+ data: {},
269
+ headers: {},
270
+ status: 0,
271
+ statusText: ""
272
+ };
273
+ await t.json().then((n) => {
274
+ r.data = n;
301
275
  });
302
- const n = this.getMatchingNode(t);
303
- return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
304
- e.push(this.renderNode(s));
305
- }) : t.text ? e.push(function(s) {
306
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
307
- return s && i.test(s) ? s.replace(a, (l) => o[l]) : s;
308
- }(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
309
- const o = this.getMatchingMark(s);
310
- o && e.push(this.renderClosingTag(o.tag));
311
- }), e.join("");
312
- }
313
- renderTag(t, e) {
314
- return t.constructor === String ? `<${t}${e}>` : t.map((n) => {
315
- if (n.constructor === String)
316
- return `<${n}${e}>`;
317
- {
318
- let s = `<${n.tag}`;
319
- if (n.attrs)
320
- for (let o in n.attrs) {
321
- let a = n.attrs[o];
322
- a !== null && (s += ` ${o}="${a}"`);
323
- }
324
- return `${s}${e}>`;
325
- }
326
- }).join("");
327
- }
328
- renderOpeningTag(t) {
329
- return this.renderTag(t, "");
276
+ for (const n of t.headers.entries())
277
+ e[n[0]] = n[1];
278
+ return r.headers = { ...e }, r.status = t.status, r.statusText = t.statusText, r;
279
+ }
280
+ async _methodHandler(t) {
281
+ const e = new URL(`${this.baseURL}${this.url}`);
282
+ let r = null;
283
+ if (t === "get") {
284
+ const i = new K();
285
+ e.search = i.stringify(this.parameters);
286
+ } else
287
+ r = JSON.stringify(this.parameters);
288
+ const n = new AbortController(), { signal: o } = n;
289
+ let a;
290
+ this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
291
+ try {
292
+ const i = await this.fetch(`${e}`, {
293
+ method: t,
294
+ headers: this.headers,
295
+ body: r,
296
+ signal: o
297
+ });
298
+ this.timeout && clearTimeout(a);
299
+ const c = await this._responseHandler(i);
300
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
301
+ } catch (i) {
302
+ return i;
303
+ }
330
304
  }
331
- renderClosingTag(t) {
332
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
305
+ eject() {
306
+ this.ejectInterceptor = !0;
333
307
  }
334
- getMatchingNode(t) {
335
- if (typeof this.nodes[t.type] == "function")
336
- return this.nodes[t.type](t);
308
+ _statusHandler(t) {
309
+ if (/20[01]/g.test(`${t.status}`))
310
+ return t;
311
+ throw {
312
+ message: new Error(t.statusText || `status: ${t.status}`),
313
+ response: t
314
+ };
337
315
  }
338
- getMatchingMark(t) {
339
- if (typeof this.marks[t.type] == "function")
340
- return this.marks[t.type](t);
341
- }
342
- }
343
- const kt = (r = 0, t = r) => {
344
- const e = Math.abs(t - r) || 0, n = r < t ? 1 : -1;
345
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * n + r);
346
- }, x = (r, t, e) => {
347
- const n = [];
348
- for (const s in r) {
349
- if (!Object.prototype.hasOwnProperty.call(r, s))
350
- continue;
351
- const o = r[s], a = e ? "" : encodeURIComponent(s);
352
- let i;
353
- i = typeof o == "object" ? x(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
354
- }
355
- return n.join("&");
356
- };
357
- let _ = {}, p = {};
358
- class _t {
316
+ }
317
+ let b = {};
318
+ const g = {};
319
+ class jt {
359
320
  constructor(t, e) {
360
- if (!e) {
361
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
362
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
321
+ if (h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), !e) {
322
+ const o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
323
+ t.oauthToken ? e = `${a}://api${o}.storyblok.com/v1` : e = `${a}://api${o}.storyblok.com/v2`;
363
324
  }
364
- let n = Object.assign({}, t.headers), s = 5;
365
- t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new yt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = X(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = st.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
325
+ const r = new Headers();
326
+ r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((o, a) => {
327
+ t.headers && t.headers[a] && r.set(a, t.headers[a]);
328
+ });
329
+ let n = 5;
330
+ t.oauthToken && (r.set("Authorization", t.oauthToken), n = 3), t.rateLimit && (n = t.rateLimit), t.richTextSchema ? this.richTextResolver = new T(t.richTextSchema) : this.richTextResolver = new T(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries, this.throttle = rt(this.throttledRequest, n, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new K(), this.resolveNestedRelations = !1, this.client = new xt({
331
+ baseURL: e,
332
+ timeout: t.timeout || 0,
333
+ headers: r,
334
+ responseInterceptor: t.responseInterceptor,
335
+ fetch: t.fetch
336
+ });
366
337
  }
367
338
  setComponentResolver(t) {
368
339
  this.richTextResolver.addNode("blok", (e) => {
369
- let n = "";
370
- return e.attrs.body.forEach((s) => {
371
- n += t(s.component, s);
372
- }), { html: n };
340
+ let r = "";
341
+ return e.attrs.body.forEach((n) => {
342
+ r += t(n.component, n);
343
+ }), {
344
+ html: r
345
+ };
373
346
  });
374
347
  }
375
- parseParams(t = {}) {
376
- return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = p[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
348
+ parseParams(t) {
349
+ return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = g[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
377
350
  }
378
- factoryParamOptions(t, e = {}) {
379
- return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
351
+ factoryParamOptions(t, e) {
352
+ return this.helpers.isCDNUrl(t) ? this.parseParams(e) : e;
380
353
  }
381
- makeRequest(t, e, n, s) {
382
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => T(d({}, a), { per_page: i, page: l }))(e, n, s));
354
+ makeRequest(t, e, r, n) {
355
+ const o = this.factoryParamOptions(
356
+ t,
357
+ this.helpers.getOptionsPage(e, r, n)
358
+ );
383
359
  return this.cacheResponse(t, o);
384
360
  }
385
361
  get(t, e) {
386
- let n = `/${t}`;
387
- const s = this.factoryParamOptions(n, e);
388
- return this.cacheResponse(n, s);
389
- }
390
- async getAll(t, e = {}, n) {
391
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
392
- n = n || a[a.length - 1];
393
- const i = await this.makeRequest(o, e, s, 1), l = i.total ? Math.ceil(i.total / s) : 1;
394
- return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(kt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
362
+ e || (e = {});
363
+ const r = `/${t}`, n = this.factoryParamOptions(r, e);
364
+ return this.cacheResponse(r, n);
365
+ }
366
+ async getAll(t, e, r) {
367
+ const n = (e == null ? void 0 : e.per_page) || 25, o = `/${t}`, a = o.split("/"), i = r || a[a.length - 1], c = 1, l = await this.makeRequest(o, e, n, c), u = l.total ? Math.ceil(l.total / n) : 1, d = await this.helpers.asyncMap(
368
+ this.helpers.range(c, u),
369
+ (p) => this.makeRequest(o, e, n, p + 1)
370
+ );
371
+ return this.helpers.flatMap(
372
+ [l, ...d],
373
+ (p) => Object.values(p.data[i])
374
+ );
395
375
  }
396
376
  post(t, e) {
397
- let n = `/${t}`;
398
- return this.throttle("post", n, e);
377
+ const r = `/${t}`;
378
+ return Promise.resolve(this.throttle("post", r, e));
399
379
  }
400
380
  put(t, e) {
401
- let n = `/${t}`;
402
- return this.throttle("put", n, e);
381
+ const r = `/${t}`;
382
+ return Promise.resolve(this.throttle("put", r, e));
403
383
  }
404
384
  delete(t, e) {
405
- let n = `/${t}`;
406
- return this.throttle("delete", n, e);
385
+ const r = `/${t}`;
386
+ return Promise.resolve(this.throttle("delete", r, e));
407
387
  }
408
388
  getStories(t) {
409
389
  return this.get("cdn/stories", t);
@@ -411,519 +391,575 @@ class _t {
411
391
  getStory(t, e) {
412
392
  return this.get(`cdn/stories/${t}`, e);
413
393
  }
414
- setToken(t) {
415
- this.accessToken = t;
416
- }
417
394
  getToken() {
418
395
  return this.accessToken;
419
396
  }
397
+ ejectInterceptor() {
398
+ this.client.eject();
399
+ }
420
400
  _cleanCopy(t) {
421
401
  return JSON.parse(JSON.stringify(t));
422
402
  }
423
403
  _insertLinks(t, e) {
424
- const n = t[e];
425
- n && n.fieldtype == "multilink" && n.linktype == "story" && typeof n.id == "string" && this.links[n.id] ? n.story = this._cleanCopy(this.links[n.id]) : n && n.linktype === "story" && typeof n.uuid == "string" && this.links[n.uuid] && (n.story = this._cleanCopy(this.links[n.uuid]));
404
+ const r = t[e];
405
+ r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
426
406
  }
427
- _insertRelations(t, e, n) {
428
- if (n.indexOf(t.component + "." + e) > -1) {
407
+ _insertRelations(t, e, r) {
408
+ if (r.indexOf(`${t.component}.${e}`) > -1) {
429
409
  if (typeof t[e] == "string")
430
410
  this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
431
- else if (t[e].constructor === Array) {
432
- let s = [];
411
+ else if (t[e] && t[e].constructor === Array) {
412
+ const n = [];
433
413
  t[e].forEach((o) => {
434
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
435
- }), t[e] = s;
414
+ this.relations[o] && n.push(this._cleanCopy(this.relations[o]));
415
+ }), t[e] = n;
436
416
  }
437
417
  }
438
418
  }
439
- _insertAssetsRelations(t, e) {
440
- e.forEach((n) => {
441
- t.id === n.id && (t.original = n, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
442
- });
443
- }
444
419
  iterateTree(t, e) {
445
- let n = (s) => {
446
- if (s != null) {
447
- if (s.constructor === Array)
448
- for (let o = 0; o < s.length; o++)
449
- n(s[o]);
450
- else if (s.constructor === Object) {
451
- if (s._stopResolving)
420
+ const r = (n) => {
421
+ if (n != null) {
422
+ if (n.constructor === Array)
423
+ for (let o = 0; o < n.length; o++)
424
+ r(n[o]);
425
+ else if (n.constructor === Object) {
426
+ if (n._stopResolving)
452
427
  return;
453
- for (let o in s)
454
- s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), n(s[o]);
428
+ for (const o in n)
429
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(
430
+ n,
431
+ o,
432
+ e
433
+ ), this._insertLinks(n, o)), r(n[o]);
455
434
  }
456
435
  }
457
436
  };
458
- n(t.content);
437
+ r(t.content);
459
438
  }
460
439
  async resolveLinks(t, e) {
461
- let n = [];
440
+ let r = [];
462
441
  if (t.link_uuids) {
463
- const s = t.link_uuids.length;
464
- let o = [];
465
- const a = 50;
466
- for (let i = 0; i < s; i += a) {
467
- const l = Math.min(s, i + a);
468
- o.push(t.link_uuids.slice(i, l));
442
+ const n = t.link_uuids.length, o = [], a = 50;
443
+ for (let i = 0; i < n; i += a) {
444
+ const c = Math.min(n, i + a);
445
+ o.push(t.link_uuids.slice(i, c));
469
446
  }
470
447
  for (let i = 0; i < o.length; i++)
471
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
472
- n.push(l);
473
- });
448
+ (await this.getStories({
449
+ per_page: a,
450
+ language: e.language,
451
+ version: e.version,
452
+ by_uuids: o[i].join(",")
453
+ })).data.stories.forEach(
454
+ (c) => {
455
+ r.push(c);
456
+ }
457
+ );
474
458
  } else
475
- n = t.links;
476
- n.forEach((s) => {
477
- this.links[s.uuid] = T(d({}, s), { _stopResolving: !0 });
459
+ r = t.links;
460
+ r.forEach((n) => {
461
+ this.links[n.uuid] = { ...n, _stopResolving: !0 };
478
462
  });
479
463
  }
480
464
  async resolveRelations(t, e) {
481
- let n = [];
465
+ let r = [];
482
466
  if (t.rel_uuids) {
483
- const s = t.rel_uuids.length;
484
- let o = [];
485
- const a = 50;
486
- for (let i = 0; i < s; i += a) {
487
- const l = Math.min(s, i + a);
488
- o.push(t.rel_uuids.slice(i, l));
467
+ const n = t.rel_uuids.length, o = [], a = 50;
468
+ for (let i = 0; i < n; i += a) {
469
+ const c = Math.min(n, i + a);
470
+ o.push(t.rel_uuids.slice(i, c));
489
471
  }
490
472
  for (let i = 0; i < o.length; i++)
491
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
492
- n.push(l);
473
+ (await this.getStories({
474
+ per_page: a,
475
+ language: e.language,
476
+ version: e.version,
477
+ by_uuids: o[i].join(",")
478
+ })).data.stories.forEach((c) => {
479
+ r.push(c);
493
480
  });
494
481
  } else
495
- n = t.rels;
496
- n.forEach((s) => {
497
- this.relations[s.uuid] = T(d({}, s), { _stopResolving: !0 });
482
+ r = t.rels;
483
+ r && r.length > 0 && r.forEach((n) => {
484
+ this.relations[n.uuid] = { ...n, _stopResolving: !0 };
498
485
  });
499
486
  }
500
487
  async resolveStories(t, e) {
501
- let n = [];
502
- if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (n = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
503
- for (const s in this.relations)
504
- this.iterateTree(this.relations[s], n);
505
- t.story ? this.iterateTree(t.story, n) : t.stories.forEach((s) => {
506
- this.iterateTree(s, n);
488
+ var r, n;
489
+ let o = [];
490
+ if (typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (o = e.resolve_relations.split(",")), await this.resolveRelations(t, e)), e.resolve_links && ["1", "story", "url"].indexOf(e.resolve_links) > -1 && ((r = t.links) != null && r.length || (n = t.link_uuids) != null && n.length) && await this.resolveLinks(t, e), this.resolveNestedRelations)
491
+ for (const a in this.relations)
492
+ this.iterateTree(this.relations[a], o);
493
+ t.story ? this.iterateTree(t.story, o) : t.stories.forEach((a) => {
494
+ this.iterateTree(a, o);
507
495
  });
508
496
  }
509
- resolveAssetsRelations(t) {
510
- const { assets: e, stories: n, story: s } = t;
511
- if (n)
512
- for (const o of n)
513
- this.iterateTree(o, e);
514
- else {
515
- if (!s)
516
- return t;
517
- this.iterateTree(s, e);
518
- }
519
- }
520
- cacheResponse(t, e, n) {
521
- return n === void 0 && (n = 0), new Promise(async (s, o) => {
522
- let a = x({ url: t, params: e }), i = this.cacheProvider();
523
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
524
- const c = await i.get(a);
497
+ cacheResponse(t, e, r) {
498
+ return new Promise((n, o) => {
499
+ const a = this.helpers.stringify({ url: t, params: e }), i = this.cacheProvider();
500
+ if (this.cache.clear === "auto" && e.version === "draft" && this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
501
+ const c = i.get(a);
525
502
  if (c)
526
- return s(c);
503
+ return n(c);
527
504
  }
528
505
  try {
529
- let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => x(h) }), u = { data: c.data, headers: c.headers };
530
- if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), u = Object.assign({}, u, { perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0, total: c.headers["per-page"] ? parseInt(c.headers.total) : 0 }), c.status != 200)
531
- return o(c);
532
- (u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && p[e.token] != u.data.cv && this.flushCache(), p[e.token] = u.data.cv), s(u);
533
- } catch (c) {
534
- if (c.response && c.response.status === 429 && (n += 1) < this.maxRetries)
535
- return console.log(`Hit rate limit. Retrying in ${n} seconds.`), await (l = 1e3 * n, new Promise((u) => setTimeout(u, l))), this.cacheResponse(t, e, n).then(s).catch(o);
536
- o(c);
506
+ (async () => {
507
+ var c;
508
+ const l = await this.throttle("get", t, e);
509
+ let u = { data: l.data, headers: l.headers };
510
+ if ((c = l.headers) != null && c["per-page"] && (u = Object.assign({}, u, {
511
+ perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
512
+ total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
513
+ })), l.status != 200)
514
+ return o(l);
515
+ (u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && e.token && (e.version == "draft" && g[e.token] != u.data.cv && this.flushCache(), g[e.token] = u.data.cv), n(u);
516
+ })();
517
+ } catch {
537
518
  }
538
- var l;
539
519
  });
540
520
  }
541
- throttledRequest(t, e, n) {
542
- return this.client[t](e, n);
521
+ throttledRequest(t, e, r) {
522
+ return this.client[t](e, r);
543
523
  }
544
524
  cacheVersions() {
545
- return p;
525
+ return g;
546
526
  }
547
527
  cacheVersion() {
548
- return p[this.accessToken];
528
+ return g[this.accessToken];
549
529
  }
550
530
  setCacheVersion(t) {
551
- this.accessToken && (p[this.accessToken] = t);
531
+ this.accessToken && (g[this.accessToken] = t);
552
532
  }
553
533
  cacheProvider() {
554
- return this.cache.type === "memory" ? { get: (t) => _[t], getAll: () => _, set(t, e) {
555
- _[t] = e;
556
- }, flush() {
557
- _ = {};
558
- } } : { get() {
559
- }, getAll() {
560
- }, set() {
561
- }, flush() {
562
- } };
563
- }
564
- async flushCache() {
565
- return await this.cacheProvider().flush(), this;
566
- }
567
- }
568
- const Vt = (r = {}) => {
569
- const { apiOptions: t } = r;
534
+ switch (this.cache.type) {
535
+ case "memory":
536
+ return {
537
+ get(t) {
538
+ return b[t];
539
+ },
540
+ getAll() {
541
+ return b;
542
+ },
543
+ set(t, e) {
544
+ b[t] = e;
545
+ },
546
+ flush() {
547
+ b = {};
548
+ }
549
+ };
550
+ default:
551
+ return {
552
+ get() {
553
+ },
554
+ getAll() {
555
+ },
556
+ set() {
557
+ },
558
+ flush() {
559
+ }
560
+ };
561
+ }
562
+ }
563
+ flushCache() {
564
+ return this.cacheProvider().flush(), this;
565
+ }
566
+ }
567
+ const Wt = (s = {}) => {
568
+ const { apiOptions: t } = s;
570
569
  if (!t.accessToken) {
571
- console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
570
+ console.error(
571
+ "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
572
+ );
572
573
  return;
573
574
  }
574
- return { storyblokApi: new _t(t) };
575
- };
576
- var bt = (r) => {
577
- if (typeof r != "object" || typeof r._editable > "u")
575
+ return { storyblokApi: new jt(t) };
576
+ }, Et = (s) => {
577
+ if (typeof s != "object" || typeof s._editable > "u")
578
578
  return {};
579
- const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
579
+ const t = JSON.parse(
580
+ s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
581
+ );
580
582
  return {
581
583
  "data-blok-c": JSON.stringify(t),
582
584
  "data-blok-uid": t.id + "-" + t.uid
583
585
  };
584
586
  };
585
- let E;
586
- const vt = "https://app.storyblok.com/f/storyblok-v2-latest.js", Jt = (r, t, e = {}) => {
587
+ let x;
588
+ const St = "https://app.storyblok.com/f/storyblok-v2-latest.js", Xt = (s, t, e = {}) => {
587
589
  if (!(typeof window > "u")) {
588
590
  if (typeof window.storyblokRegisterEvent > "u") {
589
- console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
591
+ console.error(
592
+ "Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js"
593
+ );
590
594
  return;
591
595
  }
592
- if (!r) {
596
+ if (!s) {
593
597
  console.warn("Story ID is not defined. Please provide a valid ID.");
594
598
  return;
595
599
  }
596
600
  window.storyblokRegisterEvent(() => {
597
- new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
598
- s.action === "input" && s.story.id === r ? t(s.story) : (s.action === "change" || s.action === "published") && s.storyId === r && window.location.reload();
601
+ new window.StoryblokBridge(e).on(["input", "published", "change"], (r) => {
602
+ r.action === "input" && r.story.id === s ? t(r.story) : (r.action === "change" || r.action === "published") && r.storyId === s && window.location.reload();
599
603
  });
600
604
  });
601
605
  }
602
- }, $t = (r = {}) => {
606
+ }, Pt = (s = {}) => {
603
607
  const {
604
608
  bridge: t,
605
609
  accessToken: e,
606
- use: n = [],
607
- apiOptions: s = {},
610
+ use: r = [],
611
+ apiOptions: n = {},
608
612
  richText: o = {}
609
- } = r;
610
- s.accessToken = s.accessToken || e;
611
- const a = { bridge: t, apiOptions: s };
613
+ } = s;
614
+ n.accessToken = n.accessToken || e;
615
+ const a = { bridge: t, apiOptions: n };
612
616
  let i = {};
613
- return n.forEach((l) => {
614
- i = d(d({}, i), l(a));
615
- }), t !== !1 && ut(vt), E = new W(o.schema), o.resolver && Z(E, o.resolver), i;
616
- }, Z = (r, t) => {
617
- r.addNode("blok", (e) => {
618
- let n = "";
619
- return e.attrs.body.forEach((s) => {
620
- n += t(s.component, s);
617
+ return r.forEach((c) => {
618
+ i = { ...i, ...c(a) };
619
+ }), t !== !1 && tt(St), x = new T(o.schema), o.resolver && G(x, o.resolver), i;
620
+ }, G = (s, t) => {
621
+ s.addNode("blok", (e) => {
622
+ let r = "";
623
+ return e.attrs.body.forEach((n) => {
624
+ r += t(n.component, n);
621
625
  }), {
622
- html: n
626
+ html: r
623
627
  };
624
628
  });
625
- }, Yt = (r, t, e) => {
626
- let n = e || E;
627
- if (!n) {
628
- console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
+ }, Zt = (s, t, e) => {
630
+ let r = e || x;
631
+ if (!r) {
632
+ console.error(
633
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
634
+ );
629
635
  return;
630
636
  }
631
- return r === "" ? "" : r ? (t && (n = new W(t.schema), t.resolver && Z(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
637
+ return s === "" ? "" : s ? (t && (r = new T(t.schema), t.resolver && G(r, t.resolver)), r.render(s)) : (console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
632
638
 
633
639
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
634
640
  };
635
- function O() {
641
+ function j() {
636
642
  }
637
- function S(r, t) {
643
+ function E(s, t) {
638
644
  for (const e in t)
639
- r[e] = t[e];
640
- return r;
645
+ s[e] = t[e];
646
+ return s;
641
647
  }
642
- function tt(r) {
643
- return r();
648
+ function Q(s) {
649
+ return s();
644
650
  }
645
- function V() {
651
+ function D() {
646
652
  return /* @__PURE__ */ Object.create(null);
647
653
  }
648
- function y(r) {
649
- r.forEach(tt);
654
+ function _(s) {
655
+ s.forEach(Q);
650
656
  }
651
- function et(r) {
652
- return typeof r == "function";
657
+ function W(s) {
658
+ return typeof s == "function";
653
659
  }
654
- function wt(r, t) {
655
- return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
660
+ function Ot(s, t) {
661
+ return s != s ? t == t : s !== t || s && typeof s == "object" || typeof s == "function";
656
662
  }
657
- function Tt(r) {
658
- return Object.keys(r).length === 0;
663
+ function Ct(s) {
664
+ return Object.keys(s).length === 0;
659
665
  }
660
- function Rt(r) {
666
+ function It(s) {
661
667
  const t = {};
662
- for (const e in r)
663
- e[0] !== "$" && (t[e] = r[e]);
668
+ for (const e in s)
669
+ e[0] !== "$" && (t[e] = s[e]);
664
670
  return t;
665
671
  }
666
- function J(r, t) {
672
+ function B(s, t) {
667
673
  const e = {};
668
674
  t = new Set(t);
669
- for (const n in r)
670
- !t.has(n) && n[0] !== "$" && (e[n] = r[n]);
675
+ for (const r in s)
676
+ !t.has(r) && r[0] !== "$" && (e[r] = s[r]);
671
677
  return e;
672
678
  }
673
- function xt(r, t, e) {
674
- r.insertBefore(t, e || null);
679
+ function At(s, t, e) {
680
+ s.insertBefore(t, e || null);
675
681
  }
676
- function rt(r) {
677
- r.parentNode && r.parentNode.removeChild(r);
682
+ function X(s) {
683
+ s.parentNode && s.parentNode.removeChild(s);
678
684
  }
679
- function Et(r) {
680
- return document.createTextNode(r);
685
+ function Nt(s) {
686
+ return document.createTextNode(s);
681
687
  }
682
- function Ot() {
683
- return Et("");
688
+ function Mt() {
689
+ return Nt("");
684
690
  }
685
- function St(r) {
686
- return Array.from(r.childNodes);
691
+ function Lt(s) {
692
+ return Array.from(s.childNodes);
687
693
  }
688
- function Y(r, t) {
689
- return new r(t);
694
+ function J(s, t) {
695
+ return new s(t);
690
696
  }
691
- let I;
692
- function m(r) {
693
- I = r;
697
+ let N;
698
+ function k(s) {
699
+ N = s;
694
700
  }
695
- const g = [], F = [], v = [], K = [], jt = Promise.resolve();
696
- let j = !1;
697
- function Pt() {
698
- j || (j = !0, jt.then(nt));
701
+ const y = [], F = [], v = [], V = [], Ut = Promise.resolve();
702
+ let S = !1;
703
+ function Ht() {
704
+ S || (S = !0, Ut.then(Z));
699
705
  }
700
- function P(r) {
701
- v.push(r);
706
+ function P(s) {
707
+ v.push(s);
702
708
  }
703
709
  const R = /* @__PURE__ */ new Set();
704
- let b = 0;
705
- function nt() {
706
- const r = I;
710
+ let m = 0;
711
+ function Z() {
712
+ if (m !== 0)
713
+ return;
714
+ const s = N;
707
715
  do {
708
- for (; b < g.length; ) {
709
- const t = g[b];
710
- b++, m(t), At(t.$$);
716
+ try {
717
+ for (; m < y.length; ) {
718
+ const t = y[m];
719
+ m++, k(t), qt(t.$$);
720
+ }
721
+ } catch (t) {
722
+ throw y.length = 0, m = 0, t;
711
723
  }
712
- for (m(null), g.length = 0, b = 0; F.length; )
724
+ for (k(null), y.length = 0, m = 0; F.length; )
713
725
  F.pop()();
714
726
  for (let t = 0; t < v.length; t += 1) {
715
727
  const e = v[t];
716
728
  R.has(e) || (R.add(e), e());
717
729
  }
718
730
  v.length = 0;
719
- } while (g.length);
720
- for (; K.length; )
721
- K.pop()();
722
- j = !1, R.clear(), m(r);
731
+ } while (y.length);
732
+ for (; V.length; )
733
+ V.pop()();
734
+ S = !1, R.clear(), k(s);
723
735
  }
724
- function At(r) {
725
- if (r.fragment !== null) {
726
- r.update(), y(r.before_update);
727
- const t = r.dirty;
728
- r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(P);
736
+ function qt(s) {
737
+ if (s.fragment !== null) {
738
+ s.update(), _(s.before_update);
739
+ const t = s.dirty;
740
+ s.dirty = [-1], s.fragment && s.fragment.p(s.ctx, t), s.after_update.forEach(P);
729
741
  }
730
742
  }
731
- const $ = /* @__PURE__ */ new Set();
743
+ const w = /* @__PURE__ */ new Set();
732
744
  let f;
733
- function Ct() {
745
+ function Dt() {
734
746
  f = {
735
747
  r: 0,
736
748
  c: [],
737
749
  p: f
750
+ // parent group
738
751
  };
739
752
  }
740
- function Mt() {
741
- f.r || y(f.c), f = f.p;
753
+ function Bt() {
754
+ f.r || _(f.c), f = f.p;
742
755
  }
743
- function A(r, t) {
744
- r && r.i && ($.delete(r), r.i(t));
756
+ function O(s, t) {
757
+ s && s.i && (w.delete(s), s.i(t));
745
758
  }
746
- function G(r, t, e, n) {
747
- if (r && r.o) {
748
- if ($.has(r))
759
+ function Y(s, t, e, r) {
760
+ if (s && s.o) {
761
+ if (w.has(s))
749
762
  return;
750
- $.add(r), f.c.push(() => {
751
- $.delete(r), n && (e && r.d(1), n());
752
- }), r.o(t);
763
+ w.add(s), f.c.push(() => {
764
+ w.delete(s), r && (e && s.d(1), r());
765
+ }), s.o(t);
753
766
  } else
754
- n && n();
767
+ r && r();
755
768
  }
756
- function Nt(r, t) {
757
- const e = {}, n = {}, s = { $$scope: 1 };
758
- let o = r.length;
769
+ function Jt(s, t) {
770
+ const e = {}, r = {}, n = { $$scope: 1 };
771
+ let o = s.length;
759
772
  for (; o--; ) {
760
- const a = r[o], i = t[o];
773
+ const a = s[o], i = t[o];
761
774
  if (i) {
762
- for (const l in a)
763
- l in i || (n[l] = 1);
764
- for (const l in i)
765
- s[l] || (e[l] = i[l], s[l] = 1);
766
- r[o] = i;
775
+ for (const c in a)
776
+ c in i || (r[c] = 1);
777
+ for (const c in i)
778
+ n[c] || (e[c] = i[c], n[c] = 1);
779
+ s[o] = i;
767
780
  } else
768
- for (const l in a)
769
- s[l] = 1;
781
+ for (const c in a)
782
+ n[c] = 1;
770
783
  }
771
- for (const a in n)
784
+ for (const a in r)
772
785
  a in e || (e[a] = void 0);
773
786
  return e;
774
787
  }
775
- function It(r) {
776
- return typeof r == "object" && r !== null ? r : {};
788
+ function Ft(s) {
789
+ return typeof s == "object" && s !== null ? s : {};
777
790
  }
778
- function Q(r) {
779
- r && r.c();
791
+ function z(s) {
792
+ s && s.c();
780
793
  }
781
- function C(r, t, e, n) {
782
- const { fragment: s, after_update: o } = r.$$;
783
- s && s.m(t, e), n || P(() => {
784
- const a = r.$$.on_mount.map(tt).filter(et);
785
- r.$$.on_destroy ? r.$$.on_destroy.push(...a) : y(a), r.$$.on_mount = [];
794
+ function C(s, t, e, r) {
795
+ const { fragment: n, after_update: o } = s.$$;
796
+ n && n.m(t, e), r || P(() => {
797
+ const a = s.$$.on_mount.map(Q).filter(W);
798
+ s.$$.on_destroy ? s.$$.on_destroy.push(...a) : _(a), s.$$.on_mount = [];
786
799
  }), o.forEach(P);
787
800
  }
788
- function M(r, t) {
789
- const e = r.$$;
790
- e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
801
+ function I(s, t) {
802
+ const e = s.$$;
803
+ e.fragment !== null && (_(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
791
804
  }
792
- function qt(r, t) {
793
- r.$$.dirty[0] === -1 && (g.push(r), Pt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
805
+ function Vt(s, t) {
806
+ s.$$.dirty[0] === -1 && (y.push(s), Ht(), s.$$.dirty.fill(0)), s.$$.dirty[t / 31 | 0] |= 1 << t % 31;
794
807
  }
795
- function Lt(r, t, e, n, s, o, a, i = [-1]) {
796
- const l = I;
797
- m(r);
798
- const c = r.$$ = {
808
+ function Yt(s, t, e, r, n, o, a, i = [-1]) {
809
+ const c = N;
810
+ k(s);
811
+ const l = s.$$ = {
799
812
  fragment: null,
800
813
  ctx: [],
814
+ // state
801
815
  props: o,
802
- update: O,
803
- not_equal: s,
804
- bound: V(),
816
+ update: j,
817
+ not_equal: n,
818
+ bound: D(),
819
+ // lifecycle
805
820
  on_mount: [],
806
821
  on_destroy: [],
807
822
  on_disconnect: [],
808
823
  before_update: [],
809
824
  after_update: [],
810
- context: new Map(t.context || (l ? l.$$.context : [])),
811
- callbacks: V(),
825
+ context: new Map(t.context || (c ? c.$$.context : [])),
826
+ // everything else
827
+ callbacks: D(),
812
828
  dirty: i,
813
829
  skip_bound: !1,
814
- root: t.target || l.$$.root
830
+ root: t.target || c.$$.root
815
831
  };
816
- a && a(c.root);
832
+ a && a(l.root);
817
833
  let u = !1;
818
- if (c.ctx = e ? e(r, t.props || {}, (h, k, ...q) => {
819
- const L = q.length ? q[0] : k;
820
- return c.ctx && s(c.ctx[h], c.ctx[h] = L) && (!c.skip_bound && c.bound[h] && c.bound[h](L), u && qt(r, h)), k;
821
- }) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
834
+ if (l.ctx = e ? e(s, t.props || {}, (d, p, ...M) => {
835
+ const L = M.length ? M[0] : p;
836
+ return l.ctx && n(l.ctx[d], l.ctx[d] = L) && (!l.skip_bound && l.bound[d] && l.bound[d](L), u && Vt(s, d)), p;
837
+ }) : [], l.update(), u = !0, _(l.before_update), l.fragment = r ? r(l.ctx) : !1, t.target) {
822
838
  if (t.hydrate) {
823
- const h = St(t.target);
824
- c.fragment && c.fragment.l(h), h.forEach(rt);
839
+ const d = Lt(t.target);
840
+ l.fragment && l.fragment.l(d), d.forEach(X);
825
841
  } else
826
- c.fragment && c.fragment.c();
827
- t.intro && A(r.$$.fragment), C(r, t.target, t.anchor, t.customElement), nt();
842
+ l.fragment && l.fragment.c();
843
+ t.intro && O(s.$$.fragment), C(s, t.target, t.anchor, t.customElement), Z();
828
844
  }
829
- m(l);
845
+ k(c);
830
846
  }
831
- class Bt {
847
+ class zt {
832
848
  $destroy() {
833
- M(this, 1), this.$destroy = O;
849
+ I(this, 1), this.$destroy = j;
834
850
  }
835
851
  $on(t, e) {
836
- if (!et(e))
837
- return O;
838
- const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
839
- return n.push(e), () => {
840
- const s = n.indexOf(e);
841
- s !== -1 && n.splice(s, 1);
852
+ if (!W(e))
853
+ return j;
854
+ const r = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
855
+ return r.push(e), () => {
856
+ const n = r.indexOf(e);
857
+ n !== -1 && r.splice(n, 1);
842
858
  };
843
859
  }
844
860
  $set(t) {
845
- this.$$set && !Tt(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
846
- }
847
- }
848
- function zt(r) {
849
- let t, e, n;
850
- const s = [{ blok: r[0] }, r[2]];
851
- var o = r[1];
861
+ this.$$set && !Ct(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
862
+ }
863
+ }
864
+ function Kt(s) {
865
+ let t, e, r;
866
+ const n = [
867
+ { blok: (
868
+ /*blok*/
869
+ s[0]
870
+ ) },
871
+ /*$$restProps*/
872
+ s[2]
873
+ ];
874
+ var o = (
875
+ /*component*/
876
+ s[1]
877
+ );
852
878
  function a(i) {
853
- let l = {};
854
- for (let c = 0; c < s.length; c += 1)
855
- l = S(l, s[c]);
856
- return { props: l };
879
+ let c = {};
880
+ for (let l = 0; l < n.length; l += 1)
881
+ c = E(c, n[l]);
882
+ return { props: c };
857
883
  }
858
- return o && (t = Y(o, a())), {
884
+ return o && (t = J(o, a())), {
859
885
  c() {
860
- t && Q(t.$$.fragment), e = Ot();
886
+ t && z(t.$$.fragment), e = Mt();
861
887
  },
862
- m(i, l) {
863
- t && C(t, i, l), xt(i, e, l), n = !0;
888
+ m(i, c) {
889
+ t && C(t, i, c), At(i, e, c), r = !0;
864
890
  },
865
- p(i, [l]) {
866
- const c = l & 5 ? Nt(s, [
867
- l & 1 && { blok: i[0] },
868
- l & 4 && It(i[2])
891
+ p(i, [c]) {
892
+ const l = c & /*blok, $$restProps*/
893
+ 5 ? Jt(n, [
894
+ c & /*blok*/
895
+ 1 && { blok: (
896
+ /*blok*/
897
+ i[0]
898
+ ) },
899
+ c & /*$$restProps*/
900
+ 4 && Ft(
901
+ /*$$restProps*/
902
+ i[2]
903
+ )
869
904
  ]) : {};
870
- if (o !== (o = i[1])) {
905
+ if (o !== (o = /*component*/
906
+ i[1])) {
871
907
  if (t) {
872
- Ct();
908
+ Dt();
873
909
  const u = t;
874
- G(u.$$.fragment, 1, 0, () => {
875
- M(u, 1);
876
- }), Mt();
910
+ Y(u.$$.fragment, 1, 0, () => {
911
+ I(u, 1);
912
+ }), Bt();
877
913
  }
878
- o ? (t = Y(o, a()), Q(t.$$.fragment), A(t.$$.fragment, 1), C(t, e.parentNode, e)) : t = null;
914
+ o ? (t = J(o, a()), z(t.$$.fragment), O(t.$$.fragment, 1), C(t, e.parentNode, e)) : t = null;
879
915
  } else
880
- o && t.$set(c);
916
+ o && t.$set(l);
881
917
  },
882
918
  i(i) {
883
- n || (t && A(t.$$.fragment, i), n = !0);
919
+ r || (t && O(t.$$.fragment, i), r = !0);
884
920
  },
885
921
  o(i) {
886
- t && G(t.$$.fragment, i), n = !1;
922
+ t && Y(t.$$.fragment, i), r = !1;
887
923
  },
888
924
  d(i) {
889
- i && rt(e), t && M(t, i);
925
+ i && X(e), t && I(t, i);
890
926
  }
891
927
  };
892
928
  }
893
- function Dt(r, t, e) {
894
- const n = ["blok"];
895
- let s = J(t, n), o, { blok: a } = t;
896
- return a ? o = Ut(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
897
- t = S(S({}, t), Rt(i)), e(2, s = J(t, n)), "blok" in i && e(0, a = i.blok);
898
- }, [a, o, s];
929
+ function Gt(s, t, e) {
930
+ const r = ["blok"];
931
+ let n = B(t, r), o, { blok: a } = t;
932
+ return a ? o = Qt(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), s.$$set = (i) => {
933
+ t = E(E({}, t), It(i)), e(2, n = B(t, r)), "blok" in i && e(0, a = i.blok);
934
+ }, [a, o, n];
899
935
  }
900
- class Ft extends Bt {
936
+ class te extends zt {
901
937
  constructor(t) {
902
- super(), Lt(this, t, Dt, zt, wt, { blok: 0 });
938
+ super(), Yt(this, t, Gt, Kt, Ot, { blok: 0 });
903
939
  }
904
940
  }
905
- const Kt = (r, t) => {
906
- const e = (n) => {
907
- const s = bt(n);
908
- s["data-blok-c"] && (r.setAttribute("data-blok-c", s["data-blok-c"]), r.setAttribute("data-blok-uid", s["data-blok-uid"]), r.classList.add("storyblok__outline"));
941
+ const ee = (s, t) => {
942
+ const e = (r) => {
943
+ const n = Et(r);
944
+ n["data-blok-c"] && (s.setAttribute("data-blok-c", n["data-blok-c"]), s.setAttribute("data-blok-uid", n["data-blok-uid"]), s.classList.add("storyblok__outline"));
909
945
  };
910
946
  return e(t), {
911
- update(n) {
912
- e(n);
947
+ update(r) {
948
+ e(r);
913
949
  }
914
950
  };
915
951
  };
916
- let N = null;
917
- const Gt = () => (N || console.log(
952
+ let A = null;
953
+ const se = () => (A || console.log(
918
954
  "You can't use getStoryblokApi if you're not loading apiPlugin."
919
- ), N);
920
- let w = null;
921
- const Qt = (r) => {
922
- const { storyblokApi: t } = $t(r);
923
- N = t, w = r.components || {};
924
- }, Ut = (r) => {
955
+ ), A);
956
+ let $ = null;
957
+ const re = (s) => {
958
+ const { storyblokApi: t } = Pt(s);
959
+ A = t, $ = s.components || {};
960
+ }, Qt = (s) => {
925
961
  let t = null;
926
- return t = typeof w == "function" ? w()[r] : w[r], t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
962
+ return t = typeof $ == "function" ? $()[s] : $[s], t || console.error(`You didn't load the ${s} component. Please load it in storyblokInit. For example:
927
963
  storyblokInit({
928
964
  accessToken: "<your-token>",
929
965
  components: {
@@ -933,14 +969,14 @@ storyblokInit({
933
969
  `), t;
934
970
  };
935
971
  export {
936
- dt as RichTextSchema,
937
- Ft as StoryblokComponent,
938
- Vt as apiPlugin,
939
- Ut as getComponent,
940
- Gt as getStoryblokApi,
941
- Yt as renderRichText,
942
- Kt as storyblokEditable,
943
- Qt as storyblokInit,
944
- Gt as useStoryblokApi,
945
- Jt as useStoryblokBridge
972
+ Tt as RichTextSchema,
973
+ te as StoryblokComponent,
974
+ Wt as apiPlugin,
975
+ Qt as getComponent,
976
+ se as getStoryblokApi,
977
+ Zt as renderRichText,
978
+ ee as storyblokEditable,
979
+ re as storyblokInit,
980
+ se as useStoryblokApi,
981
+ Xt as useStoryblokBridge
946
982
  };