@storyblok/astro 5.1.1 → 6.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,93 +1,80 @@
1
- function $r(o, t, r) {
2
- const s = "virtual:storyblok-init", i = `\0${s}`;
3
- return {
4
- name: "vite-plugin-storyblok-init",
5
- async resolveId(l) {
6
- if (l === s)
7
- return i;
8
- },
9
- async load(l) {
10
- if (l === i)
11
- return `
12
- import { storyblokInit, apiPlugin } from "@storyblok/js";
13
- const { storyblokApi } = storyblokInit({
14
- accessToken: "${o}",
15
- use: ${t ? "[]" : "[apiPlugin]"},
16
- apiOptions: ${JSON.stringify(r)},
17
- });
18
- export const storyblokApiInstance = storyblokApi;
19
- `;
20
- }
21
- };
22
- }
23
- const Or = /[\p{Lu}]/u, xr = /[\p{Ll}]/u, Me = /^[\p{Lu}](?![\p{Lu}])/gu, Je = /([\p{Alpha}\p{N}_]|$)/u, fe = /[_.\- ]+/, jr = new RegExp("^" + fe.source), Ne = new RegExp(fe.source + Je.source, "gu"), ze = new RegExp("\\d+" + Je.source, "gu"), Er = (o, t, r, s) => {
24
- let i = !1, l = !1, u = !1, f = !1;
25
- for (let g = 0; g < o.length; g++) {
26
- const y = o[g];
27
- f = g > 2 ? o[g - 3] === "-" : !0, i && Or.test(y) ? (o = o.slice(0, g) + "-" + o.slice(g), i = !1, u = l, l = !0, g++) : l && u && xr.test(y) && (!f || s) ? (o = o.slice(0, g - 1) + "-" + o.slice(g - 1), u = l, l = !1, i = !0) : (i = t(y) === y && r(y) !== y, u = l, l = r(y) === y && t(y) !== y);
1
+ const A = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
+ <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
+ <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
+ <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
5
+ <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
6
+ <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
7
+ </g>
8
+ </g>
9
+ </g>
10
+ </svg>`, E = /[\p{Lu}]/u, L = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, x = /([\p{Alpha}\p{N}_]|$)/u, y = /[_.\- ]+/, R = new RegExp("^" + y.source), w = new RegExp(y.source + x.source, "gu"), $ = new RegExp("\\d+" + x.source, "gu"), j = (r, e, t, o) => {
11
+ let s = !1, n = !1, a = !1, l = !1;
12
+ for (let i = 0; i < r.length; i++) {
13
+ const c = r[i];
14
+ l = i > 2 ? r[i - 3] === "-" : !0, s && E.test(c) ? (r = r.slice(0, i) + "-" + r.slice(i), s = !1, a = n, n = !0, i++) : n && a && L.test(c) && (!l || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), a = n, n = !1, s = !0) : (s = e(c) === c && t(c) !== c, a = n, n = t(c) === c && e(c) !== c);
28
15
  }
29
- return o;
30
- }, Rr = (o, t) => (Me.lastIndex = 0, o.replaceAll(Me, (r) => t(r))), Lr = (o, t) => (Ne.lastIndex = 0, ze.lastIndex = 0, o.replaceAll(ze, (r, s, i) => ["_", "-"].includes(o.charAt(i + r.length)) ? r : t(r)).replaceAll(Ne, (r, s) => t(s)));
31
- function Pr(o, t) {
32
- if (!(typeof o == "string" || Array.isArray(o)))
16
+ return r;
17
+ }, M = (r, e) => (k.lastIndex = 0, r.replaceAll(k, (t) => e(t))), P = (r, e) => (w.lastIndex = 0, $.lastIndex = 0, r.replaceAll($, (t, o, s) => ["_", "-"].includes(r.charAt(s + t.length)) ? t : e(t)).replaceAll(w, (t, o) => e(o)));
18
+ function O(r, e) {
19
+ if (!(typeof r == "string" || Array.isArray(r)))
33
20
  throw new TypeError("Expected the input to be `string | string[]`");
34
- if (t = {
21
+ if (e = {
35
22
  pascalCase: !1,
36
23
  preserveConsecutiveUppercase: !1,
37
- ...t
38
- }, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
24
+ ...e
25
+ }, Array.isArray(r) ? r = r.map((n) => n.trim()).filter((n) => n.length).join("-") : r = r.trim(), r.length === 0)
39
26
  return "";
40
- const r = t.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(t.locale);
41
- return o.length === 1 ? fe.test(o) ? "" : t.pascalCase ? s(o) : r(o) : (o !== r(o) && (o = Er(o, r, s, t.preserveConsecutiveUppercase)), o = o.replace(jr, ""), o = t.preserveConsecutiveUppercase ? Rr(o, r) : r(o), t.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), Lr(o, s));
27
+ const t = e.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(e.locale);
28
+ return r.length === 1 ? y.test(r) ? "" : e.pascalCase ? o(r) : t(r) : (r !== t(r) && (r = j(r, t, o, e.preserveConsecutiveUppercase)), r = r.replace(R, ""), r = e.preserveConsecutiveUppercase ? M(r, t) : t(r), e.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), P(r, o));
42
29
  }
43
- function Fe(o) {
44
- return Pr(o);
30
+ function v(r) {
31
+ return O(r);
45
32
  }
46
- function Mr(o, t = {}, r, s) {
47
- const i = "virtual:storyblok-components", l = `\0${i}`;
33
+ function _(r, e = {}, t, o) {
34
+ const s = "virtual:storyblok-components", n = `\0${s}`;
48
35
  return {
49
36
  name: "vite-plugin-storyblok-components",
50
- async resolveId(u) {
51
- if (u === i)
52
- return l;
37
+ async resolveId(a) {
38
+ if (a === s)
39
+ return n;
53
40
  },
54
- async load(u) {
55
- if (u === l) {
56
- const f = [], g = [];
57
- for await (const [_, C] of Object.entries(t)) {
58
- const T = await this.resolve(
59
- `/${o}/${C}.astro`
41
+ async load(a) {
42
+ if (a === n) {
43
+ const l = [], i = [];
44
+ for await (const [u, p] of Object.entries(e)) {
45
+ const f = await this.resolve(
46
+ `/${r}/${p}.astro`
60
47
  );
61
- if (T)
62
- f.push(`import ${Fe(_)} from "${T.id}"`);
63
- else if (r)
64
- g.push(_);
48
+ if (f)
49
+ l.push(`import ${v(u)} from "${f.id}"`);
50
+ else if (t)
51
+ i.push(u);
65
52
  else
66
53
  throw new Error(
67
- `Component could not be found for blok "${_}"! Does "${`/${o}/${C}`}.astro" exist?`
54
+ `Component could not be found for blok "${u}"! Does "${`/${r}/${p}`}.astro" exist?`
68
55
  );
69
56
  }
70
- let y = "";
71
- if (r)
72
- if (y = ",FallbackComponent", s) {
73
- const _ = await this.resolve(
74
- `/${o}/${s}.astro`
57
+ let c = "";
58
+ if (t)
59
+ if (c = ",FallbackComponent", o) {
60
+ const u = await this.resolve(
61
+ `/${r}/${o}.astro`
75
62
  );
76
- if (!_)
63
+ if (!u)
77
64
  throw new Error(
78
- `Custom fallback component could not be found. Does "${`/${o}/${s}`}.astro" exist?`
65
+ `Custom fallback component could not be found. Does "${`/${r}/${o}`}.astro" exist?`
79
66
  );
80
- f.push(
81
- `import FallbackComponent from "${_.id}"`
67
+ l.push(
68
+ `import FallbackComponent from "${u.id}"`
82
69
  );
83
70
  } else
84
- f.push(
71
+ l.push(
85
72
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
86
73
  );
87
- if (Object.values(t).length)
88
- return `${f.join(";")};export default {${Object.keys(t).filter((_) => !g.includes(_)).map((_) => Fe(_)).join(",")}${y}}`;
89
- if (r)
90
- return `${f[0]}; export default {${y.replace(",", "")}}`;
74
+ if (Object.values(e).length)
75
+ return `${l.join(";")};export default {${Object.keys(e).filter((u) => !i.includes(u)).map((u) => v(u)).join(",")}${c}}`;
76
+ if (t)
77
+ return `${l[0]}; export default {${c.replace(",", "")}}`;
91
78
  throw new Error(
92
79
  `Currently, no Storyblok components are registered in astro.config.mjs.
93
80
  Please register your components or enable the fallback component.
@@ -97,53 +84,75 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
97
84
  }
98
85
  };
99
86
  }
