@storyblok/astro 7.2.1 → 7.2.3

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,4 +1,4 @@
1
- const ee = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1
+ const te = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
2
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
3
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
4
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -7,62 +7,62 @@ const ee = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xm
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`, te = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, re = new RegExp("^" + O.source), N = new RegExp(O.source + G.source, "gu"), j = new RegExp("\\d+" + G.source, "gu"), se = (e, t, s, n) => {
11
- let l = !1, r = !1, b = !1, p = !1;
10
+ </svg>`, re = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, ne = new RegExp("^" + O.source), P = new RegExp(O.source + G.source, "gu"), j = new RegExp("\\d+" + G.source, "gu"), se = (e, t, r, s) => {
11
+ let a = !1, n = !1, h = !1, p = !1;
12
12
  for (let i = 0; i < e.length; i++) {
13
- const u = e[i];
14
- p = i > 2 ? e[i - 3] === "-" : !0, l && te.test(u) ? (e = e.slice(0, i) + "-" + e.slice(i), l = !1, b = r, r = !0, i++) : r && b && oe.test(u) && (!p || n) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), b = r, r = !1, l = !0) : (l = t(u) === u && s(u) !== u, b = r, r = s(u) === u && t(u) !== u);
13
+ const d = e[i];
14
+ p = i > 2 ? e[i - 3] === "-" : !0, a && re.test(d) ? (e = e.slice(0, i) + "-" + e.slice(i), a = !1, h = n, n = !0, i++) : n && h && oe.test(d) && (!p || s) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), h = n, n = !1, a = !0) : (a = t(d) === d && r(d) !== d, h = n, n = r(d) === d && t(d) !== d);
15
15
  }
16
16
  return e;
17
- }, ne = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (s) => t(s))), le = (e, t) => (N.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (s, n, l) => ["_", "-"].includes(e.charAt(l + s.length)) ? s : t(s)).replaceAll(N, (s, n) => t(n)));
18
- function ae(e, t) {
17
+ }, ae = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (r) => t(r))), le = (e, t) => (P.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (r, s, a) => ["_", "-"].includes(e.charAt(a + r.length)) ? r : t(r)).replaceAll(P, (r, s) => t(s)));
18
+ function ie(e, t) {
19
19
  if (!(typeof e == "string" || Array.isArray(e)))
20
20
  throw new TypeError("Expected the input to be `string | string[]`");
21
21
  if (t = {
22
22
  pascalCase: !1,
23
23
  preserveConsecutiveUppercase: !1,
24
24
  ...t
25
- }, Array.isArray(e) ? e = e.map((r) => r.trim()).filter((r) => r.length).join("-") : e = e.trim(), e.length === 0)
25
+ }, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
26
26
  return "";
27
- const s = t.locale === !1 ? (r) => r.toLowerCase() : (r) => r.toLocaleLowerCase(t.locale), n = t.locale === !1 ? (r) => r.toUpperCase() : (r) => r.toLocaleUpperCase(t.locale);
28
- return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : s(e) : (e !== s(e) && (e = se(e, s, n, t.preserveConsecutiveUppercase)), e = e.replace(re, ""), e = t.preserveConsecutiveUppercase ? ne(e, s) : s(e), t.pascalCase && (e = n(e.charAt(0)) + e.slice(1)), le(e, n));
27
+ const r = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
28
+ return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? s(e) : r(e) : (e !== r(e) && (e = se(e, r, s, t.preserveConsecutiveUppercase)), e = e.replace(ne, ""), e = t.preserveConsecutiveUppercase ? ae(e, r) : r(e), t.pascalCase && (e = s(e.charAt(0)) + e.slice(1)), le(e, s));
29
29
  }
