@storyblok/svelte 2.0.5 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  <script>
2
2
  import { getComponent } from "./index";
3
- export let blok;
3
+
4
4
  let component;
5
+ export let blok;
5
6
 
6
7
  if (blok) {
7
8
  component = getComponent(blok.component);
@@ -10,4 +11,5 @@
10
11
  }
11
12
  </script>
12
13
 
14
+ <!-- svelte-ignore missing-declaration -->
13
15
  <svelte:component this={component} {blok} {...$$restProps} />
@@ -0,0 +1,12 @@
1
+ /// <reference types="svelte/types/runtime/ambient" />
2
+ export { useStoryblokBridge, apiPlugin } from "@storyblok/js";
3
+ import type { SbSvelteSDKOptions, StoryblokClient, SbBlokData } from "./types";
4
+ export declare const storyblokEditable: (node: HTMLElement, value: SbBlokData) => {
5
+ update(newValue: SbBlokData): void;
6
+ };
7
+ export declare const useStoryblokApi: () => StoryblokClient;
8
+ export { useStoryblokApi as getStoryblokApi };
9
+ export declare const storyblokInit: (options: SbSvelteSDKOptions) => void;
10
+ export declare const getComponent: (componentName: string) => typeof import("*.svelte").default;
11
+ export * from "./types";
12
+ export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
package/dist/main.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { SbBlokData } from './index'
2
+ import { SvelteComponentTyped} from 'svelte'
3
+
4
+ export * from "./index"
5
+
6
+ interface StoryblokComponentProps {
7
+ blok: SbBlokData;
8
+ }
9
+
10
+ export declare class StoryblokComponent extends SvelteComponentTyped<StoryblokComponentProps> {
11
+ }
@@ -1,12 +1,12 @@
1
- (function(f,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],y):(f=typeof globalThis!="undefined"?globalThis:f||self,y(f.storyblokSvelte={},f.t))})(this,function(f,y){"use strict";function re(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var oe=re(y),se=Object.defineProperty,ie=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,B=(t,e,n)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))le.call(e,n)&&B(t,n,e[n]);if(N)for(var n of N(e))ce.call(e,n)&&B(t,n,e[n]);return t},E=(t,e)=>ie(t,ae(e));let L=!1;const q=[],ue=t=>new Promise((e,n)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}L?o():q.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=t,r.id="storyblok-javascript-bridge",r.onerror=o=>n(o),r.onload=o=>{q.forEach(s=>s()),L=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});/*!
2
- * storyblok-js-client v0.0.0-development
1
+ (function(f,m){typeof exports=="object"&&typeof module!="undefined"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(f=typeof globalThis!="undefined"?globalThis:f||self,m(f.storyblokSvelte={},f.e))})(this,function(f,m){"use strict";function rt(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var ot=rt(m),st=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,B=(n,t,e)=>t in n?st(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,p=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&B(n,e,t[e]);if(M)for(var e of M(t))ct.call(t,e)&&B(n,e,t[e]);return n},R=(n,t)=>it(n,at(t));let L=!1;const q=[],ut=n=>new Promise((t,e)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}L?o():q.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=o=>e(o),r.onload=o=>{q.forEach(s=>s()),L=!0,t(o)},document.getElementsByTagName("head")[0].appendChild(r)});/*!
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 D(t){return typeof t=="number"&&t==t&&t!==1/0&&t!==-1/0}function U(t,e,n){if(!D(e))throw new TypeError("Expected `limit` to be a finite number");if(!D(n))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],s=0,a=function(){s++;var l=setTimeout(function(){s--,r.length>0&&a(),o=o.filter(function(u){return u!==l})},n);o.indexOf(l)<0&&o.push(l);var c=r.shift();c.resolve(t.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,d){r.push({resolve:u,reject:d,args:l,self:c}),s<e&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(l){l.reject(new throttle.AbortError)}),r.length=0},i}U.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const fe=function(t,e){if(!t)return null;let n={};for(let r in t){let o=t[r];e.indexOf(r)>-1&&o!==null&&(n[r]=o)}return n};var de={nodes:{horizontal_rule:t=>({singleTag:"hr"}),blockquote:t=>({tag:"blockquote"}),bullet_list:t=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:t=>({singleTag:"br"}),heading:t=>({tag:"h"+t.attrs.level}),image:t=>({singleTag:[{tag:"img",attrs:fe(t.attrs,["src","alt","title"])}]}),list_item:t=>({tag:"li"}),ordered_list:t=>({tag:"ol"}),paragraph:t=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(t){const e=p({},t.attrs),{linktype:n="url"}=t.attrs;return n==="email"&&(e.href="mailto:"+e.href),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]})}};class he{constructor(e){e||(e=de),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,n){this.nodes[e]=n}addMark(e,n){this.marks[e]=n}render(e={}){if(e.content&&Array.isArray(e.content)){let n="";return e.content.forEach(r=>{n+=this.renderNode(r)}),n}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let n=[];e.marks&&e.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderOpeningTag(s.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&n.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{n.push(this.renderNode(o))}):e.text?n.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,l=>s[l]):o}(e.text)):r&&r.singleTag?n.push(this.renderTag(r.singleTag," /")):r&&r.html&&n.push(r.html),r&&r.tag&&n.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderClosingTag(s.tag))}),n.join("")}renderTag(e,n){return e.constructor===String?`<${e}${n}>`:e.map(r=>{if(r.constructor===String)return`<${r}${n}>`;{let o="<"+r.tag;if(r.attrs)for(let s in r.attrs){let a=r.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${n}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.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 pe=(t=0,e=t)=>{const n=Math.abs(e-t)||0,r=t<e?1:-1;return((o=0,s)=>[...Array(o)].map(s))(n,(o,s)=>s*r+t)},O=(t,e,n)=>{const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const s=t[o],a=n?"":encodeURIComponent(o);let i;i=typeof s=="object"?O(s,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),r.push(i)}return r.join("&")};let b={},g={};class ge{constructor(e,n){if(!n){let s=e.region?"-"+e.region:"",a=e.https===!1?"http":"https";n=e.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.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 he(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=U(this.throttledRequest,o,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=oe.default.create({baseURL:n,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(s=>e.responseInterceptor(s))}setComponentResolver(e){this.richTextResolver.addNode("blok",n=>{let r="";return n.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=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,n={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(n):n}makeRequest(e,n,r,o){const s=this.factoryParamOptions(e,((a={},i=25,l=1)=>E(p({},a),{per_page:i,page:l}))(n,r,o));return this.cacheResponse(e,s)}get(e,n){let r="/"+e;const o=this.factoryParamOptions(r,n);return this.cacheResponse(r,o)}async getAll(e,n={},r){const o=n.per_page||25,s="/"+e,a=s.split("/");r=r||a[a.length-1];const i=await this.makeRequest(s,n,o,1),l=Math.ceil(i.total/o);return((c=[],u)=>c.map(u).reduce((d,$)=>[...d,...$],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))(pe(1,l),async c=>this.makeRequest(s,n,o,c+1))],c=>Object.values(c.data[r]))}post(e,n){let r="/"+e;return this.throttle("post",r,n)}put(e,n){let r="/"+e;return this.throttle("put",r,n)}delete(e,n){let r="/"+e;return this.throttle("delete",r,n)}getStories(e){return this.get("cdn/stories",e)}getStory(e,n){return this.get("cdn/stories/"+e,n)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,n){const r=e[n];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,n,r){if(r.indexOf(e.component+"."+n)>-1){if(typeof e[n]=="string")this.relations[e[n]]&&(e[n]=this._cleanCopy(this.relations[e[n]]));else if(e[n].constructor===Array){let o=[];e[n].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),e[n]=o}}}iterateTree(e,n){let r=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)r(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,s,n),this._insertLinks(o,s)),r(o[s])}}};r(e.content)}async resolveLinks(e,n){let r=[];if(e.link_uuids){const o=e.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(e.link_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=e.links;r.forEach(o=>{this.links[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveRelations(e,n){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(e.rel_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=e.rels;r.forEach(o=>{this.relations[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveStories(e,n){let r=[];n.resolve_relations!==void 0&&n.resolve_relations.length>0&&(r=n.resolve_relations.split(","),await this.resolveRelations(e,n)),["1","story","url"].indexOf(n.resolve_links)>-1&&await this.resolveLinks(e,n);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)})}cacheResponse(e,n,r){return r===void 0&&(r=0),new Promise(async(o,s)=>{let a=O({url:e,params:n}),i=this.cacheProvider();if(this.cache.clear==="auto"&&n.version==="draft"&&await this.flushCache(),n.version==="published"&&e!="/cdn/spaces/me"){const c=await i.get(a);if(c)return o(c)}try{let c=await this.throttle("get",e,{params:n,paramsSerializer:d=>O(d)}),u={data:c.data,headers:c.headers};if(c.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(c.headers["per-page"]),total:parseInt(c.headers.total)})),c.status!=200)return s(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,n),n.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(n.version=="draft"&&g[n.token]!=u.data.cv&&this.flushCache(),g[n.token]=u.data.cv),o(u)}catch(c){if(c.response&&c.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(l=1e3*r,new Promise(u=>setTimeout(u,l))),this.cacheResponse(e,n,r).then(o).catch(s);s(c)}var l})}throttledRequest(e,n,r){return this.client[e](n,r)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>b[e],getAll:()=>b,set(e,n){b[e]=n},flush(){b={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var ye=(t={})=>{const{apiOptions:e}=t;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 ge(e)}},me=t=>{if(typeof t!="object"||typeof t._editable=="undefined")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const _e="https://app.storyblok.com/f/storyblok-v2-latest.js",ke=(t,e,n={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(n).on(["input","published","change"],o=>{o.action=="input"&&o.story.id===t?e(o.story):window.location.reload()})})}},be=(t={})=>{const{bridge:e,accessToken:n,use:r=[],apiOptions:o={}}=t;o.accessToken=o.accessToken||n;const s={bridge:e,apiOptions:o};let a={};return r.forEach(i=>{a=p(p({},a),i(s))}),e!==!1&&ue(_e),a};function V(){}function S(t,e){for(const n in e)t[n]=e[n];return t}function J(t){return t()}function Y(){return Object.create(null)}function m(t){t.forEach(J)}function ve(t){return typeof t=="function"}function we(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Te(t){return Object.keys(t).length===0}function $e(t){const e={};for(const n in t)n[0]!=="$"&&(e[n]=t[n]);return e}function z(t,e){const n={};e=new Set(e);for(const r in t)!e.has(r)&&r[0]!=="$"&&(n[r]=t[r]);return n}function Ee(t,e,n){t.insertBefore(e,n||null)}function F(t){t.parentNode.removeChild(t)}function Oe(t){return document.createTextNode(t)}function Se(){return Oe("")}function Pe(t){return Array.from(t.childNodes)}let P;function _(t){P=t}const k=[],H=[],v=[],G=[],Re=Promise.resolve();let R=!1;function je(){R||(R=!0,Re.then(K))}function j(t){v.push(t)}const x=new Set;let w=0;function K(){const t=P;do{for(;w<k.length;){const e=k[w];w++,_(e),xe(e.$$)}for(_(null),k.length=0,w=0;H.length;)H.pop()();for(let e=0;e<v.length;e+=1){const n=v[e];x.has(n)||(x.add(n),n())}v.length=0}while(k.length);for(;G.length;)G.pop()();R=!1,x.clear(),_(t)}function xe(t){if(t.fragment!==null){t.update(),m(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const T=new Set;let h;function Ae(){h={r:0,c:[],p:h}}function Ce(){h.r||m(h.c),h=h.p}function A(t,e){t&&t.i&&(T.delete(t),t.i(e))}function Q(t,e,n,r){if(t&&t.o){if(T.has(t))return;T.add(t),h.c.push(()=>{T.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function Ie(t,e){const n={},r={},o={$$scope:1};let s=t.length;for(;s--;){const a=t[s],i=e[s];if(i){for(const l in a)l in i||(r[l]=1);for(const l in i)o[l]||(n[l]=i[l],o[l]=1);t[s]=i}else for(const l in a)o[l]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Me(t){return typeof t=="object"&&t!==null?t:{}}function W(t){t&&t.c()}function C(t,e,n,r){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=t.$$;o&&o.m(e,n),r||j(()=>{const l=s.map(J).filter(ve);a?a.push(...l):m(l),t.$$.on_mount=[]}),i.forEach(j)}function I(t,e){const n=t.$$;n.fragment!==null&&(m(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ne(t,e){t.$$.dirty[0]===-1&&(k.push(t),je(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Be(t,e,n,r,o,s,a,i=[-1]){const l=P;_(t);const c=t.$$={fragment:null,ctx:null,props:s,update:V,not_equal:o,bound:Y(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Y(),dirty:i,skip_bound:!1,root:e.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=n?n(t,e.props||{},(d,$,...te)=>{const ne=te.length?te[0]:$;return c.ctx&&o(c.ctx[d],c.ctx[d]=ne)&&(!c.skip_bound&&c.bound[d]&&c.bound[d](ne),u&&Ne(t,d)),$}):[],c.update(),u=!0,m(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){const d=Pe(e.target);c.fragment&&c.fragment.l(d),d.forEach(F)}else c.fragment&&c.fragment.c();e.intro&&A(t.$$.fragment),C(t,e.target,e.anchor,e.customElement),K()}_(l)}class Le{$destroy(){I(this,1),this.$destroy=V}$on(e,n){const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function qe(t){let e,n,r;const o=[{blok:t[0]},t[2]];var s=t[1];function a(i){let l={};for(let c=0;c<o.length;c+=1)l=S(l,o[c]);return{props:l}}return s&&(e=new s(a())),{c(){e&&W(e.$$.fragment),n=Se()},m(i,l){e&&C(e,i,l),Ee(i,n,l),r=!0},p(i,[l]){const c=l&5?Ie(o,[l&1&&{blok:i[0]},l&4&&Me(i[2])]):{};if(s!==(s=i[1])){if(e){Ae();const u=e;Q(u.$$.fragment,1,0,()=>{I(u,1)}),Ce()}s?(e=new s(a()),W(e.$$.fragment),A(e.$$.fragment,1),C(e,n.parentNode,n)):e=null}else s&&e.$set(c)},i(i){r||(e&&A(e.$$.fragment,i),r=!0)},o(i){e&&Q(e.$$.fragment,i),r=!1},d(i){i&&F(n),e&&I(e,i)}}}function De(t,e,n){const r=["blok"];let o=z(e,r),{blok:s}=e,a;return s?a=ee(s.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),t.$$set=i=>{e=S(S({},e),$e(i)),n(2,o=z(e,r)),"blok"in i&&n(0,s=i.blok)},[s,a,o]}class Ue extends Le{constructor(e){super();Be(this,e,De,qe,we,{blok:0})}}const Ve=(t,e)=>{const n=r=>{const o=me(r);o["data-blok-c"]&&(t.setAttribute("data-blok-c",o["data-blok-c"]),t.setAttribute("data-blok-uid",o["data-blok-uid"]),t.classList.add("storyblok__outline"))};return n(e),{update(r){n(r)}}};let M=null;const X=()=>(M||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),M);let Z=null;const Je=t=>{const{storyblokApi:e}=be(t);M=e,Z=t.components||{}},ee=t=>{const e=Z[t];return e||console.error(`You didn't load the ${t} component. Please load it in storyblokInit. For example:
5
+ */function D(n){return typeof n=="number"&&n==n&&n!==1/0&&n!==-1/0}function z(n,t,e){if(!D(t))throw new TypeError("Expected `limit` to be a finite number");if(!D(e))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],s=0,a=function(){s++;var l=setTimeout(function(){s--,r.length>0&&a(),o=o.filter(function(u){return u!==l})},e);o.indexOf(l)<0&&o.push(l);var c=r.shift();c.resolve(n.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,d){r.push({resolve:u,reject:d,args:l,self:c}),s<t&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(l){l.reject(new throttle.AbortError)}),r.length=0},i}z.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const ft=function(n,t){if(!n)return null;let e={};for(let r in n){let o=n[r];t.indexOf(r)>-1&&o!==null&&(e[r]=o)}return e};var dt={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:ft(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 t=p({},n.attrs),{linktype:e="url"}=n.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:n=>({tag:[{tag:"span",attrs:n.attrs}]})}};class ht{constructor(t){t||(t=dt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(r=>{e+=this.renderNode(r)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderOpeningTag(s.tag))});const r=this.getMatchingNode(t);return r&&r.tag&&e.push(this.renderOpeningTag(r.tag)),t.content?t.content.forEach(o=>{e.push(this.renderNode(o))}):t.text?e.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,l=>s[l]):o}(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(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderClosingTag(s.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(r=>{if(r.constructor===String)return`<${r}${e}>`;{let o=`<${r.tag}`;if(r.attrs)for(let s in r.attrs){let a=r.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const pt=(n=0,t=n)=>{const e=Math.abs(t-n)||0,r=n<t?1:-1;return((o=0,s)=>[...Array(o)].map(s))(e,(o,s)=>s*r+n)},E=(n,t,e)=>{const r=[];for(const o in n){if(!Object.prototype.hasOwnProperty.call(n,o))continue;const s=n[o],a=e?"":encodeURIComponent(o);let i;i=typeof s=="object"?E(s,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),r.push(i)}return r.join("&")};let b={},g={};class gt{constructor(t,e){if(!e){let s=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let r=Object.assign({},t.headers),o=5;t.oauthToken!==void 0&&(r.Authorization=t.oauthToken,o=3),t.rateLimit!==void 0&&(o=t.rateLimit),this.richTextResolver=new ht(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=z(this.throttledRequest,o,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=ot.default.create({baseURL:e,timeout:t.timeout||0,headers:r,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(s=>t.responseInterceptor(s)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let r="";return e.attrs.body.forEach(o=>{r+=t(o.component,o)}),{html:r}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((r="")=>r.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,r,o){const s=this.factoryParamOptions(t,((a={},i=25,l=1)=>R(p({},a),{per_page:i,page:l}))(e,r,o));return this.cacheResponse(t,s)}get(t,e){let r=`/${t}`;const o=this.factoryParamOptions(r,e);return this.cacheResponse(r,o)}async getAll(t,e={},r){const o=e.per_page||25,s=`/${t}`,a=s.split("/");r=r||a[a.length-1];const i=await this.makeRequest(s,e,o,1),l=Math.ceil(i.total/o);return((c=[],u)=>c.map(u).reduce((d,T)=>[...d,...T],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))(pt(1,l),async c=>this.makeRequest(s,e,o,c+1))],c=>Object.values(c.data[r]))}post(t,e){let r=`/${t}`;return this.throttle("post",r,e)}put(t,e){let r=`/${t}`;return this.throttle("put",r,e)}delete(t,e){let r=`/${t}`;return this.throttle("delete",r,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const r=t[e];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(t,e,r){if(r.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let o=[];t[e].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),t[e]=o}}}_insertAssetsRelations(t,e){e.forEach(r=>{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)})}iterateTree(t,e){let r=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)r(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)o.component&&o._uid||o.type==="link"?(this._insertRelations(o,s,e),this._insertLinks(o,s)):o.fieldtype==="asset"&&this._insertAssetsRelations(o,e),r(o[s])}}};r(t.content)}async resolveLinks(t,e){let r=[];if(t.link_uuids){const o=t.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.link_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.links;r.forEach(o=>{this.links[o.uuid]=R(p({},o),{_stopResolving:!0})})}async resolveRelations(t,e){let r=[];if(t.rel_uuids){const o=t.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.rel_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.rels;r.forEach(o=>{this.relations[o.uuid]=R(p({},o),{_stopResolving:!0})})}async resolveStories(t,e){let r=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(r=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const o in this.relations)this.iterateTree(this.relations[o],r);t.story?this.iterateTree(t.story,r):t.stories.forEach(o=>{this.iterateTree(o,r)})}resolveAssetsRelations(t){const{assets:e,stories:r,story:o}=t;if(r)for(const s of r)this.iterateTree(s,e);else this.iterateTree(o,e)}cacheResponse(t,e,r){return r===void 0&&(r=0),new Promise(async(o,s)=>{let a=E({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return o(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:d=>E(d)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),c.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(c.headers["per-page"]),total:parseInt(c.headers.total)})),c.status!=200)return s(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),o(u)}catch(c){if(c.response&&c.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(l=1e3*r,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,r).then(o).catch(s);s(c)}var l})}throttledRequest(t,e,r){return this.client[t](e,r)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const mt=(n={})=>{const{apiOptions:t}=n;if(!t.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 gt(t)}};var yt=n=>{if(typeof n!="object"||typeof n._editable=="undefined")return{};const t=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};const _t="https://app.storyblok.com/f/storyblok-v2-latest.js",kt=(n,t,e={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],o=>{o.action=="input"&&o.story.id===n?t(o.story):window.location.reload()})})}},bt=(n={})=>{const{bridge:t,accessToken:e,use:r=[],apiOptions:o={}}=n;o.accessToken=o.accessToken||e;const s={bridge:t,apiOptions:o};let a={};return r.forEach(i=>{a=p(p({},a),i(s))}),t!==!1&&ut(_t),a};function U(){}function O(n,t){for(const e in t)n[e]=t[e];return n}function V(n){return n()}function J(){return Object.create(null)}function y(n){n.forEach(V)}function vt(n){return typeof n=="function"}function wt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function $t(n){return Object.keys(n).length===0}function Tt(n){const t={};for(const e in n)e[0]!=="$"&&(t[e]=n[e]);return t}function Y(n,t){const e={};t=new Set(t);for(const r in n)!t.has(r)&&r[0]!=="$"&&(e[r]=n[r]);return e}function Rt(n,t,e){n.insertBefore(t,e||null)}function F(n){n.parentNode.removeChild(n)}function Et(n){return document.createTextNode(n)}function Ot(){return Et("")}function St(n){return Array.from(n.childNodes)}let S;function _(n){S=n}const k=[],H=[],v=[],G=[],Pt=Promise.resolve();let P=!1;function jt(){P||(P=!0,Pt.then(K))}function j(n){v.push(n)}const A=new Set;let w=0;function K(){const n=S;do{for(;w<k.length;){const t=k[w];w++,_(t),At(t.$$)}for(_(null),k.length=0,w=0;H.length;)H.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];A.has(e)||(A.add(e),e())}v.length=0}while(k.length);for(;G.length;)G.pop()();P=!1,A.clear(),_(n)}function At(n){if(n.fragment!==null){n.update(),y(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(j)}}const $=new Set;let h;function xt(){h={r:0,c:[],p:h}}function Ct(){h.r||y(h.c),h=h.p}function x(n,t){n&&n.i&&($.delete(n),n.i(t))}function Q(n,t,e,r){if(n&&n.o){if($.has(n))return;$.add(n),h.c.push(()=>{$.delete(n),r&&(e&&n.d(1),r())}),n.o(t)}}function It(n,t){const e={},r={},o={$$scope:1};let s=n.length;for(;s--;){const a=n[s],i=t[s];if(i){for(const l in a)l in i||(r[l]=1);for(const l in i)o[l]||(e[l]=i[l],o[l]=1);n[s]=i}else for(const l in a)o[l]=1}for(const a in r)a in e||(e[a]=void 0);return e}function Nt(n){return typeof n=="object"&&n!==null?n:{}}function W(n){n&&n.c()}function C(n,t,e,r){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=n.$$;o&&o.m(t,e),r||j(()=>{const l=s.map(V).filter(vt);a?a.push(...l):y(l),n.$$.on_mount=[]}),i.forEach(j)}function I(n,t){const e=n.$$;e.fragment!==null&&(y(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Mt(n,t){n.$$.dirty[0]===-1&&(k.push(n),jt(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Bt(n,t,e,r,o,s,a,i=[-1]){const l=S;_(n);const c=n.$$={fragment:null,ctx:null,props:s,update:U,not_equal:o,bound:J(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:J(),dirty:i,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=e?e(n,t.props||{},(d,T,...et)=>{const nt=et.length?et[0]:T;return c.ctx&&o(c.ctx[d],c.ctx[d]=nt)&&(!c.skip_bound&&c.bound[d]&&c.bound[d](nt),u&&Mt(n,d)),T}):[],c.update(),u=!0,y(c.before_update),c.fragment=r?r(c.ctx):!1,t.target){if(t.hydrate){const d=St(t.target);c.fragment&&c.fragment.l(d),d.forEach(F)}else c.fragment&&c.fragment.c();t.intro&&x(n.$$.fragment),C(n,t.target,t.anchor,t.customElement),K()}_(l)}class Lt{$destroy(){I(this,1),this.$destroy=U}$on(t,e){const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{const o=r.indexOf(e);o!==-1&&r.splice(o,1)}}$set(t){this.$$set&&!$t(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qt(n){let t,e,r;const o=[{blok:n[0]},n[2]];var s=n[1];function a(i){let l={};for(let c=0;c<o.length;c+=1)l=O(l,o[c]);return{props:l}}return s&&(t=new s(a())),{c(){t&&W(t.$$.fragment),e=Ot()},m(i,l){t&&C(t,i,l),Rt(i,e,l),r=!0},p(i,[l]){const c=l&5?It(o,[l&1&&{blok:i[0]},l&4&&Nt(i[2])]):{};if(s!==(s=i[1])){if(t){xt();const u=t;Q(u.$$.fragment,1,0,()=>{I(u,1)}),Ct()}s?(t=new s(a()),W(t.$$.fragment),x(t.$$.fragment,1),C(t,e.parentNode,e)):t=null}else s&&t.$set(c)},i(i){r||(t&&x(t.$$.fragment,i),r=!0)},o(i){t&&Q(t.$$.fragment,i),r=!1},d(i){i&&F(e),t&&I(t,i)}}}function Dt(n,t,e){const r=["blok"];let o=Y(t,r),s,{blok:a}=t;return a?s=tt(a.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),n.$$set=i=>{t=O(O({},t),Tt(i)),e(2,o=Y(t,r)),"blok"in i&&e(0,a=i.blok)},[a,s,o]}class zt extends Lt{constructor(t){super(),Bt(this,t,Dt,qt,wt,{blok:0})}}const Ut=(n,t)=>{const e=r=>{const o=yt(r);o["data-blok-c"]&&(n.setAttribute("data-blok-c",o["data-blok-c"]),n.setAttribute("data-blok-uid",o["data-blok-uid"]),n.classList.add("storyblok__outline"))};return e(t),{update(r){e(r)}}};let N=null;const X=()=>(N||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),N);let Z=null;const Vt=n=>{const{storyblokApi:t}=bt(n);N=t,Z=n.components||{}},tt=n=>{const t=Z[n];return t||console.error(`You didn't load the ${n} component. Please load it in storyblokInit. For example:
6
6
  storyblokInit({
7
7
  accessToken: "<your-token>",
8
8
  components: {
9
9
  "teaser": Teaser
10
10
  }
11
11
  })
12
- `),e};f.StoryblokComponent=Ue,f.apiPlugin=ye,f.getComponent=ee,f.getStoryblokApi=X,f.storyblokEditable=Ve,f.storyblokInit=Je,f.useStoryblokApi=X,f.useStoryblokBridge=ke,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
12
+ `),t};f.StoryblokComponent=zt,f.apiPlugin=mt,f.getComponent=tt,f.getStoryblokApi=X,f.storyblokEditable=Ut,f.storyblokInit=Vt,f.useStoryblokApi=X,f.useStoryblokBridge=kt,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,4 +1,4 @@
1
- import t from "axios";
1
+ import e from "axios";
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defProps = Object.defineProperties;
4
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -50,313 +50,326 @@ const loadBridge = (src) => {
50
50
  });
51
51
  };
52
52
  /*!
53
- * storyblok-js-client v0.0.0-development
53
+ * storyblok-js-client v4.5.2
54
54
  * Universal JavaScript SDK for Storyblok's API
55
55
  * (c) 2020-2022 Stobylok Team
56
56
  */
57
- function e(t2) {
58
- return typeof t2 == "number" && (t2 == t2 && t2 !== 1 / 0 && t2 !== -1 / 0);
57
+ function t(e2) {
58
+ return typeof e2 == "number" && (e2 == e2 && e2 !== 1 / 0 && e2 !== -1 / 0);
59
59
  }
60
- function r(t2, r2, s2) {
61
- if (!e(r2))
60
+ function s(e2, s2, r2) {
61
+ if (!t(s2))
62
62
  throw new TypeError("Expected `limit` to be a finite number");
63
- if (!e(s2))
63
+ if (!t(r2))
64
64
  throw new TypeError("Expected `interval` to be a finite number");
65
- var n2 = [], i2 = [], o2 = 0, a2 = function() {
65
+ var i2 = [], n2 = [], o2 = 0, a2 = function() {
66
66
  o2++;
67
- var e2 = setTimeout(function() {
68
- o2--, n2.length > 0 && a2(), i2 = i2.filter(function(t3) {
69
- return t3 !== e2;
67
+ var t2 = setTimeout(function() {
68
+ o2--, i2.length > 0 && a2(), n2 = n2.filter(function(e3) {
69
+ return e3 !== t2;
70
70
  });
71
- }, s2);
72
- i2.indexOf(e2) < 0 && i2.push(e2);
73
- var r3 = n2.shift();
74
- r3.resolve(t2.apply(r3.self, r3.args));
71
+ }, r2);
72
+ n2.indexOf(t2) < 0 && n2.push(t2);
73
+ var s3 = i2.shift();
74
+ s3.resolve(e2.apply(s3.self, s3.args));
75
75
  }, l2 = function() {
76
- var t3 = arguments, e2 = this;
77
- return new Promise(function(s3, i3) {
78
- n2.push({ resolve: s3, reject: i3, args: t3, self: e2 }), o2 < r2 && a2();
76
+ var e3 = arguments, t2 = this;
77
+ return new Promise(function(r3, n3) {
78
+ i2.push({ resolve: r3, reject: n3, args: e3, self: t2 }), o2 < s2 && a2();
79
79
  });
80
80
  };
81
81
  return l2.abort = function() {
82
- i2.forEach(clearTimeout), i2 = [], n2.forEach(function(t3) {
83
- t3.reject(new throttle.AbortError());
84
- }), n2.length = 0;
82
+ n2.forEach(clearTimeout), n2 = [], i2.forEach(function(e3) {
83
+ e3.reject(new throttle.AbortError());
84
+ }), i2.length = 0;
85
85
  }, l2;
86
86
  }
87
- r.AbortError = function() {
87
+ s.AbortError = function() {
88
88
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
89
89
  };
90
- const s = function(t2, e2) {
91
- if (!t2)
90
+ const r = function(e2, t2) {
91
+ if (!e2)
92
92
  return null;
93
- let r2 = {};
94
- for (let s2 in t2) {
95
- let n2 = t2[s2];
96
- e2.indexOf(s2) > -1 && n2 !== null && (r2[s2] = n2);
93
+ let s2 = {};
94
+ for (let r2 in e2) {
95
+ let i2 = e2[r2];
96
+ t2.indexOf(r2) > -1 && i2 !== null && (s2[r2] = i2);
97
97
  }
98
- return r2;
98
+ return s2;
99
99
  };
100
- var n = { nodes: { horizontal_rule: (t2) => ({ singleTag: "hr" }), blockquote: (t2) => ({ tag: "blockquote" }), bullet_list: (t2) => ({ tag: "ul" }), code_block: (t2) => ({ tag: ["pre", { tag: "code", attrs: t2.attrs }] }), hard_break: (t2) => ({ singleTag: "br" }), heading: (t2) => ({ tag: "h" + t2.attrs.level }), image: (t2) => ({ singleTag: [{ tag: "img", attrs: s(t2.attrs, ["src", "alt", "title"]) }] }), list_item: (t2) => ({ tag: "li" }), ordered_list: (t2) => ({ tag: "ol" }), paragraph: (t2) => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(t2) {
101
- const e2 = __spreadValues({}, t2.attrs), { linktype: r2 = "url" } = t2.attrs;
102
- return r2 === "email" && (e2.href = "mailto:" + e2.href), e2.anchor && (e2.href = `${e2.href}#${e2.anchor}`, delete e2.anchor), { tag: [{ tag: "a", attrs: e2 }] };
103
- }, styled: (t2) => ({ tag: [{ tag: "span", attrs: t2.attrs }] }) } };
104
- class i {
105
- constructor(t2) {
106
- t2 || (t2 = n), this.marks = t2.marks || [], this.nodes = t2.nodes || [];
107
- }
108
- addNode(t2, e2) {
109
- this.nodes[t2] = e2;
110
- }
111
- addMark(t2, e2) {
112
- this.marks[t2] = e2;
113
- }
114
- render(t2 = {}) {
115
- if (t2.content && Array.isArray(t2.content)) {
116
- let e2 = "";
117
- return t2.content.forEach((t3) => {
118
- e2 += this.renderNode(t3);
119
- }), e2;
100
+ var i = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (e2) => ({ tag: ["pre", { tag: "code", attrs: e2.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (e2) => ({ tag: `h${e2.attrs.level}` }), image: (e2) => ({ singleTag: [{ tag: "img", attrs: r(e2.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(e2) {
101
+ const t2 = __spreadValues({}, e2.attrs), { linktype: s2 = "url" } = e2.attrs;
102
+ return s2 === "email" && (t2.href = `mailto:${t2.href}`), t2.anchor && (t2.href = `${t2.href}#${t2.anchor}`, delete t2.anchor), { tag: [{ tag: "a", attrs: t2 }] };
103
+ }, styled: (e2) => ({ tag: [{ tag: "span", attrs: e2.attrs }] }) } };
104
+ class n {
105
+ constructor(e2) {
106
+ e2 || (e2 = i), this.marks = e2.marks || [], this.nodes = e2.nodes || [];
107
+ }
108
+ addNode(e2, t2) {
109
+ this.nodes[e2] = t2;
110
+ }
111
+ addMark(e2, t2) {
112
+ this.marks[e2] = t2;
113
+ }
114
+ render(e2 = {}) {
115
+ if (e2.content && Array.isArray(e2.content)) {
116
+ let t2 = "";
117
+ return e2.content.forEach((e3) => {
118
+ t2 += this.renderNode(e3);
119
+ }), t2;
120
120
  }
121
121
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
122
122
  }
123
- renderNode(t2) {
124
- let e2 = [];
125
- t2.marks && t2.marks.forEach((t3) => {
126
- const r3 = this.getMatchingMark(t3);
127
- r3 && e2.push(this.renderOpeningTag(r3.tag));
123
+ renderNode(e2) {
124
+ let t2 = [];
125
+ e2.marks && e2.marks.forEach((e3) => {
126
+ const s3 = this.getMatchingMark(e3);
127
+ s3 && t2.push(this.renderOpeningTag(s3.tag));
128
128
  });
129
- const r2 = this.getMatchingNode(t2);
130
- return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)), t2.content ? t2.content.forEach((t3) => {
131
- e2.push(this.renderNode(t3));
132
- }) : t2.text ? e2.push(function(t3) {
133
- const e3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, r3 = /[&<>"']/g, s2 = RegExp(r3.source);
134
- return t3 && s2.test(t3) ? t3.replace(r3, (t4) => e3[t4]) : t3;
135
- }(t2.text)) : r2 && r2.singleTag ? e2.push(this.renderTag(r2.singleTag, " /")) : r2 && r2.html && e2.push(r2.html), r2 && r2.tag && e2.push(this.renderClosingTag(r2.tag)), t2.marks && t2.marks.slice(0).reverse().forEach((t3) => {
136
- const r3 = this.getMatchingMark(t3);
137
- r3 && e2.push(this.renderClosingTag(r3.tag));
138
- }), e2.join("");
139
- }
140
- renderTag(t2, e2) {
141
- if (t2.constructor === String)
142
- return `<${t2}${e2}>`;
143
- return t2.map((t3) => {
144
- if (t3.constructor === String)
145
- return `<${t3}${e2}>`;
129
+ const s2 = this.getMatchingNode(e2);
130
+ return s2 && s2.tag && t2.push(this.renderOpeningTag(s2.tag)), e2.content ? e2.content.forEach((e3) => {
131
+ t2.push(this.renderNode(e3));
132
+ }) : e2.text ? t2.push(function(e3) {
133
+ const t3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, s3 = /[&<>"']/g, r2 = RegExp(s3.source);
134
+ return e3 && r2.test(e3) ? e3.replace(s3, (e4) => t3[e4]) : e3;
135
+ }(e2.text)) : s2 && s2.singleTag ? t2.push(this.renderTag(s2.singleTag, " /")) : s2 && s2.html && t2.push(s2.html), s2 && s2.tag && t2.push(this.renderClosingTag(s2.tag)), e2.marks && e2.marks.slice(0).reverse().forEach((e3) => {
136
+ const s3 = this.getMatchingMark(e3);
137
+ s3 && t2.push(this.renderClosingTag(s3.tag));
138
+ }), t2.join("");
139
+ }
140
+ renderTag(e2, t2) {
141
+ if (e2.constructor === String)
142
+ return `<${e2}${t2}>`;
143
+ return e2.map((e3) => {
144
+ if (e3.constructor === String)
145
+ return `<${e3}${t2}>`;
146
146
  {
147
- let r2 = "<" + t3.tag;
148
- if (t3.attrs)
149
- for (let e3 in t3.attrs) {
150
- let s2 = t3.attrs[e3];
151
- s2 !== null && (r2 += ` ${e3}="${s2}"`);
147
+ let s2 = `<${e3.tag}`;
148
+ if (e3.attrs)
149
+ for (let t3 in e3.attrs) {
150
+ let r2 = e3.attrs[t3];
151
+ r2 !== null && (s2 += ` ${t3}="${r2}"`);
152
152
  }
153
- return `${r2}${e2}>`;
153
+ return `${s2}${t2}>`;
154
154
  }
155
155
  }).join("");
156
156
  }
157
- renderOpeningTag(t2) {
158
- return this.renderTag(t2, "");
157
+ renderOpeningTag(e2) {
158
+ return this.renderTag(e2, "");
159
159
  }
160
- renderClosingTag(t2) {
161
- if (t2.constructor === String)
162
- return `</${t2}>`;
163
- return t2.slice(0).reverse().map((t3) => t3.constructor === String ? `</${t3}>` : `</${t3.tag}>`).join("");
160
+ renderClosingTag(e2) {
161
+ if (e2.constructor === String)
162
+ return `</${e2}>`;
163
+ return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
164
164
  }
165
- getMatchingNode(t2) {
166
- if (typeof this.nodes[t2.type] == "function")
167
- return this.nodes[t2.type](t2);
165
+ getMatchingNode(e2) {
166
+ if (typeof this.nodes[e2.type] == "function")
167
+ return this.nodes[e2.type](e2);
168
168
  }
169
- getMatchingMark(t2) {
170
- if (typeof this.marks[t2.type] == "function")
171
- return this.marks[t2.type](t2);
169
+ getMatchingMark(e2) {
170
+ if (typeof this.marks[e2.type] == "function")
171
+ return this.marks[e2.type](e2);
172
172
  }
173
173
  }
174
- const o = (t2 = 0, e2 = t2) => {
175
- const r2 = Math.abs(e2 - t2) || 0, s2 = t2 < e2 ? 1 : -1;
176
- return ((t3 = 0, e3) => [...Array(t3)].map(e3))(r2, (e3, r3) => r3 * s2 + t2);
177
- }, a = (t2, e2, r2) => {
178
- const s2 = [];
179
- for (const n2 in t2) {
180
- if (!Object.prototype.hasOwnProperty.call(t2, n2))
174
+ const o = (e2 = 0, t2 = e2) => {
175
+ const s2 = Math.abs(t2 - e2) || 0, r2 = e2 < t2 ? 1 : -1;
176
+ return ((e3 = 0, t3) => [...Array(e3)].map(t3))(s2, (t3, s3) => s3 * r2 + e2);
177
+ }, a = (e2, t2, s2) => {
178
+ const r2 = [];
179
+ for (const i2 in e2) {
180
+ if (!Object.prototype.hasOwnProperty.call(e2, i2))
181
181
  continue;
182
- const i2 = t2[n2], o2 = r2 ? "" : encodeURIComponent(n2);
182
+ const n2 = e2[i2], o2 = s2 ? "" : encodeURIComponent(i2);
183
183
  let l2;
184
- l2 = typeof i2 == "object" ? a(i2, e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(i2)) : (e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(i2), s2.push(l2);
184
+ l2 = typeof n2 == "object" ? a(n2, t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(n2)) : (t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(n2), r2.push(l2);
185
185
  }
186
- return s2.join("&");
186
+ return r2.join("&");
187
187
  };
188
188
  let l = {}, c = {};
189
- class StoryblokClient {
190
- constructor(e2, s2) {
191
- if (!s2) {
192
- let t2 = e2.region ? "-" + e2.region : "", r2 = e2.https === false ? "http" : "https";
193
- s2 = e2.oauthToken === void 0 ? `${r2}://api${t2}.storyblok.com/v2` : `${r2}://api${t2}.storyblok.com/v1`;
189
+ class h {
190
+ constructor(t2, r2) {
191
+ if (!r2) {
192
+ let e2 = t2.region ? `-${t2.region}` : "", s2 = t2.https === false ? "http" : "https";
193
+ r2 = t2.oauthToken === void 0 ? `${s2}://api${e2}.storyblok.com/v2` : `${s2}://api${e2}.storyblok.com/v1`;
194
194
  }
195
- let n2 = Object.assign({}, e2.headers), o2 = 5;
196
- e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client = t.create({ baseURL: s2, timeout: e2.timeout || 0, headers: n2, proxy: e2.proxy || false }), e2.responseInterceptor && this.client.interceptors.response.use((t2) => e2.responseInterceptor(t2));
197
- }
198
- setComponentResolver(t2) {
199
- this.richTextResolver.addNode("blok", (e2) => {
200
- let r2 = "";
201
- return e2.attrs.body.forEach((e3) => {
202
- r2 += t2(e3.component, e3);
203
- }), { html: r2 };
195
+ let i2 = Object.assign({}, t2.headers), o2 = 5;
196
+ t2.oauthToken !== void 0 && (i2.Authorization = t2.oauthToken, o2 = 3), t2.rateLimit !== void 0 && (o2 = t2.rateLimit), this.richTextResolver = new n(t2.richTextSchema), typeof t2.componentResolver == "function" && this.setComponentResolver(t2.componentResolver), this.maxRetries = t2.maxRetries || 5, this.throttle = s(this.throttledRequest, o2, 1e3), this.accessToken = t2.accessToken, this.relations = {}, this.links = {}, this.cache = t2.cache || { clear: "manual" }, this.client = e.create({ baseURL: r2, timeout: t2.timeout || 0, headers: i2, proxy: t2.proxy || false }), t2.responseInterceptor && this.client.interceptors.response.use((e2) => t2.responseInterceptor(e2)), this.resolveNestedRelations = t2.resolveNestedRelations || true;
197
+ }
198
+ setComponentResolver(e2) {
199
+ this.richTextResolver.addNode("blok", (t2) => {
200
+ let s2 = "";
201
+ return t2.attrs.body.forEach((t3) => {
202
+ s2 += e2(t3.component, t3);
203
+ }), { html: s2 };
204
204
  });
205
205
  }
206
- parseParams(t2 = {}) {
207
- return t2.version || (t2.version = "published"), t2.token || (t2.token = this.getToken()), t2.cv || (t2.cv = c[t2.token]), Array.isArray(t2.resolve_relations) && (t2.resolve_relations = t2.resolve_relations.join(",")), t2;
206
+ parseParams(e2 = {}) {
207
+ return e2.version || (e2.version = "published"), e2.token || (e2.token = this.getToken()), e2.cv || (e2.cv = c[e2.token]), Array.isArray(e2.resolve_relations) && (e2.resolve_relations = e2.resolve_relations.join(",")), e2;
208
208
  }
209
- factoryParamOptions(t2, e2 = {}) {
210
- return ((t3 = "") => t3.indexOf("/cdn/") > -1)(t2) ? this.parseParams(e2) : e2;
209
+ factoryParamOptions(e2, t2 = {}) {
210
+ return ((e3 = "") => e3.indexOf("/cdn/") > -1)(e2) ? this.parseParams(t2) : t2;
211
211
  }
212
- makeRequest(t2, e2, r2, s2) {
213
- const n2 = this.factoryParamOptions(t2, ((t3 = {}, e3 = 25, r3 = 1) => __spreadProps(__spreadValues({}, t3), { per_page: e3, page: r3 }))(e2, r2, s2));
214
- return this.cacheResponse(t2, n2);
212
+ makeRequest(e2, t2, s2, r2) {
213
+ const i2 = this.factoryParamOptions(e2, ((e3 = {}, t3 = 25, s3 = 1) => __spreadProps(__spreadValues({}, e3), { per_page: t3, page: s3 }))(t2, s2, r2));
214
+ return this.cacheResponse(e2, i2);
215
215
  }
216
- get(t2, e2) {
217
- let r2 = "/" + t2;
218
- const s2 = this.factoryParamOptions(r2, e2);
219
- return this.cacheResponse(r2, s2);
216
+ get(e2, t2) {
217
+ let s2 = `/${e2}`;
218
+ const r2 = this.factoryParamOptions(s2, t2);
219
+ return this.cacheResponse(s2, r2);
220
220
  }
221
- async getAll(t2, e2 = {}, r2) {
222
- const s2 = e2.per_page || 25, n2 = "/" + t2, i2 = n2.split("/");
223
- r2 = r2 || i2[i2.length - 1];
224
- const a2 = await this.makeRequest(n2, e2, s2, 1), l2 = Math.ceil(a2.total / s2);
225
- return ((t3 = [], e3) => t3.map(e3).reduce((t4, e4) => [...t4, ...e4], []))([a2, ...await (async (t3 = [], e3) => Promise.all(t3.map(e3)))(o(1, l2), async (t3) => this.makeRequest(n2, e2, s2, t3 + 1))], (t3) => Object.values(t3.data[r2]));
221
+ async getAll(e2, t2 = {}, s2) {
222
+ const r2 = t2.per_page || 25, i2 = `/${e2}`, n2 = i2.split("/");
223
+ s2 = s2 || n2[n2.length - 1];
224
+ const a2 = await this.makeRequest(i2, t2, r2, 1), l2 = Math.ceil(a2.total / r2);
225
+ return ((e3 = [], t3) => e3.map(t3).reduce((e4, t4) => [...e4, ...t4], []))([a2, ...await (async (e3 = [], t3) => Promise.all(e3.map(t3)))(o(1, l2), async (e3) => this.makeRequest(i2, t2, r2, e3 + 1))], (e3) => Object.values(e3.data[s2]));
226
226
  }
227
- post(t2, e2) {
228
- let r2 = "/" + t2;
229
- return this.throttle("post", r2, e2);
227
+ post(e2, t2) {
228
+ let s2 = `/${e2}`;
229
+ return this.throttle("post", s2, t2);
230
230
  }
231
- put(t2, e2) {
232
- let r2 = "/" + t2;
233
- return this.throttle("put", r2, e2);
231
+ put(e2, t2) {
232
+ let s2 = `/${e2}`;
233
+ return this.throttle("put", s2, t2);
234
234
  }
235
- delete(t2, e2) {
236
- let r2 = "/" + t2;
237
- return this.throttle("delete", r2, e2);
235
+ delete(e2, t2) {
236
+ let s2 = `/${e2}`;
237
+ return this.throttle("delete", s2, t2);
238
238
  }
239
- getStories(t2) {
240
- return this.get("cdn/stories", t2);
239
+ getStories(e2) {
240
+ return this.get("cdn/stories", e2);
241
241
  }
242
- getStory(t2, e2) {
243
- return this.get("cdn/stories/" + t2, e2);
242
+ getStory(e2, t2) {
243
+ return this.get(`cdn/stories/${e2}`, t2);
244
244
  }
245
- setToken(t2) {
246
- this.accessToken = t2;
245
+ setToken(e2) {
246
+ this.accessToken = e2;
247
247
  }
248
248
  getToken() {
249
249
  return this.accessToken;
250
250
  }
251
- _cleanCopy(t2) {
252
- return JSON.parse(JSON.stringify(t2));
253
- }
254
- _insertLinks(t2, e2) {
255
- const r2 = t2[e2];
256
- r2 && r2.fieldtype == "multilink" && r2.linktype == "story" && typeof r2.id == "string" && this.links[r2.id] ? r2.story = this._cleanCopy(this.links[r2.id]) : r2 && r2.linktype === "story" && typeof r2.uuid == "string" && this.links[r2.uuid] && (r2.story = this._cleanCopy(this.links[r2.uuid]));
257
- }
258
- _insertRelations(t2, e2, r2) {
259
- if (r2.indexOf(t2.component + "." + e2) > -1) {
260
- if (typeof t2[e2] == "string")
261
- this.relations[t2[e2]] && (t2[e2] = this._cleanCopy(this.relations[t2[e2]]));
262
- else if (t2[e2].constructor === Array) {
263
- let r3 = [];
264
- t2[e2].forEach((t3) => {
265
- this.relations[t3] && r3.push(this._cleanCopy(this.relations[t3]));
266
- }), t2[e2] = r3;
251
+ _cleanCopy(e2) {
252
+ return JSON.parse(JSON.stringify(e2));
253
+ }
254
+ _insertLinks(e2, t2) {
255
+ const s2 = e2[t2];
256
+ s2 && s2.fieldtype == "multilink" && s2.linktype == "story" && typeof s2.id == "string" && this.links[s2.id] ? s2.story = this._cleanCopy(this.links[s2.id]) : s2 && s2.linktype === "story" && typeof s2.uuid == "string" && this.links[s2.uuid] && (s2.story = this._cleanCopy(this.links[s2.uuid]));
257
+ }
258
+ _insertRelations(e2, t2, s2) {
259
+ if (s2.indexOf(e2.component + "." + t2) > -1) {
260
+ if (typeof e2[t2] == "string")
261
+ this.relations[e2[t2]] && (e2[t2] = this._cleanCopy(this.relations[e2[t2]]));
262
+ else if (e2[t2].constructor === Array) {
263
+ let s3 = [];
264
+ e2[t2].forEach((e3) => {
265
+ this.relations[e3] && s3.push(this._cleanCopy(this.relations[e3]));
266
+ }), e2[t2] = s3;
267
267
  }
268
268
  }
269
269
  }
270
- iterateTree(t2, e2) {
271
- let r2 = (t3) => {
272
- if (t3 != null) {
273
- if (t3.constructor === Array)
274
- for (let e3 = 0; e3 < t3.length; e3++)
275
- r2(t3[e3]);
276
- else if (t3.constructor === Object) {
277
- if (t3._stopResolving)
270
+ _insertAssetsRelations(e2, t2) {
271
+ t2.forEach((t3) => {
272
+ e2.id === t3.id && (e2.original = t3, e2.original.filename = e2.filename, e2.original.filename = e2.original.filename.includes("https://s3.amazonaws.com/") ? e2.original.filename : e2.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e2.original.s3_filename);
273
+ });
274
+ }
275
+ iterateTree(e2, t2) {
276
+ let s2 = (e3) => {
277
+ if (e3 != null) {
278
+ if (e3.constructor === Array)
279
+ for (let t3 = 0; t3 < e3.length; t3++)
280
+ s2(e3[t3]);
281
+ else if (e3.constructor === Object) {
282
+ if (e3._stopResolving)
278
283
  return;
279
- for (let s2 in t3)
280
- (t3.component && t3._uid || t3.type === "link") && (this._insertRelations(t3, s2, e2), this._insertLinks(t3, s2)), r2(t3[s2]);
284
+ for (let r2 in e3)
285
+ e3.component && e3._uid || e3.type === "link" ? (this._insertRelations(e3, r2, t2), this._insertLinks(e3, r2)) : e3.fieldtype === "asset" && this._insertAssetsRelations(e3, t2), s2(e3[r2]);
281
286
  }
282
287
  }
283
288
  };
284
- r2(t2.content);
285
- }
286
- async resolveLinks(t2, e2) {
287
- let r2 = [];
288
- if (t2.link_uuids) {
289
- const s2 = t2.link_uuids.length;
290
- let n2 = [];
291
- const i2 = 50;
292
- for (let e3 = 0; e3 < s2; e3 += i2) {
293
- const r3 = Math.min(s2, e3 + i2);
294
- n2.push(t2.link_uuids.slice(e3, r3));
289
+ s2(e2.content);
290
+ }
291
+ async resolveLinks(e2, t2) {
292
+ let s2 = [];
293
+ if (e2.link_uuids) {
294
+ const r2 = e2.link_uuids.length;
295
+ let i2 = [];
296
+ const n2 = 50;
297
+ for (let t3 = 0; t3 < r2; t3 += n2) {
298
+ const s3 = Math.min(r2, t3 + n2);
299
+ i2.push(e2.link_uuids.slice(t3, s3));
295
300
  }
296
- for (let t3 = 0; t3 < n2.length; t3++) {
297
- (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
298
- r2.push(t4);
301
+ for (let e3 = 0; e3 < i2.length; e3++) {
302
+ (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
303
+ s2.push(e4);
299
304
  });
300
305
  }
301
306
  } else
302
- r2 = t2.links;
303
- r2.forEach((t3) => {
304
- this.links[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
307
+ s2 = e2.links;
308
+ s2.forEach((e3) => {
309
+ this.links[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
305
310
  });
306
311
  }
307
- async resolveRelations(t2, e2) {
308
- let r2 = [];
309
- if (t2.rel_uuids) {
310
- const s2 = t2.rel_uuids.length;
311
- let n2 = [];
312
- const i2 = 50;
313
- for (let e3 = 0; e3 < s2; e3 += i2) {
314
- const r3 = Math.min(s2, e3 + i2);
315
- n2.push(t2.rel_uuids.slice(e3, r3));
312
+ async resolveRelations(e2, t2) {
313
+ let s2 = [];
314
+ if (e2.rel_uuids) {
315
+ const r2 = e2.rel_uuids.length;
316
+ let i2 = [];
317
+ const n2 = 50;
318
+ for (let t3 = 0; t3 < r2; t3 += n2) {
319
+ const s3 = Math.min(r2, t3 + n2);
320
+ i2.push(e2.rel_uuids.slice(t3, s3));
316
321
  }
317
- for (let t3 = 0; t3 < n2.length; t3++) {
318
- (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
319
- r2.push(t4);
322
+ for (let e3 = 0; e3 < i2.length; e3++) {
323
+ (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
324
+ s2.push(e4);
320
325
  });
321
326
  }
322
327
  } else
323
- r2 = t2.rels;
324
- r2.forEach((t3) => {
325
- this.relations[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
328
+ s2 = e2.rels;
329
+ s2.forEach((e3) => {
330
+ this.relations[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
326
331
  });
327
332
  }
328
- async resolveStories(t2, e2) {
329
- let r2 = [];
330
- e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(t2, e2)), ["1", "story", "url"].indexOf(e2.resolve_links) > -1 && await this.resolveLinks(t2, e2);
331
- for (const t3 in this.relations)
332
- this.iterateTree(this.relations[t3], r2);
333
- t2.story ? this.iterateTree(t2.story, r2) : t2.stories.forEach((t3) => {
334
- this.iterateTree(t3, r2);
333
+ async resolveStories(e2, t2) {
334
+ let s2 = [];
335
+ if (t2.resolve_relations !== void 0 && t2.resolve_relations.length > 0 && (s2 = t2.resolve_relations.split(","), await this.resolveRelations(e2, t2)), ["1", "story", "url"].indexOf(t2.resolve_links) > -1 && await this.resolveLinks(e2, t2), this.resolveNestedRelations)
336
+ for (const e3 in this.relations)
337
+ this.iterateTree(this.relations[e3], s2);
338
+ e2.story ? this.iterateTree(e2.story, s2) : e2.stories.forEach((e3) => {
339
+ this.iterateTree(e3, s2);
335
340
  });
336
341
  }
337
- cacheResponse(t2, e2, r2) {
338
- return r2 === void 0 && (r2 = 0), new Promise(async (s2, n2) => {
339
- let i2 = a({ url: t2, params: e2 }), o2 = this.cacheProvider();
340
- if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" && t2 != "/cdn/spaces/me") {
341
- const t3 = await o2.get(i2);
342
- if (t3)
343
- return s2(t3);
342
+ resolveAssetsRelations(e2) {
343
+ const { assets: t2, stories: s2, story: r2 } = e2;
344
+ if (s2)
345
+ for (const e3 of s2)
346
+ this.iterateTree(e3, t2);
347
+ else
348
+ this.iterateTree(r2, t2);
349
+ }
350
+ cacheResponse(e2, t2, s2) {
351
+ return s2 === void 0 && (s2 = 0), new Promise(async (r2, i2) => {
352
+ let n2 = a({ url: e2, params: t2 }), o2 = this.cacheProvider();
353
+ if (this.cache.clear === "auto" && t2.version === "draft" && await this.flushCache(), t2.version === "published" && e2 != "/cdn/spaces/me") {
354
+ const e3 = await o2.get(n2);
355
+ if (e3)
356
+ return r2(e3);
344
357
  }
345
358
  try {
346
- let r3 = await this.throttle("get", t2, { params: e2, paramsSerializer: (t3) => a(t3) }), l3 = { data: r3.data, headers: r3.headers };
347
- if (r3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(r3.headers["per-page"]), total: parseInt(r3.headers.total) })), r3.status != 200)
348
- return n2(r3);
349
- (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" && t2 != "/cdn/spaces/me" && o2.set(i2, l3), l3.data.cv && (e2.version == "draft" && c[e2.token] != l3.data.cv && this.flushCache(), c[e2.token] = l3.data.cv), s2(l3);
350
- } catch (i3) {
351
- if (i3.response && i3.response.status === 429 && (r2 += 1) < this.maxRetries)
352
- return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((t3) => setTimeout(t3, l2))), this.cacheResponse(t2, e2, r2).then(s2).catch(n2);
353
- n2(i3);
359
+ let s3 = await this.throttle("get", e2, { params: t2, paramsSerializer: (e3) => a(e3) }), l3 = { data: s3.data, headers: s3.headers };
360
+ if (l3.data.assets && l3.data.assets.length && this.resolveAssetsRelations(l3.data), s3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(s3.headers["per-page"]), total: parseInt(s3.headers.total) })), s3.status != 200)
361
+ return i2(s3);
362
+ (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, t2), t2.version === "published" && e2 != "/cdn/spaces/me" && o2.set(n2, l3), l3.data.cv && (t2.version == "draft" && c[t2.token] != l3.data.cv && this.flushCache(), c[t2.token] = l3.data.cv), r2(l3);
363
+ } catch (n3) {
364
+ if (n3.response && n3.response.status === 429 && (s2 += 1) < this.maxRetries)
365
+ return console.log(`Hit rate limit. Retrying in ${s2} seconds.`), await (l2 = 1e3 * s2, new Promise((e3) => setTimeout(e3, l2))), this.cacheResponse(e2, t2, s2).then(r2).catch(i2);
366
+ i2(n3);
354
367
  }
355
368
  var l2;
356
369
  });
357
370
  }
358
- throttledRequest(t2, e2, r2) {
359
- return this.client[t2](e2, r2);
371
+ throttledRequest(e2, t2, s2) {
372
+ return this.client[e2](t2, s2);
360
373
  }
361
374
  cacheVersions() {
362
375
  return c;
@@ -364,36 +377,31 @@ class StoryblokClient {
364
377
  cacheVersion() {
365
378
  return c[this.accessToken];
366
379
  }
367
- setCacheVersion(t2) {
368
- this.accessToken && (c[this.accessToken] = t2);
380
+ setCacheVersion(e2) {
381
+ this.accessToken && (c[this.accessToken] = e2);
369
382
  }
370
383
  cacheProvider() {
371
- switch (this.cache.type) {
372
- case "memory":
373
- return { get: (t2) => l[t2], getAll: () => l, set(t2, e2) {
374
- l[t2] = e2;
375
- }, flush() {
376
- l = {};
377
- } };
378
- default:
379
- return { get() {
380
- }, getAll() {
381
- }, set() {
382
- }, flush() {
383
- } };
384
- }
384
+ return this.cache.type === "memory" ? { get: (e2) => l[e2], getAll: () => l, set(e2, t2) {
385
+ l[e2] = t2;
386
+ }, flush() {
387
+ l = {};
388
+ } } : { get() {
389
+ }, getAll() {
390
+ }, set() {
391
+ }, flush() {
392
+ } };
385
393
  }
386
394
  async flushCache() {
387
395
  return await this.cacheProvider().flush(), this;
388
396
  }
389
397
  }
390
- var api = (options = {}) => {
398
+ const apiFactory = (options = {}) => {
391
399
  const { apiOptions } = options;
392
400
  if (!apiOptions.accessToken) {
393
401
  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");
394
402
  return;
395
403
  }
396
- const storyblokApi = new StoryblokClient(apiOptions);
404
+ const storyblokApi = new h(apiOptions);
397
405
  return { storyblokApi };
398
406
  };
399
407
  var editable = (blok) => {
@@ -819,8 +827,8 @@ function create_fragment(ctx) {
819
827
  function instance($$self, $$props, $$invalidate) {
820
828
  const omit_props_names = ["blok"];
821
829
  let $$restProps = compute_rest_props($$props, omit_props_names);
822
- let { blok } = $$props;
823
830
  let component;
831
+ let { blok } = $$props;
824
832
  if (blok) {
825
833
  component = getComponent(blok.component);
826
834
  } else {
@@ -883,4 +891,4 @@ storyblokInit({
883
891
  }
884
892
  return component;
885
893
  };
886
- export { StoryblokComponent, api as apiPlugin, getComponent, useStoryblokApi as getStoryblokApi, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
894
+ export { StoryblokComponent, apiFactory as apiPlugin, getComponent, useStoryblokApi as getStoryblokApi, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
@@ -0,0 +1,9 @@
1
+ import type { SbSDKOptions } from "@storyblok/js";
2
+ import type { SvelteComponent } from "svelte";
3
+ export interface SbSvelteComponentsMap {
4
+ [name: string]: typeof SvelteComponent;
5
+ }
6
+ export interface SbSvelteSDKOptions extends SbSDKOptions {
7
+ components?: SbSvelteComponentsMap;
8
+ }
9
+ export type { AlternateObject, Richtext, RichtextInstance, SbBlokData, SbBlokKeyDataTypes, SbSDKOptions, Stories, StoriesParams, Story, StoryData, StoryParams, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokCache, StoryblokCacheProvider, StoryblokClient, StoryblokComponentType, StoryblokConfig, StoryblokManagmentApiResult, StoryblokResult, apiPlugin, useStoryblokBridge, } from "@storyblok/js";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfigExport;
2
+ export default _default;
@@ -4,8 +4,15 @@ import {
4
4
  } from "@storyblok/js";
5
5
  export { useStoryblokBridge, apiPlugin } from "@storyblok/js";
6
6
 
7
- export const storyblokEditable = (node, value) => {
8
- const updateDom = (value) => {
7
+ import type {
8
+ SbSvelteSDKOptions,
9
+ SbSvelteComponentsMap,
10
+ StoryblokClient,
11
+ SbBlokData,
12
+ } from "./types";
13
+
14
+ export const storyblokEditable = (node: HTMLElement, value: SbBlokData) => {
15
+ const updateDom = (value: SbBlokData) => {
9
16
  const options = sbEdit(value);
10
17
  if (options["data-blok-c"]) {
11
18
  node.setAttribute("data-blok-c", options["data-blok-c"]);
@@ -17,15 +24,15 @@ export const storyblokEditable = (node, value) => {
17
24
  updateDom(value); // when is mounted
18
25
 
19
26
  return {
20
- update(newValue) {
27
+ update(newValue: SbBlokData) {
21
28
  // when value changes
22
29
  updateDom(newValue);
23
30
  },
24
31
  };
25
32
  };
26
33
 
27
- let storyblokApiInstance = null;
28
- export const useStoryblokApi = () => {
34
+ let storyblokApiInstance: StoryblokClient = null;
35
+ export const useStoryblokApi = (): StoryblokClient => {
29
36
  if (!storyblokApiInstance) {
30
37
  console.log(
31
38
  `You can't use getStoryblokApi if you're not loading apiPlugin.`
@@ -36,15 +43,17 @@ export const useStoryblokApi = () => {
36
43
 
37
44
  export { useStoryblokApi as getStoryblokApi };
38
45
 
39
- let componentsMap = null;
40
- export const storyblokInit = (options) => {
46
+ let componentsMap: SbSvelteComponentsMap = null;
47
+
48
+ export const storyblokInit = (options: SbSvelteSDKOptions) => {
41
49
  const { storyblokApi } = sbInit(options);
42
50
  storyblokApiInstance = storyblokApi;
43
51
  componentsMap = options.components || {};
44
52
  };
45
53
 
46
- export const getComponent = (componentName) => {
54
+ export const getComponent = (componentName: string) => {
47
55
  const component = componentsMap[componentName];
56
+
48
57
  if (!component) {
49
58
  console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
50
59
  storyblokInit({
@@ -59,4 +68,5 @@ storyblokInit({
59
68
  return component;
60
69
  };
61
70
 
71
+ export * from "./types";
62
72
  export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@storyblok/svelte",
3
- "version": "2.0.5",
3
+ "version": "2.1.2",
4
4
  "description": "Storyblok SDK to connect Storyblok with Svelte",
5
5
  "main": "./dist/storyblok-svelte.js",
6
6
  "module": "./dist/storyblok-svelte.mjs",
7
- "svelte": "index.js",
7
+ "svelte": "index.ts",
8
+ "types": "./dist/main.d.ts",
8
9
  "files": [
9
10
  "dist",
10
- "index.js",
11
+ "index.ts",
12
+ "types.ts",
11
13
  "StoryblokComponent.svelte"
12
14
  ],
13
15
  "exports": {
@@ -18,7 +20,7 @@
18
20
  },
19
21
  "scripts": {
20
22
  "dev": "vite build --watch",
21
- "build": "vite build",
23
+ "build": "vite build && tsc --project tsconfig.json && cp main.d.ts dist",
22
24
  "test": "npm run test:unit && npm run test:e2e",
23
25
  "test:unit": "jest __tests__",
24
26
  "test:e2e": "cypress run-ct",
@@ -26,18 +28,21 @@
26
28
  "prepublishOnly": "npm run build && cp ../README.md ./"
27
29
  },
28
30
  "dependencies": {
29
- "@storyblok/js": "^1.1.0"
31
+ "@storyblok/js": "^1.6.1"
30
32
  },
31
33
  "devDependencies": {
32
34
  "@babel/core": "^7.17.9",
33
35
  "@cypress/vite-dev-server": "^2.2.3",
36
+ "@tsconfig/svelte": "^3.0.0",
34
37
  "babel-jest": "^27.5.1",
35
38
  "cypress": "^9.6.0",
36
39
  "cypress-svelte-unit-test": "^3.3.4",
37
40
  "eslint-plugin-cypress": "^2.12.1",
38
41
  "eslint-plugin-jest": "^26.1.5",
39
42
  "jest": "^27.5.1",
40
- "vite": "^2.9.6"
43
+ "svelte-preprocess": "^4.10.7",
44
+ "typescript": "^4.7.3",
45
+ "vite": "^2.9.9"
41
46
  },
42
47
  "eslintConfig": {
43
48
  "env": {
package/types.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { SbSDKOptions } from "@storyblok/js";
2
+ import type { SvelteComponent } from "svelte";
3
+
4
+ export interface SbSvelteComponentsMap {
5
+ [name: string]: typeof SvelteComponent;
6
+ }
7
+
8
+ export interface SbSvelteSDKOptions extends SbSDKOptions {
9
+ components?: SbSvelteComponentsMap;
10
+ }
11
+
12
+ export type {
13
+ AlternateObject,
14
+ Richtext,
15
+ RichtextInstance,
16
+ SbBlokData,
17
+ SbBlokKeyDataTypes,
18
+ SbSDKOptions,
19
+ Stories,
20
+ StoriesParams,
21
+ Story,
22
+ StoryData,
23
+ StoryParams,
24
+ StoryblokBridgeConfigV2,
25
+ StoryblokBridgeV2,
26
+ StoryblokCache,
27
+ StoryblokCacheProvider,
28
+ StoryblokClient,
29
+ StoryblokComponentType,
30
+ StoryblokConfig,
31
+ StoryblokManagmentApiResult,
32
+ StoryblokResult,
33
+ apiPlugin,
34
+ useStoryblokBridge,
35
+ } from "@storyblok/js";