@storyblok/vue 9.3.3 → 9.4.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/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { default as StoryblokComponent } from './components/StoryblokComponent.v
4
4
  export { default as StoryblokRichText } from './components/StoryblokRichText.vue';
5
5
  export * from './composables/useStoryblokRichText';
6
6
  export * from './types';
7
- export { apiPlugin, BlockTypes, MarkTypes, renderRichText, richTextResolver, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, useStoryblokBridge, } from '@storyblok/js';
7
+ export { apiPlugin, BlockTypes, MarkTypes, renderRichText, richTextResolver, StoryblokClient, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, useStoryblokBridge, } from '@storyblok/js';
8
8
  export declare const useStoryblokApi: () => StoryblokClient;
9
9
  export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<Ref<ISbStoryData<import('storyblok-js-client').ISbComponentType<string> & {
10
10
  [index: string]: any;
@@ -4,5 +4,5 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(v,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.storyblokVue={},v.Vue))})(this,function(v,d){"use strict";var se=Object.defineProperty,ne=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t,r)=>ne(e,typeof t!="symbol"?t+"":t,r);let _=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),j=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ie=(e={})=>{const{custom:t,...r}=e,s={...r,...t};return Object.keys(s).map(n=>`${n}="${s[n]}"`).join(" ")},ae=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const C=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function ce(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function l(c,u,y,m,A){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):A.push(`${m}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:A,grayscale:U,quality:R,rotate:L}=c||{};u&&l(u,0,100,"blur",o),R&&l(R,0,100,"quality",o),y&&l(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),U&&o.push("grayscale()"),L&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${L})`),A&&["webp","png","jpeg"].includes(A)&&o.push(`format(${A})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(r>0||s>0)&&(a=`${a}${r}x${s}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function F(e,t={},r){const s=ie(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(oe.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function N(e={}){const t=new Map,{renderFn:r=F,textFn:s=le,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=r!==F,c=(i={})=>{const{textAlign:h,class:p,id:f,style:b,...w}=i,g=[];return b&&g.push(b.endsWith(";")?b:`${b};`),h&&g.push(`text-align: ${h};`),C({...w,class:p,id:f,...g.length>0?{style:g.join(" ")}:{}})},u=i=>(h,p)=>{const f=c(h.attrs);return p.render(i,f,h.children||null)},y=(i,h)=>{const{src:p,alt:f,title:b,srcset:w,sizes:g}=i.attrs||{};let S=p,T={};if(o){const{src:ze,attrs:qe}=ce(p,o);S=ze,T=qe}const O={src:S,alt:f,title:b,srcset:w,sizes:g,...T};return h.render("img",C(O))},m=(i,h)=>{const{level:p,...f}=i.attrs||{},b=c(f);return h.render(`h${p}`,b,i.children)},A=(i,h)=>{var p,f,b,w;const g=h.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(b=i.attrs)==null?void 0:b.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},g)},U=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),R=(i,h=!1)=>({text:p,attrs:f},b)=>{const{class:w,id:g,...S}=f||{},T=h?{class:w,id:g,style:ae(S)||void 0}:f||{};return b.render(i,C(T),p)},L=i=>M(i),Be=i=>{const{marks:h,...p}=i;if("text"in i){if(h)return h.reduce((b,w)=>L({...w,text:b}),L({...p,children:p.children}));const f=i.attrs||{};if(l){const b=t.get("txt")||0;t.set("txt",b+1),f.key=`txt-${b}`}return s(p.text,f)}return""},ee=(i,h)=>{const{linktype:p,href:f,anchor:b,...w}=i.attrs||{};let g="";switch(p){case j.ASSET:case j.URL:g=f;break;case j.EMAIL:g=`mailto:${f}`;break;case j.STORY:g=f,b&&(g=`${g}#${b}`);break;default:g=f;break}const S={...w};return g&&(S.href=g),h.render("a",S,i.text)},De=(i,h)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},He=(i,h)=>{const p=c(i.attrs),f=i.children||null;return h.render("table",p,h.render("tbody",{},f))},Ue=(i,h)=>{const p=c(i.attrs);return h.render("tr",p,i.children)},Me=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("td",C(O),i.children)},Ve=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("th",C(O),i.children)},te=new Map([[_.DOCUMENT,u("")],[_.HEADING,m],[_.PARAGRAPH,u("p")],[_.UL_LIST,u("ul")],[_.OL_LIST,u("ol")],[_.LIST_ITEM,u("li")],[_.IMAGE,y],[_.EMOJI,A],[_.CODE_BLOCK,U],[_.HR,u("hr")],[_.BR,u("br")],[_.QUOTE,u("blockquote")],[_.COMPONENT,De],[V.TEXT,Be],[$.LINK,ee],[$.ANCHOR,ee],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[_.TABLE,He],[_.TABLE_ROW,Ue],[_.TABLE_CELL,Me],[_.TABLE_HEADER,Ve]]),re=new Map([...te,...Object.entries(n).map(([i,h])=>[i,h])]),Fe=()=>({render:(i,h={},p)=>{if(l&&i){const f=t.get(i)||0;t.set(i,f+1),h.key=`${i}-${f}`}return r(i,h,p)},originalResolvers:te,mergedResolvers:re});function x(i){const h=re.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=Fe();if(i.type==="text")return h(i,p);const f=i.content?i.content.map(M):void 0;return h({...i,children:f},p)}function M(i){return i.type==="doc"?a?i.content.map(x):i.content.map(x).join(""):Array.isArray(i)?i.map(x):x(i)}return{render:M}}let z=!1;const q=[],ue=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?n():q.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{q.forEach(o=>o()),z=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var he=class extends Error{constructor(e){super(e),this.name="AbortError"}};function de(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,l=!1;const a=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&a(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new he("Throttle function aborted"))),s.length=0},c}var pe=de;const G=(e="")=>e.includes("/cdn/"),fe=(e,t=25,r=1)=>({...e,per_page:t,page:r}),ye=e=>new Promise(t=>setTimeout(t,e)),me=(e=0,t)=>Array.from({length:e},t),be=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return me(r,(n,o)=>o*s+e)},ge=async(e,t)=>Promise.all(e.map(t)),ke=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof o=="object"?a=B(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,s.push(a)}return s.join("&")},J=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var ve=class{constructor(e){k(this,"baseURL"),k(this,"timeout"),k(this,"headers"),k(this,"responseInterceptor"),k(this,"fetch"),k(this,"ejectInterceptor"),k(this,"url"),k(this,"parameters"),k(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},_e=ve;const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let P={};const E={};var Te=class{constructor(e,t){k(this,"client"),k(this,"maxRetries"),k(this,"retriesDelay"),k(this,"throttle"),k(this,"accessToken"),k(this,"cache"),k(this,"resolveCounter"),k(this,"relations"),k(this,"links"),k(this,"version"),k(this,"richTextResolver"),k(this,"resolveNestedRelations"),k(this,"stringifiedStoriesCache"),k(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${J(e.region)}/v1`:r=`${o}://${J(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,l])=>{s.set(o,l)}),s.has(K)||(s.set(K,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new _e({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return G(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;G(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await ge(be(a,u),m=>this.makeRequest(o,t,n,m+1,s));return ke([c,...y],m=>Object.values(m.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(l=>{this.iterateTree(l,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return a(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const A=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${A}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(u){if(u.response&&u.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(u)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...e.data.assets.find(n=>n.id===s.id),...s});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}},$e=Te;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!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 $e(t)}},Ae=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let Y="https://app.storyblok.com/f/storyblok-v2-latest.js";const W=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},Se=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:s,apiOptions:l};let u={};o.forEach(m=>{u={...u,...m(c)}}),a&&(Y=a);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&ue(Y),u};function Ee(e,t){return N(t).render(e)}const H=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,s=d.ref();t({value:s});const n=typeof d.resolveDynamicComponent(r.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(y,m)=>({name:m,fn:d.withCtx(A=>[d.renderSlot(c.$slots,m,d.normalizeProps(d.guardReactiveProps(A)))])}))]),1040))}}),Ce=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return d.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function X(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[_.COMPONENT]:Ce,...e.resolvers}};return N(t)}const Q=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=d.ref(),s=()=>r.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=X({resolvers:o??{}});r.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(s))}}),Ie={beforeMount(e,t){if(t.value){const r=Ae(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},Z=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
- `)};let I=null;const Le=()=>(I||Z("useStoryblokApi"),I),Oe=async(e,t={},r={})=>{const s=d.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,d.onMounted(()=>{s.value&&s.value.id&&W(s.value.id,n=>s.value=n,r)}),I){const{data:n}=await I.get(`cdn/stories/${e}`,t);s.value=n.story}else Z("useStoryblok");return s},je={install(e,t={}){e.directive("editable",Ie),e.component("StoryblokComponent",H),e.component("StoryblokRichText",Q),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Ne)));const{storyblokApi:r}=Se(t);I=r||null,e.provide("VueSDKOptions",t)}},Pe={class:"fallback-component"},xe={class:"component"},Ne=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[s,n]of t)r[s]=n;return r})(d.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(d.openBlock(),d.createElementBlock("div",Pe,[d.createElementVNode("p",null,[r[0]||(r[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",xe,d.toDisplayString(t.blok.component),1),r[1]||(r[1]=d.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=_,v.MarkTypes=$,v.StoryblokComponent=H,v.StoryblokRichText=Q,v.StoryblokVue=je,v.TextTypes=V,v.apiPlugin=Re,v.renderRichText=Ee,v.richTextResolver=N,v.useStoryblok=Oe,v.useStoryblokApi=Le,v.useStoryblokBridge=W,v.useStoryblokRichText=X,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
7
+ (function(v,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.storyblokVue={},v.Vue))})(this,function(v,d){"use strict";var ne=Object.defineProperty,oe=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t,r)=>oe(e,typeof t!="symbol"?t+"":t,r);let _=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),j=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const ie=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(e={})=>{const{custom:t,...r}=e,s={...r,...t};return Object.keys(s).map(n=>`${n}="${s[n]}"`).join(" ")},le=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ce(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const C=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function ue(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function a(c,u,y,m,S){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):S.push(`${m}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:S,grayscale:U,quality:R,rotate:L}=c||{};u&&a(u,0,100,"blur",o),R&&a(R,0,100,"quality",o),y&&a(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),U&&o.push("grayscale()"),L&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${L})`),S&&["webp","png","jpeg"].includes(S)&&o.push(`format(${S})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let l=`${e}/m/`;return(r>0||s>0)&&(l=`${l}${r}x${s}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:n}}function F(e,t={},r){const s=ae(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(ie.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function N(e={}){const t=new Map,{renderFn:r=F,textFn:s=ce,resolvers:n={},optimizeImages:o=!1,keyedResolvers:a=!1}=e,l=r!==F,c=(i={})=>{const{textAlign:h,class:p,id:f,style:b,...w}=i,g=[];return b&&g.push(b.endsWith(";")?b:`${b};`),h&&g.push(`text-align: ${h};`),C({...w,class:p,id:f,...g.length>0?{style:g.join(" ")}:{}})},u=i=>(h,p)=>{const f=c(h.attrs);return p.render(i,f,h.children||null)},y=(i,h)=>{const{src:p,alt:f,title:b,srcset:w,sizes:g}=i.attrs||{};let A=p,T={};if(o){const{src:ze,attrs:qe}=ue(p,o);A=ze,T=qe}const O={src:A,alt:f,title:b,srcset:w,sizes:g,...T};return h.render("img",C(O))},m=(i,h)=>{const{level:p,...f}=i.attrs||{},b=c(f);return h.render(`h${p}`,b,i.children)},S=(i,h)=>{var p,f,b,w;const g=h.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(b=i.attrs)==null?void 0:b.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},g)},U=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),R=(i,h=!1)=>({text:p,attrs:f},b)=>{const{class:w,id:g,...A}=f||{},T=h?{class:w,id:g,style:le(A)||void 0}:f||{};return b.render(i,C(T),p)},L=i=>M(i),Be=i=>{const{marks:h,...p}=i;if("text"in i){if(h)return h.reduce((b,w)=>L({...w,text:b}),L({...p,children:p.children}));const f=i.attrs||{};if(a){const b=t.get("txt")||0;t.set("txt",b+1),f.key=`txt-${b}`}return s(p.text,f)}return""},te=(i,h)=>{const{linktype:p,href:f,anchor:b,...w}=i.attrs||{};let g="";switch(p){case j.ASSET:case j.URL:g=f;break;case j.EMAIL:g=`mailto:${f}`;break;case j.STORY:g=f,b&&(g=`${g}#${b}`);break;default:g=f;break}const A={...w};return g&&(A.href=g),h.render("a",A,i.text)},De=(i,h)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},He=(i,h)=>{const p=c(i.attrs),f=i.children||null;return h.render("table",p,h.render("tbody",{},f))},Ue=(i,h)=>{const p=c(i.attrs);return h.render("tr",p,i.children)},Me=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...A}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...A,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("td",C(O),i.children)},Ve=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...A}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...A,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("th",C(O),i.children)},re=new Map([[_.DOCUMENT,u("")],[_.HEADING,m],[_.PARAGRAPH,u("p")],[_.UL_LIST,u("ul")],[_.OL_LIST,u("ol")],[_.LIST_ITEM,u("li")],[_.IMAGE,y],[_.EMOJI,S],[_.CODE_BLOCK,U],[_.HR,u("hr")],[_.BR,u("br")],[_.QUOTE,u("blockquote")],[_.COMPONENT,De],[V.TEXT,Be],[$.LINK,te],[$.ANCHOR,te],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[_.TABLE,He],[_.TABLE_ROW,Ue],[_.TABLE_CELL,Me],[_.TABLE_HEADER,Ve]]),se=new Map([...re,...Object.entries(n).map(([i,h])=>[i,h])]),Fe=()=>({render:(i,h={},p)=>{if(a&&i){const f=t.get(i)||0;t.set(i,f+1),h.key=`${i}-${f}`}return r(i,h,p)},originalResolvers:re,mergedResolvers:se});function x(i){const h=se.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=Fe();if(i.type==="text")return h(i,p);const f=i.content?i.content.map(M):void 0;return h({...i,children:f},p)}function M(i){return i.type==="doc"?l?i.content.map(x):i.content.map(x).join(""):Array.isArray(i)?i.map(x):x(i)}return{render:M}}let z=!1;const q=[],he=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?n():q.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{q.forEach(o=>o()),z=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var de=class extends Error{constructor(e){super(e),this.name="AbortError"}};function pe(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,a=!1;const l=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&l(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&l()});return c.abort=()=>{a=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new de("Throttle function aborted"))),s.length=0},c}var fe=pe;const G=(e="")=>e.includes("/cdn/"),ye=(e,t=25,r=1)=>({...e,per_page:t,page:r}),me=e=>new Promise(t=>setTimeout(t,e)),be=(e=0,t)=>Array.from({length:e},t),ge=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return be(r,(n,o)=>o*s+e)},ke=async(e,t)=>Promise.all(e.map(t)),ve=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const a=r?"":encodeURIComponent(n);let l;typeof o=="object"?l=B(o,t?t+encodeURIComponent(`[${a}]`):a,Array.isArray(o)):l=`${t?t+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(o)}`,s.push(l)}return s.join("&")},J=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var _e=class{constructor(e){k(this,"baseURL"),k(this,"timeout"),k(this,"headers"),k(this,"responseInterceptor"),k(this,"fetch"),k(this,"ejectInterceptor"),k(this,"url"),k(this,"parameters"),k(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let a=null;this.timeout&&(a=setTimeout(()=>n.abort(),this.timeout));try{const l=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&a&&clearTimeout(a);const c=await this._responseHandler(l);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(l){return{message:l}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},we=_e;const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},Te={PUBLISHED:"published"};let P={};const E={};var $e=class{constructor(e,t){k(this,"client"),k(this,"maxRetries"),k(this,"retriesDelay"),k(this,"throttle"),k(this,"accessToken"),k(this,"cache"),k(this,"resolveCounter"),k(this,"relations"),k(this,"links"),k(this,"version"),k(this,"richTextResolver"),k(this,"resolveNestedRelations"),k(this,"stringifiedStoriesCache"),k(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${J(e.region)}/v1`:r=`${o}://${J(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,a])=>{s.set(o,a)}),s.has(K)||(s.set(K,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=fe(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||Te.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new we({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return G(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,ye(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;G(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),a=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const l=1,c=await this.makeRequest(o,t,n,l,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await ke(ge(l,u),m=>this.makeRequest(o,t,n,m+1,s));return ve([c,...y],m=>Object.values(m.data[a]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((a,l)=>s(a,`${o}[${l}]`));else if(typeof n=="object")for(const a in n){const l=o?`${o}.${a}`:a;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,a,t,r),this._insertLinks(n,a,r)),s(n[a],l)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],a=50;for(let l=0;l<n;l+=a){const c=Math.min(n,l+a);o.push(e.link_uuids.slice(l,c))}for(let l=0;l<o.length;l++)(await this.getStories({per_page:a,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[l].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],a=50;for(let l=0;l<n;l+=a){const c=Math.min(n,l+a);o.push(e.rel_uuids.slice(l,c))}for(let l=0;l<o.length;l++)(await this.getStories({per_page:a,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[l].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const a in this.relations[r])this.iterateTree(this.relations[r][a],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(a=>{this.iterateTree(a,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const a=await o.get(n);if(a)return Promise.resolve(a)}return new Promise(async(a,l)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return l(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const S=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${S}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),a(y)}catch(u){if(u.response&&u.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await me(this.retriesDelay),this.cacheResponse(e,t,r).then(a).catch(l);l(u)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...e.data.assets.find(n=>n.id===s.id),...s});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}},Y=$e;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!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 Y(t)}},Se=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let W="https://app.storyblok.com/f/storyblok-v2-latest.js";const X=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),a=o!==null&&+o===e;if(!(!n||!a)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],l=>{var c;l&&(l.action==="input"&&((c=l.story)==null?void 0:c.id)===e?t(l.story):(l.action==="change"||l.action==="published")&&l.storyId===e&&window.location.reload())})})}},Ae=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:a={},bridgeUrl:l}=e;a.accessToken=a.accessToken||n;const c={bridge:s,apiOptions:a};let u={};o.forEach(m=>{u={...u,...m(c)}}),l&&(W=l);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&he(W),u};function Ee(e,t){return N(t).render(e)}const H=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var l;const r=e,s=d.ref();t({value:s});const n=typeof d.resolveDynamicComponent(r.blok.component)!="string",o=d.inject("VueSDKOptions"),a=d.ref((l=r.blok.component)==null?void 0:l.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(a.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(a.value)=="string"&&console.error(`Is the Fallback component "${a.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(a.value),d.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(y,m)=>({name:m,fn:d.withCtx(S=>[d.renderSlot(c.$slots,m,d.normalizeProps(d.guardReactiveProps(S)))])}))]),1040))}}),Ce=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return d.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function Q(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[_.COMPONENT]:Ce,...e.resolvers}};return N(t)}const Z=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=d.ref(),s=()=>r.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:a}=Q({resolvers:o??{}});r.value=a(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(s))}}),Ie={beforeMount(e,t){if(t.value){const r=Se(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},ee=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
+ `)};let I=null;const Le=()=>(I||ee("useStoryblokApi"),I),Oe=async(e,t={},r={})=>{const s=d.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,d.onMounted(()=>{s.value&&s.value.id&&X(s.value.id,n=>s.value=n,r)}),I){const{data:n}=await I.get(`cdn/stories/${e}`,t);s.value=n.story}else ee("useStoryblok");return s},je={install(e,t={}){e.directive("editable",Ie),e.component("StoryblokComponent",H),e.component("StoryblokRichText",Z),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Ne)));const{storyblokApi:r}=Ae(t);I=r||null,e.provide("VueSDKOptions",t)}},Pe={class:"fallback-component"},xe={class:"component"},Ne=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[s,n]of t)r[s]=n;return r})(d.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(d.openBlock(),d.createElementBlock("div",Pe,[d.createElementVNode("p",null,[r[0]||(r[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",xe,d.toDisplayString(t.blok.component),1),r[1]||(r[1]=d.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=_,v.MarkTypes=$,v.StoryblokClient=Y,v.StoryblokComponent=H,v.StoryblokRichText=Z,v.StoryblokVue=je,v.TextTypes=V,v.apiPlugin=Re,v.renderRichText=Ee,v.richTextResolver=N,v.useStoryblok=Oe,v.useStoryblokApi=Le,v.useStoryblokBridge=X,v.useStoryblokRichText=Q,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -15,7 +15,7 @@ let k = /* @__PURE__ */ function(e) {
15
15
  }({}), O = /* @__PURE__ */ function(e) {
16
16
  return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
17
17
  }({});
18
- const Ee = [
18
+ const Se = [
19
19
  "area",
20
20
  "base",
21
21
  "br",
@@ -30,7 +30,7 @@ const Ee = [
30
30
  "source",
31
31
  "track",
32
32
  "wbr"
33
- ], Se = (e = {}) => {
33
+ ], Ee = (e = {}) => {
34
34
  const { custom: t, ...r } = e, s = {
35
35
  ...r,
36
36
  ...t
@@ -48,18 +48,18 @@ function Ce(e, t) {
48
48
  };
49
49
  let r = 0, s = 0;
50
50
  const n = {}, o = [];
51
- function l(c, u, f, y, R) {
51
+ function a(c, u, f, y, R) {
52
52
  typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : R.push(`${y}(${c})`);
53
53
  }
54
54
  if (typeof t == "object") {
55
55
  if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (n.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete n.width, delete n.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
56
- const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: P, quality: T, rotate: E } = c || {};
57
- u && l(u, 0, 100, "blur", o), T && l(T, 0, 100, "quality", o), f && l(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), P && o.push("grayscale()"), E && [
56
+ const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: P, quality: T, rotate: S } = c || {};
57
+ u && a(u, 0, 100, "blur", o), T && a(T, 0, 100, "quality", o), f && a(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), P && o.push("grayscale()"), S && [
58
58
  0,
59
59
  90,
60
60
  180,
61
61
  270
62
- ].includes(t.filters.rotate || 0) && o.push(`rotate(${E})`), R && [
62
+ ].includes(t.filters.rotate || 0) && o.push(`rotate(${S})`), R && [
63
63
  "webp",
64
64
  "png",
65
65
  "jpeg"
@@ -76,21 +76,21 @@ function Ce(e, t) {
76
76
  }
77
77
  }).join(", ")), t.sizes && (n.sizes = t.sizes.join(", "));
78
78
  }
79
- let a = `${e}/m/`;
80
- return (r > 0 || s > 0) && (a = `${a}${r}x${s}/`), o.length > 0 && (a = `${a}filters:${o.join(":")}`), {
81
- src: a,
79
+ let l = `${e}/m/`;
80
+ return (r > 0 || s > 0) && (l = `${l}${r}x${s}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
81
+ src: l,
82
82
  attrs: n
83
83
  };
84
84
  }
85
85
  function V(e, t = {}, r) {
86
- const s = Se(t), n = s ? `${e} ${s}` : e, o = Array.isArray(r) ? r.join("") : r || "";
86
+ const s = Ee(t), n = s ? `${e} ${s}` : e, o = Array.isArray(r) ? r.join("") : r || "";
87
87
  if (e) {
88
- if (Ee.includes(e)) return `<${n}>`;
88
+ if (Se.includes(e)) return `<${n}>`;
89
89
  } else return o;
90
90
  return `<${n}>${o}</${e}>`;
91
91
  }
92
92
  function ee(e = {}) {
93
- const t = /* @__PURE__ */ new Map(), { renderFn: r = V, textFn: s = Ie, resolvers: n = {}, optimizeImages: o = !1, keyedResolvers: l = !1 } = e, a = r !== V, c = (i = {}) => {
93
+ const t = /* @__PURE__ */ new Map(), { renderFn: r = V, textFn: s = Ie, resolvers: n = {}, optimizeImages: o = !1, keyedResolvers: a = !1 } = e, l = r !== V, c = (i = {}) => {
94
94
  const { textAlign: h, class: d, id: p, style: m, ...v } = i, g = [];
95
95
  return m && g.push(m.endsWith(";") ? m : `${m};`), h && g.push(`text-align: ${h};`), L({
96
96
  ...v,
@@ -108,7 +108,7 @@ function ee(e = {}) {
108
108
  const { src: ue, attrs: he } = Ce(d, o);
109
109
  $ = ue, w = he;
110
110
  }
111
- const S = {
111
+ const E = {
112
112
  src: $,
113
113
  alt: p,
114
114
  title: m,
@@ -116,7 +116,7 @@ function ee(e = {}) {
116
116
  sizes: g,
117
117
  ...w
118
118
  };
119
- return h.render("img", L(S));
119
+ return h.render("img", L(E));
120
120
  }, y = (i, h) => {
121
121
  const { level: d, ...p } = i.attrs || {}, m = c(p);
122
122
  return h.render(`h${d}`, m, i.children);
@@ -141,18 +141,18 @@ function ee(e = {}) {
141
141
  style: Le($) || void 0
142
142
  } : p || {};
143
143
  return m.render(i, L(w), d);
144
- }, E = (i) => N(i), se = (i) => {
144
+ }, S = (i) => N(i), se = (i) => {
145
145
  const { marks: h, ...d } = i;
146
146
  if ("text" in i) {
147
- if (h) return h.reduce((m, v) => E({
147
+ if (h) return h.reduce((m, v) => S({
148
148
  ...v,
149
149
  text: m
150
- }), E({
150
+ }), S({
151
151
  ...d,
152
152
  children: d.children
153
153
  }));
154
154
  const p = i.attrs || {};
155
- if (l) {
155
+ if (a) {
156
156
  const m = t.get("txt") || 0;
157
157
  t.set("txt", m + 1), p.key = `txt-${m}`;
158
158
  }
@@ -195,23 +195,23 @@ function ee(e = {}) {
195
195
  }, ae = (i, h) => {
196
196
  const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...$ } = i.attrs || {}, w = [];
197
197
  m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
198
- const S = {
198
+ const E = {
199
199
  ...$,
200
200
  ...d > 1 ? { colspan: d } : {},
201
201
  ...p > 1 ? { rowspan: p } : {},
202
202
  ...w.length > 0 ? { style: w.join(" ") } : {}
203
203
  };
204
- return h.render("td", L(S), i.children);
204
+ return h.render("td", L(E), i.children);
205
205
  }, le = (i, h) => {
206
206
  const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...$ } = i.attrs || {}, w = [];
207
207
  m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
208
- const S = {
208
+ const E = {
209
209
  ...$,
210
210
  ...d > 1 ? { colspan: d } : {},
211
211
  ...p > 1 ? { rowspan: p } : {},
212
212
  ...w.length > 0 ? { style: w.join(" ") } : {}
213
213
  };
214
- return h.render("th", L(S), i.children);
214
+ return h.render("th", L(E), i.children);
215
215
  }, M = /* @__PURE__ */ new Map([
216
216
  [k.DOCUMENT, u("")],
217
217
  [k.HEADING, y],
@@ -245,7 +245,7 @@ function ee(e = {}) {
245
245
  [k.TABLE_HEADER, le]
246
246
  ]), F = new Map([...M, ...Object.entries(n).map(([i, h]) => [i, h])]), ce = () => ({
247
247
  render: (i, h = {}, d) => {
248
- if (l && i) {
248
+ if (a && i) {
249
249
  const p = t.get(i) || 0;
250
250
  t.set(i, p + 1), h.key = `${i}-${p}`;
251
251
  }
@@ -267,7 +267,7 @@ function ee(e = {}) {
267
267
  }, d);
268
268
  }
269
269
  function N(i) {
270
- return i.type === "doc" ? a ? i.content.map(C) : i.content.map(C).join("") : Array.isArray(i) ? i.map(C) : C(i);
270
+ return i.type === "doc" ? l ? i.content.map(C) : i.content.map(C).join("") : Array.isArray(i) ? i.map(C) : C(i);
271
271
  }
272
272
  return { render: N };
273
273
  }
@@ -301,8 +301,8 @@ function xe(e, t, r) {
301
301
  if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
302
302
  if (!Number.isFinite(r)) throw new TypeError("Expected `interval` to be a finite number");
303
303
  const s = [];
304
- let n = [], o = 0, l = !1;
305
- const a = async () => {
304
+ let n = [], o = 0, a = !1;
305
+ const l = async () => {
306
306
  o++;
307
307
  const u = s.shift();
308
308
  if (u) try {
@@ -312,18 +312,18 @@ function xe(e, t, r) {
312
312
  u.reject(y);
313
313
  }
314
314
  const f = setTimeout(() => {
315
- o--, s.length > 0 && a(), n = n.filter((y) => y !== f);
315
+ o--, s.length > 0 && l(), n = n.filter((y) => y !== f);
316
316
  }, r);
317
317
  n.includes(f) || n.push(f);
318
- }, c = (...u) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, y) => {
318
+ }, c = (...u) => a ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, y) => {
319
319
  s.push({
320
320
  resolve: f,
321
321
  reject: y,
322
322
  args: u
323
- }), o < t && a();
323
+ }), o < t && l();
324
324
  });
325
325
  return c.abort = () => {
326
- l = !0, n.forEach(clearTimeout), n = [], s.forEach((u) => u.reject(() => new je("Throttle function aborted"))), s.length = 0;
326
+ a = !0, n.forEach(clearTimeout), n = [], s.forEach((u) => u.reject(() => new je("Throttle function aborted"))), s.length = 0;
327
327
  }, c;
328
328
  }
329
329
  var Pe = xe;
@@ -340,9 +340,9 @@ const G = (e = "") => e.includes("/cdn/"), Ne = (e, t = 25, r = 1) => ({
340
340
  if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
341
341
  const o = e[n];
342
342
  if (o == null) continue;
343
- const l = r ? "" : encodeURIComponent(n);
344
- let a;
345
- typeof o == "object" ? a = D(o, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(o)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(o)}`, s.push(a);
343
+ const a = r ? "" : encodeURIComponent(n);
344
+ let l;
345
+ typeof o == "object" ? l = D(o, t ? t + encodeURIComponent(`[${a}]`) : a, Array.isArray(o)) : l = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(o)}`, s.push(l);
346
346
  }
347
347
  return s.join("&");
348
348
  }, J = (e) => {
@@ -394,21 +394,21 @@ var Fe = class {
394
394
  let t = `${this.baseURL}${this.url}`, r = null;
395
395
  e === "get" ? t = `${this.baseURL}${this.url}?${D(this.parameters)}` : r = JSON.stringify(this.parameters);
396
396
  const s = new URL(t), n = new AbortController(), { signal: o } = n;
397
- let l;
398
- this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
397
+ let a = null;
398
+ this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
399
399
  try {
400
- const a = await this.fetch(`${s}`, {
400
+ const l = await this.fetch(`${s}`, {
401
401
  method: e,
402
402
  headers: this.headers,
403
403
  body: r,
404
404
  signal: o,
405
405
  ...this.fetchOptions
406
406
  });
407
- this.timeout && clearTimeout(l);
408
- const c = await this._responseHandler(a);
407
+ this.timeout && a && clearTimeout(a);
408
+ const c = await this._responseHandler(l);
409
409
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
410
- } catch (a) {
411
- return { message: a };
410
+ } catch (l) {
411
+ return { message: l };
412
412
  }
413
413
  }
414
414
  setFetchOptions(e = {}) {
@@ -470,8 +470,8 @@ var qe = class {
470
470
  e.oauthToken ? r = `${o}://${J(e.region)}/v1` : r = `${o}://${J(e.region)}/v2`;
471
471
  }
472
472
  const s = new Headers();
473
- s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([o, l]) => {
474
- s.set(o, l);
473
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([o, a]) => {
474
+ s.set(o, a);
475
475
  }), s.has(K) || (s.set(K, U.defaultAgentName), s.set(U.defaultAgentVersion, U.packageVersion));
476
476
  let n = 5;
477
477
  e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Pe(this.throttledRequest.bind(this), n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ze.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ve({
@@ -500,10 +500,10 @@ var qe = class {
500
500
  return this.cacheResponse(s, n, void 0, r);
501
501
  }
502
502
  async getAll(e, t = {}, r, s) {
503
- const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), l = r ?? o.substring(o.lastIndexOf("/") + 1);
503
+ const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), a = r ?? o.substring(o.lastIndexOf("/") + 1);
504
504
  t.version = t.version || this.version;
505
- const a = 1, c = await this.makeRequest(o, t, n, a, s), u = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, f = await Be(De(a, u), (y) => this.makeRequest(o, t, n, y + 1, s));
506
- return Me([c, ...f], (y) => Object.values(y.data[l]));
505
+ const l = 1, c = await this.makeRequest(o, t, n, l, s), u = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, f = await Be(De(l, u), (y) => this.makeRequest(o, t, n, y + 1, s));
506
+ return Me([c, ...f], (y) => Object.values(y.data[a]));
507
507
  }
508
508
  post(e, t = {}, r) {
509
509
  const s = `/${e}`;
@@ -597,10 +597,10 @@ var qe = class {
597
597
  iterateTree(e, t, r) {
598
598
  const s = (n, o = "") => {
599
599
  if (!(!n || n._stopResolving)) {
600
- if (Array.isArray(n)) n.forEach((l, a) => s(l, `${o}[${a}]`));
601
- else if (typeof n == "object") for (const l in n) {
602
- const a = o ? `${o}.${l}` : l;
603
- (n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, r), this._insertLinks(n, l, r)), s(n[l], a);
600
+ if (Array.isArray(n)) n.forEach((a, l) => s(a, `${o}[${l}]`));
601
+ else if (typeof n == "object") for (const a in n) {
602
+ const l = o ? `${o}.${a}` : a;
603
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, a, t, r), this._insertLinks(n, a, r)), s(n[a], l);
604
604
  }
605
605
  }
606
606
  };
@@ -609,18 +609,18 @@ var qe = class {
609
609
  async resolveLinks(e, t, r) {
610
610
  let s = [];
611
611
  if (e.link_uuids) {
612
- const n = e.link_uuids.length, o = [], l = 50;
613
- for (let a = 0; a < n; a += l) {
614
- const c = Math.min(n, a + l);
615
- o.push(e.link_uuids.slice(a, c));
612
+ const n = e.link_uuids.length, o = [], a = 50;
613
+ for (let l = 0; l < n; l += a) {
614
+ const c = Math.min(n, l + a);
615
+ o.push(e.link_uuids.slice(l, c));
616
616
  }
617
- for (let a = 0; a < o.length; a++)
617
+ for (let l = 0; l < o.length; l++)
618
618
  (await this.getStories({
619
- per_page: l,
619
+ per_page: a,
620
620
  language: t.language,
621
621
  version: t.version,
622
622
  starts_with: t.starts_with,
623
- by_uuids: o[a].join(",")
623
+ by_uuids: o[l].join(",")
624
624
  })).data.stories.forEach((c) => {
625
625
  s.push(c);
626
626
  });
@@ -635,18 +635,18 @@ var qe = class {
635
635
  async resolveRelations(e, t, r) {
636
636
  let s = [];
637
637
  if (e.rel_uuids) {
638
- const n = e.rel_uuids.length, o = [], l = 50;
639
- for (let a = 0; a < n; a += l) {
640
- const c = Math.min(n, a + l);
641
- o.push(e.rel_uuids.slice(a, c));
638
+ const n = e.rel_uuids.length, o = [], a = 50;
639
+ for (let l = 0; l < n; l += a) {
640
+ const c = Math.min(n, l + a);
641
+ o.push(e.rel_uuids.slice(l, c));
642
642
  }
643
- for (let a = 0; a < o.length; a++)
643
+ for (let l = 0; l < o.length; l++)
644
644
  (await this.getStories({
645
- per_page: l,
645
+ per_page: a,
646
646
  language: t.language,
647
647
  version: t.version,
648
648
  starts_with: t.starts_with,
649
- by_uuids: o[a].join(","),
649
+ by_uuids: o[l].join(","),
650
650
  excluding_fields: t.excluding_fields
651
651
  })).data.stories.forEach((c) => {
652
652
  s.push(c);
@@ -677,9 +677,9 @@ var qe = class {
677
677
  "story",
678
678
  "url",
679
679
  "link"
680
- ].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations) for (const l in this.relations[r]) this.iterateTree(this.relations[r][l], o, r);
681
- e.story ? this.iterateTree(e.story, o, r) : e.stories.forEach((l) => {
682
- this.iterateTree(l, o, r);
680
+ ].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations) for (const a in this.relations[r]) this.iterateTree(this.relations[r][a], o, r);
681
+ e.story ? this.iterateTree(e.story, o, r) : e.stories.forEach((a) => {
682
+ this.iterateTree(a, o, r);
683
683
  }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
684
684
  }
685
685
  async cacheResponse(e, t, r, s) {
@@ -688,14 +688,14 @@ var qe = class {
688
688
  params: t
689
689
  }), o = this.cacheProvider();
690
690
  if (t.version === "published" && e !== "/cdn/spaces/me") {
691
- const l = await o.get(n);
692
- if (l) return Promise.resolve(l);
691
+ const a = await o.get(n);
692
+ if (a) return Promise.resolve(a);
693
693
  }
694
- return new Promise(async (l, a) => {
694
+ return new Promise(async (a, l) => {
695
695
  var c;
696
696
  try {
697
697
  const u = await this.throttle("get", e, t, s);
698
- if (u.status !== 200) return a(u);
698
+ if (u.status !== 200) return l(u);
699
699
  let f = {
700
700
  data: u.data,
701
701
  headers: u.headers
@@ -709,11 +709,11 @@ var qe = class {
709
709
  }
710
710
  t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, f);
711
711
  const y = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
712
- return t.token && f.data.cv && (y && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), l(f);
712
+ return t.token && f.data.cv && (y && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), a(f);
713
713
  } catch (u) {
714
714
  if (u.response && u.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
715
- return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await He(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(a);
716
- a(u);
715
+ return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await He(this.retriesDelay), this.cacheResponse(e, t, r).then(a).catch(l);
716
+ l(u);
717
717
  }
718
718
  });
719
719
  }
@@ -816,16 +816,16 @@ const Ke = (e, t, r = {}) => {
816
816
  var s;
817
817
  const n = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
818
818
  "_storyblok"
819
- ), l = o !== null && +o === e;
820
- if (!(!n || !l)) {
819
+ ), a = o !== null && +o === e;
820
+ if (!(!n || !a)) {
821
821
  if (!e) {
822
822
  console.warn("Story ID is not defined. Please provide a valid ID.");
823
823
  return;
824
824
  }
825
825
  window.storyblokRegisterEvent(() => {
826
- new window.StoryblokBridge(r).on(["input", "published", "change"], (a) => {
826
+ new window.StoryblokBridge(r).on(["input", "published", "change"], (l) => {
827
827
  var c;
828
- a && (a.action === "input" && ((c = a.story) == null ? void 0 : c.id) === e ? t(a.story) : (a.action === "change" || a.action === "published") && a.storyId === e && window.location.reload());
828
+ l && (l.action === "input" && ((c = l.story) == null ? void 0 : c.id) === e ? t(l.story) : (l.action === "change" || l.action === "published") && l.storyId === e && window.location.reload());
829
829
  });
830
830
  });
831
831
  }
@@ -835,15 +835,15 @@ const Ke = (e, t, r = {}) => {
835
835
  bridge: s,
836
836
  accessToken: n,
837
837
  use: o = [],
838
- apiOptions: l = {},
839
- bridgeUrl: a
838
+ apiOptions: a = {},
839
+ bridgeUrl: l
840
840
  } = e;
841
- l.accessToken = l.accessToken || n;
842
- const c = { bridge: s, apiOptions: l };
841
+ a.accessToken = a.accessToken || n;
842
+ const c = { bridge: s, apiOptions: a };
843
843
  let u = {};
844
844
  o.forEach((y) => {
845
845
  u = { ...u, ...y(c) };
846
- }), a && (Y = a);
846
+ }), l && (Y = l);
847
847
  const f = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
848
848
  return s !== !1 && f && Oe(Y), u;
849
849
  };
@@ -856,17 +856,17 @@ const te = /* @__PURE__ */ W({
856
856
  blok: {}
857
857
  },
858
858
  setup(e, { expose: t }) {
859
- var a;
859
+ var l;
860
860
  const r = e, s = x();
861
861
  t({
862
862
  value: s
863
863
  });
864
- const n = typeof H(r.blok.component) != "string", o = de("VueSDKOptions"), l = x((a = r.blok.component) == null ? void 0 : a.replace(/_/g, "-"));
865
- return !n && o && (o.enableFallbackComponent ? (l.value = o.customFallbackComponent ?? "FallbackComponent", typeof H(l.value) == "string" && console.error(
866
- `Is the Fallback component "${l.value}" registered properly?`
864
+ const n = typeof H(r.blok.component) != "string", o = de("VueSDKOptions"), a = x((l = r.blok.component) == null ? void 0 : l.replace(/_/g, "-"));
865
+ return !n && o && (o.enableFallbackComponent ? (a.value = o.customFallbackComponent ?? "FallbackComponent", typeof H(a.value) == "string" && console.error(
866
+ `Is the Fallback component "${a.value}" registered properly?`
867
867
  )) : console.error(
868
868
  `Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`
869
- )), (c, u) => (Q(), X(H(l.value), pe({
869
+ )), (c, u) => (Q(), X(H(a.value), pe({
870
870
  ref_key: "blokRef",
871
871
  ref: s
872
872
  }, { ...c.$props, ...c.$attrs }), fe({ _: 2 }, [
@@ -914,10 +914,10 @@ const Qe = /* @__PURE__ */ W({
914
914
  setup(e) {
915
915
  const t = e, r = x(), s = () => r.value;
916
916
  return we([() => t.doc, () => t.resolvers], ([n, o]) => {
917
- const { render: l } = Xe({
917
+ const { render: a } = Xe({
918
918
  resolvers: o ?? {}
919
919
  });
920
- r.value = l(n);
920
+ r.value = a(n);
921
921
  }, {
922
922
  immediate: !0,
923
923
  deep: !0
@@ -965,6 +965,7 @@ const st = () => (I || re("useStoryblokApi"), I), nt = async (e, t = {}, r = {})
965
965
  export {
966
966
  k as BlockTypes,
967
967
  _ as MarkTypes,
968
+ Ge as StoryblokClient,
968
969
  te as StoryblokComponent,
969
970
  Qe as StoryblokRichText,
970
971
  ot as StoryblokVue,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
3
  "type": "module",
4
- "version": "9.3.3",
4
+ "version": "9.4.1",
5
5
  "description": "SDK to integrate Storyblok into your project using Vue.",
6
6
  "author": "Storyblok",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "vue": ">=3.4"
32
32
  },
33
33
  "dependencies": {
34
- "@storyblok/js": "4.3.2"
34
+ "@storyblok/js": "4.4.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-typescript": "^12.1.2",