@storyblok/astro 5.1.0-alpha.2 → 5.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -360,7 +360,7 @@ The Astro SDK now provides a live preview feature, designed to offer real-time e
360
360
 
361
361
  To activate the experimental live preview feature, follow these steps:
362
362
 
363
- 1. Set `livePreview` to `true` within your `astro.config.mjs` file.
363
+ 1. Set `livePreview` to `true` in your astro.config.mjs file. You can also add your `bridge` configuration here, which will be applied to your bridge.
364
364
 
365
365
  ```js
366
366
  //astro.config.mjs
@@ -369,13 +369,16 @@ export default defineConfig({
369
369
  storyblok({
370
370
  accessToken: "OsvN..",
371
371
  livePreview: true,
372
+ bridge: {
373
+ resolveRelations: ["featured.posts"],//Your bridge config
374
+ }
372
375
  }),
373
376
  ],
374
377
  output: "server", // Astro must be configured to run in SSR mode
375
378
  });
376
379
  ```
377
380
 
378
- 1. Additionally, please use `getLiveStory` on your Astro pages for getting live story.
381
+ 2. Additionally, please use `getLiveStory` on your Astro pages for getting live story.
379
382
 
380
383
  ```jsx
381
384
  //pages/[...slug].astro
@@ -406,7 +409,7 @@ if (liveStory) {
406
409
 
407
410
  <StoryblokComponent blok={story.content} />
408
411
  ```
409
- 2. You can also listen to when the live preview is updated.
412
+ 3. You can also listen to when the live preview is updated.
410
413
 
411
414
  ```js
412
415
  <script>
@@ -416,6 +419,85 @@ if (liveStory) {
416
419
  });
417
420
  </script>
418
421
  ```
422
+
423
+ ## Enabling Storyblok Loader
424
+
425
+ > [!WARNING]
426
+ > This feature is currently experimental and optional. You may encounters bugs or performance issues.
427
+
428
+ The Astro SDK now provides Storyblok Loader feature, It is designed to scale efficiently and handle large sites with thousands of pages highly performantly.
429
+
430
+ To activate the experimental Storyblok Loader feature, follow these steps:
431
+
432
+ 1. Set `contentLayer` to `true` in your `astro.config.mjs` file.
433
+
434
+ ```js
435
+ //astro.config.mjs
436
+ export default defineConfig({
437
+ integrations: [
438
+ storyblok({
439
+ accessToken: "OsvN..",
440
+ contentLayer: true,
441
+ }),
442
+ ],
443
+ });
444
+ ```
445
+
446
+ 2. Additionally, in your `src/content/config.ts` file define your collection.
447
+
448
+ ```jsx
449
+ //src/content/config.ts
450
+ import { storyblokLoader } from "@storyblok/astro";
451
+ import { defineCollection } from "astro:content";
452
+
453
+ const storyblokCollection = defineCollection({
454
+ loader: storyblokLoader({
455
+ accessToken: "fV...",
456
+ apiOptions: {
457
+ region: "us",
458
+ },
459
+ version: "draft",
460
+ }),
461
+ });
462
+
463
+ export const collections = {
464
+ storyblok: storyblokCollection,
465
+ };
466
+
467
+ ```
468
+ 3. You can now use the storyblokCollection in your pages.
469
+
470
+ ```jsx
471
+ //src/pages/[...slug].astro
472
+ ---
473
+ import StoryblokComponent from "@storyblok/astro/StoryblokComponent.astro";
474
+ import BaseLayout from "~/layouts/BaseLayout.astro";
475
+ import { getCollection } from "astro:content";
476
+ import { type ISbStoryData } from "@storyblok/astro";
477
+
478
+ export async function getStaticPaths() {
479
+ const stories = await getCollection("storyblok");
480
+
481
+ return stories.map(({ data }: { data: ISbStoryData }) => {
482
+ return {
483
+ params: { slug: data.full_slug },
484
+ props: { story: data },
485
+ };
486
+ });
487
+ }
488
+
489
+ interface Props {
490
+ story: ISbStoryData;
491
+ }
492
+
493
+ const { story } = Astro.props;
494
+ ---
495
+
496
+ <BaseLayout>
497
+ <StoryblokComponent blok={story.content} />
498
+ </BaseLayout>
499
+ ```
500
+
419
501
  ## The Storyblok JavaScript SDK Ecosystem
420
502
 
