@storyblok/js 4.2.4 → 4.2.7
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.
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +516 -795
- package/package.json +3 -3
package/dist/storyblok-js.mjs
CHANGED
@@ -4,625 +4,346 @@
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
5
5
|
* author: undefined
|
6
6
|
*/
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
return
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
return !0;
|
22
|
-
switch (t) {
|
23
|
-
case 9:
|
24
|
-
// \t
|
25
|
-
case 10:
|
26
|
-
// \n
|
27
|
-
case 11:
|
28
|
-
// \v
|
29
|
-
case 12:
|
30
|
-
// \f
|
31
|
-
case 13:
|
32
|
-
// \r
|
33
|
-
case 32:
|
34
|
-
case 160:
|
35
|
-
case 5760:
|
36
|
-
case 8239:
|
37
|
-
case 8287:
|
38
|
-
case 12288:
|
39
|
-
return !0;
|
40
|
-
}
|
41
|
-
return !1;
|
42
|
-
}
|
43
|
-
function q(t) {
|
44
|
-
return Dt.test(t) || dt.test(t);
|
45
|
-
}
|
46
|
-
function J(t) {
|
47
|
-
switch (t) {
|
48
|
-
case 33:
|
49
|
-
case 34:
|
50
|
-
case 35:
|
51
|
-
case 36:
|
52
|
-
case 37:
|
53
|
-
case 38:
|
54
|
-
case 39:
|
55
|
-
case 40:
|
56
|
-
case 41:
|
57
|
-
case 42:
|
58
|
-
case 43:
|
59
|
-
case 44:
|
60
|
-
case 45:
|
61
|
-
case 46:
|
62
|
-
case 47:
|
63
|
-
case 58:
|
64
|
-
case 59:
|
65
|
-
case 60:
|
66
|
-
case 61:
|
67
|
-
case 62:
|
68
|
-
case 63:
|
69
|
-
case 64:
|
70
|
-
case 91:
|
71
|
-
case 92:
|
72
|
-
case 93:
|
73
|
-
case 94:
|
74
|
-
case 95:
|
75
|
-
case 96:
|
76
|
-
case 123:
|
77
|
-
case 124:
|
78
|
-
case 125:
|
79
|
-
case 126:
|
80
|
-
return !0;
|
81
|
-
default:
|
82
|
-
return !1;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
function x(t, e, s) {
|
86
|
-
this.type = t, this.tag = e, this.attrs = null, this.map = null, this.nesting = s, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
87
|
-
}
|
88
|
-
x.prototype.attrIndex = function(e) {
|
89
|
-
if (!this.attrs)
|
90
|
-
return -1;
|
91
|
-
const s = this.attrs;
|
92
|
-
for (let r = 0, u = s.length; r < u; r++)
|
93
|
-
if (s[r][0] === e)
|
94
|
-
return r;
|
95
|
-
return -1;
|
96
|
-
};
|
97
|
-
x.prototype.attrPush = function(e) {
|
98
|
-
this.attrs ? this.attrs.push(e) : this.attrs = [e];
|
99
|
-
};
|
100
|
-
x.prototype.attrSet = function(e, s) {
|
101
|
-
const r = this.attrIndex(e), u = [e, s];
|
102
|
-
r < 0 ? this.attrPush(u) : this.attrs[r] = u;
|
103
|
-
};
|
104
|
-
x.prototype.attrGet = function(e) {
|
105
|
-
const s = this.attrIndex(e);
|
106
|
-
let r = null;
|
107
|
-
return s >= 0 && (r = this.attrs[s][1]), r;
|
108
|
-
};
|
109
|
-
x.prototype.attrJoin = function(e, s) {
|
110
|
-
const r = this.attrIndex(e);
|
111
|
-
r < 0 ? this.attrPush([e, s]) : this.attrs[r][1] = this.attrs[r][1] + " " + s;
|
112
|
-
};
|
113
|
-
function ft(t, e, s) {
|
114
|
-
this.src = t, this.env = s, this.tokens = [], this.inlineMode = !1, this.md = e;
|
115
|
-
}
|
116
|
-
ft.prototype.Token = x;
|
117
|
-
function _(t, e, s, r) {
|
118
|
-
this.src = t, this.md = e, this.env = s, this.tokens = r, this.bMarks = [], this.eMarks = [], this.tShift = [], this.sCount = [], this.bsCount = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.ddIndent = -1, this.listIndent = -1, this.parentType = "root", this.level = 0;
|
119
|
-
const u = this.src;
|
120
|
-
for (let i = 0, o = 0, n = 0, a = 0, c = u.length, h = !1; o < c; o++) {
|
121
|
-
const D = u.charCodeAt(o);
|
122
|
-
if (!h)
|
123
|
-
if (O(D)) {
|
124
|
-
n++, D === 9 ? a += 4 - a % 4 : a++;
|
125
|
-
continue;
|
126
|
-
} else
|
127
|
-
h = !0;
|
128
|
-
(D === 10 || o === c - 1) && (D !== 10 && o++, this.bMarks.push(i), this.eMarks.push(o), this.tShift.push(n), this.sCount.push(a), this.bsCount.push(0), h = !1, n = 0, a = 0, i = o + 1);
|
129
|
-
}
|
130
|
-
this.bMarks.push(u.length), this.eMarks.push(u.length), this.tShift.push(0), this.sCount.push(0), this.bsCount.push(0), this.lineMax = this.bMarks.length - 1;
|
131
|
-
}
|
132
|
-
_.prototype.push = function(t, e, s) {
|
133
|
-
const r = new x(t, e, s);
|
134
|
-
return r.block = !0, s < 0 && this.level--, r.level = this.level, s > 0 && this.level++, this.tokens.push(r), r;
|
135
|
-
};
|
136
|
-
_.prototype.isEmpty = function(e) {
|
137
|
-
return this.bMarks[e] + this.tShift[e] >= this.eMarks[e];
|
138
|
-
};
|
139
|
-
_.prototype.skipEmptyLines = function(e) {
|
140
|
-
for (let s = this.lineMax; e < s && !(this.bMarks[e] + this.tShift[e] < this.eMarks[e]); e++)
|
141
|
-
;
|
142
|
-
return e;
|
143
|
-
};
|
144
|
-
_.prototype.skipSpaces = function(e) {
|
145
|
-
for (let s = this.src.length; e < s; e++) {
|
146
|
-
const r = this.src.charCodeAt(e);
|
147
|
-
if (!O(r))
|
148
|
-
break;
|
149
|
-
}
|
150
|
-
return e;
|
151
|
-
};
|
152
|
-
_.prototype.skipSpacesBack = function(e, s) {
|
153
|
-
if (e <= s)
|
154
|
-
return e;
|
155
|
-
for (; e > s; )
|
156
|
-
if (!O(this.src.charCodeAt(--e)))
|
157
|
-
return e + 1;
|
158
|
-
return e;
|
159
|
-
};
|
160
|
-
_.prototype.skipChars = function(e, s) {
|
161
|
-
for (let r = this.src.length; e < r && this.src.charCodeAt(e) === s; e++)
|
162
|
-
;
|
163
|
-
return e;
|
164
|
-
};
|
165
|
-
_.prototype.skipCharsBack = function(e, s, r) {
|
166
|
-
if (e <= r)
|
167
|
-
return e;
|
168
|
-
for (; e > r; )
|
169
|
-
if (s !== this.src.charCodeAt(--e))
|
170
|
-
return e + 1;
|
171
|
-
return e;
|
172
|
-
};
|
173
|
-
_.prototype.getLines = function(e, s, r, u) {
|
174
|
-
if (e >= s)
|
175
|
-
return "";
|
176
|
-
const i = new Array(s - e);
|
177
|
-
for (let o = 0, n = e; n < s; n++, o++) {
|
178
|
-
let a = 0;
|
179
|
-
const c = this.bMarks[n];
|
180
|
-
let h = c, D;
|
181
|
-
for (n + 1 < s || u ? D = this.eMarks[n] + 1 : D = this.eMarks[n]; h < D && a < r; ) {
|
182
|
-
const g = this.src.charCodeAt(h);
|
183
|
-
if (O(g))
|
184
|
-
g === 9 ? a += 4 - (a + this.bsCount[n]) % 4 : a++;
|
185
|
-
else if (h - c < this.tShift[n])
|
186
|
-
a++;
|
187
|
-
else
|
188
|
-
break;
|
189
|
-
h++;
|
190
|
-
}
|
191
|
-
a > r ? i[o] = new Array(a - r + 1).join(" ") + this.src.slice(h, D) : i[o] = this.src.slice(h, D);
|
192
|
-
}
|
193
|
-
return i.join("");
|
194
|
-
};
|
195
|
-
_.prototype.Token = x;
|
196
|
-
const Ft = [
|
197
|
-
"address",
|
198
|
-
"article",
|
199
|
-
"aside",
|
7
|
+
var re = Object.defineProperty;
|
8
|
+
var se = (e, t, s) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
9
|
+
var b = (e, t, s) => se(e, typeof t != "symbol" ? t + "" : t, s);
|
10
|
+
let w = /* @__PURE__ */ function(e) {
|
11
|
+
return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
|
12
|
+
}({}), S = /* @__PURE__ */ function(e) {
|
13
|
+
return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
|
14
|
+
}({}), ie = /* @__PURE__ */ function(e) {
|
15
|
+
return e.TEXT = "text", e;
|
16
|
+
}({}), C = /* @__PURE__ */ function(e) {
|
17
|
+
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
18
|
+
}({});
|
19
|
+
const ne = [
|
20
|
+
"area",
|
200
21
|
"base",
|
201
|
-
"
|
202
|
-
"blockquote",
|
203
|
-
"body",
|
204
|
-
"caption",
|
205
|
-
"center",
|
22
|
+
"br",
|
206
23
|
"col",
|
207
|
-
"
|
208
|
-
"dd",
|
209
|
-
"details",
|
210
|
-
"dialog",
|
211
|
-
"dir",
|
212
|
-
"div",
|
213
|
-
"dl",
|
214
|
-
"dt",
|
215
|
-
"fieldset",
|
216
|
-
"figcaption",
|
217
|
-
"figure",
|
218
|
-
"footer",
|
219
|
-
"form",
|
220
|
-
"frame",
|
221
|
-
"frameset",
|
222
|
-
"h1",
|
223
|
-
"h2",
|
224
|
-
"h3",
|
225
|
-
"h4",
|
226
|
-
"h5",
|
227
|
-
"h6",
|
228
|
-
"head",
|
229
|
-
"header",
|
24
|
+
"embed",
|
230
25
|
"hr",
|
231
|
-
"
|
232
|
-
"
|
233
|
-
"legend",
|
234
|
-
"li",
|
26
|
+
"img",
|
27
|
+
"input",
|
235
28
|
"link",
|
236
|
-
"
|
237
|
-
"menu",
|
238
|
-
"menuitem",
|
239
|
-
"nav",
|
240
|
-
"noframes",
|
241
|
-
"ol",
|
242
|
-
"optgroup",
|
243
|
-
"option",
|
244
|
-
"p",
|
29
|
+
"meta",
|
245
30
|
"param",
|
246
|
-
"
|
247
|
-
"section",
|
248
|
-
"summary",
|
249
|
-
"table",
|
250
|
-
"tbody",
|
251
|
-
"td",
|
252
|
-
"tfoot",
|
253
|
-
"th",
|
254
|
-
"thead",
|
255
|
-
"title",
|
256
|
-
"tr",
|
31
|
+
"source",
|
257
32
|
"track",
|
258
|
-
"
|
259
|
-
],
|
260
|
-
|
261
|
-
|
262
|
-
this.src = t, this.env = s, this.md = e, this.tokens = r, this.tokens_meta = Array(r.length), this.pos = 0, this.posMax = this.src.length, this.level = 0, this.pending = "", this.pendingLevel = 0, this.cache = {}, this.delimiters = [], this._prev_delimiters = [], this.backticks = {}, this.backticksScanned = !1, this.linkLevel = 0;
|
33
|
+
"wbr"
|
34
|
+
], oe = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), ae = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
35
|
+
function le(e) {
|
36
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
263
37
|
}
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
I.prototype.push = function(t, e, s) {
|
269
|
-
this.pending && this.pushPending();
|
270
|
-
const r = new x(t, e, s);
|
271
|
-
let u = null;
|
272
|
-
return s < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), r.level = this.level, s > 0 && (this.level++, this._prev_delimiters.push(this.delimiters), this.delimiters = [], u = { delimiters: this.delimiters }), this.pendingLevel = this.level, this.tokens.push(r), this.tokens_meta.push(u), r;
|
273
|
-
};
|
274
|
-
I.prototype.scanDelims = function(t, e) {
|
275
|
-
const s = this.posMax, r = this.src.charCodeAt(t), u = t > 0 ? this.src.charCodeAt(t - 1) : 32;
|
276
|
-
let i = t;
|
277
|
-
for (; i < s && this.src.charCodeAt(i) === r; )
|
278
|
-
i++;
|
279
|
-
const o = i - t, n = i < s ? this.src.charCodeAt(i) : 32, a = J(u) || q(String.fromCharCode(u)), c = J(n) || q(String.fromCharCode(n)), h = G(u), D = G(n), g = !D && (!c || h || a), k = !h && (!a || D || c);
|
280
|
-
return { can_open: g && (e || !k || a), can_close: k && (e || !g || c), length: o };
|
281
|
-
};
|
282
|
-
I.prototype.Token = x;
|
283
|
-
const Q = [];
|
284
|
-
for (let t = 0; t < 256; t++)
|
285
|
-
Q.push(0);
|
286
|
-
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t) {
|
287
|
-
Q[t.charCodeAt(0)] = 1;
|
288
|
-
});
|
289
|
-
let b = /* @__PURE__ */ function(t) {
|
290
|
-
return t.DOCUMENT = "doc", t.HEADING = "heading", t.PARAGRAPH = "paragraph", t.QUOTE = "blockquote", t.OL_LIST = "ordered_list", t.UL_LIST = "bullet_list", t.LIST_ITEM = "list_item", t.CODE_BLOCK = "code_block", t.HR = "horizontal_rule", t.BR = "hard_break", t.IMAGE = "image", t.EMOJI = "emoji", t.COMPONENT = "blok", t.TABLE = "table", t.TABLE_ROW = "tableRow", t.TABLE_CELL = "tableCell", t.TABLE_HEADER = "tableHeader", t;
|
291
|
-
}({}), v = /* @__PURE__ */ function(t) {
|
292
|
-
return t.BOLD = "bold", t.STRONG = "strong", t.STRIKE = "strike", t.UNDERLINE = "underline", t.ITALIC = "italic", t.CODE = "code", t.LINK = "link", t.ANCHOR = "anchor", t.STYLED = "styled", t.SUPERSCRIPT = "superscript", t.SUBSCRIPT = "subscript", t.TEXT_STYLE = "textStyle", t.HIGHLIGHT = "highlight", t;
|
293
|
-
}({}), vt = /* @__PURE__ */ function(t) {
|
294
|
-
return t.TEXT = "text", t;
|
295
|
-
}({}), L = /* @__PURE__ */ function(t) {
|
296
|
-
return t.URL = "url", t.STORY = "story", t.ASSET = "asset", t.EMAIL = "email", t;
|
297
|
-
}({});
|
298
|
-
function xt(t, e) {
|
299
|
-
if (!e) return {
|
300
|
-
src: t,
|
38
|
+
const P = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
|
39
|
+
function ce(e, t) {
|
40
|
+
if (!t) return {
|
41
|
+
src: e,
|
301
42
|
attrs: {}
|
302
43
|
};
|
303
44
|
let s = 0, r = 0;
|
304
|
-
const
|
305
|
-
function
|
306
|
-
typeof
|
307
|
-
}
|
308
|
-
if (typeof
|
309
|
-
if (typeof
|
310
|
-
const { filters:
|
311
|
-
c &&
|
45
|
+
const i = {}, n = [];
|
46
|
+
function l(u, c, f, g, E) {
|
47
|
+
typeof u != "number" || u <= c || u >= f ? console.warn(`[StoryblokRichText] - ${g.charAt(0).toUpperCase() + g.slice(1)} value must be a number between ${c} and ${f} (inclusive)`) : E.push(`${g}(${u})`);
|
48
|
+
}
|
49
|
+
if (typeof t == "object") {
|
50
|
+
if (typeof t.width == "number" && t.width > 0 ? (i.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (i.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (i.loading = t.loading), t.class && (i.class = t.class), t.filters) {
|
51
|
+
const { filters: u } = t || {}, { blur: c, brightness: f, fill: g, format: E, grayscale: _, quality: T, rotate: L } = u || {};
|
52
|
+
c && l(c, 0, 100, "blur", n), T && l(T, 0, 100, "quality", n), f && l(f, 0, 100, "brightness", n), g && n.push(`fill(${g})`), _ && n.push("grayscale()"), L && [
|
312
53
|
0,
|
313
54
|
90,
|
314
55
|
180,
|
315
56
|
270
|
316
|
-
].includes(
|
57
|
+
].includes(t.filters.rotate || 0) && n.push(`rotate(${L})`), E && [
|
317
58
|
"webp",
|
318
59
|
"png",
|
319
60
|
"jpeg"
|
320
|
-
].includes(
|
61
|
+
].includes(E) && n.push(`format(${E})`);
|
321
62
|
}
|
322
|
-
|
323
|
-
if (typeof
|
324
|
-
if (Array.isArray(
|
325
|
-
const [c,
|
326
|
-
return `${
|
63
|
+
t.srcset && (i.srcset = t.srcset.map((u) => {
|
64
|
+
if (typeof u == "number") return `${e}/m/${u}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
65
|
+
if (Array.isArray(u) && u.length === 2) {
|
66
|
+
const [c, f] = u;
|
67
|
+
return `${e}/m/${c}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
|
327
68
|
} else {
|
328
69
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
329
70
|
return;
|
330
71
|
}
|
331
|
-
}).join(", ")),
|
72
|
+
}).join(", ")), t.sizes && (i.sizes = t.sizes.join(", "));
|
332
73
|
}
|
333
|
-
let
|
334
|
-
return s > 0 && r > 0 && (
|
335
|
-
src:
|
336
|
-
attrs:
|
74
|
+
let a = `${e}/m/`;
|
75
|
+
return s > 0 && r > 0 && (a = `${a}${s}x${r}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
|
76
|
+
src: a,
|
77
|
+
attrs: i
|
337
78
|
};
|
338
79
|
}
|
339
|
-
|
340
|
-
"
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
"hr",
|
346
|
-
"img",
|
347
|
-
"input",
|
348
|
-
"link",
|
349
|
-
"meta",
|
350
|
-
"param",
|
351
|
-
"source",
|
352
|
-
"track",
|
353
|
-
"wbr"
|
354
|
-
], Bt = (t = {}) => Object.keys(t).map((e) => `${e}="${t[e]}"`).join(" "), wt = (t = {}) => Object.keys(t).map((e) => `${e}: ${t[e]}`).join("; ");
|
355
|
-
function Rt(t) {
|
356
|
-
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
80
|
+
function F(e, t = {}, s) {
|
81
|
+
const r = oe(t), i = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
|
82
|
+
if (e) {
|
83
|
+
if (ne.includes(e)) return `<${i}>`;
|
84
|
+
} else return n;
|
85
|
+
return `<${i}>${n}</${e}>`;
|
357
86
|
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
const F = f.attrs || {};
|
369
|
-
return d.render(l, F, f.children || null);
|
370
|
-
}, c = (l, f) => {
|
371
|
-
const { src: d, alt: F, title: p, srcset: C, sizes: A } = l.attrs || {};
|
372
|
-
let y = d, m = {};
|
373
|
-
if (i) {
|
374
|
-
const { src: at, attrs: ct } = xt(d, i);
|
375
|
-
y = at, m = ct;
|
87
|
+
function ue(e = {}) {
|
88
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: s = F, textFn: r = le, resolvers: i = {}, optimizeImages: n = !1, keyedResolvers: l = !1 } = e, a = s !== F, u = (o) => (d, h) => {
|
89
|
+
const y = d.attrs || {};
|
90
|
+
return h.render(o, y, d.children || null);
|
91
|
+
}, c = (o, d) => {
|
92
|
+
const { src: h, alt: y, title: p, srcset: m, sizes: v } = o.attrs || {};
|
93
|
+
let R = h, k = {};
|
94
|
+
if (n) {
|
95
|
+
const { src: ee, attrs: te } = ce(h, n);
|
96
|
+
R = ee, k = te;
|
376
97
|
}
|
377
|
-
const
|
378
|
-
src:
|
379
|
-
alt:
|
98
|
+
const Z = {
|
99
|
+
src: R,
|
100
|
+
alt: y,
|
380
101
|
title: p,
|
381
|
-
srcset:
|
382
|
-
sizes:
|
383
|
-
...
|
102
|
+
srcset: m,
|
103
|
+
sizes: v,
|
104
|
+
...k
|
384
105
|
};
|
385
|
-
return
|
386
|
-
},
|
387
|
-
const { level:
|
388
|
-
return
|
389
|
-
},
|
390
|
-
var
|
391
|
-
const
|
392
|
-
src: (
|
393
|
-
alt: (p =
|
106
|
+
return d.render("img", P(Z));
|
107
|
+
}, f = (o, d) => {
|
108
|
+
const { level: h, ...y } = o.attrs || {};
|
109
|
+
return d.render(`h${h}`, y, o.children);
|
110
|
+
}, g = (o, d) => {
|
111
|
+
var y, p, m, v;
|
112
|
+
const h = d.render("img", {
|
113
|
+
src: (y = o.attrs) == null ? void 0 : y.fallbackImage,
|
114
|
+
alt: (p = o.attrs) == null ? void 0 : p.alt,
|
394
115
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
395
116
|
draggable: "false",
|
396
117
|
loading: "lazy"
|
397
118
|
});
|
398
|
-
return
|
119
|
+
return d.render("span", {
|
399
120
|
"data-type": "emoji",
|
400
|
-
"data-name": (
|
401
|
-
"data-emoji": (
|
402
|
-
},
|
403
|
-
},
|
404
|
-
const { class:
|
405
|
-
class:
|
406
|
-
id:
|
407
|
-
style:
|
408
|
-
} :
|
409
|
-
return p.render(
|
410
|
-
},
|
411
|
-
const { marks:
|
412
|
-
if ("text" in
|
413
|
-
if (
|
414
|
-
...
|
121
|
+
"data-name": (m = o.attrs) == null ? void 0 : m.name,
|
122
|
+
"data-emoji": (v = o.attrs) == null ? void 0 : v.emoji
|
123
|
+
}, h);
|
124
|
+
}, E = (o, d) => d.render("pre", o.attrs || {}, d.render("code", {}, o.children || "")), _ = (o, d = !1) => ({ text: h, attrs: y }, p) => {
|
125
|
+
const { class: m, id: v, ...R } = y || {}, k = d ? {
|
126
|
+
class: m,
|
127
|
+
id: v,
|
128
|
+
style: ae(R) || void 0
|
129
|
+
} : y || {};
|
130
|
+
return p.render(o, P(k), h);
|
131
|
+
}, T = (o) => N(o), L = (o) => {
|
132
|
+
const { marks: d, ...h } = o;
|
133
|
+
if ("text" in o) {
|
134
|
+
if (d) return d.reduce((p, m) => T({
|
135
|
+
...m,
|
415
136
|
text: p
|
416
|
-
}),
|
417
|
-
...
|
418
|
-
children:
|
137
|
+
}), T({
|
138
|
+
...h,
|
139
|
+
children: h.children
|
419
140
|
}));
|
420
|
-
const
|
421
|
-
if (
|
422
|
-
const p =
|
423
|
-
|
141
|
+
const y = o.attrs || {};
|
142
|
+
if (l) {
|
143
|
+
const p = t.get("txt") || 0;
|
144
|
+
t.set("txt", p + 1), y.key = `txt-${p}`;
|
424
145
|
}
|
425
|
-
return r(
|
146
|
+
return r(h.text, y);
|
426
147
|
}
|
427
148
|
return "";
|
428
|
-
},
|
429
|
-
const { linktype:
|
430
|
-
let
|
431
|
-
switch (
|
432
|
-
case
|
433
|
-
case
|
434
|
-
|
149
|
+
}, j = (o, d) => {
|
150
|
+
const { linktype: h, href: y, anchor: p, ...m } = o.attrs || {};
|
151
|
+
let v = "";
|
152
|
+
switch (h) {
|
153
|
+
case C.ASSET:
|
154
|
+
case C.URL:
|
155
|
+
v = y;
|
435
156
|
break;
|
436
|
-
case
|
437
|
-
|
157
|
+
case C.EMAIL:
|
158
|
+
v = `mailto:${y}`;
|
438
159
|
break;
|
439
|
-
case
|
440
|
-
|
160
|
+
case C.STORY:
|
161
|
+
v = y, p && (v = `${v}#${p}`);
|
441
162
|
break;
|
442
163
|
default:
|
443
|
-
|
164
|
+
v = y;
|
444
165
|
break;
|
445
166
|
}
|
446
|
-
const
|
447
|
-
return
|
448
|
-
},
|
449
|
-
var
|
450
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
451
|
-
blok: (
|
452
|
-
id: (
|
167
|
+
const R = { ...m };
|
168
|
+
return v && (R.href = v), d.render("a", R, o.text);
|
169
|
+
}, J = (o, d) => {
|
170
|
+
var h, y;
|
171
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
|
172
|
+
blok: (h = o == null ? void 0 : o.attrs) == null ? void 0 : h.body[0],
|
173
|
+
id: (y = o.attrs) == null ? void 0 : y.id,
|
453
174
|
style: "display: none"
|
454
175
|
});
|
455
|
-
},
|
456
|
-
const
|
457
|
-
return
|
458
|
-
},
|
459
|
-
const
|
460
|
-
return
|
461
|
-
},
|
462
|
-
const { colspan:
|
463
|
-
|
464
|
-
const
|
465
|
-
return p &&
|
466
|
-
},
|
467
|
-
const { colspan:
|
468
|
-
|
469
|
-
const
|
470
|
-
return p &&
|
471
|
-
},
|
472
|
-
[
|
473
|
-
[
|
474
|
-
[
|
475
|
-
[
|
476
|
-
[
|
477
|
-
[
|
478
|
-
[
|
479
|
-
[
|
480
|
-
[
|
481
|
-
[
|
482
|
-
[
|
483
|
-
[
|
484
|
-
[
|
485
|
-
[
|
486
|
-
[
|
487
|
-
[
|
488
|
-
[
|
489
|
-
[
|
490
|
-
[
|
491
|
-
[
|
492
|
-
[
|
493
|
-
[
|
494
|
-
[
|
495
|
-
[
|
496
|
-
[
|
497
|
-
[
|
498
|
-
[
|
499
|
-
[
|
500
|
-
[
|
501
|
-
[
|
502
|
-
]),
|
503
|
-
render: (
|
504
|
-
if (
|
505
|
-
const
|
506
|
-
|
176
|
+
}, K = (o, d) => {
|
177
|
+
const h = {}, y = d.render("tbody", {}, o.children);
|
178
|
+
return d.render("table", h, y);
|
179
|
+
}, Y = (o, d) => {
|
180
|
+
const h = {};
|
181
|
+
return d.render("tr", h, o.children);
|
182
|
+
}, W = (o, d) => {
|
183
|
+
const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
|
184
|
+
h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
|
185
|
+
const k = [];
|
186
|
+
return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("td", P(R), o.children);
|
187
|
+
}, X = (o, d) => {
|
188
|
+
const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
|
189
|
+
h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
|
190
|
+
const k = [];
|
191
|
+
return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("th", P(R), o.children);
|
192
|
+
}, U = /* @__PURE__ */ new Map([
|
193
|
+
[w.DOCUMENT, u("")],
|
194
|
+
[w.HEADING, f],
|
195
|
+
[w.PARAGRAPH, u("p")],
|
196
|
+
[w.UL_LIST, u("ul")],
|
197
|
+
[w.OL_LIST, u("ol")],
|
198
|
+
[w.LIST_ITEM, u("li")],
|
199
|
+
[w.IMAGE, c],
|
200
|
+
[w.EMOJI, g],
|
201
|
+
[w.CODE_BLOCK, E],
|
202
|
+
[w.HR, u("hr")],
|
203
|
+
[w.BR, u("br")],
|
204
|
+
[w.QUOTE, u("blockquote")],
|
205
|
+
[w.COMPONENT, J],
|
206
|
+
[ie.TEXT, L],
|
207
|
+
[S.LINK, j],
|
208
|
+
[S.ANCHOR, j],
|
209
|
+
[S.STYLED, _("span", !0)],
|
210
|
+
[S.BOLD, _("strong")],
|
211
|
+
[S.TEXT_STYLE, _("span", !0)],
|
212
|
+
[S.ITALIC, _("em")],
|
213
|
+
[S.UNDERLINE, _("u")],
|
214
|
+
[S.STRIKE, _("s")],
|
215
|
+
[S.CODE, _("code")],
|
216
|
+
[S.SUPERSCRIPT, _("sup")],
|
217
|
+
[S.SUBSCRIPT, _("sub")],
|
218
|
+
[S.HIGHLIGHT, _("mark")],
|
219
|
+
[w.TABLE, K],
|
220
|
+
[w.TABLE_ROW, Y],
|
221
|
+
[w.TABLE_CELL, W],
|
222
|
+
[w.TABLE_HEADER, X]
|
223
|
+
]), B = new Map([...U, ...Object.entries(i).map(([o, d]) => [o, d])]), Q = () => ({
|
224
|
+
render: (h, y = {}, p) => {
|
225
|
+
if (l && h) {
|
226
|
+
const m = t.get(h) || 0;
|
227
|
+
t.set(h, m + 1), y.key = `${h}-${m}`;
|
507
228
|
}
|
508
|
-
return s(
|
229
|
+
return s(h, y, p);
|
509
230
|
},
|
510
|
-
originalResolvers:
|
511
|
-
mergedResolvers:
|
231
|
+
originalResolvers: U,
|
232
|
+
mergedResolvers: B
|
512
233
|
});
|
513
|
-
function
|
514
|
-
const
|
515
|
-
if (!
|
516
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
517
|
-
const
|
518
|
-
if (
|
519
|
-
const
|
520
|
-
return
|
521
|
-
...
|
522
|
-
children:
|
523
|
-
},
|
524
|
-
}
|
525
|
-
function N(
|
526
|
-
return
|
234
|
+
function O(o) {
|
235
|
+
const d = B.get(o.type);
|
236
|
+
if (!d)
|
237
|
+
return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
|
238
|
+
const h = Q();
|
239
|
+
if (o.type === "text") return d(o, h);
|
240
|
+
const y = o.content ? o.content.map(N) : void 0;
|
241
|
+
return d({
|
242
|
+
...o,
|
243
|
+
children: y
|
244
|
+
}, h);
|
245
|
+
}
|
246
|
+
function N(o) {
|
247
|
+
return o.type === "doc" ? a ? o.content.map(O) : o.content.map(O).join("") : Array.isArray(o) ? o.map(O) : O(o);
|
527
248
|
}
|
528
249
|
return { render: N };
|
529
250
|
}
|
530
|
-
let
|
531
|
-
const
|
251
|
+
let z = !1;
|
252
|
+
const G = [], M = (e) => new Promise((t, s) => {
|
532
253
|
if (typeof window > "u") {
|
533
254
|
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
534
255
|
return;
|
535
256
|
}
|
536
|
-
if (window.storyblokRegisterEvent = (
|
257
|
+
if (window.storyblokRegisterEvent = (i) => {
|
537
258
|
if (!window.location.search.includes("_storyblok")) {
|
538
259
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
539
260
|
return;
|
540
261
|
}
|
541
|
-
|
262
|
+
z ? i() : G.push(i);
|
542
263
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
543
|
-
|
264
|
+
t(void 0);
|
544
265
|
return;
|
545
266
|
}
|
546
267
|
const r = document.createElement("script");
|
547
|
-
r.async = !0, r.src =
|
548
|
-
|
268
|
+
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (i) => s(i), r.onload = (i) => {
|
269
|
+
G.forEach((n) => n()), z = !0, t(i);
|
549
270
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
550
271
|
});
|
551
|
-
var
|
552
|
-
constructor(
|
553
|
-
super(
|
272
|
+
var he = class extends Error {
|
273
|
+
constructor(e) {
|
274
|
+
super(e), this.name = "AbortError";
|
554
275
|
}
|
555
276
|
};
|
556
|
-
function
|
557
|
-
if (!Number.isFinite(
|
277
|
+
function de(e, t, s) {
|
278
|
+
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
558
279
|
if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
|
559
280
|
const r = [];
|
560
|
-
let
|
561
|
-
const
|
562
|
-
|
281
|
+
let i = [], n = 0, l = !1;
|
282
|
+
const a = async () => {
|
283
|
+
n++;
|
563
284
|
const c = r.shift();
|
564
285
|
if (c) try {
|
565
|
-
const
|
566
|
-
c.resolve(
|
567
|
-
} catch (
|
568
|
-
c.reject(
|
286
|
+
const g = await e(...c.args);
|
287
|
+
c.resolve(g);
|
288
|
+
} catch (g) {
|
289
|
+
c.reject(g);
|
569
290
|
}
|
570
|
-
const
|
571
|
-
|
291
|
+
const f = setTimeout(() => {
|
292
|
+
n--, r.length > 0 && a(), i = i.filter((g) => g !== f);
|
572
293
|
}, s);
|
573
|
-
|
574
|
-
},
|
294
|
+
i.includes(f) || i.push(f);
|
295
|
+
}, u = (...c) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, g) => {
|
575
296
|
r.push({
|
576
|
-
resolve:
|
577
|
-
reject:
|
297
|
+
resolve: f,
|
298
|
+
reject: g,
|
578
299
|
args: c
|
579
|
-
}),
|
300
|
+
}), n < t && a();
|
580
301
|
});
|
581
|
-
return
|
582
|
-
|
583
|
-
},
|
302
|
+
return u.abort = () => {
|
303
|
+
l = !0, i.forEach(clearTimeout), i = [], r.forEach((c) => c.reject(() => new he("Throttle function aborted"))), r.length = 0;
|
304
|
+
}, u;
|
584
305
|
}
|
585
|
-
var
|
586
|
-
const
|
587
|
-
...
|
588
|
-
per_page:
|
306
|
+
var fe = de;
|
307
|
+
const q = (e = "") => e.includes("/cdn/"), ye = (e, t = 25, s = 1) => ({
|
308
|
+
...e,
|
309
|
+
per_page: t,
|
589
310
|
page: s
|
590
|
-
}),
|
591
|
-
const s = Math.abs(
|
592
|
-
return
|
593
|
-
},
|
311
|
+
}), ge = (e) => new Promise((t) => setTimeout(t, e)), be = (e = 0, t) => Array.from({ length: e }, t), pe = (e = 0, t = e) => {
|
312
|
+
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
313
|
+
return be(s, (i, n) => n * r + e);
|
314
|
+
}, me = async (e, t) => Promise.all(e.map(t)), ve = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), H = (e, t, s) => {
|
594
315
|
const r = [];
|
595
|
-
for (const
|
596
|
-
if (!Object.prototype.hasOwnProperty.call(
|
597
|
-
const
|
598
|
-
if (
|
599
|
-
const
|
600
|
-
let
|
601
|
-
typeof
|
316
|
+
for (const i in e) {
|
317
|
+
if (!Object.prototype.hasOwnProperty.call(e, i)) continue;
|
318
|
+
const n = e[i];
|
319
|
+
if (n == null) continue;
|
320
|
+
const l = s ? "" : encodeURIComponent(i);
|
321
|
+
let a;
|
322
|
+
typeof n == "object" ? a = H(n, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(n)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, r.push(a);
|
602
323
|
}
|
603
324
|
return r.join("&");
|
604
|
-
},
|
605
|
-
const
|
325
|
+
}, V = (e) => {
|
326
|
+
const t = {
|
606
327
|
eu: "api.storyblok.com",
|
607
328
|
us: "api-us.storyblok.com",
|
608
329
|
cn: "app.storyblokchina.cn",
|
609
330
|
ap: "api-ap.storyblok.com",
|
610
331
|
ca: "api-ca.storyblok.com"
|
611
332
|
};
|
612
|
-
return e
|
333
|
+
return t[e] ?? t.eu;
|
613
334
|
};
|
614
|
-
var
|
615
|
-
constructor(
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
this.baseURL =
|
335
|
+
var Re = class {
|
336
|
+
constructor(e) {
|
337
|
+
b(this, "baseURL");
|
338
|
+
b(this, "timeout");
|
339
|
+
b(this, "headers");
|
340
|
+
b(this, "responseInterceptor");
|
341
|
+
b(this, "fetch");
|
342
|
+
b(this, "ejectInterceptor");
|
343
|
+
b(this, "url");
|
344
|
+
b(this, "parameters");
|
345
|
+
b(this, "fetchOptions");
|
346
|
+
this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
626
347
|
}
|
627
348
|
/**
|
628
349
|
*
|
@@ -630,54 +351,54 @@ var Ut = class {
|
|
630
351
|
* @param params ISbStoriesParams
|
631
352
|
* @returns Promise<ISbResponse | Error>
|
632
353
|
*/
|
633
|
-
get(
|
634
|
-
return this.url =
|
354
|
+
get(e, t) {
|
355
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
635
356
|
}
|
636
|
-
post(
|
637
|
-
return this.url =
|
357
|
+
post(e, t) {
|
358
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
638
359
|
}
|
639
|
-
put(
|
640
|
-
return this.url =
|
360
|
+
put(e, t) {
|
361
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
641
362
|
}
|
642
|
-
delete(
|
643
|
-
return this.url =
|
363
|
+
delete(e, t) {
|
364
|
+
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
644
365
|
}
|
645
|
-
async _responseHandler(
|
646
|
-
const
|
366
|
+
async _responseHandler(e) {
|
367
|
+
const t = [], s = {
|
647
368
|
data: {},
|
648
369
|
headers: {},
|
649
370
|
status: 0,
|
650
371
|
statusText: ""
|
651
372
|
};
|
652
|
-
|
373
|
+
e.status !== 204 && await e.json().then((r) => {
|
653
374
|
s.data = r;
|
654
375
|
});
|
655
|
-
for (const r of
|
656
|
-
return s.headers = { ...
|
657
|
-
}
|
658
|
-
async _methodHandler(
|
659
|
-
let
|
660
|
-
|
661
|
-
const r = new URL(
|
662
|
-
let
|
663
|
-
this.timeout && (
|
376
|
+
for (const r of e.headers.entries()) t[r[0]] = r[1];
|
377
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
378
|
+
}
|
379
|
+
async _methodHandler(e) {
|
380
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
381
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${H(this.parameters)}` : s = JSON.stringify(this.parameters);
|
382
|
+
const r = new URL(t), i = new AbortController(), { signal: n } = i;
|
383
|
+
let l;
|
384
|
+
this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
|
664
385
|
try {
|
665
|
-
const
|
666
|
-
method:
|
386
|
+
const a = await this.fetch(`${r}`, {
|
387
|
+
method: e,
|
667
388
|
headers: this.headers,
|
668
389
|
body: s,
|
669
|
-
signal:
|
390
|
+
signal: n,
|
670
391
|
...this.fetchOptions
|
671
392
|
});
|
672
|
-
this.timeout && clearTimeout(
|
673
|
-
const
|
674
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
675
|
-
} catch (
|
676
|
-
return { message:
|
393
|
+
this.timeout && clearTimeout(l);
|
394
|
+
const u = await this._responseHandler(a);
|
395
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
|
396
|
+
} catch (a) {
|
397
|
+
return { message: a };
|
677
398
|
}
|
678
399
|
}
|
679
|
-
setFetchOptions(
|
680
|
-
Object.keys(
|
400
|
+
setFetchOptions(e = {}) {
|
401
|
+
Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
|
681
402
|
}
|
682
403
|
eject() {
|
683
404
|
this.ejectInterceptor = !0;
|
@@ -687,124 +408,124 @@ var Ut = class {
|
|
687
408
|
* @param data The response data that might contain error information
|
688
409
|
* @returns A normalized error message string
|
689
410
|
*/
|
690
|
-
_normalizeErrorMessage(
|
691
|
-
if (Array.isArray(
|
692
|
-
if (
|
693
|
-
if (
|
694
|
-
for (const
|
695
|
-
if (Array.isArray(t
|
696
|
-
if (typeof t
|
411
|
+
_normalizeErrorMessage(e) {
|
412
|
+
if (Array.isArray(e)) return e[0] || "Unknown error";
|
413
|
+
if (e && typeof e == "object") {
|
414
|
+
if (e.error) return e.error;
|
415
|
+
for (const t in e) {
|
416
|
+
if (Array.isArray(e[t])) return `${t}: ${e[t][0]}`;
|
417
|
+
if (typeof e[t] == "string") return `${t}: ${e[t]}`;
|
697
418
|
}
|
698
|
-
if (
|
419
|
+
if (e.slug) return e.slug;
|
699
420
|
}
|
700
421
|
return "Unknown error";
|
701
422
|
}
|
702
|
-
_statusHandler(
|
703
|
-
const
|
423
|
+
_statusHandler(e) {
|
424
|
+
const t = /20[0-6]/g;
|
704
425
|
return new Promise((s, r) => {
|
705
|
-
if (
|
706
|
-
const
|
707
|
-
message: this._normalizeErrorMessage(
|
708
|
-
status:
|
709
|
-
response:
|
426
|
+
if (t.test(`${e.status}`)) return s(e);
|
427
|
+
const i = {
|
428
|
+
message: this._normalizeErrorMessage(e.data),
|
429
|
+
status: e.status,
|
430
|
+
response: e
|
710
431
|
};
|
711
|
-
r(
|
432
|
+
r(i);
|
712
433
|
});
|
713
434
|
}
|
714
|
-
},
|
715
|
-
const
|
435
|
+
}, we = Re;
|
436
|
+
const D = "SB-Agent", x = {
|
716
437
|
defaultAgentName: "SB-JS-CLIENT",
|
717
438
|
defaultAgentVersion: "SB-Agent-Version",
|
718
439
|
packageVersion: "7.0.0"
|
719
|
-
},
|
440
|
+
}, ke = {
|
720
441
|
PUBLISHED: "published"
|
721
442
|
};
|
722
|
-
let
|
723
|
-
const
|
724
|
-
var
|
443
|
+
let I = {};
|
444
|
+
const A = {};
|
445
|
+
var _e = class {
|
725
446
|
/**
|
726
447
|
*
|
727
448
|
* @param config ISbConfig interface
|
728
449
|
* @param pEndpoint string, optional
|
729
450
|
*/
|
730
|
-
constructor(
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
451
|
+
constructor(e, t) {
|
452
|
+
b(this, "client");
|
453
|
+
b(this, "maxRetries");
|
454
|
+
b(this, "retriesDelay");
|
455
|
+
b(this, "throttle");
|
456
|
+
b(this, "accessToken");
|
457
|
+
b(this, "cache");
|
458
|
+
b(this, "resolveCounter");
|
459
|
+
b(this, "relations");
|
460
|
+
b(this, "links");
|
461
|
+
b(this, "version");
|
741
462
|
/**
|
742
463
|
* @deprecated This property is deprecated. Use the standalone `richTextResolver` from `@storyblok/richtext` instead.
|
743
464
|
* @see https://github.com/storyblok/richtext
|
744
465
|
*/
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
let s =
|
466
|
+
b(this, "richTextResolver");
|
467
|
+
b(this, "resolveNestedRelations");
|
468
|
+
b(this, "stringifiedStoriesCache");
|
469
|
+
b(this, "inlineAssets");
|
470
|
+
let s = e.endpoint || t;
|
750
471
|
if (!s) {
|
751
|
-
const
|
752
|
-
|
472
|
+
const n = e.https === !1 ? "http" : "https";
|
473
|
+
e.oauthToken ? s = `${n}://${V(e.region)}/v1` : s = `${n}://${V(e.region)}/v2`;
|
753
474
|
}
|
754
475
|
const r = new Headers();
|
755
|
-
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"),
|
756
|
-
r.set(
|
757
|
-
}), r.has(
|
758
|
-
let
|
759
|
-
|
476
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([l, a]) => {
|
477
|
+
r.set(l, a);
|
478
|
+
}), r.has(D) || (r.set(D, x.defaultAgentName), r.set(x.defaultAgentVersion, x.packageVersion));
|
479
|
+
let i = 5;
|
480
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = fe(this.throttledRequest.bind(this), i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new we({
|
760
481
|
baseURL: s,
|
761
|
-
timeout:
|
482
|
+
timeout: e.timeout || 0,
|
762
483
|
headers: r,
|
763
|
-
responseInterceptor:
|
764
|
-
fetch:
|
484
|
+
responseInterceptor: e.responseInterceptor,
|
485
|
+
fetch: e.fetch
|
765
486
|
});
|
766
487
|
}
|
767
|
-
parseParams(
|
768
|
-
return
|
488
|
+
parseParams(e) {
|
489
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = A[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
769
490
|
}
|
770
|
-
factoryParamOptions(
|
771
|
-
return
|
491
|
+
factoryParamOptions(e, t) {
|
492
|
+
return q(e) ? this.parseParams(t) : t;
|
772
493
|
}
|
773
|
-
makeRequest(
|
774
|
-
const
|
775
|
-
return this.cacheResponse(
|
494
|
+
makeRequest(e, t, s, r, i) {
|
495
|
+
const n = this.factoryParamOptions(e, ye(t, s, r));
|
496
|
+
return this.cacheResponse(e, n, void 0, i);
|
776
497
|
}
|
777
|
-
get(
|
778
|
-
|
779
|
-
const r = `/${
|
780
|
-
|
781
|
-
const
|
782
|
-
return this.cacheResponse(r,
|
498
|
+
get(e, t = {}, s) {
|
499
|
+
t || (t = {});
|
500
|
+
const r = `/${e}`;
|
501
|
+
q(r) && (t.version = t.version || this.version);
|
502
|
+
const i = this.factoryParamOptions(r, t);
|
503
|
+
return this.cacheResponse(r, i, void 0, s);
|
783
504
|
}
|
784
|
-
async getAll(
|
785
|
-
const
|
786
|
-
|
787
|
-
const
|
788
|
-
return
|
505
|
+
async getAll(e, t = {}, s, r) {
|
506
|
+
const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1);
|
507
|
+
t.version = t.version || this.version;
|
508
|
+
const a = 1, u = await this.makeRequest(n, t, i, a, r), c = u.total ? Math.ceil(u.total / (u.perPage || i)) : 1, f = await me(pe(a, c), (g) => this.makeRequest(n, t, i, g + 1, r));
|
509
|
+
return ve([u, ...f], (g) => Object.values(g.data[l]));
|
789
510
|
}
|
790
|
-
post(
|
791
|
-
const r = `/${
|
792
|
-
return this.throttle("post", r,
|
511
|
+
post(e, t = {}, s) {
|
512
|
+
const r = `/${e}`;
|
513
|
+
return this.throttle("post", r, t, s);
|
793
514
|
}
|
794
|
-
put(
|
795
|
-
const r = `/${
|
796
|
-
return this.throttle("put", r,
|
515
|
+
put(e, t = {}, s) {
|
516
|
+
const r = `/${e}`;
|
517
|
+
return this.throttle("put", r, t, s);
|
797
518
|
}
|
798
|
-
delete(
|
799
|
-
|
800
|
-
const r = `/${
|
801
|
-
return this.throttle("delete", r,
|
519
|
+
delete(e, t = {}, s) {
|
520
|
+
t || (t = {});
|
521
|
+
const r = `/${e}`;
|
522
|
+
return this.throttle("delete", r, t, s);
|
802
523
|
}
|
803
|
-
getStories(
|
804
|
-
return this._addResolveLevel(
|
524
|
+
getStories(e = {}, t) {
|
525
|
+
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
805
526
|
}
|
806
|
-
getStory(
|
807
|
-
return this._addResolveLevel(
|
527
|
+
getStory(e, t = {}, s) {
|
528
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
|
808
529
|
}
|
809
530
|
getToken() {
|
810
531
|
return this.accessToken;
|
@@ -812,14 +533,14 @@ var Gt = class {
|
|
812
533
|
ejectInterceptor() {
|
813
534
|
this.client.eject();
|
814
535
|
}
|
815
|
-
_addResolveLevel(
|
816
|
-
typeof
|
536
|
+
_addResolveLevel(e) {
|
537
|
+
typeof e.resolve_relations < "u" && (e.resolve_level = 2);
|
817
538
|
}
|
818
|
-
_cleanCopy(
|
819
|
-
return JSON.parse(JSON.stringify(
|
539
|
+
_cleanCopy(e) {
|
540
|
+
return JSON.parse(JSON.stringify(e));
|
820
541
|
}
|
821
|
-
_insertLinks(
|
822
|
-
const r = t
|
542
|
+
_insertLinks(e, t, s) {
|
543
|
+
const r = e[t];
|
823
544
|
r && r.fieldtype === "multilink" && r.linktype === "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
|
824
545
|
}
|
825
546
|
/**
|
@@ -828,8 +549,8 @@ var Gt = class {
|
|
828
549
|
* @param uuid The uuid of the story
|
829
550
|
* @returns string | object
|
830
551
|
*/
|
831
|
-
getStoryReference(
|
832
|
-
return this.relations[
|
552
|
+
getStoryReference(e, t) {
|
553
|
+
return this.relations[e][t] ? JSON.parse(this.stringifiedStoriesCache[t] || JSON.stringify(this.relations[e][t])) : t;
|
833
554
|
}
|
834
555
|
/**
|
835
556
|
* Resolves a field's value by replacing UUIDs with their corresponding story references
|
@@ -841,9 +562,9 @@ var Gt = class {
|
|
841
562
|
* - For single strings: directly replaces the UUID with the story reference
|
842
563
|
* - For arrays: maps through each UUID and replaces with corresponding story references
|
843
564
|
*/
|
844
|
-
_resolveField(
|
845
|
-
const r = t
|
846
|
-
typeof r == "string" ? t
|
565
|
+
_resolveField(e, t, s) {
|
566
|
+
const r = e[t];
|
567
|
+
typeof r == "string" ? e[t] = this.getStoryReference(s, r) : Array.isArray(r) && (e[t] = r.map((i) => this.getStoryReference(s, i)).filter(Boolean));
|
847
568
|
}
|
848
569
|
/**
|
849
570
|
* Inserts relations into the JSON tree by resolving references
|
@@ -862,13 +583,13 @@ var Gt = class {
|
|
862
583
|
* The method supports both string and array formats for the fields parameter,
|
863
584
|
* allowing flexible specification of relation patterns.
|
864
585
|
*/
|
865
|
-
_insertRelations(
|
866
|
-
if (Array.isArray(s) ? s.find((
|
867
|
-
this._resolveField(
|
586
|
+
_insertRelations(e, t, s, r) {
|
587
|
+
if (Array.isArray(s) ? s.find((l) => l.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
|
588
|
+
this._resolveField(e, t, r);
|
868
589
|
return;
|
869
590
|
}
|
870
|
-
const
|
871
|
-
(Array.isArray(s) ? s.includes(
|
591
|
+
const n = e.component ? `${e.component}.${t}` : t;
|
592
|
+
(Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, r);
|
872
593
|
}
|
873
594
|
/**
|
874
595
|
* Recursively traverses and resolves relations in the story content tree
|
@@ -876,68 +597,68 @@ var Gt = class {
|
|
876
597
|
* @param fields - The relation patterns to resolve
|
877
598
|
* @param resolveId - The unique identifier for the current resolution context
|
878
599
|
*/
|
879
|
-
iterateTree(
|
880
|
-
const r = (
|
881
|
-
if (!(!
|
882
|
-
if (Array.isArray(
|
883
|
-
else if (typeof
|
884
|
-
const
|
885
|
-
(
|
600
|
+
iterateTree(e, t, s) {
|
601
|
+
const r = (i, n = "") => {
|
602
|
+
if (!(!i || i._stopResolving)) {
|
603
|
+
if (Array.isArray(i)) i.forEach((l, a) => r(l, `${n}[${a}]`));
|
604
|
+
else if (typeof i == "object") for (const l in i) {
|
605
|
+
const a = n ? `${n}.${l}` : l;
|
606
|
+
(i.component && i._uid || i.type === "link") && (this._insertRelations(i, l, t, s), this._insertLinks(i, l, s)), r(i[l], a);
|
886
607
|
}
|
887
608
|
}
|
888
609
|
};
|
889
|
-
r(
|
610
|
+
r(e.content);
|
890
611
|
}
|
891
|
-
async resolveLinks(
|
612
|
+
async resolveLinks(e, t, s) {
|
892
613
|
let r = [];
|
893
|
-
if (
|
894
|
-
const
|
895
|
-
for (let
|
896
|
-
const
|
897
|
-
|
614
|
+
if (e.link_uuids) {
|
615
|
+
const i = e.link_uuids.length, n = [], l = 50;
|
616
|
+
for (let a = 0; a < i; a += l) {
|
617
|
+
const u = Math.min(i, a + l);
|
618
|
+
n.push(e.link_uuids.slice(a, u));
|
898
619
|
}
|
899
|
-
for (let
|
620
|
+
for (let a = 0; a < n.length; a++)
|
900
621
|
(await this.getStories({
|
901
|
-
per_page:
|
902
|
-
language:
|
903
|
-
version:
|
904
|
-
starts_with:
|
905
|
-
by_uuids:
|
622
|
+
per_page: l,
|
623
|
+
language: t.language,
|
624
|
+
version: t.version,
|
625
|
+
starts_with: t.starts_with,
|
626
|
+
by_uuids: n[a].join(",")
|
906
627
|
})).data.stories.forEach((c) => {
|
907
628
|
r.push(c);
|
908
629
|
});
|
909
|
-
} else r =
|
910
|
-
r.forEach((
|
911
|
-
this.links[s][
|
912
|
-
...
|
630
|
+
} else r = e.links;
|
631
|
+
r.forEach((i) => {
|
632
|
+
this.links[s][i.uuid] = {
|
633
|
+
...i,
|
913
634
|
_stopResolving: !0
|
914
635
|
};
|
915
636
|
});
|
916
637
|
}
|
917
|
-
async resolveRelations(
|
638
|
+
async resolveRelations(e, t, s) {
|
918
639
|
let r = [];
|
919
|
-
if (
|
920
|
-
const
|
921
|
-
for (let
|
922
|
-
const
|
923
|
-
|
640
|
+
if (e.rel_uuids) {
|
641
|
+
const i = e.rel_uuids.length, n = [], l = 50;
|
642
|
+
for (let a = 0; a < i; a += l) {
|
643
|
+
const u = Math.min(i, a + l);
|
644
|
+
n.push(e.rel_uuids.slice(a, u));
|
924
645
|
}
|
925
|
-
for (let
|
646
|
+
for (let a = 0; a < n.length; a++)
|
926
647
|
(await this.getStories({
|
927
|
-
per_page:
|
928
|
-
language:
|
929
|
-
version:
|
930
|
-
starts_with:
|
931
|
-
by_uuids:
|
932
|
-
excluding_fields:
|
648
|
+
per_page: l,
|
649
|
+
language: t.language,
|
650
|
+
version: t.version,
|
651
|
+
starts_with: t.starts_with,
|
652
|
+
by_uuids: n[a].join(","),
|
653
|
+
excluding_fields: t.excluding_fields
|
933
654
|
})).data.stories.forEach((c) => {
|
934
655
|
r.push(c);
|
935
656
|
});
|
936
|
-
r.length > 0 && (
|
937
|
-
} else r =
|
938
|
-
r && r.length > 0 && r.forEach((
|
939
|
-
this.relations[s][
|
940
|
-
...
|
657
|
+
r.length > 0 && (e.rels = r, delete e.rel_uuids);
|
658
|
+
} else r = e.rels;
|
659
|
+
r && r.length > 0 && r.forEach((i) => {
|
660
|
+
this.relations[s][i.uuid] = {
|
661
|
+
...i,
|
941
662
|
_stopResolving: !0
|
942
663
|
};
|
943
664
|
});
|
@@ -951,84 +672,84 @@ var Gt = class {
|
|
951
672
|
* @returns Promise<void>
|
952
673
|
*
|
953
674
|
*/
|
954
|
-
async resolveStories(
|
955
|
-
var
|
675
|
+
async resolveStories(e, t, s) {
|
676
|
+
var i, n;
|
956
677
|
let r = [];
|
957
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof
|
678
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (r = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && [
|
958
679
|
"1",
|
959
680
|
"story",
|
960
681
|
"url",
|
961
682
|
"link"
|
962
|
-
].includes(
|
963
|
-
|
964
|
-
this.iterateTree(
|
683
|
+
].includes(t.resolve_links) && ((i = e.links) != null && i.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const l in this.relations[s]) this.iterateTree(this.relations[s][l], r, s);
|
684
|
+
e.story ? this.iterateTree(e.story, r, s) : e.stories.forEach((l) => {
|
685
|
+
this.iterateTree(l, r, s);
|
965
686
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
966
687
|
}
|
967
|
-
async cacheResponse(
|
968
|
-
const
|
969
|
-
url:
|
970
|
-
params:
|
971
|
-
}),
|
972
|
-
if (
|
973
|
-
const
|
974
|
-
if (
|
688
|
+
async cacheResponse(e, t, s, r) {
|
689
|
+
const i = H({
|
690
|
+
url: e,
|
691
|
+
params: t
|
692
|
+
}), n = this.cacheProvider();
|
693
|
+
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
694
|
+
const l = await n.get(i);
|
695
|
+
if (l) return Promise.resolve(l);
|
975
696
|
}
|
976
|
-
return new Promise(async (
|
977
|
-
var
|
697
|
+
return new Promise(async (l, a) => {
|
698
|
+
var u;
|
978
699
|
try {
|
979
|
-
const c = await this.throttle("get",
|
980
|
-
if (c.status !== 200) return
|
981
|
-
let
|
700
|
+
const c = await this.throttle("get", e, t, r);
|
701
|
+
if (c.status !== 200) return a(c);
|
702
|
+
let f = {
|
982
703
|
data: c.data,
|
983
704
|
headers: c.headers
|
984
705
|
};
|
985
|
-
if ((
|
706
|
+
if ((u = c.headers) != null && u["per-page"] && (f = Object.assign({}, f, {
|
986
707
|
perPage: c.headers["per-page"] ? Number.parseInt(c.headers["per-page"]) : 0,
|
987
708
|
total: c.headers["per-page"] ? Number.parseInt(c.headers.total) : 0
|
988
|
-
})),
|
989
|
-
const
|
990
|
-
await this.resolveStories(
|
709
|
+
})), f.data.story || f.data.stories) {
|
710
|
+
const E = this.resolveCounter = ++this.resolveCounter % 1e3;
|
711
|
+
await this.resolveStories(f.data, t, `${E}`), f = await this.processInlineAssets(f);
|
991
712
|
}
|
992
|
-
|
993
|
-
const
|
994
|
-
return
|
713
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(i, f);
|
714
|
+
const g = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
715
|
+
return t.token && f.data.cv && (g && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), l(f);
|
995
716
|
} catch (c) {
|
996
717
|
if (c.response && c.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
997
|
-
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await
|
998
|
-
|
718
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await ge(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
|
719
|
+
a(c);
|
999
720
|
}
|
1000
721
|
});
|
1001
722
|
}
|
1002
|
-
throttledRequest(
|
1003
|
-
return this.client.setFetchOptions(r), this.client[
|
723
|
+
throttledRequest(e, t, s, r) {
|
724
|
+
return this.client.setFetchOptions(r), this.client[e](t, s);
|
1004
725
|
}
|
1005
726
|
cacheVersions() {
|
1006
|
-
return
|
727
|
+
return A;
|
1007
728
|
}
|
1008
729
|
cacheVersion() {
|
1009
|
-
return
|
730
|
+
return A[this.accessToken];
|
1010
731
|
}
|
1011
|
-
setCacheVersion(
|
1012
|
-
this.accessToken && (
|
732
|
+
setCacheVersion(e) {
|
733
|
+
this.accessToken && (A[this.accessToken] = e);
|
1013
734
|
}
|
1014
735
|
clearCacheVersion() {
|
1015
|
-
this.accessToken && (
|
736
|
+
this.accessToken && (A[this.accessToken] = 0);
|
1016
737
|
}
|
1017
738
|
cacheProvider() {
|
1018
739
|
switch (this.cache.type) {
|
1019
740
|
case "memory":
|
1020
741
|
return {
|
1021
|
-
get(
|
1022
|
-
return Promise.resolve(
|
742
|
+
get(e) {
|
743
|
+
return Promise.resolve(I[e]);
|
1023
744
|
},
|
1024
745
|
getAll() {
|
1025
|
-
return Promise.resolve(
|
746
|
+
return Promise.resolve(I);
|
1026
747
|
},
|
1027
|
-
set(
|
1028
|
-
return
|
748
|
+
set(e, t) {
|
749
|
+
return I[e] = t, Promise.resolve(void 0);
|
1029
750
|
},
|
1030
751
|
flush() {
|
1031
|
-
return
|
752
|
+
return I = {}, Promise.resolve(void 0);
|
1032
753
|
}
|
1033
754
|
};
|
1034
755
|
case "custom":
|
@@ -1053,96 +774,96 @@ var Gt = class {
|
|
1053
774
|
async flushCache() {
|
1054
775
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
1055
776
|
}
|
1056
|
-
async processInlineAssets(
|
1057
|
-
if (!this.inlineAssets) return
|
1058
|
-
const
|
777
|
+
async processInlineAssets(e) {
|
778
|
+
if (!this.inlineAssets) return e;
|
779
|
+
const t = (s) => {
|
1059
780
|
if (!s || typeof s != "object") return s;
|
1060
|
-
if (Array.isArray(s)) return s.map((
|
781
|
+
if (Array.isArray(s)) return s.map((i) => t(i));
|
1061
782
|
let r = { ...s };
|
1062
|
-
r.fieldtype === "asset" && Array.isArray(
|
783
|
+
r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
|
1063
784
|
...r,
|
1064
|
-
...
|
785
|
+
...e.data.assets.find((i) => i.id === r.id)
|
1065
786
|
});
|
1066
|
-
for (const
|
787
|
+
for (const i in r) typeof r[i] == "object" && (r[i] = t(r[i]));
|
1067
788
|
return r;
|
1068
789
|
};
|
1069
|
-
return
|
790
|
+
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((s) => (s.content = t(s.content), s))), e;
|
1070
791
|
}
|
1071
|
-
},
|
1072
|
-
const
|
1073
|
-
const { apiOptions:
|
1074
|
-
if (!
|
792
|
+
}, Se = _e;
|
793
|
+
const Ae = (e = {}) => {
|
794
|
+
const { apiOptions: t } = e;
|
795
|
+
if (!t || !t.accessToken) {
|
1075
796
|
console.error(
|
1076
797
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
1077
798
|
);
|
1078
799
|
return;
|
1079
800
|
}
|
1080
|
-
return { storyblokApi: new
|
1081
|
-
},
|
1082
|
-
if (typeof
|
801
|
+
return { storyblokApi: new Se(t) };
|
802
|
+
}, Te = (e) => {
|
803
|
+
if (typeof e != "object" || typeof e._editable > "u")
|
1083
804
|
return {};
|
1084
805
|
try {
|
1085
|
-
const
|
1086
|
-
|
806
|
+
const t = JSON.parse(
|
807
|
+
e._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
1087
808
|
);
|
1088
|
-
return
|
1089
|
-
"data-blok-c": JSON.stringify(
|
1090
|
-
"data-blok-uid": `${
|
809
|
+
return t ? {
|
810
|
+
"data-blok-c": JSON.stringify(t),
|
811
|
+
"data-blok-uid": `${t.id}-${t.uid}`
|
1091
812
|
} : {};
|
1092
813
|
} catch {
|
1093
814
|
return {};
|
1094
815
|
}
|
1095
816
|
};
|
1096
|
-
let
|
1097
|
-
const
|
1098
|
-
var
|
1099
|
-
const
|
817
|
+
let $ = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
818
|
+
const Le = (e, t, s = {}) => {
|
819
|
+
var a;
|
820
|
+
const i = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
|
1100
821
|
"_storyblok"
|
1101
|
-
),
|
1102
|
-
if (!(!
|
1103
|
-
if (!
|
822
|
+
), l = n !== null && +n === e;
|
823
|
+
if (!(!i || !l)) {
|
824
|
+
if (!e) {
|
1104
825
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
1105
826
|
return;
|
1106
827
|
}
|
1107
828
|
window.storyblokRegisterEvent(() => {
|
1108
829
|
new window.StoryblokBridge(s).on(["input", "published", "change"], (c) => {
|
1109
|
-
var
|
1110
|
-
c && (c.action === "input" && ((
|
830
|
+
var f;
|
831
|
+
c && (c.action === "input" && ((f = c.story) == null ? void 0 : f.id) === e ? t(c.story) : (c.action === "change" || c.action === "published") && c.storyId === e && window.location.reload());
|
1111
832
|
});
|
1112
833
|
});
|
1113
834
|
}
|
1114
|
-
},
|
1115
|
-
var
|
835
|
+
}, Oe = (e = {}) => {
|
836
|
+
var f, g;
|
1116
837
|
const {
|
1117
|
-
bridge:
|
838
|
+
bridge: t,
|
1118
839
|
accessToken: s,
|
1119
840
|
use: r = [],
|
1120
|
-
apiOptions:
|
1121
|
-
bridgeUrl:
|
1122
|
-
} =
|
1123
|
-
|
1124
|
-
const
|
1125
|
-
let
|
1126
|
-
r.forEach((
|
1127
|
-
|
1128
|
-
}),
|
1129
|
-
const c = !(typeof window > "u") && ((
|
1130
|
-
return
|
841
|
+
apiOptions: i = {},
|
842
|
+
bridgeUrl: n
|
843
|
+
} = e;
|
844
|
+
i.accessToken = i.accessToken || s;
|
845
|
+
const l = { bridge: t, apiOptions: i };
|
846
|
+
let a = {};
|
847
|
+
r.forEach((E) => {
|
848
|
+
a = { ...a, ...E(l) };
|
849
|
+
}), n && ($ = n);
|
850
|
+
const c = !(typeof window > "u") && ((g = (f = window.location) == null ? void 0 : f.search) == null ? void 0 : g.includes("_storyblok_tk"));
|
851
|
+
return t !== !1 && c && M($), a;
|
1131
852
|
};
|
1132
|
-
function
|
1133
|
-
return
|
853
|
+
function Ce(e, t) {
|
854
|
+
return ue(t).render(e);
|
1134
855
|
}
|
1135
|
-
const
|
856
|
+
const Pe = () => M($);
|
1136
857
|
export {
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
858
|
+
w as BlockTypes,
|
859
|
+
S as MarkTypes,
|
860
|
+
ie as TextTypes,
|
861
|
+
Ae as apiPlugin,
|
862
|
+
Pe as loadStoryblokBridge,
|
863
|
+
Le as registerStoryblokBridge,
|
864
|
+
Ce as renderRichText,
|
865
|
+
ue as richTextResolver,
|
866
|
+
Te as storyblokEditable,
|
867
|
+
Oe as storyblokInit,
|
868
|
+
Le as useStoryblokBridge
|
1148
869
|
};
|