@storyblok/vue 11.0.0 → 11.0.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.
@@ -4,5 +4,5 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(y,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(y=typeof globalThis<"u"?globalThis:y||self,a(y.storyblokVue={},y.Vue))})(this,(function(y,a){"use strict";var pt=Object.defineProperty;var gt=(y,a,g)=>a in y?pt(y,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):y[a]=g;var d=(y,a,g)=>gt(y,typeof a!="symbol"?a+"":a,g);const g=(e="")=>e.includes("/cdn/"),he=(e,t=25,r=1)=>({...e,per_page:t,page:r}),fe=e=>new Promise(t=>setTimeout(t,e)),de=(e=0,t)=>Array.from({length:e},t),ye=(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return de(r,(s,i)=>i*n+e)},pe=async(e,t)=>Promise.all(e.map(t)),ge=(e=[],t)=>e.map(t).reduce((r,n)=>[...r,...n],[]),z=e=>{if(/%[0-9A-F]{2}/i.test(e))try{return decodeURIComponent(e)}catch{return e}return e},N=(e,t,r)=>{const n=[];for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];if(i==null)continue;const l=r?"":encodeURIComponent(s);let o;typeof i=="object"?o=N(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):o=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,n.push(o)}return n.join("&")},F=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 me=class{constructor(e){d(this,"baseURL");d(this,"timeout");d(this,"headers");d(this,"responseInterceptor");d(this,"fetch");d(this,"ejectInterceptor");d(this,"url");d(this,"parameters");d(this,"fetchOptions");this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}patch(e,t){return this.url=e,this.parameters=t,this._methodHandler("patch")}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(n=>{r.data=n});for(const n of e.headers.entries())t[n[0]]=n[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}?${N(this.parameters)}`:r=JSON.stringify(this.parameters);const n=new URL(t),s=new AbortController,{signal:i}=s;let l=null;this.timeout&&(l=setTimeout(()=>s.abort(),this.timeout));try{const o=await this.fetch(`${n}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const c=await this._responseHandler(o);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(o){return o.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:o.message||o.toString()||"An unknown error occurred"}}}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,n)=>{if(t.test(`${e.status}`))return r(e);n({message:this._normalizeErrorMessage(e.data),status:e.status,response:e})})}};const be={PUBLISHED:"published"},ke=25,O={SMALL:25,MEDIUM:50,LARGE:75},k={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},D=1e3,w=3;function _e(e,t){const r=e.includes("/cdn/stories/"),n=e.split("/").length>3&&!e.endsWith("/cdn/stories"),s="find_by"in t;return r&&n||s}function Re(e){return e<=O.SMALL?k.SINGLE_OR_SMALL:e<=O.MEDIUM?k.MEDIUM:e<=O.LARGE?k.LARGE:k.VERY_LARGE}function S(e,t,r={},n){return r.userRateLimit!==void 0?Math.min(r.userRateLimit,D):r.serverHeadersRateLimit!==void 0?Math.min(r.serverHeadersRateLimit,D):n!==void 0?n:!e||!t||_e(e,t)?k.SINGLE_OR_SMALL:Re(t.per_page||ke)}function we(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],r=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!r)return null;const n={};if(t){const s=t.match(/r=(\d+)/);s&&(n.remaining=Number.parseInt(s[1],10))}if(r){const s=r.match(/q=(\d+)/);s&&(n.max=Number.parseInt(s[1],10))}return Object.keys(n).length>0?n:null}function Se(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Ae=class extends Error{constructor(e){super(e),this.name="AbortError"}};function ve(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 n=[];let s=[],i=0,l=!1;const o=async()=>{i++;const u=n.shift();if(u)try{const h=await e(...u.args);u.resolve(h)}catch(h){u.reject(h)}const f=setTimeout(()=>{i--,n.length>0&&o(),s=s.filter(h=>h!==f)},r);s.includes(f)||s.push(f)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,h)=>{n.push({resolve:f,reject:h,args:u}),i<t&&o()});return c.abort=()=>{l=!0,s.forEach(clearTimeout),s=[],n.forEach(u=>u.reject(()=>new Ae("Throttle function aborted"))),n.length=0},c}var $e=class{constructor(e,t=1e3){d(this,"queues");d(this,"interval");d(this,"throttledRequestFn");this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=ve(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let T={};const m={};var G=class{constructor(e,t){d(this,"client");d(this,"maxRetries");d(this,"retriesDelay");d(this,"throttleManager");d(this,"accessToken");d(this,"cache");d(this,"resolveCounter");d(this,"relations");d(this,"links");d(this,"version");d(this,"rateLimitConfig");d(this,"cvMode");d(this,"richTextResolver");d(this,"resolveNestedRelations");d(this,"stringifiedStoriesCache");d(this,"inlineAssets");var s;let r=e.endpoint||t;if(!r){const i=e.https===!1?"http":"https";e.oauthToken?r=`${i}://${F(e.region)}/v1`:r=`${i}://${F(e.region)}/v2`}const n=new Headers;!e.oauthToken&&typeof window<"u"||n.set("Content-Type","application/json"),n.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{n.set(i,l)}),e.oauthToken&&n.set("Authorization",e.oauthToken),this.rateLimitConfig=Se(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=e.retriesDelay??300,this.throttleManager=new $e(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.cvMode=((s=e.cache)==null?void 0:s.cv)??"auto",this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||be.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new me({baseURL:r,timeout:e.timeout||0,headers:n,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),!e.cv&&this.cvMode==="auto"&&(e.cv=m[e.token]),Array.isArray(e.resolve_relations)?e.resolve_relations=e.resolve_relations.map(z).join(","):typeof e.resolve_relations=="string"&&(e.resolve_relations=z(e.resolve_relations)),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return g(e)?this.parseParams(t):t}makeRequest(e,t,r,n,s){const i=this.factoryParamOptions(e,he(t,r,n));return this.cacheResponse(e,i,void 0,s)}get(e,t={},r){t||(t={});const n=`/${e}`;g(n)&&(t.version=t.version||this.version);const s=this.factoryParamOptions(n,t);return this.cacheResponse(n,s,void 0,r)}async getAll(e,t={},r,n){const s=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1);t.version=t.version||this.version;const o=1,c=await this.makeRequest(i,t,s,o,n);return ge([c,...await pe(ye(o,c.total?Math.ceil(c.total/(c.perPage||s)):1),u=>this.makeRequest(i,t,s,u+1,n))],u=>Object.values(u.data[l]))}post(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"post",n,t,r)}put(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"put",n,t,r)}patch(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"patch",n,t,r)}delete(e,t={},r){t||(t={});const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"delete",n,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 n=e[t];n&&n.fieldtype==="multilink"&&n.linktype==="story"&&typeof n.id=="string"&&this.links[r][n.id]?n.story=this._cleanCopy(this.links[r][n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[r][n.uuid]&&(n.story=this._cleanCopy(this.links[r][n.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 n=e[t];typeof n=="string"?e[t]=this.getStoryReference(r,n):Array.isArray(n)&&(e[t]=n.map(s=>this.getStoryReference(r,s)).filter(Boolean))}_insertRelations(e,t,r,n){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,n);return}const s=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(s):r===s)&&this._resolveField(e,t,n)}iterateTree(e,t,r){const n=(s,i="")=>{if(!(!s||s._stopResolving)){if(Array.isArray(s))s.forEach((l,o)=>n(l,`${i}[${o}]`));else if(typeof s=="object")for(const l in s){const o=i?`${i}.${l}`:l;(s.component&&s._uid||s.type==="link")&&(this._insertRelations(s,l,t,r),this._insertLinks(s,l,r)),n(s[l],o)}}};n(e.content)}async resolveLinks(e,t,r){let n=[];if(e.link_uuids){const s=e.link_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.link_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(",")})).data.stories.forEach(c=>{n.push(c)})}else n=e.links;n.forEach(s=>{this.links[r][s.uuid]={...s,_stopResolving:!0}})}async resolveRelations(e,t,r){let n=[];if(e.rel_uuids){const s=e.rel_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.rel_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{n.push(c)});n.length>0&&(e.rels=n,delete e.rel_uuids)}else n=e.rels;n&&n.length>0&&n.forEach(s=>{this.relations[r][s.uuid]={...s,_stopResolving:!0}})}async resolveStories(e,t,r){var s,i;let n=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=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||(i=e.link_uuids)!=null&&i.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],n,r);e.story?this.iterateTree(e.story,n,r):e.stories.forEach(l=>{this.iterateTree(l,n,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,n){const s=N({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await i.get(s);if(c)return Promise.resolve(c)}const l=!g(e)&&this.rateLimitConfig.isManagementApi?w:void 0,o=S(e,t,this.rateLimitConfig,l);return new Promise(async(c,u)=>{var f;try{const h=await this.throttleManager.execute(o,"get",e,t,n);if(h.status!==200)return u(h);let p={data:h.data,headers:h.headers};const b=we(h.headers);if((b==null?void 0:b.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=b.max),(f=h.headers)!=null&&f["per-page"]&&(p=Object.assign({},p,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),p.data.story||p.data.stories){const P=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${P}`),p=await this.processInlineAssets(p)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(s,p);const M=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(M&&m[t.token]&&m[t.token]!==p.data.cv&&await this.flushCache(),m[t.token]=p.data.cv),c(p)}catch(h){if(h.response&&h.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 fe(this.retriesDelay),this.cacheResponse(e,t,r).then(c).catch(u);u(h)}})}throttledRequest(e,t,r,n){return this.client.setFetchOptions(n),this.client[e](t,r)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(m[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(T[e])},getAll(){return Promise.resolve(T)},set(e,t){return T[e]=t,Promise.resolve(void 0)},flush(){return T={},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(s=>t(s));let n={...r};n.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(n={...e.data.assets.find(s=>s.id===n.id),...n});for(const s in n)typeof n[s]=="object"&&(n[s]=t(n[s]));return n};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}};function j(e,t){if(!t)return{src:e,attrs:{}};let r=0,n=0;const s={},i=[];function l(c,u,f,h,p){typeof c!="number"||c<=u||c>=f?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):p.push(`${h}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(s.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?(s.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete s.width,delete s.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(s.loading=t.loading),t.class&&(s.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:f,fill:h,format:p,grayscale:b,quality:M,rotate:P}=c||{};u&&l(u,0,100,"blur",i),M&&l(M,0,100,"quality",i),f&&l(f,0,100,"brightness",i),h&&i.push(`fill(${h})`),b&&i.push("grayscale()"),P&&[0,90,180,270].includes(t.filters.rotate||0)&&i.push(`rotate(${P})`),p&&["webp","png","jpeg"].includes(p)&&i.push(`format(${p})`)}t.srcset&&(s.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${i.length>0?`filters:${i.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,f]=c;return`${e}/m/${u}x${f}/${i.length>0?`filters:${i.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(s.sizes=t.sizes.join(", "))}let o=`${e}/m/`;return(r>0||n>0)&&(o=`${o}${r}x${n}/`),i.length>0&&(o=`${o}filters:${i.join(":")}`),{src:o,attrs:s}}function I(e,t){if(e===t)return!0;if(e==null||t===null||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length!==t.length?!1:e.every((s,i)=>I(s,t[i]));const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&I(e[s],t[s]))}const Te=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"];function Le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Ce(){const e=new Map;return t=>{const r=(e.get(t)||0)+1;return e.set(t,r),`${t}-${r}`}}const L={paragraph:{tag:"p",content:!0},doc:null,text:null,emoji:{tag:"img",attrs:{style:"width: 1.25em; height: 1.25em; vertical-align: text-top;",draggable:"false",loading:"lazy"}},blockquote:{tag:"blockquote",content:!0},heading:{resolve:e=>`h${typeof(e==null?void 0:e.level)=="number"?Math.min(6,Math.max(1,e.level)):1}`},bullet_list:{tag:"ul",content:!0},ordered_list:{tag:"ol",attrs:{order:1},content:!0},list_item:{tag:"li",content:!0},code_block:{tag:"pre",children:[{tag:"code",content:!0}]},hard_break:{tag:"br"},horizontal_rule:{tag:"hr"},image:{tag:"img"},table:{tag:"table",content:!0},tableRow:{tag:"tr",content:!0},tableCell:{tag:"td",attrs:{colspan:1,rowspan:1},content:!0},tableHeader:{tag:"th",attrs:{colspan:1,rowspan:1},content:!0},blok:null},Ee={link:{tag:"a",attrs:{rel:"noopener noreferrer nofollow",linktype:"url",custom:{}},content:!0},bold:{tag:"strong",content:!0},italic:{tag:"em",content:!0},strike:{tag:"s",content:!0},underline:{tag:"u",content:!0},code:{tag:"code",content:!0},superscript:{tag:"sup",content:!0},subscript:{tag:"sub",content:!0},highlight:{tag:"mark",content:!0},textStyle:{tag:"span",content:!0},anchor:{tag:"span",content:!0},styled:{tag:"span",content:!0}};function Me(e){return Object.entries(e).filter(([,t])=>x(t)).map(([t,r])=>`${Oe(t)}: ${r};`).join(" ")}function Pe(e){return e.split(";").map(t=>t.trim()).filter(Boolean).reduce((t,r)=>{const n=r.indexOf(":");if(n===-1)return t;const s=r.slice(0,n).trim(),i=r.slice(n+1).trim();return!s||!i||(t[Ne(s)]=i),t},{})}function Ne(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function Oe(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function x(e){return e!=null&&e!==""}const je={highlight:{color:"backgroundColor"},textStyle:{color:"color"},paragraph:{textAlign:"textAlign"},heading:{textAlign:"textAlign"},tableCell:{backgroundColor:"backgroundColor",colwidth:"width"},tableHeader:{colwidth:"width"}},Ie={fallbackImage:"src",body:"data-body",colspan:"colSpan",rowspan:"rowSpan",name:"data-name",emoji:"data-emoji",order:"start"},xe=new Set(["level","linktype","uuid","anchor","meta_data","copyright","source"]),qe=new Set(["colspan","rowspan","order"]);function He(e){const{linktype:t,href:r,anchor:n}=e;if(t==="story")return`${typeof r=="string"?r:""}${typeof n=="string"&&n?`#${n}`:""}`;if(t==="email"&&typeof r=="string")return`mailto:${r.replace(/^mailto:/,"")}`}function Ue(e){const t={};let r={};if(!(e in L))return{staticAttrs:r,staticStyle:t};const n=L[e];if(!n||!("attrs"in n))return{staticAttrs:r,staticStyle:t};const s=n.attrs||{},i="style"in s&&typeof s.style=="string"?s.style:"",{style:l,...o}=s;return r=o,i&&Object.assign(t,Pe(i)),{staticAttrs:r,staticStyle:t}}function Ve(e){return Array.isArray(e)?e[0]!=null?`${e[0]}px`:void 0:typeof e=="number"||typeof e=="string"?e:String(e)}function ze(e,t,r,n,s,i,l){if(!x(t)||xe.has(e)||qe.has(e)&&t===1)return;if(e in n){const c=n[e],u=Ve(t);u!==void 0&&x(u)&&(i[c]=u);return}const o=s[e]??e;if(o==="custom"&&r==="link"&&typeof t=="object"&&t!==null){for(const[c,u]of Object.entries(t))l[c]=String(u);return}if(typeof t=="object"&&t!==null){l[o]=JSON.stringify(t);return}l[o]=t}function _(e,t={},r={}){const{staticAttrs:n,staticStyle:s}=Ue(e),i={...s},l={},o=je[e]||{},c={...Ie,...r},u={...n,...t};for(const[f,h]of Object.entries(u))ze(f,h,e,o,c,i,l);if(e==="link"){const f=He(t);f!==void 0&&(l.href=f)}return{...l,...Object.keys(i).length>0&&{style:i}}}const Fe=e=>String(e).replace(/[&"'<>]/g,t=>{switch(t){case"&":return"&amp;";case'"':return"&quot;";case"'":return"&#39;";case"<":return"&lt;";case">":return"&gt;";default:return t}});function C(e){if(e.type!=="text"||!e.marks)return null;for(const t of e.marks)if(t.type==="link")return t;return null}function B(e,t){return!e||!t?!1:I(e.attrs??{},t.attrs??{})}function De(e){return e.type!=="text"||!e.marks?[]:e.marks.filter(t=>t.type!=="link")}function Ge(e){const t=[];let r=0;const n=e.length;for(;r<n;){const s=e[r],i=C(s);if(i){const l=[s];let o=r+1;for(;o<n&&B(i,C(e[o]));)l.push(e[o]),o++;t.push({nodes:l,linkMark:i,_key:`group-link-${r}`}),r=o}else t.push({nodes:[s],linkMark:null,_key:`group-node-${r}`}),r++}return t}function K(e){const t=e.content;if(!(t!=null&&t.length))return!1;for(const r of t)if(r.type!=="tableHeader")return!1;return!0}function J(e){if(!(e!=null&&e.length))return{headerRows:[],bodyRows:[]};let t=0;for(;t<e.length&&K(e[t]);)t++;return{headerRows:e.slice(0,t),bodyRows:e.slice(t)}}function W(e,t=!1){if(!e)return[];if(Array.isArray(e))return e;const r=e.type==="doc"?e.content||[]:[e];return t?Y(r,Ce()):r}function Y(e,t){return e.map(r=>{var n;return{...r,_key:t(r.type),marks:(n=r.marks)==null?void 0:n.map(s=>({...s,_key:t(s.type)})),content:r.content?Y(r.content,t):void 0}})}function R(e){const t=e.type,r=L[t]??Ee[t];return r?"resolve"in r&&typeof r.resolve=="function"?r.resolve(e.attrs):"tag"in r&&typeof r.tag=="string"?r.tag:null:null}function E(e){return Te.includes(e)}function Q(e){const t=L[e.type];return t&&"children"in t?t.children:null}function Be(e){let t="";for(const r in e){const n=e[r];n!=null&&(t+=` ${r}="${Fe(n)}"`)}return t}function Ke(e,t){const r=W(e);return r!=null&&r.length?X(r,t):""}function q(e,t){var o;if(e.type==="text")return Z(e,e.marks,t);const r=e.content?X(e.content,t):"",n=(o=t==null?void 0:t.renderers)==null?void 0:o[e.type];if(n)return n({...e,children:r,context:t});if(e.type==="blok")return console.warn('"blok" nodes require a custom renderer in renderRichText.'),"";const s=R(e);if(!s)return r;if(e.type==="image"&&(t!=null&&t.optimizeImage))return Je(e,t);const i=A(e.type,e.attrs);if(E(s))return`<${s}${i}>`;if(e.type==="table")return`<${s}${i}>${Qe(e.content,t)}</${s}>`;const l=Q(e);return l?`<${s}>${ee(e.type,l,e.attrs,r)}</${s}>`:`<${s}${i}>${r}</${s}>`}function Je(e,t){const r=e.attrs,n=r==null?void 0:r.src;let s=r;if(n){const{src:l,attrs:o}=j(n,t.optimizeImage);s={...r,src:l,...o}}const i=A("image",s);return i?`<img${i}>`:"<img>"}function X(e,t){let r="",n=0;const s=e.length;for(;n<s;){const i=e[n],l=C(i);if(l){let o=n+1;for(;o<s&&B(l,C(e[o]));)o++;r+=Ye(e,n,o,l,t),n=o}else r+=q(i,t),n++}return r}function Z(e,t,r){let n=Le(e.text);if(!(t!=null&&t.length))return n;for(const s of t)n=We(n,s,r);return n}function We(e,t,r){var i;const n=(i=r==null?void 0:r.renderers)==null?void 0:i[t.type];if(n)return n({...t,children:e});const s=R(t);return s?`<${s}${A(t.type,t.attrs)}>${e}</${s}>`:e}function Ye(e,t,r,n,s){var c,u;let i="";for(let f=t;f<r;f++){const h=e[f],p=(c=h.marks)==null?void 0:c.filter(b=>b.type!=="link");i+=Z(h,p,s)}const l=(u=s==null?void 0:s.renderers)==null?void 0:u[n.type];if(l)return l({...n,children:i});const o=R(n);return o?`<${o}${A(n.type,n.attrs)}>${i}</${o}>`:i}function Qe(e,t){if(!(e!=null&&e.length))return"";let r=0;for(;r<e.length&&K(e[r]);)r++;let n="";if(r>0){n+="<thead>";for(let s=0;s<r;s++)n+=q(e[s],t);n+="</thead>"}if(r<e.length){n+="<tbody>";for(let s=r;s<e.length;s++)n+=q(e[s],t);n+="</tbody>"}return n}function ee(e,t,r,n){let s="";for(const i of t){const{tag:l,children:o,attrs:c}=i,u=A(e,{...c,...r});if(E(l))s+=`<${l}${u}>`;else{const f=o?ee(e,o,r,n):n;s+=`<${l}${u}>${f}</${l}>`}}return s}function A(e,t){const r=_(e,t,{colspan:"colspan",rowspan:"rowspan"}),n=r.style,s={...r};return n&&(s.style=Me(n)),Be(s)}let te=!1;const re=[],Xe=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=s=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}te?s():re.push(s)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=s=>r(s),n.onload=s=>{re.forEach(i=>i()),te=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),Ze=(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 G(t)}},et=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 ne="https://app.storyblok.com/f/storyblok-v2-latest.js";const se=(e,t,r={})=>{var n;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((n=window.location)==null?void 0:n.href).searchParams.get("_storyblok"),l=i!==null&&+i===e;if(!(!s||!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"],o=>{var c;o&&(o.action==="input"&&((c=o.story)==null?void 0:c.id)===e?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===e&&window.location.reload())})})}},tt=(e={})=>{var t,r;const{bridge:n,accessToken:s,use:i=[],apiOptions:l={},bridgeUrl:o}=e;l.accessToken=l.accessToken||s;const c={bridge:n,apiOptions:l};let u={};i.forEach(h=>{u={...u,...h(c)}}),o&&(ne=o);const f=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return n!==!1&&f&&Xe(ne),u},H=a.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var c;const r=e,n=a.useSlots(),s=a.ref();t({value:s});const i=typeof a.resolveDynamicComponent(r.blok.component)!="string",l=a.inject("VueSDKOptions"),o=a.ref((c=r.blok.component)==null?void 0:c.replace(/_/g,"-"));return!i&&l&&(l.enableFallbackComponent?(o.value=l.customFallbackComponent??"FallbackComponent",typeof a.resolveDynamicComponent(o.value)=="string"&&console.error(`Is the Fallback component "${o.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});"?`)),(u,f)=>(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.value),a.mergeProps({ref_key:"blokRef",ref:s},{...u.$props,...u.$attrs}),a.createSlots({_:2},[a.renderList(Object.keys(a.unref(n)),h=>({name:h,fn:a.withCtx(p=>[a.renderSlot(u.$slots,h,a.normalizeProps(a.guardReactiveProps(p)))])}))]),1040))}}),ie=a.defineComponent({name:"StoryblokBlokRenderer",props:{type:{type:String,required:!0},attrs:{type:Object,required:!1},content:{type:Array,required:!1},marks:{type:Array,required:!1},_key:{type:String,required:!1},context:{type:Object,required:!1}},setup(e){return()=>{var t;return Array.isArray((t=e.attrs)==null?void 0:t.body)?e.attrs.body.map((r,n)=>a.h(H,{blok:r,key:r._uid||n})):null}}});function U(e,t){return t==null?void 0:t[e]}function oe(e){return function(r){if(!r)return null;const n=W(r,!0);return n.length?v(n,e):null}}function v(e,t){return Ge(e).map((n,s)=>n.linkMark?rt(n.nodes,n.linkMark,t,n._key||s):V(n.nodes[0],t,n._key||s))}function rt(e,t,r,n){const s=e.map((o,c)=>{const u=o,f=De(o);return ce(u,f,r)}),i=U(t.type,r.components);if(i)return a.h(i,{key:n,...t},{default:()=>s});const l=R(t);return l?a.h(l,{key:n,..._(t.type,t.attrs)},s):s.length>0?s[0]:a.createTextVNode("")}function V(e,t,r){if(e.type==="text")return it(e,t);const n=U(e.type,t.components);if(n)return a.h(n,{key:r,...e,context:t},e.content?{default:()=>v(e.content,t)}:void 0);const s=R(e);if(!s){const c=e.content?v(e.content,t):[];return c.length===0?a.createTextVNode(""):c.length===1?c[0]:a.h("div",{key:r},c)}if(e.type==="image"&&t.optimizeImage)return nt(e,t,r);const i=_(e.type,e.attrs);if(E(s))return a.h(s,{key:r,...i});if(e.type==="table")return st(e,t,r,s,i);const l=Q(e);if(l){const c=e.content?v(e.content,t):[],u=le(e.type,l,e.attrs,c);return a.h(s,{key:r},u)}const o=e.content?v(e.content,t):[];return a.h(s,{key:r,...i},o)}function nt(e,t,r){const n=e.attrs,s=n==null?void 0:n.src;if(!s)return a.createTextVNode("");const{src:i,attrs:l}=j(s,t.optimizeImage),o=_("image",{...n,src:i,...l});return a.h("img",{key:r,...o})}function st(e,t,r,n,s){const{headerRows:i,bodyRows:l}=J(e.content),o=[];return i.length>0&&o.push(a.h("thead",{key:"thead"},i.map((c,u)=>V(c,t,u)))),l.length>0&&o.push(a.h("tbody",{key:"tbody"},l.map((c,u)=>V(c,t,u)))),a.h(n,{key:r,...s},o)}function le(e,t,r,n){return t.map((s,i)=>{const{tag:l,children:o,attrs:c}=s,u={...c,...r},f=_(e,u);if(E(l))return a.h(l,{key:i,...f});const h=o?le(e,o,r,n):n;return a.h(l,{key:i,...f},h)})}function it(e,t,r){return ce(e,e.marks,t)}function ce(e,t,r,n){let s=e.text;if(t!=null&&t.length)for(const i of t)s=ot(s,i,r);return typeof s=="string"?a.createTextVNode(s):s}function ot(e,t,r){const n=U(t.type,r.components);if(n){const i=typeof e=="string"?a.createTextVNode(e):e;return a.h(n,{...t},{default:()=>[i]})}const s=R(t);return s?a.h(s,_(t.type,t.attrs),typeof e=="string"?e:[e]):typeof e=="string"?a.createTextVNode(e):e}const ae=a.defineComponent({name:"StoryblokRichText",props:{document:{type:Object,required:!1},optimizeImage:{type:[Boolean,Object],required:!1},components:{type:Object,required:!1}},setup(e){const t=oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}});return()=>t(e.document)}});function lt(e){return oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}})}const ct={beforeMount(e,t){if(t.value){const r=et(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"))}}},ue=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
7
+ (function(y,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(y=typeof globalThis<"u"?globalThis:y||self,a(y.storyblokVue={},y.Vue))})(this,(function(y,a){"use strict";var pt=Object.defineProperty;var gt=(y,a,g)=>a in y?pt(y,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):y[a]=g;var d=(y,a,g)=>gt(y,typeof a!="symbol"?a+"":a,g);const g=(e="")=>e.includes("/cdn/"),he=(e,t=25,r=1)=>({...e,per_page:t,page:r}),fe=e=>new Promise(t=>setTimeout(t,e)),de=(e=0,t)=>Array.from({length:e},t),ye=(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return de(r,(s,i)=>i*n+e)},pe=async(e,t)=>Promise.all(e.map(t)),ge=(e=[],t)=>e.map(t).reduce((r,n)=>[...r,...n],[]),z=e=>{if(/%[0-9A-F]{2}/i.test(e))try{return decodeURIComponent(e)}catch{return e}return e},N=(e,t,r)=>{const n=[];for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];if(i==null)continue;const l=r?"":encodeURIComponent(s);let o;typeof i=="object"?o=N(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):o=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,n.push(o)}return n.join("&")},F=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 me=class{constructor(e){d(this,"baseURL");d(this,"timeout");d(this,"headers");d(this,"responseInterceptor");d(this,"fetch");d(this,"ejectInterceptor");d(this,"url");d(this,"parameters");d(this,"fetchOptions");this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}patch(e,t){return this.url=e,this.parameters=t,this._methodHandler("patch")}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(n=>{r.data=n});for(const n of e.headers.entries())t[n[0]]=n[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}?${N(this.parameters)}`:r=JSON.stringify(this.parameters);const n=new URL(t),s=new AbortController,{signal:i}=s;let l=null;this.timeout&&(l=setTimeout(()=>s.abort(),this.timeout));try{const o=await this.fetch(`${n}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const c=await this._responseHandler(o);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(o){return o.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:o.message||o.toString()||"An unknown error occurred"}}}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,n)=>{if(t.test(`${e.status}`))return r(e);n({message:this._normalizeErrorMessage(e.data),status:e.status,response:e})})}};const be={PUBLISHED:"published"},ke=25,O={SMALL:25,MEDIUM:50,LARGE:75},k={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},D=1e3,w=3;function _e(e,t){const r=e.includes("/cdn/stories/"),n=e.split("/").length>3&&!e.endsWith("/cdn/stories"),s="find_by"in t;return r&&n||s}function Re(e){return e<=O.SMALL?k.SINGLE_OR_SMALL:e<=O.MEDIUM?k.MEDIUM:e<=O.LARGE?k.LARGE:k.VERY_LARGE}function S(e,t,r={},n){return r.userRateLimit!==void 0?Math.min(r.userRateLimit,D):r.serverHeadersRateLimit!==void 0?Math.min(r.serverHeadersRateLimit,D):n!==void 0?n:!e||!t||_e(e,t)?k.SINGLE_OR_SMALL:Re(t.per_page||ke)}function we(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],r=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!r)return null;const n={};if(t){const s=t.match(/r=(\d+)/);s&&(n.remaining=Number.parseInt(s[1],10))}if(r){const s=r.match(/q=(\d+)/);s&&(n.max=Number.parseInt(s[1],10))}return Object.keys(n).length>0?n:null}function Se(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Ae=class extends Error{constructor(e){super(e),this.name="AbortError"}};function ve(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 n=[];let s=[],i=0,l=!1;const o=async()=>{i++;const u=n.shift();if(u)try{const h=await e(...u.args);u.resolve(h)}catch(h){u.reject(h)}const f=setTimeout(()=>{i--,n.length>0&&o(),s=s.filter(h=>h!==f)},r);s.includes(f)||s.push(f)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,h)=>{n.push({resolve:f,reject:h,args:u}),i<t&&o()});return c.abort=()=>{l=!0,s.forEach(clearTimeout),s=[],n.forEach(u=>u.reject(()=>new Ae("Throttle function aborted"))),n.length=0},c}var $e=class{constructor(e,t=1e3){d(this,"queues");d(this,"interval");d(this,"throttledRequestFn");this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=ve(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let T={};const m={};var G=class{constructor(e,t){d(this,"client");d(this,"maxRetries");d(this,"retriesDelay");d(this,"throttleManager");d(this,"accessToken");d(this,"cache");d(this,"resolveCounter");d(this,"relations");d(this,"links");d(this,"version");d(this,"rateLimitConfig");d(this,"cvMode");d(this,"richTextResolver");d(this,"resolveNestedRelations");d(this,"stringifiedStoriesCache");d(this,"inlineAssets");var s;let r=e.endpoint||t;if(!r){const i=e.https===!1?"http":"https";e.oauthToken?r=`${i}://${F(e.region)}/v1`:r=`${i}://${F(e.region)}/v2`}const n=new Headers;!e.oauthToken&&typeof window<"u"||n.set("Content-Type","application/json"),n.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{n.set(i,l)}),e.oauthToken&&n.set("Authorization",e.oauthToken),this.rateLimitConfig=Se(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=e.retriesDelay??300,this.throttleManager=new $e(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.cvMode=((s=e.cache)==null?void 0:s.cv)??"auto",this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||be.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new me({baseURL:r,timeout:e.timeout||0,headers:n,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),!e.cv&&this.cvMode==="auto"&&(e.cv=m[e.token]),Array.isArray(e.resolve_relations)?e.resolve_relations=e.resolve_relations.map(z).join(","):typeof e.resolve_relations=="string"&&(e.resolve_relations=z(e.resolve_relations)),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return g(e)?this.parseParams(t):t}makeRequest(e,t,r,n,s){const i=this.factoryParamOptions(e,he(t,r,n));return this.cacheResponse(e,i,void 0,s)}get(e,t={},r){t||(t={});const n=`/${e}`;g(n)&&(t.version=t.version||this.version);const s=this.factoryParamOptions(n,t);return this.cacheResponse(n,s,void 0,r)}async getAll(e,t={},r,n){const s=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1);t.version=t.version||this.version;const o=1,c=await this.makeRequest(i,t,s,o,n);return ge([c,...await pe(ye(o,c.total?Math.ceil(c.total/(c.perPage||s)):1),u=>this.makeRequest(i,t,s,u+1,n))],u=>Object.values(u.data[l]))}post(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"post",n,t,r)}put(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"put",n,t,r)}patch(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"patch",n,t,r)}delete(e,t={},r){t||(t={});const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"delete",n,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 n=e[t];n&&n.fieldtype==="multilink"&&n.linktype==="story"&&typeof n.id=="string"&&this.links[r][n.id]?n.story=this._cleanCopy(this.links[r][n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[r][n.uuid]&&(n.story=this._cleanCopy(this.links[r][n.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 n=e[t];typeof n=="string"?e[t]=this.getStoryReference(r,n):Array.isArray(n)&&(e[t]=n.map(s=>this.getStoryReference(r,s)).filter(Boolean))}_insertRelations(e,t,r,n){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,n);return}const s=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(s):r===s)&&this._resolveField(e,t,n)}iterateTree(e,t,r){const n=(s,i="")=>{if(!(!s||s._stopResolving)){if(Array.isArray(s))s.forEach((l,o)=>n(l,`${i}[${o}]`));else if(typeof s=="object")for(const l in s){const o=i?`${i}.${l}`:l;(s.component&&s._uid||s.type==="link")&&(this._insertRelations(s,l,t,r),this._insertLinks(s,l,r)),n(s[l],o)}}};n(e.content)}async resolveLinks(e,t,r){let n=[];if(e.link_uuids){const s=e.link_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.link_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(",")})).data.stories.forEach(c=>{n.push(c)})}else n=e.links;n.forEach(s=>{this.links[r][s.uuid]={...s,_stopResolving:!0}})}async resolveRelations(e,t,r){let n=[];if(e.rel_uuids){const s=e.rel_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.rel_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{n.push(c)});n.length>0&&(e.rels=n,delete e.rel_uuids)}else n=e.rels;n&&n.length>0&&n.forEach(s=>{this.relations[r][s.uuid]={...s,_stopResolving:!0}})}async resolveStories(e,t,r){var s,i;let n=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=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||(i=e.link_uuids)!=null&&i.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],n,r);e.story?this.iterateTree(e.story,n,r):e.stories.forEach(l=>{this.iterateTree(l,n,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,n){const s=N({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await i.get(s);if(c)return Promise.resolve(c)}const l=!g(e)&&this.rateLimitConfig.isManagementApi?w:void 0,o=S(e,t,this.rateLimitConfig,l);return new Promise(async(c,u)=>{var f;try{const h=await this.throttleManager.execute(o,"get",e,t,n);if(h.status!==200)return u(h);let p={data:h.data,headers:h.headers};const b=we(h.headers);if((b==null?void 0:b.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=b.max),(f=h.headers)!=null&&f["per-page"]&&(p=Object.assign({},p,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),p.data.story||p.data.stories){const P=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${P}`),p=await this.processInlineAssets(p)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(s,p);const M=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(M&&m[t.token]&&m[t.token]!==p.data.cv&&await this.flushCache(),m[t.token]=p.data.cv),c(p)}catch(h){if(h.response&&h.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 fe(this.retriesDelay),this.cacheResponse(e,t,r).then(c).catch(u);u(h)}})}throttledRequest(e,t,r,n){return this.client.setFetchOptions(n),this.client[e](t,r)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(m[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(T[e])},getAll(){return Promise.resolve(T)},set(e,t){return T[e]=t,Promise.resolve(void 0)},flush(){return T={},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(s=>t(s));let n={...r};n.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(n={...e.data.assets.find(s=>s.id===n.id),...n});for(const s in n)typeof n[s]=="object"&&(n[s]=t(n[s]));return n};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}};function j(e,t){if(!t)return{src:e,attrs:{}};let r=0,n=0;const s={},i=[];function l(c,u,f,h,p){typeof c!="number"||c<=u||c>=f?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):p.push(`${h}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(s.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?(s.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete s.width,delete s.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(s.loading=t.loading),t.class&&(s.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:f,fill:h,format:p,grayscale:b,quality:M,rotate:P}=c||{};u&&l(u,0,100,"blur",i),M&&l(M,0,100,"quality",i),f&&l(f,0,100,"brightness",i),h&&i.push(`fill(${h})`),b&&i.push("grayscale()"),P&&[0,90,180,270].includes(t.filters.rotate||0)&&i.push(`rotate(${P})`),p&&["webp","png","jpeg"].includes(p)&&i.push(`format(${p})`)}t.srcset&&(s.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${i.length>0?`filters:${i.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,f]=c;return`${e}/m/${u}x${f}/${i.length>0?`filters:${i.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(s.sizes=t.sizes.join(", "))}let o=`${e}/m/`;return(r>0||n>0)&&(o=`${o}${r}x${n}/`),i.length>0&&(o=`${o}filters:${i.join(":")}`),{src:o,attrs:s}}function I(e,t){if(e===t)return!0;if(e==null||t===null||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length!==t.length?!1:e.every((s,i)=>I(s,t[i]));const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&I(e[s],t[s]))}const Te=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"];function Le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Ce(){const e=new Map;return t=>{const r=(e.get(t)||0)+1;return e.set(t,r),`${t}-${r}`}}const L={paragraph:{tag:"p",content:!0},doc:null,text:null,emoji:{tag:"img",attrs:{style:"width: 1.25em; height: 1.25em; vertical-align: text-top;",draggable:"false",loading:"lazy"}},blockquote:{tag:"blockquote",content:!0},heading:{resolve:e=>`h${typeof(e==null?void 0:e.level)=="number"?Math.min(6,Math.max(1,e.level)):1}`},bullet_list:{tag:"ul",content:!0},ordered_list:{tag:"ol",attrs:{order:1},content:!0},list_item:{tag:"li",content:!0},code_block:{tag:"pre",children:[{tag:"code",content:!0}]},hard_break:{tag:"br"},horizontal_rule:{tag:"hr"},image:{tag:"img"},table:{tag:"table",content:!0},tableRow:{tag:"tr",content:!0},tableCell:{tag:"td",attrs:{colspan:1,rowspan:1},content:!0},tableHeader:{tag:"th",attrs:{colspan:1,rowspan:1},content:!0},blok:null},Ee={link:{tag:"a",attrs:{rel:"noopener noreferrer nofollow",linktype:"url",custom:{}},content:!0},bold:{tag:"strong",content:!0},italic:{tag:"em",content:!0},strike:{tag:"s",content:!0},underline:{tag:"u",content:!0},code:{tag:"code",content:!0},superscript:{tag:"sup",content:!0},subscript:{tag:"sub",content:!0},highlight:{tag:"mark",content:!0},textStyle:{tag:"span",content:!0},anchor:{tag:"span",content:!0},styled:{tag:"span",content:!0}};function Me(e){return Object.entries(e).filter(([,t])=>x(t)).map(([t,r])=>`${Oe(t)}: ${r};`).join(" ")}function Pe(e){return e.split(";").map(t=>t.trim()).filter(Boolean).reduce((t,r)=>{const n=r.indexOf(":");if(n===-1)return t;const s=r.slice(0,n).trim(),i=r.slice(n+1).trim();return!s||!i||(t[Ne(s)]=i),t},{})}function Ne(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function Oe(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function x(e){return e!=null&&e!==""}const je={highlight:{color:"backgroundColor"},textStyle:{color:"color"},paragraph:{textAlign:"textAlign"},heading:{textAlign:"textAlign"},tableCell:{backgroundColor:"backgroundColor",colwidth:"width"},tableHeader:{colwidth:"width"}},Ie={fallbackImage:"src",body:"data-body",colspan:"colSpan",rowspan:"rowSpan",name:"data-name",emoji:"data-emoji",order:"start"},xe=new Set(["level","linktype","uuid","anchor","meta_data","copyright","source"]),qe=new Set(["colspan","rowspan","order"]);function He(e){const{linktype:t,href:r,anchor:n}=e;if(t==="story")return`${typeof r=="string"?r:""}${typeof n=="string"&&n?`#${n}`:""}`;if(t==="email"&&typeof r=="string")return`mailto:${r.replace(/^mailto:/,"")}`}function Ue(e){const t={};let r={};if(!(e in L))return{staticAttrs:r,staticStyle:t};const n=L[e];if(!n||!("attrs"in n))return{staticAttrs:r,staticStyle:t};const s=n.attrs||{},i="style"in s&&typeof s.style=="string"?s.style:"",{style:l,...o}=s;return r=o,i&&Object.assign(t,Pe(i)),{staticAttrs:r,staticStyle:t}}function Ve(e){return Array.isArray(e)?e[0]!=null?`${e[0]}px`:void 0:typeof e=="number"||typeof e=="string"?e:String(e)}function ze(e,t,r,n,s,i,l){if(!x(t)||xe.has(e)||qe.has(e)&&t===1)return;if(e in n){const c=n[e],u=Ve(t);u!==void 0&&x(u)&&(i[c]=u);return}const o=s[e]??e;if(o==="custom"&&r==="link"&&typeof t=="object"&&t!==null){for(const[c,u]of Object.entries(t))l[c]=String(u);return}if(typeof t=="object"&&t!==null){l[o]=JSON.stringify(t);return}l[o]=t}function _(e,t={},r={}){const{staticAttrs:n,staticStyle:s}=Ue(e),i={...s},l={},o=je[e]||{},c={...Ie,...r},u={...n,...t};for(const[f,h]of Object.entries(u))ze(f,h,e,o,c,i,l);if(e==="link"){const f=He(t);f!==void 0&&(l.href=f)}return{...l,...Object.keys(i).length>0&&{style:i}}}const Fe=e=>String(e).replace(/[&"'<>]/g,t=>{switch(t){case"&":return"&amp;";case'"':return"&quot;";case"'":return"&#39;";case"<":return"&lt;";case">":return"&gt;";default:return t}});function C(e){if(e.type!=="text"||!e.marks)return null;for(const t of e.marks)if(t.type==="link")return t;return null}function B(e,t){return!e||!t?!1:I(e.attrs??{},t.attrs??{})}function De(e){return e.type!=="text"||!e.marks?[]:e.marks.filter(t=>t.type!=="link")}function Ge(e){const t=[];let r=0;const n=e.length;for(;r<n;){const s=e[r],i=C(s);if(i){const l=[s];let o=r+1;for(;o<n&&B(i,C(e[o]));)l.push(e[o]),o++;t.push({nodes:l,linkMark:i,_key:`group-link-${r}`}),r=o}else t.push({nodes:[s],linkMark:null,_key:`group-node-${r}`}),r++}return t}function K(e){const t=e.content;if(!(t!=null&&t.length))return!1;for(const r of t)if(r.type!=="tableHeader")return!1;return!0}function J(e){if(!(e!=null&&e.length))return{headerRows:[],bodyRows:[]};let t=0;for(;t<e.length&&K(e[t]);)t++;return{headerRows:e.slice(0,t),bodyRows:e.slice(t)}}function W(e,t=!1){if(!e)return[];if(Array.isArray(e))return e;const r=e.type==="doc"?e.content||[]:[e];return t?Y(r,Ce()):r}function Y(e,t){return e.map(r=>{var n;return{...r,_key:t(r.type),marks:(n=r.marks)==null?void 0:n.map(s=>({...s,_key:t(s.type)})),...r.content?{content:Y(r.content,t)}:{}}})}function R(e){const t=e.type,r=L[t]??Ee[t];return r?"resolve"in r&&typeof r.resolve=="function"?r.resolve(e.attrs):"tag"in r&&typeof r.tag=="string"?r.tag:null:null}function E(e){return Te.includes(e)}function Q(e){const t=L[e.type];return t&&"children"in t?t.children:null}function Be(e){let t="";for(const r in e){const n=e[r];n!=null&&(t+=` ${r}="${Fe(n)}"`)}return t}function Ke(e,t){const r=W(e);return r!=null&&r.length?X(r,t):""}function q(e,t){var o;if(e.type==="text")return Z(e,e.marks,t);const r=e.content?X(e.content,t):"",n=(o=t==null?void 0:t.renderers)==null?void 0:o[e.type];if(n)return n({...e,children:r,context:t});if(e.type==="blok")return console.warn('"blok" nodes require a custom renderer in renderRichText.'),"";const s=R(e);if(!s)return r;if(e.type==="image"&&(t!=null&&t.optimizeImage))return Je(e,t);const i=A(e.type,e.attrs);if(E(s))return`<${s}${i}>`;if(e.type==="table")return`<${s}${i}>${Qe(e.content,t)}</${s}>`;const l=Q(e);return l?`<${s}>${ee(e.type,l,e.attrs,r)}</${s}>`:`<${s}${i}>${r}</${s}>`}function Je(e,t){const r=e.attrs,n=r==null?void 0:r.src;let s=r;if(n){const{src:l,attrs:o}=j(n,t.optimizeImage);s={...r,src:l,...o}}const i=A("image",s);return i?`<img${i}>`:"<img>"}function X(e,t){let r="",n=0;const s=e.length;for(;n<s;){const i=e[n],l=C(i);if(l){let o=n+1;for(;o<s&&B(l,C(e[o]));)o++;r+=Ye(e,n,o,l,t),n=o}else r+=q(i,t),n++}return r}function Z(e,t,r){let n=Le(e.text);if(!(t!=null&&t.length))return n;for(const s of t)n=We(n,s,r);return n}function We(e,t,r){var i;const n=(i=r==null?void 0:r.renderers)==null?void 0:i[t.type];if(n)return n({...t,children:e});const s=R(t);return s?`<${s}${A(t.type,t.attrs)}>${e}</${s}>`:e}function Ye(e,t,r,n,s){var c,u;let i="";for(let f=t;f<r;f++){const h=e[f],p=(c=h.marks)==null?void 0:c.filter(b=>b.type!=="link");i+=Z(h,p,s)}const l=(u=s==null?void 0:s.renderers)==null?void 0:u[n.type];if(l)return l({...n,children:i});const o=R(n);return o?`<${o}${A(n.type,n.attrs)}>${i}</${o}>`:i}function Qe(e,t){if(!(e!=null&&e.length))return"";let r=0;for(;r<e.length&&K(e[r]);)r++;let n="";if(r>0){n+="<thead>";for(let s=0;s<r;s++)n+=q(e[s],t);n+="</thead>"}if(r<e.length){n+="<tbody>";for(let s=r;s<e.length;s++)n+=q(e[s],t);n+="</tbody>"}return n}function ee(e,t,r,n){let s="";for(const i of t){const{tag:l,children:o,attrs:c}=i,u=A(e,{...c,...r});if(E(l))s+=`<${l}${u}>`;else{const f=o?ee(e,o,r,n):n;s+=`<${l}${u}>${f}</${l}>`}}return s}function A(e,t){const r=_(e,t,{colspan:"colspan",rowspan:"rowspan"}),n=r.style,s={...r};return n&&(s.style=Me(n)),Be(s)}let te=!1;const re=[],Xe=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=s=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}te?s():re.push(s)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=s=>r(s),n.onload=s=>{re.forEach(i=>i()),te=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),Ze=(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 G(t)}},et=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 ne="https://app.storyblok.com/f/storyblok-v2-latest.js";const se=(e,t,r={})=>{var n;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((n=window.location)==null?void 0:n.href).searchParams.get("_storyblok"),l=i!==null&&+i===e;if(!(!s||!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"],o=>{var c;o&&(o.action==="input"&&((c=o.story)==null?void 0:c.id)===e?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===e&&window.location.reload())})})}},tt=(e={})=>{var t,r;const{bridge:n,accessToken:s,use:i=[],apiOptions:l={},bridgeUrl:o}=e;l.accessToken=l.accessToken||s;const c={bridge:n,apiOptions:l};let u={};i.forEach(h=>{u={...u,...h(c)}}),o&&(ne=o);const f=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return n!==!1&&f&&Xe(ne),u},H=a.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var c;const r=e,n=a.useSlots(),s=a.ref();t({value:s});const i=typeof a.resolveDynamicComponent(r.blok.component)!="string",l=a.inject("VueSDKOptions"),o=a.ref((c=r.blok.component)==null?void 0:c.replace(/_/g,"-"));return!i&&l&&(l.enableFallbackComponent?(o.value=l.customFallbackComponent??"FallbackComponent",typeof a.resolveDynamicComponent(o.value)=="string"&&console.error(`Is the Fallback component "${o.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});"?`)),(u,f)=>(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.value),a.mergeProps({ref_key:"blokRef",ref:s},{...u.$props,...u.$attrs}),a.createSlots({_:2},[a.renderList(Object.keys(a.unref(n)),h=>({name:h,fn:a.withCtx(p=>[a.renderSlot(u.$slots,h,a.normalizeProps(a.guardReactiveProps(p)))])}))]),1040))}}),ie=a.defineComponent({name:"StoryblokBlokRenderer",props:{type:{type:String,required:!0},attrs:{type:Object,required:!1},content:{type:Array,required:!1},marks:{type:Array,required:!1},_key:{type:String,required:!1},context:{type:Object,required:!1}},setup(e){return()=>{var t;return Array.isArray((t=e.attrs)==null?void 0:t.body)?e.attrs.body.map((r,n)=>a.h(H,{blok:r,key:r._uid||n})):null}}});function U(e,t){return t==null?void 0:t[e]}function oe(e){return function(r){if(!r)return null;const n=W(r,!0);return n.length?v(n,e):null}}function v(e,t){return Ge(e).map((n,s)=>n.linkMark?rt(n.nodes,n.linkMark,t,n._key||s):V(n.nodes[0],t,n._key||s))}function rt(e,t,r,n){const s=e.map((o,c)=>{const u=o,f=De(o);return ce(u,f,r)}),i=U(t.type,r.components);if(i)return a.h(i,{key:n,...t},{default:()=>s});const l=R(t);return l?a.h(l,{key:n,..._(t.type,t.attrs)},s):s.length>0?s[0]:a.createTextVNode("")}function V(e,t,r){if(e.type==="text")return it(e,t);const n=U(e.type,t.components);if(n)return a.h(n,{key:r,...e,context:t},e.content?{default:()=>v(e.content,t)}:void 0);const s=R(e);if(!s){const c=e.content?v(e.content,t):[];return c.length===0?a.createTextVNode(""):c.length===1?c[0]:a.h("div",{key:r},c)}if(e.type==="image"&&t.optimizeImage)return nt(e,t,r);const i=_(e.type,e.attrs);if(E(s))return a.h(s,{key:r,...i});if(e.type==="table")return st(e,t,r,s,i);const l=Q(e);if(l){const c=e.content?v(e.content,t):[],u=le(e.type,l,e.attrs,c);return a.h(s,{key:r},u)}const o=e.content?v(e.content,t):[];return a.h(s,{key:r,...i},o)}function nt(e,t,r){const n=e.attrs,s=n==null?void 0:n.src;if(!s)return a.createTextVNode("");const{src:i,attrs:l}=j(s,t.optimizeImage),o=_("image",{...n,src:i,...l});return a.h("img",{key:r,...o})}function st(e,t,r,n,s){const{headerRows:i,bodyRows:l}=J(e.content),o=[];return i.length>0&&o.push(a.h("thead",{key:"thead"},i.map((c,u)=>V(c,t,u)))),l.length>0&&o.push(a.h("tbody",{key:"tbody"},l.map((c,u)=>V(c,t,u)))),a.h(n,{key:r,...s},o)}function le(e,t,r,n){return t.map((s,i)=>{const{tag:l,children:o,attrs:c}=s,u={...c,...r},f=_(e,u);if(E(l))return a.h(l,{key:i,...f});const h=o?le(e,o,r,n):n;return a.h(l,{key:i,...f},h)})}function it(e,t,r){return ce(e,e.marks,t)}function ce(e,t,r,n){let s=e.text;if(t!=null&&t.length)for(const i of t)s=ot(s,i,r);return typeof s=="string"?a.createTextVNode(s):s}function ot(e,t,r){const n=U(t.type,r.components);if(n){const i=typeof e=="string"?a.createTextVNode(e):e;return a.h(n,{...t},{default:()=>[i]})}const s=R(t);return s?a.h(s,_(t.type,t.attrs),typeof e=="string"?e:[e]):typeof e=="string"?a.createTextVNode(e):e}const ae=a.defineComponent({name:"StoryblokRichText",props:{document:{type:Object,required:!1},optimizeImage:{type:[Boolean,Object],required:!1},components:{type:Object,required:!1}},setup(e){const t=oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}});return()=>t(e.document)}});function lt(e){return oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}})}const ct={beforeMount(e,t){if(t.value){const r=et(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"))}}},ue=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
8
  `)};let $=null;const at=()=>($||ue("useStoryblokApi"),$),ut=async(e,t={},r={})=>{const n=a.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,a.onMounted(()=>{n.value&&n.value.id&&se(n.value.id,s=>n.value=s,r)}),$){const{data:s}=await $.get(`cdn/stories/${e}`,t);n.value=s.story}else ue("useStoryblok");return n},ht={install(e,t={}){e.directive("editable",ct),e.component("StoryblokComponent",H),e.component("StoryblokRichText",ae),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",a.defineAsyncComponent(()=>Promise.resolve().then(()=>yt)));const{storyblokApi:r}=tt(t);$=r||null,e.provide("VueSDKOptions",t)}},ft={class:"fallback-component"},dt={class:"component"},yt=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[n,s]of t)r[n]=s;return r})(a.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(a.openBlock(),a.createElementBlock("div",ft,[a.createElementVNode("p",null,[r[0]||(r[0]=a.createTextVNode(" Component could not be found for blok ",-1)),a.createElementVNode("span",dt,a.toDisplayString(e.blok.component),1),r[1]||(r[1]=a.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));y.StoryblokClient=G,y.StoryblokComponent=H,y.StoryblokRichText=ae,y.StoryblokVue=ht,y.apiPlugin=Ze,y.buildStoryblokImage=j,y.renderRichText=Ke,y.splitTableRows=J,y.useStoryblok=ut,y.useStoryblokApi=at,y.useStoryblokBridge=se,y.useStoryblokRichText=lt,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
@@ -1013,7 +1013,7 @@ function Z(e, t) {
1013
1013
  ...s,
1014
1014
  _key: t(s.type)
1015
1015
  })),
1016
- content: r.content ? Z(r.content, t) : void 0
1016
+ ...r.content ? { content: Z(r.content, t) } : {}
1017
1017
  };
1018
1018
  });
1019
1019
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
3
  "type": "module",
4
- "version": "11.0.0",
4
+ "version": "11.0.1",
5
5
  "description": "SDK to integrate Storyblok into your project using Vue.",
6
6
  "author": "Storyblok",
7
7
  "license": "MIT",
@@ -31,8 +31,8 @@
31
31
  "vue": ">=3.4"
32
32
  },
33
33
  "dependencies": {
34
- "@storyblok/js": "6.0.0",
35
- "@storyblok/richtext": "5.0.0"
34
+ "@storyblok/js": "6.0.1",
35
+ "@storyblok/richtext": "5.0.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@rollup/plugin-typescript": "^12.1.2",