@storyblok/astro 7.3.7 → 7.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,133 +1,139 @@
1
- const be = `
1
+ const Fe = `
2
2
  <svg class="logo-storyblok logo-storyblok--dark" role="img" aria-label="Storyblok Official Logo" viewBox="0 0 19 22" xmlns="http://www.w3.org/2000/svg">
3
3
  <path d="M29.0287 14.9132C28.2686 14.9132 27.5302 14.8018 26.7918 14.5568C26.0988 14.3265 25.462 13.9468 24.924 13.4432L25.9013 11.7504C26.4443 12.1291 26.9655 12.4186 27.4867 12.6414C27.9862 12.8641 28.4858 12.9532 28.9636 12.9532C29.3111 12.9532 29.5934 12.8864 29.7888 12.7527C29.9843 12.6414 30.0712 12.4409 30.0712 12.1959C30.0712 11.9732 29.9626 11.7504 29.702 11.6168C29.2938 11.4162 28.8636 11.2666 28.4206 11.1714L26.9003 10.6591C26.4877 10.4809 26.1619 10.3027 25.9013 10.1023C25.6407 9.92408 25.4452 9.67908 25.3366 9.43408C25.2184 9.1529 25.1592 8.84935 25.1629 8.54317C25.1502 7.66646 25.5255 6.83107 26.1836 6.27136C26.4877 6.00408 26.8786 5.80363 27.313 5.64772C27.7473 5.49181 28.2251 5.42499 28.7247 5.42499C29.3979 5.42499 30.0277 5.51408 30.6141 5.69226C31.2005 5.89272 31.7652 6.22681 32.3081 6.71681L31.244 8.38726C30.8236 8.07881 30.3722 7.81747 29.8974 7.60772C29.4848 7.42954 29.1156 7.36272 28.7247 7.36272C28.4423 7.36272 28.1817 7.40726 27.9862 7.5409C27.7691 7.65226 27.6822 7.85272 27.6822 8.11999C27.6822 8.38726 27.7908 8.56545 28.008 8.69908C28.2251 8.83272 28.6595 8.96635 29.2459 9.12226C29.7903 9.26289 30.3268 9.4339 30.853 9.63454C31.2874 9.81272 31.6349 10.0132 31.9172 10.2136C32.4511 10.6169 32.7463 11.2726 32.6991 11.9509C32.6991 12.8641 32.3733 13.5768 31.7 14.1114C31.0485 14.6459 30.1798 14.9132 29.0287 14.9132ZM39.7792 14.2673C39.41 14.4232 38.9756 14.5791 38.4978 14.7127C38.02 14.8464 37.5422 14.9354 37.0427 14.9354C36.6952 14.9354 36.3911 14.8909 36.0871 14.8018C35.7915 14.7134 35.5176 14.5616 35.2835 14.3564C35.0663 14.1782 34.8926 13.9109 34.7623 13.6214C34.632 13.3095 34.5451 12.9309 34.5451 12.4854V7.69681H33.4158V5.60317H34.5668V2.68545H37.2599V5.5809H39.0842V7.69681H37.2599V11.5277C37.2599 11.8173 37.325 12.04 37.4771 12.1959C37.6291 12.3073 37.8245 12.3741 38.0417 12.3741C38.2589 12.3741 38.4761 12.3518 38.6715 12.2627C38.8887 12.1959 39.0842 12.1291 39.2362 12.04L39.7575 14.2673H39.7792ZM44.8612 14.9132C44.1701 14.9255 43.4835 14.7968 42.8414 14.5345C41.7112 14.076 40.8261 13.1439 40.409 11.9732C39.9823 10.8102 39.9823 9.52792 40.409 8.36499C40.8261 7.19423 41.7112 6.26214 42.8414 5.80363C43.4278 5.55863 44.1011 5.42499 44.8612 5.42499C46.1833 5.36117 47.4671 5.88947 48.3795 6.87272C48.7922 7.2959 49.0962 7.80817 49.3134 8.36499C49.758 9.5322 49.758 10.8282 49.3134 11.9954C48.8937 13.1518 48.0186 14.0734 46.9027 14.5345C46.2538 14.7998 45.5596 14.9285 44.8612 14.9132ZM42.9066 10.1914C42.9066 10.9041 43.0803 11.4832 43.4495 11.9064C43.8405 12.3518 44.3183 12.5745 44.8829 12.5745C45.4284 12.5853 45.9487 12.3391 46.2946 11.9064C46.4683 11.6836 46.5987 11.4609 46.7072 11.1491C46.8158 10.8595 46.8593 10.5254 46.8593 10.1914C46.8593 9.45636 46.6638 8.87726 46.2946 8.45408C45.9254 8.00863 45.4476 7.78589 44.8829 7.78589C44.3394 7.78464 43.8229 8.02909 43.4712 8.45408C43.2975 8.67681 43.1455 8.89954 43.0369 9.21136C42.939 9.52794 42.8949 9.85944 42.9066 10.1914ZM56.6541 7.98636C56.0026 7.98636 55.3945 8.09772 54.8515 8.32045C54.3736 8.48572 53.9666 8.81646 53.7005 9.2559V14.7573H50.9857V5.60317H53.4833V7.42954C53.7873 6.8059 54.1783 6.3159 54.6778 5.98181C55.1556 5.62545 55.6551 5.44726 56.1981 5.42499H56.4804L56.6541 5.44726V7.96408V7.98636ZM57.8486 16.1159C58.2263 16.2505 58.6217 16.3256 59.0214 16.3386C59.3472 16.3386 59.6078 16.2273 59.8033 16.0045C59.977 15.7818 60.129 15.3364 60.2811 14.7573L56.893 5.60317H59.6947L61.7579 12.3518L63.5605 5.60317H66.1015L62.6918 16.2273C62.1569 18.0318 60.3638 19.1157 58.5653 18.7218C58.3481 18.6773 58.0875 18.6104 57.8486 18.4991V16.1159ZM72.5301 14.9133C71.8568 14.9133 71.2487 14.7795 70.7492 14.4677C70.2417 14.1818 69.8208 13.758 69.533 13.2427V14.7573H67.1657V2.01727H69.9022V7.09545C70.4962 6.02938 71.6157 5.38681 72.8124 5.42499C73.3771 5.42499 73.8983 5.53636 74.3761 5.80363C74.8539 6.02636 75.2448 6.38272 75.614 6.8059C76.6831 8.32739 76.974 10.2831 76.3959 12.0623C76.1787 12.6414 75.8746 13.1536 75.5054 13.5768C74.7429 14.4342 73.6616 14.9198 72.5301 14.9133ZM71.7699 12.5745C72.6515 12.5764 73.4369 12.0037 73.7245 11.1491C74.043 10.2518 73.887 9.24956 73.3119 8.49863C72.9724 8.0401 72.4398 7.7753 71.8785 7.7859C71.4659 7.7859 71.0749 7.94181 70.7057 8.23136C70.3582 8.54317 70.0759 8.92181 69.8805 9.38954V11.305C70.2309 12.0628 70.9738 12.5476 71.7916 12.5523L71.7699 12.5745ZM78.0247 2.01727H80.7395V11.4832C80.7395 12.1959 81.0218 12.53 81.6082 12.53C81.9183 12.5309 82.2239 12.4545 82.4987 12.3073L82.8679 14.3786C82.1072 14.7203 81.2875 14.902 80.4572 14.9132C79.6753 14.9132 79.0672 14.6904 78.6546 14.2895C78.2202 13.8441 78.003 13.265 78.003 12.4632V2.01727H78.0247ZM87.9933 14.9132C87.3023 14.9255 86.6157 14.7968 85.9736 14.5345C84.8367 14.0789 83.9437 13.1469 83.5194 11.9732C82.8914 10.2226 83.2408 8.26037 84.4316 6.85045C84.8659 6.40499 85.3437 6.0709 85.9518 5.80363C86.5382 5.55863 87.2115 5.42499 87.9716 5.42499C89.2937 5.36117 90.5776 5.88947 91.49 6.87272C91.9243 7.2959 92.2066 7.80817 92.4238 8.36499C93.0767 10.1133 92.7249 12.0889 91.5117 13.4877C91.099 13.9332 90.5995 14.2895 89.9914 14.5345C89.3493 14.7968 88.6627 14.9255 87.9716 14.9132H87.9933ZM86.017 10.1914C86.017 10.9041 86.1907 11.4832 86.5599 11.9064C86.9509 12.3518 87.4287 12.5745 87.9933 12.5745C88.5382 12.5821 89.0571 12.3364 89.405 11.9064C89.5788 11.6836 89.7091 11.4609 89.8177 11.1491C89.9262 10.8595 89.9697 10.5254 89.9697 10.1914C89.9697 9.45636 89.7742 8.87726 89.405 8.45408C89.0358 8.00863 88.558 7.78589 87.9933 7.78589C87.4498 7.78464 86.9334 8.02909 86.5817 8.45408C86.4079 8.67681 86.2559 8.89954 86.1473 9.21136C86.0387 9.52317 86.017 9.83499 86.017 10.1914ZM100.112 14.7573L97.7882 11.06L96.8326 12.0845V14.7573H94.1178V2.01727H96.8326V9.38954L99.8514 5.60317H102.74L99.5256 9.54545L103.001 14.7573H100.112Z" fill="currentColor"></path>
4
4
  <path fill-rule="evenodd" clip-rule="evenodd" d="M0 1.71089C0 0.76599 0.76599 0 1.71089 0H17.1089C18.0538 0 18.8198 0.76599 18.8198 1.71089V17.1089C18.8198 18.0538 18.0538 18.8198 17.1089 18.8198H7.13145L4.57616 20.9297C4.24445 21.2036 3.74366 20.9676 3.74366 20.5375V18.8198H1.71089C0.76599 18.8198 0 18.0538 0 17.1089V1.71089ZM3.74233 3.10946H11.9675C13.7438 3.10946 15.1839 4.5495 15.1839 6.32587C15.1839 7.74936 14.2592 8.95687 12.9777 9.38045C14.4761 9.65447 15.6117 10.9667 15.6117 12.5443C15.6117 14.3207 14.1717 15.7607 12.3953 15.7607H3.74247V9.54229H3.74233V3.10946ZM10.583 6.00384H6.73607V7.93369H10.583C11.1159 7.93369 11.5479 7.50168 11.5479 6.96877C11.5479 6.43585 11.1159 6.00384 10.583 6.00384ZM6.73607 10.2925H10.9035C11.4956 10.2925 11.9757 10.7725 11.9757 11.3647C11.9757 11.9568 11.4956 12.4368 10.9035 12.4368H6.73607V10.2925Z" fill="currentColor"></path>
5
5
  </svg>
6
6
  `;
7
- function Ce(e, t, s) {
8
- const r = "virtual:storyblok-init", o = `\0${r}`;
7
+ function qe(e, t, r) {
8
+ const s = "virtual:storyblok-init", n = `\0${s}`;
9
9
  return {
10
10
  name: "vite-plugin-storyblok-init",
11
- async resolveId(n) {
12
- if (n === r)
13
- return o;
11
+ async resolveId(i) {
12
+ if (i === s)
13
+ return n;
14
14
  },
15
- async load(n) {
16
- if (n === o)
15
+ async load(i) {
16
+ if (i === n)
17
17
  return `
18
18
  import { storyblokInit, apiPlugin } from "@storyblok/astro";
19
19
  const { storyblokApi } = storyblokInit({
20
20
  accessToken: "${e}",
21
21
  use: ${t ? "[]" : "[apiPlugin]"},
22
- apiOptions: ${JSON.stringify(s)},
22
+ apiOptions: ${JSON.stringify(r)},
23
23
  });
24
24
  export const storyblokApiInstance = storyblokApi;