421
503
  ![A visual representation of the Storyblok JavaScript SDK Ecosystem](https://a.storyblok.com/f/88751/2400x1350/be4a4a4180/sdk-ecosystem.png/m/1200x0)
@@ -6,9 +6,9 @@
6
6
  apiOptions: ${JSON.stringify(t)},
7
7
  });
8
8
  export const storyblokApiInstance = storyblokApi;
9
- `}}}const D=/[\p{Lu}]/u,F=/[\p{Ll}]/u,_=/^[\p{Lu}](?![\p{Lu}])/gu,A=/([\p{Alpha}\p{N}_]|$)/u,S=/[_.\- ]+/,J=new RegExp("^"+S.source),I=new RegExp(S.source+A.source,"gu"),O=new RegExp("\\d+"+A.source,"gu"),q=(o,e,t,s)=>{let r=!1,n=!1,i=!1,l=!1;for(let a=0;a<o.length;a++){const c=o[a];l=a>2?o[a-3]==="-":!0,r&&D.test(c)?(o=o.slice(0,a)+"-"+o.slice(a),r=!1,i=n,n=!0,a++):n&&i&&F.test(c)&&(!l||s)?(o=o.slice(0,a-1)+"-"+o.slice(a-1),i=n,n=!1,r=!0):(r=e(c)===c&&t(c)!==c,i=n,n=t(c)===c&&e(c)!==c)}return o},V=(o,e)=>(_.lastIndex=0,o.replaceAll(_,t=>e(t))),K=(o,e)=>(I.lastIndex=0,O.lastIndex=0,o.replaceAll(O,(t,s,r)=>["_","-"].includes(o.charAt(r+t.length))?t:e(t)).replaceAll(I,(t,s)=>e(s)));function L(o,e){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(o)?o=o.map(n=>n.trim()).filter(n=>n.length).join("-"):o=o.trim(),o.length===0)return"";const t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),s=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return o.length===1?S.test(o)?"":e.pascalCase?s(o):t(o):(o!==t(o)&&(o=q(o,t,s,e.preserveConsecutiveUppercase)),o=o.replace(J,""),o=e.preserveConsecutiveUppercase?V(o,t):t(o),e.pascalCase&&(o=s(o.charAt(0))+o.slice(1)),K(o,s))}function W(o,e,t,s){const r="virtual:storyblok-components",n="\0"+r;return{name:"vite-plugin-storyblok-components",async resolveId(i){if(i===r)return n},async load(i){if(i===n){const l=[],a=[];for await(const[h,u]of Object.entries(e)){const p=await this.resolve("/"+o+"/"+u+".astro");if(p)l.push(`import ${L(h)} from "${p.id}"`);else if(t)a.push(h);else throw new Error(`Component could not be found for blok "${h}"! Does "${"/"+o+"/"+u}.astro" exist?`)}let c="";if(t)if(c=",FallbackComponent",s){const h=await this.resolve("/"+o+"/"+s+".astro");if(!h)throw new Error(`Custom fallback component could not be found. Does "${"/"+o+"/"+s}.astro" exist?`);l.push(`import FallbackComponent from "${h.id}"`)}else l.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(e).length)return`${l.join(";")};export default {${Object.keys(e).filter(h=>!a.includes(h)).map(h=>L(h)).join(",")}${c}}`;if(t)return`${l[0]}; export default {${c.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
9
+ `}}}const D=/[\p{Lu}]/u,F=/[\p{Ll}]/u,_=/^[\p{Lu}](?![\p{Lu}])/gu,A=/([\p{Alpha}\p{N}_]|$)/u,S=/[_.\- ]+/,J=new RegExp("^"+S.source),I=new RegExp(S.source+A.source,"gu"),O=new RegExp("\\d+"+A.source,"gu"),q=(o,e,t,s)=>{let r=!1,n=!1,i=!1,l=!1;for(let a=0;a<o.length;a++){const c=o[a];l=a>2?o[a-3]==="-":!0,r&&D.test(c)?(o=o.slice(0,a)+"-"+o.slice(a),r=!1,i=n,n=!0,a++):n&&i&&F.test(c)&&(!l||s)?(o=o.slice(0,a-1)+"-"+o.slice(a-1),i=n,n=!1,r=!0):(r=e(c)===c&&t(c)!==c,i=n,n=t(c)===c&&e(c)!==c)}return o},V=(o,e)=>(_.lastIndex=0,o.replaceAll(_,t=>e(t))),W=(o,e)=>(I.lastIndex=0,O.lastIndex=0,o.replaceAll(O,(t,s,r)=>["_","-"].includes(o.charAt(r+t.length))?t:e(t)).replaceAll(I,(t,s)=>e(s)));function L(o,e){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(o)?o=o.map(n=>n.trim()).filter(n=>n.length).join("-"):o=o.trim(),o.length===0)return"";const t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),s=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return o.length===1?S.test(o)?"":e.pascalCase?s(o):t(o):(o!==t(o)&&(o=q(o,t,s,e.preserveConsecutiveUppercase)),o=o.replace(J,""),o=e.preserveConsecutiveUppercase?V(o,t):t(o),e.pascalCase&&(o=s(o.charAt(0))+o.slice(1)),W(o,s))}function K(o,e,t,s){const r="virtual:storyblok-components",n="\0"+r;return{name:"vite-plugin-storyblok-components",async resolveId(i){if(i===r)return n},async load(i){if(i===n){const l=[],a=[];for await(const[h,u]of Object.entries(e)){const p=await this.resolve("/"+o+"/"+u+".astro");if(p)l.push(`import ${L(h)} from "${p.id}"`);else if(t)a.push(h);else throw new Error(`Component could not be found for blok "${h}"! Does "${"/"+o+"/"+u}.astro" exist?`)}let c="";if(t)if(c=",FallbackComponent",s){const h=await this.resolve("/"+o+"/"+s+".astro");if(!h)throw new Error(`Custom fallback component could not be found. Does "${"/"+o+"/"+s}.astro" exist?`);l.push(`import FallbackComponent from "${h.id}"`)}else l.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(e).length)return`${l.join(";")};export default {${Object.keys(e).filter(h=>!a.includes(h)).map(h=>L(h)).join(",")}${c}}`;if(t)return`${l[0]}; export default {${c.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
10
  Please register your components or enable the fallback component.
11
- Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function Z(o){const e="virtual:storyblok-options",t="\0"+e;return{name:"vite-plugin-storyblok-options",async resolveId(s){if(s===e)return t},async load(s){if(s===t)return`export default ${JSON.stringify(o)}`}}}let j=!1;const E=[],x=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}j?r():E.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{E.forEach(n=>n()),j=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var Y=Object.defineProperty,G=(o,e,t)=>e in o?Y(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,d=(o,e,t)=>G(o,typeof e!="symbol"?e+"":e,t);function P(o){return!(o!==o||o===1/0||o===-1/0)}function Q(o,e,t){if(!P(e))throw new TypeError("Expected `limit` to be a finite number");if(!P(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],n=0;const i=function(){n++;const a=setTimeout(function(){n--,s.length>0&&i(),r=r.filter(function(h){return h!==a})},t);r.indexOf(a)<0&&r.push(a);const c=s.shift();c.resolve(o.apply(c.self,c.args))},l=function(...a){const c=this;return new Promise(function(h,u){s.push({resolve:h,reject:u,args:a,self:c}),n<e&&i()})};return l.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},l}class v{constructor(){d(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),d(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),d(this,"delay",e=>new Promise(t=>setTimeout(t,e))),d(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),d(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,i)=>i*r+e)}),d(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),d(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),d(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],l=s?"":encodeURIComponent(n);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent("["+l+"]"):l,Array.isArray(i)):a=(t?t+encodeURIComponent("["+l+"]"):l)+"="+encodeURIComponent(i),r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return i;default:return t}}}const X=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},ee=o=>o==="email",te=()=>({singleTag:"hr"}),se=()=>({tag:"blockquote"}),re=()=>({tag:"ul"}),oe=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),ne=()=>({singleTag:"br"}),ie=o=>({tag:`h${o.attrs.level}`}),ae=o=>({singleTag:[{tag:"img",attrs:X(o.attrs,["src","alt","title"])}]}),le=()=>({tag:"li"}),ce=()=>({tag:"ol"}),he=()=>({tag:"p"}),ue=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),de=()=>({tag:"b"}),pe=()=>({tag:"s"}),fe=()=>({tag:"u"}),ge=()=>({tag:"strong"}),ye=()=>({tag:"code"}),me=()=>({tag:"i"}),be=o=>{if(!o.attrs)return{tag:""};const e=new v().escapeHTML,t={...o.attrs},{linktype:s="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),ee(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ke=o=>({tag:[{tag:"span",attrs:o.attrs}]}),ve=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Se=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Te=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ce=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},N={nodes:{horizontal_rule:te,blockquote:se,bullet_list:re,code_block:oe,hard_break:ne,heading:ie,image:ae,list_item:le,ordered_list:ce,paragraph:he,emoji:ue},marks:{bold:de,strike:pe,underline:fe,strong:ge,code:ye,italic:me,link:be,styled:ke,subscript:ve,superscript:we,anchor:Se,highlight:Te,textStyle:Ce}},Re=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};let M=!1;class $e{constructor(e){d(this,"marks"),d(this,"nodes"),e||(e=N),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},s=!0){if(!M&&s&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),M=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
11
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function Z(o){const e="virtual:storyblok-options",t="\0"+e;return{name:"vite-plugin-storyblok-options",async resolveId(s){if(s===e)return t},async load(s){if(s===t)return`export default ${JSON.stringify(o)}`}}}let j=!1;const x=[],E=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}j?r():x.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{x.forEach(n=>n()),j=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var G=Object.defineProperty,Y=(o,e,t)=>e in o?G(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,d=(o,e,t)=>Y(o,typeof e!="symbol"?e+"":e,t);function P(o){return!(o!==o||o===1/0||o===-1/0)}function Q(o,e,t){if(!P(e))throw new TypeError("Expected `limit` to be a finite number");if(!P(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],n=0;const i=function(){n++;const a=setTimeout(function(){n--,s.length>0&&i(),r=r.filter(function(h){return h!==a})},t);r.indexOf(a)<0&&r.push(a);const c=s.shift();c.resolve(o.apply(c.self,c.args))},l=function(...a){const c=this;return new Promise(function(h,u){s.push({resolve:h,reject:u,args:a,self:c}),n<e&&i()})};return l.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},l}class v{constructor(){d(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),d(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),d(this,"delay",e=>new Promise(t=>setTimeout(t,e))),d(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),d(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,i)=>i*r+e)}),d(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),d(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),d(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],l=s?"":encodeURIComponent(n);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent("["+l+"]"):l,Array.isArray(i)):a=(t?t+encodeURIComponent("["+l+"]"):l)+"="+encodeURIComponent(i),r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return i;default:return t}}}const X=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},ee=o=>o==="email",te=()=>({singleTag:"hr"}),se=()=>({tag:"blockquote"}),re=()=>({tag:"ul"}),oe=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),ne=()=>({singleTag:"br"}),ie=o=>({tag:`h${o.attrs.level}`}),ae=o=>({singleTag:[{tag:"img",attrs:X(o.attrs,["src","alt","title"])}]}),le=()=>({tag:"li"}),ce=()=>({tag:"ol"}),he=()=>({tag:"p"}),ue=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),de=()=>({tag:"b"}),pe=()=>({tag:"s"}),fe=()=>({tag:"u"}),ge=()=>({tag:"strong"}),ye=()=>({tag:"code"}),me=()=>({tag:"i"}),be=o=>{if(!o.attrs)return{tag:""};const e=new v().escapeHTML,t={...o.attrs},{linktype:s="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),ee(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ke=o=>({tag:[{tag:"span",attrs:o.attrs}]}),ve=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Se=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Te=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ce=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},N={nodes:{horizontal_rule:te,blockquote:se,bullet_list:re,code_block:oe,hard_break:ne,heading:ie,image:ae,list_item:le,ordered_list:ce,paragraph:he,emoji:ue},marks:{bold:de,strike:pe,underline:fe,strong:ge,code:ye,italic:me,link:be,styled:ke,subscript:ve,superscript:we,anchor:Se,highlight:Te,textStyle:Ce}},$e=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};let M=!1;class Re{constructor(e){d(this,"marks"),d(this,"nodes"),e||(e=N),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},s=!0){if(!M&&s&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),M=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
12
12
  The "content" field must be an array of nodes as the type ISbRichtext.
13
13
  ISbRichtext:
14
14
  content?: ISbRichtext[]
@@ -31,7 +31,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
31
31
  }
32
32
  ],
