@storyblok/astro 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -143,7 +143,7 @@ For working examples, please refer to the [Live Demo on Stackblitz](https://stac
143
143
 
144
144
  ### 2. Getting Storyblok Stories and using the Storyblok Bridge
145
145
 
146
- ### Fetching one Story
146
+ #### Fetching one Story
147
147
 
148
148
  Use the `useStoryblokApi` function to have access to an instance of `storyblok-js-client`:
149
149
 
@@ -165,7 +165,7 @@ const story = data.story;
165
165
 
166
166
  > Note: The available methods are described in the [storyblok-js-client] repository(https://github.com/storyblok/storyblok-js-client#method-storyblokget)
167
167
 
168
- ### Dynamic Routing
168
+ #### Dynamic Routing
169
169
 
170
170
  In order to dynamically generate Astro pages based on the Stories in your Storyblok Space, you can use the [Storyblok Links API](https://www.storyblok.com/docs/api/content-delivery/v2#core-resources/links/links) and the Astro [`getStaticPaths()` function](https://docs.astro.build/en/reference/api-reference/#getstaticpaths) similar to this example:
171
171
 
@@ -210,7 +210,7 @@ The Storyblok Bridge is automatically activated by default. If you would like to
210
210
 
211
211
  > Note: Since Astro is not a reactive JavaScript framework and renders everything as HTML, the Storyblok Bridge will not provide real-time editing as you may know it from other frameworks. However, it automatically refreshes the site for you whenever you save or publish a story.
212
212
 
213
- #### Rendering Rich Text
213
+ ### Rendering Rich Text
214
214
 
215
215
  You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/astro`. Then you can use the [`set:html` directive](https://docs.astro.build/en/reference/directives-reference/#sethtml):
216
216
 
@@ -1,8 +1,25 @@
1
1
  ---
2
2
  import components from "virtual:storyblok-components";
3
+ import camelcase from "camelcase";
4
+
3
5
  const { blok, ...props } = Astro.props;
4
6
 
5
- const Component = components[blok.component];
7
+ /**
8
+ * convert blok components to camel case to match vite-plugin-storyblok
9
+ */
10
+ const key = camelcase(blok.component);
11
+
12
+ if (!(key in components)) {
13
+ /**
14
+ * Component not found! Log an error with details on the blok name that could not be found
15
+ * TODO: Add support for a placeholder component as a fallback?
16
+ */
17
+ throw new Error(
18
+ `Component could not be found for blok "${blok.component}"! Is it defined in astro.config.mjs?`
19
+ );
20
+ }
21
+
22
+ const Component = components[key];
6
23
  ---
7
24
 
8
25
  <Component blok={blok} {...props} />
@@ -1,10 +1,10 @@
1
- (function(h,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h.storyblokAstro={},h.axios))})(this,function(h,g){"use strict";const A=(n=>n&&typeof n=="object"&&"default"in n?n:{default:n})(g);function P(n){const e="virtual:storyblok-components",t="\0"+e;return{name:"vite-plugin-storyblok",async resolveId(r){if(r===e)return t},async load(r){if(r===t){const s=[];for await(const[o,a]of Object.entries(n)){const{id:i}=await this.resolve("/src/"+a+".astro");s.push(`import ${o} from "${i}"`)}return`${s.join(";")};export default {${Object.keys(n).join(",")}}`}}}}var M=Object.defineProperty,I=Object.defineProperties,C=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,T=(n,e,t)=>e in n?M(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))N.call(e,t)&&T(n,t,e[t]);if(v)for(var t of v(e))q.call(e,t)&&T(n,t,e[t]);return n},k=(n,e)=>I(n,C(e));let _=!1;const w=[],R=n=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}_?s():w.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{w.forEach(o=>o()),_=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)}),L=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t},B=n=>n==="email";var $={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(n){return{tag:["pre",{tag:"code",attrs:n.attrs}]}},hard_break(){return{singleTag:"br"}},heading(n){return{tag:`h${n.attrs.level}`}},image(n){return{singleTag:[{tag:"img",attrs:L(n.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(n){const e=d({},n.attrs),{linktype:t="url"}=n.attrs;return B(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled(n){return{tag:[{tag:"span",attrs:n.attrs}]}}}};const z=function(n){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=RegExp(t.source);return n&&r.test(n)?n.replace(t,s=>e[s]):n};class O{constructor(e){e||(e=$),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(z(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let o=`<${s.tag}`;if(s.attrs)for(let a in s.attrs){let i=s.attrs[a];i!==null&&(o+=` ${a}="${i}"`)}return`${o}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}/*!
1
+ (function(u,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],p):(u=typeof globalThis<"u"?globalThis:u||self,p(u.storyblokAstro={},u.axios))})(this,function(u,p){"use strict";const M=(s=>s&&typeof s=="object"&&"default"in s?s:{default:s})(p),U=/[\p{Lu}]/u,D=/[\p{Ll}]/u,T=/^[\p{Lu}](?![\p{Lu}])/gu,_=/([\p{Alpha}\p{N}_]|$)/u,m=/[_.\- ]+/,q=new RegExp("^"+m.source),R=new RegExp(m.source+_.source,"gu"),w=new RegExp("\\d+"+_.source,"gu"),B=(s,e,t)=>{let r=!1,o=!1,n=!1;for(let i=0;i<s.length;i++){const a=s[i];r&&U.test(a)?(s=s.slice(0,i)+"-"+s.slice(i),r=!1,n=o,o=!0,i++):o&&n&&D.test(a)?(s=s.slice(0,i-1)+"-"+s.slice(i-1),n=o,o=!1,r=!0):(r=e(a)===a&&t(a)!==a,n=o,o=t(a)===a&&e(a)!==a)}return s},z=(s,e)=>(T.lastIndex=0,s.replace(T,t=>e(t))),H=(s,e)=>(R.lastIndex=0,w.lastIndex=0,s.replace(R,(t,r)=>e(r)).replace(w,t=>e(t)));function E(s,e){if(!(typeof s=="string"||Array.isArray(s)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(s)?s=s.map(n=>n.trim()).filter(n=>n.length).join("-"):s=s.trim(),s.length===0)return"";const t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),r=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return s.length===1?m.test(s)?"":e.pascalCase?r(s):t(s):(s!==t(s)&&(s=B(s,t,r)),s=s.replace(q,""),s=e.preserveConsecutiveUppercase?z(s,t):t(s),e.pascalCase&&(s=r(s.charAt(0))+s.slice(1)),H(s,r))}function V(s){const e="virtual:storyblok-components",t="\0"+e;return{name:"vite-plugin-storyblok",async resolveId(r){if(r===e)return t},async load(r){if(r===t){const o=[];for await(const[n,i]of Object.entries(s)){const{id:a}=await this.resolve("/src/"+i+".astro");o.push(`import ${E(n)} from "${a}"`)}return`${o.join(";")};export default {${Object.keys(s).map(n=>E(n)).join(",")}}`}}}}var F=Object.defineProperty,J=Object.defineProperties,G=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,$=(s,e,t)=>e in s?F(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,d=(s,e)=>{for(var t in e||(e={}))K.call(e,t)&&$(s,t,e[t]);if(A)for(var t of A(e))Y.call(e,t)&&$(s,t,e[t]);return s},k=(s,e)=>J(s,G(e));let S=!1;const O=[],x=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}S?o():O.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=s,r.id="storyblok-javascript-bridge",r.onerror=o=>t(o),r.onload=o=>{O.forEach(n=>n()),S=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)}),W=function(s,e){if(!s)return null;let t={};for(let r in s){let o=s[r];e.indexOf(r)>-1&&o!==null&&(t[r]=o)}return t},Q=s=>s==="email";var C={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(s){return{tag:["pre",{tag:"code",attrs:s.attrs}]}},hard_break(){return{singleTag:"br"}},heading(s){return{tag:`h${s.attrs.level}`}},image(s){return{singleTag:[{tag:"img",attrs:W(s.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(s){const e=d({},s.attrs),{linktype:t="url"}=s.attrs;return Q(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled(s){return{tag:[{tag:"span",attrs:s.attrs}]}}}};const X=function(s){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=RegExp(t.source);return s&&r.test(s)?s.replace(t,o=>e[o]):s};class I{constructor(e){e||(e=C),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(o=>{const n=this.getMatchingMark(o);n&&t.push(this.renderOpeningTag(n.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{t.push(this.renderNode(o))}):e.text?t.push(X(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const n=this.getMatchingMark(o);n&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(o=>{if(o.constructor===String)return`<${o}${t}>`;{let n=`<${o.tag}`;if(o.attrs)for(let i in o.attrs){let a=o.attrs[i];a!==null&&(n+=` ${i}="${a}"`)}return`${n}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}/*!
2
2
  * storyblok-js-client v4.5.2
3
3
  * Universal JavaScript SDK for Storyblok's API
4
4
  * (c) 2020-2022 Stobylok Team
5
- */function E(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function S(n,e,t){if(!E(e))throw new TypeError("Expected `limit` to be a finite number");if(!E(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],s=[],o=0,a=function(){o++;var c=setTimeout(function(){o--,r.length>0&&a(),s=s.filter(function(u){return u!==c})},t);s.indexOf(c)<0&&s.push(c);var l=r.shift();l.resolve(n.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,f){r.push({resolve:u,reject:f,args:c,self:l}),o<e&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}S.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const D=function(n,e){if(!n)return null;let t={};for(let r in n){let s=n[r];e.indexOf(r)>-1&&s!==null&&(t[r]=s)}return t};var U={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:n=>({tag:`h${n.attrs.level}`}),image:n=>({singleTag:[{tag:"img",attrs:D(n.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(n){const e=d({},n.attrs),{linktype:t="url"}=n.attrs;return t==="email"&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class H{constructor(e){e||(e=U),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,c=>o[c]):s}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs)for(let o in r.attrs){let a=r.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${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){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const V=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return((s=0,o)=>[...Array(s)].map(o))(t,(s,o)=>o*r+n)},m=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s],a=t?"":encodeURIComponent(s);let i;i=typeof o=="object"?m(o,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),r.push(i)}return r.join("&")};let y={},p={};class J{constructor(e,t){if(!t){let o=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let r=Object.assign({},e.headers),s=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,s=3),e.rateLimit!==void 0&&(s=e.rateLimit),this.richTextResolver=new H(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=S(this.throttledRequest,s,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=A.default.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(o=>e.responseInterceptor(o)),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=p[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,s){const o=this.factoryParamOptions(e,((a={},i=25,c=1)=>k(d({},a),{per_page:i,page:c}))(t,r,s));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const s=this.factoryParamOptions(r,t);return this.cacheResponse(r,s)}async getAll(e,t={},r){const s=t.per_page||25,o=`/${e}`,a=o.split("/");r=r||a[a.length-1];const i=await this.makeRequest(o,t,s,1),c=Math.ceil(i.total/s);return((l=[],u)=>l.map(u).reduce((f,te)=>[...f,...te],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(V(1,c),async l=>this.makeRequest(o,t,s,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let s=[];e[t].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),e[t]=s}}}_insertAssetsRelations(e,t){t.forEach(r=>{e.id===r.id&&(e.original=r,e.original.filename=e.filename,e.original.filename=e.original.filename.includes("https://s3.amazonaws.com/")?e.original.filename:e.original.filename.replace("https://","https://s3.amazonaws.com/"),delete e.original.s3_filename)})}iterateTree(e,t){let r=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)r(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,t),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,t),r(s[o])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const s=e.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.link_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(s=>{this.links[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const s=e.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const c=Math.min(s,i+a);o.push(e.rel_uuids.slice(i,c))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:o[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(s=>{this.relations[s.uuid]=k(d({},s),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];if(t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(e.rels||e.rel_uuids)&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&(e.links||e.link_uuids)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(s=>{this.iterateTree(s,r)})}resolveAssetsRelations(e){const{assets:t,stories:r,story:s}=e;if(r)for(const o of r)this.iterateTree(o,t);else{if(!s)return e;this.iterateTree(s,t)}}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(s,o)=>{let a=m({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(a);if(l)return s(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:f=>m(f)}),u={data:l.data,headers:l.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return o(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(t.version=="draft"&&p[t.token]!=u.data.cv&&this.flushCache(),p[t.token]=u.data.cv),s(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,t,r).then(s).catch(o);o(l)}var c})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(e){this.accessToken&&(p[this.accessToken]=e)}cacheProvider(){return this.cache.type==="memory"?{get:e=>y[e],getAll:()=>y,set(e,t){y[e]=t},flush(){y={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const F=(n={})=>{const{apiOptions:e}=n;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 J(e)}};var K=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let b;const j="https://app.storyblok.com/f/storyblok-v2-latest.js",Y=(n={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:s={},richText:o={}}=n;s.accessToken=s.accessToken||t;const a={bridge:e,apiOptions:s};let i={};return r.forEach(c=>{i=d(d({},i),c(a))}),e!==!1&&R(j),b=new O(o.schema),o.resolver&&x(b,o.resolver),i},x=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},G=(n,e,t)=>{let r=t||b;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return n===""?"":n?(e&&(r=new O(e.schema),e.resolver&&x(r,e.resolver)),r.render(n)):(console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
5
+ */function j(s){return typeof s=="number"&&s==s&&s!==1/0&&s!==-1/0}function P(s,e,t){if(!j(e))throw new TypeError("Expected `limit` to be a finite number");if(!j(t))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],n=0,i=function(){n++;var c=setTimeout(function(){n--,r.length>0&&i(),o=o.filter(function(h){return h!==c})},t);o.indexOf(c)<0&&o.push(c);var l=r.shift();l.resolve(s.apply(l.self,l.args))},a=function(){var c=arguments,l=this;return new Promise(function(h,g){r.push({resolve:h,reject:g,args:c,self:l}),n<e&&i()})};return a.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},a}P.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const Z=function(s,e){if(!s)return null;let t={};for(let r in s){let o=s[r];e.indexOf(r)>-1&&o!==null&&(t[r]=o)}return t};var ee={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:s=>({tag:["pre",{tag:"code",attrs:s.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:s=>({tag:`h${s.attrs.level}`}),image:s=>({singleTag:[{tag:"img",attrs:Z(s.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(s){const e=d({},s.attrs),{linktype:t="url"}=s.attrs;return t==="email"&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:s=>({tag:[{tag:"span",attrs:s.attrs}]})}};class te{constructor(e){e||(e=ee),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach(o=>{const n=this.getMatchingMark(o);n&&t.push(this.renderOpeningTag(n.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{t.push(this.renderNode(o))}):e.text?t.push(function(o){const n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i=/[&<>"']/g,a=RegExp(i.source);return o&&a.test(o)?o.replace(i,c=>n[c]):o}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const n=this.getMatchingMark(o);n&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let o=`<${r.tag}`;if(r.attrs)for(let n in r.attrs){let i=r.attrs[n];i!==null&&(o+=` ${n}="${i}"`)}return`${o}${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){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const re=(s=0,e=s)=>{const t=Math.abs(e-s)||0,r=s<e?1:-1;return((o=0,n)=>[...Array(o)].map(n))(t,(o,n)=>n*r+s)},b=(s,e,t)=>{const r=[];for(const o in s){if(!Object.prototype.hasOwnProperty.call(s,o))continue;const n=s[o],i=t?"":encodeURIComponent(o);let a;a=typeof n=="object"?b(n,e?e+encodeURIComponent("["+i+"]"):i,Array.isArray(n)):(e?e+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")};let y={},f={};class se{constructor(e,t){if(!t){let n=e.region?`-${e.region}`:"",i=e.https===!1?"http":"https";t=e.oauthToken===void 0?`${i}://api${n}.storyblok.com/v2`:`${i}://api${n}.storyblok.com/v1`}let r=Object.assign({},e.headers),o=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,o=3),e.rateLimit!==void 0&&(o=e.rateLimit),this.richTextResolver=new te(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=P(this.throttledRequest,o,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=M.default.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(n=>e.responseInterceptor(n)),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=f[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,o){const n=this.factoryParamOptions(e,((i={},a=25,c=1)=>k(d({},i),{per_page:a,page:c}))(t,r,o));return this.cacheResponse(e,n)}get(e,t){let r=`/${e}`;const o=this.factoryParamOptions(r,t);return this.cacheResponse(r,o)}async getAll(e,t={},r){const o=t.per_page||25,n=`/${e}`,i=n.split("/");r=r||i[i.length-1];const a=await this.makeRequest(n,t,o,1),c=Math.ceil(a.total/o);return((l=[],h)=>l.map(h).reduce((g,fe)=>[...g,...fe],[]))([a,...await(async(l=[],h)=>Promise.all(l.map(h)))(re(1,c),async l=>this.makeRequest(n,t,o,l+1))],l=>Object.values(l.data[r]))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let o=[];e[t].forEach(n=>{this.relations[n]&&o.push(this._cleanCopy(this.relations[n]))}),e[t]=o}}}_insertAssetsRelations(e,t){t.forEach(r=>{e.id===r.id&&(e.original=r,e.original.filename=e.filename,e.original.filename=e.original.filename.includes("https://s3.amazonaws.com/")?e.original.filename:e.original.filename.replace("https://","https://s3.amazonaws.com/"),delete e.original.s3_filename)})}iterateTree(e,t){let r=o=>{if(o!=null){if(o.constructor===Array)for(let n=0;n<o.length;n++)r(o[n]);else if(o.constructor===Object){if(o._stopResolving)return;for(let n in o)o.component&&o._uid||o.type==="link"?(this._insertRelations(o,n,t),this._insertLinks(o,n)):"id"in o&&o.fieldtype==="asset"&&this._insertAssetsRelations(o,t),r(o[n])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const o=e.link_uuids.length;let n=[];const i=50;for(let a=0;a<o;a+=i){const c=Math.min(o,a+i);n.push(e.link_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:i,language:t.language,version:t.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(o=>{this.links[o.uuid]=k(d({},o),{_stopResolving:!0})})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length;let n=[];const i=50;for(let a=0;a<o;a+=i){const c=Math.min(o,a+i);n.push(e.rel_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:i,language:t.language,version:t.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(o=>{this.relations[o.uuid]=k(d({},o),{_stopResolving:!0})})}async resolveStories(e,t){let r=[];if(t.resolve_relations!==void 0&&t.resolve_relations.length>0&&(e.rels||e.rel_uuids)&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&(e.links||e.link_uuids)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const o in this.relations)this.iterateTree(this.relations[o],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(o=>{this.iterateTree(o,r)})}resolveAssetsRelations(e){const{assets:t,stories:r,story:o}=e;if(r)for(const n of r)this.iterateTree(n,t);else{if(!o)return e;this.iterateTree(o,t)}}cacheResponse(e,t,r){return r===void 0&&(r=0),new Promise(async(o,n)=>{let i=b({url:e,params:t}),a=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=await a.get(i);if(l)return o(l)}try{let l=await this.throttle("get",e,{params:t,paramsSerializer:g=>b(g)}),h={data:l.data,headers:l.headers};if(h.data.assets&&h.data.assets.length&&this.resolveAssetsRelations(h.data),l.headers["per-page"]&&(h=Object.assign({},h,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return n(l);(h.data.story||h.data.stories)&&await this.resolveStories(h.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&a.set(i,h),h.data.cv&&(t.version=="draft"&&f[t.token]!=h.data.cv&&this.flushCache(),f[t.token]=h.data.cv),o(h)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(h=>setTimeout(h,c))),this.cacheResponse(e,t,r).then(o).catch(n);n(l)}var c})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return f}cacheVersion(){return f[this.accessToken]}setCacheVersion(e){this.accessToken&&(f[this.accessToken]=e)}cacheProvider(){return this.cache.type==="memory"?{get:e=>y[e],getAll:()=>y,set(e,t){y[e]=t},flush(){y={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const oe=(s={})=>{const{apiOptions:e}=s;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 se(e)}};var ne=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let v;const N="https://app.storyblok.com/f/storyblok-v2-latest.js",ae=(s={})=>{const{bridge:e,accessToken:t,use:r=[],apiOptions:o={},richText:n={}}=s;o.accessToken=o.accessToken||t;const i={bridge:e,apiOptions:o};let a={};return r.forEach(c=>{a=d(d({},a),c(i))}),e!==!1&&x(N),v=new I(n.schema),n.resolver&&L(v,n.resolver),a},L=(s,e)=>{s.addNode("blok",t=>{let r="";return t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})},ie=(s,e,t)=>{let r=t||v;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return s===""?"":s?(e&&(r=new I(e.schema),e.resolver&&L(r,e.resolver)),r.render(s)):(console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
6
6
 
7
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},Q=()=>R(j);function W(n,e,t){const{storyblokApi:r}=Y({accessToken:n,use:e||[F],apiOptions:{...t}});globalThis.storyblokApiInstance=r}function X(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function Z(n,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return G(n,e,t)}function ee(n){return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:e,updateConfig:t})=>{var s;t({vite:{plugins:[P(n.components)]}}),W(n.accessToken,n.use,n.apiOptions),((s=n.bridge)!=null?s:!0)&&e("page",`
7
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},le=()=>x(N);function ce(s,e,t){const{storyblokApi:r}=ae({accessToken:s,use:e||[oe],apiOptions:{...t}});globalThis.storyblokApiInstance=r}function he(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function ue(s,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ie(s,e,t)}function de(s){return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:e,updateConfig:t})=>{var o;t({vite:{plugins:[V(s.components)]}}),ce(s.accessToken,s.use,s.apiOptions),((o=s.bridge)!=null?o:!0)&&e("page",`
8
8
  import { loadStoryblokBridge } from "@storyblok/astro";
9
9
  loadStoryblokBridge().then(() => {
10
10
  const { StoryblokBridge, location } = window;
@@ -16,4 +16,4 @@
16
16
  }
17
17
  });
18
18
  });
19
- `)}}}}h.RichTextSchema=$,h.default=ee,h.loadStoryblokBridge=Q,h.renderRichText=Z,h.storyblokEditable=K,h.useStoryblokApi=X,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
19
+ `)}}}}u.RichTextSchema=C,u.default=de,u.loadStoryblokBridge=le,u.renderRichText=ue,u.storyblokEditable=ne,u.useStoryblokApi=he,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,57 +1,77 @@
1
- import S from "axios";
2
- function j(n) {
3
- const t = "virtual:storyblok-components", e = "\0" + t;
1
+ import N from "axios";
2
+ const L = /[\p{Lu}]/u, M = /[\p{Ll}]/u, v = /^[\p{Lu}](?![\p{Lu}])/gu, O = /([\p{Alpha}\p{N}_]|$)/u, k = /[_.\- ]+/, U = new RegExp("^" + k.source), b = new RegExp(k.source + O.source, "gu"), T = new RegExp("\\d+" + O.source, "gu"), D = (s, e, t) => {
3
+ let r = !1, o = !1, n = !1;
4
+ for (let i = 0; i < s.length; i++) {
5
+ const a = s[i];
6
+ r && L.test(a) ? (s = s.slice(0, i) + "-" + s.slice(i), r = !1, n = o, o = !0, i++) : o && n && M.test(a) ? (s = s.slice(0, i - 1) + "-" + s.slice(i - 1), n = o, o = !1, r = !0) : (r = e(a) === a && t(a) !== a, n = o, o = t(a) === a && e(a) !== a);
7
+ }
8
+ return s;
9
+ }, q = (s, e) => (v.lastIndex = 0, s.replace(v, (t) => e(t))), B = (s, e) => (b.lastIndex = 0, T.lastIndex = 0, s.replace(b, (t, r) => e(r)).replace(T, (t) => e(t)));
10
+ function _(s, e) {
11
+ if (!(typeof s == "string" || Array.isArray(s)))
12
+ throw new TypeError("Expected the input to be `string | string[]`");
13
+ if (e = {
14
+ pascalCase: !1,
15
+ preserveConsecutiveUppercase: !1,
16
+ ...e
17
+ }, Array.isArray(s) ? s = s.map((n) => n.trim()).filter((n) => n.length).join("-") : s = s.trim(), s.length === 0)
18
+ return "";
19
+ const t = e.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(e.locale), r = e.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(e.locale);
20
+ return s.length === 1 ? k.test(s) ? "" : e.pascalCase ? r(s) : t(s) : (s !== t(s) && (s = D(s, t, r)), s = s.replace(U, ""), s = e.preserveConsecutiveUppercase ? q(s, t) : t(s), e.pascalCase && (s = r(s.charAt(0)) + s.slice(1)), B(s, r));
21
+ }
22
+ function z(s) {
23
+ const e = "virtual:storyblok-components", t = "\0" + e;
4
24
  return {
5
25
  name: "vite-plugin-storyblok",
6
26
  async resolveId(r) {
7
- if (r === t)
8
- return e;
27
+ if (r === e)
28
+ return t;
9
29
  },
10
30
  async load(r) {
11
- if (r === e) {
12
- const s = [];
13
- for await (const [o, a] of Object.entries(n)) {
14
- const { id: i } = await this.resolve("/src/" + a + ".astro");
15
- s.push(`import ${o} from "${i}"`);
31
+ if (r === t) {
32
+ const o = [];
33
+ for await (const [n, i] of Object.entries(s)) {
34
+ const { id: a } = await this.resolve("/src/" + i + ".astro");
35
+ o.push(`import ${_(n)} from "${a}"`);
16
36
  }
17
- return `${s.join(";")};export default {${Object.keys(n).join(",")}}`;
37
+ return `${o.join(";")};export default {${Object.keys(s).map((n) => _(n)).join(",")}}`;
18
38
  }
19
39
  }
20
40
  };
21
41
  }
22
- var A = Object.defineProperty, P = Object.defineProperties, M = Object.getOwnPropertyDescriptors, k = Object.getOwnPropertySymbols, I = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? A(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, u = (n, t) => {
23
- for (var e in t || (t = {}))
24
- I.call(t, e) && b(n, e, t[e]);
25
- if (k)
26
- for (var e of k(t))
27
- C.call(t, e) && b(n, e, t[e]);
28
- return n;
29
- }, f = (n, t) => P(n, M(t));
30
- let v = !1;
31
- const T = [], w = (n) => new Promise((t, e) => {
32
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
42
+ var H = Object.defineProperty, V = Object.defineProperties, F = Object.getOwnPropertyDescriptors, R = Object.getOwnPropertySymbols, J = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable, w = (s, e, t) => e in s ? H(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, u = (s, e) => {
43
+ for (var t in e || (e = {}))
44
+ J.call(e, t) && w(s, t, e[t]);
45
+ if (R)
46
+ for (var t of R(e))
47
+ G.call(e, t) && w(s, t, e[t]);
48
+ return s;
49
+ }, g = (s, e) => V(s, F(e));
50
+ let E = !1;
51
+ const A = [], S = (s) => new Promise((e, t) => {
52
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
33
53
  if (window.location === window.parent.location) {
34
54
  console.warn("You are not in Draft Mode or in the Visual Editor.");
35
55
  return;
36
56
  }
37
- v ? s() : T.push(s);
57
+ E ? o() : A.push(o);
38
58
  }, document.getElementById("storyblok-javascript-bridge")))
39
59
  return;
40
60
  const r = document.createElement("script");
41
- r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
42
- T.forEach((o) => o()), v = !0, t(s);
61
+ r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (o) => t(o), r.onload = (o) => {
62
+ A.forEach((n) => n()), E = !0, e(o);
43
63
  }, document.getElementsByTagName("head")[0].appendChild(r);
44
- }), N = function(n, t) {
45
- if (!n)
64
+ }), K = function(s, e) {
65
+ if (!s)
46
66
  return null;
47
- let e = {};
48
- for (let r in n) {
49
- let s = n[r];
50
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
51
- }
52
- return e;
53
- }, q = (n) => n === "email";
54
- var z = {
67
+ let t = {};
68
+ for (let r in s) {
69
+ let o = s[r];
70
+ e.indexOf(r) > -1 && o !== null && (t[r] = o);
71
+ }
72
+ return t;
73
+ }, Y = (s) => s === "email";
74
+ var W = {
55
75
  nodes: {
56
76
  horizontal_rule() {
57
77
  return {
@@ -68,13 +88,13 @@ var z = {
68
88
  tag: "ul"
69
89
  };
70
90
  },
71
- code_block(n) {
91
+ code_block(s) {
72
92
  return {
73
93
  tag: [
74
94
  "pre",
75
95
  {
76
96
  tag: "code",
77
- attrs: n.attrs
97
+ attrs: s.attrs
78
98
  }
79
99
  ]
80
100
  };
@@ -84,17 +104,17 @@ var z = {
84
104
  singleTag: "br"
85
105
  };
86
106
  },
87
- heading(n) {
107
+ heading(s) {
88
108
  return {
89
- tag: `h${n.attrs.level}`
109
+ tag: `h${s.attrs.level}`
90
110
  };
91
111
  },
92
- image(n) {
112
+ image(s) {
93
113
  return {
94
114
  singleTag: [
95
115
  {
96
116
  tag: "img",
97
- attrs: N(n.attrs, ["src", "alt", "title"])
117
+ attrs: K(s.attrs, ["src", "alt", "title"])
98
118
  }
99
119
  ]
100
120
  };
@@ -146,100 +166,100 @@ var z = {
146
166
  tag: "i"
147
167
  };
148
168
  },
149
- link(n) {
150
- const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
151
- return q(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
169
+ link(s) {
170
+ const e = u({}, s.attrs), { linktype: t = "url" } = s.attrs;
171
+ return Y(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
152
172
  tag: [
153
173
  {
154
174
  tag: "a",
155
- attrs: t
175
+ attrs: e
156
176
  }
157
177
  ]
158
178
  };
159
179
  },
160
- styled(n) {
180
+ styled(s) {
161
181
  return {
162
182
  tag: [
163
183
  {
164
184
  tag: "span",
165
- attrs: n.attrs
185
+ attrs: s.attrs
166
186
  }
167
187
  ]
168
188
  };
169
189
  }
170
190
  }
171
191
  };
172
- const B = function(n) {
173
- const t = {
192
+ const Q = function(s) {
193
+ const e = {
174
194
  "&": "&amp;",
175
195
  "<": "&lt;",
176
196
  ">": "&gt;",
177
197
  '"': "&quot;",
178
198
  "'": "&#39;"
179
- }, e = /[&<>"']/g, r = RegExp(e.source);
180
- return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
199
+ }, t = /[&<>"']/g, r = RegExp(t.source);
200
+ return s && r.test(s) ? s.replace(t, (o) => e[o]) : s;
181
201
  };
182
- class R {
183
- constructor(t) {
184
- t || (t = z), this.marks = t.marks || [], this.nodes = t.nodes || [];
185
- }
186
- addNode(t, e) {
187
- this.nodes[t] = e;
188
- }
189
- addMark(t, e) {
190
- this.marks[t] = e;
191
- }
192
- render(t = {}) {
193
- if (t.content && Array.isArray(t.content)) {
194
- let e = "";
195
- return t.content.forEach((r) => {
196
- e += this.renderNode(r);
197
- }), e;
202
+ class x {
203
+ constructor(e) {
204
+ e || (e = W), this.marks = e.marks || [], this.nodes = e.nodes || [];
205
+ }
206
+ addNode(e, t) {
207
+ this.nodes[e] = t;
208
+ }
209
+ addMark(e, t) {
210
+ this.marks[e] = t;
211
+ }
212
+ render(e = {}) {
213
+ if (e.content && Array.isArray(e.content)) {
214
+ let t = "";
215
+ return e.content.forEach((r) => {
216
+ t += this.renderNode(r);
217
+ }), t;
198
218
  }
199
219
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
200
220
  }
201
- renderNode(t) {
202
- let e = [];
203
- t.marks && t.marks.forEach((s) => {
204
- const o = this.getMatchingMark(s);
205
- o && e.push(this.renderOpeningTag(o.tag));
221
+ renderNode(e) {
222
+ let t = [];
223
+ e.marks && e.marks.forEach((o) => {
224
+ const n = this.getMatchingMark(o);
225
+ n && t.push(this.renderOpeningTag(n.tag));
206
226
  });
207
- const r = this.getMatchingNode(t);
208
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
209
- e.push(this.renderNode(s));
210
- }) : t.text ? e.push(B(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
211
- const o = this.getMatchingMark(s);
212
- o && e.push(this.renderClosingTag(o.tag));
213
- }), e.join("");
214
- }
215
- renderTag(t, e) {
216
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
217
- if (s.constructor === String)
218
- return `<${s}${e}>`;
227
+ const r = this.getMatchingNode(e);
228
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
229
+ t.push(this.renderNode(o));
230
+ }) : e.text ? t.push(Q(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
231
+ const n = this.getMatchingMark(o);
232
+ n && t.push(this.renderClosingTag(n.tag));
233
+ }), t.join("");
234
+ }
235
+ renderTag(e, t) {
236
+ return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
237
+ if (o.constructor === String)
238
+ return `<${o}${t}>`;
219
239
  {
220
- let o = `<${s.tag}`;
221
- if (s.attrs)
222
- for (let a in s.attrs) {
223
- let i = s.attrs[a];
224
- i !== null && (o += ` ${a}="${i}"`);
240
+ let n = `<${o.tag}`;
241
+ if (o.attrs)
242
+ for (let i in o.attrs) {
243
+ let a = o.attrs[i];
244
+ a !== null && (n += ` ${i}="${a}"`);
225
245
  }
226
- return `${o}${e}>`;
246
+ return `${n}${t}>`;
227
247
  }
228
248
  }).join("");
229
249
  }
230
- renderOpeningTag(t) {
231
- return this.renderTag(t, "");
250
+ renderOpeningTag(e) {
251
+ return this.renderTag(e, "");
232
252
  }
233
- renderClosingTag(t) {
234
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
253
+ renderClosingTag(e) {
254
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
235
255
  }
236
- getMatchingNode(t) {
237
- if (typeof this.nodes[t.type] == "function")
238
- return this.nodes[t.type](t);
256
+ getMatchingNode(e) {
257
+ if (typeof this.nodes[e.type] == "function")
258
+ return this.nodes[e.type](e);
239
259
  }
240
- getMatchingMark(t) {
241
- if (typeof this.marks[t.type] == "function")
242
- return this.marks[t.type](t);
260
+ getMatchingMark(e) {
261
+ if (typeof this.marks[e.type] == "function")
262
+ return this.marks[e.type](e);
243
263
  }
244
264
  }
245
265
  /*!
@@ -247,319 +267,319 @@ class R {
247
267
  * Universal JavaScript SDK for Storyblok's API
248
268
  * (c) 2020-2022 Stobylok Team
249
269
  */
250
- function _(n) {
251
- return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
270
+ function $(s) {
271
+ return typeof s == "number" && s == s && s !== 1 / 0 && s !== -1 / 0;
252
272
  }
253
- function $(n, t, e) {
254
- if (!_(t))
273
+ function C(s, e, t) {
274
+ if (!$(e))
255
275
  throw new TypeError("Expected `limit` to be a finite number");
256
- if (!_(e))
276
+ if (!$(t))
257
277
  throw new TypeError("Expected `interval` to be a finite number");
258
- var r = [], s = [], o = 0, a = function() {
259
- o++;
278
+ var r = [], o = [], n = 0, i = function() {
279
+ n++;
260
280
  var c = setTimeout(function() {
261
- o--, r.length > 0 && a(), s = s.filter(function(h) {
281
+ n--, r.length > 0 && i(), o = o.filter(function(h) {
262
282
  return h !== c;
263
283
  });
264
- }, e);
265
- s.indexOf(c) < 0 && s.push(c);
284
+ }, t);
285
+ o.indexOf(c) < 0 && o.push(c);
266
286
  var l = r.shift();
267
- l.resolve(n.apply(l.self, l.args));
268
- }, i = function() {
287
+ l.resolve(s.apply(l.self, l.args));
288
+ }, a = function() {
269
289
  var c = arguments, l = this;
270
290
  return new Promise(function(h, p) {
271
- r.push({ resolve: h, reject: p, args: c, self: l }), o < t && a();
291
+ r.push({ resolve: h, reject: p, args: c, self: l }), n < e && i();
272
292
  });
273
293
  };
274
- return i.abort = function() {
275
- s.forEach(clearTimeout), s = [], r.forEach(function(c) {
294
+ return a.abort = function() {
295
+ o.forEach(clearTimeout), o = [], r.forEach(function(c) {
276
296
  c.reject(new throttle.AbortError());
277
297
  }), r.length = 0;
278
- }, i;
298
+ }, a;
279
299
  }
280
- $.AbortError = function() {
300
+ C.AbortError = function() {
281
301
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
282
302
  };
283
- const L = function(n, t) {
284
- if (!n)
303
+ const X = function(s, e) {
304
+ if (!s)
285
305
  return null;
286
- let e = {};
287
- for (let r in n) {
288
- let s = n[r];
289
- t.indexOf(r) > -1 && s !== null && (e[r] = s);
306
+ let t = {};
307
+ for (let r in s) {
308
+ let o = s[r];
309
+ e.indexOf(r) > -1 && o !== null && (t[r] = o);
290
310
  }
291
- return e;
311
+ return t;
292
312
  };
293
- var U = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: L(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
294
- const t = u({}, n.attrs), { linktype: e = "url" } = n.attrs;
295
- return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
296
- }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
297
- class H {
298
- constructor(t) {
299
- t || (t = U), this.marks = t.marks || [], this.nodes = t.nodes || [];
300
- }
301
- addNode(t, e) {
302
- this.nodes[t] = e;
303
- }
304
- addMark(t, e) {
305
- this.marks[t] = e;
306
- }
307
- render(t = {}) {
308
- if (t.content && Array.isArray(t.content)) {
309
- let e = "";
310
- return t.content.forEach((r) => {
311
- e += this.renderNode(r);
312
- }), e;
313
+ var Z = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (s) => ({ tag: ["pre", { tag: "code", attrs: s.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (s) => ({ tag: `h${s.attrs.level}` }), image: (s) => ({ singleTag: [{ tag: "img", attrs: X(s.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(s) {
314
+ const e = u({}, s.attrs), { linktype: t = "url" } = s.attrs;
315
+ return t === "email" && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), { tag: [{ tag: "a", attrs: e }] };
316
+ }, styled: (s) => ({ tag: [{ tag: "span", attrs: s.attrs }] }) } };
317
+ class ee {
318
+ constructor(e) {
319
+ e || (e = Z), this.marks = e.marks || [], this.nodes = e.nodes || [];
320
+ }
321
+ addNode(e, t) {
322
+ this.nodes[e] = t;
323
+ }
324
+ addMark(e, t) {
325
+ this.marks[e] = t;
326
+ }
327
+ render(e = {}) {
328
+ if (e.content && Array.isArray(e.content)) {
329
+ let t = "";
330
+ return e.content.forEach((r) => {
331
+ t += this.renderNode(r);
332
+ }), t;
313
333
  }
314
334
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
315
335
  }
316
- renderNode(t) {
317
- let e = [];
318
- t.marks && t.marks.forEach((s) => {
319
- const o = this.getMatchingMark(s);
320
- o && e.push(this.renderOpeningTag(o.tag));
336
+ renderNode(e) {
337
+ let t = [];
338
+ e.marks && e.marks.forEach((o) => {
339
+ const n = this.getMatchingMark(o);
340
+ n && t.push(this.renderOpeningTag(n.tag));
321
341
  });
322
- const r = this.getMatchingNode(t);
323
- return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
324
- e.push(this.renderNode(s));
325
- }) : t.text ? e.push(function(s) {
326
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
327
- return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
328
- }(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
329
- const o = this.getMatchingMark(s);
330
- o && e.push(this.renderClosingTag(o.tag));
331
- }), e.join("");
332
- }
333
- renderTag(t, e) {
334
- return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
342
+ const r = this.getMatchingNode(e);
343
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((o) => {
344
+ t.push(this.renderNode(o));
345
+ }) : e.text ? t.push(function(o) {
346
+ const n = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, i = /[&<>"']/g, a = RegExp(i.source);
347
+ return o && a.test(o) ? o.replace(i, (c) => n[c]) : o;
348
+ }(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
349
+ const n = this.getMatchingMark(o);
350
+ n && t.push(this.renderClosingTag(n.tag));
351
+ }), t.join("");
352
+ }
353
+ renderTag(e, t) {
354
+ return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
335
355
  if (r.constructor === String)
336
- return `<${r}${e}>`;
356
+ return `<${r}${t}>`;
337
357
  {
338
- let s = `<${r.tag}`;
358
+ let o = `<${r.tag}`;
339
359
  if (r.attrs)
340
- for (let o in r.attrs) {
341
- let a = r.attrs[o];
342
- a !== null && (s += ` ${o}="${a}"`);
360
+ for (let n in r.attrs) {
361
+ let i = r.attrs[n];
362
+ i !== null && (o += ` ${n}="${i}"`);
343
363
  }
344
- return `${s}${e}>`;
364
+ return `${o}${t}>`;
345
365
  }
346
366
  }).join("");
347
367
  }
348
- renderOpeningTag(t) {
349
- return this.renderTag(t, "");
368
+ renderOpeningTag(e) {
369
+ return this.renderTag(e, "");
350
370
  }
351
- renderClosingTag(t) {
352
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
371
+ renderClosingTag(e) {
372
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
353
373
  }
354
- getMatchingNode(t) {
355
- if (typeof this.nodes[t.type] == "function")
356
- return this.nodes[t.type](t);
374
+ getMatchingNode(e) {
375
+ if (typeof this.nodes[e.type] == "function")
376
+ return this.nodes[e.type](e);
357
377
  }
358
- getMatchingMark(t) {
359
- if (typeof this.marks[t.type] == "function")
360
- return this.marks[t.type](t);
378
+ getMatchingMark(e) {
379
+ if (typeof this.marks[e.type] == "function")
380
+ return this.marks[e.type](e);
361
381
  }
362
382
  }
363
- const V = (n = 0, t = n) => {
364
- const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
365
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
366
- }, y = (n, t, e) => {
383
+ const te = (s = 0, e = s) => {
384
+ const t = Math.abs(e - s) || 0, r = s < e ? 1 : -1;
385
+ return ((o = 0, n) => [...Array(o)].map(n))(t, (o, n) => n * r + s);
386
+ }, y = (s, e, t) => {
367
387
  const r = [];
368
- for (const s in n) {
369
- if (!Object.prototype.hasOwnProperty.call(n, s))
388
+ for (const o in s) {
389
+ if (!Object.prototype.hasOwnProperty.call(s, o))
370
390
  continue;
371
- const o = n[s], a = e ? "" : encodeURIComponent(s);
372
- let i;
373
- i = typeof o == "object" ? y(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
391
+ const n = s[o], i = t ? "" : encodeURIComponent(o);
392
+ let a;
393
+ a = typeof n == "object" ? y(n, e ? e + encodeURIComponent("[" + i + "]") : i, Array.isArray(n)) : (e ? e + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(n), r.push(a);
374
394
  }
375
395
  return r.join("&");
376
396
  };
377
- let g = {}, d = {};
378
- class D {
379
- constructor(t, e) {
380
- if (!e) {
381
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
382
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
397
+ let f = {}, d = {};
398
+ class re {
399
+ constructor(e, t) {
400
+ if (!t) {
401
+ let n = e.region ? `-${e.region}` : "", i = e.https === !1 ? "http" : "https";
402
+ t = e.oauthToken === void 0 ? `${i}://api${n}.storyblok.com/v2` : `${i}://api${n}.storyblok.com/v1`;
383
403
  }
384
- let r = Object.assign({}, t.headers), s = 5;
385
- t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new H(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = S.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
404
+ let r = Object.assign({}, e.headers), o = 5;
405
+ e.oauthToken !== void 0 && (r.Authorization = e.oauthToken, o = 3), e.rateLimit !== void 0 && (o = e.rateLimit), this.richTextResolver = new ee(e.richTextSchema), typeof e.componentResolver == "function" && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = C(this.throttledRequest, o, 1e3), this.accessToken = e.accessToken, this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.client = N.create({ baseURL: t, timeout: e.timeout || 0, headers: r, proxy: e.proxy || !1 }), e.responseInterceptor && this.client.interceptors.response.use((n) => e.responseInterceptor(n)), this.resolveNestedRelations = e.resolveNestedRelations || !0;
386
406
  }
387
- setComponentResolver(t) {
388
- this.richTextResolver.addNode("blok", (e) => {
407
+ setComponentResolver(e) {
408
+ this.richTextResolver.addNode("blok", (t) => {
389
409
  let r = "";
390
- return e.attrs.body.forEach((s) => {
391
- r += t(s.component, s);
410
+ return t.attrs.body.forEach((o) => {
411
+ r += e(o.component, o);
392
412
  }), { html: r };
393
413
  });
394
414
  }
395
- parseParams(t = {}) {
396
- return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
415
+ parseParams(e = {}) {
416
+ return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = d[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
397
417
  }
398
- factoryParamOptions(t, e = {}) {
399
- return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
418
+ factoryParamOptions(e, t = {}) {
419
+ return ((r = "") => r.indexOf("/cdn/") > -1)(e) ? this.parseParams(t) : t;
400
420
  }
401
- makeRequest(t, e, r, s) {
402
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => f(u({}, a), { per_page: i, page: c }))(e, r, s));
403
- return this.cacheResponse(t, o);
421
+ makeRequest(e, t, r, o) {
422
+ const n = this.factoryParamOptions(e, ((i = {}, a = 25, c = 1) => g(u({}, i), { per_page: a, page: c }))(t, r, o));
423
+ return this.cacheResponse(e, n);
404
424
  }
405
- get(t, e) {
406
- let r = `/${t}`;
407
- const s = this.factoryParamOptions(r, e);
408
- return this.cacheResponse(r, s);
425
+ get(e, t) {
426
+ let r = `/${e}`;
427
+ const o = this.factoryParamOptions(r, t);
428
+ return this.cacheResponse(r, o);
409
429
  }
410
- async getAll(t, e = {}, r) {
411
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
412
- r = r || a[a.length - 1];
413
- const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
414
- return ((l = [], h) => l.map(h).reduce((p, x) => [...p, ...x], []))([i, ...await (async (l = [], h) => Promise.all(l.map(h)))(V(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
430
+ async getAll(e, t = {}, r) {
431
+ const o = t.per_page || 25, n = `/${e}`, i = n.split("/");
432
+ r = r || i[i.length - 1];
433
+ const a = await this.makeRequest(n, t, o, 1), c = Math.ceil(a.total / o);
434
+ return ((l = [], h) => l.map(h).reduce((p, j) => [...p, ...j], []))([a, ...await (async (l = [], h) => Promise.all(l.map(h)))(te(1, c), async (l) => this.makeRequest(n, t, o, l + 1))], (l) => Object.values(l.data[r]));
415
435
  }
416
- post(t, e) {
417
- let r = `/${t}`;
418
- return this.throttle("post", r, e);
436
+ post(e, t) {
437
+ let r = `/${e}`;
438
+ return this.throttle("post", r, t);
419
439
  }
420
- put(t, e) {
421
- let r = `/${t}`;
422
- return this.throttle("put", r, e);
440
+ put(e, t) {
441
+ let r = `/${e}`;
442
+ return this.throttle("put", r, t);
423
443
  }
424
- delete(t, e) {
425
- let r = `/${t}`;
426
- return this.throttle("delete", r, e);
444
+ delete(e, t) {
445
+ let r = `/${e}`;
446
+ return this.throttle("delete", r, t);
427
447
  }
428
- getStories(t) {
429
- return this.get("cdn/stories", t);
448
+ getStories(e) {
449
+ return this.get("cdn/stories", e);
430
450
  }
431
- getStory(t, e) {
432
- return this.get(`cdn/stories/${t}`, e);
451
+ getStory(e, t) {
452
+ return this.get(`cdn/stories/${e}`, t);
433
453
  }
434
- setToken(t) {
435
- this.accessToken = t;
454
+ setToken(e) {
455
+ this.accessToken = e;
436
456
  }
437
457
  getToken() {
438
458
  return this.accessToken;
439
459
  }
440
- _cleanCopy(t) {
441
- return JSON.parse(JSON.stringify(t));
460
+ _cleanCopy(e) {
461
+ return JSON.parse(JSON.stringify(e));
442
462
  }
443
- _insertLinks(t, e) {
444
- const r = t[e];
463
+ _insertLinks(e, t) {
464
+ const r = e[t];
445
465
  r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
446
466
  }
447
- _insertRelations(t, e, r) {
448
- if (r.indexOf(t.component + "." + e) > -1) {
449
- if (typeof t[e] == "string")
450
- this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
451
- else if (t[e].constructor === Array) {
452
- let s = [];
453
- t[e].forEach((o) => {
454
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
455
- }), t[e] = s;
467
+ _insertRelations(e, t, r) {
468
+ if (r.indexOf(e.component + "." + t) > -1) {
469
+ if (typeof e[t] == "string")
470
+ this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
471
+ else if (e[t].constructor === Array) {
472
+ let o = [];
473
+ e[t].forEach((n) => {
474
+ this.relations[n] && o.push(this._cleanCopy(this.relations[n]));
475
+ }), e[t] = o;
456
476
  }
457
477
  }
458
478
  }
459
- _insertAssetsRelations(t, e) {
460
- e.forEach((r) => {
461
- t.id === r.id && (t.original = r, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
479
+ _insertAssetsRelations(e, t) {
480
+ t.forEach((r) => {
481
+ e.id === r.id && (e.original = r, e.original.filename = e.filename, e.original.filename = e.original.filename.includes("https://s3.amazonaws.com/") ? e.original.filename : e.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e.original.s3_filename);
462
482
  });
463
483
  }
464
- iterateTree(t, e) {
465
- let r = (s) => {
466
- if (s != null) {
467
- if (s.constructor === Array)
468
- for (let o = 0; o < s.length; o++)
469
- r(s[o]);
470
- else if (s.constructor === Object) {
471
- if (s._stopResolving)
484
+ iterateTree(e, t) {
485
+ let r = (o) => {
486
+ if (o != null) {
487
+ if (o.constructor === Array)
488
+ for (let n = 0; n < o.length; n++)
489
+ r(o[n]);
490
+ else if (o.constructor === Object) {
491
+ if (o._stopResolving)
472
492
  return;
473
- for (let o in s)
474
- s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
493
+ for (let n in o)
494
+ o.component && o._uid || o.type === "link" ? (this._insertRelations(o, n, t), this._insertLinks(o, n)) : "id" in o && o.fieldtype === "asset" && this._insertAssetsRelations(o, t), r(o[n]);
475
495
  }
476
496
  }
477
497
  };
478
- r(t.content);
498
+ r(e.content);
479
499
  }
480
- async resolveLinks(t, e) {
500
+ async resolveLinks(e, t) {
481
501
  let r = [];
482
- if (t.link_uuids) {
483
- const s = t.link_uuids.length;
484
- let o = [];
485
- const a = 50;
486
- for (let i = 0; i < s; i += a) {
487
- const c = Math.min(s, i + a);
488
- o.push(t.link_uuids.slice(i, c));
502
+ if (e.link_uuids) {
503
+ const o = e.link_uuids.length;
504
+ let n = [];
505
+ const i = 50;
506
+ for (let a = 0; a < o; a += i) {
507
+ const c = Math.min(o, a + i);
508
+ n.push(e.link_uuids.slice(a, c));
489
509
  }
490
- for (let i = 0; i < o.length; i++)
491
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
510
+ for (let a = 0; a < n.length; a++)
511
+ (await this.getStories({ per_page: i, language: t.language, version: t.version, by_uuids: n[a].join(",") })).data.stories.forEach((c) => {
492
512
  r.push(c);
493
513
  });
494
514
  } else
495
- r = t.links;
496
- r.forEach((s) => {
497
- this.links[s.uuid] = f(u({}, s), { _stopResolving: !0 });
515
+ r = e.links;
516
+ r.forEach((o) => {
517
+ this.links[o.uuid] = g(u({}, o), { _stopResolving: !0 });
498
518
  });
499
519
  }
500
- async resolveRelations(t, e) {
520
+ async resolveRelations(e, t) {
501
521
  let r = [];
502
- if (t.rel_uuids) {
503
- const s = t.rel_uuids.length;
504
- let o = [];
505
- const a = 50;
506
- for (let i = 0; i < s; i += a) {
507
- const c = Math.min(s, i + a);
508
- o.push(t.rel_uuids.slice(i, c));
522
+ if (e.rel_uuids) {
523
+ const o = e.rel_uuids.length;
524
+ let n = [];
525
+ const i = 50;
526
+ for (let a = 0; a < o; a += i) {
527
+ const c = Math.min(o, a + i);
528
+ n.push(e.rel_uuids.slice(a, c));
509
529
  }
510
- for (let i = 0; i < o.length; i++)
511
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
530
+ for (let a = 0; a < n.length; a++)
531
+ (await this.getStories({ per_page: i, language: t.language, version: t.version, by_uuids: n[a].join(",") })).data.stories.forEach((c) => {
512
532
  r.push(c);
513
533
  });
514
534
  } else
515
- r = t.rels;
516
- r.forEach((s) => {
517
- this.relations[s.uuid] = f(u({}, s), { _stopResolving: !0 });
535
+ r = e.rels;
536
+ r.forEach((o) => {
537
+ this.relations[o.uuid] = g(u({}, o), { _stopResolving: !0 });
518
538
  });
519
539
  }
520
- async resolveStories(t, e) {
540
+ async resolveStories(e, t) {
521
541
  let r = [];
522
- if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
523
- for (const s in this.relations)
524
- this.iterateTree(this.relations[s], r);
525
- t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
526
- this.iterateTree(s, r);
542
+ if (t.resolve_relations !== void 0 && t.resolve_relations.length > 0 && (e.rels || e.rel_uuids) && (r = t.resolve_relations.split(","), await this.resolveRelations(e, t)), ["1", "story", "url"].indexOf(t.resolve_links) > -1 && (e.links || e.link_uuids) && await this.resolveLinks(e, t), this.resolveNestedRelations)
543
+ for (const o in this.relations)
544
+ this.iterateTree(this.relations[o], r);
545
+ e.story ? this.iterateTree(e.story, r) : e.stories.forEach((o) => {
546
+ this.iterateTree(o, r);
527
547
  });
528
548
  }
529
- resolveAssetsRelations(t) {
530
- const { assets: e, stories: r, story: s } = t;
549
+ resolveAssetsRelations(e) {
550
+ const { assets: t, stories: r, story: o } = e;
531
551
  if (r)
532
- for (const o of r)
533
- this.iterateTree(o, e);
552
+ for (const n of r)
553
+ this.iterateTree(n, t);
534
554
  else {
535
- if (!s)
536
- return t;
537
- this.iterateTree(s, e);
555
+ if (!o)
556
+ return e;
557
+ this.iterateTree(o, t);
538
558
  }
539
559
  }
540
- cacheResponse(t, e, r) {
541
- return r === void 0 && (r = 0), new Promise(async (s, o) => {
542
- let a = y({ url: t, params: e }), i = this.cacheProvider();
543
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
544
- const l = await i.get(a);
560
+ cacheResponse(e, t, r) {
561
+ return r === void 0 && (r = 0), new Promise(async (o, n) => {
562
+ let i = y({ url: e, params: t }), a = this.cacheProvider();
563
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
564
+ const l = await a.get(i);
545
565
  if (l)
546
- return s(l);
566
+ return o(l);
547
567
  }
548
568
  try {
549
- let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => y(p) }), h = { data: l.data, headers: l.headers };
569
+ let l = await this.throttle("get", e, { params: t, paramsSerializer: (p) => y(p) }), h = { data: l.data, headers: l.headers };
550
570
  if (h.data.assets && h.data.assets.length && this.resolveAssetsRelations(h.data), l.headers["per-page"] && (h = Object.assign({}, h, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
551
- return o(l);
552
- (h.data.story || h.data.stories) && await this.resolveStories(h.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, h), h.data.cv && (e.version == "draft" && d[e.token] != h.data.cv && this.flushCache(), d[e.token] = h.data.cv), s(h);
571
+ return n(l);
572
+ (h.data.story || h.data.stories) && await this.resolveStories(h.data, t), t.version === "published" && e != "/cdn/spaces/me" && a.set(i, h), h.data.cv && (t.version == "draft" && d[t.token] != h.data.cv && this.flushCache(), d[t.token] = h.data.cv), o(h);
553
573
  } catch (l) {
554
574
  if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
555
- return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((h) => setTimeout(h, c))), this.cacheResponse(t, e, r).then(s).catch(o);
556
- o(l);
575
+ return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((h) => setTimeout(h, c))), this.cacheResponse(e, t, r).then(o).catch(n);
576
+ n(l);
557
577
  }
558
578
  var c;
559
579
  });
560
580
  }
561
- throttledRequest(t, e, r) {
562
- return this.client[t](e, r);
581
+ throttledRequest(e, t, r) {
582
+ return this.client[e](t, r);
563
583
  }
564
584
  cacheVersions() {
565
585
  return d;
@@ -567,14 +587,14 @@ class D {
567
587
  cacheVersion() {
568
588
  return d[this.accessToken];
569
589
  }
570
- setCacheVersion(t) {
571
- this.accessToken && (d[this.accessToken] = t);
590
+ setCacheVersion(e) {
591
+ this.accessToken && (d[this.accessToken] = e);
572
592
  }
573
593
  cacheProvider() {
574
- return this.cache.type === "memory" ? { get: (t) => g[t], getAll: () => g, set(t, e) {
575
- g[t] = e;
594
+ return this.cache.type === "memory" ? { get: (e) => f[e], getAll: () => f, set(e, t) {
595
+ f[e] = t;
576
596
  }, flush() {
577
- g = {};
597
+ f = {};
578
598
  } } : { get() {
579
599
  }, getAll() {
580
600
  }, set() {
@@ -585,87 +605,91 @@ class D {
585
605
  return await this.cacheProvider().flush(), this;
586
606
  }
587
607
  }
588
- const J = (n = {}) => {
589
- const { apiOptions: t } = n;
590
- if (!t.accessToken) {
608
+ const se = (s = {}) => {
609
+ const { apiOptions: e } = s;
610
+ if (!e.accessToken) {
591
611
  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");
592
612
  return;
593
613
  }
594
- return { storyblokApi: new D(t) };
614
+ return { storyblokApi: new re(e) };
595
615
  };
596
- var Q = (n) => {
597
- if (typeof n != "object" || typeof n._editable > "u")
616
+ var le = (s) => {
617
+ if (typeof s != "object" || typeof s._editable > "u")
598
618
  return {};
599
- const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
619
+ const e = JSON.parse(s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
600
620
  return {
601
- "data-blok-c": JSON.stringify(t),
602
- "data-blok-uid": t.id + "-" + t.uid
621
+ "data-blok-c": JSON.stringify(e),
622
+ "data-blok-uid": e.id + "-" + e.uid
603
623
  };
604
624
  };
605
625
  let m;
606
- const O = "https://app.storyblok.com/f/storyblok-v2-latest.js", F = (n = {}) => {
626
+ const I = "https://app.storyblok.com/f/storyblok-v2-latest.js", oe = (s = {}) => {
607
627
  const {
608
- bridge: t,
609
- accessToken: e,
628
+ bridge: e,
629
+ accessToken: t,
610
630
  use: r = [],
611
- apiOptions: s = {},
612
- richText: o = {}
613
- } = n;
614
- s.accessToken = s.accessToken || e;
615
- const a = { bridge: t, apiOptions: s };
616
- let i = {};
631
+ apiOptions: o = {},
632
+ richText: n = {}
633
+ } = s;
634
+ o.accessToken = o.accessToken || t;
635
+ const i = { bridge: e, apiOptions: o };
636
+ let a = {};
617
637
  return r.forEach((c) => {
618
- i = u(u({}, i), c(a));
619
- }), t !== !1 && w(O), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
620
- }, E = (n, t) => {
621
- n.addNode("blok", (e) => {
638
+ a = u(u({}, a), c(i));
639
+ }), e !== !1 && S(I), m = new x(n.schema), n.resolver && P(m, n.resolver), a;
640
+ }, P = (s, e) => {
641
+ s.addNode("blok", (t) => {
622
642
  let r = "";
623
- return e.attrs.body.forEach((s) => {
624
- r += t(s.component, s);
643
+ return t.attrs.body.forEach((o) => {
644
+ r += e(o.component, o);
625
645
  }), {
626
646
  html: r
627
647
  };
628
648
  });
629
- }, K = (n, t, e) => {
630
- let r = e || m;
649
+ }, ne = (s, e, t) => {
650
+ let r = t || m;
631
651
  if (!r) {
632
652
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
633
653
  return;
634
654
  }
635
- return n === "" ? "" : n ? (t && (r = new R(t.schema), t.resolver && E(r, t.resolver)), r.render(n)) : (console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
655
+ return s === "" ? "" : s ? (e && (r = new x(e.schema), e.resolver && P(r, e.resolver)), r.render(s)) : (console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
636
656
 
637
657
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
638
- }, W = () => w(O);
639
- function Y(n, t, e) {
640
- const { storyblokApi: r } = F({
641
- accessToken: n,
642
- use: t || [J],
643
- apiOptions: { ...e }
658
+ }, ce = () => S(I);
659
+ function ae(s, e, t) {
660
+ const { storyblokApi: r } = oe({
661
+ accessToken: s,
662
+ use: e || [se],
663
+ apiOptions: { ...t }
644
664
  });
645
665
  globalThis.storyblokApiInstance = r;
646
666
  }
647
- function X() {
667
+ function he() {
648
668
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
649
669
  }
650
- function Z(n, t) {
651
- const e = globalThis.storyblokApiInstance.richTextResolver;
652
- if (!e) {
653
- console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
670
+ function ue(s, e) {
671
+ const t = globalThis.storyblokApiInstance.richTextResolver;
672
+ if (!t) {
673
+ console.error(
674
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
675
+ );
654
676
  return;
655
677
  }
656
- return K(n, t, e);
678
+ return ne(s, e, t);
657
679
  }
658
- function tt(n) {
680
+ function de(s) {
659
681
  return {
660
682
  name: "@storyblok/astro",
661
683
  hooks: {
662
- "astro:config:setup": ({ injectScript: t, updateConfig: e }) => {
663
- var s;
664
- e({
684
+ "astro:config:setup": ({ injectScript: e, updateConfig: t }) => {
685
+ var o;
686
+ t({
665
687
  vite: {
666
- plugins: [j(n.components)]
688
+ plugins: [z(s.components)]
667
689
  }
668
- }), Y(n.accessToken, n.use, n.apiOptions), ((s = n.bridge) != null ? s : !0) && t("page", `
690
+ }), ae(s.accessToken, s.use, s.apiOptions), ((o = s.bridge) != null ? o : !0) && e(
691
+ "page",
692
+ `
669
693
  import { loadStoryblokBridge } from "@storyblok/astro";
670
694
  loadStoryblokBridge().then(() => {
671
695
  const { StoryblokBridge, location } = window;
@@ -677,16 +701,17 @@ function tt(n) {
677
701
  }
678
702
  });
679
703
  });
680
- `);
704
+ `
705
+ );
681
706
  }
682
707
  }
683
708
  };
684
709
  }
685
710
  export {
686
- z as RichTextSchema,
687
- tt as default,
688
- W as loadStoryblokBridge,
689
- Z as renderRichText,
690
- Q as storyblokEditable,
691
- X as useStoryblokApi
711
+ W as RichTextSchema,
712
+ de as default,
713
+ ce as loadStoryblokBridge,
714
+ ue as renderRichText,
715
+ le as storyblokEditable,
716
+ he as useStoryblokApi
692
717
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
- "version": "1.1.0",
4
- "description": "UPDATE DESCRIPTION",
3
+ "version": "1.1.1",
4
+ "description": "SDK to integrate Storyblok into your project using Astro.",
5
5
  "main": "./dist/storyblok-astro.js",
6
6
  "module": "./dist/storyblok-astro.mjs",
7
7
  "files": [
@@ -27,16 +27,17 @@
27
27
  "prepublishOnly": "npm run build && cp ../README.md ./"
28
28
  },
29
29
  "dependencies": {
30
- "@storyblok/js": "^1.8.5"
30
+ "@storyblok/js": "^1.8.5",
31
+ "camelcase": "^7.0.0"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@cypress/vite-dev-server": "^2.0.7",
34
35
  "@rollup/plugin-dynamic-import-vars": "^1.4.4",
35
36
  "axios": "^0.27.2",
36
- "cypress": "^10.6.0",
37
+ "cypress": "^10.9.0",
37
38
  "eslint-plugin-cypress": "^2.12.1",
38
39
  "start-server-and-test": "^1.14.0",
39
- "vite": "^3.0.8"
40
+ "vite": "^3.1.3"
40
41
  },
41
42
  "repository": {
42
43
  "type": "git",