25
25
  `;
26
26
  }
27
27
  };
28
28
  }
29
- function ve(e) {
30
- const t = "virtual:storyblok-options", s = `\0${t}`;
29
+ function Ge(e) {
30
+ const t = "virtual:storyblok-options", r = `\0${t}`;
31
31
  return {
32
32
  name: "vite-plugin-storyblok-options",
33
- async resolveId(r) {
34
- if (r === t)
35
- return s;
33
+ async resolveId(s) {
34
+ if (s === t)
35
+ return r;
36
36
  },
37
- async load(r) {
38
- if (r === s)
37
+ async load(s) {
38
+ if (s === r)
39
39
  return `export default ${JSON.stringify(e)}`;
40
40
  }
41
41
  };
42
42
  }
43
- function dt() {
43
+ function lr() {
44
44
  if (!(globalThis != null && globalThis.storyblokApiInstance))
45
45
  throw new Error("storyblokApiInstance has not been initialized correctly");
46
46
  return globalThis.storyblokApiInstance;
47
47
  }
48
- async function pt(e) {
48
+ async function cr(e) {
49
49
  let t = null;
50
- return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
50
+ return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data.story || null), t;
51
+ }
52
+ async function ur({
53
+ locals: e
54
+ }) {
55
+ const { story: t, serverData: r } = e._storyblok_preview_data || {};
56
+ return { story: t, serverData: r };
51
57
  }
52
- function ke(e) {
58
+ function ze(e) {
53
59
  return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
54
60
  }
55
- function we(e) {
61
+ function Je(e) {
56
62
  return e.endsWith(".astro") ? e : `${e}.astro`;
57
63
  }
58
- function F(e) {
64
+ function ge(e) {
59
65
  return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
60
66
  }
61
- const Le = /[\p{Lu}]/u, Ae = /[\p{Ll}]/u, Y = /^[\p{Lu}](?![\p{Lu}])/gu, ie = /([\p{Alpha}\p{N}_]|$)/u, G = /[_.\- ]+/, Ee = new RegExp("^" + G.source), K = new RegExp(G.source + ie.source, "gu"), X = new RegExp("\\d+" + ie.source, "gu"), Re = (e, t, s, r) => {
62
- let o = !1, n = !1, a = !1, l = !1;
63
- for (let c = 0; c < e.length; c++) {
64
- const u = e[c];
65
- l = c > 2 ? e[c - 3] === "-" : !0, o && Le.test(u) ? (e = e.slice(0, c) + "-" + e.slice(c), o = !1, a = n, n = !0, c++) : n && a && Ae.test(u) && (!l || r) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), a = n, n = !1, o = !0) : (o = t(u) === u && s(u) !== u, a = n, n = s(u) === u && t(u) !== u);
67
+ const Ke = /[\p{Lu}]/u, We = /[\p{Ll}]/u, Te = /^[\p{Lu}](?![\p{Lu}])/gu, De = /([\p{Alpha}\p{N}_]|$)/u, Ce = /[_.\- ]+/, Ye = new RegExp("^" + Ce.source), we = new RegExp(Ce.source + De.source, "gu"), Ee = new RegExp("\\d+" + De.source, "gu"), Ze = (e, t, r, s) => {
68
+ let n = !1, i = !1, o = !1, l = !1;
69
+ for (let a = 0; a < e.length; a++) {
70
+ const h = e[a];
71
+ l = a > 2 ? e[a - 3] === "-" : !0, n && Ke.test(h) ? (e = e.slice(0, a) + "-" + e.slice(a), n = !1, o = i, i = !0, a++) : i && o && We.test(h) && (!l || s) ? (e = e.slice(0, a - 1) + "-" + e.slice(a - 1), o = i, i = !1, n = !0) : (n = t(h) === h && r(h) !== h, o = i, i = r(h) === h && t(h) !== h);
66
72
  }
67
73
  return e;
68
- }, Te = (e, t) => (Y.lastIndex = 0, e.replaceAll(Y, (s) => t(s))), _e = (e, t) => (K.lastIndex = 0, X.lastIndex = 0, e.replaceAll(X, (s, r, o) => ["_", "-"].includes(e.charAt(o + s.length)) ? s : t(s)).replaceAll(K, (s, r) => t(r)));
69
- function $e(e, t) {
74
+ }, Xe = (e, t) => (Te.lastIndex = 0, e.replaceAll(Te, (r) => t(r))), Qe = (e, t) => (we.lastIndex = 0, Ee.lastIndex = 0, e.replaceAll(Ee, (r, s, n) => ["_", "-"].includes(e.charAt(n + r.length)) ? r : t(r)).replaceAll(we, (r, s) => t(s)));
75
+ function et(e, t) {
70
76
  if (!(typeof e == "string" || Array.isArray(e)))
71
77
  throw new TypeError("Expected the input to be `string | string[]`");
72
78
  if (t = {
73
79
  pascalCase: !1,
74
80
  preserveConsecutiveUppercase: !1,
75
81
  ...t
76
- }, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
82
+ }, Array.isArray(e) ? e = e.map((i) => i.trim()).filter((i) => i.length).join("-") : e = e.trim(), e.length === 0)
77
83
  return "";
78
- const s = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), r = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
79
- return e.length === 1 ? G.test(e) ? "" : t.pascalCase ? r(e) : s(e) : (e !== s(e) && (e = Re(e, s, r, t.preserveConsecutiveUppercase)), e = e.replace(Ee, ""), e = t.preserveConsecutiveUppercase ? Te(e, s) : s(e), t.pascalCase && (e = r(e.charAt(0)) + e.slice(1)), _e(e, r));
84
+ const r = t.locale === !1 ? (i) => i.toLowerCase() : (i) => i.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (i) => i.toUpperCase() : (i) => i.toLocaleUpperCase(t.locale);
85
+ return e.length === 1 ? Ce.test(e) ? "" : t.pascalCase ? s(e) : r(e) : (e !== r(e) && (e = Ze(e, r, s, t.preserveConsecutiveUppercase)), e = e.replace(Ye, ""), e = t.preserveConsecutiveUppercase ? Xe(e, r) : r(e), t.pascalCase && (e = s(e.charAt(0)) + e.slice(1)), Qe(e, s));
80
86
  }
81
- function Ie(e) {
82
- return $e(e);
87
+ function tt(e) {
88
+ return et(e);
83
89
  }
84
- function Se(e, t, s, r) {
85
- const o = "virtual:import-storyblok-components", n = `\0${o}`;
90
+ function rt(e, t, r, s) {
91
+ const n = "virtual:import-storyblok-components", i = `\0${n}`;
86
92
  return {
87
93
  name: "vite-plugin-import-storyblok-components",
88
94
  /**
89
95
  * Resolves virtual module imports
90
96
  */
91
- async resolveId(a) {
92
- if (a === o)
93
- return n;
97
+ async resolveId(o) {
98
+ if (o === n)
99
+ return i;
94
100
  },
95
101
  /**
96
102
  * Generates the virtual module content with dynamic imports
97
103
  */
98
- async load(a) {
99
- if (a !== n)
104
+ async load(o) {
105
+ if (o !== i)
100
106
  return;
101
- const l = await xe(
107
+ const l = await nt(
102
108
  this,
103
109
  t,
104
- s,
105
- r
106
- ), c = await Me(
110
+ r,
111
+ s
112
+ ), a = await it(
107
113
  this,
108
114
  e,
109
115
  t,
110
- s
116
+ r
111
117
  );
112
- return Oe(
118
+ return st(
113
119
  t,
114
120
  l,
115
- c
121
+ a
116
122
  );
117
123
  }
118
124
  };
119
125
  }
120
- function Oe(e, t, s) {
121
- const o = `${F(e)}/storyblok/**/*.astro`;
126
+ function st(e, t, r) {
127
+ const n = `${ge(e)}/storyblok/**/*.astro`;
122
128
  return `
123
129
  // Import utilities and fallback component
124
130
  import { toCamelCase } from '@storyblok/astro';
125
131
  ${t}