33
33
  type: 'doc'
34
- }`),""}optimizeImages(e,t){let s=0,r=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i="/filters"+i))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,h;const u=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(u&&u.length>0){const p={srcset:(c=t.srcset)==null?void 0:c.map(f=>{if(typeof f=="number")return`//${u}/m/${f}x0${i} ${f}w`;if(typeof f=="object"&&f.length===2){let $=0,z=0;return typeof f[0]=="number"&&($=f[0]),typeof f[1]=="number"&&(z=f[1]),`//${u}/m/${$}x${z}${i} ${$}w`}}).join(", "),sizes:(h=t.sizes)==null?void 0:h.map(f=>f).join(", ")};let y="";return p.srcset&&(y+=`srcset="${p.srcset}" `),p.sizes&&(y+=`sizes="${p.sizes}" `),a.replace(/<img/g,`<img ${y.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(Re(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const n in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,n)){const i=s.attrs[n];i!==null&&(r+=` ${n}="${i}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const k=$e;class _e{constructor(e){d(this,"baseURL"),d(this,"timeout"),d(this,"headers"),d(this,"responseInterceptor"),d(this,"fetch"),d(this,"ejectInterceptor"),d(this,"url"),d(this,"parameters"),d(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={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new v;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}const Ae=_e,U="SB-Agent",T={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let w={};const m={};class Ie{constructor(e,t){d(this,"client"),d(this,"maxRetries"),d(this,"retriesDelay"),d(this,"throttle"),d(this,"accessToken"),d(this,"cache"),d(this,"helpers"),d(this,"resolveCounter"),d(this,"relations"),d(this,"links"),d(this,"richTextResolver"),d(this,"resolveNestedRelations"),d(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const i=new v().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${i(e.region)}/v1`:s=`${l}://${i(e.region)}/v2`}const r=new Headers;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(([i,l])=>{r.set(i,l)}),r.has(U)||(r.set(U,T.defaultAgentName),r.set(T.defaultAgentVersion,T.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new k(e.richTextSchema):this.richTextResolver=new k,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=Q(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ae({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=m[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,i,void 0,n)}get(e,t,s){t||(t={});const r=`/${e}`,n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,s)}async getAll(e,t,s,r){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`,l=i.split("/"),a=s||l[l.length-1],c=1,h=await this.makeRequest(i,t,n,c,r),u=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(c,u),y=>this.makeRequest(i,t,n,y+1,r));return this.helpers.flatMap([h,...p],y=>Object.values(y.data[a]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("delete",r,t,s))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];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]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(r,n)).filter(Boolean)))}iterateTree(e,t,s){const r=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)r(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,s),this._insertLinks(n,i,s)),r(n[i])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.link_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let i=[];if(this.links[s]={},this.relations[s]={},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,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],i,s);e.story?this.iterateTree(e.story,i,s):e.stories.forEach(l=>{this.iterateTree(l,i,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const h=await this.throttle("get",e,t,r);if(h.status!==200)return a(h);let u={data:h.data,headers:h.headers};if((c=h.headers)!=null&&c["per-page"]&&(u=Object.assign({},u,{perPage:h.headers["per-page"]?parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?parseInt(h.headers.total):0})),u.data.story||u.data.stories){const p=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,t,`${p}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(n,u),u.data.cv&&t.token&&(t.version==="draft"&&m[t.token]!=u.data.cv&&await this.flushCache(),m[t.token]=t.cv?t.cv:u.data.cv),l(u)}catch(h){if(h.response&&h.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(l).catch(a);a(h)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(m[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(w[e])},getAll(){return Promise.resolve(w)},set(e,t){return w[e]=t,Promise.resolve(void 0)},flush(){return w={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}}const Oe=(o={})=>{const{apiOptions:e}=o;if(!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Ie(e)}},Le=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let C,R="https://app.storyblok.com/f/storyblok-v2-latest.js";const je=(o={})=>{var e,t;const{bridge:s,accessToken:r,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||r;const c={bridge:s,apiOptions:i};let h={};n.forEach(p=>{h={...h,...p(c)}}),a&&(R=a);const u=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&u&&x(R),C=new k(l.schema),l.resolver&&B(C,l.resolver),h},B=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},Ee=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),xe=(o,e,t)=>{let s=t||C;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ee(o)?"":(e&&(s=new k(e.schema),e.resolver&&B(s,e.resolver)),s.render(o,{},!1))},Pe=()=>x(R);function Ne(o){return typeof o=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(o)});`:"const storyblokInstance = new StoryblokBridge();"}const Me=`<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">
34
+ }`),""}optimizeImages(e,t){let s=0,r=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i="/filters"+i))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,h;const u=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(u&&u.length>0){const p={srcset:(c=t.srcset)==null?void 0:c.map(f=>{if(typeof f=="number")return`//${u}/m/${f}x0${i} ${f}w`;if(typeof f=="object"&&f.length===2){let R=0,z=0;return typeof f[0]=="number"&&(R=f[0]),typeof f[1]=="number"&&(z=f[1]),`//${u}/m/${R}x${z}${i} ${R}w`}}).join(", "),sizes:(h=t.sizes)==null?void 0:h.map(f=>f).join(", ")};let y="";return p.srcset&&(y+=`srcset="${p.srcset}" `),p.sizes&&(y+=`sizes="${p.sizes}" `),a.replace(/<img/g,`<img ${y.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push($e(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const n in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,n)){const i=s.attrs[n];i!==null&&(r+=` ${n}="${i}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const k=Re;class _e{constructor(e){d(this,"baseURL"),d(this,"timeout"),d(this,"headers"),d(this,"responseInterceptor"),d(this,"fetch"),d(this,"ejectInterceptor"),d(this,"url"),d(this,"parameters"),d(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={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new v;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}const Ae=_e,U="SB-Agent",T={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let w={};const m={};class Ie{constructor(e,t){d(this,"client"),d(this,"maxRetries"),d(this,"retriesDelay"),d(this,"throttle"),d(this,"accessToken"),d(this,"cache"),d(this,"helpers"),d(this,"resolveCounter"),d(this,"relations"),d(this,"links"),d(this,"richTextResolver"),d(this,"resolveNestedRelations"),d(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const i=new v().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${i(e.region)}/v1`:s=`${l}://${i(e.region)}/v2`}const r=new Headers;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(([i,l])=>{r.set(i,l)}),r.has(U)||(r.set(U,T.defaultAgentName),r.set(T.defaultAgentVersion,T.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new k(e.richTextSchema):this.richTextResolver=new k,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=Q(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ae({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=m[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,i,void 0,n)}get(e,t,s){t||(t={});const r=`/${e}`,n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,s)}async getAll(e,t,s,r){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`,l=i.split("/"),a=s||l[l.length-1],c=1,h=await this.makeRequest(i,t,n,c,r),u=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(c,u),y=>this.makeRequest(i,t,n,y+1,r));return this.helpers.flatMap([h,...p],y=>Object.values(y.data[a]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("delete",r,t,s))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];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]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(r,n)).filter(Boolean)))}iterateTree(e,t,s){const r=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)r(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,s),this._insertLinks(n,i,s)),r(n[i])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.link_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let i=[];if(this.links[s]={},this.relations[s]={},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,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],i,s);e.story?this.iterateTree(e.story,i,s):e.stories.forEach(l=>{this.iterateTree(l,i,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const h=await this.throttle("get",e,t,r);if(h.status!==200)return a(h);let u={data:h.data,headers:h.headers};if((c=h.headers)!=null&&c["per-page"]&&(u=Object.assign({},u,{perPage:h.headers["per-page"]?parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?parseInt(h.headers.total):0})),u.data.story||u.data.stories){const p=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,t,`${p}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(n,u),u.data.cv&&t.token&&(t.version==="draft"&&m[t.token]!=u.data.cv&&await this.flushCache(),m[t.token]=t.cv?t.cv:u.data.cv),l(u)}catch(h){if(h.response&&h.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(l).catch(a);a(h)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(m[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(w[e])},getAll(){return Promise.resolve(w)},set(e,t){return w[e]=t,Promise.resolve(void 0)},flush(){return w={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}}const Oe=(o={})=>{const{apiOptions:e}=o;if(!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Ie(e)}},Le=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let C,$="https://app.storyblok.com/f/storyblok-v2-latest.js";const je=(o={})=>{var e,t;const{bridge:s,accessToken:r,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||r;const c={bridge:s,apiOptions:i};let h={};n.forEach(p=>{h={...h,...p(c)}}),a&&($=a);const u=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&u&&E($),C=new k(l.schema),l.resolver&&B(C,l.resolver),h},B=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},xe=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ee=(o,e,t)=>{let s=t||C;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return xe(o)?"":(e&&(s=new k(e.schema),e.resolver&&B(s,e.resolver)),s.render(o,{},!1))},Pe=()=>E($);function Ne(o){return typeof o=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(o)});`:"const storyblokInstance = new StoryblokBridge();"}const Me=`<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">
35
35
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
36
36
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
37
37
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -40,7 +40,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
40
40
  </g>
