@storyblok/vue 11.2.0 → 11.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,214 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(y,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(y=typeof globalThis<"u"?globalThis:y||self,c(y.storyblokVue={},y.Vue))})(this,(function(y,c){"use strict";var pt=Object.defineProperty;var gt=(y,c,g)=>c in y?pt(y,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):y[c]=g;var d=(y,c,g)=>gt(y,typeof c!="symbol"?c+"":c,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],[]),V=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("&")},z=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 a=await this._responseHandler(o);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(a)):this._statusHandler(a)}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 f=await e(...u.args);u.resolve(f)}catch(f){u.reject(f)}const h=setTimeout(()=>{i--,n.length>0&&o(),s=s.filter(f=>f!==h)},r);s.includes(h)||s.push(h)},a=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((h,f)=>{n.push({resolve:h,reject:f,args:u}),i<t&&o()});return a.abort=()=>{l=!0,s.forEach(clearTimeout),s=[],n.forEach(u=>u.reject(()=>new Ae("Throttle function aborted"))),n.length=0},a}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}://${z(e.region)}/v1`:r=`${i}://${z(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(V).join(","):typeof e.resolve_relations=="string"&&(e.resolve_relations=V(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,a=await this.makeRequest(i,t,s,o,n);return ge([a,...await pe(ye(o,a.total?Math.ceil(a.total/(a.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 a=Math.min(s,o+l);i.push(e.link_uuids.slice(o,a))}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(a=>{n.push(a)})}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 a=Math.min(s,o+l);i.push(e.rel_uuids.slice(o,a))}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(a=>{n.push(a)});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 a=await i.get(s);if(a)return Promise.resolve(a)}const l=!g(e)&&this.rateLimitConfig.isManagementApi?w:void 0,o=S(e,t,this.rateLimitConfig,l);return new Promise(async(a,u)=>{var h;try{const f=await this.throttleManager.execute(o,"get",e,t,n);if(f.status!==200)return u(f);let p={data:f.data,headers:f.headers};const b=we(f.headers);if((b==null?void 0:b.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=b.max),(h=f.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:f.headers["per-page"]?Number.parseInt(f.headers["per-page"]):0,total:f.headers["per-page"]?Number.parseInt(f.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),a(p)}catch(f){if(f.response&&f.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(a).catch(u);u(f)}})}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(a,u,h,f,p){typeof a!="number"||a<=u||a>=h?console.warn(`[StoryblokRichText] - ${f.charAt(0).toUpperCase()+f.slice(1)} value must be a number between ${u} and ${h} (inclusive)`):p.push(`${f}(${a})`)}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:a}=t||{},{blur:u,brightness:h,fill:f,format:p,grayscale:b,quality:M,rotate:P}=a||{};u&&l(u,0,100,"blur",i),M&&l(M,0,100,"quality",i),h&&l(h,0,100,"brightness",i),f&&i.push(`fill(${f})`),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(a=>{if(typeof a=="number")return`${e}/m/${a}x0/${i.length>0?`filters:${i.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[u,h]=a;return`${e}/m/${u}x${h}/${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 Ce(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Le(){const e=new Map;return t=>{const r=(e.get(t)||0)+1;return e.set(t,r),`${t}-${r}`}}const C={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 Fe(e){const t={};let r={};if(!(e in C))return{staticAttrs:r,staticStyle:t};const n=C[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 Ue(e){return Array.isArray(e)?e[0]!=null?`${e[0]}px`:void 0:typeof e=="number"||typeof e=="string"?e:String(e)}function Ve(e,t,r,n,s,i,l){if(!x(t)||xe.has(e)||qe.has(e)&&t===1)return;if(e in n){const a=n[e],u=Ue(t);u!==void 0&&x(u)&&(i[a]=u);return}const o=s[e]??e;if(o==="custom"&&r==="link"&&typeof t=="object"&&t!==null){for(const[a,u]of Object.entries(t))l[a]=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}=Fe(e),i={...s},l={},o=je[e]||{},a={...Ie,...r},u={...n,...t};for(const[h,f]of Object.entries(u))Ve(h,f,e,o,a,i,l);if(e==="link"){const h=He(t);h!==void 0&&(l.href=h)}return{...l,...Object.keys(i).length>0&&{style:i}}}const ze=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 L(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=L(s);if(i){const l=[s];let o=r+1;for(;o<n&&B(i,L(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,Le()):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=C[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=C[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}="${ze(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,a;const r=e.type!=="text"&&e.content?X(e.content,t):"",n=(o=t==null?void 0:t.renderers)==null?void 0:o[e.type];if(n){const u=(a=t==null?void 0:t.renderers)!=null&&a[e.type]?{...t,renderers:{...t.renderers,[e.type]:void 0}}:t;return n({...e,children:r,context:u})}if(e.type==="text")return Z(e,e.marks,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=L(i);if(l){let o=n+1;for(;o<s&&B(l,L(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=Ce(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,context:r});const s=R(t);return s?`<${s}${A(t.type,t.attrs)}>${e}</${s}>`:e}function Ye(e,t,r,n,s){var a,u;let i="";for(let h=t;h<r;h++){const f=e[h],p=(a=f.marks)==null?void 0:a.filter(b=>b.type!=="link");i+=Z(f,p,s)}const l=(u=s==null?void 0:s.renderers)==null?void 0:u[n.type];if(l)return l({...n,children:i,context:s});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:a}=i,u=A(e,{...a,...r});if(E(l))s+=`<${l}${u}>`;else{const h=o?ee(e,o,r,n):n;s+=`<${l}${u}>${h}</${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!="string")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 a;o&&(o.action==="input"&&((a=o.story)==null?void 0:a.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 a={bridge:n,apiOptions:l};let u={};i.forEach(f=>{u={...u,...f(a)}}),o&&(ne=o);const h=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return n!==!1&&h&&Xe(ne),u},H=c.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,n=c.useSlots(),s=c.ref();t({value:s});const i=typeof c.resolveDynamicComponent(r.blok.component)!="string",l=c.inject("VueSDKOptions"),o=c.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!i&&l&&(l.enableFallbackComponent?(o.value=l.customFallbackComponent??"FallbackComponent",typeof c.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,h)=>(c.openBlock(),c.createBlock(c.resolveDynamicComponent(o.value),c.mergeProps({ref_key:"blokRef",ref:s},{...u.$props,...u.$attrs}),c.createSlots({_:2},[c.renderList(Object.keys(c.unref(n)),f=>({name:f,fn:c.withCtx(p=>[c.renderSlot(u.$slots,f,c.normalizeProps(c.guardReactiveProps(p)))])}))]),1040))}}),ie=c.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)=>c.h(H,{blok:r,key:r._uid||n})):null}}});function F(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):U(n.nodes[0],t,n._key||s))}function rt(e,t,r,n){const s=e.map((o,a)=>{const u=o,h=De(o);return ae(u,h,r)}),i=F(t.type,r.components);if(i)return c.h(i,{key:n,...t,context:r},{default:()=>s});const l=R(t);return l?c.h(l,{key:n,..._(t.type,t.attrs)},s):s.length>0?s[0]:c.createTextVNode("")}function U(e,t,r){var u;const n=e.type!=="text"&&e.content?v(e.content,t):[],s=F(e.type,t.components);if(s){const h=(u=t.components)!=null&&u[e.type]?{...t,components:{...t.components,[e.type]:void 0}}:t;return c.h(s,{key:r,...e,context:h},n.length?{default:()=>n}:void 0)}if(e.type==="text")return it(e,t);const i=R(e);if(!i){const h=e.content?v(e.content,t):[];return h.length===0?c.createTextVNode(""):h.length===1?h[0]:c.h("div",{key:r},h)}if(e.type==="image"&&t.optimizeImage)return nt(e,t,r);const l=_(e.type,e.attrs);if(E(i))return c.h(i,{key:r,...l});if(e.type==="table")return st(e,t,r,i,l);const o=Q(e);if(o){const h=e.content?v(e.content,t):[],f=le(e.type,o,e.attrs,h);return c.h(i,{key:r},f)}const a=e.content?v(e.content,t):[];return c.h(i,{key:r,...l},a)}function nt(e,t,r){const n=e.attrs,s=n==null?void 0:n.src;if(!s)return c.createTextVNode("");const{src:i,attrs:l}=j(s,t.optimizeImage),o=_("image",{...n,src:i,...l});return c.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(c.h("thead",{key:"thead"},i.map((a,u)=>U(a,t,u)))),l.length>0&&o.push(c.h("tbody",{key:"tbody"},l.map((a,u)=>U(a,t,u)))),c.h(n,{key:r,...s},o)}function le(e,t,r,n){return t.map((s,i)=>{const{tag:l,children:o,attrs:a}=s,u={...a,...r},h=_(e,u);if(E(l))return c.h(l,{key:i,...h});const f=o?le(e,o,r,n):n;return c.h(l,{key:i,...h},f)})}function it(e,t,r){return ae(e,e.marks,t)}function ae(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"?c.createTextVNode(s):s}function ot(e,t,r){const n=F(t.type,r.components);if(n){const i=typeof e=="string"?c.createTextVNode(e):e;return c.h(n,{...t,context:r},{default:()=>[i]})}const s=R(t);return s?c.h(s,_(t.type,t.attrs),typeof e=="string"?e:[e]):typeof e=="string"?c.createTextVNode(e):e}const ce=c.defineComponent({name:"StoryblokRichText",props:{document:{type:Object,required:!1},optimizeImage:{type:[Boolean,Object],required:!1},components:{type:Object,required:!1},data:{type:null,required:!1}},setup(e){const t=oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components},data:e.data});return()=>t(e.document)}});function lt(e){return oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}})}const at={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
- `)};let $=null;const ct=()=>($||ue("useStoryblokApi"),$),ut=async(e,t={},r={})=>{const n=c.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,c.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",at),e.component("StoryblokComponent",H),e.component("StoryblokRichText",ce),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",c.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})(c.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(c.openBlock(),c.createElementBlock("div",ft,[c.createElementVNode("p",null,[r[0]||(r[0]=c.createTextVNode(" Component could not be found for blok ",-1)),c.createElementVNode("span",dt,c.toDisplayString(e.blok.component),1),r[1]||(r[1]=c.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));y.StoryblokClient=G,y.StoryblokComponent=H,y.StoryblokRichText=ce,y.StoryblokVue=ht,y.apiPlugin=Ze,y.buildStoryblokImage=j,y.renderRichText=Ke,y.splitTableRows=J,y.useStoryblok=ut,y.useStoryblokApi=ct,y.useStoryblokBridge=se,y.useStoryblokRichText=lt,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
7
+ (function(p,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(p=typeof globalThis<"u"?globalThis:p||self,c(p.storyblokVue={},p.Vue))})(this,(function(p,c){"use strict";var Zt=Object.defineProperty;var en=(p,c,y)=>c in p?Zt(p,c,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[c]=y;var f=(p,c,y)=>en(p,typeof c!="symbol"?c+"":c,y);const y=(t="")=>t.includes("/cdn/"),Se=(t,e=25,n=1)=>({...t,per_page:e,page:n}),Be=t=>new Promise(e=>setTimeout(e,t)),Te=(t=0,e)=>Array.from({length:t},e),Ce=(t=0,e=t)=>{const n=Math.abs(e-t)||0,o=t<e?1:-1;return Te(n,(r,i)=>i*o+t)},$e=async(t,e)=>Promise.all(t.map(e)),Re=(t=[],e)=>t.map(e).reduce((n,o)=>[...n,...o],[]),Q=t=>{if(/%[0-9A-F]{2}/i.test(t))try{return decodeURIComponent(t)}catch{return t}return t},F=(t,e,n)=>{const o=[];for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const i=t[r];if(i==null)continue;const l=n?"":encodeURIComponent(r);let s;typeof i=="object"?s=F(i,e?e+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):s=`${e?e+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,o.push(s)}return o.join("&")},X=t=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[t]??e.eu};var Le=class{constructor(t){f(this,"baseURL");f(this,"timeout");f(this,"headers");f(this,"responseInterceptor");f(this,"fetch");f(this,"ejectInterceptor");f(this,"url");f(this,"parameters");f(this,"fetchOptions");this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&t.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}patch(t,e){return this.url=t,this.parameters=e,this._methodHandler("patch")}delete(t,e){return this.url=t,this.parameters=e??{},this._methodHandler("delete")}async _responseHandler(t){const e=[],n={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(o=>{n.data=o});for(const o of t.headers.entries())e[o[0]]=o[1];return n.headers={...e},n.status=t.status,n.statusText=t.statusText,n}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,n=null;t==="get"?e=`${this.baseURL}${this.url}?${F(this.parameters)}`:n=JSON.stringify(this.parameters);const o=new URL(e),r=new AbortController,{signal:i}=r;let l=null;this.timeout&&(l=setTimeout(()=>r.abort(),this.timeout));try{const s=await this.fetch(`${o}`,{method:t,headers:this.headers,body:n,signal:i,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const a=await this._responseHandler(s);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(a)):this._statusHandler(a)}catch(s){return s.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:s.message||s.toString()||"An unknown error occurred"}}}setFetchOptions(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(t){if(Array.isArray(t))return t[0]||"Unknown error";if(t&&typeof t=="object"){if(t.error)return t.error;for(const e in t){if(Array.isArray(t[e]))return`${e}: ${t[e][0]}`;if(typeof t[e]=="string")return`${e}: ${t[e]}`}if(t.slug)return t.slug}return"Unknown error"}_statusHandler(t){const e=/20[0-6]/g;return new Promise((n,o)=>{if(e.test(`${t.status}`))return n(t);o({message:this._normalizeErrorMessage(t.data),status:t.status,response:t})})}};const Ne={PUBLISHED:"published"},Oe=25,j={SMALL:25,MEDIUM:50,LARGE:75},v={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Z=1e3,M=3;function Ie(t,e){const n=t.includes("/cdn/stories/"),o=t.split("/").length>3&&!t.endsWith("/cdn/stories"),r="find_by"in e;return n&&o||r}function xe(t){return t<=j.SMALL?v.SINGLE_OR_SMALL:t<=j.MEDIUM?v.MEDIUM:t<=j.LARGE?v.LARGE:v.VERY_LARGE}function S(t,e,n={},o){return n.userRateLimit!==void 0?Math.min(n.userRateLimit,Z):n.serverHeadersRateLimit!==void 0?Math.min(n.serverHeadersRateLimit,Z):o!==void 0?o:!t||!e||Ie(t,e)?v.SINGLE_OR_SMALL:xe(e.per_page||Oe)}function Pe(t){if(!t)return null;const e=t["x-ratelimit"]||t["X-RateLimit"],n=t["x-ratelimit-policy"]||t["X-RateLimit-Policy"];if(!e&&!n)return null;const o={};if(e){const r=e.match(/r=(\d+)/);r&&(o.remaining=Number.parseInt(r[1],10))}if(n){const r=n.match(/q=(\d+)/);r&&(o.max=Number.parseInt(r[1],10))}return Object.keys(o).length>0?o:null}function He(t,e=!1){return{userRateLimit:t,serverHeadersRateLimit:void 0,isManagementApi:e}}var Ue=class extends Error{constructor(t){super(t),this.name="AbortError"}};function Fe(t,e,n){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(n))throw new TypeError("Expected `interval` to be a finite number");const o=[];let r=[],i=0,l=!1;const s=async()=>{i++;const u=o.shift();if(u)try{const m=await t(...u.args);u.resolve(m)}catch(m){u.reject(m)}const d=setTimeout(()=>{i--,o.length>0&&s(),r=r.filter(m=>m!==d)},n);r.includes(d)||r.push(d)},a=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,m)=>{o.push({resolve:d,reject:m,args:u}),i<e&&s()});return a.abort=()=>{l=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new Ue("Throttle function aborted"))),o.length=0},a}var je=class{constructor(t,e=1e3){f(this,"queues");f(this,"interval");f(this,"throttledRequestFn");this.queues=new Map,this.interval=e,this.throttledRequestFn=t}getQueue(t){let e=this.queues.get(t);return e||(e=Fe(this.throttledRequestFn,t,this.interval),this.queues.set(t,e)),e}execute(t,...e){return this.getQueue(t)(...e)}abortAll(){this.queues.forEach(t=>{var e;(e=t.abort)==null||e.call(t)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let R={};const g={};var ee=class{constructor(t,e){f(this,"client");f(this,"maxRetries");f(this,"retriesDelay");f(this,"throttleManager");f(this,"accessToken");f(this,"cache");f(this,"resolveCounter");f(this,"relations");f(this,"links");f(this,"version");f(this,"rateLimitConfig");f(this,"cvMode");f(this,"richTextResolver");f(this,"resolveNestedRelations");f(this,"stringifiedStoriesCache");f(this,"inlineAssets");var r;let n=t.endpoint||e;if(!n){const i=t.https===!1?"http":"https";t.oauthToken?n=`${i}://${X(t.region)}/v1`:n=`${i}://${X(t.region)}/v2`}const o=new Headers;!t.oauthToken&&typeof window<"u"||o.set("Content-Type","application/json"),o.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([i,l])=>{o.set(i,l)}),t.oauthToken&&o.set("Authorization",t.oauthToken),this.rateLimitConfig=He(t.rateLimit,!!t.oauthToken),this.maxRetries=t.maxRetries||10,this.retriesDelay=t.retriesDelay??300,this.throttleManager=new je(this.throttledRequest.bind(this),1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.cvMode=((r=t.cache)==null?void 0:r.cv)??"auto",this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=t.version||Ne.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new Le({baseURL:n,timeout:t.timeout||0,headers:o,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),!t.cv&&this.cvMode==="auto"&&(t.cv=g[t.token]),Array.isArray(t.resolve_relations)?t.resolve_relations=t.resolve_relations.map(Q).join(","):typeof t.resolve_relations=="string"&&(t.resolve_relations=Q(t.resolve_relations)),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return y(t)?this.parseParams(e):e}makeRequest(t,e,n,o,r){const i=this.factoryParamOptions(t,Se(e,n,o));return this.cacheResponse(t,i,void 0,r)}get(t,e={},n){e||(e={});const o=`/${t}`;y(o)&&(e.version=e.version||this.version);const r=this.factoryParamOptions(o,e);return this.cacheResponse(o,r,void 0,n)}async getAll(t,e={},n,o){const r=(e==null?void 0:e.per_page)||25,i=`/${t}`.replace(/\/$/,""),l=n??i.substring(i.lastIndexOf("/")+1);e.version=e.version||this.version;const s=1,a=await this.makeRequest(i,e,r,s,o);return Re([a,...await $e(Ce(s,a.total?Math.ceil(a.total/(a.perPage||r)):1),u=>this.makeRequest(i,e,r,u+1,o))],u=>Object.values(u.data[l]))}post(t,e={},n){const o=`/${t}`,r=S(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(r,"post",o,e,n)}put(t,e={},n){const o=`/${t}`,r=S(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(r,"put",o,e,n)}patch(t,e={},n){const o=`/${t}`,r=S(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(r,"patch",o,e,n)}delete(t,e={},n){e||(e={});const o=`/${t}`,r=S(void 0,void 0,this.rateLimitConfig,M);return this.throttleManager.execute(r,"delete",o,e,n)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},n){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,n)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(t){typeof t.resolve_relations<"u"&&(t.resolve_level=2)}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,n){const o=t[e];o&&o.fieldtype==="multilink"&&o.linktype==="story"&&typeof o.id=="string"&&this.links[n][o.id]?o.story=this._cleanCopy(this.links[n][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[n][o.uuid]&&(o.story=this._cleanCopy(this.links[n][o.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,n){const o=t[e];typeof o=="string"?t[e]=this.getStoryReference(n,o):Array.isArray(o)&&(t[e]=o.map(r=>this.getStoryReference(n,r)).filter(Boolean))}_insertRelations(t,e,n,o){if(Array.isArray(n)?n.find(i=>i.endsWith(`.${e}`)):n.endsWith(`.${e}`)){this._resolveField(t,e,o);return}const r=t.component?`${t.component}.${e}`:e;(Array.isArray(n)?n.includes(r):n===r)&&this._resolveField(t,e,o)}iterateTree(t,e,n){const o=(r,i="")=>{if(!(!r||r._stopResolving)){if(Array.isArray(r))r.forEach((l,s)=>o(l,`${i}[${s}]`));else if(typeof r=="object")for(const l in r){const s=i?`${i}.${l}`:l;(r.component&&r._uid||r.type==="link")&&(this._insertRelations(r,l,e,n),this._insertLinks(r,l,n)),o(r[l],s)}}};o(t.content)}async resolveLinks(t,e,n){let o=[];if(t.link_uuids){const r=t.link_uuids.length,i=[],l=50;for(let s=0;s<r;s+=l){const a=Math.min(r,s+l);i.push(t.link_uuids.slice(s,a))}for(let s=0;s<i.length;s++)(await this.getStories({per_page:l,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:i[s].join(",")})).data.stories.forEach(a=>{o.push(a)})}else o=t.links;o.forEach(r=>{this.links[n][r.uuid]={...r,_stopResolving:!0}})}async resolveRelations(t,e,n){let o=[];if(t.rel_uuids){const r=t.rel_uuids.length,i=[],l=50;for(let s=0;s<r;s+=l){const a=Math.min(r,s+l);i.push(t.rel_uuids.slice(s,a))}for(let s=0;s<i.length;s++)(await this.getStories({per_page:l,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:i[s].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(a=>{o.push(a)});o.length>0&&(t.rels=o,delete t.rel_uuids)}else o=t.rels;o&&o.length>0&&o.forEach(r=>{this.relations[n][r.uuid]={...r,_stopResolving:!0}})}async resolveStories(t,e,n){var r,i;let o=[];if(this.links[n]={},this.relations[n]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(o=e.resolve_relations.split(",")),await this.resolveRelations(t,e,n)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,n),this.resolveNestedRelations)for(const l in this.relations[n])this.iterateTree(this.relations[n][l],o,n);t.story?this.iterateTree(t.story,o,n):t.stories.forEach(l=>{this.iterateTree(l,o,n)}),this.stringifiedStoriesCache={},delete this.links[n],delete this.relations[n]}async cacheResponse(t,e,n,o){const r=F({url:t,params:e}),i=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const a=await i.get(r);if(a)return Promise.resolve(a)}const l=!y(t)&&this.rateLimitConfig.isManagementApi?M:void 0,s=S(t,e,this.rateLimitConfig,l);return new Promise(async(a,u)=>{var d;try{const m=await this.throttleManager.execute(s,"get",t,e,o);if(m.status!==200)return u(m);let b={data:m.data,headers:m.headers};const k=Pe(m.headers);if((k==null?void 0:k.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=k.max),(d=m.headers)!=null&&d["per-page"]&&(b=Object.assign({},b,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),b.data.story||b.data.stories){const U=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(b.data,e,`${U}`),b=await this.processInlineAssets(b)}e.version==="published"&&t!=="/cdn/spaces/me"&&await i.set(r,b);const H=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&b.data.cv&&(H&&g[e.token]&&g[e.token]!==b.data.cv&&await this.flushCache(),g[e.token]=b.data.cv),a(b)}catch(m){if(m.response&&m.status===429&&(n=typeof n>"u"?0:n+1,n<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await Be(this.retriesDelay),this.cacheResponse(t,e,n).then(a).catch(u);u(m)}})}throttledRequest(t,e,n,o){return this.client.setFetchOptions(o),this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(g[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(R[t])},getAll(){return Promise.resolve(R)},set(t,e){return R[t]=e,Promise.resolve(void 0)},flush(){return R={},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(t){if(!this.inlineAssets)return t;const e=n=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map(r=>e(r));let o={...n};o.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(o={...t.data.assets.find(r=>r.id===o.id),...o});for(const r in o)typeof o[r]=="object"&&(o[r]=e(o[r]));return o};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(n=>(n.content=e(n.content),n))),t}};function V(t,e){if(!e)return{src:t,attrs:{}};let n=0,o=0;const r={},i=[];function l(a,u,d,m,b){typeof a!="number"||a<=u||a>=d?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${d} (inclusive)`):b.push(`${m}(${a})`)}if(typeof e=="object"){if(e.width!==void 0&&(typeof e.width=="number"&&e.width>=0?(r.width=e.width,n=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),e.height!==void 0&&(typeof e.height=="number"&&e.height>=0?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),e.height===0&&e.width===0&&(delete r.width,delete r.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:a}=e||{},{blur:u,brightness:d,fill:m,format:b,grayscale:k,quality:H,rotate:U}=a||{};u&&l(u,0,100,"blur",i),H&&l(H,0,100,"quality",i),d&&l(d,0,100,"brightness",i),m&&i.push(`fill(${m})`),k&&i.push("grayscale()"),U&&[0,90,180,270].includes(e.filters.rotate||0)&&i.push(`rotate(${U})`),b&&["webp","png","jpeg"].includes(b)&&i.push(`format(${b})`)}e.srcset&&(r.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${t}/m/${a}x0/${i.length>0?`filters:${i.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[u,d]=a;return`${t}/m/${u}x${d}/${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(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let s=`${t}/m/`;return(n>0||o>0)&&(s=`${s}${n}x${o}/`),i.length>0&&(s=`${s}filters:${i.join(":")}`),{src:s,attrs:r}}function q(t,e){if(t===e)return!0;if(t==null||e===null||e===void 0)return t===e;if(typeof t!=typeof e||typeof t!="object"||Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t))return t.length!==e.length?!1:t.every((r,i)=>q(r,e[i]));const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(e,r)&&q(t[r],e[r]))}const Ve=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"];function qe(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ze(){const t=new Map;return e=>{const n=(t.get(e)||0)+1;return t.set(e,n),`${e}-${n}`}}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:t=>`h${typeof(t==null?void 0:t.level)=="number"?Math.min(6,Math.max(1,t.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},De={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 Ge(t){return Object.entries(t).filter(([,e])=>z(e)).map(([e,n])=>`${We(e)}: ${n};`).join(" ")}function Ye(t){return t.split(";").map(e=>e.trim()).filter(Boolean).reduce((e,n)=>{const o=n.indexOf(":");if(o===-1)return e;const r=n.slice(0,o).trim(),i=n.slice(o+1).trim();return!r||!i||(e[Ke(r)]=i),e},{})}function Ke(t){return t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function We(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function z(t){return t!=null&&t!==""}const Je={highlight:{color:"backgroundColor"},textStyle:{color:"color"},paragraph:{textAlign:"textAlign"},heading:{textAlign:"textAlign"},tableCell:{backgroundColor:"backgroundColor",colwidth:"width"},tableHeader:{colwidth:"width"}},Qe={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"]),Ze=new Set(["colspan","rowspan","order"]);function et(t){const{linktype:e,href:n,anchor:o}=t;if(e==="story")return`${typeof n=="string"?n:""}${typeof o=="string"&&o?`#${o}`:""}`;if(e==="email"&&typeof n=="string")return`mailto:${n.replace(/^mailto:/,"")}`}function tt(t){const e={};let n={};if(!(t in L))return{staticAttrs:n,staticStyle:e};const o=L[t];if(!o||!("attrs"in o))return{staticAttrs:n,staticStyle:e};const r=o.attrs||{},i="style"in r&&typeof r.style=="string"?r.style:"",{style:l,...s}=r;return n=s,i&&Object.assign(e,Ye(i)),{staticAttrs:n,staticStyle:e}}function nt(t){return Array.isArray(t)?t[0]!=null?`${t[0]}px`:void 0:typeof t=="number"||typeof t=="string"?t:String(t)}function ot(t,e,n,o,r,i,l){if(!z(e)||Xe.has(t)||Ze.has(t)&&e===1)return;if(t in o){const a=o[t],u=nt(e);u!==void 0&&z(u)&&(i[a]=u);return}const s=r[t]??t;if(s==="custom"&&n==="link"&&typeof e=="object"&&e!==null){for(const[a,u]of Object.entries(e))l[a]=String(u);return}if(typeof e=="object"&&e!==null){l[s]=JSON.stringify(e);return}l[s]=e}function E(t,e={},n={}){const{staticAttrs:o,staticStyle:r}=tt(t),i={...r},l={},s=Je[t]||{},a={...Qe,...n},u={...o,...e};for(const[d,m]of Object.entries(u))ot(d,m,t,s,a,i,l);if(t==="link"){const d=et(e);d!==void 0&&(l.href=d)}return{...l,...Object.keys(i).length>0&&{style:i}}}const rt=t=>String(t).replace(/[&"'<>]/g,e=>{switch(e){case"&":return"&amp;";case'"':return"&quot;";case"'":return"&#39;";case"<":return"&lt;";case">":return"&gt;";default:return e}});function N(t){if(t.type!=="text"||!t.marks)return null;for(const e of t.marks)if(e.type==="link")return e;return null}function te(t,e){return!t||!e?!1:q(t.attrs??{},e.attrs??{})}function it(t){return t.type!=="text"||!t.marks?[]:t.marks.filter(e=>e.type!=="link")}function st(t){const e=[];let n=0;const o=t.length;for(;n<o;){const r=t[n],i=N(r);if(i){const l=[r];let s=n+1;for(;s<o&&te(i,N(t[s]));)l.push(t[s]),s++;e.push({nodes:l,linkMark:i,_key:`group-link-${n}`}),n=s}else e.push({nodes:[r],linkMark:null,_key:`group-node-${n}`}),n++}return e}function ne(t){const e=t.content;if(!(e!=null&&e.length))return!1;for(const n of e)if(n.type!=="tableHeader")return!1;return!0}function oe(t){if(!(t!=null&&t.length))return{headerRows:[],bodyRows:[]};let e=0;for(;e<t.length&&ne(t[e]);)e++;return{headerRows:t.slice(0,e),bodyRows:t.slice(e)}}function re(t,e=!1){if(!t)return[];if(Array.isArray(t))return t;const n=t.type==="doc"?t.content||[]:[t];return e?ie(n,ze()):n}function ie(t,e){return t.map(n=>{var o;return{...n,_key:e(n.type),marks:(o=n.marks)==null?void 0:o.map(r=>({...r,_key:e(r.type)})),...n.content?{content:ie(n.content,e)}:{}}})}function A(t){const e=t.type,n=L[e]??De[e];return n?"resolve"in n&&typeof n.resolve=="function"?n.resolve(t.attrs):"tag"in n&&typeof n.tag=="string"?n.tag:null:null}function O(t){return Ve.includes(t)}function se(t){const e=L[t.type];return e&&"children"in e?e.children:null}function lt(t){let e="";for(const n in t){const o=t[n];o!=null&&(e+=` ${n}="${rt(o)}"`)}return e}function at(t,e){const n=re(t);return n!=null&&n.length?le(n,e):""}function D(t,e){var s,a;const n=t.type!=="text"&&t.content?le(t.content,e):"",o=(s=e==null?void 0:e.renderers)==null?void 0:s[t.type];if(o){const u=(a=e==null?void 0:e.renderers)!=null&&a[t.type]?{...e,renderers:{...e.renderers,[t.type]:void 0}}:e;return o({...t,children:n,context:u})}if(t.type==="text")return ae(t,t.marks,e);if(t.type==="blok")return console.warn('"blok" nodes require a custom renderer in renderRichText.'),"";const r=A(t);if(!r)return n;if(t.type==="image"&&(e!=null&&e.optimizeImage))return ct(t,e);const i=B(t.type,t.attrs);if(O(r))return`<${r}${i}>`;if(t.type==="table")return`<${r}${i}>${dt(t.content,e)}</${r}>`;const l=se(t);return l?`<${r}>${ce(t.type,l,t.attrs,n)}</${r}>`:`<${r}${i}>${n}</${r}>`}function ct(t,e){const n=t.attrs,o=n==null?void 0:n.src;let r=n;if(o){const{src:l,attrs:s}=V(o,e.optimizeImage);r={...n,src:l,...s}}const i=B("image",r);return i?`<img${i}>`:"<img>"}function le(t,e){let n="",o=0;const r=t.length;for(;o<r;){const i=t[o],l=N(i);if(l){let s=o+1;for(;s<r&&te(l,N(t[s]));)s++;n+=ht(t,o,s,l,e),o=s}else n+=D(i,e),o++}return n}function ae(t,e,n){let o=qe(t.text);if(!(e!=null&&e.length))return o;for(const r of e)o=ut(o,r,n);return o}function ut(t,e,n){var i;const o=(i=n==null?void 0:n.renderers)==null?void 0:i[e.type];if(o)return o({...e,children:t,context:n});const r=A(e);return r?`<${r}${B(e.type,e.attrs)}>${t}</${r}>`:t}function ht(t,e,n,o,r){var a,u;let i="";for(let d=e;d<n;d++){const m=t[d],b=(a=m.marks)==null?void 0:a.filter(k=>k.type!=="link");i+=ae(m,b,r)}const l=(u=r==null?void 0:r.renderers)==null?void 0:u[o.type];if(l)return l({...o,children:i,context:r});const s=A(o);return s?`<${s}${B(o.type,o.attrs)}>${i}</${s}>`:i}function dt(t,e){if(!(t!=null&&t.length))return"";let n=0;for(;n<t.length&&ne(t[n]);)n++;let o="";if(n>0){o+="<thead>";for(let r=0;r<n;r++)o+=D(t[r],e);o+="</thead>"}if(n<t.length){o+="<tbody>";for(let r=n;r<t.length;r++)o+=D(t[r],e);o+="</tbody>"}return o}function ce(t,e,n,o){let r="";for(const i of e){const{tag:l,children:s,attrs:a}=i,u=B(t,{...a,...n});if(O(l))r+=`<${l}${u}>`;else{const d=s?ce(t,s,n,o):o;r+=`<${l}${u}>${d}</${l}>`}}return r}function B(t,e){const n=E(t,e,{colspan:"colspan",rowspan:"rowspan"}),o=n.style,r={...n};return o&&(r.style=Ge(o)),lt(r)}let G=!1,I;const ue=[],mt=()=>typeof window>"u"?Promise.reject(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)")):(window.storyblokRegisterEvent=t=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?t():ue.push(t)},G?Promise.resolve():I||(I=Promise.resolve().then(()=>Wt).then(({default:t})=>{window.StoryblokBridge=t,ue.forEach(e=>e()),G=!0}).catch(t=>{throw I=void 0,t}),I)),ft=(t={})=>{const{apiOptions:e}=t;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ee(e)}},pt=t=>{if(typeof t!="object"||typeof t._editable!="string")return{};try{const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function bt(t){const{language:e,resolveRelations:n,...o}=t;return e&&console.warn("[Storyblok] The `language` bridge option is no longer supported by the bundled bridge. Language context is now passed automatically by the Visual Editor via the `_storyblok_lang` URL parameter."),{...o,...n!==void 0&&{resolveRelations:Array.isArray(n)?n:[n]}}}const he=(t,e,n={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),l=i!==null&&+i===t;if(!(!r||!l)){if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(bt(n)).on(["input","published","change"],s=>{var a;s&&(s.action==="input"&&((a=s.story)==null?void 0:a.id)===t?e(s.story):(s.action==="change"||s.action==="published")&&s.storyId===t&&window.location.reload())})})}},yt=(t={})=>{var e,n;const{bridge:o,accessToken:r,use:i=[],apiOptions:l={},bridgeUrl:s}=t;s&&console.warn("[Storyblok] The `bridgeUrl` option is deprecated and will be removed in a future major version. The Storyblok bridge is now bundled and is no longer loaded from a CDN URL."),l.accessToken=l.accessToken||r;const a={bridge:o,apiOptions:l};let u={};i.forEach(m=>{u={...u,...m(a)}});const d=!(typeof window>"u")&&((n=(e=window.location)==null?void 0:e.search)==null?void 0:n.includes("_storyblok_tk"));return o!==!1&&d&&mt(),u},Y=c.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(t,{expose:e}){var a;const n=t,o=c.useSlots(),r=c.ref();e({value:r});const i=typeof c.resolveDynamicComponent(n.blok.component)!="string",l=c.inject("VueSDKOptions"),s=c.ref((a=n.blok.component)==null?void 0:a.replace(/_/g,"-"));return!i&&l&&(l.enableFallbackComponent?(s.value=l.customFallbackComponent??"FallbackComponent",typeof c.resolveDynamicComponent(s.value)=="string"&&console.error(`Is the Fallback component "${s.value}" registered properly?`)):console.error(`Component could not be found for blok "${n.blok.component}"! Is it defined in main.ts as "app.component("${n.blok.component}", ${n.blok.component});"?`)),(u,d)=>(c.openBlock(),c.createBlock(c.resolveDynamicComponent(s.value),c.mergeProps({ref_key:"blokRef",ref:r},{...u.$props,...u.$attrs}),c.createSlots({_:2},[c.renderList(Object.keys(c.unref(o)),m=>({name:m,fn:c.withCtx(b=>[c.renderSlot(u.$slots,m,c.normalizeProps(c.guardReactiveProps(b)))])}))]),1040))}}),de=c.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(t){return()=>{var e;return Array.isArray((e=t.attrs)==null?void 0:e.body)?t.attrs.body.map((n,o)=>c.h(Y,{blok:n,key:n._uid||o})):null}}});function K(t,e){return e==null?void 0:e[t]}function me(t){return function(n){if(!n)return null;const o=re(n,!0);return o.length?T(o,t):null}}function T(t,e){return st(t).map((o,r)=>o.linkMark?gt(o.nodes,o.linkMark,e,o._key||r):W(o.nodes[0],e,o._key||r))}function gt(t,e,n,o){const r=t.map((s,a)=>{const u=s,d=it(s);return pe(u,d,n)}),i=K(e.type,n.components);if(i)return c.h(i,{key:o,...e,context:n},{default:()=>r});const l=A(e);return l?c.h(l,{key:o,...E(e.type,e.attrs)},r):r.length>0?r[0]:c.createTextVNode("")}function W(t,e,n){var u;const o=t.type!=="text"&&t.content?T(t.content,e):[],r=K(t.type,e.components);if(r){const d=(u=e.components)!=null&&u[t.type]?{...e,components:{...e.components,[t.type]:void 0}}:e;return c.h(r,{key:n,...t,context:d},o.length?{default:()=>o}:void 0)}if(t.type==="text")return vt(t,e);const i=A(t);if(!i){const d=t.content?T(t.content,e):[];return d.length===0?c.createTextVNode(""):d.length===1?d[0]:c.h("div",{key:n},d)}if(t.type==="image"&&e.optimizeImage)return kt(t,e,n);const l=E(t.type,t.attrs);if(O(i))return c.h(i,{key:n,...l});if(t.type==="table")return _t(t,e,n,i,l);const s=se(t);if(s){const d=t.content?T(t.content,e):[],m=fe(t.type,s,t.attrs,d);return c.h(i,{key:n},m)}const a=t.content?T(t.content,e):[];return c.h(i,{key:n,...l},a)}function kt(t,e,n){const o=t.attrs,r=o==null?void 0:o.src;if(!r)return c.createTextVNode("");const{src:i,attrs:l}=V(r,e.optimizeImage),s=E("image",{...o,src:i,...l});return c.h("img",{key:n,...s})}function _t(t,e,n,o,r){const{headerRows:i,bodyRows:l}=oe(t.content),s=[];return i.length>0&&s.push(c.h("thead",{key:"thead"},i.map((a,u)=>W(a,e,u)))),l.length>0&&s.push(c.h("tbody",{key:"tbody"},l.map((a,u)=>W(a,e,u)))),c.h(o,{key:n,...r},s)}function fe(t,e,n,o){return e.map((r,i)=>{const{tag:l,children:s,attrs:a}=r,u={...a,...n},d=E(t,u);if(O(l))return c.h(l,{key:i,...d});const m=s?fe(t,s,n,o):o;return c.h(l,{key:i,...d},m)})}function vt(t,e,n){return pe(t,t.marks,e)}function pe(t,e,n,o){let r=t.text;if(e!=null&&e.length)for(const i of e)r=Et(r,i,n);return typeof r=="string"?c.createTextVNode(r):r}function Et(t,e,n){const o=K(e.type,n.components);if(o){const i=typeof t=="string"?c.createTextVNode(t):t;return c.h(o,{...e,context:n},{default:()=>[i]})}const r=A(e);return r?c.h(r,E(e.type,e.attrs),typeof t=="string"?t:[t]):typeof t=="string"?c.createTextVNode(t):t}const be=c.defineComponent({name:"StoryblokRichText",props:{document:{type:Object,required:!1},optimizeImage:{type:[Boolean,Object],required:!1},components:{type:Object,required:!1},data:{type:null,required:!1}},setup(t){const e=me({optimizeImage:t.optimizeImage,components:{blok:de,...t.components},data:t.data});return()=>e(t.document)}});function At(t){return me({optimizeImage:t.optimizeImage,components:{blok:de,...t.components}})}const wt={beforeMount(t,e){if(e.value){const n=pt(e.value);Object.keys(n).length>0&&(t.setAttribute("data-blok-c",n["data-blok-c"]),t.setAttribute("data-blok-uid",n["data-blok-uid"]),t.classList.add("storyblok__outline"))}}},ye=t=>{console.error(`You can't use ${t} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
+ `)};let C=null;const Mt=()=>(C||ye("useStoryblokApi"),C),St=async(t,e={},n={})=>{const o=c.ref(null);if(n.resolveRelations=n.resolveRelations??e.resolve_relations,n.resolveLinks=n.resolveLinks??e.resolve_links,c.onMounted(()=>{o.value&&o.value.id&&he(o.value.id,r=>o.value=r,n)}),C){const{data:r}=await C.get(`cdn/stories/${t}`,e);o.value=r.story}else ye("useStoryblok");return o},Bt={install(t,e={}){t.directive("editable",wt),t.component("StoryblokComponent",Y),t.component("StoryblokRichText",be),e.enableFallbackComponent&&!e.customFallbackComponent&&t.component("FallbackComponent",c.defineAsyncComponent(()=>Promise.resolve().then(()=>Xt)));const{storyblokApi:n}=yt(e);C=n||null,t.provide("VueSDKOptions",e)}},Tt=(t,e)=>{for(;t&&t.nodeType===1;){if(t.hasAttribute(e))return t;t=t.parentNode}return null},ge=t=>{const e=Tt(t,"data-blok-c");if(!e)return null;const n=e.getAttribute("data-blok-c");return JSON.parse(n)},Ct=(t,e)=>t.contains(e),_=t=>document.querySelector(`[data-blok-uid="${t}"]`),ke=t=>{const e=t.getBoundingClientRect();return e.top<0&&e.top+e.height>=0||e.top>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)},$t=t=>{let e={};try{const n=t.replace(/\\/g,"");e=JSON.parse(n)}catch{console.error("Error parsing json",t)}return e},Rt=t=>{const e=[],n=()=>NodeFilter.FILTER_ACCEPT,o=document.createNodeIterator(t,NodeFilter.SHOW_COMMENT,n,!1);let r={};for(;r=o.nextNode();)if(r.nodeValue.indexOf("#storyblok#")>-1){const i=r.nodeValue.replace("#storyblok#",""),l=r.nextElementSibling||r.nextSibling,s=$t(i);s&&e.push({options:s,el:l})}return e},_e=t=>{let e="";return location.search.substr(1).split("&").forEach(n=>{const o=n.split("=");o[0]===t&&(e=decodeURIComponent(o[1]))}),e},Lt=(t,e,n)=>typeof t!="string"?"":t.toString().replace(/([A-Z])/g," $1").trim().toLowerCase().replace(/[_-]/g," ").replace(/(?:^|\s)\S/g,function(o,r){return o.toUpperCase()}),ve=t=>t&&t.display_name?t.display_name:Lt(t.name),Ee=t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox",t.viewBox),e.setAttribute("class",t.svgClass);const n=document.createElementNS(e.namespaceURI,"path");return n.setAttribute("d",t.path),n.setAttribute("fill",t.pathFill),n.setAttribute("transform",t.pathTransform?t.pathTransform:"translate(0 0)"),e.appendChild(n),e},Nt=t=>t,Ot=Nt,Ae=Ot`
9
+ @keyframes smoke {
10
+ from {
11
+ background-color: rgba(89, 197, 198, 0);
12
+ }
13
+ to {
14
+ background-color: rgba(89, 197, 198, 0.5);
15
+ }
16
+ }
17
+
18
+ .storyblok--outlined .storyblok__outline,
19
+ .storyblok--outlined [data-blok-c] {
20
+ outline: 1px dashed rgba(182, 186, 191, 0.5);
21
+ }
22
+
23
+ .storyblok--outlined .storyblok__outline[data-blok-focused='true'],
24
+ .storyblok--outlined [data-blok-c][data-blok-focused='true'] {
25
+ outline: 0;
26
+ }
27
+
28
+ .storyblok__hint {
29
+ box-sizing: border-box;
30
+ outline: 1px solid #05807f;
31
+ pointer-events: none;
32
+ position: absolute;
33
+ transition: opacity 0.2s ease;
34
+ z-index: 16777272;
35
+ }
36
+
37
+ .storyblok__highlight {
38
+ background: rgba(89, 197, 198, 0.2);
39
+ outline: 1px solid #05807f;
40
+ pointer-events: none;
41
+ position: absolute;
42
+ transition: opacity 0.2s ease;
43
+ z-index: 16777270;
44
+ }
45
+
46
+ .storyblok__overlay {
47
+ box-shadow: 0 0 8px 2px rgba(34, 42, 69, 0.07);
48
+ box-sizing: border-box;
49
+ outline: 1px solid #05807f;
50
+ pointer-events: none;
51
+ position: absolute;
52
+ z-index: 16777273;
53
+ }
54
+
55
+ .storyblok__overlay-menu {
56
+ background-color: #05807f;
57
+ border-radius: 5px;
58
+ display: inline-flex;
59
+ font-family:
60
+ -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, helvetica, arial,
61
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
62
+ height: 30px;
63
+ left: -1px;
64
+ pointer-events: auto;
65
+ position: absolute;
66
+ top: -40px;
67
+ }
68
+
69
+ .storyblok__overlay-menu--simple .storyblok__overlay-menu-btn {
70
+ border-bottom-right-radius: 5px;
71
+ border-top-right-radius: 5px;
72
+ }
73
+
74
+ .storyblok__overlay-menu-label {
75
+ color: #fff;
76
+ font-size: 14px;
77
+ line-height: 30px;
78
+ margin-right: 20px;
79
+ max-width: 200px;
80
+ overflow-x: hidden;
81
+ text-overflow: ellipsis;
82
+ white-space: nowrap;
83
+ }
84
+
85
+ .storyblok__overlay-menu-label:first-child {
86
+ margin-left: 20px;
87
+ }
88
+
89
+ .storyblok__overlay-menu-btn {
90
+ align-items: center;
91
+ background-color: transparent;
92
+ border: 0;
93
+ display: flex;
94
+ justify-content: center;
95
+ outline: none;
96
+ padding: 0;
97
+ }
98
+
99
+ .storyblok__overlay-menu-btn:hover {
100
+ background-color: #0d5454;
101
+ }
102
+
103
+ .storyblok__overlay-menu-btn-action {
104
+ border-bottom-right-radius: 5px;
105
+ border-left: 1px solid #fff;
106
+ border-top-right-radius: 5px;
107
+ height: inherit;
108
+ margin: auto;
109
+ margin-right: 0;
110
+ }
111
+
112
+ .storyblok__overlay-menu-btn-parent {
113
+ border-bottom-left-radius: 5px;
114
+ border-top-left-radius: 5px;
115
+ cursor: pointer;
116
+ margin: 0;
117
+ width: auto;
118
+ }
119
+
120
+ .storyblok__overlay-menu-svg {
121
+ box-sizing: border-box;
122
+ cursor: pointer;
123
+ height: 24px;
124
+ margin: 0 3px;
125
+ width: 24px;
126
+ }
127
+
128
+ .storyblok__overlay--bottom .storyblok__overlay-menu {
129
+ bottom: -40px;
130
+ top: auto;
131
+ }
132
+
133
+ .storyblok__overlay--clicked {
134
+ animation-duration: 0.2s;
135
+ animation-iteration-count: 1;
136
+ animation-name: smoke;
137
+ }
138
+
139
+ .storyblok__actions-menu,
140
+ .storyblok__breadcrumbs-menu {
141
+ background-color: #fff;
142
+ border: 1px solid #dfe3e8;
143
+ border-radius: 5px;
144
+ box-shadow: 0 2px 17px 3px rgba(34, 42, 69, 0.07);
145
+ box-sizing: content-box;
146
+ display: none;
147
+ height: fit-content;
148
+ min-width: 156px;
149
+ overflow: hidden;
150
+ padding: 11px 0;
151
+ position: absolute;
152
+ top: 25px;
153
+ z-index: 2;
154
+ }
155
+
156
+ .storyblok__actions-menu hr,
157
+ .storyblok__breadcrumbs-menu hr {
158
+ background-color: #dfe3e8;
159
+ border: 0;
160
+ height: 1px;
161
+ margin: 11px 0 11px 20px;
162
+ }
163
+
164
+ .storyblok__actions-menu__menu-item,
165
+ .storyblok__breadcrumbs-menu__menu-item {
166
+ align-items: center;
167
+ appearance: none;
168
+ background: #fff;
169
+ border: 0;
170
+ color: #1b243f;
171
+ cursor: pointer;
172
+ display: flex;
173
+ font-family:
174
+ -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, helvetica, arial,
175
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
176
+ font-size: 14px;
177
+ padding: 8px 20px;
178
+ text-align: left;
179
+ width: 100%;
180
+ }
181
+
182
+ .storyblok__actions-menu__menu-item--delete,
183
+ .storyblok__breadcrumbs-menu__menu-item--delete {
184
+ color: #c11c14;
185
+ margin-bottom: 0;
186
+ }
187
+
188
+ .storyblok__actions-menu__menu-item--selected,
189
+ .storyblok__breadcrumbs-menu__menu-item--selected {
190
+ color: #05807f;
191
+ cursor: default;
192
+ margin-bottom: 0;
193
+ }
194
+
195
+ .storyblok__actions-menu__menu-item--selected:hover,
196
+ .storyblok__breadcrumbs-menu__menu-item--selected:hover {
197
+ background: transparent;
198
+ }
199
+
200
+ .storyblok__actions-menu__menu-item:hover,
201
+ .storyblok__breadcrumbs-menu__menu-item:hover {
202
+ background: #eff1f3;
203
+ }
204
+
205
+ .storyblok__actions-menu__menu-item:focus,
206
+ .storyblok__breadcrumbs-menu__menu-item:focus {
207
+ outline: none;
208
+ }
209
+
210
+ .storyblok__actions-menu {
211
+ left: calc(100% - 20px);
212
+ }
213
+
214
+ .storyblok__breadcrumbs-menu {
215
+ left: -10px;
216
+ }
217
+ `,h={OUTLINE:"storyblok--outlined",STYLESHEET:"storyblok-bridge-stylesheet",HINT:"storyblok__hint",HIGHLIGHTER:"storyblok__highlight",OVERLAY:"storyblok__overlay",COMPONENT_BASE:"storyblok__overlay-menu",ACTIONS_MENU:"storyblok__actions-menu",BREADCRUMBS_MENU:"storyblok__breadcrumbs-menu"};class It{constructor(e){this.appVersion="v1",this.inEditor=!0,this.initialized=!1,this.currentUid=null,this.storyId="",this.componentNames={},this.outlineOnMoveInterval=null,this.calcInterval=null,this.canAddBlocks=!1,this.canMoveForward=!1,this.canMoveBackward=!1,this.canDeleteBlocks=!1,this.navigationBreadcrumbs=[],this.focusState=!1,this.actionsEnabled=!1,this.hinter=null,this.highlighter=null,this.overlay=null,this.componentBase=null,this.componentLabel=null,this.breadcrumbsButtonMenu=null,this.breadcrumbsMenu=null,this.actionsMenu=null,this.actionsMenuButton=null,this.actionsMenuItems=null,this.events={input:[],change:[],published:[],unpublished:[],viewLiveVersion:[],enterEditmode:[],enterComponent:[],hoverComponent:[],highlightComponent:[],customEvent:[],pingBack:[],sessionReceived:[],editedBlok:[],deselectBlok:[],addedBlock:[],deletedBlock:[],movedBlock:[],duplicatedBlock:[]};const n={customParent:null,resolveRelations:null,resolveLinks:null,preventClicks:!1,initOnlyOnce:!0,fallbackLang:null};this.config={...n,...e},this.init()}get isInIframe(){return window.top!==window.self}get csProtocol(){let e=location.protocol.replace(":","");return e!=="http"&&e!=="https"&&(e="https"),e}get targetOrigin(){return this.config.customParent?this.config.customParent:_e("_storyblok_env")==="stage"?`${this.csProtocol}://app-beta.storyblok.com`:`${this.csProtocol}://app.storyblok.com`}get lastBreadcrumbItem(){return this.navigationBreadcrumbs[this.navigationBreadcrumbs.length-1]||{}}isInEditor(){return this.inEditor}init(){if(document.body===null){console.error("Body tag not found. Please install the Storyblok bridge script inside the body tag");return}this.config.initOnlyOnce&&document.querySelectorAll(`.${h.HINT}`).length>0||this.isInIframe&&(this.resetAllEvents(),this.addMessageListener(),this.outlineOnMove(),this.buildBridgeStyles(),this.on("enterEditmode",this.enterEditmode),this.isInIframe&&this.sendDataToEditor({action:"initialized",config:this.config}),this.initialized=!0)}keyPress(e,n){(n.key==="z"&&n.metaKey||n.key==="z"&&n.ctrlKey)&&(n.preventDefault(),n.stopImmediatePropagation(),e.sendDataToEditor({action:"undo"})),(n.key==="y"&&n.metaKey||n.key==="y"&&n.ctrlKey)&&(n.preventDefault(),n.stopImmediatePropagation(),e.sendDataToEditor({action:"redo"}))}sendDataToEditor(e){window.parent.postMessage(e,this.targetOrigin)}buildBridgeStyles(){document.getElementById(h.STYLESHEET)?(this.hinter=document.querySelector(`.${h.HINT}`),this.highlighter=document.querySelector(`.${h.HIGHLIGHTER}`),this.overlay=document.querySelector(`.${h.OVERLAY}`),this.componentBase=document.querySelector(`.${h.COMPONENT_BASE}`),this.breadcrumbsButtonMenu=document.querySelector(`.${h.COMPONENT_BASE}-btn-parent`),this.breadcrumbsMenu=document.querySelector(`.${h.BREADCRUMBS_MENU}`),this.actionsMenuButton=document.querySelector(`.${h.COMPONENT_BASE}-btn-action`),this.actionsMenu=document.querySelector(`.${h.ACTIONS_MENU}`),this.componentLabel=document.querySelector(`.${h.COMPONENT_BASE} > .${h.COMPONENT_BASE}-label`),this.createActionsMenuItems()):(this.createBridgeStylesheet(),this.createHinter(),this.createHighlighter(),this.createOverlay(),this.createComponentContext())}createBridgeStylesheet(){const e=document.createElement("style");e.setAttribute("type","text/css"),e.id=h.STYLESHEET,"textContent"in e?e.textContent=Ae:e.styleSheet.cssText=Ae,document.getElementsByTagName("head")[0].appendChild(e)}createHinter(){this.hinter=document.createElement("div"),this.hinter.className=h.HINT,this.hideElement(this.hinter),document.body.appendChild(this.hinter)}createHighlighter(){this.highlighter=document.createElement("div"),this.highlighter.style.opacity=0,this.hideElement(this.highlighter),document.body.appendChild(this.highlighter)}createOverlay(){this.overlay=document.createElement("div"),this.overlay.setAttribute("class",h.OVERLAY),this.overlay.setAttribute("id",h.OVERLAY),this.hideElement(this.overlay),document.body.appendChild(this.overlay)}calculateElementPosition(e,n){if(!n){this.hideElement(e);return}const o=_(n);if(o){const{left:r,top:i}=this.getElementOffset(o);i<=30?this.overlay.classList.add(`${h.OVERLAY}--bottom`):this.overlay.classList.remove(`${h.OVERLAY}--bottom`),e.style.top=`${i}px`,e.style.left=`${r}px`,e.style.width=`${o.offsetWidth}px`,e.style.height=`${o.offsetHeight}px`,e.style.minHeight="5px"}else this.hideElement(e)}getElementOffset(e){const n=e.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,r=window.pageYOffset||document.documentElement.scrollTop;return{top:n.top+r,left:n.left+o}}resetAllEvents(){for(const e in this.events)this.events[e]=[]}addMessageListener(){window.addEventListener&&addEventListener("message",this.receiveMessageFromApp.bind(this),!1)}receiveMessageFromApp(e){e&&e.data&&e.data.action&&this.emit(e.data.action,e.data)}emit(e,...n){const o=this.events[e];if(!(!e||!o||!o.length))for(let r=0;r<o.length;r++)o[r].apply(this,n)}outlineOnMoveHandler(){document.body.classList.add(h.OUTLINE);const e=()=>{document.body.classList.remove(h.OUTLINE),this.hinter&&(this.hinter.style.opacity=0)};this.outlineOnMoveInterval&&clearTimeout(this.outlineOnMoveInterval),this.outlineOnMoveInterval=setTimeout(e,800)}outlineOnMove(){document.addEventListener("mousemove",this.outlineOnMoveHandler.bind(this),!1)}on(e,n){if(e.constructor===Array){for(const o of e)this.subscribeEvent(o,n);return}this.subscribeEvent(e,n)}subscribeEvent(e,n){e==="input"&&(this.actionsEnabled=!0),this.events[e].indexOf(n)===-1&&this.events[e].push(n)}pingEditor(e){this.isInIframe?this.sendDataToEditor({action:"ping"}):(this.inEditor=!1,e(this)),this.on("pingBack",this.handlePingBack(e))}handlePingBack(e){return()=>{this.inEditor=!0,e(this)}}handleEditedBlok(e){this.navigationBreadcrumbs=e.breadcrumbs,this.canAddBlocks=e.canAddBlocks||!1,this.canMoveForward=e.canMoveForward||!1,this.canMoveBackward=e.canMoveBackward||!1,this.canDeleteBlocks=e.canDeleteBlocks||!1,this.updateComponentBase(e.blok)}handleAddMoveBlok(e){const n=_(`${this.storyId}-${e.blockId}`);n&&this.handleOpenBlok(n)}handleDeselectBlock(){document.querySelectorAll("[data-blok-focused]").forEach(e=>e.removeAttribute("data-blok-focused")),this.hideElement(this.overlay)}handleDuplicatedBlok(e){this.handleDeselectBlock(),setTimeout(()=>{const n=_(`${this.storyId}-${e.blockId}`);this.handleOpenBlok(n)},500)}handleWindowClick(e){this.config.preventClicks&&(e.preventDefault(),e.stopPropagation()),this.handleOpenBlok(e.target,e)}handleOpenBlok(e,n){const o=ge(e);if(o){n&&o.uid!==this.currentUid&&(n.preventDefault(),n.stopPropagation()),this.currentUid=o.uid,this.storyId=o.id,this.openBlok(o);return}n&&this.toggleFocusElement(e,!0)}enterEditmode(e){const n=Rt(document.body);e&&e.appVersion&&(this.appVersion=e.appVersion),e&&e.componentNames&&(this.componentNames=e.componentNames);for(let o=0;o<n.length;o++){const r=n[o].el,i=n[o].options;!r||r.nodeType!==Node.ELEMENT_NODE||(i.name=this.componentNames[i.name]||i.name,r.setAttribute("data-blok-c",JSON.stringify(i)),r.setAttribute("data-blok-uid",`${i.id}-${i.uid}`),r.offsetHeight<5&&(r.style["min-height"]="5px"),r.classList.add("storyblok__outline"))}if(this.on("addedBlock",this.handleAddMoveBlok),this.on("duplicatedBlock",this.handleDuplicatedBlok),this.on("movedBlock",this.handleAddMoveBlok),this.on("enterComponent",this.enterComponent),this.on("highlightComponent",this.highlightComponent),this.on("hoverComponent",this.hoverComponent),this.on("editedBlok",this.handleEditedBlok),this.on("deselectBlok",this.handleDeselectBlock),e&&e.blockId&&this.config.setActiveBlock){const o=_(`${e.storyId}-${e.blockId}`);this.handleOpenBlok(o)}window.addEventListener("click",this.handleWindowClick.bind(this)),this.calcInterval!==null&&window.clearInterval(this.calcInterval),this.calcInterval=window.setInterval(()=>{this.calculateElementPosition(this.overlay,`${this.storyId}-${this.currentUid}`)},300)}highlightComponent(e){this.highlighter.innerHTML="",e.componentIds.length>0?(this.highlighter.style.display="block",this.highlighter.style.opacity=1):(this.highlighter.style.display="none",this.highlighter.style.opacity=0);for(let n=0;n<e.componentIds.length;n++){const o=`${e.storyId}-${e.componentIds[n]}`,r=_(o);if(r){const i=document.createElement("div");i.setAttribute("class",h.HIGHLIGHTER),this.highlighter.appendChild(i),this.calculateElementPosition(i,o),e.componentId===e.componentIds[n]&&!ke(r)&&typeof r.scrollIntoView<"u"&&r.scrollIntoView()}}}hoverComponent(e){this.calculateElementPosition(this.hinter,`${e.storyId}-${e.componentId}`),this.hinter.style.opacity=1,this.hinter.style.display="block"}toggleFocusElement(e,n=!1){if(!Ct(this.overlay,e)){if(this.handleDeselectBlock(),!n&&this.storyId===_e("_storyblok")){e.setAttribute("data-blok-focused",!0),this.showFocusedElement(this.overlay),this.focusState=!1;return}this.focusState||this.sendDataToEditor({action:"noFocus"})}}showFocusedElement(e){if(!this.currentUid){this.hideElement(e);return}this.showElement(e),this.calculateElementPosition(e,`${this.storyId}-${this.currentUid}`)}handleBlokActions(e){this.sendDataToEditor({action:e,blok:this.lastBreadcrumbItem}),e==="addBlockBefore"||e==="addBlockAfter"||e==="copy"?this.hideElement(this.actionsMenu):this.hideElement(this.overlay),(e==="moveForward"||e==="moveBackward")&&(this.focusState=!0)}hideElement(e){e.style.display="none"}showElement(e){e.style.display="block"}toggleElement(e){if(e.style.display==="block"){this.hideElement(e);return}this.showElement(e)}enterComponent(e){const n=_(`${e.storyId}-${e.componentId}`),o=ge(n);o&&(this.hinter.style.opacity=0,this.hinter.style.display="none",this.currentUid=o.uid,this.storyId=o.id,this.scrollIntoView(n),this.handleEditedBlok(e))}scrollIntoView(e){e&&!ke(e)&&typeof e.scrollIntoView<"u"&&setTimeout(()=>{e.scrollIntoView({behavior:"smooth",block:"start"})},100)}openBlok(e){this.sendDataToEditor({action:"edit",dataC:e,config:this.config})}createComponentContext(){this.createComponentBase(),this.createActionsMenu(),this.createActionsMenuItems(),this.createBreadcrumbsMenu(),this.createActionsMenuButton(),this.createBreadcrumbsMenuButton(),this.createComponentLabel(),this.createComponentButtonLabel()}createComponentBase(){this.componentBase=document.createElement("div"),this.componentBase.setAttribute("class",h.COMPONENT_BASE),this.componentBase.setAttribute("id",h.COMPONENT_BASE),this.overlay.append(this.componentBase)}createComponentLabel(){this.componentLabel=document.createElement("span"),this.componentLabel.setAttribute("class",`${h.COMPONENT_BASE}-label`),this.componentBase.prepend(this.componentLabel)}createComponentButtonLabel(){const e=document.createElement("span");e.setAttribute("class",`${h.COMPONENT_BASE}-label`),this.breadcrumbsButtonMenu.appendChild(e)}updateComponentLabel(e){document.querySelectorAll(`.${h.COMPONENT_BASE}-label`).forEach(n=>n.innerText=this.componentNames[e.name]||ve(e))}updateComponentBase(e){this.hideElement(this.actionsMenu),this.hideElement(this.breadcrumbsMenu),this.overlay.classList.add(`${h.OVERLAY}--clicked`),setTimeout(()=>{this.overlay.classList.remove(`${h.OVERLAY}--clicked`)},400),this.navigationBreadcrumbs.length>1?(this.updateBreadcrumbsMenu(this.navigationBreadcrumbs),this.actionsEnabled?this.updateActionsMenu():(this.componentBase.setAttribute("class",`${h.COMPONENT_BASE} ${h.COMPONENT_BASE}--simple`),this.hideElement(this.actionsMenuButton)),this.hideElement(this.componentLabel)):(this.hideElement(this.breadcrumbsButtonMenu),this.hideElement(this.actionsMenuButton),this.showElement(this.componentLabel)),this.updateComponentLabel(e);const n=_(`${this.storyId}-${e.uid}`);n&&this.toggleFocusElement(n)}createBreadcrumbsMenuButton(){this.breadcrumbsButtonMenu=document.createElement("button"),this.breadcrumbsButtonMenu.setAttribute("class",`${h.COMPONENT_BASE}-btn ${h.COMPONENT_BASE}-btn-parent`),this.breadcrumbsButtonMenu.prepend(Ee({viewBox:"0 0 24 24",svgClass:`${h.COMPONENT_BASE}-svg`,path:"M13.73 14.284l-2.197-2.216 2.197-2.217a1.051 1.051 0 000-1.477 1.03 1.03 0 00-1.465 0l-2.93 2.955a1.043 1.043 0 00-.287.554l-.014.123v.123c.014.247.115.489.301.677l2.93 2.956a1.03 1.03 0 001.465 0 1.051 1.051 0 000-1.478z",pathFill:"#ffffff"})),this.breadcrumbsButtonMenu.addEventListener("click",()=>{this.toggleElement(this.breadcrumbsMenu),this.hideElement(this.actionsMenu)}),this.componentBase.prepend(this.breadcrumbsButtonMenu)}createBreadcrumbsMenu(){this.breadcrumbsMenu=document.createElement("div"),this.breadcrumbsMenu.setAttribute("class",h.BREADCRUMBS_MENU),this.breadcrumbsMenu.setAttribute("id",h.BREADCRUMBS_MENU),this.componentBase.append(this.breadcrumbsMenu)}updateBreadcrumbsMenu(e){this.breadcrumbsMenu.innerHTML="";const n=[];for(let o=0;o<e.length;o++){n[o]=document.createElement("button"),n[o].innerHTML=ve({display_name:this.componentNames[e[o].component],name:e[o].component});const r=e[o];n[o].addEventListener("click",i=>{i.stopPropagation(),this.currentUid=r._uid,this.openBlok({id:this.storyId,uid:r._uid,name:r.component})}),n[o].classList.add(`${h.BREADCRUMBS_MENU}__menu-item`),e[o]._uid===this.currentUid&&(n[o].classList.add(`${h.BREADCRUMBS_MENU}__menu-item--selected`),n[o].setAttribute("disabled",!0)),this.breadcrumbsMenu.appendChild(n[o]),this.breadcrumbsButtonMenu.style.display="flex"}}createActionsMenuButton(){this.actionsMenuButton=document.createElement("button"),this.actionsMenuButton.setAttribute("class",`${h.COMPONENT_BASE}-btn ${h.COMPONENT_BASE}-btn-action`),this.actionsMenuButton.prepend(Ee({viewBox:"0 0 24 24",svgClass:`${h.COMPONENT_BASE}-svg`,path:"M7.5 11a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm10 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm-5 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3z",pathFill:"#ffffff"})),this.actionsMenuButton.addEventListener("click",()=>{this.toggleElement(this.actionsMenu),this.breadcrumbsMenu&&this.hideElement(this.breadcrumbsMenu)}),this.componentBase.append(this.actionsMenuButton)}createActionsMenuItems(){this.actionsMenuItems=[{eventFunction:()=>this.handleBlokActions.bind(this,"addBlockBefore"),innerHTML:"Add Block Before",order:0,show:()=>this.canAddBlocks},{eventFunction:()=>this.handleBlokActions.bind(this,"addBlockAfter"),innerHTML:"Add Block After",order:1,show:()=>this.canAddBlocks},{eventFunction:()=>this.handleBlokActions.bind(this,"duplicateBlock"),innerHTML:"Duplicate",order:2,show:()=>this.canAddBlocks},{eventFunction:()=>this.handleBlokActions.bind(this,"copy"),innerHTML:"Copy",order:3,show:()=>this.appVersion==="v2"},{separator:!0,order:4,show:()=>this.canAddBlocks&&this.canMoveForward||!!(this.canMoveBackward&&this.lastBreadcrumbItem._parentindex)},{eventFunction:()=>this.handleBlokActions.bind(this,"moveForward"),innerHTML:"Move Forward",order:5,show:()=>this.canMoveForward},{eventFunction:()=>this.handleBlokActions.bind(this,"moveBackward"),innerHTML:"Move Backward",order:6,show:()=>this.canMoveBackward&&this.lastBreadcrumbItem._parentindex},{separator:!0,order:7,show:()=>this.canAddBlocks&&this.canDeleteBlocks},{eventFunction:()=>this.handleBlokActions.bind(this,"deleteBlock"),className:`${h.ACTIONS_MENU}__menu-item--delete`,innerHTML:"Delete",order:8,show:()=>this.canDeleteBlocks}]}createActionsMenu(){this.actionsMenu=document.createElement("div"),this.actionsMenu.setAttribute("class",h.ACTIONS_MENU),this.actionsMenu.setAttribute("id",h.ACTIONS_MENU),this.componentBase.append(this.actionsMenu)}updateActionsMenu(){this.actionsMenu.innerHTML="";const e=`${h.ACTIONS_MENU}__menu-item`,n="button",o="click";this.actionsMenuItems.sort((r,i)=>r.order>i.order?1:i.order>r.order?-1:0).forEach(r=>{if(r.separator&&r.show()){this.actionsMenu.appendChild(document.createElement("hr"));return}const i=document.createElement(r.element?r.element:n);i.classList.add(e),r.className&&i.classList.add(r.className),i.innerHTML=r.innerHTML,r.eventFunction&&i.addEventListener(r.event?r.event:o,r.eventFunction()),r.show()&&this.actionsMenu.appendChild(i)}),this.actionsMenuButton.style.display="flex"}}var xt=Object.defineProperty,Pt=(t,e,n)=>e in t?xt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,x=(t,e,n)=>Pt(t,typeof e!="symbol"?e+"":e,n);let Ht=class{constructor(t){x(this,"isInEditor"),x(this,"enterEditmode"),x(this,"pingEditor"),x(this,"on");const e=new It(t);this.isInEditor=()=>e.isInEditor(),this.enterEditmode=n=>{e.enterEditmode(n)},this.pingEditor=n=>{e.pingEditor(n)},this.on=(n,o)=>{e.on(n,o)}}};const $=t=>({tag:"success",value:t}),w=t=>({tag:"failure",error:t,path:[]}),we=(t,e)=>({tag:"failure",error:t.error,path:[e,...t.path]}),Ut=t=>typeof t>"u",Ft=t=>typeof t=="string",jt=t=>typeof t=="object"&&t!==null,J=Symbol("propertyAbsent"),Me=Symbol("omitProperty"),Vt="Not an object",qt=t=>we(w("Property is missing"),{tag:"object",key:t}),zt=t=>{const e=Object.entries(t);return n=>{if(!jt(n))return w(Vt);const o={};for(let r=0;r<e.length;r++){const[i,l]=e[r],s=n[i];if(s===void 0&&!n.hasOwnProperty(i)){const a=l(J);if(a.tag==="failure"||a.value===J)return qt(i);a.value!==Me&&(o[i]=a.value)}else{const a=l(s);if(a.tag==="failure")return we(a,{tag:"object",key:i});o[i]=a.value}}return $(o)}},Dt=t=>Ut(t)?$(t):w("Not undefined"),P=t=>Ft(t)?$(t):w("Not a string"),Gt=(...t)=>e=>{for(const n of t){const o=n(e);if(o.tag==="success")return $(o.value)}return w("No parser in the union matched")},Yt=t=>Gt(Kt,Dt,t),Kt=t=>t===J?$(Me):w("not optional");zt({name:P,space:Yt(P),uid:P,id:P});const Wt=Object.freeze(Object.defineProperty({__proto__:null,default:Ht},Symbol.toStringTag,{value:"Module"})),Jt={class:"fallback-component"},Qt={class:"component"},Xt=Object.freeze(Object.defineProperty({__proto__:null,default:((t,e)=>{const n=t.__vccOpts||t;for(const[o,r]of e)n[o]=r;return n})(c.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(t){return(e,n)=>(c.openBlock(),c.createElementBlock("div",Jt,[c.createElementVNode("p",null,[n[0]||(n[0]=c.createTextVNode(" Component could not be found for blok ",-1)),c.createElementVNode("span",Qt,c.toDisplayString(t.blok.component),1),n[1]||(n[1]=c.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));p.StoryblokClient=ee,p.StoryblokComponent=Y,p.StoryblokRichText=be,p.StoryblokVue=Bt,p.apiPlugin=ft,p.buildStoryblokImage=V,p.renderRichText=at,p.splitTableRows=oe,p.useStoryblok=St,p.useStoryblokApi=Mt,p.useStoryblokBridge=he,p.useStoryblokRichText=At,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));