30
- function P(e) {
31
- return ae(e);
30
+ function D(e) {
31
+ return ie(e);
32
32
  }
33
- function ie(e, t = {}, s, n) {
34
- const l = "virtual:storyblok-components", r = `\0${l}`;
33
+ function ce(e, t = {}, r, s) {
34
+ const a = "virtual:storyblok-components", n = `\0${a}`;
35
35
  return {
36
36
  name: "vite-plugin-storyblok-components",
37
- async resolveId(b) {
38
- if (b === l)
39
- return r;
37
+ async resolveId(h) {
38
+ if (h === a)
39
+ return n;
40
40
  },
41
- async load(b) {
42
- if (b === r) {
41
+ async load(h) {
42
+ if (h === n) {
43
43
  const p = [], i = [];
44
- for await (const [f, E] of Object.entries(t)) {
45
- const L = await this.resolve(
46
- `/${e}/${E}.astro`
44
+ for await (const [f, v] of Object.entries(t)) {
45
+ const A = await this.resolve(
46
+ `/${e}/${v}.astro`
47
47
  );
48
- if (L)
49
- p.push(`import ${P(f)} from "${L.id}"`);
50
- else if (s)
48
+ if (A)
49
+ p.push(`import ${D(f)} from "${A.id}"`);
50
+ else if (r)
51
51
  i.push(f);
52
52
  else
53
53
  throw new Error(
54
- `Component could not be found for blok "${f}"! Does "${`/${e}/${E}`}.astro" exist?`
54
+ `Component could not be found for blok "${f}"! Does "${`/${e}/${v}`}.astro" exist?`
55
55
  );
56
56
  }
57
- let u = "";
58
- if (s)
59
- if (u = ",FallbackComponent", n) {
57
+ let d = "";
58
+ if (r)
59
+ if (d = ",FallbackComponent", s) {
60
60
  const f = await this.resolve(
61
- `/${e}/${n}.astro`
61
+ `/${e}/${s}.astro`
62
62
  );
63
63
  if (!f)
64
64
  throw new Error(
65
- `Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`
65
+ `Custom fallback component could not be found. Does "${`/${e}/${s}`}.astro" exist?`
66
66
  );
67
67
  p.push(
68
68
  `import FallbackComponent from "${f.id}"`
@@ -72,9 +72,9 @@ function ie(e, t = {}, s, n) {
72
72
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
73
73
  );
74
74
  if (Object.values(t).length)
75
- return `${p.join(";")};export default {${Object.keys(t).filter((f) => !i.includes(f)).map((f) => P(f)).join(",")}${u}}`;
76
- if (s)
77
- return `${p[0]}; export default {${u.replace(",", "")}}`;
75
+ return `${p.join(";")};export default {${Object.keys(t).filter((f) => !i.includes(f)).map((f) => D(f)).join(",")}${d}}`;
76
+ if (r)
77
+ return `${p[0]}; export default {${d.replace(",", "")}}`;
78
78
  throw new Error(
79
79
  `Currently, no Storyblok components are registered in astro.config.mjs.
80
80
  Please register your components or enable the fallback component.
@@ -84,22 +84,22 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
84
84
  }
85
85
  };
86
86
  }
87
- function ce(e, t, s) {
88
- const n = "virtual:storyblok-init", l = `\0${n}`;
87
+ function ue(e, t, r) {
88
+ const s = "virtual:storyblok-init", a = `\0${s}`;
89
89
  return {
90
90
  name: "vite-plugin-storyblok-init",
91
- async resolveId(r) {
92
- if (r === n)
93
- return l;
91
+ async resolveId(n) {
92
+ if (n === s)
93
+ return a;
94
94
  },
95
- async load(r) {
96
- if (r === l)
95
+ async load(n) {
96
+ if (n === a)
97
97
  return `
98
98
  import { storyblokInit, apiPlugin } from "@storyblok/js";
99
99
  const { storyblokApi } = storyblokInit({
100
100
  accessToken: "${e}",
101
101
  use: ${t ? "[]" : "[apiPlugin]"},
102
- apiOptions: ${JSON.stringify(s)},
102
+ apiOptions: ${JSON.stringify(r)},
103
103
  });
104
104
  export const storyblokApiInstance = storyblokApi;
105
105
  `;
@@ -107,32 +107,32 @@ function ce(e, t, s) {
107
107
  };
108
108
  }
109
109
  function de(e) {
110
- const t = "virtual:storyblok-options", s = `\0${t}`;
110
+ const t = "virtual:storyblok-options", r = `\0${t}`;
111
111
  return {
112
112
  name: "vite-plugin-storyblok-options",
113
- async resolveId(n) {
114
- if (n === t)
115
- return s;
113
+ async resolveId(s) {
114
+ if (s === t)
115
+ return r;
116
116
  },
117
- async load(n) {
118
- if (n === s)
117
+ async load(s) {
118
+ if (s === r)
119
119
  return `export default ${JSON.stringify(e)}`;
120
120
  }
121
121
  };
122
122
  }
123
- function Ce() {
123
+ function _e() {
124
124
  if (!(globalThis != null && globalThis.storyblokApiInstance))
125
125
  throw new Error("storyblokApiInstance has not been initialized correctly");
126
126
  return globalThis.storyblokApiInstance;
127
127
  }
128
- async function Ee(e) {
128
+ async function Be(e) {
129
129
  let t = null;
130
130
  return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
131
131
  }
132
- function ue(e) {
132
+ function pe(e) {
133
133
  return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
134
134
  }
135
- function Le(e) {
135
+ function Ne(e) {
136
136
  const t = {
137
137
  useCustomApi: !1,
138
138
  bridge: !0,
@@ -140,26 +140,26 @@ function Le(e) {
140
140
  enableFallbackComponent: !1,
141
141
  livePreview: !1,
142
142
  ...e
143
- }, s = ue(t.bridge);
143
+ }, r = pe(t.bridge);
144
144
  return {
145
145
  name: "@storyblok/astro",
146
146
  hooks: {
147
147
  "astro:config:setup": ({
148
- injectScript: n,
149
- updateConfig: l,
150
- addDevToolbarApp: r,
151
- addMiddleware: b,
148
+ injectScript: s,
149
+ updateConfig: a,
150
+ addDevToolbarApp: n,
151
+ addMiddleware: h,
152
152
  config: p
153
153
  }) => {
154
- if (l({
154
+ if (a({
155
155
  vite: {
156
156
  plugins: [
157
- ce(
157
+ ue(
158
158
  t.accessToken,
159
159
  t.useCustomApi,
160
160
  t.apiOptions
161
161
  ),
162
- ie(
162
+ ce(
163
163
  t.componentsDir,
164
164
  t.components,
165
165
  t.enableFallbackComponent,
@@ -172,18 +172,18 @@ function Le(e) {
172
172
  throw new Error(
173
173
  "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."
174
174
  );
175
- n(
175
+ s(
176
176
  "page-ssr",
177
177
  `
178
178
  import { storyblokApiInstance } from "virtual:storyblok-init";
179
179
  globalThis.storyblokApiInstance = storyblokApiInstance;
180
180
  `
181
- ), t.bridge && !t.livePreview && n(
181
+ ), t.bridge && !t.livePreview && s(
182
182
  "page",
183
183
  `import { loadStoryblokBridge } from "@storyblok/astro";
184
184
  loadStoryblokBridge().then(() => {
185
185
  const { StoryblokBridge, location } = window;
186
- ${s}
186
+ ${r}
187
187
  storyblokInstance.on(["published", "change"], (event) => {
188
188
  if (!event.slugChanged) {
189
189
  location.reload(true);
@@ -191,54 +191,54 @@ function Le(e) {
191
191
  });
192
192
  });
193
193
  `
194
- ), t.livePreview && (n(
194
+ ), t.livePreview && (s(
195
195
  "page",
196
196
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
197
197
  loadStoryblokBridge().then(() => {
198
198
  const { StoryblokBridge, location } = window;
199
- ${s}
199
+ ${r}
200
200
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
201
201
  });
202
202
  `
203
- ), b({
203
+ ), h({
204
204
  entrypoint: "@storyblok/astro/middleware.ts",
205
205
  order: "pre"
206
- })), r({
206
+ })), n({
207
207
  id: "storyblok",
208
208
  name: "Storyblok",
209
- icon: ee,
209
+ icon: te,
210
210
  entrypoint: "@storyblok/astro/toolbarApp.ts"
211
211
  });
212
212
  }
213
213
  }
214
214
  };
215
215
  }
216
- let D;
217
- async function $e(e) {
218
- const { action: t, story: s } = e || {};
219
- if (t === "input" && s) {
220
- const n = async () => {
221
- const r = await be(s), b = document.body;
222
- if (r.outerHTML === b.outerHTML)
216
+ let U;
217
+ async function Me(e) {
218
+ const { action: t, story: r } = e || {};
219
+ if (t === "input" && r) {
220
+ const s = async () => {
221
+ const n = await fe(r), h = document.body;
222
+ if (n.outerHTML === h.outerHTML)
223
223
  return;
224
224
  const p = document.querySelector('[data-blok-focused="true"]');
225
- pe(b, r, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
225
+ he(h, n, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
226
226
  };
227
- clearTimeout(D), D = setTimeout(n, 500);
227
+ clearTimeout(U), U = setTimeout(s, 500);
228
228
  }
229
229
  ["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
230
230
  }
231
- function pe(e, t, s) {
232
- if (s) {
233
- const n = s.getAttribute("data-blok-uid"), l = t.querySelector(
234
- `[data-blok-uid="${n}"]`
231
+ function he(e, t, r) {
232
+ if (r) {
233
+ const s = r.getAttribute("data-blok-uid"), a = t.querySelector(
234
+ `[data-blok-uid="${s}"]`
235
235
  );
236
- l && (l.setAttribute("data-blok-focused", "true"), s.replaceWith(l));
236
+ a && (a.setAttribute("data-blok-focused", "true"), r.replaceWith(a));
237
237
  } else
238
238
  e.replaceWith(t);
239
239
  }
240
- async function be(e) {
241
- const s = await (await fetch(location.href, {
240
+ async function fe(e) {
241
+ const r = await (await fetch(location.href, {
242
242
  method: "POST",
243
243
  body: JSON.stringify({
244
244
  ...e,
@@ -248,41 +248,95 @@ async function be(e) {
248
248
  "Content-Type": "application/json"
249
249
  }
250
250
  })).text();
251
- return new DOMParser().parseFromString(s, "text/html").body;
251
+ return new DOMParser().parseFromString(r, "text/html").body;
252
+ }
253
+ function I(e, t, r) {
254
+ this.type = e, this.tag = t, this.attrs = null, this.map = null, this.nesting = r, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
252
255
  }
253
- function fe(e, t) {
254
- if (!t)
255
- return { src: e, attrs: {} };
256
- let s = 0, n = 0;
257
- const l = {}, r = [];
258
- function b(i, u, f, E, L) {
259
- typeof i != "number" || i <= u || i >= f ? console.warn(`[StoryblokRichText] - ${E.charAt(0).toUpperCase() + E.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : L.push(`${E}(${i})`);
256
+ I.prototype.attrIndex = function(e) {
257
+ if (!this.attrs)
258
+ return -1;
259
+ const t = this.attrs;
260
+ for (let r = 0, s = t.length; r < s; r++)
261
+ if (t[r][0] === e)
262
+ return r;
263
+ return -1;
264
+ };
265
+ I.prototype.attrPush = function(e) {
266
+ this.attrs ? this.attrs.push(e) : this.attrs = [e];
267
+ };
268
+ I.prototype.attrSet = function(e, t) {
269
+ const r = this.attrIndex(e), s = [e, t];
270
+ r < 0 ? this.attrPush(s) : this.attrs[r] = s;
271
+ };
272
+ I.prototype.attrGet = function(e) {
273
+ const t = this.attrIndex(e);
274
+ let r = null;
275
+ return t >= 0 && (r = this.attrs[t][1]), r;
276
+ };
277
+ I.prototype.attrJoin = function(e, t) {
278
+ const r = this.attrIndex(e);
279
+ r < 0 ? this.attrPush([e, t]) : this.attrs[r][1] = this.attrs[r][1] + " " + t;
280
+ };
281
+ const be = "[a-zA-Z_:][a-zA-Z0-9:._-]*", ye = "[^\"'=<>`\\x00-\\x20]+", ge = "'[^']*'", ke = '"[^"]*"', me = "(?:" + ye + "|" + ge + "|" + ke + ")", we = "(?:\\s+" + be + "(?:\\s*=\\s*" + me + ")?)", Ce = "<[A-Za-z][A-Za-z0-9\\-]*" + we + "*\\s*\\/?>", Ee = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", ve = new RegExp("^(?:" + Ce + "|" + Ee + ")");
282
+ new RegExp(ve.source + "\\s*$");
283
+ const Z = [];
284
+ for (let e = 0; e < 256; e++)
285
+ Z.push(0);
286
+ "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e) {
287
+ Z[e.charCodeAt(0)] = 1;
288
+ });
289
+ let k = /* @__PURE__ */ function(e) {
290
+ 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;
291
+ }({}), E = /* @__PURE__ */ function(e) {
292
+ 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;
293
+ }({}), Ae = /* @__PURE__ */ function(e) {
294
+ return e.TEXT = "text", e;
295
+ }({}), T = /* @__PURE__ */ function(e) {
296
+ return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
297
+ }({});
298
+ function Le(e, t) {
299
+ if (!t) return {
300
+ src: e,
301
+ attrs: {}
302
+ };
303
+ let r = 0, s = 0;
304
+ const a = {}, n = [];
305
+ function h(i, d, f, v, A) {
306
+ typeof i != "number" || i <= d || i >= f ? console.warn(`[StoryblokRichText] - ${v.charAt(0).toUpperCase() + v.slice(1)} value must be a number between ${d} and ${f} (inclusive)`) : A.push(`${v}(${i})`);
260
307
  }
261
308
  if (typeof t == "object") {
262
- if (typeof t.width == "number" && t.width > 0 ? (l.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (l.height = t.height, n = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (l.loading = t.loading), t.class && (l.class = t.class), t.filters) {
263
- const { filters: i } = t || {}, { blur: u, brightness: f, fill: E, format: L, grayscale: C, quality: $, rotate: T } = i || {};
264
- u && b(u, 0, 100, "blur", r), $ && b($, 0, 100, "quality", r), f && b(f, 0, 100, "brightness", r), E && r.push(`fill(${E})`), C && r.push("grayscale()"), T && [0, 90, 180, 270].includes(t.filters.rotate || 0) && r.push(`rotate(${T})`), L && ["webp", "png", "jpeg"].includes(L) && r.push(`format(${L})`);
309
+ if (typeof t.width == "number" && t.width > 0 ? (a.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (a.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (a.loading = t.loading), t.class && (a.class = t.class), t.filters) {
310
+ const { filters: i } = t || {}, { blur: d, brightness: f, fill: v, format: A, grayscale: C, quality: L, rotate: $ } = i || {};
311
+ d && h(d, 0, 100, "blur", n), L && h(L, 0, 100, "quality", n), f && h(f, 0, 100, "brightness", n), v && n.push(`fill(${v})`), C && n.push("grayscale()"), $ && [
312
+ 0,
313
+ 90,
314
+ 180,
315
+ 270
316
+ ].includes(t.filters.rotate || 0) && n.push(`rotate(${$})`), A && [
317
+ "webp",
318
+ "png",
319
+ "jpeg"
320
+ ].includes(A) && n.push(`format(${A})`);
265
321
  }
266
- t.srcset && (l.srcset = t.srcset.map((i) => {
267
- if (typeof i == "number")
268
- return `${e}/m/${i}x0/${r.length > 0 ? `filters:${r.join(":")}` : ""} ${i}w`;
322
+ t.srcset && (a.srcset = t.srcset.map((i) => {
323
+ if (typeof i == "number") return `${e}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
269
324
  if (Array.isArray(i) && i.length === 2) {
270
- const [u, f] = i;
271
- return `${e}/m/${u}x${f}/${r.length > 0 ? `filters:${r.join(":")}` : ""} ${u}w`;
325
+ const [d, f] = i;
326
+ return `${e}/m/${d}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${d}w`;
272
327
  } else {
273
328
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
274
329
  return;
275
330
  }
276
- }).join(", ")), t.sizes && (l.sizes = t.sizes.join(", "));
331
+ }).join(", ")), t.sizes && (a.sizes = t.sizes.join(", "));
277
332
  }
278
333
  let p = `${e}/m/`;
279
- return s > 0 && n > 0 && (p = `${p}${s}x${n}/`), r.length > 0 && (p = `${p}filters:${r.join(":")}`), {
334
+ return r > 0 && s > 0 && (p = `${p}${r}x${s}/`), n.length > 0 && (p = `${p}filters:${n.join(":")}`), {
280
335
  src: p,
281
- attrs: l
336
+ attrs: a
282
337
  };
283
338
  }
284
- var g = /* @__PURE__ */ ((e) => (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))(g || {}), v = /* @__PURE__ */ ((e) => (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))(v || {}), z = /* @__PURE__ */ ((e) => (e.TEXT = "text", e))(z || {}), I = /* @__PURE__ */ ((e) => (e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e))(I || {});
285
- const ye = [
339
+ const Ie = [
286
340
  "area",
287
341
  "base",
288
342
  "br",
@@ -297,222 +351,203 @@ const ye = [
297
351
  "source",
298
352
  "track",
299
353
  "wbr"
300
- ], he = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), ge = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
301
- function ke(e) {
354
+ ], $e = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), Se = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
355
+ function Te(e) {
302
356
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
303
357
  }
304
- const S = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
305
- function U(e, t = {}, s) {
306
- const n = he(t), l = n ? `${e} ${n}` : e, r = Array.isArray(s) ? s.join("") : s || "";
358
+ const R = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
359
+ function H(e, t = {}, r) {
360
+ const s = $e(t), a = s ? `${e} ${s}` : e, n = Array.isArray(r) ? r.join("") : r || "";
307
361
  if (e) {
308
- if (ye.includes(e))
309
- return `<${l}>`;
310
- } else return r;
311
- return `<${l}>${r}</${e}>`;
362
+ if (Ie.includes(e)) return `<${a}>`;
363
+ } else return n;
364
+ return `<${a}>${n}</${e}>`;
312
365
  }
313
- function me(e = {}) {
314
- const t = /* @__PURE__ */ new Map(), {
315
- renderFn: s = U,
316
- textFn: n = ke,
317
- resolvers: l = {},
318
- optimizeImages: r = !1,
319
- keyedResolvers: b = !1
320
- } = e, p = s !== U, i = (o) => (a, c) => {
321
- const d = a.attrs || {};
322
- return c.render(o, d, a.children || null);
323
- }, u = (o, a) => {
324
- const { src: c, alt: d, title: y, srcset: m, sizes: h } = o.attrs || {};
325
- let k = c, w = {};
326
- if (r) {
327
- const { src: V, attrs: Q } = fe(c, r);
328
- k = V, w = Q;
366
+ function Re(e = {}) {
367
+ const t = /* @__PURE__ */ new Map(), { renderFn: r = H, textFn: s = Te, resolvers: a = {}, optimizeImages: n = !1, keyedResolvers: h = !1 } = e, p = r !== H, i = (o) => (l, c) => {
368
+ const u = l.attrs || {};
369
+ return c.render(o, u, l.children || null);
370
+ }, d = (o, l) => {
371
+ const { src: c, alt: u, title: b, srcset: m, sizes: y } = o.attrs || {};
372
+ let g = c, w = {};
373
+ if (n) {
374
+ const { src: Q, attrs: ee } = Le(c, n);
375
+ g = Q, w = ee;
329
376
  }
330
- const Z = {
331
- src: k,
332
- alt: d,
333
- title: y,
377
+ const X = {
378
+ src: g,
379
+ alt: u,
380
+ title: b,
334
381
  srcset: m,
335
- sizes: h,
382
+ sizes: y,
336
383
  ...w
337
384
  };
338
- return a.render("img", S(Z));
339
- }, f = (o, a) => {
340
- const { level: c, ...d } = o.attrs || {};
341
- return a.render(`h${c}`, d, o.children);
342
- }, E = (o, a) => {
343
- var c, d, y, m;
344
- const h = a.render("img", {
385
+ return l.render("img", R(X));
386
+ }, f = (o, l) => {
387
+ const { level: c, ...u } = o.attrs || {};
388
+ return l.render(`h${c}`, u, o.children);
389
+ }, v = (o, l) => {
390
+ var c, u, b, m;
391
+ const y = l.render("img", {
345
392
  src: (c = o.attrs) == null ? void 0 : c.fallbackImage,
346
- alt: (d = o.attrs) == null ? void 0 : d.alt,
393
+ alt: (u = o.attrs) == null ? void 0 : u.alt,
347
394
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
348
395
  draggable: "false",
349
396
  loading: "lazy"
350
397
  });
351
- return a.render("span", {
398
+ return l.render("span", {
352
399
  "data-type": "emoji",
353
- "data-name": (y = o.attrs) == null ? void 0 : y.name,
400
+ "data-name": (b = o.attrs) == null ? void 0 : b.name,
354
401
  "data-emoji": (m = o.attrs) == null ? void 0 : m.emoji
355
- }, h);
356
- }, L = (o, a) => a.render(
357
- "pre",
358
- o.attrs || {},
359
- a.render("code", {}, o.children || "")
360
- ), C = (o, a = !1) => ({ text: c, attrs: d }, y) => {
361
- const { class: m, id: h, ...k } = d || {}, w = a ? {
402
+ }, y);
403
+ }, A = (o, l) => l.render("pre", o.attrs || {}, l.render("code", {}, o.children || "")), C = (o, l = !1) => ({ text: c, attrs: u }, b) => {
404
+ const { class: m, id: y, ...g } = u || {}, w = l ? {
362
405
  class: m,
363
- id: h,
364
- style: ge(k) || void 0
365
- } : d || {};
366
- return y.render(o, S(w), c);
367
- }, $ = (o) => R(o), T = (o) => {
368
- const { marks: a, ...c } = o;
406
+ id: y,
407
+ style: Se(g) || void 0
408
+ } : u || {};
409
+ return b.render(o, R(w), c);
410
+ }, L = (o) => x(o), $ = (o) => {
411
+ const { marks: l, ...c } = o;
369
412
  if ("text" in o) {
370
- if (a)
371
- return a.reduce(
372
- (y, m) => $({ ...m, text: y }),
373
- $({ ...c, children: c.children })
374
- );
375
- const d = o.attrs || {};
376
- if (b) {
377
- const y = t.get("txt") || 0;
378
- t.set("txt", y + 1), d.key = `txt-${y}`;
413
+ if (l) return l.reduce((b, m) => L({
414
+ ...m,
415
+ text: b
416
+ }), L({
417
+ ...c,
418
+ children: c.children
419
+ }));
420
+ const u = o.attrs || {};
421
+ if (h) {
422
+ const b = t.get("txt") || 0;
423
+ t.set("txt", b + 1), u.key = `txt-${b}`;
379
424
  }
380
- return n(c.text, d);
425
+ return s(c.text, u);
381
426
  }
382
427
  return "";
383
- }, x = (o, a) => {
384
- const { linktype: c, href: d, anchor: y, ...m } = o.attrs || {};
385
- let h = "";
428
+ }, _ = (o, l) => {
429
+ const { linktype: c, href: u, anchor: b, ...m } = o.attrs || {};
430
+ let y = "";
386
431
  switch (c) {
387
- case I.ASSET:
388
- case I.URL:
389
- h = d;
432
+ case T.ASSET:
433
+ case T.URL:
434
+ y = u;
390
435
  break;
391
- case I.EMAIL:
392
- h = `mailto:${d}`;
436
+ case T.EMAIL:
437
+ y = `mailto:${u}`;
393
438
  break;
394
- case I.STORY:
395
- h = d, y && (h = `${h}#${y}`);
439
+ case T.STORY:
440
+ y = u, b && (y = `${y}#${b}`);
396
441
  break;
397
442
  default:
398
- h = d;
443
+ y = u;
399
444
  break;
400
445
  }
401
- const k = { ...m };
402
- return h && (k.href = h), a.render("a", k, o.text);
403
- }, K = (o, a) => {
404
- var c, d;
405
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), a.render("span", {
446
+ const g = { ...m };
447
+ return y && (g.href = y), l.render("a", g, o.text);
448
+ }, J = (o, l) => {
449
+ var c, u;
450
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), l.render("span", {
406
451
  blok: (c = o == null ? void 0 : o.attrs) == null ? void 0 : c.body[0],
407
- id: (d = o.attrs) == null ? void 0 : d.id,
452
+ id: (u = o.attrs) == null ? void 0 : u.id,
408
453
  style: "display: none"
409
454
  });
410
- }, J = (o, a) => {
411
- const c = {}, d = a.render("tbody", {}, o.children);
412
- return a.render("table", c, d);
413
- }, W = (o, a) => {
455
+ }, K = (o, l) => {
456
+ const c = {}, u = l.render("tbody", {}, o.children);
457
+ return l.render("table", c, u);
458
+ }, W = (o, l) => {
414
459
  const c = {};
415
- return a.render("tr", c, o.children);
416
- }, Y = (o, a) => {
417
- const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
418
- ...h
419
- };
420
- c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
460
+ return l.render("tr", c, o.children);
461
+ }, Y = (o, l) => {
462
+ const { colspan: c, rowspan: u, colwidth: b, backgroundColor: m, ...y } = o.attrs || {}, g = { ...y };
463
+ c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
421
464
  const w = [];
422
- return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("td", S(k), o.children);
423
- }, q = (o, a) => {
424
- const { colspan: c, rowspan: d, colwidth: y, backgroundColor: m, ...h } = o.attrs || {}, k = {
425
- ...h
426
- };
427
- c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
465
+ return b && w.push(`width: ${b}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (g.style = w.join(" ")), l.render("td", R(g), o.children);
466
+ }, q = (o, l) => {
467
+ const { colspan: c, rowspan: u, colwidth: b, backgroundColor: m, ...y } = o.attrs || {}, g = { ...y };
468
+ c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
428
469
  const w = [];
429
- return y && w.push(`width: ${y}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (k.style = w.join(" ")), a.render("th", S(k), o.children);
430
- }, _ = /* @__PURE__ */ new Map([
431
- [g.DOCUMENT, i("")],
432
- [g.HEADING, f],
433
- [g.PARAGRAPH, i("p")],
434
- [g.UL_LIST, i("ul")],
435
- [g.OL_LIST, i("ol")],
436
- [g.LIST_ITEM, i("li")],
437
- [g.IMAGE, u],
438
- [g.EMOJI, E],
439
- [g.CODE_BLOCK, L],
440
- [g.HR, i("hr")],
441
- [g.BR, i("br")],
442
- [g.QUOTE, i("blockquote")],
443
- [g.COMPONENT, K],
444
- [z.TEXT, T],
445
- [v.LINK, x],
446
- [v.ANCHOR, x],
447
- [v.STYLED, C("span", !0)],
448
- [v.BOLD, C("strong")],
449
- [v.TEXT_STYLE, C("span", !0)],
450
- [v.ITALIC, C("em")],
451
- [v.UNDERLINE, C("u")],
452
- [v.STRIKE, C("s")],
453
- [v.CODE, C("code")],
454
- [v.SUPERSCRIPT, C("sup")],
455
- [v.SUBSCRIPT, C("sub")],
456
- [v.HIGHLIGHT, C("mark")],
457
- [g.TABLE, J],
458
- [g.TABLE_ROW, W],
459
- [g.TABLE_CELL, Y],
460
- [g.TABLE_HEADER, q]
461
- ]), B = new Map([
462
- ..._,
463
- ...Object.entries(l).map(([o, a]) => [o, a])
464
- ]), X = () => ({
465
- render: (o, a = {}, c) => {
466
- if (b && o) {
467
- const d = t.get(o) || 0;
468
- t.set(o, d + 1), a.key = `${o}-${d}`;
470
+ return b && w.push(`width: ${b}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (g.style = w.join(" ")), l.render("th", R(g), o.children);
471
+ }, B = /* @__PURE__ */ new Map([
472
+ [k.DOCUMENT, i("")],
473
+ [k.HEADING, f],
474
+ [k.PARAGRAPH, i("p")],
475
+ [k.UL_LIST, i("ul")],
476
+ [k.OL_LIST, i("ol")],
477
+ [k.LIST_ITEM, i("li")],
478
+ [k.IMAGE, d],
479
+ [k.EMOJI, v],
480
+ [k.CODE_BLOCK, A],
481
+ [k.HR, i("hr")],
482
+ [k.BR, i("br")],
483
+ [k.QUOTE, i("blockquote")],
484
+ [k.COMPONENT, J],
485
+ [Ae.TEXT, $],
486
+ [E.LINK, _],
487
+ [E.ANCHOR, _],
488
+ [E.STYLED, C("span", !0)],
489
+ [E.BOLD, C("strong")],
490
+ [E.TEXT_STYLE, C("span", !0)],
491
+ [E.ITALIC, C("em")],
492
+ [E.UNDERLINE, C("u")],
493
+ [E.STRIKE, C("s")],
494
+ [E.CODE, C("code")],
495
+ [E.SUPERSCRIPT, C("sup")],
496
+ [E.SUBSCRIPT, C("sub")],
497
+ [E.HIGHLIGHT, C("mark")],
498
+ [k.TABLE, K],
499
+ [k.TABLE_ROW, W],
500
+ [k.TABLE_CELL, Y],
501
+ [k.TABLE_HEADER, q]
502
+ ]), N = new Map([...B, ...Object.entries(a).map(([o, l]) => [o, l])]), V = () => ({
503
+ render: (o, l = {}, c) => {
504
+ if (h && o) {
505
+ const u = t.get(o) || 0;
506
+ t.set(o, u + 1), l.key = `${o}-${u}`;
469
507
  }
470
- return s(o, a, c);
508
+ return r(o, l, c);
471
509
  },
472
- originalResolvers: _,
473
- mergedResolvers: B
510
+ originalResolvers: B,
511
+ mergedResolvers: N
474
512
  });
475
- function A(o) {
476
- const a = B.get(o.type);
477
- if (!a)
513
+ function S(o) {
514
+ const l = N.get(o.type);
515
+ if (!l)
478
516
  return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
479
- const c = X();
480
- if (o.type === "text")
481
- return a(o, c);
482
- const d = o.content ? o.content.map(R) : void 0;
483
- return a({
517
+ const c = V();
518
+ if (o.type === "text") return l(o, c);
519
+ const u = o.content ? o.content.map(x) : void 0;
520
+ return l({
484
521
  ...o,
485
- children: d
522
+ children: u
486
523
  }, c);
487
524
  }
488
- function R(o) {
489
- return o.type === "doc" ? p ? o.content.map(A) : o.content.map(A).join("") : Array.isArray(o) ? o.map(A) : A(o);
525
+ function x(o) {
526
+ return o.type === "doc" ? p ? o.content.map(S) : o.content.map(S).join("") : Array.isArray(o) ? o.map(S) : S(o);
490
527
  }
491
- return {
492
- render: R
493
- };
528
+ return { render: x };
494
529
  }
495
- let H = !1;
496
- const F = [], we = (e) => new Promise((t, s) => {
530
+ let z = !1;
531
+ const F = [], xe = (e) => new Promise((t, r) => {
497
532
  if (typeof window > "u") {
498
- s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
533
+ r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
499
534
  return;
500
535
  }
501
- if (window.storyblokRegisterEvent = (l) => {
536
+ if (window.storyblokRegisterEvent = (a) => {
502
537
  if (!window.location.search.includes("_storyblok")) {
503
538
  console.warn("You are not in Draft Mode or in the Visual Editor.");
504
539
  return;
505
540
  }
506
- H ? l() : F.push(l);
541
+ z ? a() : F.push(a);
507
542
  }, document.getElementById("storyblok-javascript-bridge")) {
508
543
  t(void 0);
509
544
  return;
510
545
  }
511
- const n = document.createElement("script");
512
- n.async = !0, n.src = e, n.id = "storyblok-javascript-bridge", n.onerror = (l) => s(l), n.onload = (l) => {
513
- F.forEach((r) => r()), H = !0, t(l);
514
- }, document.getElementsByTagName("head")[0].appendChild(n);
515
- }), Ie = (e) => {
546
+ const s = document.createElement("script");
547
+ s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (a) => r(a), s.onload = (a) => {
548
+ F.forEach((n) => n()), z = !0, t(a);
549
+ }, document.getElementsByTagName("head")[0].appendChild(s);
550
+ }), Pe = (e) => {
516
551
  if (typeof e != "object" || typeof e._editable > "u")
517
552
  return {};
518
553
  try {
@@ -527,19 +562,19 @@ const F = [], we = (e) => new Promise((t, s) => {
527
562
  return {};
528
563
  }
529
564
  };
530
- let ve = "https://app.storyblok.com/f/storyblok-v2-latest.js";
531
- function Te(e, t) {
532
- return me(t).render(e);
565
+ let Oe = "https://app.storyblok.com/f/storyblok-v2-latest.js";
566
+ function je(e, t) {
567
+ return Re(t).render(e);
533
568
  }
534
- const Ae = () => we(ve);
569
+ const De = () => xe(Oe);
535
570
  export {
536
- Ee as getLiveStory,
537
- $e as handleStoryblokMessage,
538
- Ae as loadStoryblokBridge,
539
- Te as renderRichText,
540
- me as richTextResolver,
541
- Le as storyblok,
542
- Ie as storyblokEditable,
543
- P as toCamelCase,
544
- Ce as useStoryblokApi
571
+ Be as getLiveStory,
572
+ Me as handleStoryblokMessage,
573
+ De as loadStoryblokBridge,
574
+ je as renderRichText,
575
+ Re as richTextResolver,
576
+ Ne as storyblok,
577
+ Pe as storyblokEditable,
578
+ D as toCamelCase,
579
+ _e as useStoryblokApi
545
580
  };