100
- function Nr(o) {
101
- const t = "virtual:storyblok-options", r = `\0${t}`;
87
+ function N(r, e, t) {
88
+ const o = "virtual:storyblok-init", s = `\0${o}`;
89
+ return {
90
+ name: "vite-plugin-storyblok-init",
91
+ async resolveId(n) {
92
+ if (n === o)
93
+ return s;
94
+ },
95
+ async load(n) {
96
+ if (n === s)
97
+ return `
98
+ import { storyblokInit, apiPlugin } from "@storyblok/js";
99
+ const { storyblokApi } = storyblokInit({
100
+ accessToken: "${r}",
101
+ use: ${e ? "[]" : "[apiPlugin]"},
102
+ apiOptions: ${JSON.stringify(t)},
103
+ });
104
+ export const storyblokApiInstance = storyblokApi;
105
+ `;
106
+ }
107
+ };
108
+ }
109
+ function z(r) {
110
+ const e = "virtual:storyblok-options", t = `\0${e}`;
102
111
  return {
103
112
  name: "vite-plugin-storyblok-options",
104
- async resolveId(s) {
105
- if (s === t)
106
- return r;
113
+ async resolveId(o) {
114
+ if (o === e)
115
+ return t;
107
116
  },
108
- async load(s) {
109
- if (s === r)
110
- return `export default ${JSON.stringify(o)}`;
117
+ async load(o) {
118
+ if (o === t)
119
+ return `export default ${JSON.stringify(r)}`;
111
120
  }
112
121
  };
113
122
  }
114
- let De = !1;
115
- const Be = [], zr = (o) => new Promise((t, r) => {
116
- if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
123
+ let C = !1;
124
+ const I = [], B = (r) => new Promise((e, t) => {
125
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
117
126
  if (window.location === window.parent.location) {
118
127
  console.warn("You are not in Draft Mode or in the Visual Editor.");
119
128
  return;
120
129
  }
121
- De ? i() : Be.push(i);
130
+ C ? s() : I.push(s);
122
131
  }, document.getElementById("storyblok-javascript-bridge"))) return;
123
- const s = document.createElement("script");
124
- s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => r(i), s.onload = (i) => {
125
- Be.forEach((l) => l()), De = !0, t(i);
126
- }, document.getElementsByTagName("head")[0].appendChild(s);
132
+ const o = document.createElement("script");
133
+ o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => t(s), o.onload = (s) => {
134
+ I.forEach((n) => n()), C = !0, e(s);
135
+ }, document.getElementsByTagName("head")[0].appendChild(o);
127
136
  });
128
- var Fr = Object.defineProperty, Dr = (o, t, r) => t in o ? Fr(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r, S = (o, t, r) => Dr(o, typeof t != "symbol" ? t + "" : t, r);
129
- let Br = class {
137
+ var F = Object.defineProperty, D = (r, e, t) => e in r ? F(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, g = (r, e, t) => D(r, typeof e != "symbol" ? e + "" : e, t);
138
+ let U = class {
130
139
  constructor() {
131
- S(this, "isCDNUrl", (o = "") => o.includes("/cdn/")), S(this, "getOptionsPage", (o, t = 25, r = 1) => ({
132
- ...o,
133
- per_page: t,
134
- page: r
135
- })), S(this, "delay", (o) => new Promise((t) => setTimeout(t, o))), S(this, "arrayFrom", (o = 0, t) => Array.from({ length: o }, t)), S(this, "range", (o = 0, t = o) => {
136
- const r = Math.abs(t - o) || 0, s = o < t ? 1 : -1;
137
- return this.arrayFrom(r, (i, l) => l * s + o);
138
- }), S(this, "asyncMap", async (o, t) => Promise.all(o.map(t))), S(this, "flatMap", (o = [], t) => o.map(t).reduce((r, s) => [...r, ...s], [])), S(this, "escapeHTML", function(o) {
139
- const t = {
140
+ g(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), g(this, "getOptionsPage", (r, e = 25, t = 1) => ({
141
+ ...r,
142
+ per_page: e,
143
+ page: t
144
+ })), g(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), g(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), g(this, "range", (r = 0, e = r) => {
145
+ const t = Math.abs(e - r) || 0, o = r < e ? 1 : -1;
146
+ return this.arrayFrom(t, (s, n) => n * o + r);
147
+ }), g(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), g(this, "flatMap", (r = [], e) => r.map(e).reduce((t, o) => [...t, ...o], [])), g(this, "escapeHTML", function(r) {
148
+ const e = {
140
149
  "&": "&amp;",
141
150
  "<": "&lt;",
142
151
  ">": "&gt;",
143
152
  '"': "&quot;",
144
153
  "'": "&#39;"
145
- }, r = /[&<>"']/g, s = new RegExp(r.source);
146
- return o && s.test(o) ? o.replace(r, (i) => t[i]) : o;
154
+ }, t = /[&<>"']/g, o = new RegExp(t.source);
155
+ return r && o.test(r) ? r.replace(t, (s) => e[s]) : r;
147
156
  });
148
157
  }
149
158
  /**
@@ -153,226 +162,226 @@ let Br = class {
153
162
  * @param {boolean} isArray
154
163
  * @return {string} Stringified object
155
164
  */
156
- stringify(o, t, r) {
157
- const s = [];
158
- for (const i in o) {
159
- if (!Object.prototype.hasOwnProperty.call(o, i))
165
+ stringify(r, e, t) {
166
+ const o = [];
167
+ for (const s in r) {
168
+ if (!Object.prototype.hasOwnProperty.call(r, s))
160
169
  continue;
161
- const l = o[i], u = r ? "" : encodeURIComponent(i);
162
- let f;
163
- typeof l == "object" ? f = this.stringify(
164
- l,
165
- t ? t + encodeURIComponent(`[${u}]`) : u,
166
- Array.isArray(l)
167
- ) : f = `${t ? t + encodeURIComponent(`[${u}]`) : u}=${encodeURIComponent(l)}`, s.push(f);
168
- }
169
- return s.join("&");
170
+ const n = r[s], a = t ? "" : encodeURIComponent(s);
171
+ let l;
172
+ typeof n == "object" ? l = this.stringify(
173
+ n,
174
+ e ? e + encodeURIComponent(`[${a}]`) : a,
175
+ Array.isArray(n)
176
+ ) : l = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(l);
177
+ }
178
+ return o.join("&");
170
179
  }
171
180
  /**
172
181
  * @method getRegionURL
173
182
  * @param {string} regionCode region code, could be eu, us, cn, ap or ca
174
183
  * @return {string} The base URL of the region
175
184
  */
176
- getRegionURL(o) {
177
- const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", i = "api-ap.storyblok.com", l = "api-ca.storyblok.com";
178
- switch (o) {
185
+ getRegionURL(r) {
186
+ const e = "api.storyblok.com", t = "api-us.storyblok.com", o = "app.storyblokchina.cn", s = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
187
+ switch (r) {
179
188
  case "us":
180
- return r;
189
+ return t;
181
190
  case "cn":
182
- return s;
191
+ return o;
183
192
  case "ap":
184
- return i;
193
+ return s;
185
194
  case "ca":
186
- return l;
195
+ return n;
187
196
  default:
188
- return t;
197
+ return e;
189
198
  }
190
199
  }
191
200
  };
192
- const Ur = function(o, t) {
193
- const r = {};
194
- for (const s in o) {
195
- const i = o[s];
196
- t.includes(s) && i !== null && (r[s] = i);
201
+ const q = function(r, e) {
202
+ const t = {};
203
+ for (const o in r) {
204
+ const s = r[o];
205
+ e.includes(o) && s !== null && (t[o] = s);
197
206
  }
198
- return r;
199
- }, Hr = (o) => o === "email", qr = () => ({
207
+ return t;
208
+ }, H = (r) => r === "email", W = () => ({
200
209
  singleTag: "hr"
201
- }), Gr = () => ({
210
+ }), J = () => ({
202
211
  tag: "blockquote"
203
- }), Jr = () => ({
212
+ }), V = () => ({
204
213
  tag: "ul"
205
- }), Wr = (o) => ({
214
+ }), K = (r) => ({
206
215
  tag: [
207
216
  "pre",
208
217
  {
209
218
  tag: "code",
210
- attrs: o.attrs
219
+ attrs: r.attrs
211
220
  }
212
221
  ]
213
- }), Kr = () => ({
222
+ }), Z = () => ({
214
223
  singleTag: "br"
215
- }), Zr = (o) => ({
216
- tag: `h${o.attrs.level}`
217
- }), Vr = (o) => ({
224
+ }), G = (r) => ({
225
+ tag: `h${r.attrs.level}`
226
+ }), X = (r) => ({
218
227
  singleTag: [
219
228
  {
220
229
  tag: "img",
221
- attrs: Ur(o.attrs, ["src", "alt", "title"])
230
+ attrs: q(r.attrs, ["src", "alt", "title"])
222
231
  }
223
232
  ]
224
- }), Xr = () => ({
233
+ }), Y = () => ({
225
234
  tag: "li"
226
- }), Yr = () => ({
235
+ }), Q = () => ({
227
236
  tag: "ol"
228
- }), Qr = () => ({
237
+ }), ee = () => ({
229
238
  tag: "p"
230
- }), en = (o) => ({
239
+ }), te = (r) => ({
231
240
  tag: [
232
241
  {
233
242
  tag: "span",
234
243
  attrs: {
235
244
  "data-type": "emoji",
236
- "data-name": o.attrs.name,
237
- emoji: o.attrs.emoji
245
+ "data-name": r.attrs.name,
246
+ emoji: r.attrs.emoji
238
247
  }
239
248
  }
240
249
  ]
241
- }), tn = () => ({
250
+ }), re = () => ({
242
251
  tag: "b"
243
- }), rn = () => ({
252
+ }), oe = () => ({
244
253
  tag: "s"
245
- }), nn = () => ({
254
+ }), se = () => ({
246
255
  tag: "u"
247
- }), on = () => ({
256
+ }), ne = () => ({
248
257
  tag: "strong"
249
- }), an = () => ({
258
+ }), ae = () => ({
250
259
  tag: "code"
251
- }), sn = () => ({
260
+ }), le = () => ({
252
261
  tag: "i"
253
- }), ln = (o) => {
254
- if (!o.attrs)
262
+ }), ie = (r) => {
263
+ if (!r.attrs)
255
264
  return {
256
265
  tag: ""
257
266
  };
258
- const t = new Br().escapeHTML, r = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
259
- if (delete r.linktype, r.href && (r.href = t(o.attrs.href || "")), Hr(s) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
260
- for (const i in r.custom)
261
- r[i] = r.custom[i];
262
- delete r.custom;
267
+ const e = new U().escapeHTML, t = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
268
+ if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), H(o) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
269
+ for (const s in t.custom)
270
+ t[s] = t.custom[s];
271
+ delete t.custom;
263
272
  }
264
273
  return {
265
274
  tag: [
266
275
  {
267
276
  tag: "a",
268
- attrs: r
277
+ attrs: t
269
278
  }
270
279
  ]
271
280
  };
272
- }, cn = (o) => ({
281
+ }, ce = (r) => ({
273
282
  tag: [
274
283
  {
275
284
  tag: "span",
276
- attrs: o.attrs
285
+ attrs: r.attrs
277
286
  }
278
287
  ]
279
- }), un = () => ({
288
+ }), ue = () => ({
280
289
  tag: "sub"
281
- }), fn = () => ({
290
+ }), de = () => ({
282
291
  tag: "sup"
283
- }), dn = (o) => ({
292
+ }), ge = (r) => ({
284
293
  tag: [
285
294
  {
286
295
  tag: "span",
287
- attrs: o.attrs
296
+ attrs: r.attrs
288
297
  }
289
298
  ]
290
- }), pn = (o) => {
291
- var t;
292
- return (t = o.attrs) != null && t.color ? {
299
+ }), pe = (r) => {
300
+ var e;
301
+ return (e = r.attrs) != null && e.color ? {
293
302
  tag: [
294
303
  {
295
304
  tag: "span",
296
305
  attrs: {
297
- style: `background-color:${o.attrs.color};`
306
+ style: `background-color:${r.attrs.color};`
298
307
  }
299
308
  }
300
309
  ]
301
310
  } : {
302
311
  tag: ""
303
312
  };
304
- }, gn = (o) => {
305
- var t;
306
- return (t = o.attrs) != null && t.color ? {
313
+ }, fe = (r) => {
314
+ var e;
315
+ return (e = r.attrs) != null && e.color ? {
307
316
  tag: [
308
317
  {
309
318
  tag: "span",
310
319
  attrs: {
311
- style: `color:${o.attrs.color}`
320
+ style: `color:${r.attrs.color}`
312
321
  }
313
322
  }
314
323
  ]
315
324
  } : {
316
325
  tag: ""
317
326
  };
318
- }, hn = {
327
+ }, he = {
319
328
  nodes: {
320
- horizontal_rule: qr,
321
- blockquote: Gr,
322
- bullet_list: Jr,
323
- code_block: Wr,
324
- hard_break: Kr,
325
- heading: Zr,
326
- image: Vr,
327
- list_item: Xr,
328
- ordered_list: Yr,
329
- paragraph: Qr,
330
- emoji: en
329
+ horizontal_rule: W,
330
+ blockquote: J,
331
+ bullet_list: V,
332
+ code_block: K,
333
+ hard_break: Z,
334
+ heading: G,
335
+ image: X,
336
+ list_item: Y,
337
+ ordered_list: Q,
338
+ paragraph: ee,
339
+ emoji: te
331
340
  },
332
341
  marks: {
333
- bold: tn,
334
- strike: rn,
335
- underline: nn,
336
- strong: on,
337
- code: an,
338
- italic: sn,
339
- link: ln,
340
- styled: cn,
341
- subscript: un,
342
- superscript: fn,
343
- anchor: dn,
344
- highlight: pn,
345
- textStyle: gn
342
+ bold: re,
343
+ strike: oe,
344
+ underline: se,
345
+ strong: ne,
346
+ code: ae,
347
+ italic: le,
348
+ link: ie,
349
+ styled: ce,
350
+ subscript: ue,
351
+ superscript: de,
352
+ anchor: ge,
353
+ highlight: pe,
354
+ textStyle: fe
346
355
  }
347
- }, bn = function(o) {
348
- const t = {
356
+ }, be = function(r) {
357
+ const e = {
349
358
  "&": "&amp;",
350
359
  "<": "&lt;",
351
360
  ">": "&gt;",
352
361
  '"': "&quot;",
353
362
  "'": "&#39;"
354
- }, r = /[&<>"']/g, s = new RegExp(r.source);
355
- return o && s.test(o) ? o.replace(r, (i) => t[i]) : o;
363
+ }, t = /[&<>"']/g, o = new RegExp(t.source);
364
+ return r && o.test(r) ? r.replace(t, (s) => e[s]) : r;
356
365
  };
357
- let Ue = !1;
358
- class yn {
359
- constructor(t) {
360
- S(this, "marks"), S(this, "nodes"), t || (t = hn), this.marks = t.marks || [], this.nodes = t.nodes || [];
366
+ let S = !1;
367
+ class ye {
368
+ constructor(e) {
369
+ g(this, "marks"), g(this, "nodes"), e || (e = he), this.marks = e.marks || [], this.nodes = e.nodes || [];
361
370
  }
362
- addNode(t, r) {
363
- this.nodes[t] = r;
371
+ addNode(e, t) {
372
+ this.nodes[e] = t;
364
373
  }
365
- addMark(t, r) {
366
- this.marks[t] = r;
374
+ addMark(e, t) {
375
+ this.marks[e] = t;
367
376
  }
368
- render(t, r = { optimizeImages: !1 }, s = !0) {
369
- if (!Ue && s && (console.warn(
377
+ render(e, t = { optimizeImages: !1 }, o = !0) {
378
+ if (!S && o && (console.warn(
370
379
  "Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
371
- ), Ue = !0), t && t.content && Array.isArray(t.content)) {
372
- let i = "";
373
- return t.content.forEach((l) => {
374
- i += this.renderNode(l);
375
- }), r.optimizeImages ? this.optimizeImages(i, r.optimizeImages) : i;
380
+ ), S = !0), e && e.content && Array.isArray(e.content)) {
381
+ let s = "";
382
+ return e.content.forEach((n) => {
383
+ s += this.renderNode(n);
384
+ }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
376
385
  }
377
386
  return console.warn(
378
387
  `The render method must receive an Object with a "content" field.
@@ -401,924 +410,286 @@ class yn {
401
410
  }`
402
411
  ), "";
403
412
  }
404
- optimizeImages(t, r) {
405
- let s = 0, i = 0, l = "", u = "";
406
- typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, s = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, i = r.height), (r.loading === "lazy" || r.loading === "eager") && (l += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (l += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (u += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (u += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-F]{6}/gi) || r.filters.fill === "transparent") && (u += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (u += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (u += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (u += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (u += `:rotate(${r.filters.rotate})`), u.length > 0 && (u = `/filters${u}`))), l.length > 0 && (t = t.replace(/<img/g, `<img ${l.trim()}`));
407
- const f = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${u}` : "";
408
- return t = t.replace(
413
+ optimizeImages(e, t) {
414
+ let o = 0, s = 0, n = "", a = "";
415
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, o = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, s = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
416
+ const l = o > 0 || s > 0 || a.length > 0 ? `${o}x${s}${a}` : "";
417
+ return e = e.replace(
409
418
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
410
- `a.storyblok.com/f/$1/$2.$3/m/${f}`
411
- ), typeof r != "boolean" && (r.sizes || r.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (g) => {
412
- var y, _;
413
- const C = g.match(
419
+ `a.storyblok.com/f/$1/$2.$3/m/${l}`
420
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
421
+ var c, u;
422
+ const p = i.match(
414
423
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
415
424
  );
416
- if (C && C.length > 0) {
417
- const T = {
418
- srcset: (y = r.srcset) == null ? void 0 : y.map((w) => {
419
- if (typeof w == "number")
420
- return `//${C}/m/${w}x0${u} ${w}w`;
421
- if (typeof w == "object" && w.length === 2) {
422
- let x = 0, H = 0;
423
- return typeof w[0] == "number" && (x = w[0]), typeof w[1] == "number" && (H = w[1]), `//${C}/m/${x}x${H}${u} ${x}w`;
425
+ if (p && p.length > 0) {
426
+ const f = {
427
+ srcset: (c = t.srcset) == null ? void 0 : c.map((d) => {
428
+ if (typeof d == "number")
429
+ return `//${p}/m/${d}x0${a} ${d}w`;
430
+ if (typeof d == "object" && d.length === 2) {
431
+ let b = 0, m = 0;
432
+ return typeof d[0] == "number" && (b = d[0]), typeof d[1] == "number" && (m = d[1]), `//${p}/m/${b}x${m}${a} ${b}w`;
424
433
  }
425
434
  return "";
426
435
  }).join(", "),
427
- sizes: (_ = r.sizes) == null ? void 0 : _.map((w) => w).join(", ")
436
+ sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
428
437
  };
429
- let $ = "";
430
- return T.srcset && ($ += `srcset="${T.srcset}" `), T.sizes && ($ += `sizes="${T.sizes}" `), g.replace(/<img/g, `<img ${$.trim()}`);
438
+ let h = "";
439
+ return f.srcset && (h += `srcset="${f.srcset}" `), f.sizes && (h += `sizes="${f.sizes}" `), i.replace(/<img/g, `<img ${h.trim()}`);
431
440
  }
432
- return g;
433
- })), t;
441
+ return i;
442
+ })), e;
434
443
  }
435
- renderNode(t) {
436
- const r = [];
437
- t.marks && t.marks.forEach((i) => {
438
- const l = this.getMatchingMark(i);
439
- l && l.tag !== "" && r.push(this.renderOpeningTag(l.tag));
444
+ renderNode(e) {
445
+ const t = [];
446
+ e.marks && e.marks.forEach((s) => {
447
+ const n = this.getMatchingMark(s);
448
+ n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
440
449
  });
441
- const s = this.getMatchingNode(t);
442
- return s && s.tag && r.push(this.renderOpeningTag(s.tag)), t.content ? t.content.forEach((i) => {
443
- r.push(this.renderNode(i));
444
- }) : t.text ? r.push(bn(t.text)) : s && s.singleTag ? r.push(this.renderTag(s.singleTag, " /")) : s && s.html ? r.push(s.html) : t.type === "emoji" && r.push(this.renderEmoji(t)), s && s.tag && r.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((i) => {
445
- const l = this.getMatchingMark(i);
446
- l && l.tag !== "" && r.push(this.renderClosingTag(l.tag));
447
- }), r.join("");
450
+ const o = this.getMatchingNode(e);
451
+ return o && o.tag && t.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((s) => {
452
+ t.push(this.renderNode(s));
453
+ }) : e.text ? t.push(be(e.text)) : o && o.singleTag ? t.push(this.renderTag(o.singleTag, " /")) : o && o.html ? t.push(o.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), o && o.tag && t.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
454
+ const n = this.getMatchingMark(s);
455
+ n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
456
+ }), t.join("");
448
457
  }
449
- renderTag(t, r) {
450
- return t.constructor === String ? `<${t}${r}>` : t.map((s) => {
451
- if (s.constructor === String)
452
- return `<${s}${r}>`;
458
+ renderTag(e, t) {
459
+ return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
460
+ if (o.constructor === String)
461
+ return `<${o}${t}>`;
453
462
  {
454
- let i = `<${s.tag}`;
455
- if (s.attrs) {
456
- for (const l in s.attrs)
457
- if (Object.prototype.hasOwnProperty.call(s.attrs, l)) {
458
- const u = s.attrs[l];
459
- u !== null && (i += ` ${l}="${u}"`);
463
+ let s = `<${o.tag}`;
464
+ if (o.attrs) {
465
+ for (const n in o.attrs)
466
+ if (Object.prototype.hasOwnProperty.call(o.attrs, n)) {
467
+ const a = o.attrs[n];
468
+ a !== null && (s += ` ${n}="${a}"`);
460
469
  }
461
470
  }
462
- return `${i}${r}>`;
471
+ return `${s}${t}>`;
463
472
  }
464
473
  }).join("");
465
474
  }
466
- renderOpeningTag(t) {
467
- return this.renderTag(t, "");
475
+ renderOpeningTag(e) {
476
+ return this.renderTag(e, "");
468
477
  }
469
- renderClosingTag(t) {
470
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
478
+ renderClosingTag(e) {
479
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
471
480
  }
472
- getMatchingNode(t) {
473
- const r = this.nodes[t.type];
474
- if (typeof r == "function")
475
- return r(t);
481
+ getMatchingNode(e) {
482
+ const t = this.nodes[e.type];
483
+ if (typeof t == "function")
484
+ return t(e);
476
485
  }
477
- getMatchingMark(t) {
478
- const r = this.marks[t.type];
479
- if (typeof r == "function")
480
- return r(t);
486
+ getMatchingMark(e) {
487
+ const t = this.marks[e.type];
488
+ if (typeof t == "function")
489
+ return t(e);
481
490
  }
482
- renderEmoji(t) {
483
- if (t.attrs.emoji)
484
- return t.attrs.emoji;
485
- const r = [
491
+ renderEmoji(e) {
492
+ if (e.attrs.emoji)
493
+ return e.attrs.emoji;
494
+ const t = [
486
495
  {
487
496
  tag: "img",
488
497
  attrs: {
489
- src: t.attrs.fallbackImage,
498
+ src: e.attrs.fallbackImage,
490
499
  draggable: "false",
491
500
  loading: "lazy",
492
501
  align: "absmiddle"
493
502
  }
494
503
  }
495
504
  ];
496
- return this.renderTag(r, " /");
505
+ return this.renderTag(t, " /");
497
506
  }
498
507
  }
499
- const mn = yn, Pn = (o) => {
500
- if (typeof o != "object" || typeof o._editable > "u")
508
+ const me = ye, xe = (r) => {
509
+ if (typeof r != "object" || typeof r._editable > "u")
501
510
  return {};
502
511
  try {
503
- const t = JSON.parse(
504
- o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
512
+ const e = JSON.parse(
513
+ r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
505
514
  );
506
- return t ? {
507
- "data-blok-c": JSON.stringify(t),
508
- "data-blok-uid": t.id + "-" + t.uid
515
+ return e ? {
516
+ "data-blok-c": JSON.stringify(e),
517
+ "data-blok-uid": e.id + "-" + e.uid
509
518
  } : {};
510
519
  } catch {
511
520
  return {};
512
521
  }
513
522
  };
514
- let vn, _n = "https://app.storyblok.com/f/storyblok-v2-latest.js";
515
- const wn = (o, t) => {
516
- o.addNode("blok", (r) => {
517
- let s = "";
518
- return r.attrs.body.forEach((i) => {
519
- s += t(i.component, i);
523
+ let ke, we = "https://app.storyblok.com/f/storyblok-v2-latest.js";
524
+ const $e = (r, e) => {
525
+ r.addNode("blok", (t) => {
526
+ let o = "";
527
+ return t.attrs.body.forEach((s) => {
528
+ o += e(s.component, s);
520
529
  }), {
521
- html: s
530
+ html: o
522
531
  };
523
532
  });
524
- }, kn = (o) => !o || !(o != null && o.content.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule")), Tn = (o, t, r) => {
525
- let s = r || vn;
526
- if (!s) {
533
+ }, ve = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ce = (r, e, t) => {
534
+ let o = t || ke;
535
+ if (!o) {
527
536
  console.error(
528
537
  "Please initialize the Storyblok SDK before calling the renderRichText function"
529
538
  );
530
539
  return;
531
540
  }
532
- return kn(o) ? "" : (t && (s = new mn(t.schema), t.resolver && wn(s, t.resolver)), s.render(o, {}, !1));
533
- }, Mn = () => zr(_n);
534
- function Cn(o) {
535
- const t = {
536
- resolveRelations: []
537
- };
538
- function r(s) {
539
- s && Array.isArray(t.resolveRelations) && t.resolveRelations.push(
540
- ...Array.isArray(s) ? s : [s]
541
- );
542
- }
543
- for (const s of o)
544
- if (s.options) {
545
- const { apiOptions: i, bridgeOptions: l } = s.options;
546
- if (r(i == null ? void 0 : i.resolve_relations), l) {
547
- const { resolveRelations: u, ...f } = l;
548
- r(u), Object.assign(t, f);
549
- }
550
- }
551
- return t.resolveRelations = [...new Set(t.resolveRelations)], t;
552
- }
553
- var Y = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
554
- function An(o) {
555
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
556
- }
557
- var U = { exports: {} };
558
- U.exports;
559
- var He;
560
- function Sn() {
561
- return He || (He = 1, function(o, t) {
562
- var r = 200, s = "__lodash_hash_undefined__", i = 800, l = 16, u = 9007199254740991, f = "[object Arguments]", g = "[object Array]", y = "[object AsyncFunction]", _ = "[object Boolean]", C = "[object Date]", T = "[object Error]", $ = "[object Function]", w = "[object GeneratorFunction]", x = "[object Map]", H = "[object Number]", We = "[object Null]", de = "[object Object]", Ke = "[object Proxy]", Ze = "[object RegExp]", Ve = "[object Set]", Xe = "[object String]", Ye = "[object Undefined]", Qe = "[object WeakMap]", et = "[object ArrayBuffer]", tt = "[object DataView]", rt = "[object Float32Array]", nt = "[object Float64Array]", ot = "[object Int8Array]", at = "[object Int16Array]", st = "[object Int32Array]", it = "[object Uint8Array]", lt = "[object Uint8ClampedArray]", ct = "[object Uint16Array]", ut = "[object Uint32Array]", ft = /[\\^$.*+?()[\]{}|]/g, dt = /^\[object .+?Constructor\]$/, pt = /^(?:0|[1-9]\d*)$/, b = {};
563
- b[rt] = b[nt] = b[ot] = b[at] = b[st] = b[it] = b[lt] = b[ct] = b[ut] = !0, b[f] = b[g] = b[et] = b[_] = b[tt] = b[C] = b[T] = b[$] = b[x] = b[H] = b[de] = b[Ze] = b[Ve] = b[Xe] = b[Qe] = !1;
564
- var pe = typeof Y == "object" && Y && Y.Object === Object && Y, gt = typeof self == "object" && self && self.Object === Object && self, M = pe || gt || Function("return this")(), ge = t && !t.nodeType && t, N = ge && !0 && o && !o.nodeType && o, he = N && N.exports === ge, Q = he && pe.process, be = function() {
565
- try {
566
- var e = N && N.require && N.require("util").types;
567
- return e || Q && Q.binding && Q.binding("util");
568
- } catch {
569
- }
570
- }(), ye = be && be.isTypedArray;
571
- function ht(e, n, a) {
572
- switch (a.length) {
573
- case 0:
574
- return e.call(n);
575
- case 1:
576
- return e.call(n, a[0]);
577
- case 2:
578
- return e.call(n, a[0], a[1]);
579
- case 3:
580
- return e.call(n, a[0], a[1], a[2]);
581
- }
582
- return e.apply(n, a);
583
- }
584
- function bt(e, n) {
585
- for (var a = -1, c = Array(e); ++a < e; )
586
- c[a] = n(a);
587
- return c;
588
- }
589
- function yt(e) {
590
- return function(n) {
591
- return e(n);
592
- };
593
- }
594
- function mt(e, n) {
595
- return e == null ? void 0 : e[n];
596
- }
597
- function vt(e, n) {
598
- return function(a) {
599
- return e(n(a));
600
- };
601
- }
602
- var _t = Array.prototype, wt = Function.prototype, q = Object.prototype, ee = M["__core-js_shared__"], G = wt.toString, O = q.hasOwnProperty, me = function() {
603
- var e = /[^.]+$/.exec(ee && ee.keys && ee.keys.IE_PROTO || "");
604
- return e ? "Symbol(src)_1." + e : "";
605
- }(), ve = q.toString, kt = G.call(Object), Tt = RegExp(
606
- "^" + G.call(O).replace(ft, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
607
- ), J = he ? M.Buffer : void 0, _e = M.Symbol, we = M.Uint8Array;
608
- J && J.allocUnsafe;
609
- var ke = vt(Object.getPrototypeOf, Object), Te = Object.create, Ct = q.propertyIsEnumerable, At = _t.splice, j = _e ? _e.toStringTag : void 0, W = function() {
610
- try {
611
- var e = ne(Object, "defineProperty");
612
- return e({}, "", {}), e;
613
- } catch {
614
- }
615
- }(), St = J ? J.isBuffer : void 0, Ce = Math.max, It = Date.now, Ae = ne(M, "Map"), z = ne(Object, "create"), $t = /* @__PURE__ */ function() {
616
- function e() {
617
- }
618
- return function(n) {
619
- if (!R(n))
620
- return {};
621
- if (Te)
622
- return Te(n);
623
- e.prototype = n;
624
- var a = new e();
625
- return e.prototype = void 0, a;
626
- };
627
- }();
628
- function E(e) {
629
- var n = -1, a = e == null ? 0 : e.length;
630
- for (this.clear(); ++n < a; ) {
631
- var c = e[n];
632
- this.set(c[0], c[1]);
633
- }
634
- }
635
- function Ot() {
636
- this.__data__ = z ? z(null) : {}, this.size = 0;
637
- }
638
- function xt(e) {
639
- var n = this.has(e) && delete this.__data__[e];
640
- return this.size -= n ? 1 : 0, n;
641
- }
642
- function jt(e) {
643
- var n = this.__data__;
644
- if (z) {
645
- var a = n[e];
646
- return a === s ? void 0 : a;
647
- }
648
- return O.call(n, e) ? n[e] : void 0;
649
- }
650
- function Et(e) {
651
- var n = this.__data__;
652
- return z ? n[e] !== void 0 : O.call(n, e);
653
- }
654
- function Rt(e, n) {
655
- var a = this.__data__;
656
- return this.size += this.has(e) ? 0 : 1, a[e] = z && n === void 0 ? s : n, this;
657
- }
658
- E.prototype.clear = Ot, E.prototype.delete = xt, E.prototype.get = jt, E.prototype.has = Et, E.prototype.set = Rt;
659
- function I(e) {
660
- var n = -1, a = e == null ? 0 : e.length;
661
- for (this.clear(); ++n < a; ) {
662
- var c = e[n];
663
- this.set(c[0], c[1]);
664
- }
665
- }
666
- function Lt() {
667
- this.__data__ = [], this.size = 0;
668
- }
669
- function Pt(e) {
670
- var n = this.__data__, a = K(n, e);
671
- if (a < 0)
672
- return !1;
673
- var c = n.length - 1;
674
- return a == c ? n.pop() : At.call(n, a, 1), --this.size, !0;
675
- }
676
- function Mt(e) {
677
- var n = this.__data__, a = K(n, e);
678
- return a < 0 ? void 0 : n[a][1];
679
- }
680
- function Nt(e) {
681
- return K(this.__data__, e) > -1;
682
- }
683
- function zt(e, n) {
684
- var a = this.__data__, c = K(a, e);
685
- return c < 0 ? (++this.size, a.push([e, n])) : a[c][1] = n, this;
686
- }
687
- I.prototype.clear = Lt, I.prototype.delete = Pt, I.prototype.get = Mt, I.prototype.has = Nt, I.prototype.set = zt;
688
- function L(e) {
689
- var n = -1, a = e == null ? 0 : e.length;
690
- for (this.clear(); ++n < a; ) {
691
- var c = e[n];
692
- this.set(c[0], c[1]);
693
- }
694
- }
695
- function Ft() {
696
- this.size = 0, this.__data__ = {
697
- hash: new E(),
698
- map: new (Ae || I)(),
699
- string: new E()
700
- };
701
- }
702
- function Dt(e) {
703
- var n = V(this, e).delete(e);
704
- return this.size -= n ? 1 : 0, n;
705
- }
706
- function Bt(e) {
707
- return V(this, e).get(e);
708
- }
709
- function Ut(e) {
710
- return V(this, e).has(e);
711
- }
712
- function Ht(e, n) {
713
- var a = V(this, e), c = a.size;
714
- return a.set(e, n), this.size += a.size == c ? 0 : 1, this;
715
- }
716
- L.prototype.clear = Ft, L.prototype.delete = Dt, L.prototype.get = Bt, L.prototype.has = Ut, L.prototype.set = Ht;
717
- function P(e) {
718
- var n = this.__data__ = new I(e);
719
- this.size = n.size;
720
- }
721
- function qt() {
722
- this.__data__ = new I(), this.size = 0;
723
- }
724
- function Gt(e) {
725
- var n = this.__data__, a = n.delete(e);
726
- return this.size = n.size, a;
727
- }
728
- function Jt(e) {
729
- return this.__data__.get(e);
730
- }
731
- function Wt(e) {
732
- return this.__data__.has(e);
733
- }
734
- function Kt(e, n) {
735
- var a = this.__data__;
736
- if (a instanceof I) {
737
- var c = a.__data__;
738
- if (!Ae || c.length < r - 1)
739
- return c.push([e, n]), this.size = ++a.size, this;
740
- a = this.__data__ = new L(c);
741
- }
742
- return a.set(e, n), this.size = a.size, this;
743
- }
744
- P.prototype.clear = qt, P.prototype.delete = Gt, P.prototype.get = Jt, P.prototype.has = Wt, P.prototype.set = Kt;
745
- function Zt(e, n) {
746
- var a = se(e), c = !a && ae(e), d = !a && !c && xe(e), h = !a && !c && !d && Ee(e), m = a || c || d || h, p = m ? bt(e.length, String) : [], v = p.length;
747
- for (var A in e)
748
- m && // Safari 9 has enumerable `arguments.length` in strict mode.
749
- (A == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
750
- d && (A == "offset" || A == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
751
- h && (A == "buffer" || A == "byteLength" || A == "byteOffset") || // Skip index properties.
752
- $e(A, v)) || p.push(A);
753
- return p;
754
- }
755
- function te(e, n, a) {
756
- (a !== void 0 && !X(e[n], a) || a === void 0 && !(n in e)) && re(e, n, a);
757
- }
758
- function Vt(e, n, a) {
759
- var c = e[n];
760
- (!(O.call(e, n) && X(c, a)) || a === void 0 && !(n in e)) && re(e, n, a);
761
- }
762
- function K(e, n) {
763
- for (var a = e.length; a--; )
764
- if (X(e[a][0], n))
765
- return a;
766
- return -1;
767
- }
768
- function re(e, n, a) {
769
- n == "__proto__" && W ? W(e, n, {
770
- configurable: !0,
771
- enumerable: !0,
772
- value: a,
773
- writable: !0
774
- }) : e[n] = a;
775
- }
776
- var Xt = ur();
777
- function Z(e) {
778
- return e == null ? e === void 0 ? Ye : We : j && j in Object(e) ? fr(e) : yr(e);
779
- }
780
- function Se(e) {
781
- return F(e) && Z(e) == f;
782
- }
783
- function Yt(e) {
784
- if (!R(e) || hr(e))
785
- return !1;
786
- var n = le(e) ? Tt : dt;
787
- return n.test(wr(e));
788
- }
789
- function Qt(e) {
790
- return F(e) && je(e.length) && !!b[Z(e)];
791
- }
792
- function er(e) {
793
- if (!R(e))
794
- return br(e);
795
- var n = Oe(e), a = [];
796
- for (var c in e)
797
- c == "constructor" && (n || !O.call(e, c)) || a.push(c);
798
- return a;
799
- }
800
- function Ie(e, n, a, c, d) {
801
- e !== n && Xt(n, function(h, m) {
802
- if (d || (d = new P()), R(h))
803
- tr(e, n, m, a, Ie, c, d);
804
- else {
805
- var p = c ? c(oe(e, m), h, m + "", e, n, d) : void 0;
806
- p === void 0 && (p = h), te(e, m, p);
807
- }
808
- }, Re);
809
- }
810
- function tr(e, n, a, c, d, h, m) {
811
- var p = oe(e, a), v = oe(n, a), A = m.get(v);
812
- if (A) {
813
- te(e, a, A);
814
- return;
815
- }
816
- var k = h ? h(p, v, a + "", e, n, m) : void 0, D = k === void 0;
817
- if (D) {
818
- var ce = se(v), ue = !ce && xe(v), Pe = !ce && !ue && Ee(v);
819
- k = v, ce || ue || Pe ? se(p) ? k = p : kr(p) ? k = ir(p) : ue ? (D = !1, k = or(v)) : Pe ? (D = !1, k = sr(v)) : k = [] : Tr(v) || ae(v) ? (k = p, ae(p) ? k = Cr(p) : (!R(p) || le(p)) && (k = dr(v))) : D = !1;
820
- }
821
- D && (m.set(v, k), d(k, v, c, h, m), m.delete(v)), te(e, a, k);
822
- }
823
- function rr(e, n) {
824
- return vr(mr(e, n, Le), e + "");
825
- }
826
- var nr = W ? function(e, n) {
827
- return W(e, "toString", {
828
- configurable: !0,
829
- enumerable: !1,
830
- value: Sr(n),
831
- writable: !0
832
- });
833
- } : Le;
834
- function or(e, n) {
835
- return e.slice();
836
- }
837
- function ar(e) {
838
- var n = new e.constructor(e.byteLength);
839
- return new we(n).set(new we(e)), n;
840
- }
841
- function sr(e, n) {
842
- var a = ar(e.buffer);
843
- return new e.constructor(a, e.byteOffset, e.length);
844
- }
845
- function ir(e, n) {
846
- var a = -1, c = e.length;
847
- for (n || (n = Array(c)); ++a < c; )
848
- n[a] = e[a];
849
- return n;
850
- }
851
- function lr(e, n, a, c) {
852
- var d = !a;
853
- a || (a = {});
854
- for (var h = -1, m = n.length; ++h < m; ) {
855
- var p = n[h], v = void 0;
856
- v === void 0 && (v = e[p]), d ? re(a, p, v) : Vt(a, p, v);
857
- }
858
- return a;
859
- }
860
- function cr(e) {
861
- return rr(function(n, a) {
862
- var c = -1, d = a.length, h = d > 1 ? a[d - 1] : void 0, m = d > 2 ? a[2] : void 0;
863
- for (h = e.length > 3 && typeof h == "function" ? (d--, h) : void 0, m && pr(a[0], a[1], m) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
864
- var p = a[c];
865
- p && e(n, p, c, h);
866
- }
867
- return n;
868
- });
869
- }
870
- function ur(e) {
871
- return function(n, a, c) {
872
- for (var d = -1, h = Object(n), m = c(n), p = m.length; p--; ) {
873
- var v = m[++d];
874
- if (a(h[v], v, h) === !1)
875
- break;
876
- }
877
- return n;
878
- };
879
- }
880
- function V(e, n) {
881
- var a = e.__data__;
882
- return gr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
883
- }
884
- function ne(e, n) {
885
- var a = mt(e, n);
886
- return Yt(a) ? a : void 0;
887
- }
888
- function fr(e) {
889
- var n = O.call(e, j), a = e[j];
890
- try {
891
- e[j] = void 0;
892
- var c = !0;
893
- } catch {
894
- }
895
- var d = ve.call(e);
896
- return c && (n ? e[j] = a : delete e[j]), d;
897
- }
898
- function dr(e) {
899
- return typeof e.constructor == "function" && !Oe(e) ? $t(ke(e)) : {};
900
- }
901
- function $e(e, n) {
902
- var a = typeof e;
903
- return n = n ?? u, !!n && (a == "number" || a != "symbol" && pt.test(e)) && e > -1 && e % 1 == 0 && e < n;
904
- }
905
- function pr(e, n, a) {
906
- if (!R(a))
907
- return !1;
908
- var c = typeof n;
909
- return (c == "number" ? ie(a) && $e(n, a.length) : c == "string" && n in a) ? X(a[n], e) : !1;
910
- }
911
- function gr(e) {
912
- var n = typeof e;
913
- return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? e !== "__proto__" : e === null;
914
- }
915
- function hr(e) {
916
- return !!me && me in e;
917
- }
918
- function Oe(e) {
919
- var n = e && e.constructor, a = typeof n == "function" && n.prototype || q;
920
- return e === a;
921
- }
922
- function br(e) {
923
- var n = [];
924
- if (e != null)
925
- for (var a in Object(e))
926
- n.push(a);
927
- return n;
928
- }
929
- function yr(e) {
930
- return ve.call(e);
931
- }
932
- function mr(e, n, a) {
933
- return n = Ce(n === void 0 ? e.length - 1 : n, 0), function() {
934
- for (var c = arguments, d = -1, h = Ce(c.length - n, 0), m = Array(h); ++d < h; )
935
- m[d] = c[n + d];
936
- d = -1;
937
- for (var p = Array(n + 1); ++d < n; )
938
- p[d] = c[d];
939
- return p[n] = a(m), ht(e, this, p);
940
- };
941
- }
942
- function oe(e, n) {
943
- if (!(n === "constructor" && typeof e[n] == "function") && n != "__proto__")
944
- return e[n];
945
- }
946
- var vr = _r(nr);
947
- function _r(e) {
948
- var n = 0, a = 0;
949
- return function() {
950
- var c = It(), d = l - (c - a);
951
- if (a = c, d > 0) {
952
- if (++n >= i)
953
- return arguments[0];
954
- } else
955
- n = 0;
956
- return e.apply(void 0, arguments);
957
- };
958
- }
959
- function wr(e) {
960
- if (e != null) {
961
- try {
962
- return G.call(e);
963
- } catch {
964
- }
965
- try {
966
- return e + "";
967
- } catch {
968
- }
969
- }
970
- return "";
971
- }
972
- function X(e, n) {
973
- return e === n || e !== e && n !== n;
974
- }
975
- var ae = Se(/* @__PURE__ */ function() {
976
- return arguments;
977
- }()) ? Se : function(e) {
978
- return F(e) && O.call(e, "callee") && !Ct.call(e, "callee");
979
- }, se = Array.isArray;
980
- function ie(e) {
981
- return e != null && je(e.length) && !le(e);
982
- }
983
- function kr(e) {
984
- return F(e) && ie(e);
985
- }
986
- var xe = St || Ir;
987
- function le(e) {
988
- if (!R(e))
989
- return !1;
990
- var n = Z(e);
991
- return n == $ || n == w || n == y || n == Ke;
992
- }
993
- function je(e) {
994
- return typeof e == "number" && e > -1 && e % 1 == 0 && e <= u;
995
- }
996
- function R(e) {
997
- var n = typeof e;
998
- return e != null && (n == "object" || n == "function");
999
- }
1000
- function F(e) {
1001
- return e != null && typeof e == "object";
1002
- }
1003
- function Tr(e) {
1004
- if (!F(e) || Z(e) != de)
1005
- return !1;
1006
- var n = ke(e);
1007
- if (n === null)
1008
- return !0;
1009
- var a = O.call(n, "constructor") && n.constructor;
1010
- return typeof a == "function" && a instanceof a && G.call(a) == kt;
1011
- }
1012
- var Ee = ye ? yt(ye) : Qt;
1013
- function Cr(e) {
1014
- return lr(e, Re(e));
1015
- }
1016
- function Re(e) {
1017
- return ie(e) ? Zt(e) : er(e);
1018
- }
1019
- var Ar = cr(function(e, n, a, c) {
1020
- Ie(e, n, a, c);
1021
- });
1022
- function Sr(e) {
1023
- return function() {
1024
- return e;
1025
- };
1026
- }
1027
- function Le(e) {
1028
- return e;
1029
- }
1030
- function Ir() {
1031
- return !1;
1032
- }
1033
- o.exports = Ar;
1034
- }(U, U.exports)), U.exports;
1035
- }
1036
- var In = Sn();
1037
- const $n = /* @__PURE__ */ An(In);
1038
- function On(o) {
1039
- let t = {};
1040
- function r(s, i) {
1041
- if ((i == null ? void 0 : i.type) === "AwaitExpression" && i.argument.type === "CallExpression" && i.argument.callee.type === "Identifier" && i.argument.callee.name === "useStoryblok") {
1042
- const l = i.argument.arguments;
1043
- if (l && l[1].type === "ObjectExpression") {
1044
- const u = qe(l[1].properties);
1045
- t = {
1046
- ...t,
1047
- apiOptions: u
1048
- };
1049
- }
1050
- if (l && l[2].type === "ObjectExpression") {
1051
- const u = qe(l[2].properties);
1052
- t = {
1053
- ...t,
1054
- bridgeOptions: u
1055
- };
1056
- }
1057
- }
1058
- }
1059
- return $n({}, o, r), t;
1060
- }
1061
- function qe(o) {
1062
- const t = {};
1063
- return o.reduce((r, s) => {
1064
- if (s.type !== "Property")
1065
- return r;
1066
- const { key: i, value: l } = s, { type: u } = l;
1067
- if (i.type !== "Identifier")
1068
- return r;
1069
- if (u === "Literal")
1070
- r[i.name] = l.value;
1071
- else if (u === "ArrayExpression") {
1072
- const f = l.elements.reduce(
1073
- (g, y) => y.type === "Literal" && y.value ? [...g, y.value] : g,
1074
- []
1075
- );
1076
- r[i.name] = f;
1077
- }
1078
- return r;
1079
- }, t);
1080
- }
1081
- let B = [];
1082
- function xn(o, t) {
1083
- const r = "virtual:storyblok-bridge", s = `\0${r}`;
1084
- if (!o || t !== "server")
1085
- return {
1086
- name: "vite-plugin-storyblok-bridge",
1087
- resolveId(f) {
1088
- if (f === r)
1089
- return s;
1090
- },
1091
- load(f) {
1092
- if (f === s)
1093
- return "export const bridgeOptions = null";
1094
- }
1095
- };
1096
- let i = [], l = null, u;
1097
- return {
1098
- name: "vite-plugin-storyblok-bridge",
1099
- async resolveId(f) {
1100
- if (f === r)
1101
- return s;
1102
- },
1103
- async transform(f, g) {
1104
- var w;
1105
- if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok"))
1106
- return;
1107
- const _ = this.getModuleInfo(g);
1108
- if (!((w = _ == null ? void 0 : _.meta) != null && w.astro))
1109
- return;
1110
- const [, ...C] = g.split("src/pages/"), T = C.join("/").replace(".astro", ""), $ = On(this.parse(f));
1111
- B.length && (i = B.filter((x) => x.url !== T)), i.push({
1112
- url: T,
1113
- options: $
1114
- }), l && (u && clearTimeout(u), u = setTimeout(() => {
1115
- jn(B, i) || (B.length !== 0 && (l == null || l.restart(), console.info("Bridge options updated. Restarting...")), B = [...i]);
1116
- }, 1e3));
1117
- },
1118
- async load(f) {
1119
- if (f === s)
1120
- return `export const bridgeOptions = ${JSON.stringify(Cn(i))}`;
1121
- },
1122
- configureServer(f) {
1123
- l = f;
1124
- }
1125
- };
1126
- }
1127
- function jn(o = [], t = []) {
1128
- return t.every(({ url: r, options: s }) => {
1129
- const i = o.find((l) => (l == null ? void 0 : l.url) === r);
1130
- return i && JSON.stringify(s) === JSON.stringify(i.options);
1131
- });
1132
- }
1133
- const En = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1134
- <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1135
- <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
1136
- <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
1137
- <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
1138
- <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
1139
- </g>
1140
- </g>
1141
- </g>
1142
- </svg>`;
1143
- let Ge;
1144
- async function Nn(o) {
1145
- const { action: t, story: r } = o || {};
1146
- if (t === "input" && r) {
1147
- const s = async () => {
1148
- const l = await Ln(r), u = document.body;
1149
- if (l.outerHTML === u.outerHTML)
1150
- return;
1151
- const f = document.querySelector('[data-blok-focused="true"]');
1152
- Rn(u, l, f);
1153
- };
1154
- clearTimeout(Ge), Ge = setTimeout(s, 500);
1155
- }
1156
- ["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
1157
- }
1158
- function Rn(o, t, r) {
1159
- if (r) {
1160
- const s = r.getAttribute("data-blok-uid"), i = t.querySelector(
1161
- `[data-blok-uid="${s}"]`
1162
- );
1163
- i && (i.setAttribute("data-blok-focused", "true"), r.replaceWith(i));
1164
- } else
1165
- o.replaceWith(t);
1166
- }
1167
- async function Ln(o) {
1168
- const r = await (await fetch(location.href, {
1169
- method: "POST",
1170
- body: JSON.stringify({
1171
- ...o,
1172
- is_storyblok_preview: !0
1173
- }),
1174
- headers: {
1175
- "Content-Type": "application/json"
1176
- }
1177
- })).text();
1178
- return new DOMParser().parseFromString(r, "text/html").body;
1179
- }
1180
- function zn() {
541
+ return ve(r) ? "" : (e && (o = new me(e.schema), e.resolver && $e(o, e.resolver)), o.render(r, {}, !1));
542
+ }, Ae = () => B(we);
543
+ function Ee() {
1181
544
  if (!(globalThis != null && globalThis.storyblokApiInstance))
1182
545
  throw new Error("storyblokApiInstance has not been initialized correctly");
1183
546
  return globalThis.storyblokApiInstance;
1184
547
  }
1185
- async function Fn(o, t = {}, r = {}, s) {
1186
- var l;
1187
- if (!globalThis.storyblokApiInstance)
1188
- throw new Error("storyblokApiInstance has not been initialized correctly");
1189
- let i = null;
1190
- if (s && s.locals._storyblok_preview_data)
1191
- i = s.locals._storyblok_preview_data;
1192
- else {
1193
- const { data: u } = await ((l = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : l.get(
1194
- o,
1195
- t
1196
- ));
1197
- i = u.story;
1198
- }
1199
- return i;
548
+ async function Le(r) {
549
+ let e = null;
550
+ return r && r.locals._storyblok_preview_data && (e = r.locals._storyblok_preview_data), e;
1200
551
  }
1201
- function Dn(o, t) {
1202
- var s;
1203
- const r = (s = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : s.richTextResolver;
1204
- if (!r)
552
+ function Re(r, e) {
553
+ var o;
554
+ const t = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
555
+ if (!t)
1205
556
  throw new Error(
1206
557
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1207
558
  );
1208
- return Tn(o, t, r);
559
+ return Ce(r, e, t);
1209
560
  }
1210
- function Bn(o) {
1211
- const t = {
561
+ function Ie(r) {
562
+ return typeof r == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});` : "const storyblokInstance = new StoryblokBridge();";
563
+ }
564
+ function je(r) {
565
+ const e = {
1212
566
  useCustomApi: !1,
1213
567
  bridge: !0,
1214
568
  componentsDir: "src",
1215
569
  enableFallbackComponent: !1,
1216
570
  livePreview: !1,
1217
- ...o
1218
- };
571
+ ...r
572
+ }, t = Ie(e.bridge);
1219
573
  return {
1220
574
  name: "@storyblok/astro",
1221
575
  hooks: {
1222
576
  "astro:config:setup": ({
1223
- injectScript: r,
577
+ injectScript: o,
1224
578
  updateConfig: s,
1225
- addDevToolbarApp: i,
1226
- addMiddleware: l,
1227
- config: u
579
+ addDevToolbarApp: n,
580
+ addMiddleware: a,
581
+ config: l
1228
582
  }) => {
1229
583
  if (s({
1230
584
  vite: {
1231
585
  plugins: [
1232
- $r(
1233
- t.accessToken,
1234
- t.useCustomApi,
1235
- t.apiOptions
586
+ N(
587
+ e.accessToken,
588
+ e.useCustomApi,
589
+ e.apiOptions
1236
590
  ),
1237
- Mr(
1238
- t.componentsDir,
1239
- t.components,
1240
- t.enableFallbackComponent,
1241
- t.customFallbackComponent
591
+ _(
592
+ e.componentsDir,
593
+ e.components,
594
+ e.enableFallbackComponent,
595
+ e.customFallbackComponent
1242
596
  ),
1243
- Nr(t),
1244
- xn(
1245
- t.livePreview,
1246
- u.output
1247
- )
597
+ z(e)
1248
598
  ]
1249
599
  }
1250
- }), t.livePreview && (u == null ? void 0 : u.output) !== "server")
600
+ }), e.livePreview && (l == null ? void 0 : l.output) !== "server")
1251
601
  throw new Error(
1252
602
  "To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
1253
603
  );
1254
- if (r(
604
+ o(
1255
605
  "page-ssr",
1256
606
  `
1257
- import { storyblokApiInstance } from "virtual:storyblok-init";
1258
- globalThis.storyblokApiInstance = storyblokApiInstance;
1259
- `
1260
- ), t.bridge && !t.livePreview) {
1261
- let f = "";
1262
- if (typeof t.bridge == "object") {
1263
- const g = { ...t.bridge };
1264
- f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
1265
- g
1266
- )});`;
1267
- } else
1268
- f = "const storyblokInstance = new StoryblokBridge()";
1269
- r(
1270
- "page",
607
+ import { storyblokApiInstance } from "virtual:storyblok-init";
608
+ globalThis.storyblokApiInstance = storyblokApiInstance;
1271
609
  `
1272
- import { loadStoryblokBridge } from "@storyblok/astro";
1273
- loadStoryblokBridge().then(() => {
1274
- const { StoryblokBridge, location } = window;
1275
- ${f}
1276
-
1277
- storyblokInstance.on(["published", "change"], (event) => {
1278
- if (!event.slugChanged) {
1279
- location.reload(true);
1280
- }
610
+ ), e.bridge && !e.livePreview && o(
611
+ "page",
612
+ `
613
+ import { loadStoryblokBridge } from "@storyblok/astro";
614
+ loadStoryblokBridge().then(() => {
615
+ const { StoryblokBridge, location } = window;
616
+ ${t}
617
+ storyblokInstance.on(["published", "change"], (event) => {
618
+ if (!event.slugChanged) {
619
+ location.reload(true);
620
+ }
621
+ });
1281
622
  });
1282
- });
1283
- `
1284
- );
1285
- }
1286
- t.livePreview && (r(
623
+ `
624
+ ), e.livePreview && (o(
1287
625
  "page",
1288
626
  `
1289
- import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
1290
- import { bridgeOptions } from "virtual:storyblok-bridge";
1291
- console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
1292
- loadStoryblokBridge().then(() => {
1293
- const { StoryblokBridge, location } = window;
1294
- if(bridgeOptions){
1295
- const storyblokInstance = new StoryblokBridge(bridgeOptions);
627
+ import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
628
+ loadStoryblokBridge().then(() => {
629
+ const { StoryblokBridge, location } = window;
630
+ ${t}
1296
631
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
1297
- };
1298
- });
1299
- `
1300
- ), l({
632
+ });
633
+ `
634
+ ), a({
1301
635
  entrypoint: "@storyblok/astro/middleware.ts",
1302
636
  order: "pre"
1303
- })), i({
637
+ })), n({
1304
638
  id: "storyblok",
1305
639
  name: "Storyblok",
1306
- icon: En,
640
+ icon: A,
1307
641
  entrypoint: "@storyblok/astro/toolbarApp.ts"
1308
642
  });
1309
643
  }
1310
644
  }
1311
645
  };
1312
646
  }
647
+ let T;
648
+ async function Me(r) {
649
+ const { action: e, story: t } = r || {};
650
+ if (e === "input" && t) {
651
+ const o = async () => {
652
+ const n = await Te(t), a = document.body;
653
+ if (n.outerHTML === a.outerHTML)
654
+ return;
655
+ const l = document.querySelector('[data-blok-focused="true"]');
656
+ Se(a, n, l), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
657
+ };
658
+ clearTimeout(T), T = setTimeout(o, 500);
659
+ }
660
+ ["published", "change"].includes(r == null ? void 0 : r.action) && location.reload();
661
+ }
662
+ function Se(r, e, t) {
663
+ if (t) {
664
+ const o = t.getAttribute("data-blok-uid"), s = e.querySelector(
665
+ `[data-blok-uid="${o}"]`
666
+ );
667
+ s && (s.setAttribute("data-blok-focused", "true"), t.replaceWith(s));
668
+ } else
669
+ r.replaceWith(e);
670
+ }
671
+ async function Te(r) {
672
+ const t = await (await fetch(location.href, {
673
+ method: "POST",
674
+ body: JSON.stringify({
675
+ ...r,
676
+ is_storyblok_preview: !0
677
+ }),
678
+ headers: {
679
+ "Content-Type": "application/json"
680
+ }
681
+ })).text();
682
+ return new DOMParser().parseFromString(t, "text/html").body;
683
+ }
1313
684
  export {
1314
- mn as RichTextResolver,
1315
- hn as RichTextSchema,
1316
- Bn as default,
1317
- Nn as handleStoryblokMessage,
1318
- Mn as loadStoryblokBridge,
1319
- Dn as renderRichText,
1320
- Pn as storyblokEditable,
1321
- Fe as toCamelCase,
1322
- Fn as useStoryblok,
1323
- zn as useStoryblokApi
685
+ me as RichTextResolver,
686
+ he as RichTextSchema,
687
+ Le as getLiveStory,
688
+ Me as handleStoryblokMessage,
689
+ Ae as loadStoryblokBridge,
690
+ Re as renderRichText,
691
+ je as storyblok,
692
+ xe as storyblokEditable,
693
+ v as toCamelCase,
694
+ Ee as useStoryblokApi
1324
695
  };