41
41
  </g>
42
42
  </g>
43
- </svg>`;let H;async function Ue(o){const{action:e,story:t}=o||{};if(e==="input"&&t){const s=async()=>{const n=await He(t),i=document.body;if(n.outerHTML===i.outerHTML)return;const l=document.querySelector('[data-blok-focused="true"]');Be(i,n,l),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(H),H=setTimeout(s,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function Be(o,e,t){if(t){const s=t.getAttribute("data-blok-uid"),r=e.querySelector(`[data-blok-uid="${s}"]`);r&&(r.setAttribute("data-blok-focused","true"),t.replaceWith(r))}else o.replaceWith(e)}async function He(o){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}async function ze(o){const{story:e}=o||{};await fetch(location.origin+"/_refresh",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}function De(o){const{storyblokApi:e}=je({accessToken:o.STORYBLOK_TOKEN,use:[Oe]});return{name:"story-loader",load:async({store:t,meta:s,logger:r,refreshContextData:n})=>{if(!e)throw new Error("storyblokApi is not loaded");if(n!=null&&n.story){r.info("Syncing... story updated in Storyblok");const h=n.story;t.set({data:h,id:h.uuid});return}r.info("Loading stories");const i=s.get("lastPublishedAt"),l=i&&o.version==="published"?{published_at_gt:i}:{},a=await(e==null?void 0:e.getAll("cdn/stories",{version:o.version,...l}));console.log("total = ",a.length),r.info("Clearing store"),o.version==="draft"&&t.clear();let c=i?new Date(i):null;for(const h of a){const u=h.published_at?new Date(h.published_at):null;u&&(!c||u>c)&&(c=u),t.set({data:h,id:h.uuid}),c&&s.set("lastPublishedAt",c.toISOString())}}}}function Fe(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function Je(o){let e=null;return o&&o.locals._storyblok_preview_data&&(e=o.locals._storyblok_preview_data),e}function qe(o,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return xe(o,e,t)}function Ve({useCustomApi:o=!1,bridge:e=!0,componentsDir:t="src",enableFallbackComponent:s=!1,livePreview:r=!1,contentLayer:n=!1,...i}){const l={useCustomApi:o,bridge:e,componentsDir:t,enableFallbackComponent:s,livePreview:r,contentLayer:n,...i},a=Ne(e);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:c,updateConfig:h,addDevToolbarApp:u,addMiddleware:p,config:y})=>{if(h({vite:{plugins:[b(l.accessToken,l.useCustomApi,l.apiOptions),W(l.componentsDir,l.components,l.enableFallbackComponent,l.customFallbackComponent),Z(l)]}}),l.livePreview&&(y==null?void 0:y.output)!=="server")throw new Error("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.");c("page-ssr",`
43
+ </svg>`;let H;async function Ue(o){const{action:e,story:t}=o||{};if(e==="input"&&t){const s=async()=>{const n=await He(t),i=document.body;if(n.outerHTML===i.outerHTML)return;const l=document.querySelector('[data-blok-focused="true"]');Be(i,n,l),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(H),H=setTimeout(s,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function Be(o,e,t){if(t){const s=t.getAttribute("data-blok-uid"),r=e.querySelector(`[data-blok-uid="${s}"]`);r&&(r.setAttribute("data-blok-focused","true"),t.replaceWith(r))}else o.replaceWith(e)}async function He(o){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}async function ze(o){const{story:e}=o||{};await fetch(location.origin+"/_refresh",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}function De(o){const{storyblokApi:e}=je({accessToken:o.accessToken,apiOptions:o.apiOptions,use:[Oe]});return{name:"story-loader",load:async({store:t,meta:s,logger:r,refreshContextData:n})=>{if(!e)throw new Error("storyblokApi is not loaded");if(n!=null&&n.story){r.info("Syncing... story updated in Storyblok");const h=n.story;t.set({data:h,id:h.uuid});return}r.info("Loading stories");const i=s.get("lastPublishedAt"),l=i&&o.version==="published"?{published_at_gt:i}:{},a=await(e==null?void 0:e.getAll("cdn/stories",{version:o.version,...l}));console.log("total = ",a.length),r.info("Clearing store"),o.version==="draft"&&t.clear();let c=i?new Date(i):null;for(const h of a){const u=h.published_at?new Date(h.published_at):null;u&&(!c||u>c)&&(c=u),t.set({data:h,id:h.uuid}),c&&s.set("lastPublishedAt",c.toISOString())}}}}function Fe(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function Je(o){let e=null;return o&&o.locals._storyblok_preview_data&&(e=o.locals._storyblok_preview_data),e}function qe(o,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ee(o,e,t)}function Ve({useCustomApi:o=!1,bridge:e=!0,componentsDir:t="src",enableFallbackComponent:s=!1,livePreview:r=!1,contentLayer:n=!1,...i}){const l={useCustomApi:o,bridge:e,componentsDir:t,enableFallbackComponent:s,livePreview:r,contentLayer:n,...i},a=Ne(e);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:c,updateConfig:h,addDevToolbarApp:u,addMiddleware:p,config:y})=>{if(h({vite:{plugins:[b(l.accessToken,l.useCustomApi,l.apiOptions),K(l.componentsDir,l.components,l.enableFallbackComponent,l.customFallbackComponent),Z(l)]}}),l.livePreview&&(y==null?void 0:y.output)!=="server")throw new Error("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.");c("page-ssr",`
44
44
  import { storyblokApiInstance } from "virtual:storyblok-init";