126
- ${s.join(`
132
+ ${r.join(`
127
133
  `)}
128
134
 
129
135
  // Dynamically import all Storyblok components using Vite's glob import
130
- const modules = import.meta.glob('${o}', { eager: true });
136
+ const modules = import.meta.glob('${n}', { eager: true });
131
137
  // Process imported modules into a components object
132
138
  const storyblokComponents = {};
133
139
 
@@ -147,10 +153,10 @@ function Oe(e, t, s) {
147
153
  }
148
154
 
149
155
  // Manual imports (overwrite auto if same key exists)
150
- ${s.map((n) => {
156
+ ${r.map((i) => {
151
157
  var l;
152
- const a = (l = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
153
- return `storyblokComponents['${a}'] = ${a};`;
158
+ const o = (l = i.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
159
+ return `storyblokComponents['${o}'] = ${o};`;
154
160
  }).join(`
155
161
  `)}
156
162
 
@@ -161,40 +167,40 @@ function Oe(e, t, s) {
161
167
  export { storyblokComponents };
162
168
  `.trim();
163
169
  }
164
- async function xe(e, t, s, r) {
165
- if (!s)
170
+ async function nt(e, t, r, s) {
171
+ if (!r)
166
172
  return "";
167
- if (r) {
168
- const o = ae(
173
+ if (s) {
174
+ const n = Ue(
169
175
  t,
170
- r
176
+ s
171
177
  );
172
- if (!await e.resolve(o))
178
+ if (!await e.resolve(n))
173
179
  throw new Error(
174
- `Custom fallback component could not be found. Does "${o}" exist?`
180
+ `Custom fallback component could not be found. Does "${n}" exist?`
175
181
  );
176
- return `import FallbackComponent from '${o}';`;
182
+ return `import FallbackComponent from '${n}';`;
177
183
  }
178
184
  return "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';";
179
185
  }
180
- async function Me(e, t, s, r) {
181
- const o = [];
182
- for await (const [n, a] of Object.entries(t)) {
183
- const l = ae(s, a), c = await e.resolve(l);
184
- if (c)
185
- o.push(`import ${Ie(n)} from "${c.id}"`);
186
- else if (!r)
186
+ async function it(e, t, r, s) {
187
+ const n = [];
188
+ for await (const [i, o] of Object.entries(t)) {
189
+ const l = Ue(r, o), a = await e.resolve(l);
190
+ if (a)
191
+ n.push(`import ${tt(i)} from "${a.id}"`);
192
+ else if (!s)
187
193
  throw new Error(
188
- `Component could not be found for blok "${n}"! Does "${l}" exist?`
194
+ `Component could not be found for blok "${i}"! Does "${l}" exist?`
189
195
  );
190
196
  }
191
- return o;
197
+ return n;
192
198
  }
193
- function ae(e, t) {
194
- const r = `${F(e)}${F(t)}`;
195
- return we(r);
199
+ function Ue(e, t) {
200
+ const s = `${ge(e)}${ge(t)}`;
201
+ return Je(s);
196
202
  }
197
- function ft(e) {
203
+ function dr(e) {
198
204
  const t = {
199
205
  useCustomApi: !1,
200
206
  bridge: !0,
@@ -203,55 +209,55 @@ function ft(e) {
203
209
  livePreview: !1,
204
210
  ...e
205
211
  }, {
206
- accessToken: s,
207
- useCustomApi: r,
208
- apiOptions: o,
209
- componentsDir: n,
210
- customFallbackComponent: a,
212
+ accessToken: r,
213
+ useCustomApi: s,
214
+ apiOptions: n,
215
+ componentsDir: i,
216
+ customFallbackComponent: o,
211
217
  enableFallbackComponent: l,
212
- components: c,
213
- bridge: u,
218
+ components: a,
219
+ bridge: h,
214
220
  livePreview: g
215
- } = t, d = ke(t.bridge);
221
+ } = t, p = ze(t.bridge);
216
222
  return {
217
223
  name: "@storyblok/astro",
218
224
  hooks: {
219
225
  "astro:config:setup": ({
220
- injectScript: C,
221
- updateConfig: R,
222
- addDevToolbarApp: k,
223
- addMiddleware: T,
224
- config: $
226
+ injectScript: w,
227
+ updateConfig: I,
228
+ addDevToolbarApp: E,
229
+ addMiddleware: $,
230
+ config: U
225
231
  }) => {
226
- if (R({
232
+ if (I({
227
233
  vite: {
228
234
  plugins: [
229
- Ce(s, r, o),
230
- Se(
231
- c || {},
232
- n,
235
+ qe(r, s, n),
236
+ rt(
237
+ a || {},
238
+ i,
233
239
  l,
234
- a
240
+ o
235
241
  ),
236
- ve(t)
242
+ Ge(t)
237
243
  ]
238
244
  }
239
- }), g && ($ == null ? void 0 : $.output) !== "server")
245
+ }), g && (U == null ? void 0 : U.output) !== "server")
240
246
  throw new Error(
241
247
  "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."
242
248
  );
243
- C(
249
+ w(
244
250
  "page-ssr",
245
251
  `
246
252
  import { storyblokApiInstance } from "virtual:storyblok-init";
247
253
  globalThis.storyblokApiInstance = storyblokApiInstance;
248
254
  `
249
- ), u && !g && C(
255
+ ), h && !g && w(
250
256
  "page",
251
257
  `import { loadStoryblokBridge } from "@storyblok/astro";
252
258
  loadStoryblokBridge().then(() => {
253
259
  const { StoryblokBridge, location } = window;
254
- ${d}
260
+ ${p}
255
261
  storyblokInstance.on(["published", "change"], (event) => {
256
262
  if (!event.slugChanged) {
257
263
  location.reload(true);
@@ -259,80 +265,398 @@ function ft(e) {
259
265
  });
260
266
  });
261
267
  `
262
- ), g && (C(
268
+ ), g && (w(
263
269
  "page",
264
270
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
265
271
  loadStoryblokBridge().then(() => {
266
272
  const { StoryblokBridge, location } = window;
267
- ${d}
273
+ ${p}
268
274
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
269
275
  });
270
276
  `
271
- ), T({
277
+ ), $({
272
278
  entrypoint: "@storyblok/astro/middleware.ts",
273
279
  order: "pre"
274
- })), k({
280
+ })), E({
275
281
  id: "storyblok",
276
282
  name: "Storyblok",
277
- icon: be,
283
+ icon: Fe,
278
284
  entrypoint: "@storyblok/astro/toolbarApp.ts"
279
285
  });
280
286
  }
281
287
  }
282
288
  };
283
289
  }
284
- let Q;
285
- async function mt(e) {
286
- const { action: t, story: s } = e || {};
287
- if (t === "input" && s) {
288
- const r = async () => {
289
- ee("storyblok-live-preview-updating", { story: s });
290
- const n = await He(s), a = document.body;
291
- if (n.outerHTML === a.outerHTML)
290
+ function hr(e) {
291
+ const t = JSON.stringify(e);
292
+ return t === void 0 ? "null" : t.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/&/g, "\\u0026");
293
+ }
294
+ var _e = 11;
295
+ function ot(e, t) {
296
+ var r = t.attributes, s, n, i, o, l;
297
+ if (!(t.nodeType === _e || e.nodeType === _e)) {
298
+ for (var a = r.length - 1; a >= 0; a--)
299
+ s = r[a], n = s.name, i = s.namespaceURI, o = s.value, i ? (n = s.localName || n, l = e.getAttributeNS(i, n), l !== o && (s.prefix === "xmlns" && (n = s.name), e.setAttributeNS(i, n, o))) : (l = e.getAttribute(n), l !== o && e.setAttribute(n, o));
300
+ for (var h = e.attributes, g = h.length - 1; g >= 0; g--)
301
+ s = h[g], n = s.name, i = s.namespaceURI, i ? (n = s.localName || n, t.hasAttributeNS(i, n) || e.removeAttributeNS(i, n)) : t.hasAttribute(n) || e.removeAttribute(n);
302
+ }
303
+ }
304
+ var se, at = "http://www.w3.org/1999/xhtml", R = typeof document > "u" ? void 0 : document, lt = !!R && "content" in R.createElement("template"), ct = !!R && R.createRange && "createContextualFragment" in R.createRange();
305
+ function ut(e) {
306
+ var t = R.createElement("template");
307
+ return t.innerHTML = e, t.content.childNodes[0];
308
+ }
309
+ function dt(e) {
310
+ se || (se = R.createRange(), se.selectNode(R.body));
311
+ var t = se.createContextualFragment(e);
312
+ return t.childNodes[0];
313
+ }
314
+ function ht(e) {
315
+ var t = R.createElement("body");
316
+ return t.innerHTML = e, t.childNodes[0];
317
+ }
318
+ function ft(e) {
319
+ return e = e.trim(), lt ? ut(e) : ct ? dt(e) : ht(e);
320
+ }
321
+ function ne(e, t) {
322
+ var r = e.nodeName, s = t.nodeName, n, i;
323
+ return r === s ? !0 : (n = r.charCodeAt(0), i = s.charCodeAt(0), n <= 90 && i >= 97 ? r === s.toUpperCase() : i <= 90 && n >= 97 ? s === r.toUpperCase() : !1);
324
+ }
325
+ function pt(e, t) {
326
+ return !t || t === at ? R.createElement(e) : R.createElementNS(t, e);
327
+ }
328
+ function mt(e, t) {
329
+ for (var r = e.firstChild; r; ) {
330
+ var s = r.nextSibling;
331
+ t.appendChild(r), r = s;
332
+ }
333
+ return t;
334
+ }
335
+ function de(e, t, r) {
336
+ e[r] !== t[r] && (e[r] = t[r], e[r] ? e.setAttribute(r, "") : e.removeAttribute(r));
337
+ }
338
+ var Le = {
339
+ OPTION: function(e, t) {
340
+ var r = e.parentNode;
341
+ if (r) {
342
+ var s = r.nodeName.toUpperCase();
343
+ s === "OPTGROUP" && (r = r.parentNode, s = r && r.nodeName.toUpperCase()), s === "SELECT" && !r.hasAttribute("multiple") && (e.hasAttribute("selected") && !t.selected && (e.setAttribute("selected", "selected"), e.removeAttribute("selected")), r.selectedIndex = -1);
344
+ }
345
+ de(e, t, "selected");
346
+ },
347
+ /**
348
+ * The "value" attribute is special for the <input> element since it sets
349
+ * the initial value. Changing the "value" attribute without changing the
350
+ * "value" property will have no effect since it is only used to the set the
351
+ * initial value. Similar for the "checked" attribute, and "disabled".
352
+ */
353
+ INPUT: function(e, t) {
354
+ de(e, t, "checked"), de(e, t, "disabled"), e.value !== t.value && (e.value = t.value), t.hasAttribute("value") || e.removeAttribute("value");
355
+ },
356
+ TEXTAREA: function(e, t) {
357
+ var r = t.value;
358
+ e.value !== r && (e.value = r);
359
+ var s = e.firstChild;
360
+ if (s) {
361
+ var n = s.nodeValue;
362
+ if (n == r || !r && n == e.placeholder)
292
363
  return;
293
- const l = document.querySelector('[data-blok-focused="true"]');
294
- Pe(a, n, l), ee("storyblok-live-preview-updated", { story: s });
295
- };
296
- clearTimeout(Q), Q = setTimeout(r, 500);
364
+ s.nodeValue = r;
365
+ }
366
+ },
367
+ SELECT: function(e, t) {
368
+ if (!t.hasAttribute("multiple")) {
369
+ for (var r = -1, s = 0, n = e.firstChild, i, o; n; )
370
+ if (o = n.nodeName && n.nodeName.toUpperCase(), o === "OPTGROUP")
371
+ i = n, n = i.firstChild, n || (n = i.nextSibling, i = null);
372
+ else {
373
+ if (o === "OPTION") {
374
+ if (n.hasAttribute("selected")) {
375
+ r = s;
376
+ break;
377
+ }
378
+ s++;
379
+ }
380
+ n = n.nextSibling, !n && i && (n = i.nextSibling, i = null);
381
+ }
382
+ e.selectedIndex = r;
383
+ }
297
384
  }
298
- ["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
385
+ }, Y = 1, Re = 11, Se = 3, Ie = 8;
386
+ function H() {
299
387
  }
300
- function Pe(e, t, s) {
301
- if (s) {
302
- const r = s.getAttribute("data-blok-uid"), o = t.querySelector(
303
- `[data-blok-uid="${r}"]`
388
+ function vt(e) {
389
+ if (e)
390
+ return e.getAttribute && e.getAttribute("id") || e.id;
391
+ }
392
+ function yt(e) {
393
+ return function(r, s, n) {
394
+ if (n || (n = {}), typeof s == "string")
395
+ if (r.nodeName === "#document" || r.nodeName === "HTML") {
396
+ var i = s;
397
+ s = R.createElement("html"), s.innerHTML = i;
398
+ } else if (r.nodeName === "BODY") {
399
+ var o = s;
400
+ s = R.createElement("html"), s.innerHTML = o;
401
+ var l = s.querySelector("body");
402
+ l && (s = l);
403
+ } else
404
+ s = ft(s);
405
+ else s.nodeType === Re && (s = s.firstElementChild);
406
+ var a = n.getNodeKey || vt, h = n.onBeforeNodeAdded || H, g = n.onNodeAdded || H, p = n.onBeforeElUpdated || H, w = n.onElUpdated || H, I = n.onBeforeNodeDiscarded || H, E = n.onNodeDiscarded || H, $ = n.onBeforeElChildrenUpdated || H, U = n.skipFromChildren || H, J = n.addChild || function(f, d) {
407
+ return f.appendChild(d);
408
+ }, K = n.childrenOnly === !0, x = /* @__PURE__ */ Object.create(null), j = [];
409
+ function B(f) {
410
+ j.push(f);
411
+ }
412
+ function ee(f, d) {
413
+ if (f.nodeType === Y)
414
+ for (var A = f.firstChild; A; ) {
415
+ var y = void 0;
416
+ d && (y = a(A)) ? B(y) : (E(A), A.firstChild && ee(A, d)), A = A.nextSibling;
417
+ }
418
+ }
419
+ function V(f, d, A) {
420
+ I(f) !== !1 && (d && d.removeChild(f), E(f), ee(f, A));
421
+ }
422
+ function F(f) {
423
+ if (f.nodeType === Y || f.nodeType === Re)
424
+ for (var d = f.firstChild; d; ) {
425
+ var A = a(d);
426
+ A && (x[A] = d), F(d), d = d.nextSibling;
427
+ }
428
+ }
429
+ F(r);
430
+ function W(f) {
431
+ g(f);
432
+ for (var d = f.firstChild; d; ) {
433
+ var A = d.nextSibling, y = a(d);
434
+ if (y) {
435
+ var C = x[y];
436
+ C && ne(d, C) ? (d.parentNode.replaceChild(C, d), P(C, d)) : W(d);
437
+ } else
438
+ W(d);
439
+ d = A;
440
+ }
441
+ }
442
+ function q(f, d, A) {
443
+ for (; d; ) {
444
+ var y = d.nextSibling;
445
+ (A = a(d)) ? B(A) : V(
446
+ d,
447
+ f,
448
+ !0
449
+ /* skip keyed nodes */
450
+ ), d = y;
451
+ }
452
+ }
453
+ function P(f, d, A) {
454
+ var y = a(d);
455
+ if (y && delete x[y], !A) {
456
+ var C = p(f, d);
457
+ if (C === !1 || (C instanceof HTMLElement && (f = C, F(f)), e(f, d), w(f), $(f, d) === !1))
458
+ return;
459
+ }
460
+ f.nodeName !== "TEXTAREA" ? c(f, d) : Le.TEXTAREA(f, d);
461
+ }
462
+ function c(f, d) {
463
+ var A = U(f, d), y = d.firstChild, C = f.firstChild, G, O, z, te, M;
464
+ e: for (; y; ) {
465
+ for (te = y.nextSibling, G = a(y); !A && C; ) {
466
+ if (z = C.nextSibling, y.isSameNode && y.isSameNode(C)) {
467
+ y = te, C = z;
468
+ continue e;
469
+ }
470
+ O = a(C);
471
+ var re = C.nodeType, N = void 0;
472
+ if (re === y.nodeType && (re === Y ? (G ? G !== O && ((M = x[G]) ? z === M ? N = !1 : (f.insertBefore(M, C), O ? B(O) : V(
473
+ C,
474
+ f,
475
+ !0
476
+ /* skip keyed nodes */
477
+ ), C = M, O = a(C)) : N = !1) : O && (N = !1), N = N !== !1 && ne(C, y), N && P(C, y)) : (re === Se || re == Ie) && (N = !0, C.nodeValue !== y.nodeValue && (C.nodeValue = y.nodeValue))), N) {
478
+ y = te, C = z;
479
+ continue e;
480
+ }
481
+ O ? B(O) : V(
482
+ C,
483
+ f,
484
+ !0
485
+ /* skip keyed nodes */
486
+ ), C = z;
487
+ }
488
+ if (G && (M = x[G]) && ne(M, y))
489
+ A || J(f, M), P(M, y);
490
+ else {
491
+ var ue = h(y);
492
+ ue !== !1 && (ue && (y = ue), y.actualize && (y = y.actualize(f.ownerDocument || R)), J(f, y), W(y));
493
+ }
494
+ y = te, C = z;
495
+ }
496
+ q(f, C, O);
497
+ var Ae = Le[f.nodeName];
498
+ Ae && Ae(f, d);
499
+ }
500
+ var u = r, m = u.nodeType, v = s.nodeType;
501
+ if (!K) {
502
+ if (m === Y)
503
+ v === Y ? ne(r, s) || (E(r), u = mt(r, pt(s.nodeName, s.namespaceURI))) : u = s;
504
+ else if (m === Se || m === Ie) {
505
+ if (v === m)
506
+ return u.nodeValue !== s.nodeValue && (u.nodeValue = s.nodeValue), u;
507
+ u = s;
508
+ }
509
+ }
510
+ if (u === s)
511
+ E(r);
512
+ else {
513
+ if (s.isSameNode && s.isSameNode(u))
514
+ return;
515
+ if (P(u, s, K), j)
516
+ for (var b = 0, _ = j.length; b < _; b++) {
517
+ var k = x[j[b]];
518
+ k && V(k, k.parentNode, !1);
519
+ }
520
+ }
521
+ return !K && u !== r && r.parentNode && (u.actualize && (u = u.actualize(r.ownerDocument || R)), r.parentNode.replaceChild(u, r)), u;
522
+ };
523
+ }
524
+ var gt = yt(ot);
525
+ let he, ce = null;
526
+ const bt = 500, Ct = "__STORYBLOK_SERVERDATA__", Ve = "data-blok-focused", Q = "data-blok-uid", kt = "data-preserve-state", At = "storyblok-live-preview", Tt = "storyblok-live-preview-updating", $e = "storyblok-live-preview-updated";
527
+ function wt() {
528
+ const e = document.querySelector(
529
+ `meta[name="${At}"]`
530
+ );
531
+ return (e == null ? void 0 : e.content) === "disabled" || (e == null ? void 0 : e.content) === "false";
532
+ }
533
+ async function fr(e) {
534
+ const { action: t, story: r } = e || {};
535
+ if (["published", "change"].includes(t)) {
536
+ location.reload();
537
+ return;
538
+ }
539
+ if (t === "input" && r) {
540
+ if (wt())
541
+ return;
542
+ ce && ce.abort(), he && clearTimeout(he), he = setTimeout(async () => {
543
+ try {
544
+ await Et(r);
545
+ } catch (s) {
546
+ if (s instanceof Error && s.name === "AbortError")
547
+ return;
548
+ console.error("Failed to update live preview:", s);
549
+ }
550
+ }, bt);
551
+ }
552
+ }
553
+ async function Et(e) {
554
+ if (fe(
555
+ Tt,
556
+ { story: e },
557
+ !0
558
+ ).defaultPrevented)
559
+ return;
560
+ const r = document.body, s = $t(r), n = await It(e, s);
561
+ if (n.outerHTML === r.outerHTML) {
562
+ fe($e, { story: e });
563
+ return;
564
+ }
565
+ const i = document.querySelector(`[${Ve}="true"]`);
566
+ Lt(r, n, i), fe($e, { story: e });
567
+ }
568
+ function _t(e, t) {
569
+ var n, i;
570
+ const r = (n = e.attributes.getNamedItem(Q)) == null ? void 0 : n.value, s = (i = t.attributes.getNamedItem(Q)) == null ? void 0 : i.value;
571
+ r === s && Array.from(e.attributes).forEach((o) => {
572
+ if (o.name === Q)
573
+ return;
574
+ const l = o.value, a = t.getAttribute(o.name);
575
+ (!t.hasAttribute(o.name) || a !== l) && t.setAttribute(o.name, l);
576
+ });
577
+ }
578
+ function Lt(e, t, r) {
579
+ let s = !0;
580
+ if (r) {
581
+ const n = r.getAttribute(Q), i = t.querySelector(
582
+ `[data-blok-uid="${n}"]`
304
583
  );
305
- o && (o.setAttribute("data-blok-focused", "true"), s.replaceWith(o));
306
- } else
307
- e.replaceWith(t);
584
+ i && (i.setAttribute(Ve, "true"), Oe(r, i), s = !1);
585
+ }
586
+ s && Oe(e, t);
308
587
  }
309
- async function He(e) {
310
- const s = await (await fetch(location.href, {
311
- method: "POST",
312
- body: JSON.stringify({
588
+ function Rt(e) {
589
+ if (e.nodeType === 1) {
590
+ const t = e.getAttribute(Q);
591
+ if (t)
592
+ return t;
593
+ }
594
+ }
595
+ function Oe(e, t) {
596
+ gt(e, t, {
597
+ getNodeKey: Rt,
598
+ onBeforeElUpdated: (r, s) => r.hasAttribute(kt) ? !1 : (_t(r, s), !0)
599
+ });
600
+ }
601
+ const St = (e) => {
602
+ if (e === null || typeof e != "object" || Array.isArray(e))
603
+ return !1;
604
+ const t = Object.getPrototypeOf(e);
605
+ return t === Object.prototype || t === null;
606
+ };
607
+ async function It(e, t) {
608
+ ce = new AbortController();
609
+ const r = {
610
+ story: {
313
611
  ...e,
314
612
  is_storyblok_preview: !0
315
- }),
613
+ },
614
+ ...St(t) && { serverData: t }
615
+ }, s = await fetch(location.href, {
616
+ method: "POST",
617
+ body: JSON.stringify(r),
316
618
  headers: {
317
619
  "Content-Type": "application/json"
318
- }
319
- })).text();
320
- return new DOMParser().parseFromString(s, "text/html").body;
620
+ },
621
+ signal: ce.signal
622
+ });
623
+ if (!s.ok)
624
+ throw new Error(
625
+ `Failed to fetch updated HTML: ${s.status} ${s.statusText}`
626
+ );
627
+ const n = await s.text();
628
+ return new DOMParser().parseFromString(n, "text/html").body;
321
629
  }
322
- function ee(e, t) {
323
- document.dispatchEvent(new CustomEvent(e, { detail: t }));
630
+ function fe(e, t, r = !1) {
631
+ const s = new CustomEvent(e, { detail: t, cancelable: r });
632
+ return document.dispatchEvent(s), s;
324
633
  }
325
- var Ne = Object.defineProperty, je = (e, t, s) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, y = (e, t, s) => je(e, typeof t != "symbol" ? t + "" : t, s);
326
- let w = /* @__PURE__ */ function(e) {
634
+ function $t(e) {
635
+ const t = e.querySelector(`#${Ct}`);
636
+ if (!(t != null && t.textContent))
637
+ return null;
638
+ try {
639
+ return JSON.parse(t.textContent || "{}");
640
+ } catch (r) {
641
+ return console.error("Failed to parse server data:", r), null;
642
+ }
643
+ }
644
+ const Ot = ["_storyblok", "_storyblok_c", "_storyblok_tk[space_id]"];
645
+ function pr(e, t = {}) {
646
+ const r = e.searchParams;
647
+ return !(!Ot.every((n) => r.has(n)) || t.spaceId && r.get("_storyblok_tk[space_id]") !== t.spaceId);
648
+ }
649
+ var xt = Object.defineProperty, Pt = (e, t, r) => t in e ? xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, T = (e, t, r) => Pt(e, typeof t != "symbol" ? t + "" : t, r);
650
+ let L = /* @__PURE__ */ function(e) {
327
651
  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;
328
- }({}), A = /* @__PURE__ */ function(e) {
652
+ }({}), S = /* @__PURE__ */ function(e) {
329
653
  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;
330
- }({}), De = /* @__PURE__ */ function(e) {
654
+ }({}), Mt = /* @__PURE__ */ function(e) {
331
655
  return e.TEXT = "text", e;
332
- }({}), M = /* @__PURE__ */ function(e) {
656
+ }({}), ie = /* @__PURE__ */ function(e) {
333
657
  return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
334
658
  }({});
335
- const Ue = [
659
+ const Nt = [
336
660
  "area",
337
661
  "base",
338
662
  "br",
@@ -347,286 +671,286 @@ const Ue = [
347
671
  "source",
348
672
  "track",
349
673
  "wbr"
350
- ], Ve = (e = {}) => {
351
- const { custom: t, ...s } = e, r = {
352
- ...s,
674
+ ], Ht = (e = {}) => {
675
+ const { custom: t, ...r } = e, s = {
676
+ ...r,
353
677
  ...t
354
678
  };
355
- return Object.keys(r).map((o) => `${o}="${r[o]}"`).join(" ");
356
- }, Be = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
357
- function Fe(e) {
679
+ return Object.keys(s).map((n) => `${n}="${s[n]}"`).join(" ");
680
+ }, Dt = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
681
+ function Ut(e) {
358
682
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
359
683
  }
360
- const S = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
361
- function qe(e, t) {
684
+ const Z = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
685
+ function Vt(e, t) {
362
686
  if (!t) return {
363
687
  src: e,
364
688
  attrs: {}
365
689
  };
366
- let s = 0, r = 0;
367
- const o = {}, n = [];
368
- function a(c, u, g, d, C) {
369
- typeof c != "number" || c <= u || c >= g ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${u} and ${g} (inclusive)`) : C.push(`${d}(${c})`);
690
+ let r = 0, s = 0;
691
+ const n = {}, i = [];
692
+ function o(a, h, g, p, w) {
693
+ typeof a != "number" || a <= h || a >= g ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${g} (inclusive)`) : w.push(`${p}(${a})`);
370
694
  }
371
695
  if (typeof t == "object") {
372
- if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (o.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (o.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete o.width, delete o.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (o.loading = t.loading), t.class && (o.class = t.class), t.filters) {
373
- const { filters: c } = t || {}, { blur: u, brightness: g, fill: d, format: C, grayscale: R, quality: k, rotate: T } = c || {};
374
- u && a(u, 0, 100, "blur", n), k && a(k, 0, 100, "quality", n), g && a(g, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), T && [
696
+ if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (n.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete n.width, delete n.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
697
+ const { filters: a } = t || {}, { blur: h, brightness: g, fill: p, format: w, grayscale: I, quality: E, rotate: $ } = a || {};
698
+ h && o(h, 0, 100, "blur", i), E && o(E, 0, 100, "quality", i), g && o(g, 0, 100, "brightness", i), p && i.push(`fill(${p})`), I && i.push("grayscale()"), $ && [
375
699
  0,
376
700
  90,
377
701
  180,
378
702
  270
379
- ].includes(t.filters.rotate || 0) && n.push(`rotate(${T})`), C && [
703
+ ].includes(t.filters.rotate || 0) && i.push(`rotate(${$})`), w && [
380
704
  "webp",
381
705
  "png",
382
706
  "jpeg"
383
- ].includes(C) && n.push(`format(${C})`);
707
+ ].includes(w) && i.push(`format(${w})`);
384
708
  }
385
- t.srcset && (o.srcset = t.srcset.map((c) => {
386
- if (typeof c == "number") return `${e}/m/${c}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
387
- if (Array.isArray(c) && c.length === 2) {
388
- const [u, g] = c;
389
- return `${e}/m/${u}x${g}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
709
+ t.srcset && (n.srcset = t.srcset.map((a) => {
710
+ if (typeof a == "number") return `${e}/m/${a}x0/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${a}w`;
711
+ if (Array.isArray(a) && a.length === 2) {
712
+ const [h, g] = a;
713
+ return `${e}/m/${h}x${g}/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${h}w`;
390
714
  } else {
391
715
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
392
716
  return;
393
717
  }
394
- }).join(", ")), t.sizes && (o.sizes = t.sizes.join(", "));
718
+ }).join(", ")), t.sizes && (n.sizes = t.sizes.join(", "));
395
719
  }
396
720
  let l = `${e}/m/`;
397
- return (s > 0 || r > 0) && (l = `${l}${s}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
721
+ return (r > 0 || s > 0) && (l = `${l}${r}x${s}/`), i.length > 0 && (l = `${l}filters:${i.join(":")}`), {
398
722
  src: l,
399
- attrs: o
723
+ attrs: n
400
724
  };
401
725
  }
402
- function te(e, t = {}, s) {
403
- const r = Ve(t), o = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
726
+ function xe(e, t = {}, r) {
727
+ const s = Ht(t), n = s ? `${e} ${s}` : e, i = Array.isArray(r) ? r.join("") : r || "";
404
728
  if (e) {
405
- if (Ue.includes(e)) return `<${o}>`;
406
- } else return n;
407
- return `<${o}>${n}</${e}>`;
729
+ if (Nt.includes(e)) return `<${n}>`;
730
+ } else return i;
731
+ return `<${n}>${i}</${e}>`;
408
732
  }
409
- function Ge(e = {}) {
410
- const t = /* @__PURE__ */ new Map(), { renderFn: s = te, textFn: r = Fe, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: a = !1 } = e, l = s !== te, c = (i = {}) => {
411
- const { textAlign: h, class: p, id: f, style: m, ...v } = i, b = [];
412
- return m && b.push(m.endsWith(";") ? m : `${m};`), h && b.push(`text-align: ${h};`), S({
413
- ...v,
414
- class: p,
415
- id: f,
416
- ...b.length > 0 ? { style: b.join(" ") } : {}
733
+ function jt(e = {}) {
734
+ const t = /* @__PURE__ */ new Map(), { renderFn: r = xe, textFn: s = Ut, resolvers: n = {}, optimizeImages: i = !1, keyedResolvers: o = !1 } = e, l = r !== xe, a = (c = {}) => {
735
+ const { textAlign: u, class: m, id: v, style: b, ..._ } = c, k = [];
736
+ return b && k.push(b.endsWith(";") ? b : `${b};`), u && k.push(`text-align: ${u};`), Z({
737
+ ..._,
738
+ class: m,
739
+ id: v,
740
+ ...k.length > 0 ? { style: k.join(" ") } : {}
417
741
  });
418
- }, u = (i) => (h, p) => {
419
- const f = c(h.attrs);
420
- return p.render(i, f, h.children || null);
421
- }, g = (i, h) => {
422
- const { src: p, alt: f, title: m, srcset: v, sizes: b } = i.attrs || {};
423
- let E = p, L = {};
424
- if (n) {
425
- const { src: ye, attrs: ge } = qe(p, n);
426
- E = ye, L = ge;
742
+ }, h = (c) => (u, m) => {
743
+ const v = a(u.attrs);
744
+ return m.render(c, v, u.children || null);
745
+ }, g = (c, u) => {
746
+ const { src: m, alt: v, title: b, srcset: _, sizes: k } = c.attrs || {};
747
+ let f = m, d = {};
748
+ if (i) {
749
+ const { src: y, attrs: C } = Vt(m, i);
750
+ f = y, d = C;
427
751
  }
428
- const I = {
429
- src: E,
430
- alt: f,
431
- title: m,
432
- srcset: v,
433
- sizes: b,
434
- ...L
752
+ const A = {
753
+ src: f,
754
+ alt: v,
755
+ title: b,
756
+ srcset: _,
757
+ sizes: k,
758
+ ...d
435
759
  };
436
- return h.render("img", S(I));
437
- }, d = (i, h) => {
438
- const { level: p, ...f } = i.attrs || {}, m = c(f);
439
- return h.render(`h${p}`, m, i.children);
440
- }, C = (i, h) => {
441
- var p, f, m, v;
442
- const b = h.render("img", {
443
- src: (p = i.attrs) == null ? void 0 : p.fallbackImage,
444
- alt: (f = i.attrs) == null ? void 0 : f.alt,
760
+ return u.render("img", Z(A));
761
+ }, p = (c, u) => {
762
+ const { level: m, ...v } = c.attrs || {}, b = a(v);
763
+ return u.render(`h${m}`, b, c.children);
764
+ }, w = (c, u) => {
765
+ var m, v, b, _;
766
+ const k = u.render("img", {
767
+ src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
768
+ alt: (v = c.attrs) == null ? void 0 : v.alt,
445
769
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
446
770
  draggable: "false",
447
771
  loading: "lazy"
448
772
  });
449
- return h.render("span", {
773
+ return u.render("span", {
450
774
  "data-type": "emoji",
451
- "data-name": (m = i.attrs) == null ? void 0 : m.name,
452
- "data-emoji": (v = i.attrs) == null ? void 0 : v.emoji
453
- }, b);
454
- }, R = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), k = (i, h = !1) => ({ text: p, attrs: f }, m) => {
455
- const { class: v, id: b, ...E } = f || {}, L = h ? {
456
- class: v,
457
- id: b,
458
- style: Be(E) || void 0
459
- } : f || {};
460
- return m.render(i, S(L), p);
461
- }, T = (i) => j(i), $ = (i) => {
462
- const { marks: h, ...p } = i;
463
- if ("text" in i) {
464
- if (h) return h.reduce((m, v) => T({
465
- ...v,
466
- text: m
467
- }), T({
468
- ...p,
469
- children: p.children
775
+ "data-name": (b = c.attrs) == null ? void 0 : b.name,
776
+ "data-emoji": (_ = c.attrs) == null ? void 0 : _.emoji
777
+ }, k);
778
+ }, I = (c, u) => u.render("pre", c.attrs || {}, u.render("code", {}, c.children || "")), E = (c, u = !1) => ({ text: m, attrs: v }, b) => {
779
+ const { class: _, id: k, ...f } = v || {}, d = u ? {
780
+ class: _,
781
+ id: k,
782
+ style: Dt(f) || void 0
783
+ } : v || {};
784
+ return b.render(c, Z(d), m);
785
+ }, $ = (c) => P(c), U = (c) => {
786
+ const { marks: u, ...m } = c;
787
+ if ("text" in c) {
788
+ if (u) return u.reduce((b, _) => $({
789
+ ..._,
790
+ text: b
791
+ }), $({
792
+ ...m,
793
+ children: m.children
470
794
  }));
471
- const f = i.attrs || {};
472
- if (a) {
473
- const m = t.get("txt") || 0;
474
- t.set("txt", m + 1), f.key = `txt-${m}`;
795
+ const v = c.attrs || {};
796
+ if (o) {
797
+ const b = t.get("txt") || 0;
798
+ t.set("txt", b + 1), v.key = `txt-${b}`;
475
799
  }
476
- return r(p.text, f);
800
+ return s(m.text, v);
477
801
  }
478
802
  return "";
479
- }, Z = (i, h) => {
480
- const { linktype: p, href: f, anchor: m, ...v } = i.attrs || {};
481
- let b = "";
482
- switch (p) {
483
- case M.ASSET:
484
- case M.URL:
485
- b = f;
803
+ }, J = (c, u) => {
804
+ const { linktype: m, href: v, anchor: b, ..._ } = c.attrs || {};
805
+ let k = "";
806
+ switch (m) {
807
+ case ie.ASSET:
808
+ case ie.URL:
809
+ k = v;
486
810
  break;
487
- case M.EMAIL:
488
- b = `mailto:${f}`;
811
+ case ie.EMAIL:
812
+ k = `mailto:${v}`;
489
813
  break;
490
- case M.STORY:
491
- b = f, m && (b = `${b}#${m}`);
814
+ case ie.STORY:
815
+ k = v, b && (k = `${k}#${b}`);
492
816
  break;
493
817
  default:
494
- b = f;
818
+ k = v;
495
819
  break;
496
820
  }
497
- const E = { ...v };
498
- return b && (E.href = b), h.render("a", E, i.text);
499
- }, ue = (i, h) => {
500
- var p, f;
501
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
502
- blok: (p = i == null ? void 0 : i.attrs) == null ? void 0 : p.body[0],
503
- id: (f = i.attrs) == null ? void 0 : f.id,
821
+ const f = { ..._ };
822
+ return k && (f.href = k), u.render("a", f, c.text);
823
+ }, K = (c, u) => {
824
+ var m, v;
825
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
826
+ blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
827
+ id: (v = c.attrs) == null ? void 0 : v.id,
504
828
  style: "display: none"
505
829
  });
506
- }, he = (i, h) => {
507
- const p = c(i.attrs), f = i.children || null;
508
- return h.render("table", p, h.render("tbody", {}, f));
509
- }, de = (i, h) => {
510
- const p = c(i.attrs);
511
- return h.render("tr", p, i.children);
512
- }, pe = (i, h) => {
513
- const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
514
- m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
515
- const I = {
516
- ...E,
517
- ...p > 1 ? { colspan: p } : {},
518
- ...f > 1 ? { rowspan: f } : {},
519
- ...L.length > 0 ? { style: L.join(" ") } : {}
830
+ }, x = (c, u) => {
831
+ const m = a(c.attrs), v = c.children || null;
832
+ return u.render("table", m, u.render("tbody", {}, v));
833
+ }, j = (c, u) => {
834
+ const m = a(c.attrs);
835
+ return u.render("tr", m, c.children);
836
+ }, B = (c, u) => {
837
+ const { colspan: m, rowspan: v, colwidth: b, backgroundColor: _, textAlign: k, ...f } = c.attrs || {}, d = [];
838
+ b && d.push(`width: ${b}px;`), _ && d.push(`background-color: ${_};`), k && d.push(`text-align: ${k};`);
839
+ const A = {
840
+ ...f,
841
+ ...m > 1 ? { colspan: m } : {},
842
+ ...v > 1 ? { rowspan: v } : {},
843
+ ...d.length > 0 ? { style: d.join(" ") } : {}
520
844
  };
521
- return h.render("td", S(I), i.children);
522
- }, fe = (i, h) => {
523
- const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
524
- m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
525
- const I = {
526
- ...E,
527
- ...p > 1 ? { colspan: p } : {},
528
- ...f > 1 ? { rowspan: f } : {},
529
- ...L.length > 0 ? { style: L.join(" ") } : {}
845
+ return u.render("td", Z(A), c.children);
846
+ }, ee = (c, u) => {
847
+ const { colspan: m, rowspan: v, colwidth: b, backgroundColor: _, textAlign: k, ...f } = c.attrs || {}, d = [];
848
+ b && d.push(`width: ${b}px;`), _ && d.push(`background-color: ${_};`), k && d.push(`text-align: ${k};`);
849
+ const A = {
850
+ ...f,
851
+ ...m > 1 ? { colspan: m } : {},
852
+ ...v > 1 ? { rowspan: v } : {},
853
+ ...d.length > 0 ? { style: d.join(" ") } : {}
530
854
  };
531
- return h.render("th", S(I), i.children);
532
- }, J = /* @__PURE__ */ new Map([
533
- [w.DOCUMENT, u("")],
534
- [w.HEADING, d],
535
- [w.PARAGRAPH, u("p")],
536
- [w.UL_LIST, u("ul")],
537
- [w.OL_LIST, u("ol")],
538
- [w.LIST_ITEM, u("li")],
539
- [w.IMAGE, g],
540
- [w.EMOJI, C],
541
- [w.CODE_BLOCK, R],
542
- [w.HR, u("hr")],
543
- [w.BR, u("br")],
544
- [w.QUOTE, u("blockquote")],
545
- [w.COMPONENT, ue],
546
- [De.TEXT, $],
547
- [A.LINK, Z],
548
- [A.ANCHOR, Z],
549
- [A.STYLED, k("span", !0)],
550
- [A.BOLD, k("strong")],
551
- [A.TEXT_STYLE, k("span", !0)],
552
- [A.ITALIC, k("em")],
553
- [A.UNDERLINE, k("u")],
554
- [A.STRIKE, k("s")],
555
- [A.CODE, k("code")],
556
- [A.SUPERSCRIPT, k("sup")],
557
- [A.SUBSCRIPT, k("sub")],
558
- [A.HIGHLIGHT, k("mark")],
559
- [w.TABLE, he],
560
- [w.TABLE_ROW, de],
561
- [w.TABLE_CELL, pe],
562
- [w.TABLE_HEADER, fe]
563
- ]), W = new Map([...J, ...Object.entries(o).map(([i, h]) => [i, h])]), me = () => ({
564
- render: (i, h = {}, p) => {
565
- if (a && i) {
566
- const f = t.get(i) || 0;
567
- t.set(i, f + 1), h.key = `${i}-${f}`;
855
+ return u.render("th", Z(A), c.children);
856
+ }, V = /* @__PURE__ */ new Map([
857
+ [L.DOCUMENT, h("")],
858
+ [L.HEADING, p],
859
+ [L.PARAGRAPH, h("p")],
860
+ [L.UL_LIST, h("ul")],
861
+ [L.OL_LIST, h("ol")],
862
+ [L.LIST_ITEM, h("li")],
863
+ [L.IMAGE, g],
864
+ [L.EMOJI, w],
865
+ [L.CODE_BLOCK, I],
866
+ [L.HR, h("hr")],
867
+ [L.BR, h("br")],
868
+ [L.QUOTE, h("blockquote")],
869
+ [L.COMPONENT, K],
870
+ [Mt.TEXT, U],
871
+ [S.LINK, J],
872
+ [S.ANCHOR, J],
873
+ [S.STYLED, E("span", !0)],
874
+ [S.BOLD, E("strong")],
875
+ [S.TEXT_STYLE, E("span", !0)],
876
+ [S.ITALIC, E("em")],
877
+ [S.UNDERLINE, E("u")],
878
+ [S.STRIKE, E("s")],
879
+ [S.CODE, E("code")],
880
+ [S.SUPERSCRIPT, E("sup")],
881
+ [S.SUBSCRIPT, E("sub")],
882
+ [S.HIGHLIGHT, E("mark")],
883
+ [L.TABLE, x],
884
+ [L.TABLE_ROW, j],
885
+ [L.TABLE_CELL, B],
886
+ [L.TABLE_HEADER, ee]
887
+ ]), F = new Map([...V, ...Object.entries(n).map(([c, u]) => [c, u])]), W = () => ({
888
+ render: (c, u = {}, m) => {
889
+ if (o && c) {
890
+ const v = t.get(c) || 0;
891
+ t.set(c, v + 1), u.key = `${c}-${v}`;
568
892
  }
569
- return s(i, h, p);
893
+ return r(c, u, m);
570
894
  },
571
- originalResolvers: J,
572
- mergedResolvers: W
895
+ originalResolvers: V,
896
+ mergedResolvers: F
573
897
  });
574
- function x(i) {
575
- const h = W.get(i.type);
576
- if (!h)
577
- return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
578
- const p = me();
579
- if (i.type === "text") return h(i, p);
580
- const f = i.content ? i.content.map(j) : void 0;
581
- return h({
582
- ...i,
583
- children: f
584
- }, p);
585
- }
586
- function j(i) {
587
- return i.type === "doc" ? l ? i.content.map(x) : i.content.map(x).join("") : Array.isArray(i) ? i.map(x) : x(i);
588
- }
589
- return { render: j };
898
+ function q(c) {
899
+ const u = F.get(c.type);
900
+ if (!u)
901
+ return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
902
+ const m = W();
903
+ if (c.type === "text") return u(c, m);
904
+ const v = c.content ? c.content.map(P) : void 0;
905
+ return u({
906
+ ...c,
907
+ children: v
908
+ }, m);
909
+ }
910
+ function P(c) {
911
+ return c.type === "doc" ? l ? c.content.map(q) : c.content.map(q).join("") : Array.isArray(c) ? c.map(q) : q(c);
912
+ }
913
+ return { render: P };
590
914
  }
591
- let se = !1;
592
- const re = [], le = (e) => new Promise((t, s) => {
915
+ let Pe = !1;
916
+ const Me = [], je = (e) => new Promise((t, r) => {
593
917
  if (typeof window > "u") {
594
- s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
918
+ r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
595
919
  return;
596
920
  }
597
- if (window.storyblokRegisterEvent = (o) => {
921
+ if (window.storyblokRegisterEvent = (n) => {
598
922
  if (!window.location.search.includes("_storyblok")) {
599
923
  console.warn("You are not in Draft Mode or in the Visual Editor.");
600
924
  return;
601
925
  }
602
- se ? o() : re.push(o);
926
+ Pe ? n() : Me.push(n);
603
927
  }, document.getElementById("storyblok-javascript-bridge")) {
604
928
  t(void 0);
605
929
  return;
606
930
  }
607
- const r = document.createElement("script");
608
- r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (o) => s(o), r.onload = (o) => {
609
- re.forEach((n) => n()), se = !0, t(o);
610
- }, document.getElementsByTagName("head")[0].appendChild(r);
611
- }), D = (e = "") => e.includes("/cdn/"), ze = (e, t = 25, s = 1) => ({
931
+ const s = document.createElement("script");
932
+ s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (n) => r(n), s.onload = (n) => {
933
+ Me.forEach((i) => i()), Pe = !0, t(n);
934
+ }, document.getElementsByTagName("head")[0].appendChild(s);
935
+ }), pe = (e = "") => e.includes("/cdn/"), Bt = (e, t = 25, r = 1) => ({
612
936
  ...e,
613
937
  per_page: t,
614
- page: s
615
- }), Ze = (e) => new Promise((t) => setTimeout(t, e)), Je = (e = 0, t) => Array.from({ length: e }, t), We = (e = 0, t = e) => {
616
- const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
617
- return Je(s, (o, n) => n * r + e);
618
- }, Ye = async (e, t) => Promise.all(e.map(t)), Ke = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), z = (e, t, s) => {
619
- const r = [];
620
- for (const o in e) {
621
- if (!Object.prototype.hasOwnProperty.call(e, o)) continue;
622
- const n = e[o];
623
- if (n == null) continue;
624
- const a = s ? "" : encodeURIComponent(o);
938
+ page: r
939
+ }), Ft = (e) => new Promise((t) => setTimeout(t, e)), qt = (e = 0, t) => Array.from({ length: e }, t), Gt = (e = 0, t = e) => {
940
+ const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
941
+ return qt(r, (n, i) => i * s + e);
942
+ }, zt = async (e, t) => Promise.all(e.map(t)), Jt = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), ke = (e, t, r) => {
943
+ const s = [];
944
+ for (const n in e) {
945
+ if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
946
+ const i = e[n];
947
+ if (i == null) continue;
948
+ const o = r ? "" : encodeURIComponent(n);
625
949
  let l;
626
- typeof n == "object" ? l = z(n, t ? t + encodeURIComponent(`[${a}]`) : a, Array.isArray(n)) : l = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, r.push(l);
950
+ typeof i == "object" ? l = ke(i, t ? t + encodeURIComponent(`[${o}]`) : o, Array.isArray(i)) : l = `${t ? t + encodeURIComponent(`[${o}]`) : o}=${encodeURIComponent(i)}`, s.push(l);
627
951
  }
628
- return r.join("&");
629
- }, oe = (e) => {
952
+ return s.join("&");
953
+ }, Ne = (e) => {
630
954
  const t = {
631
955
  eu: "api.storyblok.com",
632
956
  us: "api-us.storyblok.com",
@@ -636,9 +960,9 @@ const re = [], le = (e) => new Promise((t, s) => {
636
960
  };
637
961
  return t[e] ?? t.eu;
638
962
  };
639
- var Xe = class {
963
+ var Kt = class {
640
964
  constructor(e) {
641
- y(this, "baseURL"), y(this, "timeout"), y(this, "headers"), y(this, "responseInterceptor"), y(this, "fetch"), y(this, "ejectInterceptor"), y(this, "url"), y(this, "parameters"), y(this, "fetchOptions"), 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 = {};
965
+ T(this, "baseURL"), T(this, "timeout"), T(this, "headers"), T(this, "responseInterceptor"), T(this, "fetch"), T(this, "ejectInterceptor"), T(this, "url"), T(this, "parameters"), T(this, "fetchOptions"), 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 = {};
642
966
  }
643
967
  /**
644
968
  *
@@ -659,37 +983,37 @@ var Xe = class {
659
983
  return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
660
984
  }
661
985
  async _responseHandler(e) {
662
- const t = [], s = {
986
+ const t = [], r = {
663
987
  data: {},
664
988
  headers: {},
665
989
  status: 0,
666
990
  statusText: ""
667
991
  };
668
- e.status !== 204 && await e.json().then((r) => {
669
- s.data = r;
992
+ e.status !== 204 && await e.json().then((s) => {
993
+ r.data = s;
670
994
  });
671
- for (const r of e.headers.entries()) t[r[0]] = r[1];
672
- return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
995
+ for (const s of e.headers.entries()) t[s[0]] = s[1];
996
+ return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
673
997
  }
674
998
  async _methodHandler(e) {
675
- let t = `${this.baseURL}${this.url}`, s = null;
676
- e === "get" ? t = `${this.baseURL}${this.url}?${z(this.parameters)}` : s = JSON.stringify(this.parameters);
677
- const r = new URL(t), o = new AbortController(), { signal: n } = o;
678
- let a = null;
679
- this.timeout && (a = setTimeout(() => o.abort(), this.timeout));
999
+ let t = `${this.baseURL}${this.url}`, r = null;
1000
+ e === "get" ? t = `${this.baseURL}${this.url}?${ke(this.parameters)}` : r = JSON.stringify(this.parameters);
1001
+ const s = new URL(t), n = new AbortController(), { signal: i } = n;
1002
+ let o = null;
1003
+ this.timeout && (o = setTimeout(() => n.abort(), this.timeout));
680
1004
  try {
681
- const l = await this.fetch(`${r}`, {
1005
+ const l = await this.fetch(`${s}`, {
682
1006
  method: e,
683
1007
  headers: this.headers,
684
- body: s,
685
- signal: n,
1008
+ body: r,
1009
+ signal: i,
686
1010
  ...this.fetchOptions
687
1011
  });
688
- this.timeout && a && clearTimeout(a);
689
- const c = await this._responseHandler(l);
690
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
1012
+ this.timeout && o && clearTimeout(o);
1013
+ const a = await this._responseHandler(l);
1014
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(a)) : this._statusHandler(a);
691
1015
  } catch (l) {
692
- return { message: l };
1016
+ return l.name === "AbortError" ? { message: "Request timeout: The request was aborted due to timeout" } : { message: l.message || l.toString() || "An unknown error occurred" };
693
1017
  }
694
1018
  }
695
1019
  setFetchOptions(e = {}) {
@@ -717,119 +1041,119 @@ var Xe = class {
717
1041
  }
718
1042
  _statusHandler(e) {
719
1043
  const t = /20[0-6]/g;
720
- return new Promise((s, r) => {
721
- if (t.test(`${e.status}`)) return s(e);
722
- const o = {
1044
+ return new Promise((r, s) => {
1045
+ if (t.test(`${e.status}`)) return r(e);
1046
+ const n = {
723
1047
  message: this._normalizeErrorMessage(e.data),
724
1048
  status: e.status,
725
1049
  response: e
726
1050
  };
727
- r(o);
1051
+ s(n);
728
1052
  });
729
1053
  }
730
- }, Qe = Xe;
731
- const ne = "SB-Agent", U = {
1054
+ }, Wt = Kt;
1055
+ const He = "SB-Agent", me = {
732
1056
  defaultAgentName: "SB-JS-CLIENT",
733
1057
  defaultAgentVersion: "SB-Agent-Version",
734
1058
  packageVersion: "7.0.0"
735
- }, ce = {
1059
+ }, Be = {
736
1060
  DRAFT: "draft",
737
1061
  PUBLISHED: "published"
738
- }, et = 25, V = {
1062
+ }, Yt = 25, ve = {
739
1063
  SMALL: 25,
740
1064
  MEDIUM: 50,
741
1065
  LARGE: 75
742
- }, O = {
1066
+ }, X = {
743
1067
  SINGLE_OR_SMALL: 50,
744
1068
  MEDIUM: 15,
745
1069
  LARGE: 10,
746
1070
  VERY_LARGE: 6
747
- }, B = 1e3, P = 3;
748
- function tt(e) {
749
- return e.version === ce.DRAFT;
1071
+ }, ye = 1e3, oe = 3;
1072
+ function Zt(e) {
1073
+ return e.version === Be.DRAFT;
750
1074
  }
751
- function st(e, t) {
752
- const s = e.includes("/cdn/stories/"), r = e.split("/").length > 3 && !e.endsWith("/cdn/stories"), o = "find_by" in t;
753
- return s && r || o;
1075
+ function Xt(e, t) {
1076
+ const r = e.includes("/cdn/stories/"), s = e.split("/").length > 3 && !e.endsWith("/cdn/stories"), n = "find_by" in t;
1077
+ return r && s || n;
754
1078
  }
755
- function rt(e) {
756
- return e <= V.SMALL ? O.SINGLE_OR_SMALL : e <= V.MEDIUM ? O.MEDIUM : e <= V.LARGE ? O.LARGE : O.VERY_LARGE;
1079
+ function Qt(e) {
1080
+ return e <= ve.SMALL ? X.SINGLE_OR_SMALL : e <= ve.MEDIUM ? X.MEDIUM : e <= ve.LARGE ? X.LARGE : X.VERY_LARGE;
757
1081
  }
758
- function H(e, t, s = {}, r) {
759
- if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, B);
760
- if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit, B);
761
- if (r !== void 0) return r;
762
- if (t && !tt(t)) return B;
763
- if (st(e, t)) return O.SINGLE_OR_SMALL;
764
- const o = t.per_page || et;
765
- return rt(o);
1082
+ function ae(e, t, r = {}, s) {
1083
+ if (r.userRateLimit !== void 0) return Math.min(r.userRateLimit, ye);
1084
+ if (r.serverHeadersRateLimit !== void 0) return Math.min(r.serverHeadersRateLimit, ye);
1085
+ if (s !== void 0) return s;
1086
+ if (t && !Zt(t)) return ye;
1087
+ if (Xt(e, t)) return X.SINGLE_OR_SMALL;
1088
+ const n = t.per_page || Yt;
1089
+ return Qt(n);
766
1090
  }
767
- function ot(e) {
1091
+ function er(e) {
768
1092
  if (!e) return null;
769
- const t = e["x-ratelimit"] || e["X-RateLimit"], s = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
770
- if (!t && !s) return null;
771
- const r = {};
1093
+ const t = e["x-ratelimit"] || e["X-RateLimit"], r = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
1094
+ if (!t && !r) return null;
1095
+ const s = {};
772
1096
  if (t) {
773
- const o = t.match(/r=(\d+)/);
774
- o && (r.remaining = Number.parseInt(o[1], 10));
1097
+ const n = t.match(/r=(\d+)/);
1098
+ n && (s.remaining = Number.parseInt(n[1], 10));
775
1099
  }
776
- if (s) {
777
- const o = s.match(/q=(\d+)/);
778
- o && (r.max = Number.parseInt(o[1], 10));
1100
+ if (r) {
1101
+ const n = r.match(/q=(\d+)/);
1102
+ n && (s.max = Number.parseInt(n[1], 10));
779
1103
  }
780
- return Object.keys(r).length > 0 ? r : null;
1104
+ return Object.keys(s).length > 0 ? s : null;
781
1105
  }
782
- function nt(e, t = !1) {
1106
+ function tr(e, t = !1) {
783
1107
  return {
784
1108
  userRateLimit: e,
785
1109
  serverHeadersRateLimit: void 0,
786
1110
  isManagementApi: t
787
1111
  };
788
1112
  }
789
- var it = class extends Error {
1113
+ var rr = class extends Error {
790
1114
  constructor(e) {
791
1115
  super(e), this.name = "AbortError";
792
1116
  }
793
1117
  };
794
- function at(e, t, s) {
1118
+ function sr(e, t, r) {
795
1119
  if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
796
- if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
797
- const r = [];
798
- let o = [], n = 0, a = !1;
1120
+ if (!Number.isFinite(r)) throw new TypeError("Expected `interval` to be a finite number");
1121
+ const s = [];
1122
+ let n = [], i = 0, o = !1;
799
1123
  const l = async () => {
800
- n++;
801
- const u = r.shift();
802
- if (u) try {
803
- const d = await e(...u.args);
804
- u.resolve(d);
805
- } catch (d) {
806
- u.reject(d);
1124
+ i++;
1125
+ const h = s.shift();
1126
+ if (h) try {
1127
+ const p = await e(...h.args);
1128
+ h.resolve(p);
1129
+ } catch (p) {
1130
+ h.reject(p);
807
1131
  }
808
1132
  const g = setTimeout(() => {
809
- n--, r.length > 0 && l(), o = o.filter((d) => d !== g);
810
- }, s);
811
- o.includes(g) || o.push(g);
812
- }, c = (...u) => a ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((g, d) => {
813
- r.push({
1133
+ i--, s.length > 0 && l(), n = n.filter((p) => p !== g);
1134
+ }, r);
1135
+ n.includes(g) || n.push(g);
1136
+ }, a = (...h) => o ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((g, p) => {
1137
+ s.push({
814
1138
  resolve: g,
815
- reject: d,
816
- args: u
817
- }), n < t && l();
1139
+ reject: p,
1140
+ args: h
1141
+ }), i < t && l();
818
1142
  });
819
- return c.abort = () => {
820
- a = !0, o.forEach(clearTimeout), o = [], r.forEach((u) => u.reject(() => new it("Throttle function aborted"))), r.length = 0;
821
- }, c;
1143
+ return a.abort = () => {
1144
+ o = !0, n.forEach(clearTimeout), n = [], s.forEach((h) => h.reject(() => new rr("Throttle function aborted"))), s.length = 0;
1145
+ }, a;
822
1146
  }
823
- var lt = at, ct = class {
1147
+ var nr = sr, ir = class {
824
1148
  constructor(e, t = 1e3) {
825
- y(this, "queues"), y(this, "interval"), y(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
1149
+ T(this, "queues"), T(this, "interval"), T(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
826
1150
  }
827
1151
  /**
828
1152
  * Gets or creates a throttle queue for the specified rate limit
829
1153
  */
830
1154
  getQueue(e) {
831
1155
  let t = this.queues.get(e);
832
- return t || (t = lt(this.throttledRequestFn, e, this.interval), this.queues.set(e, t)), t;
1156
+ return t || (t = nr(this.throttledRequestFn, e, this.interval), this.queues.set(e, t)), t;
833
1157
  }
834
1158
  /**
835
1159
  * Executes a request through the appropriate throttle queue based on rate limit
@@ -853,73 +1177,73 @@ var lt = at, ct = class {
853
1177
  return this.queues.size;
854
1178
  }
855
1179
  };
856
- let N = {};
857
- const _ = {};
858
- var ut = class {
1180
+ let le = {};
1181
+ const D = {};
1182
+ var or = class {
859
1183
  /**
860
1184
  *
861
1185
  * @param config ISbConfig interface
862
1186
  * @param pEndpoint string, optional
863
1187
  */
864
1188
  constructor(e, t) {
865
- y(this, "client"), y(this, "maxRetries"), y(this, "retriesDelay"), y(this, "throttleManager"), y(this, "accessToken"), y(this, "cache"), y(this, "resolveCounter"), y(this, "relations"), y(this, "links"), y(this, "version"), y(this, "rateLimitConfig"), y(this, "richTextResolver"), y(this, "resolveNestedRelations"), y(this, "stringifiedStoriesCache"), y(this, "inlineAssets");
866
- let s = e.endpoint || t;
867
- if (!s) {
868
- const o = e.https === !1 ? "http" : "https";
869
- e.oauthToken ? s = `${o}://${oe(e.region)}/v1` : s = `${o}://${oe(e.region)}/v2`;
1189
+ T(this, "client"), T(this, "maxRetries"), T(this, "retriesDelay"), T(this, "throttleManager"), T(this, "accessToken"), T(this, "cache"), T(this, "resolveCounter"), T(this, "relations"), T(this, "links"), T(this, "version"), T(this, "rateLimitConfig"), T(this, "richTextResolver"), T(this, "resolveNestedRelations"), T(this, "stringifiedStoriesCache"), T(this, "inlineAssets");
1190
+ let r = e.endpoint || t;
1191
+ if (!r) {
1192
+ const n = e.https === !1 ? "http" : "https";
1193
+ e.oauthToken ? r = `${n}://${Ne(e.region)}/v1` : r = `${n}://${Ne(e.region)}/v2`;
870
1194
  }
871
- const r = new Headers();
872
- 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(([o, n]) => {
873
- r.set(o, n);
874
- }), r.has(ne) || (r.set(ne, U.defaultAgentName), r.set(U.defaultAgentVersion, U.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = nt(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ct(this.throttledRequest.bind(this), 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 || ce.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Qe({
875
- baseURL: s,
1195
+ const s = new Headers();
1196
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, i]) => {
1197
+ s.set(n, i);
1198
+ }), s.has(He) || (s.set(He, me.defaultAgentName), s.set(me.defaultAgentVersion, me.packageVersion)), e.oauthToken && s.set("Authorization", e.oauthToken), this.rateLimitConfig = tr(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ir(this.throttledRequest.bind(this), 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 || Be.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Wt({
1199
+ baseURL: r,
876
1200
  timeout: e.timeout || 0,
877
- headers: r,
1201
+ headers: s,
878
1202
  responseInterceptor: e.responseInterceptor,
879
1203
  fetch: e.fetch
880
1204
  });
881
1205
  }
882
1206
  parseParams(e) {
883
- return e.token || (e.token = this.getToken()), e.cv || (e.cv = _[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
1207
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = D[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
884
1208
  }
885
1209
  factoryParamOptions(e, t) {
886
- return D(e) ? this.parseParams(t) : t;
1210
+ return pe(e) ? this.parseParams(t) : t;
887
1211
  }
888
- makeRequest(e, t, s, r, o) {
889
- const n = this.factoryParamOptions(e, ze(t, s, r));
890
- return this.cacheResponse(e, n, void 0, o);
1212
+ makeRequest(e, t, r, s, n) {
1213
+ const i = this.factoryParamOptions(e, Bt(t, r, s));
1214
+ return this.cacheResponse(e, i, void 0, n);
891
1215
  }
892
- get(e, t = {}, s) {
1216
+ get(e, t = {}, r) {
893
1217
  t || (t = {});
894
- const r = `/${e}`;
895
- D(r) && (t.version = t.version || this.version);
896
- const o = this.factoryParamOptions(r, t);
897
- return this.cacheResponse(r, o, void 0, s);
1218
+ const s = `/${e}`;
1219
+ pe(s) && (t.version = t.version || this.version);
1220
+ const n = this.factoryParamOptions(s, t);
1221
+ return this.cacheResponse(s, n, void 0, r);
898
1222
  }
899
- async getAll(e, t = {}, s, r) {
900
- const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), a = s ?? n.substring(n.lastIndexOf("/") + 1);
1223
+ async getAll(e, t = {}, r, s) {
1224
+ const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), o = r ?? i.substring(i.lastIndexOf("/") + 1);
901
1225
  t.version = t.version || this.version;
902
- const l = 1, c = await this.makeRequest(n, t, o, l, r), u = c.total ? Math.ceil(c.total / (c.perPage || o)) : 1, g = await Ye(We(l, u), (d) => this.makeRequest(n, t, o, d + 1, r));
903
- return Ke([c, ...g], (d) => Object.values(d.data[a]));
1226
+ const l = 1, a = await this.makeRequest(i, t, n, l, s), h = a.total ? Math.ceil(a.total / (a.perPage || n)) : 1, g = await zt(Gt(l, h), (p) => this.makeRequest(i, t, n, p + 1, s));
1227
+ return Jt([a, ...g], (p) => Object.values(p.data[o]));
904
1228
  }
905
- post(e, t = {}, s) {
906
- const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
907
- return this.throttleManager.execute(o, "post", r, t, s);
1229
+ post(e, t = {}, r) {
1230
+ const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
1231
+ return this.throttleManager.execute(n, "post", s, t, r);
908
1232
  }
909
- put(e, t = {}, s) {
910
- const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
911
- return this.throttleManager.execute(o, "put", r, t, s);
1233
+ put(e, t = {}, r) {
1234
+ const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
1235
+ return this.throttleManager.execute(n, "put", s, t, r);
912
1236
  }
913
- delete(e, t = {}, s) {
1237
+ delete(e, t = {}, r) {
914
1238
  t || (t = {});
915
- const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
916
- return this.throttleManager.execute(o, "delete", r, t, s);
1239
+ const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
1240
+ return this.throttleManager.execute(n, "delete", s, t, r);
917
1241
  }
918
1242
  getStories(e = {}, t) {
919
1243
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
920
1244
  }
921
- getStory(e, t = {}, s) {
922
- return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
1245
+ getStory(e, t = {}, r) {
1246
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
923
1247
  }
924
1248
  getToken() {
925
1249
  return this.accessToken;
@@ -933,9 +1257,9 @@ var ut = class {
933
1257
  _cleanCopy(e) {
934
1258
  return JSON.parse(JSON.stringify(e));
935
1259
  }
936
- _insertLinks(e, t, s) {
937
- const r = e[t];
938
- 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]));
1260
+ _insertLinks(e, t, r) {
1261
+ const s = e[t];
1262
+ s && s.fieldtype === "multilink" && s.linktype === "story" && typeof s.id == "string" && this.links[r][s.id] ? s.story = this._cleanCopy(this.links[r][s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[r][s.uuid] && (s.story = this._cleanCopy(this.links[r][s.uuid]));
939
1263
  }
940
1264
  /**
941
1265
  *
@@ -956,9 +1280,9 @@ var ut = class {
956
1280
  * - For single strings: directly replaces the UUID with the story reference
957
1281
  * - For arrays: maps through each UUID and replaces with corresponding story references
958
1282
  */
959
- _resolveField(e, t, s) {
960
- const r = e[t];
961
- typeof r == "string" ? e[t] = this.getStoryReference(s, r) : Array.isArray(r) && (e[t] = r.map((o) => this.getStoryReference(s, o)).filter(Boolean));
1283
+ _resolveField(e, t, r) {
1284
+ const s = e[t];
1285
+ typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map((n) => this.getStoryReference(r, n)).filter(Boolean));
962
1286
  }
963
1287
  /**
964
1288
  * Inserts relations into the JSON tree by resolving references
@@ -977,13 +1301,13 @@ var ut = class {
977
1301
  * The method supports both string and array formats for the fields parameter,
978
1302
  * allowing flexible specification of relation patterns.
979
1303
  */
980
- _insertRelations(e, t, s, r) {
981
- if (Array.isArray(s) ? s.find((n) => n.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
982
- this._resolveField(e, t, r);
1304
+ _insertRelations(e, t, r, s) {
1305
+ if (Array.isArray(r) ? r.find((i) => i.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
1306
+ this._resolveField(e, t, s);
983
1307
  return;
984
1308
  }
985
- const o = e.component ? `${e.component}.${t}` : t;
986
- (Array.isArray(s) ? s.includes(o) : s === o) && this._resolveField(e, t, r);
1309
+ const n = e.component ? `${e.component}.${t}` : t;
1310
+ (Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, s);
987
1311
  }
988
1312
  /**
989
1313
  * Recursively traverses and resolves relations in the story content tree
@@ -991,68 +1315,68 @@ var ut = class {
991
1315
  * @param fields - The relation patterns to resolve
992
1316
  * @param resolveId - The unique identifier for the current resolution context
993
1317
  */
994
- iterateTree(e, t, s) {
995
- const r = (o, n = "") => {
996
- if (!(!o || o._stopResolving)) {
997
- if (Array.isArray(o)) o.forEach((a, l) => r(a, `${n}[${l}]`));
998
- else if (typeof o == "object") for (const a in o) {
999
- const l = n ? `${n}.${a}` : a;
1000
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, a, t, s), this._insertLinks(o, a, s)), r(o[a], l);
1318
+ iterateTree(e, t, r) {
1319
+ const s = (n, i = "") => {
1320
+ if (!(!n || n._stopResolving)) {
1321
+ if (Array.isArray(n)) n.forEach((o, l) => s(o, `${i}[${l}]`));
1322
+ else if (typeof n == "object") for (const o in n) {
1323
+ const l = i ? `${i}.${o}` : o;
1324
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, o, t, r), this._insertLinks(n, o, r)), s(n[o], l);
1001
1325
  }
1002
1326
  }
1003
1327
  };
1004
- r(e.content);
1328
+ s(e.content);
1005
1329
  }
1006
- async resolveLinks(e, t, s) {
1007
- let r = [];
1330
+ async resolveLinks(e, t, r) {
1331
+ let s = [];
1008
1332
  if (e.link_uuids) {
1009
- const o = e.link_uuids.length, n = [], a = 50;
1010
- for (let l = 0; l < o; l += a) {
1011
- const c = Math.min(o, l + a);
1012
- n.push(e.link_uuids.slice(l, c));
1333
+ const n = e.link_uuids.length, i = [], o = 50;
1334
+ for (let l = 0; l < n; l += o) {
1335
+ const a = Math.min(n, l + o);
1336
+ i.push(e.link_uuids.slice(l, a));
1013
1337
  }
1014
- for (let l = 0; l < n.length; l++)
1338
+ for (let l = 0; l < i.length; l++)
1015
1339
  (await this.getStories({
1016
- per_page: a,
1340
+ per_page: o,
1017
1341
  language: t.language,
1018
1342
  version: t.version,
1019
1343
  starts_with: t.starts_with,
1020
- by_uuids: n[l].join(",")
1021
- })).data.stories.forEach((c) => {
1022
- r.push(c);
1344
+ by_uuids: i[l].join(",")
1345
+ })).data.stories.forEach((a) => {
1346
+ s.push(a);
1023
1347
  });
1024
- } else r = e.links;
1025
- r.forEach((o) => {
1026
- this.links[s][o.uuid] = {
1027
- ...o,
1348
+ } else s = e.links;
1349
+ s.forEach((n) => {
1350
+ this.links[r][n.uuid] = {
1351
+ ...n,
1028
1352
  _stopResolving: !0
1029
1353
  };
1030
1354
  });
1031
1355
  }
1032
- async resolveRelations(e, t, s) {
1033
- let r = [];
1356
+ async resolveRelations(e, t, r) {
1357
+ let s = [];
1034
1358
  if (e.rel_uuids) {
1035
- const o = e.rel_uuids.length, n = [], a = 50;
1036
- for (let l = 0; l < o; l += a) {
1037
- const c = Math.min(o, l + a);
1038
- n.push(e.rel_uuids.slice(l, c));
1359
+ const n = e.rel_uuids.length, i = [], o = 50;
1360
+ for (let l = 0; l < n; l += o) {
1361
+ const a = Math.min(n, l + o);
1362
+ i.push(e.rel_uuids.slice(l, a));
1039
1363
  }
1040
- for (let l = 0; l < n.length; l++)
1364
+ for (let l = 0; l < i.length; l++)
1041
1365
  (await this.getStories({
1042
- per_page: a,
1366
+ per_page: o,
1043
1367
  language: t.language,
1044
1368
  version: t.version,
1045
1369
  starts_with: t.starts_with,
1046
- by_uuids: n[l].join(","),
1370
+ by_uuids: i[l].join(","),
1047
1371
  excluding_fields: t.excluding_fields
1048
- })).data.stories.forEach((c) => {
1049
- r.push(c);
1372
+ })).data.stories.forEach((a) => {
1373
+ s.push(a);
1050
1374
  });
1051
- r.length > 0 && (e.rels = r, delete e.rel_uuids);
1052
- } else r = e.rels;
1053
- r && r.length > 0 && r.forEach((o) => {
1054
- this.relations[s][o.uuid] = {
1055
- ...o,
1375
+ s.length > 0 && (e.rels = s, delete e.rel_uuids);
1376
+ } else s = e.rels;
1377
+ s && s.length > 0 && s.forEach((n) => {
1378
+ this.relations[r][n.uuid] = {
1379
+ ...n,
1056
1380
  _stopResolving: !0
1057
1381
  };
1058
1382
  });
@@ -1066,86 +1390,86 @@ var ut = class {
1066
1390
  * @returns Promise<void>
1067
1391
  *
1068
1392
  */
1069
- async resolveStories(e, t, s) {
1070
- var r, o;
1071
- let n = [];
1072
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && [
1393
+ async resolveStories(e, t, r) {
1394
+ var s, n;
1395
+ let i = [];
1396
+ if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && [
1073
1397
  "1",
1074
1398
  "story",
1075
1399
  "url",
1076
1400
  "link"
1077
- ].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const a in this.relations[s]) this.iterateTree(this.relations[s][a], n, s);
1078
- e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((a) => {
1079
- this.iterateTree(a, n, s);
1080
- }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
1401
+ ].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations) for (const o in this.relations[r]) this.iterateTree(this.relations[r][o], i, r);
1402
+ e.story ? this.iterateTree(e.story, i, r) : e.stories.forEach((o) => {
1403
+ this.iterateTree(o, i, r);
1404
+ }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
1081
1405
  }
1082
- async cacheResponse(e, t, s, r) {
1083
- const o = z({
1406
+ async cacheResponse(e, t, r, s) {
1407
+ const n = ke({
1084
1408
  url: e,
1085
1409
  params: t
1086
- }), n = this.cacheProvider();
1410
+ }), i = this.cacheProvider();
1087
1411
  if (t.version === "published" && e !== "/cdn/spaces/me") {
1088
- const c = await n.get(o);
1089
- if (c) return Promise.resolve(c);
1412
+ const a = await i.get(n);
1413
+ if (a) return Promise.resolve(a);
1090
1414
  }
1091
- const a = !D(e) && this.rateLimitConfig.isManagementApi ? P : void 0, l = H(e, t, this.rateLimitConfig, a);
1092
- return new Promise(async (c, u) => {
1415
+ const o = !pe(e) && this.rateLimitConfig.isManagementApi ? oe : void 0, l = ae(e, t, this.rateLimitConfig, o);
1416
+ return new Promise(async (a, h) => {
1093
1417
  var g;
1094
1418
  try {
1095
- const d = await this.throttleManager.execute(l, "get", e, t, r);
1096
- if (d.status !== 200) return u(d);
1097
- let C = {
1098
- data: d.data,
1099
- headers: d.headers
1419
+ const p = await this.throttleManager.execute(l, "get", e, t, s);
1420
+ if (p.status !== 200) return h(p);
1421
+ let w = {
1422
+ data: p.data,
1423
+ headers: p.headers
1100
1424
  };
1101
- const R = ot(d.headers);
1102
- if ((R == null ? void 0 : R.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = R.max), (g = d.headers) != null && g["per-page"] && (C = Object.assign({}, C, {
1103
- perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
1104
- total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
1105
- })), C.data.story || C.data.stories) {
1106
- const T = this.resolveCounter = ++this.resolveCounter % 1e3;
1107
- await this.resolveStories(C.data, t, `${T}`), C = await this.processInlineAssets(C);
1425
+ const I = er(p.headers);
1426
+ if ((I == null ? void 0 : I.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = I.max), (g = p.headers) != null && g["per-page"] && (w = Object.assign({}, w, {
1427
+ perPage: p.headers["per-page"] ? Number.parseInt(p.headers["per-page"]) : 0,
1428
+ total: p.headers["per-page"] ? Number.parseInt(p.headers.total) : 0
1429
+ })), w.data.story || w.data.stories) {
1430
+ const $ = this.resolveCounter = ++this.resolveCounter % 1e3;
1431
+ await this.resolveStories(w.data, t, `${$}`), w = await this.processInlineAssets(w);
1108
1432
  }
1109
- t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, C);
1110
- const k = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
1111
- return t.token && C.data.cv && (k && _[t.token] && _[t.token] !== C.data.cv && await this.flushCache(), _[t.token] = C.data.cv), c(C);
1112
- } catch (d) {
1113
- if (d.response && d.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
1114
- return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ze(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(u);
1115
- u(d);
1433
+ t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, w);
1434
+ const E = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
1435
+ return t.token && w.data.cv && (E && D[t.token] && D[t.token] !== w.data.cv && await this.flushCache(), D[t.token] = w.data.cv), a(w);
1436
+ } catch (p) {
1437
+ if (p.response && p.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
1438
+ return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ft(this.retriesDelay), this.cacheResponse(e, t, r).then(a).catch(h);
1439
+ h(p);
1116
1440
  }
1117
1441
  });
1118
1442
  }
1119
- throttledRequest(e, t, s, r) {
1120
- return this.client.setFetchOptions(r), this.client[e](t, s);
1443
+ throttledRequest(e, t, r, s) {
1444
+ return this.client.setFetchOptions(s), this.client[e](t, r);
1121
1445
  }
1122
1446
  cacheVersions() {
1123
- return _;
1447
+ return D;
1124
1448
  }
1125
1449
  cacheVersion() {
1126
- return _[this.accessToken];
1450
+ return D[this.accessToken];
1127
1451
  }
1128
1452
  setCacheVersion(e) {
1129
- this.accessToken && (_[this.accessToken] = e);
1453
+ this.accessToken && (D[this.accessToken] = e);
1130
1454
  }
1131
1455
  clearCacheVersion() {
1132
- this.accessToken && (_[this.accessToken] = 0);
1456
+ this.accessToken && (D[this.accessToken] = 0);
1133
1457
  }
1134
1458
  cacheProvider() {
1135
1459
  switch (this.cache.type) {
1136
1460
  case "memory":
1137
1461
  return {
1138
1462
  get(e) {
1139
- return Promise.resolve(N[e]);
1463
+ return Promise.resolve(le[e]);
1140
1464
  },
1141
1465
  getAll() {
1142
- return Promise.resolve(N);
1466
+ return Promise.resolve(le);
1143
1467
  },
1144
1468
  set(e, t) {
1145
- return N[e] = t, Promise.resolve(void 0);
1469
+ return le[e] = t, Promise.resolve(void 0);
1146
1470
  },
1147
1471
  flush() {
1148
- return N = {}, Promise.resolve(void 0);
1472
+ return le = {}, Promise.resolve(void 0);
1149
1473
  }
1150
1474
  };
1151
1475
  case "custom":
@@ -1172,21 +1496,21 @@ var ut = class {
1172
1496
  }
1173
1497
  async processInlineAssets(e) {
1174
1498
  if (!this.inlineAssets) return e;
1175
- const t = (s) => {
1176
- if (!s || typeof s != "object") return s;
1177
- if (Array.isArray(s)) return s.map((o) => t(o));
1178
- let r = { ...s };
1179
- r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
1180
- ...e.data.assets.find((o) => o.id === r.id),
1181
- ...r
1499
+ const t = (r) => {
1500
+ if (!r || typeof r != "object") return r;
1501
+ if (Array.isArray(r)) return r.map((n) => t(n));
1502
+ let s = { ...r };
1503
+ s.fieldtype === "asset" && Array.isArray(e.data.assets) && (s = {
1504
+ ...e.data.assets.find((n) => n.id === s.id),
1505
+ ...s
1182
1506
  });
1183
- for (const o in r) typeof r[o] == "object" && (r[o] = t(r[o]));
1184
- return r;
1507
+ for (const n in s) typeof s[n] == "object" && (s[n] = t(s[n]));
1508
+ return s;
1185
1509
  };
1186
- 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;
1510
+ return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((r) => (r.content = t(r.content), r))), e;
1187
1511
  }
1188
- }, ht = ut;
1189
- const yt = (e = {}) => {
1512
+ }, ar = or;
1513
+ const mr = (e = {}) => {
1190
1514
  const { apiOptions: t } = e;
1191
1515
  if (!t || !t.accessToken) {
1192
1516
  console.error(
@@ -1194,8 +1518,8 @@ const yt = (e = {}) => {
1194
1518
  );
1195
1519
  return;
1196
1520
  }
1197
- return { storyblokApi: new ht(t) };
1198
- }, gt = (e) => {
1521
+ return { storyblokApi: new ar(t) };
1522
+ }, vr = (e) => {
1199
1523
  if (typeof e != "object" || typeof e._editable > "u")
1200
1524
  return {};
1201
1525
  try {
@@ -1210,39 +1534,42 @@ const yt = (e = {}) => {
1210
1534
  return {};
1211
1535
  }
1212
1536
  };
1213
- let q = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1214
- const bt = (e = {}) => {
1215
- var t, s;
1537
+ let be = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1538
+ const yr = (e = {}) => {
1539
+ var t, r;
1216
1540
  const {
1217
- bridge: r,
1218
- accessToken: o,
1219
- use: n = [],
1220
- apiOptions: a = {},
1541
+ bridge: s,
1542
+ accessToken: n,
1543
+ use: i = [],
1544
+ apiOptions: o = {},
1221
1545
  bridgeUrl: l
1222
1546
  } = e;
1223
- a.accessToken = a.accessToken || o;
1224
- const c = { bridge: r, apiOptions: a };
1225
- let u = {};
1226
- n.forEach((d) => {
1227
- u = { ...u, ...d(c) };
1228
- }), l && (q = l);
1229
- const g = !(typeof window > "u") && ((s = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : s.includes("_storyblok_tk"));
1230
- return r !== !1 && g && le(q), u;
1547
+ o.accessToken = o.accessToken || n;
1548
+ const a = { bridge: s, apiOptions: o };
1549
+ let h = {};
1550
+ i.forEach((p) => {
1551
+ h = { ...h, ...p(a) };
1552
+ }), l && (be = l);
1553
+ const g = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
1554
+ return s !== !1 && g && je(be), h;
1231
1555
  };
1232
- function Ct(e, t) {
1233
- return Ge(t).render(e);
1556
+ function gr(e, t) {
1557
+ return jt(t).render(e);
1234
1558
  }
1235
- const vt = () => le(q);
1559
+ const br = () => je(be);
1236
1560
  export {
1237
- yt as apiPlugin,
1238
- pt as getLiveStory,
1239
- mt as handleStoryblokMessage,
1240
- vt as loadStoryblokBridge,
1241
- Ct as renderRichText,
1242
- Ge as richTextResolver,
1243
- ft as storyblok,
1244
- gt as storyblokEditable,
1245
- bt as storyblokInit,
1246
- Ie as toCamelCase,
1247
- dt as useStoryblokApi
1561
+ mr as apiPlugin,
1562
+ cr as getLiveStory,
1563
+ ur as getPayload,
1564
+ fr as handleStoryblokMessage,
1565
+ pr as isEditorRequest,
1566
+ br as loadStoryblokBridge,
1567
+ gr as renderRichText,
1568
+ jt as richTextResolver,
1569
+ hr as sanitizeJSON,
1570
+ dr as storyblok,
1571
+ vr as storyblokEditable,
1572
+ yr as storyblokInit,
1573
+ tt as toCamelCase,
1574
+ lr as useStoryblokApi
1248
1575
  };