@storyblok/vue 6.3.1 → 7.0.0

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,546 +1,507 @@
1
- import { defineComponent as P, openBlock as j, createBlock as x, resolveDynamicComponent as A, normalizeProps as C, guardReactiveProps as M, ref as N, onMounted as I } from "vue";
2
- import q from "axios";
3
- var L = Object.defineProperty, z = Object.defineProperties, B = Object.getOwnPropertyDescriptors, v = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, h = (n, t) => {
4
- for (var e in t || (t = {}))
5
- D.call(t, e) && b(n, e, t[e]);
6
- if (v)
7
- for (var e of v(t))
8
- U.call(t, e) && b(n, e, t[e]);
9
- return n;
10
- }, y = (n, t) => z(n, B(t));
11
- let _ = !1;
12
- const T = [], V = (n) => new Promise((t, e) => {
13
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
1
+ import { defineComponent as j, openBlock as x, createBlock as C, resolveDynamicComponent as I, normalizeProps as A, guardReactiveProps as M, ref as N, onMounted as L } from "vue";
2
+ var U = Object.defineProperty, D = Object.defineProperties, H = Object.getOwnPropertyDescriptors, w = Object.getOwnPropertySymbols, B = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable, T = (o, e, t) => e in o ? U(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, p = (o, e) => {
3
+ for (var t in e || (e = {}))
4
+ B.call(e, t) && T(o, t, e[t]);
5
+ if (w)
6
+ for (var t of w(e))
7
+ q.call(e, t) && T(o, t, e[t]);
8
+ return o;
9
+ }, v = (o, e) => D(o, H(e));
10
+ let R = !1;
11
+ const P = [], V = (o) => new Promise((e, t) => {
12
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
14
13
  if (window.location === window.parent.location) {
15
14
  console.warn("You are not in Draft Mode or in the Visual Editor.");
16
15
  return;
17
16
  }
18
- _ ? s() : T.push(s);
17
+ R ? r() : P.push(r);
19
18
  }, document.getElementById("storyblok-javascript-bridge")))
20
19
  return;
21
- const r = document.createElement("script");
22
- r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
23
- T.forEach((o) => o()), _ = !0, t(s);
24
- }, document.getElementsByTagName("head")[0].appendChild(r);
25
- }), H = function(n, t) {
26
- if (!n)
27
- return null;
28
- let e = {};
29
- for (let r in n) {
30
- let s = n[r];
31
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
32
- }
33
- return e;
34
- }, J = (n) => n === "email";
35
- var Y = {
36
- nodes: {
37
- horizontal_rule() {
38
- return {
39
- singleTag: "hr"
40
- };
41
- },
42
- blockquote() {
43
- return {
44
- tag: "blockquote"
45
- };
46
- },
47
- bullet_list() {
48
- return {
49
- tag: "ul"
50
- };
51
- },
52
- code_block(n) {
53
- return {
54
- tag: [
55
- "pre",
56
- {
57
- tag: "code",
58
- attrs: n.attrs
59
- }
60
- ]
61
- };
62
- },
63
- hard_break() {
64
- return {
65
- singleTag: "br"
66
- };
67
- },
68
- heading(n) {
69
- return {
70
- tag: `h${n.attrs.level}`
71
- };
72
- },
73
- image(n) {
74
- return {
75
- singleTag: [
76
- {
77
- tag: "img",
78
- attrs: H(n.attrs, ["src", "alt", "title"])
79
- }
80
- ]
81
- };
82
- },
83
- list_item() {
84
- return {
85
- tag: "li"
86
- };
87
- },
88
- ordered_list() {
89
- return {
90
- tag: "ol"
91
- };
92
- },
93
- paragraph() {
94
- return {
95
- tag: "p"
96
- };
20
+ const s = document.createElement("script");
21
+ s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
22
+ P.forEach((n) => n()), R = !0, e(r);
23
+ }, document.getElementsByTagName("head")[0].appendChild(s);
24
+ });
25
+ var z = Object.defineProperty, J = (o, e, t) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, c = (o, e, t) => (J(o, typeof e != "symbol" ? e + "" : e, t), t);
26
+ function E(o) {
27
+ return !(o !== o || o === 1 / 0 || o === -1 / 0);
28
+ }
29
+ function F(o, e, t) {
30
+ if (!E(e))
31
+ throw new TypeError("Expected `limit` to be a finite number");
32
+ if (!E(t))
33
+ throw new TypeError("Expected `interval` to be a finite number");
34
+ const s = [];
35
+ let r = [], n = 0;
36
+ const a = function() {
37
+ n++;
38
+ const l = setTimeout(function() {
39
+ n--, s.length > 0 && a(), r = r.filter(function(u) {
40
+ return u !== l;
41
+ });
42
+ }, t);
43
+ r.indexOf(l) < 0 && r.push(l);
44
+ const h = s.shift();
45
+ h.resolve(o.apply(h.self, h.args));
46
+ }, i = function(...l) {
47
+ const h = this;
48
+ return new Promise(function(u, b) {
49
+ s.push({
50
+ resolve: u,
51
+ reject: b,
52
+ args: l,
53
+ self: h
54
+ }), n < e && a();
55
+ });
56
+ };
57
+ return i.abort = function() {
58
+ r.forEach(clearTimeout), r = [], s.forEach(function(l) {
59
+ l.reject(function() {
60
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
61
+ });
62
+ }), s.length = 0;
63
+ }, i;
64
+ }
65
+ const G = function(o, e) {
66
+ const t = {};
67
+ for (const s in o) {
68
+ const r = o[s];
69
+ e.indexOf(s) > -1 && r !== null && (t[s] = r);
70
+ }
71
+ return t;
72
+ }, Y = (o) => o === "email", K = () => ({
73
+ singleTag: "hr"
74
+ }), Q = () => ({
75
+ tag: "blockquote"
76
+ }), W = () => ({
77
+ tag: "ul"
78
+ }), X = (o) => ({
79
+ tag: [
80
+ "pre",
81
+ {
82
+ tag: "code",
83
+ attrs: o.attrs
84
+ }
85
+ ]
86
+ }), Z = () => ({
87
+ singleTag: "br"
88
+ }), ee = (o) => ({
89
+ tag: `h${o.attrs.level}`
90
+ }), te = (o) => ({
91
+ singleTag: [
92
+ {
93
+ tag: "img",
94
+ attrs: G(o.attrs, ["src", "alt", "title"])
97
95
  }
96
+ ]
97
+ }), se = () => ({
98
+ tag: "li"
99
+ }), re = () => ({
100
+ tag: "ol"
101
+ }), oe = () => ({
102
+ tag: "p"
103
+ }), ne = () => ({
104
+ tag: "b"
105
+ }), ie = () => ({
106
+ tag: "strike"
107
+ }), ae = () => ({
108
+ tag: "u"
109
+ }), le = () => ({
110
+ tag: "strong"
111
+ }), ce = () => ({
112
+ tag: "code"
113
+ }), he = () => ({
114
+ tag: "i"
115
+ }), ue = (o) => {
116
+ const e = p({}, o.attrs), { linktype: t = "url" } = o.attrs;
117
+ return Y(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
118
+ tag: [
119
+ {
120
+ tag: "a",
121
+ attrs: e
122
+ }
123
+ ]
124
+ };
125
+ }, pe = (o) => ({
126
+ tag: [
127
+ {
128
+ tag: "span",
129
+ attrs: o.attrs
130
+ }
131
+ ]
132
+ }), de = {
133
+ nodes: {
134
+ horizontal_rule: K,
135
+ blockquote: Q,
136
+ bullet_list: W,
137
+ code_block: X,
138
+ hard_break: Z,
139
+ heading: ee,
140
+ image: te,
141
+ list_item: se,
142
+ ordered_list: re,
143
+ paragraph: oe
98
144
  },
99
145
  marks: {
100
- bold() {
101
- return {
102
- tag: "b"
103
- };
104
- },
105
- strike() {
106
- return {
107
- tag: "strike"
108
- };
109
- },
110
- underline() {
111
- return {
112
- tag: "u"
113
- };
114
- },
115
- strong() {
116
- return {
117
- tag: "strong"
118
- };
119
- },
120
- code() {
121
- return {
122
- tag: "code"
123
- };
124
- },
125
- italic() {
126
- return {
127
- tag: "i"
128
- };
129
- },
130
- link(n) {
131
- const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
132
- return J(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
133
- tag: [
134
- {
135
- tag: "a",
136
- attrs: t
137
- }
138
- ]
139
- };
140
- },
141
- styled(n) {
142
- return {
143
- tag: [
144
- {
145
- tag: "span",
146
- attrs: n.attrs
147
- }
148
- ]
149
- };
150
- }
151
- }
152
- };
153
- const F = function(n) {
154
- const t = {
146
+ bold: ne,
147
+ strike: ie,
148
+ underline: ae,
149
+ strong: le,
150
+ code: ce,
151
+ italic: he,
152
+ link: ue,
153
+ styled: pe
154
+ }
155
+ }, ge = function(o) {
156
+ const e = {
155
157
  "&": "&amp;",
156
158
  "<": "&lt;",
157
159
  ">": "&gt;",
158
160
  '"': "&quot;",
159
161
  "'": "&#39;"
160
- }, e = /[&<>"']/g, r = RegExp(e.source);
161
- return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
162
+ }, t = /[&<>"']/g, s = RegExp(t.source);
163
+ return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
162
164
  };
163
- class R {
164
- constructor(t) {
165
- t || (t = Y), this.marks = t.marks || [], this.nodes = t.nodes || [];
166
- }
167
- addNode(t, e) {
168
- this.nodes[t] = e;
169
- }
170
- addMark(t, e) {
171
- this.marks[t] = e;
172
- }
173
- render(t = {}) {
174
- if (t.content && Array.isArray(t.content)) {
175
- let e = "";
176
- return t.content.forEach((r) => {
177
- e += this.renderNode(r);
178
- }), e;
165
+ class y {
166
+ constructor(e) {
167
+ c(this, "marks"), c(this, "nodes"), e || (e = de), this.marks = e.marks || [], this.nodes = e.nodes || [];
168
+ }
169
+ addNode(e, t) {
170
+ this.nodes[e] = t;
171
+ }
172
+ addMark(e, t) {
173
+ this.marks[e] = t;
174
+ }
175
+ render(e) {
176
+ if (e && e.content && Array.isArray(e.content)) {
177
+ let t = "";
178
+ return e.content.forEach((s) => {
179
+ t += this.renderNode(s);
180
+ }), t;
179
181
  }
180
182
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
181
183
  }
182
- renderNode(t) {
183
- let e = [];
184
- t.marks && t.marks.forEach((s) => {
185
- const o = this.getMatchingMark(s);
186
- o && e.push(this.renderOpeningTag(o.tag));
184
+ renderNode(e) {
185
+ const t = [];
186
+ e.marks && e.marks.forEach((r) => {
187
+ const n = this.getMatchingMark(r);
188
+ n && t.push(this.renderOpeningTag(n.tag));
187
189
  });
188
- const r = this.getMatchingNode(t);
189
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
190
- e.push(this.renderNode(s));
191
- }) : t.text ? e.push(F(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((s) => {
192
- const o = this.getMatchingMark(s);
193
- o && e.push(this.renderClosingTag(o.tag));
194
- }), e.join("");
195
- }
196
- renderTag(t, e) {
197
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
190
+ const s = this.getMatchingNode(e);
191
+ return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
192
+ t.push(this.renderNode(r));
193
+ }) : e.text ? t.push(ge(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html && t.push(s.html), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
194
+ const n = this.getMatchingMark(r);
195
+ n && t.push(this.renderClosingTag(n.tag));
196
+ }), t.join("");
197
+ }
198
+ renderTag(e, t) {
199
+ return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
198
200
  if (s.constructor === String)
199
- return `<${s}${e}>`;
201
+ return `<${s}${t}>`;
200
202
  {
201
- let o = `<${s.tag}`;
203
+ let r = `<${s.tag}`;
202
204
  if (s.attrs)
203
- for (let a in s.attrs) {
204
- let i = s.attrs[a];
205
- i !== null && (o += ` ${a}="${i}"`);
205
+ for (const n in s.attrs) {
206
+ const a = s.attrs[n];
207
+ a !== null && (r += ` ${n}="${a}"`);
206
208
  }
207
- return `${o}${e}>`;
209
+ return `${r}${t}>`;
208
210
  }
209
211
  }).join("");
210
212
  }
211
- renderOpeningTag(t) {
212
- return this.renderTag(t, "");
213
+ renderOpeningTag(e) {
214
+ return this.renderTag(e, "");
213
215
  }
214
- renderClosingTag(t) {
215
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
216
+ renderClosingTag(e) {
217
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
216
218
  }
217
- getMatchingNode(t) {
218
- if (typeof this.nodes[t.type] == "function")
219
- return this.nodes[t.type](t);
219
+ getMatchingNode(e) {
220
+ const t = this.nodes[e.type];
221
+ if (typeof t == "function")
222
+ return t(e);
220
223
  }
221
- getMatchingMark(t) {
222
- if (typeof this.marks[t.type] == "function")
223
- return this.marks[t.type](t);
224
+ getMatchingMark(e) {
225
+ const t = this.marks[e.type];
226
+ if (typeof t == "function")
227
+ return t(e);
224
228
  }
225
229
  }
226
- /*!
227
- * storyblok-js-client v4.5.2
228
- * Universal JavaScript SDK for Storyblok's API
229
- * (c) 2020-2022 Stobylok Team
230
- */
231
- function w(n) {
232
- return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
233
- }
234
- function $(n, t, e) {
235
- if (!w(t))
236
- throw new TypeError("Expected `limit` to be a finite number");
237
- if (!w(e))
238
- throw new TypeError("Expected `interval` to be a finite number");
239
- var r = [], s = [], o = 0, a = function() {
240
- o++;
241
- var c = setTimeout(function() {
242
- o--, r.length > 0 && a(), s = s.filter(function(u) {
243
- return u !== c;
244
- });
245
- }, e);
246
- s.indexOf(c) < 0 && s.push(c);
247
- var l = r.shift();
248
- l.resolve(n.apply(l.self, l.args));
249
- }, i = function() {
250
- var c = arguments, l = this;
251
- return new Promise(function(u, p) {
252
- r.push({ resolve: u, reject: p, args: c, self: l }), o < t && a();
253
- });
254
- };
255
- return i.abort = function() {
256
- s.forEach(clearTimeout), s = [], r.forEach(function(c) {
257
- c.reject(new throttle.AbortError());
258
- }), r.length = 0;
259
- }, i;
260
- }
261
- $.AbortError = function() {
262
- Error.call(this, "Throttled function aborted"), this.name = "AbortError";
263
- };
264
- const K = function(n, t) {
265
- if (!n)
266
- return null;
267
- let e = {};
268
- for (let r in n) {
269
- let s = n[r];
270
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
271
- }
272
- return e;
273
- };
274
- var G = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: K(n.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(n) {
275
- const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
276
- return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
277
- }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
278
- class Q {
279
- constructor(t) {
280
- t || (t = G), this.marks = t.marks || [], this.nodes = t.nodes || [];
281
- }
282
- addNode(t, e) {
283
- this.nodes[t] = e;
284
- }
285
- addMark(t, e) {
286
- this.marks[t] = e;
287
- }
288
- render(t = {}) {
289
- if (t.content && Array.isArray(t.content)) {
290
- let e = "";
291
- return t.content.forEach((r) => {
292
- e += this.renderNode(r);
293
- }), e;
230
+ class O {
231
+ constructor() {
232
+ c(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), c(this, "getOptionsPage", (e, t = 25, s = 1) => v(p({}, e), {
233
+ per_page: t,
234
+ page: s
235
+ })), 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) => {
236
+ const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
237
+ return this.arrayFrom(s, (n, a) => a * r + e);
238
+ }), c(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), c(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []));
239
+ }
240
+ stringify(e, t, s) {
241
+ const r = [];
242
+ for (const n in e) {
243
+ if (!Object.prototype.hasOwnProperty.call(e, n))
244
+ continue;
245
+ const a = e[n], i = s ? "" : encodeURIComponent(n);
246
+ let l;
247
+ typeof a == "object" ? l = this.stringify(a, t ? t + encodeURIComponent("[" + i + "]") : i, Array.isArray(a)) : l = (t ? t + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(a), r.push(l);
294
248
  }
295
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
249
+ return r.join("&");
296
250
  }
297
- renderNode(t) {
298
- let e = [];
299
- t.marks && t.marks.forEach((s) => {
300
- const o = this.getMatchingMark(s);
301
- o && e.push(this.renderOpeningTag(o.tag));
302
- });
303
- const r = this.getMatchingNode(t);
304
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
305
- e.push(this.renderNode(s));
306
- }) : t.text ? e.push(function(s) {
307
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
308
- return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
309
- }(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((s) => {
310
- const o = this.getMatchingMark(s);
311
- o && e.push(this.renderClosingTag(o.tag));
312
- }), e.join("");
313
- }
314
- renderTag(t, e) {
315
- return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
316
- if (r.constructor === String)
317
- return `<${r}${e}>`;
318
- {
319
- let s = `<${r.tag}`;
320
- if (r.attrs)
321
- for (let o in r.attrs) {
322
- let a = r.attrs[o];
323
- a !== null && (s += ` ${o}="${a}"`);
324
- }
325
- return `${s}${e}>`;
326
- }
327
- }).join("");
251
+ }
252
+ var g = /* @__PURE__ */ ((o) => (o.GET = "get", o.DELETE = "delete", o.POST = "post", o.PUT = "put", o))(g || {});
253
+ class fe {
254
+ constructor(e) {
255
+ c(this, "baseURL"), c(this, "timeout"), c(this, "headers"), c(this, "responseInterceptor"), c(this, "ejectInterceptor"), c(this, "url"), c(this, "parameters"), this.baseURL = e.baseURL, this.timeout = e.timeout ? e.timeout * 1e3 : 1e3, this.headers = e.headers || [], this.responseInterceptor = e.responseInterceptor, this.ejectInterceptor = !1, this.url = "", this.parameters = {};
256
+ }
257
+ get(e, t) {
258
+ return this.url = e, this.parameters = t, this._methodHandler(g.GET);
259
+ }
260
+ post(e, t) {
261
+ return this.url = e, this.parameters = t, this._methodHandler(g.POST);
262
+ }
263
+ put(e, t) {
264
+ return this.url = e, this.parameters = t, this._methodHandler(g.PUT);
328
265
  }
329
- renderOpeningTag(t) {
330
- return this.renderTag(t, "");
266
+ delete(e, t) {
267
+ return this.url = e, this.parameters = t, this._methodHandler(g.DELETE);
331
268
  }
332
- renderClosingTag(t) {
333
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
269
+ async _responseHandler(e) {
270
+ const t = [], s = {
271
+ data: {},
272
+ headers: {},
273
+ status: 0,
274
+ statusText: ""
275
+ };
276
+ await e.json().then((r) => {
277
+ s.data = r;
278
+ });
279
+ for (const r of e.headers.entries())
280
+ t[r[0]] = r[1];
281
+ return s.headers = p({}, t), s.status = e.status, s.statusText = e.statusText, s;
282
+ }
283
+ async _methodHandler(e) {
284
+ const t = new URL(`${this.baseURL}${this.url}`);
285
+ let s = null;
286
+ if (e === "get") {
287
+ const i = new O();
288
+ t.search = i.stringify(this.parameters);
289
+ } else
290
+ s = JSON.stringify(this.parameters);
291
+ const r = new AbortController(), { signal: n } = r, a = setTimeout(() => r.abort(), this.timeout);
292
+ try {
293
+ const i = await fetch(`${t}`, {
294
+ method: e,
295
+ headers: this.headers,
296
+ body: s,
297
+ signal: n
298
+ });
299
+ clearTimeout(a);
300
+ const l = await this._responseHandler(i);
301
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
302
+ } catch (i) {
303
+ return i;
304
+ }
334
305
  }
335
- getMatchingNode(t) {
336
- if (typeof this.nodes[t.type] == "function")
337
- return this.nodes[t.type](t);
306
+ eject() {
307
+ this.ejectInterceptor = !0;
338
308
  }
339
- getMatchingMark(t) {
340
- if (typeof this.marks[t.type] == "function")
341
- return this.marks[t.type](t);
309
+ _statusHandler(e) {
310
+ if (/20[01]/g.test(`${e.status}`))
311
+ return e;
312
+ throw {
313
+ message: new Error(e.statusText || `status: ${e.status}`),
314
+ response: e
315
+ };
342
316
  }
343
317
  }
344
- const W = (n = 0, t = n) => {
345
- const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
346
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
347
- }, k = (n, t, e) => {
348
- const r = [];
349
- for (const s in n) {
350
- if (!Object.prototype.hasOwnProperty.call(n, s))
351
- continue;
352
- const o = n[s], a = e ? "" : encodeURIComponent(s);
353
- let i;
354
- i = typeof o == "object" ? k(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
355
- }
356
- return r.join("&");
357
- };
358
- let f = {}, d = {};
359
- class X {
360
- constructor(t, e) {
361
- if (!e) {
362
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
363
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
318
+ let m = {};
319
+ const d = {};
320
+ class me {
321
+ constructor(e, t) {
322
+ if (c(this, "client"), c(this, "maxRetries"), c(this, "throttle"), c(this, "accessToken"), c(this, "cache"), c(this, "helpers"), c(this, "relations"), c(this, "links"), c(this, "richTextResolver"), c(this, "resolveNestedRelations"), !t) {
323
+ const n = e.region ? `-${e.region}` : "", a = e.https === !1 ? "http" : "https";
324
+ e.oauthToken ? t = `${a}://api${n}.storyblok.com/v1` : t = `${a}://api${n}.storyblok.com/v2`;
364
325
  }
365
- let r = Object.assign({}, t.headers), s = 5;
366
- t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new Q(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = q.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
367
- }
368
- setComponentResolver(t) {
369
- this.richTextResolver.addNode("blok", (e) => {
370
- let r = "";
371
- return e.attrs.body.forEach((s) => {
372
- r += t(s.component, s);
373
- }), { html: r };
326
+ const s = Object.assign({}, e.headers);
327
+ let r = 5;
328
+ e.oauthToken && (s.Authorization = e.oauthToken, r = 3), e.rateLimit && (r = e.rateLimit), e.richTextSchema ? this.richTextResolver = new y(e.richTextSchema) : this.richTextResolver = new y(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = F(this.throttledRequest, r, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new O(), this.resolveNestedRelations = !1, this.client = new fe({
329
+ baseURL: t,
330
+ timeout: e.timeout || 0,
331
+ headers: s,
332
+ responseInterceptor: e.responseInterceptor
374
333
  });
375
334
  }
376
- parseParams(t = {}) {
377
- return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
335
+ setComponentResolver(e) {
336
+ this.richTextResolver.addNode("blok", (t) => {
337
+ let s = "";
338
+ return t.attrs.body.forEach((r) => {
339
+ s += e(r.component, r);
340
+ }), {
341
+ html: s
342
+ };
343
+ });
378
344
  }
379
- factoryParamOptions(t, e = {}) {
380
- return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
345
+ parseParams(e) {
346
+ return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = d[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
381
347
  }
382
- makeRequest(t, e, r, s) {
383
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(h({}, a), { per_page: i, page: c }))(e, r, s));
384
- return this.cacheResponse(t, o);
348
+ factoryParamOptions(e, t) {
349
+ return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
385
350
  }
386
- get(t, e) {
387
- let r = `/${t}`;
388
- const s = this.factoryParamOptions(r, e);
389
- return this.cacheResponse(r, s);
351
+ makeRequest(e, t, s, r) {
352
+ const n = this.factoryParamOptions(e, this.helpers.getOptionsPage(t, s, r));
353
+ return this.cacheResponse(e, n);
390
354
  }
391
- async getAll(t, e = {}, r) {
392
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
393
- r = r || a[a.length - 1];
394
- const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
395
- return ((l = [], u) => l.map(u).reduce((p, O) => [...p, ...O], []))([i, ...await (async (l = [], u) => Promise.all(l.map(u)))(W(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
355
+ get(e, t) {
356
+ t || (t = {});
357
+ const s = `/${e}`, r = this.factoryParamOptions(s, t);
358
+ return this.cacheResponse(s, r);
396
359
  }
397
- post(t, e) {
398
- let r = `/${t}`;
399
- return this.throttle("post", r, e);
360
+ async getAll(e, t, s) {
361
+ const r = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, a = n.split("/"), i = s || a[a.length - 1], l = 1, h = await this.makeRequest(n, t, r, l), u = h.total ? Math.ceil(h.total / r) : 1, b = await this.helpers.asyncMap(this.helpers.range(l, u), (k) => this.makeRequest(n, t, r, k + 1));
362
+ return this.helpers.flatMap([h, ...b], (k) => Object.values(k.data[i]));
400
363
  }
401
- put(t, e) {
402
- let r = `/${t}`;
403
- return this.throttle("put", r, e);
364
+ post(e, t) {
365
+ const s = `/${e}`;
366
+ return Promise.resolve(this.throttle("post", s, t));
404
367
  }
405
- delete(t, e) {
406
- let r = `/${t}`;
407
- return this.throttle("delete", r, e);
368
+ put(e, t) {
369
+ const s = `/${e}`;
370
+ return Promise.resolve(this.throttle("put", s, t));
408
371
  }
409
- getStories(t) {
410
- return this.get("cdn/stories", t);
372
+ delete(e, t) {
373
+ const s = `/${e}`;
374
+ return Promise.resolve(this.throttle("delete", s, t));
411
375
  }
412
- getStory(t, e) {
413
- return this.get(`cdn/stories/${t}`, e);
376
+ getStories(e) {
377
+ return this.get("cdn/stories", e);
414
378
  }
415
- setToken(t) {
416
- this.accessToken = t;
379
+ getStory(e, t) {
380
+ return this.get(`cdn/stories/${e}`, t);
417
381
  }
418
382
  getToken() {
419
383
  return this.accessToken;
420
384
  }
421
- _cleanCopy(t) {
422
- return JSON.parse(JSON.stringify(t));
423
- }
424
- _insertLinks(t, e) {
425
- const r = t[e];
426
- 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]));
427
- }
428
- _insertRelations(t, e, r) {
429
- if (r.indexOf(t.component + "." + e) > -1) {
430
- if (typeof t[e] == "string")
431
- this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
432
- else if (t[e].constructor === Array) {
433
- let s = [];
434
- t[e].forEach((o) => {
435
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
436
- }), t[e] = s;
385
+ ejectInterceptor() {
386
+ this.client.eject();
387
+ }
388
+ _cleanCopy(e) {
389
+ return JSON.parse(JSON.stringify(e));
390
+ }
391
+ _insertLinks(e, t) {
392
+ const s = e[t];
393
+ s && s.fieldtype == "multilink" && s.linktype == "story" && typeof s.id == "string" && this.links[s.id] ? s.story = this._cleanCopy(this.links[s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[s.uuid] && (s.story = this._cleanCopy(this.links[s.uuid]));
394
+ }
395
+ _insertRelations(e, t, s) {
396
+ if (s.indexOf(`${e.component}.${t}`) > -1) {
397
+ if (typeof e[t] == "string")
398
+ this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
399
+ else if (e[t] && e[t].constructor === Array) {
400
+ const r = [];
401
+ e[t].forEach((n) => {
402
+ this.relations[n] && r.push(this._cleanCopy(this.relations[n]));
403
+ }), e[t] = r;
437
404
  }
438
405
  }
439
406
  }
440
- _insertAssetsRelations(t, e) {
441
- e.forEach((r) => {
442
- t.id === r.id && (t.original = r, 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);
443
- });
444
- }
445
- iterateTree(t, e) {
446
- let r = (s) => {
447
- if (s != null) {
448
- if (s.constructor === Array)
449
- for (let o = 0; o < s.length; o++)
450
- r(s[o]);
451
- else if (s.constructor === Object) {
452
- if (s._stopResolving)
407
+ iterateTree(e, t) {
408
+ const s = (r) => {
409
+ if (r != null) {
410
+ if (r.constructor === Array)
411
+ for (let n = 0; n < r.length; n++)
412
+ s(r[n]);
413
+ else if (r.constructor === Object) {
414
+ if (r._stopResolving)
453
415
  return;
454
- for (let o in s)
455
- 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), r(s[o]);
416
+ for (const n in r)
417
+ (r.component && r._uid || r.type === "link") && (this._insertRelations(r, n, t), this._insertLinks(r, n)), s(r[n]);
456
418
  }
457
419
  }
458
420
  };
459
- r(t.content);
460
- }
461
- async resolveLinks(t, e) {
462
- let r = [];
463
- if (t.link_uuids) {
464
- const s = t.link_uuids.length;
465
- let o = [];
466
- const a = 50;
467
- for (let i = 0; i < s; i += a) {
468
- const c = Math.min(s, i + a);
469
- o.push(t.link_uuids.slice(i, c));
421
+ s(e.content);
422
+ }
423
+ async resolveLinks(e, t) {
424
+ let s = [];
425
+ if (e.link_uuids) {
426
+ const r = e.link_uuids.length, n = [], a = 50;
427
+ for (let i = 0; i < r; i += a) {
428
+ const l = Math.min(r, i + a);
429
+ n.push(e.link_uuids.slice(i, l));
470
430
  }
471
- for (let i = 0; i < o.length; i++)
472
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
473
- r.push(c);
431
+ for (let i = 0; i < n.length; i++)
432
+ (await this.getStories({
433
+ per_page: a,
434
+ language: t.language,
435
+ version: t.version,
436
+ by_uuids: n[i].join(",")
437
+ })).data.stories.forEach((l) => {
438
+ s.push(l);
474
439
  });
475
440
  } else
476
- r = t.links;
477
- r.forEach((s) => {
478
- this.links[s.uuid] = y(h({}, s), { _stopResolving: !0 });
441
+ s = e.links;
442
+ s.forEach((r) => {
443
+ this.links[r.uuid] = v(p({}, r), { _stopResolving: !0 });
479
444
  });
480
445
  }
481
- async resolveRelations(t, e) {
482
- let r = [];
483
- if (t.rel_uuids) {
484
- const s = t.rel_uuids.length;
485
- let o = [];
486
- const a = 50;
487
- for (let i = 0; i < s; i += a) {
488
- const c = Math.min(s, i + a);
489
- o.push(t.rel_uuids.slice(i, c));
446
+ async resolveRelations(e, t) {
447
+ let s = [];
448
+ if (e.rel_uuids) {
449
+ const r = e.rel_uuids.length, n = [], a = 50;
450
+ for (let i = 0; i < r; i += a) {
451
+ const l = Math.min(r, i + a);
452
+ n.push(e.rel_uuids.slice(i, l));
490
453
  }
491
- for (let i = 0; i < o.length; i++)
492
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
493
- r.push(c);
454
+ for (let i = 0; i < n.length; i++)
455
+ (await this.getStories({
456
+ per_page: a,
457
+ language: t.language,
458
+ version: t.version,
459
+ by_uuids: n[i].join(",")
460
+ })).data.stories.forEach((l) => {
461
+ s.push(l);
494
462
  });
495
463
  } else
496
- r = t.rels;
497
- r.forEach((s) => {
498
- this.relations[s.uuid] = y(h({}, s), { _stopResolving: !0 });
464
+ s = e.rels;
465
+ s && s.length > 0 && s.forEach((r) => {
466
+ this.relations[r.uuid] = v(p({}, r), { _stopResolving: !0 });
499
467
  });
500
468
  }
501
- async resolveStories(t, e) {
502
- let r = [];
503
- if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = 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)
504
- for (const s in this.relations)
505
- this.iterateTree(this.relations[s], r);
506
- t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
507
- this.iterateTree(s, r);
469
+ async resolveStories(e, t) {
470
+ var s, r;
471
+ let n = [];
472
+ if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (n = t.resolve_relations.split(","), await this.resolveRelations(e, t)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && (((s = e.links) == null ? void 0 : s.length) || ((r = e.link_uuids) == null ? void 0 : r.length)) && await this.resolveLinks(e, t), this.resolveNestedRelations)
473
+ for (const a in this.relations)
474
+ this.iterateTree(this.relations[a], n);
475
+ e.story ? this.iterateTree(e.story, n) : e.stories.forEach((a) => {
476
+ this.iterateTree(a, n);
508
477
  });
509
478
  }
510
- resolveAssetsRelations(t) {
511
- const { assets: e, stories: r, story: s } = t;
512
- if (r)
513
- for (const o of r)
514
- this.iterateTree(o, e);
515
- else {
516
- if (!s)
517
- return t;
518
- this.iterateTree(s, e);
519
- }
520
- }
521
- cacheResponse(t, e, r) {
522
- return r === void 0 && (r = 0), new Promise(async (s, o) => {
523
- let a = k({ url: t, params: e }), i = this.cacheProvider();
524
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
525
- const l = await i.get(a);
479
+ cacheResponse(e, t, s) {
480
+ return new Promise((r, n) => {
481
+ const a = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
482
+ if (this.cache.clear === "auto" && t.version === "draft" && this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
483
+ const l = i.get(a);
526
484
  if (l)
527
- return s(l);
485
+ return r(l);
528
486
  }
529
487
  try {
530
- let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => k(p) }), u = { data: l.data, headers: l.headers };
531
- if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), l.headers["per-page"] && (u = Object.assign({}, u, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
532
- return o(l);
533
- (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" && d[e.token] != u.data.cv && this.flushCache(), d[e.token] = u.data.cv), s(u);
534
- } catch (l) {
535
- if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
536
- return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(o);
537
- o(l);
488
+ (async () => {
489
+ var l;
490
+ const h = await this.throttle("get", e, t);
491
+ let u = { data: h.data, headers: h.headers };
492
+ if ((l = h.headers) != null && l["per-page"] && (u = Object.assign({}, u, {
493
+ perPage: h.headers["per-page"] ? parseInt(h.headers["per-page"]) : 0,
494
+ total: h.headers["per-page"] ? parseInt(h.headers.total) : 0
495
+ })), h.status != 200)
496
+ return n(h);
497
+ (u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && i.set(a, u), u.data.cv && t.token && (t.version == "draft" && d[t.token] != u.data.cv && this.flushCache(), d[t.token] = u.data.cv), r(u);
498
+ })();
499
+ } catch {
538
500
  }
539
- var c;
540
501
  });
541
502
  }
542
- throttledRequest(t, e, r) {
543
- return this.client[t](e, r);
503
+ throttledRequest(e, t, s) {
504
+ return this.client[e](t, s);
544
505
  }
545
506
  cacheVersions() {
546
507
  return d;
@@ -548,145 +509,161 @@ class X {
548
509
  cacheVersion() {
549
510
  return d[this.accessToken];
550
511
  }
551
- setCacheVersion(t) {
552
- this.accessToken && (d[this.accessToken] = t);
512
+ setCacheVersion(e) {
513
+ this.accessToken && (d[this.accessToken] = e);
553
514
  }
554
515
  cacheProvider() {
555
- return this.cache.type === "memory" ? { get: (t) => f[t], getAll: () => f, set(t, e) {
556
- f[t] = e;
557
- }, flush() {
558
- f = {};
559
- } } : { get() {
560
- }, getAll() {
561
- }, set() {
562
- }, flush() {
563
- } };
564
- }
565
- async flushCache() {
566
- return await this.cacheProvider().flush(), this;
516
+ switch (this.cache.type) {
517
+ case "memory":
518
+ return {
519
+ get(e) {
520
+ return m[e];
521
+ },
522
+ getAll() {
523
+ return m;
524
+ },
525
+ set(e, t) {
526
+ m[e] = t;
527
+ },
528
+ flush() {
529
+ m = {};
530
+ }
531
+ };
532
+ default:
533
+ return {
534
+ get() {
535
+ },
536
+ getAll() {
537
+ },
538
+ set() {
539
+ },
540
+ flush() {
541
+ }
542
+ };
543
+ }
544
+ }
545
+ flushCache() {
546
+ return this.cacheProvider().flush(), this;
567
547
  }
568
548
  }
569
- const at = (n = {}) => {
570
- const { apiOptions: t } = n;
571
- if (!t.accessToken) {
549
+ const Re = (o = {}) => {
550
+ const { apiOptions: e } = o;
551
+ if (!e.accessToken) {
572
552
  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");
573
553
  return;
574
554
  }
575
- return { storyblokApi: new X(t) };
555
+ return { storyblokApi: new me(e) };
576
556
  };
577
- var Z = (n) => {
578
- if (typeof n != "object" || typeof n._editable > "u")
557
+ var ye = (o) => {
558
+ if (typeof o != "object" || typeof o._editable > "u")
579
559
  return {};
580
- const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
560
+ const e = JSON.parse(o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
581
561
  return {
582
- "data-blok-c": JSON.stringify(t),
583
- "data-blok-uid": t.id + "-" + t.uid
562
+ "data-blok-c": JSON.stringify(e),
563
+ "data-blok-uid": e.id + "-" + e.uid
584
564
  };
585
565
  };
586
- let m;
587
- const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (n, t, e = {}) => {
566
+ let _;
567
+ const be = "https://app.storyblok.com/f/storyblok-v2-latest.js", ke = (o, e, t = {}) => {
588
568
  if (!(typeof window > "u")) {
589
569
  if (typeof window.storyblokRegisterEvent > "u") {
590
570
  console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
591
571
  return;
592
572
  }
593
- if (!n) {
573
+ if (!o) {
594
574
  console.warn("Story ID is not defined. Please provide a valid ID.");
595
575
  return;
596
576
  }
597
577
  window.storyblokRegisterEvent(() => {
598
- new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
599
- s.story.id === n && (s.action === "input" ? t(s.story) : window.location.reload());
578
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (r) => {
579
+ r.action === "input" && r.story.id === o ? e(r.story) : (r.action === "change" || r.action === "published") && r.storyId === o && window.location.reload();
600
580
  });
601
581
  });
602
582
  }
603
- }, rt = (n = {}) => {
583
+ }, ve = (o = {}) => {
604
584
  const {
605
- bridge: t,
606
- accessToken: e,
607
- use: r = [],
608
- apiOptions: s = {},
609
- richText: o = {}
610
- } = n;
611
- s.accessToken = s.accessToken || e;
612
- const a = { bridge: t, apiOptions: s };
585
+ bridge: e,
586
+ accessToken: t,
587
+ use: s = [],
588
+ apiOptions: r = {},
589
+ richText: n = {}
590
+ } = o;
591
+ r.accessToken = r.accessToken || t;
592
+ const a = { bridge: e, apiOptions: r };
613
593
  let i = {};
614
- return r.forEach((c) => {
615
- i = h(h({}, i), c(a));
616
- }), t !== !1 && V(tt), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
617
- }, E = (n, t) => {
618
- n.addNode("blok", (e) => {
619
- let r = "";
620
- return e.attrs.body.forEach((s) => {
621
- r += t(s.component, s);
594
+ return s.forEach((l) => {
595
+ i = p(p({}, i), l(a));
596
+ }), e !== !1 && V(be), _ = new y(n.schema), n.resolver && $(_, n.resolver), i;
597
+ }, $ = (o, e) => {
598
+ o.addNode("blok", (t) => {
599
+ let s = "";
600
+ return t.attrs.body.forEach((r) => {
601
+ s += e(r.component, r);
622
602
  }), {
623
- html: r
603
+ html: s
624
604
  };
625
605
  });
626
- }, lt = (n, t) => {
627
- if (!m) {
606
+ }, Pe = (o, e, t) => {
607
+ let s = t || _;
608
+ if (!s) {
628
609
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
610
  return;
630
611
  }
631
- if (n === "")
632
- return "";
633
- if (!n)
634
- return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
612
+ return o === "" ? "" : o ? (e && (s = new y(e.schema), e.resolver && $(s, e.resolver)), s.render(o)) : (console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
635
613
 
636
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "";
637
- let e = m;
638
- return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(n);
639
- }, st = /* @__PURE__ */ P({
614
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
615
+ }, _e = /* @__PURE__ */ j({
640
616
  __name: "StoryblokComponent",
641
617
  props: {
642
618
  blok: null
643
619
  },
644
- setup(n) {
645
- return (t, e) => (j(), x(A(n.blok.component), C(M({ ...t.$props, ...t.$attrs })), null, 16));
646
- }
647
- }), nt = {
648
- beforeMount(n, t) {
649
- if (t.value) {
650
- const e = Z(t.value);
651
- n.setAttribute("data-blok-c", e["data-blok-c"]), n.setAttribute("data-blok-uid", e["data-blok-uid"]), n.classList.add("storyblok__outline");
620
+ setup(o) {
621
+ return (e, t) => (x(), C(I(o.blok.component), A(M({ ...e.$props, ...e.$attrs })), null, 16));
622
+ }
623
+ }), we = {
624
+ beforeMount(o, e) {
625
+ if (e.value) {
626
+ const t = ye(e.value);
627
+ o.setAttribute("data-blok-c", t["data-blok-c"]), o.setAttribute("data-blok-uid", t["data-blok-uid"]), o.classList.add("storyblok__outline");
652
628
  }
653
629
  }
654
- }, S = (n) => {
655
- console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
630
+ }, S = (o) => {
631
+ console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
656
632
  `);
657
633
  };
658
- let g = null;
659
- const ct = () => (g || S("useStoryblokApi"), g), ut = async (n, t = {}, e = {}) => {
660
- const r = N(null);
661
- if (I(() => {
662
- r.value && r.value.id && et(
663
- r.value.id,
664
- (s) => r.value = s,
665
- e
666
- );
667
- }), g) {
668
- const { data: s } = await g.get(
669
- `cdn/stories/${n}`,
634
+ let f = null;
635
+ const Ee = () => (f || S("useStoryblokApi"), f), Oe = async (o, e = {}, t = {}) => {
636
+ const s = N(null);
637
+ if (L(() => {
638
+ s.value && s.value.id && ke(
639
+ s.value.id,
640
+ (r) => s.value = r,
670
641
  t
671
642
  );
672
- r.value = s.story;
643
+ }), f) {
644
+ const { data: r } = await f.get(
645
+ `cdn/stories/${o}`,
646
+ e
647
+ );
648
+ s.value = r.story;
673
649
  } else
674
650
  S("useStoryblok");
675
- return r;
676
- }, ht = {
677
- install(n, t = {}) {
678
- n.directive("editable", nt), n.component("StoryblokComponent", st);
679
- const { storyblokApi: e } = rt(t);
680
- g = e;
651
+ return s;
652
+ }, $e = {
653
+ install(o, e = {}) {
654
+ o.directive("editable", we), o.component("StoryblokComponent", _e);
655
+ const { storyblokApi: t } = ve(e);
656
+ f = t;
681
657
  }
682
658
  };
683
659
  export {
684
- Y as RichTextSchema,
685
- st as StoryblokComponent,
686
- ht as StoryblokVue,
687
- at as apiPlugin,
688
- lt as renderRichText,
689
- ut as useStoryblok,
690
- ct as useStoryblokApi,
691
- et as useStoryblokBridge
660
+ y as RichTextResolver,
661
+ de as RichTextSchema,
662
+ _e as StoryblokComponent,
663
+ $e as StoryblokVue,
664
+ Re as apiPlugin,
665
+ Pe as renderRichText,
666
+ Oe as useStoryblok,
667
+ Ee as useStoryblokApi,
668
+ ke as useStoryblokBridge
692
669
  };