45
45
  globalThis.storyblokApiInstance = storyblokApiInstance;
46
46
  `),e&&!r&&c("page",`
@@ -94,7 +94,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
94
94
  }
95
95
  };
96
96
  }
97
- function K(o) {
97
+ function W(o) {
98
98
  const e = "virtual:storyblok-options", t = "\0" + e;
99
99
  return {
100
100
  name: "vite-plugin-storyblok-options",
@@ -122,11 +122,11 @@ const O = [], M = (o) => new Promise((e, t) => {
122
122
  O.forEach((n) => n()), x = !0, e(r);
123
123
  }, document.getElementsByTagName("head")[0].appendChild(s);
124
124
  });
125
- var W = Object.defineProperty, Z = (o, e, t) => e in o ? W(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, d = (o, e, t) => Z(o, typeof e != "symbol" ? e + "" : e, t);
125
+ var K = Object.defineProperty, Z = (o, e, t) => e in o ? K(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, d = (o, e, t) => Z(o, typeof e != "symbol" ? e + "" : e, t);
126
126
  function E(o) {
127
127
  return !(o !== o || o === 1 / 0 || o === -1 / 0);
128
128
  }
129
- function Y(o, e, t) {
129
+ function G(o, e, t) {
130
130
  if (!E(e))
131
131
  throw new TypeError("Expected `limit` to be a finite number");
132
132
  if (!E(t))
@@ -225,7 +225,7 @@ class b {
225
225
  }
226
226
  }
227
227
  }
228
- const G = function(o, e) {
228
+ const Y = function(o, e) {
229
229
  const t = {};
230
230
  for (const s in o) {
231
231
  const r = o[s];
@@ -254,7 +254,7 @@ const G = function(o, e) {
254
254
  singleTag: [
255
255
  {
256
256
  tag: "img",
257
- attrs: G(o.attrs, ["src", "alt", "title"])
257
+ attrs: Y(o.attrs, ["src", "alt", "title"])
258
258
  }
259
259
  ]
260
260
  }), ie = () => ({
@@ -647,7 +647,7 @@ class Ae {
647
647
  w.packageVersion
648
648
  ));
649
649
  let n = 5;
650
- e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Y(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new _e({
650
+ e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = G(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new _e({
651
651
  baseURL: s,
652
652
  timeout: e.timeout || 0,
653
653
  headers: r,
@@ -1059,7 +1059,8 @@ async function He(o) {
1059
1059
  }
1060
1060
  function ze(o) {
1061
1061
  const { storyblokApi: e } = xe({
1062
- accessToken: o.STORYBLOK_TOKEN,
1062
+ accessToken: o.accessToken,
1063
+ apiOptions: o.apiOptions,
1063
1064
  use: [Ie]
1064
1065
  });
1065
1066
  return {
@@ -1152,7 +1153,7 @@ function qe({
1152
1153
  l.enableFallbackComponent,
1153
1154
  l.customFallbackComponent
1154
1155
  ),
1155
- K(l)
1156
+ W(l)
1156
1157
  ]
1157
1158
  }
1158
1159
  }), l.livePreview && (f == null ? void 0 : f.output) !== "server")
@@ -1,6 +1,8 @@
1
1
  import type { Loader } from "astro/loaders";
2
+ import { type ISbConfig } from "@storyblok/js";
2
3
  interface StoryblokLoaderConfig {
3
- STORYBLOK_TOKEN: string;
4
+ accessToken: string;
5
+ apiOptions?: ISbConfig;
4
6
  version: "draft" | "published";
5
7
  }
6
8
  export declare function storyblokLoader(config: StoryblokLoaderConfig): Loader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
- "version": "5.1.0-alpha.2",
3
+ "version": "5.1.0-alpha.4",
4
4
  "description": "Official Astro integration for the Storyblok Headless CMS",
5
5
  "main": "./dist/storyblok-astro.js",
6
6
  "module": "./dist/storyblok-astro.mjs",