@storyblok/vue 11.1.0 → 11.2.0
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.
|
@@ -14,6 +14,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
14
14
|
type: PropType<SbVueRichTextComponentMap>;
|
|
15
15
|
required: false;
|
|
16
16
|
};
|
|
17
|
+
data: {
|
|
18
|
+
type: PropType<unknown>;
|
|
19
|
+
required: false;
|
|
20
|
+
};
|
|
17
21
|
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
18
22
|
[key: string]: any;
|
|
19
23
|
}> | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
@@ -31,5 +35,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
31
35
|
type: PropType<SbVueRichTextComponentMap>;
|
|
32
36
|
required: false;
|
|
33
37
|
};
|
|
38
|
+
data: {
|
|
39
|
+
type: PropType<unknown>;
|
|
40
|
+
required: false;
|
|
41
|
+
};
|
|
34
42
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
35
43
|
export default _default;
|
|
@@ -7,6 +7,7 @@ export type SbVueRichTextComponentMap = {
|
|
|
7
7
|
export interface SbVueRichTextRenderContext {
|
|
8
8
|
optimizeImage?: boolean | Partial<SbRichTextImageOptions>;
|
|
9
9
|
components?: SbVueRichTextComponentMap;
|
|
10
|
+
data?: unknown;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Creates a Vue-compatible render function for Storyblok Rich Text documents.
|
package/dist/storyblok-vue.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
(function(y,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(y=typeof globalThis<"u"?globalThis:y||self,a(y.storyblokVue={},y.Vue))})(this,(function(y,a){"use strict";var pt=Object.defineProperty;var gt=(y,a,g)=>a in y?pt(y,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):y[a]=g;var d=(y,a,g)=>gt(y,typeof a!="symbol"?a+"":a,g);const g=(e="")=>e.includes("/cdn/"),he=(e,t=25,r=1)=>({...e,per_page:t,page:r}),fe=e=>new Promise(t=>setTimeout(t,e)),de=(e=0,t)=>Array.from({length:e},t),ye=(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return de(r,(s,i)=>i*n+e)},pe=async(e,t)=>Promise.all(e.map(t)),ge=(e=[],t)=>e.map(t).reduce((r,n)=>[...r,...n],[]),z=e=>{if(/%[0-9A-F]{2}/i.test(e))try{return decodeURIComponent(e)}catch{return e}return e},N=(e,t,r)=>{const n=[];for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];if(i==null)continue;const l=r?"":encodeURIComponent(s);let o;typeof i=="object"?o=N(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):o=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,n.push(o)}return n.join("&")},F=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var me=class{constructor(e){d(this,"baseURL");d(this,"timeout");d(this,"headers");d(this,"responseInterceptor");d(this,"fetch");d(this,"ejectInterceptor");d(this,"url");d(this,"parameters");d(this,"fetchOptions");this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}patch(e,t){return this.url=e,this.parameters=t,this._methodHandler("patch")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(n=>{r.data=n});for(const n of e.headers.entries())t[n[0]]=n[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${N(this.parameters)}`:r=JSON.stringify(this.parameters);const n=new URL(t),s=new AbortController,{signal:i}=s;let l=null;this.timeout&&(l=setTimeout(()=>s.abort(),this.timeout));try{const o=await this.fetch(`${n}`,{method:e,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const c=await this._responseHandler(o);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(o){return o.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:o.message||o.toString()||"An unknown error occurred"}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,n)=>{if(t.test(`${e.status}`))return r(e);n({message:this._normalizeErrorMessage(e.data),status:e.status,response:e})})}};const be={PUBLISHED:"published"},ke=25,O={SMALL:25,MEDIUM:50,LARGE:75},k={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},D=1e3,w=3;function _e(e,t){const r=e.includes("/cdn/stories/"),n=e.split("/").length>3&&!e.endsWith("/cdn/stories"),s="find_by"in t;return r&&n||s}function Re(e){return e<=O.SMALL?k.SINGLE_OR_SMALL:e<=O.MEDIUM?k.MEDIUM:e<=O.LARGE?k.LARGE:k.VERY_LARGE}function S(e,t,r={},n){return r.userRateLimit!==void 0?Math.min(r.userRateLimit,D):r.serverHeadersRateLimit!==void 0?Math.min(r.serverHeadersRateLimit,D):n!==void 0?n:!e||!t||_e(e,t)?k.SINGLE_OR_SMALL:Re(t.per_page||ke)}function we(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],r=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!r)return null;const n={};if(t){const s=t.match(/r=(\d+)/);s&&(n.remaining=Number.parseInt(s[1],10))}if(r){const s=r.match(/q=(\d+)/);s&&(n.max=Number.parseInt(s[1],10))}return Object.keys(n).length>0?n:null}function Se(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Ae=class extends Error{constructor(e){super(e),this.name="AbortError"}};function ve(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const n=[];let s=[],i=0,l=!1;const o=async()=>{i++;const u=n.shift();if(u)try{const h=await e(...u.args);u.resolve(h)}catch(h){u.reject(h)}const f=setTimeout(()=>{i--,n.length>0&&o(),s=s.filter(h=>h!==f)},r);s.includes(f)||s.push(f)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,h)=>{n.push({resolve:f,reject:h,args:u}),i<t&&o()});return c.abort=()=>{l=!0,s.forEach(clearTimeout),s=[],n.forEach(u=>u.reject(()=>new Ae("Throttle function aborted"))),n.length=0},c}var $e=class{constructor(e,t=1e3){d(this,"queues");d(this,"interval");d(this,"throttledRequestFn");this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=ve(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let T={};const m={};var G=class{constructor(e,t){d(this,"client");d(this,"maxRetries");d(this,"retriesDelay");d(this,"throttleManager");d(this,"accessToken");d(this,"cache");d(this,"resolveCounter");d(this,"relations");d(this,"links");d(this,"version");d(this,"rateLimitConfig");d(this,"cvMode");d(this,"richTextResolver");d(this,"resolveNestedRelations");d(this,"stringifiedStoriesCache");d(this,"inlineAssets");var s;let r=e.endpoint||t;if(!r){const i=e.https===!1?"http":"https";e.oauthToken?r=`${i}://${F(e.region)}/v1`:r=`${i}://${F(e.region)}/v2`}const n=new Headers;!e.oauthToken&&typeof window<"u"||n.set("Content-Type","application/json"),n.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{n.set(i,l)}),e.oauthToken&&n.set("Authorization",e.oauthToken),this.rateLimitConfig=Se(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=e.retriesDelay??300,this.throttleManager=new $e(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.cvMode=((s=e.cache)==null?void 0:s.cv)??"auto",this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||be.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new me({baseURL:r,timeout:e.timeout||0,headers:n,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),!e.cv&&this.cvMode==="auto"&&(e.cv=m[e.token]),Array.isArray(e.resolve_relations)?e.resolve_relations=e.resolve_relations.map(z).join(","):typeof e.resolve_relations=="string"&&(e.resolve_relations=z(e.resolve_relations)),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return g(e)?this.parseParams(t):t}makeRequest(e,t,r,n,s){const i=this.factoryParamOptions(e,he(t,r,n));return this.cacheResponse(e,i,void 0,s)}get(e,t={},r){t||(t={});const n=`/${e}`;g(n)&&(t.version=t.version||this.version);const s=this.factoryParamOptions(n,t);return this.cacheResponse(n,s,void 0,r)}async getAll(e,t={},r,n){const s=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1);t.version=t.version||this.version;const o=1,c=await this.makeRequest(i,t,s,o,n);return ge([c,...await pe(ye(o,c.total?Math.ceil(c.total/(c.perPage||s)):1),u=>this.makeRequest(i,t,s,u+1,n))],u=>Object.values(u.data[l]))}post(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"post",n,t,r)}put(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"put",n,t,r)}patch(e,t={},r){const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"patch",n,t,r)}delete(e,t={},r){t||(t={});const n=`/${e}`,s=S(void 0,void 0,this.rateLimitConfig,w);return this.throttleManager.execute(s,"delete",n,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const n=e[t];n&&n.fieldtype==="multilink"&&n.linktype==="story"&&typeof n.id=="string"&&this.links[r][n.id]?n.story=this._cleanCopy(this.links[r][n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[r][n.uuid]&&(n.story=this._cleanCopy(this.links[r][n.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const n=e[t];typeof n=="string"?e[t]=this.getStoryReference(r,n):Array.isArray(n)&&(e[t]=n.map(s=>this.getStoryReference(r,s)).filter(Boolean))}_insertRelations(e,t,r,n){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,n);return}const s=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(s):r===s)&&this._resolveField(e,t,n)}iterateTree(e,t,r){const n=(s,i="")=>{if(!(!s||s._stopResolving)){if(Array.isArray(s))s.forEach((l,o)=>n(l,`${i}[${o}]`));else if(typeof s=="object")for(const l in s){const o=i?`${i}.${l}`:l;(s.component&&s._uid||s.type==="link")&&(this._insertRelations(s,l,t,r),this._insertLinks(s,l,r)),n(s[l],o)}}};n(e.content)}async resolveLinks(e,t,r){let n=[];if(e.link_uuids){const s=e.link_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.link_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(",")})).data.stories.forEach(c=>{n.push(c)})}else n=e.links;n.forEach(s=>{this.links[r][s.uuid]={...s,_stopResolving:!0}})}async resolveRelations(e,t,r){let n=[];if(e.rel_uuids){const s=e.rel_uuids.length,i=[],l=50;for(let o=0;o<s;o+=l){const c=Math.min(s,o+l);i.push(e.rel_uuids.slice(o,c))}for(let o=0;o<i.length;o++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[o].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{n.push(c)});n.length>0&&(e.rels=n,delete e.rel_uuids)}else n=e.rels;n&&n.length>0&&n.forEach(s=>{this.relations[r][s.uuid]={...s,_stopResolving:!0}})}async resolveStories(e,t,r){var s,i;let n=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(n=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(i=e.link_uuids)!=null&&i.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],n,r);e.story?this.iterateTree(e.story,n,r):e.stories.forEach(l=>{this.iterateTree(l,n,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,n){const s=N({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await i.get(s);if(c)return Promise.resolve(c)}const l=!g(e)&&this.rateLimitConfig.isManagementApi?w:void 0,o=S(e,t,this.rateLimitConfig,l);return new Promise(async(c,u)=>{var f;try{const h=await this.throttleManager.execute(o,"get",e,t,n);if(h.status!==200)return u(h);let p={data:h.data,headers:h.headers};const b=we(h.headers);if((b==null?void 0:b.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=b.max),(f=h.headers)!=null&&f["per-page"]&&(p=Object.assign({},p,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),p.data.story||p.data.stories){const P=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${P}`),p=await this.processInlineAssets(p)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(s,p);const M=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(M&&m[t.token]&&m[t.token]!==p.data.cv&&await this.flushCache(),m[t.token]=p.data.cv),c(p)}catch(h){if(h.response&&h.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await fe(this.retriesDelay),this.cacheResponse(e,t,r).then(c).catch(u);u(h)}})}throttledRequest(e,t,r,n){return this.client.setFetchOptions(n),this.client[e](t,r)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(m[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(T[e])},getAll(){return Promise.resolve(T)},set(e,t){return T[e]=t,Promise.resolve(void 0)},flush(){return T={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(s=>t(s));let n={...r};n.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(n={...e.data.assets.find(s=>s.id===n.id),...n});for(const s in n)typeof n[s]=="object"&&(n[s]=t(n[s]));return n};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}};function j(e,t){if(!t)return{src:e,attrs:{}};let r=0,n=0;const s={},i=[];function l(c,u,f,h,p){typeof c!="number"||c<=u||c>=f?console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase()+h.slice(1)} value must be a number between ${u} and ${f} (inclusive)`):p.push(`${h}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(s.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(s.height=t.height,n=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete s.width,delete s.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(s.loading=t.loading),t.class&&(s.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:f,fill:h,format:p,grayscale:b,quality:M,rotate:P}=c||{};u&&l(u,0,100,"blur",i),M&&l(M,0,100,"quality",i),f&&l(f,0,100,"brightness",i),h&&i.push(`fill(${h})`),b&&i.push("grayscale()"),P&&[0,90,180,270].includes(t.filters.rotate||0)&&i.push(`rotate(${P})`),p&&["webp","png","jpeg"].includes(p)&&i.push(`format(${p})`)}t.srcset&&(s.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${i.length>0?`filters:${i.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,f]=c;return`${e}/m/${u}x${f}/${i.length>0?`filters:${i.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(s.sizes=t.sizes.join(", "))}let o=`${e}/m/`;return(r>0||n>0)&&(o=`${o}${r}x${n}/`),i.length>0&&(o=`${o}filters:${i.join(":")}`),{src:o,attrs:s}}function I(e,t){if(e===t)return!0;if(e==null||t===null||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length!==t.length?!1:e.every((s,i)=>I(s,t[i]));const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&I(e[s],t[s]))}const Te=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"];function Le(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ce(){const e=new Map;return t=>{const r=(e.get(t)||0)+1;return e.set(t,r),`${t}-${r}`}}const L={paragraph:{tag:"p",content:!0},doc:null,text:null,emoji:{tag:"img",attrs:{style:"width: 1.25em; height: 1.25em; vertical-align: text-top;",draggable:"false",loading:"lazy"}},blockquote:{tag:"blockquote",content:!0},heading:{resolve:e=>`h${typeof(e==null?void 0:e.level)=="number"?Math.min(6,Math.max(1,e.level)):1}`},bullet_list:{tag:"ul",content:!0},ordered_list:{tag:"ol",attrs:{order:1},content:!0},list_item:{tag:"li",content:!0},code_block:{tag:"pre",children:[{tag:"code",content:!0}]},hard_break:{tag:"br"},horizontal_rule:{tag:"hr"},image:{tag:"img"},table:{tag:"table",content:!0},tableRow:{tag:"tr",content:!0},tableCell:{tag:"td",attrs:{colspan:1,rowspan:1},content:!0},tableHeader:{tag:"th",attrs:{colspan:1,rowspan:1},content:!0},blok:null},Ee={link:{tag:"a",attrs:{rel:"noopener noreferrer nofollow",linktype:"url",custom:{}},content:!0},bold:{tag:"strong",content:!0},italic:{tag:"em",content:!0},strike:{tag:"s",content:!0},underline:{tag:"u",content:!0},code:{tag:"code",content:!0},superscript:{tag:"sup",content:!0},subscript:{tag:"sub",content:!0},highlight:{tag:"mark",content:!0},textStyle:{tag:"span",content:!0},anchor:{tag:"span",content:!0},styled:{tag:"span",content:!0}};function Me(e){return Object.entries(e).filter(([,t])=>x(t)).map(([t,r])=>`${Oe(t)}: ${r};`).join(" ")}function Pe(e){return e.split(";").map(t=>t.trim()).filter(Boolean).reduce((t,r)=>{const n=r.indexOf(":");if(n===-1)return t;const s=r.slice(0,n).trim(),i=r.slice(n+1).trim();return!s||!i||(t[Ne(s)]=i),t},{})}function Ne(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function Oe(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function x(e){return e!=null&&e!==""}const je={highlight:{color:"backgroundColor"},textStyle:{color:"color"},paragraph:{textAlign:"textAlign"},heading:{textAlign:"textAlign"},tableCell:{backgroundColor:"backgroundColor",colwidth:"width"},tableHeader:{colwidth:"width"}},Ie={fallbackImage:"src",body:"data-body",colspan:"colSpan",rowspan:"rowSpan",name:"data-name",emoji:"data-emoji",order:"start"},xe=new Set(["level","linktype","uuid","anchor","meta_data","copyright","source"]),qe=new Set(["colspan","rowspan","order"]);function He(e){const{linktype:t,href:r,anchor:n}=e;if(t==="story")return`${typeof r=="string"?r:""}${typeof n=="string"&&n?`#${n}`:""}`;if(t==="email"&&typeof r=="string")return`mailto:${r.replace(/^mailto:/,"")}`}function Ue(e){const t={};let r={};if(!(e in L))return{staticAttrs:r,staticStyle:t};const n=L[e];if(!n||!("attrs"in n))return{staticAttrs:r,staticStyle:t};const s=n.attrs||{},i="style"in s&&typeof s.style=="string"?s.style:"",{style:l,...o}=s;return r=o,i&&Object.assign(t,Pe(i)),{staticAttrs:r,staticStyle:t}}function Ve(e){return Array.isArray(e)?e[0]!=null?`${e[0]}px`:void 0:typeof e=="number"||typeof e=="string"?e:String(e)}function ze(e,t,r,n,s,i,l){if(!x(t)||xe.has(e)||qe.has(e)&&t===1)return;if(e in n){const c=n[e],u=Ve(t);u!==void 0&&x(u)&&(i[c]=u);return}const o=s[e]??e;if(o==="custom"&&r==="link"&&typeof t=="object"&&t!==null){for(const[c,u]of Object.entries(t))l[c]=String(u);return}if(typeof t=="object"&&t!==null){l[o]=JSON.stringify(t);return}l[o]=t}function _(e,t={},r={}){const{staticAttrs:n,staticStyle:s}=Ue(e),i={...s},l={},o=je[e]||{},c={...Ie,...r},u={...n,...t};for(const[f,h]of Object.entries(u))ze(f,h,e,o,c,i,l);if(e==="link"){const f=He(t);f!==void 0&&(l.href=f)}return{...l,...Object.keys(i).length>0&&{style:i}}}const Fe=e=>String(e).replace(/[&"'<>]/g,t=>{switch(t){case"&":return"&";case'"':return""";case"'":return"'";case"<":return"<";case">":return">";default:return t}});function C(e){if(e.type!=="text"||!e.marks)return null;for(const t of e.marks)if(t.type==="link")return t;return null}function B(e,t){return!e||!t?!1:I(e.attrs??{},t.attrs??{})}function De(e){return e.type!=="text"||!e.marks?[]:e.marks.filter(t=>t.type!=="link")}function Ge(e){const t=[];let r=0;const n=e.length;for(;r<n;){const s=e[r],i=C(s);if(i){const l=[s];let o=r+1;for(;o<n&&B(i,C(e[o]));)l.push(e[o]),o++;t.push({nodes:l,linkMark:i,_key:`group-link-${r}`}),r=o}else t.push({nodes:[s],linkMark:null,_key:`group-node-${r}`}),r++}return t}function K(e){const t=e.content;if(!(t!=null&&t.length))return!1;for(const r of t)if(r.type!=="tableHeader")return!1;return!0}function J(e){if(!(e!=null&&e.length))return{headerRows:[],bodyRows:[]};let t=0;for(;t<e.length&&K(e[t]);)t++;return{headerRows:e.slice(0,t),bodyRows:e.slice(t)}}function W(e,t=!1){if(!e)return[];if(Array.isArray(e))return e;const r=e.type==="doc"?e.content||[]:[e];return t?Y(r,Ce()):r}function Y(e,t){return e.map(r=>{var n;return{...r,_key:t(r.type),marks:(n=r.marks)==null?void 0:n.map(s=>({...s,_key:t(s.type)})),...r.content?{content:Y(r.content,t)}:{}}})}function R(e){const t=e.type,r=L[t]??Ee[t];return r?"resolve"in r&&typeof r.resolve=="function"?r.resolve(e.attrs):"tag"in r&&typeof r.tag=="string"?r.tag:null:null}function E(e){return Te.includes(e)}function Q(e){const t=L[e.type];return t&&"children"in t?t.children:null}function Be(e){let t="";for(const r in e){const n=e[r];n!=null&&(t+=` ${r}="${Fe(n)}"`)}return t}function Ke(e,t){const r=W(e);return r!=null&&r.length?X(r,t):""}function q(e,t){var o;if(e.type==="text")return Z(e,e.marks,t);const r=e.content?X(e.content,t):"",n=(o=t==null?void 0:t.renderers)==null?void 0:o[e.type];if(n)return n({...e,children:r,context:t});if(e.type==="blok")return console.warn('"blok" nodes require a custom renderer in renderRichText.'),"";const s=R(e);if(!s)return r;if(e.type==="image"&&(t!=null&&t.optimizeImage))return Je(e,t);const i=A(e.type,e.attrs);if(E(s))return`<${s}${i}>`;if(e.type==="table")return`<${s}${i}>${Qe(e.content,t)}</${s}>`;const l=Q(e);return l?`<${s}>${ee(e.type,l,e.attrs,r)}</${s}>`:`<${s}${i}>${r}</${s}>`}function Je(e,t){const r=e.attrs,n=r==null?void 0:r.src;let s=r;if(n){const{src:l,attrs:o}=j(n,t.optimizeImage);s={...r,src:l,...o}}const i=A("image",s);return i?`<img${i}>`:"<img>"}function X(e,t){let r="",n=0;const s=e.length;for(;n<s;){const i=e[n],l=C(i);if(l){let o=n+1;for(;o<s&&B(l,C(e[o]));)o++;r+=Ye(e,n,o,l,t),n=o}else r+=q(i,t),n++}return r}function Z(e,t,r){let n=Le(e.text);if(!(t!=null&&t.length))return n;for(const s of t)n=We(n,s,r);return n}function We(e,t,r){var i;const n=(i=r==null?void 0:r.renderers)==null?void 0:i[t.type];if(n)return n({...t,children:e});const s=R(t);return s?`<${s}${A(t.type,t.attrs)}>${e}</${s}>`:e}function Ye(e,t,r,n,s){var c,u;let i="";for(let f=t;f<r;f++){const h=e[f],p=(c=h.marks)==null?void 0:c.filter(b=>b.type!=="link");i+=Z(h,p,s)}const l=(u=s==null?void 0:s.renderers)==null?void 0:u[n.type];if(l)return l({...n,children:i});const o=R(n);return o?`<${o}${A(n.type,n.attrs)}>${i}</${o}>`:i}function Qe(e,t){if(!(e!=null&&e.length))return"";let r=0;for(;r<e.length&&K(e[r]);)r++;let n="";if(r>0){n+="<thead>";for(let s=0;s<r;s++)n+=q(e[s],t);n+="</thead>"}if(r<e.length){n+="<tbody>";for(let s=r;s<e.length;s++)n+=q(e[s],t);n+="</tbody>"}return n}function ee(e,t,r,n){let s="";for(const i of t){const{tag:l,children:o,attrs:c}=i,u=A(e,{...c,...r});if(E(l))s+=`<${l}${u}>`;else{const f=o?ee(e,o,r,n):n;s+=`<${l}${u}>${f}</${l}>`}}return s}function A(e,t){const r=_(e,t,{colspan:"colspan",rowspan:"rowspan"}),n=r.style,s={...r};return n&&(s.style=Me(n)),Be(s)}let te=!1;const re=[],Xe=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}te?s():re.push(s)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const n=document.createElement("script");n.async=!0,n.src=e,n.id="storyblok-javascript-bridge",n.onerror=s=>r(s),n.onload=s=>{re.forEach(i=>i()),te=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),Ze=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new G(t)}},et=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let ne="https://app.storyblok.com/f/storyblok-v2-latest.js";const se=(e,t,r={})=>{var n;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((n=window.location)==null?void 0:n.href).searchParams.get("_storyblok"),l=i!==null&&+i===e;if(!(!s||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],o=>{var c;o&&(o.action==="input"&&((c=o.story)==null?void 0:c.id)===e?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===e&&window.location.reload())})})}},tt=(e={})=>{var t,r;const{bridge:n,accessToken:s,use:i=[],apiOptions:l={},bridgeUrl:o}=e;l.accessToken=l.accessToken||s;const c={bridge:n,apiOptions:l};let u={};i.forEach(h=>{u={...u,...h(c)}}),o&&(ne=o);const f=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return n!==!1&&f&&Xe(ne),u},H=a.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var c;const r=e,n=a.useSlots(),s=a.ref();t({value:s});const i=typeof a.resolveDynamicComponent(r.blok.component)!="string",l=a.inject("VueSDKOptions"),o=a.ref((c=r.blok.component)==null?void 0:c.replace(/_/g,"-"));return!i&&l&&(l.enableFallbackComponent?(o.value=l.customFallbackComponent??"FallbackComponent",typeof a.resolveDynamicComponent(o.value)=="string"&&console.error(`Is the Fallback component "${o.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(u,f)=>(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.value),a.mergeProps({ref_key:"blokRef",ref:s},{...u.$props,...u.$attrs}),a.createSlots({_:2},[a.renderList(Object.keys(a.unref(n)),h=>({name:h,fn:a.withCtx(p=>[a.renderSlot(u.$slots,h,a.normalizeProps(a.guardReactiveProps(p)))])}))]),1040))}}),ie=a.defineComponent({name:"StoryblokBlokRenderer",props:{type:{type:String,required:!0},attrs:{type:Object,required:!1},content:{type:Array,required:!1},marks:{type:Array,required:!1},_key:{type:String,required:!1},context:{type:Object,required:!1}},setup(e){return()=>{var t;return Array.isArray((t=e.attrs)==null?void 0:t.body)?e.attrs.body.map((r,n)=>a.h(H,{blok:r,key:r._uid||n})):null}}});function U(e,t){return t==null?void 0:t[e]}function oe(e){return function(r){if(!r)return null;const n=W(r,!0);return n.length?v(n,e):null}}function v(e,t){return Ge(e).map((n,s)=>n.linkMark?rt(n.nodes,n.linkMark,t,n._key||s):V(n.nodes[0],t,n._key||s))}function rt(e,t,r,n){const s=e.map((o,c)=>{const u=o,f=De(o);return ce(u,f,r)}),i=U(t.type,r.components);if(i)return a.h(i,{key:n,...t},{default:()=>s});const l=R(t);return l?a.h(l,{key:n,..._(t.type,t.attrs)},s):s.length>0?s[0]:a.createTextVNode("")}function V(e,t,r){if(e.type==="text")return it(e,t);const n=U(e.type,t.components);if(n)return a.h(n,{key:r,...e,context:t},e.content?{default:()=>v(e.content,t)}:void 0);const s=R(e);if(!s){const c=e.content?v(e.content,t):[];return c.length===0?a.createTextVNode(""):c.length===1?c[0]:a.h("div",{key:r},c)}if(e.type==="image"&&t.optimizeImage)return nt(e,t,r);const i=_(e.type,e.attrs);if(E(s))return a.h(s,{key:r,...i});if(e.type==="table")return st(e,t,r,s,i);const l=Q(e);if(l){const c=e.content?v(e.content,t):[],u=le(e.type,l,e.attrs,c);return a.h(s,{key:r},u)}const o=e.content?v(e.content,t):[];return a.h(s,{key:r,...i},o)}function nt(e,t,r){const n=e.attrs,s=n==null?void 0:n.src;if(!s)return a.createTextVNode("");const{src:i,attrs:l}=j(s,t.optimizeImage),o=_("image",{...n,src:i,...l});return a.h("img",{key:r,...o})}function st(e,t,r,n,s){const{headerRows:i,bodyRows:l}=J(e.content),o=[];return i.length>0&&o.push(a.h("thead",{key:"thead"},i.map((c,u)=>V(c,t,u)))),l.length>0&&o.push(a.h("tbody",{key:"tbody"},l.map((c,u)=>V(c,t,u)))),a.h(n,{key:r,...s},o)}function le(e,t,r,n){return t.map((s,i)=>{const{tag:l,children:o,attrs:c}=s,u={...c,...r},f=_(e,u);if(E(l))return a.h(l,{key:i,...f});const h=o?le(e,o,r,n):n;return a.h(l,{key:i,...f},h)})}function it(e,t,r){return ce(e,e.marks,t)}function ce(e,t,r,n){let s=e.text;if(t!=null&&t.length)for(const i of t)s=ot(s,i,r);return typeof s=="string"?a.createTextVNode(s):s}function ot(e,t,r){const n=U(t.type,r.components);if(n){const i=typeof e=="string"?a.createTextVNode(e):e;return a.h(n,{...t},{default:()=>[i]})}const s=R(t);return s?a.h(s,_(t.type,t.attrs),typeof e=="string"?e:[e]):typeof e=="string"?a.createTextVNode(e):e}const ae=a.defineComponent({name:"StoryblokRichText",props:{document:{type:Object,required:!1},optimizeImage:{type:[Boolean,Object],required:!1},components:{type:Object,required:!1}},setup(e){const t=oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}});return()=>t(e.document)}});function lt(e){return oe({optimizeImage:e.optimizeImage,components:{blok:ie,...e.components}})}const ct={beforeMount(e,t){if(t.value){const r=et(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},ue=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
-
`)};let $=null;const
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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"&";case'"':return""";case"'":return"'";case"<":return"<";case">":return">";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"})}));
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -168,7 +168,7 @@ function je(e) {
|
|
|
168
168
|
function R(e, t, r = {}, n) {
|
|
169
169
|
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 || Ne(e, t) ? m.SINGLE_OR_SMALL : je(t.per_page || Ie);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function qe(e) {
|
|
172
172
|
if (!e) return null;
|
|
173
173
|
const t = e["x-ratelimit"] || e["X-RateLimit"], r = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
|
|
174
174
|
if (!t && !r) return null;
|
|
@@ -183,7 +183,7 @@ function xe(e) {
|
|
|
183
183
|
}
|
|
184
184
|
return Object.keys(n).length > 0 ? n : null;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function xe(e, t = !1) {
|
|
187
187
|
return {
|
|
188
188
|
userRateLimit: e,
|
|
189
189
|
serverHeadersRateLimit: void 0,
|
|
@@ -204,19 +204,19 @@ function Ue(e, t, r) {
|
|
|
204
204
|
i++;
|
|
205
205
|
const c = n.shift();
|
|
206
206
|
if (c) try {
|
|
207
|
-
const
|
|
208
|
-
c.resolve(
|
|
209
|
-
} catch (
|
|
210
|
-
c.reject(
|
|
207
|
+
const h = await e(...c.args);
|
|
208
|
+
c.resolve(h);
|
|
209
|
+
} catch (h) {
|
|
210
|
+
c.reject(h);
|
|
211
211
|
}
|
|
212
|
-
const
|
|
213
|
-
i--, n.length > 0 && o(), s = s.filter((
|
|
212
|
+
const u = setTimeout(() => {
|
|
213
|
+
i--, n.length > 0 && o(), s = s.filter((h) => h !== u);
|
|
214
214
|
}, r);
|
|
215
|
-
s.includes(
|
|
216
|
-
}, a = (...c) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((
|
|
215
|
+
s.includes(u) || s.push(u);
|
|
216
|
+
}, a = (...c) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((u, h) => {
|
|
217
217
|
n.push({
|
|
218
|
-
resolve:
|
|
219
|
-
reject:
|
|
218
|
+
resolve: u,
|
|
219
|
+
reject: h,
|
|
220
220
|
args: c
|
|
221
221
|
}), i < t && o();
|
|
222
222
|
});
|
|
@@ -298,7 +298,7 @@ var Fe = class {
|
|
|
298
298
|
const n = new Headers();
|
|
299
299
|
!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]) => {
|
|
300
300
|
n.set(i, l);
|
|
301
|
-
}), e.oauthToken && n.set("Authorization", e.oauthToken), this.rateLimitConfig =
|
|
301
|
+
}), e.oauthToken && n.set("Authorization", e.oauthToken), this.rateLimitConfig = xe(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = e.retriesDelay ?? 300, this.throttleManager = new ze(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 || Oe.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Pe({
|
|
302
302
|
baseURL: r,
|
|
303
303
|
timeout: e.timeout || 0,
|
|
304
304
|
headers: n,
|
|
@@ -519,18 +519,18 @@ var Fe = class {
|
|
|
519
519
|
}
|
|
520
520
|
const l = !O(e) && this.rateLimitConfig.isManagementApi ? _ : void 0, o = R(e, t, this.rateLimitConfig, l);
|
|
521
521
|
return new Promise(async (a, c) => {
|
|
522
|
-
var
|
|
522
|
+
var u;
|
|
523
523
|
try {
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
524
|
+
const h = await this.throttleManager.execute(o, "get", e, t, n);
|
|
525
|
+
if (h.status !== 200) return c(h);
|
|
526
526
|
let d = {
|
|
527
|
-
data:
|
|
528
|
-
headers:
|
|
527
|
+
data: h.data,
|
|
528
|
+
headers: h.headers
|
|
529
529
|
};
|
|
530
|
-
const p =
|
|
531
|
-
if ((p == null ? void 0 : p.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = p.max), (
|
|
532
|
-
perPage:
|
|
533
|
-
total:
|
|
530
|
+
const p = qe(h.headers);
|
|
531
|
+
if ((p == null ? void 0 : p.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = p.max), (u = h.headers) != null && u["per-page"] && (d = Object.assign({}, d, {
|
|
532
|
+
perPage: h.headers["per-page"] ? Number.parseInt(h.headers["per-page"]) : 0,
|
|
533
|
+
total: h.headers["per-page"] ? Number.parseInt(h.headers.total) : 0
|
|
534
534
|
})), d.data.story || d.data.stories) {
|
|
535
535
|
const T = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
536
536
|
await this.resolveStories(d.data, t, `${T}`), d = await this.processInlineAssets(d);
|
|
@@ -538,10 +538,10 @@ var Fe = class {
|
|
|
538
538
|
t.version === "published" && e !== "/cdn/spaces/me" && await i.set(s, d);
|
|
539
539
|
const $ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
540
540
|
return t.token && d.data.cv && ($ && g[t.token] && g[t.token] !== d.data.cv && await this.flushCache(), g[t.token] = d.data.cv), a(d);
|
|
541
|
-
} catch (
|
|
542
|
-
if (
|
|
541
|
+
} catch (h) {
|
|
542
|
+
if (h.response && h.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
543
543
|
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Te(this.retriesDelay), this.cacheResponse(e, t, r).then(a).catch(c);
|
|
544
|
-
c(
|
|
544
|
+
c(h);
|
|
545
545
|
}
|
|
546
546
|
});
|
|
547
547
|
}
|
|
@@ -622,13 +622,13 @@ function W(e, t) {
|
|
|
622
622
|
};
|
|
623
623
|
let r = 0, n = 0;
|
|
624
624
|
const s = {}, i = [];
|
|
625
|
-
function l(a, c,
|
|
626
|
-
typeof a != "number" || a <= c || a >=
|
|
625
|
+
function l(a, c, u, h, d) {
|
|
626
|
+
typeof a != "number" || a <= c || a >= u ? console.warn(`[StoryblokRichText] - ${h.charAt(0).toUpperCase() + h.slice(1)} value must be a number between ${c} and ${u} (inclusive)`) : d.push(`${h}(${a})`);
|
|
627
627
|
}
|
|
628
628
|
if (typeof t == "object") {
|
|
629
629
|
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) {
|
|
630
|
-
const { filters: a } = t || {}, { blur: c, brightness:
|
|
631
|
-
c && l(c, 0, 100, "blur", i), $ && l($, 0, 100, "quality", i),
|
|
630
|
+
const { filters: a } = t || {}, { blur: c, brightness: u, fill: h, format: d, grayscale: p, quality: $, rotate: T } = a || {};
|
|
631
|
+
c && l(c, 0, 100, "blur", i), $ && l($, 0, 100, "quality", i), u && l(u, 0, 100, "brightness", i), h && i.push(`fill(${h})`), p && i.push("grayscale()"), T && [
|
|
632
632
|
0,
|
|
633
633
|
90,
|
|
634
634
|
180,
|
|
@@ -642,8 +642,8 @@ function W(e, t) {
|
|
|
642
642
|
t.srcset && (s.srcset = t.srcset.map((a) => {
|
|
643
643
|
if (typeof a == "number") return `${e}/m/${a}x0/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${a}w`;
|
|
644
644
|
if (Array.isArray(a) && a.length === 2) {
|
|
645
|
-
const [c,
|
|
646
|
-
return `${e}/m/${c}x${
|
|
645
|
+
const [c, u] = a;
|
|
646
|
+
return `${e}/m/${c}x${u}/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${c}w`;
|
|
647
647
|
} else {
|
|
648
648
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
649
649
|
return;
|
|
@@ -815,7 +815,7 @@ const Be = (e) => `h${typeof (e == null ? void 0 : e.level) == "number" ? Math.m
|
|
|
815
815
|
}
|
|
816
816
|
};
|
|
817
817
|
function Je(e) {
|
|
818
|
-
return Object.entries(e).filter(([, t]) =>
|
|
818
|
+
return Object.entries(e).filter(([, t]) => q(t)).map(([t, r]) => `${Qe(t)}: ${r};`).join(" ");
|
|
819
819
|
}
|
|
820
820
|
function We(e) {
|
|
821
821
|
return e.split(";").map((t) => t.trim()).filter(Boolean).reduce((t, r) => {
|
|
@@ -831,7 +831,7 @@ function Ye(e) {
|
|
|
831
831
|
function Qe(e) {
|
|
832
832
|
return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function q(e) {
|
|
835
835
|
return e != null && e !== "";
|
|
836
836
|
}
|
|
837
837
|
const Xe = {
|
|
@@ -892,10 +892,10 @@ function st(e) {
|
|
|
892
892
|
return Array.isArray(e) ? e[0] != null ? `${e[0]}px` : void 0 : typeof e == "number" || typeof e == "string" ? e : String(e);
|
|
893
893
|
}
|
|
894
894
|
function it(e, t, r, n, s, i, l) {
|
|
895
|
-
if (!
|
|
895
|
+
if (!q(t) || et.has(e) || tt.has(e) && t === 1) return;
|
|
896
896
|
if (e in n) {
|
|
897
897
|
const a = n[e], c = st(t);
|
|
898
|
-
c !== void 0 &&
|
|
898
|
+
c !== void 0 && q(c) && (i[a] = c);
|
|
899
899
|
return;
|
|
900
900
|
}
|
|
901
901
|
const o = s[e] ?? e;
|
|
@@ -917,10 +917,10 @@ function k(e, t = {}, r = {}) {
|
|
|
917
917
|
...n,
|
|
918
918
|
...t
|
|
919
919
|
};
|
|
920
|
-
for (const [
|
|
920
|
+
for (const [u, h] of Object.entries(c)) it(u, h, e, o, a, i, l);
|
|
921
921
|
if (e === "link") {
|
|
922
|
-
const
|
|
923
|
-
|
|
922
|
+
const u = rt(t);
|
|
923
|
+
u !== void 0 && (l.href = u);
|
|
924
924
|
}
|
|
925
925
|
return {
|
|
926
926
|
...l,
|
|
@@ -1040,15 +1040,24 @@ function Lt(e, t) {
|
|
|
1040
1040
|
const r = X(e);
|
|
1041
1041
|
return r != null && r.length ? te(r, t) : "";
|
|
1042
1042
|
}
|
|
1043
|
-
function
|
|
1044
|
-
var o;
|
|
1043
|
+
function x(e, t) {
|
|
1044
|
+
var o, a;
|
|
1045
|
+
const r = e.type !== "text" && e.content ? te(e.content, t) : "", n = (o = t == null ? void 0 : t.renderers) == null ? void 0 : o[e.type];
|
|
1046
|
+
if (n) {
|
|
1047
|
+
const c = (a = t == null ? void 0 : t.renderers) != null && a[e.type] ? {
|
|
1048
|
+
...t,
|
|
1049
|
+
renderers: {
|
|
1050
|
+
...t.renderers,
|
|
1051
|
+
[e.type]: void 0
|
|
1052
|
+
}
|
|
1053
|
+
} : t;
|
|
1054
|
+
return n({
|
|
1055
|
+
...e,
|
|
1056
|
+
children: r,
|
|
1057
|
+
context: c
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1045
1060
|
if (e.type === "text") return re(e, e.marks, t);
|
|
1046
|
-
const r = e.content ? te(e.content, t) : "", n = (o = t == null ? void 0 : t.renderers) == null ? void 0 : o[e.type];
|
|
1047
|
-
if (n) return n({
|
|
1048
|
-
...e,
|
|
1049
|
-
children: r,
|
|
1050
|
-
context: t
|
|
1051
|
-
});
|
|
1052
1061
|
if (e.type === "blok")
|
|
1053
1062
|
return console.warn('"blok" nodes require a custom renderer in renderRichText.'), "";
|
|
1054
1063
|
const s = v(e);
|
|
@@ -1084,7 +1093,7 @@ function te(e, t) {
|
|
|
1084
1093
|
for (; o < s && Y(l, C(e[o])); ) o++;
|
|
1085
1094
|
r += dt(e, n, o, l, t), n = o;
|
|
1086
1095
|
} else
|
|
1087
|
-
r +=
|
|
1096
|
+
r += x(i, t), n++;
|
|
1088
1097
|
}
|
|
1089
1098
|
return r;
|
|
1090
1099
|
}
|
|
@@ -1099,7 +1108,8 @@ function ft(e, t, r) {
|
|
|
1099
1108
|
const n = (i = r == null ? void 0 : r.renderers) == null ? void 0 : i[t.type];
|
|
1100
1109
|
if (n) return n({
|
|
1101
1110
|
...t,
|
|
1102
|
-
children: e
|
|
1111
|
+
children: e,
|
|
1112
|
+
context: r
|
|
1103
1113
|
});
|
|
1104
1114
|
const s = v(t);
|
|
1105
1115
|
return s ? `<${s}${S(t.type, t.attrs)}>${e}</${s}>` : e;
|
|
@@ -1107,14 +1117,15 @@ function ft(e, t, r) {
|
|
|
1107
1117
|
function dt(e, t, r, n, s) {
|
|
1108
1118
|
var a, c;
|
|
1109
1119
|
let i = "";
|
|
1110
|
-
for (let
|
|
1111
|
-
const
|
|
1112
|
-
i += re(
|
|
1120
|
+
for (let u = t; u < r; u++) {
|
|
1121
|
+
const h = e[u], d = (a = h.marks) == null ? void 0 : a.filter((p) => p.type !== "link");
|
|
1122
|
+
i += re(h, d, s);
|
|
1113
1123
|
}
|
|
1114
1124
|
const l = (c = s == null ? void 0 : s.renderers) == null ? void 0 : c[n.type];
|
|
1115
1125
|
if (l) return l({
|
|
1116
1126
|
...n,
|
|
1117
|
-
children: i
|
|
1127
|
+
children: i,
|
|
1128
|
+
context: s
|
|
1118
1129
|
});
|
|
1119
1130
|
const o = v(n);
|
|
1120
1131
|
return o ? `<${o}${S(n.type, n.attrs)}>${i}</${o}>` : i;
|
|
@@ -1126,12 +1137,12 @@ function yt(e, t) {
|
|
|
1126
1137
|
let n = "";
|
|
1127
1138
|
if (r > 0) {
|
|
1128
1139
|
n += "<thead>";
|
|
1129
|
-
for (let s = 0; s < r; s++) n +=
|
|
1140
|
+
for (let s = 0; s < r; s++) n += x(e[s], t);
|
|
1130
1141
|
n += "</thead>";
|
|
1131
1142
|
}
|
|
1132
1143
|
if (r < e.length) {
|
|
1133
1144
|
n += "<tbody>";
|
|
1134
|
-
for (let s = r; s < e.length; s++) n +=
|
|
1145
|
+
for (let s = r; s < e.length; s++) n += x(e[s], t);
|
|
1135
1146
|
n += "</tbody>";
|
|
1136
1147
|
}
|
|
1137
1148
|
return n;
|
|
@@ -1145,8 +1156,8 @@ function ne(e, t, r, n) {
|
|
|
1145
1156
|
});
|
|
1146
1157
|
if (M(l)) s += `<${l}${c}>`;
|
|
1147
1158
|
else {
|
|
1148
|
-
const
|
|
1149
|
-
s += `<${l}${c}>${
|
|
1159
|
+
const u = o ? ne(e, o, r, n) : n;
|
|
1160
|
+
s += `<${l}${c}>${u}</${l}>`;
|
|
1150
1161
|
}
|
|
1151
1162
|
}
|
|
1152
1163
|
return s;
|
|
@@ -1188,7 +1199,7 @@ const K = [], pt = (e) => new Promise((t, r) => {
|
|
|
1188
1199
|
}
|
|
1189
1200
|
return { storyblokApi: new Fe(t) };
|
|
1190
1201
|
}, gt = (e) => {
|
|
1191
|
-
if (typeof e != "object" || typeof e._editable
|
|
1202
|
+
if (typeof e != "object" || typeof e._editable != "string")
|
|
1192
1203
|
return {};
|
|
1193
1204
|
try {
|
|
1194
1205
|
const t = JSON.parse(
|
|
@@ -1232,11 +1243,11 @@ const mt = (e, t, r = {}) => {
|
|
|
1232
1243
|
l.accessToken = l.accessToken || s;
|
|
1233
1244
|
const a = { bridge: n, apiOptions: l };
|
|
1234
1245
|
let c = {};
|
|
1235
|
-
i.forEach((
|
|
1236
|
-
c = { ...c, ...
|
|
1246
|
+
i.forEach((h) => {
|
|
1247
|
+
c = { ...c, ...h(a) };
|
|
1237
1248
|
}), o && (J = o);
|
|
1238
|
-
const
|
|
1239
|
-
return n !== !1 &&
|
|
1249
|
+
const u = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
|
|
1250
|
+
return n !== !1 && u && pt(J), c;
|
|
1240
1251
|
}, se = /* @__PURE__ */ U({
|
|
1241
1252
|
__name: "StoryblokComponent",
|
|
1242
1253
|
props: {
|
|
@@ -1253,14 +1264,14 @@ const mt = (e, t, r = {}) => {
|
|
|
1253
1264
|
`Is the Fallback component "${o.value}" registered properly?`
|
|
1254
1265
|
)) : console.error(
|
|
1255
1266
|
`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});"?`
|
|
1256
|
-
)), (c,
|
|
1267
|
+
)), (c, u) => (ye(), pe(P(o.value), ge({
|
|
1257
1268
|
ref_key: "blokRef",
|
|
1258
1269
|
ref: s
|
|
1259
1270
|
}, { ...c.$props, ...c.$attrs }), me({ _: 2 }, [
|
|
1260
|
-
be(Object.keys(ke(n)), (
|
|
1261
|
-
name:
|
|
1271
|
+
be(Object.keys(ke(n)), (h) => ({
|
|
1272
|
+
name: h,
|
|
1262
1273
|
fn: ve((d) => [
|
|
1263
|
-
_e(c.$slots,
|
|
1274
|
+
_e(c.$slots, h, Re(we(d)))
|
|
1264
1275
|
])
|
|
1265
1276
|
}))
|
|
1266
1277
|
]), 1040));
|
|
@@ -1321,43 +1332,46 @@ function w(e, t) {
|
|
|
1321
1332
|
}
|
|
1322
1333
|
function kt(e, t, r, n) {
|
|
1323
1334
|
const s = e.map((o, a) => {
|
|
1324
|
-
const c = o,
|
|
1325
|
-
return ae(c,
|
|
1335
|
+
const c = o, u = lt(o);
|
|
1336
|
+
return ae(c, u, r);
|
|
1326
1337
|
}), i = F(t.type, r.components);
|
|
1327
1338
|
if (i)
|
|
1328
|
-
return y(i, { key: n, ...t }, {
|
|
1339
|
+
return y(i, { key: n, ...t, context: r }, {
|
|
1329
1340
|
default: () => s
|
|
1330
1341
|
});
|
|
1331
1342
|
const l = v(t);
|
|
1332
1343
|
return l ? y(l, { key: n, ...k(t.type, t.attrs) }, s) : s.length > 0 ? s[0] : b("");
|
|
1333
1344
|
}
|
|
1334
1345
|
function H(e, t, r) {
|
|
1346
|
+
var c;
|
|
1347
|
+
const n = e.type !== "text" && e.content ? w(e.content, t) : [], s = F(e.type, t.components);
|
|
1348
|
+
if (s) {
|
|
1349
|
+
const u = (c = t.components) != null && c[e.type] ? { ...t, components: { ...t.components, [e.type]: void 0 } } : t;
|
|
1350
|
+
return y(s, { key: r, ...e, context: u }, n.length ? {
|
|
1351
|
+
default: () => n
|
|
1352
|
+
} : void 0);
|
|
1353
|
+
}
|
|
1335
1354
|
if (e.type === "text")
|
|
1336
1355
|
return Rt(e, t);
|
|
1337
|
-
const
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
} : void 0);
|
|
1342
|
-
const s = v(e);
|
|
1343
|
-
if (!s) {
|
|
1344
|
-
const a = e.content ? w(e.content, t) : [];
|
|
1345
|
-
return a.length === 0 ? b("") : a.length === 1 ? a[0] : y("div", { key: r }, a);
|
|
1356
|
+
const i = v(e);
|
|
1357
|
+
if (!i) {
|
|
1358
|
+
const u = e.content ? w(e.content, t) : [];
|
|
1359
|
+
return u.length === 0 ? b("") : u.length === 1 ? u[0] : y("div", { key: r }, u);
|
|
1346
1360
|
}
|
|
1347
1361
|
if (e.type === "image" && t.optimizeImage)
|
|
1348
1362
|
return vt(e, t, r);
|
|
1349
|
-
const
|
|
1350
|
-
if (M(
|
|
1351
|
-
return y(
|
|
1363
|
+
const l = k(e.type, e.attrs);
|
|
1364
|
+
if (M(i))
|
|
1365
|
+
return y(i, { key: r, ...l });
|
|
1352
1366
|
if (e.type === "table")
|
|
1353
|
-
return _t(e, t, r,
|
|
1354
|
-
const
|
|
1355
|
-
if (
|
|
1356
|
-
const
|
|
1357
|
-
return y(
|
|
1358
|
-
}
|
|
1359
|
-
const
|
|
1360
|
-
return y(
|
|
1367
|
+
return _t(e, t, r, i, l);
|
|
1368
|
+
const o = ee(e);
|
|
1369
|
+
if (o) {
|
|
1370
|
+
const u = e.content ? w(e.content, t) : [], h = le(e.type, o, e.attrs, u);
|
|
1371
|
+
return y(i, { key: r }, h);
|
|
1372
|
+
}
|
|
1373
|
+
const a = e.content ? w(e.content, t) : [];
|
|
1374
|
+
return y(i, { key: r, ...l }, a);
|
|
1361
1375
|
}
|
|
1362
1376
|
function vt(e, t, r) {
|
|
1363
1377
|
const n = e.attrs, s = n == null ? void 0 : n.src;
|
|
@@ -1380,11 +1394,11 @@ function _t(e, t, r, n, s) {
|
|
|
1380
1394
|
}
|
|
1381
1395
|
function le(e, t, r, n) {
|
|
1382
1396
|
return t.map((s, i) => {
|
|
1383
|
-
const { tag: l, children: o, attrs: a } = s, c = { ...a, ...r },
|
|
1397
|
+
const { tag: l, children: o, attrs: a } = s, c = { ...a, ...r }, u = k(e, c);
|
|
1384
1398
|
if (M(l))
|
|
1385
|
-
return y(l, { key: i, ...
|
|
1386
|
-
const
|
|
1387
|
-
return y(l, { key: i, ...
|
|
1399
|
+
return y(l, { key: i, ...u });
|
|
1400
|
+
const h = o ? le(e, o, r, n) : n;
|
|
1401
|
+
return y(l, { key: i, ...u }, h);
|
|
1388
1402
|
});
|
|
1389
1403
|
}
|
|
1390
1404
|
function Rt(e, t, r) {
|
|
@@ -1401,7 +1415,7 @@ function wt(e, t, r) {
|
|
|
1401
1415
|
const n = F(t.type, r.components);
|
|
1402
1416
|
if (n) {
|
|
1403
1417
|
const i = typeof e == "string" ? b(e) : e;
|
|
1404
|
-
return y(n, { ...t }, {
|
|
1418
|
+
return y(n, { ...t, context: r }, {
|
|
1405
1419
|
default: () => [i]
|
|
1406
1420
|
});
|
|
1407
1421
|
}
|
|
@@ -1422,6 +1436,10 @@ const At = U({
|
|
|
1422
1436
|
components: {
|
|
1423
1437
|
type: Object,
|
|
1424
1438
|
required: !1
|
|
1439
|
+
},
|
|
1440
|
+
data: {
|
|
1441
|
+
type: null,
|
|
1442
|
+
required: !1
|
|
1425
1443
|
}
|
|
1426
1444
|
},
|
|
1427
1445
|
setup(e) {
|
|
@@ -1430,7 +1448,8 @@ const At = U({
|
|
|
1430
1448
|
components: {
|
|
1431
1449
|
blok: ie,
|
|
1432
1450
|
...e.components
|
|
1433
|
-
}
|
|
1451
|
+
},
|
|
1452
|
+
data: e.data
|
|
1434
1453
|
});
|
|
1435
1454
|
return () => t(e.document);
|
|
1436
1455
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.2.0",
|
|
5
5
|
"description": "SDK to integrate Storyblok into your project using Vue.",
|
|
6
6
|
"author": "Storyblok",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"vue": ">=3.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@storyblok/js": "6.
|
|
35
|
-
"@storyblok/richtext": "5.
|
|
34
|
+
"@storyblok/js": "6.2.0",
|
|
35
|
+
"@storyblok/richtext": "5.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rollup/plugin-typescript": "^12.1.2",
|