@storyblok/vue 7.1.10 → 7.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(p,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(p=typeof globalThis<"u"?globalThis:p||self,d(p.storyblokVue={},p.Vue))})(this,function(p,d){"use strict";let R=!1;const j=[],A=o=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}R?r():j.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>e(r),s.onload=r=>{j.forEach(i=>i()),R=!0,t(r)},document.getElementsByTagName("head")[0].appendChild(s)});var M=Object.defineProperty,N=(o,t,e)=>t in o?M(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,h=(o,t,e)=>(N(o,typeof t!="symbol"?t+"":t,e),e);function S(o){return!(o!==o||o===1/0||o===-1/0)}function z(o,t,e){if(!S(t))throw new TypeError("Expected `limit` to be a finite number");if(!S(e))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const a=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==a})},e);r.indexOf(a)<0&&r.push(a);const c=s.shift();c.resolve(o.apply(c.self,c.args))},l=function(...a){const c=this;return new Promise(function(u,g){s.push({resolve:u,reject:g,args:a,self:c}),i<t&&n()})};return l.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},l}const L=function(o,t){const e={};for(const s in o){const r=o[s];t.indexOf(s)>-1&&r!==null&&(e[s]=r)}return e},U=o=>o==="email",q=()=>({singleTag:"hr"}),H=()=>({tag:"blockquote"}),V=()=>({tag:"ul"}),D=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),B=()=>({singleTag:"br"}),J=o=>({tag:`h${o.attrs.level}`}),F=o=>({singleTag:[{tag:"img",attrs:L(o.attrs,["src","alt","title"])}]}),Y=()=>({tag:"li"}),K=()=>({tag:"ol"}),W=()=>({tag:"p"}),G=o=>({tag:[{tag:"span",attrs:{["data-type"]:"emoji",["data-name"]:o.attrs.name,emoji:o.attrs.emoji}}]}),Q=()=>({tag:"b"}),X=()=>({tag:"strike"}),Z=()=>({tag:"u"}),tt=()=>({tag:"strong"}),et=()=>({tag:"code"}),st=()=>({tag:"i"}),rt=o=>{const t={...o.attrs},{linktype:e="url"}=o.attrs;if(U(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ot=o=>({tag:[{tag:"span",attrs:o.attrs}]}),it=()=>({tag:"sub"}),nt=()=>({tag:"sup"}),at=o=>({tag:[{tag:"span",attrs:o.attrs}]}),lt=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},ct=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},P={nodes:{horizontal_rule:q,blockquote:H,bullet_list:V,code_block:D,hard_break:B,heading:J,image:F,list_item:Y,ordered_list:K,paragraph:W,emoji:G},marks:{bold:Q,strike:X,underline:Z,strong:tt,code:et,italic:st,link:rt,styled:ot,subscript:it,superscript:nt,anchor:at,highlight:lt,textStyle:ct}},ht=function(o){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,s=RegExp(e.source);return o&&s.test(o)?o.replace(e,r=>t[r]):o};class b{constructor(t){h(this,"marks"),h(this,"nodes"),t||(t=P),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(r=>{s+=this.renderNode(r)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
1
+ (function(d,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(d=typeof globalThis<"u"?globalThis:d||self,p(d.storyblokVue={},d.Vue))})(this,function(d,p){"use strict";let j=!1;const S=[],M=o=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}j?r():S.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>e(r),s.onload=r=>{S.forEach(i=>i()),j=!0,t(r)},document.getElementsByTagName("head")[0].appendChild(s)});var z=Object.defineProperty,L=(o,t,e)=>t in o?z(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,h=(o,t,e)=>(L(o,typeof t!="symbol"?t+"":t,e),e);function P(o){return!(o!==o||o===1/0||o===-1/0)}function U(o,t,e){if(!P(t))throw new TypeError("Expected `limit` to be a finite number");if(!P(e))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const a=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==a})},e);r.indexOf(a)<0&&r.push(a);const l=s.shift();l.resolve(o.apply(l.self,l.args))},c=function(...a){const l=this;return new Promise(function(u,g){s.push({resolve:u,reject:g,args:a,self:l}),i<t&&n()})};return c.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},c}const q=function(o,t){const e={};for(const s in o){const r=o[s];t.indexOf(s)>-1&&r!==null&&(e[s]=r)}return e},V=o=>o==="email",H=()=>({singleTag:"hr"}),B=()=>({tag:"blockquote"}),D=()=>({tag:"ul"}),J=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),F=()=>({singleTag:"br"}),Y=o=>({tag:`h${o.attrs.level}`}),K=o=>({singleTag:[{tag:"img",attrs:q(o.attrs,["src","alt","title"])}]}),W=()=>({tag:"li"}),G=()=>({tag:"ol"}),Q=()=>({tag:"p"}),X=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Z=()=>({tag:"b"}),tt=()=>({tag:"strike"}),et=()=>({tag:"u"}),st=()=>({tag:"strong"}),rt=()=>({tag:"code"}),ot=()=>({tag:"i"}),it=o=>{const t={...o.attrs},{linktype:e="url"}=o.attrs;if(V(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},nt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),at=()=>({tag:"sub"}),lt=()=>({tag:"sup"}),ct=o=>({tag:[{tag:"span",attrs:o.attrs}]}),ht=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},ut=o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},E={nodes:{horizontal_rule:H,blockquote:B,bullet_list:D,code_block:J,hard_break:F,heading:Y,image:K,list_item:W,ordered_list:G,paragraph:Q,emoji:X},marks:{bold:Z,strike:tt,underline:et,strong:st,code:rt,italic:ot,link:it,styled:nt,subscript:at,superscript:lt,anchor:ct,highlight:ht,textStyle:ut}},dt=function(o){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,s=RegExp(e.source);return o&&s.test(o)?o.replace(e,r=>t[r]):o};class b{constructor(t){h(this,"marks"),h(this,"nodes"),t||(t=E),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(r=>{s+=this.renderNode(r)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
2
2
  The "content" field must be an array of nodes as the type ISbRichtext.
3
3
  ISbRichtext:
4
4
  content?: ISbRichtext[]
@@ -21,5 +21,5 @@
21
21
  }
22
22
  ],
23
23
  type: 'doc'
24
- }`),""}optimizeImages(t,e){let s=0,r=0,i="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),typeof e.height=="number"&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),(e.loading==="lazy"||e.loading==="eager")&&(i+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const l=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,u;const g=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(g&&g.length>0){const m={srcset:(c=e.srcset)==null?void 0:c.map(f=>{if(typeof f=="number")return`//${g}/m/${f}x0${n} ${f}w`;if(typeof f=="object"&&f.length===2){let _=0,O=0;return typeof f[0]=="number"&&(_=f[0]),typeof f[1]=="number"&&(O=f[1]),`//${g}/m/${_}x${O}${n} ${_}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let T="";return m.srcset&&(T+=`srcset="${m.srcset}" `),m.sizes&&(T+=`sizes="${m.sizes}" `),a.replace(/<img/g,`<img ${T.trim()}`)}return a})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach(r=>{e.push(this.renderNode(r))}):t.text?e.push(ht(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderClosingTag(i.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class w{constructor(){h(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(t,e=25,s=1)=>({...t,per_page:e,page:s})),h(this,"delay",t=>new Promise(e=>setTimeout(e,t))),h(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),h(this,"range",(t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,(i,n)=>n*r+t)}),h(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),h(this,"flatMap",(t=[],e)=>t.map(e).reduce((s,r)=>[...s,...r],[]))}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=t[i],l=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=this.stringify(n,e?e+encodeURIComponent("["+l+"]"):l,Array.isArray(n)):a=(e?e+encodeURIComponent("["+l+"]"):l)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")}getRegionURL(t){const e="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn";switch(t){case"us":return s;case"cn":return r;default:return e}}}class ut{constructor(t){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),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={}}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")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(r=>{s.data=r});for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if(t==="get"){const a=new w;e=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:n}=i;let l;this.timeout&&(l=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise((s,r)=>{if(e.test(`${t.status}`))return s(t);const i={message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug};r(i)})}}let v={};const y={};class pt{constructor(t,e){h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations");let s=t.endpoint||e;if(!s){const n=new w().getRegionURL,l=t.https===!1?"http":"https";t.oauthToken?s=`${l}://${n(t.region)}/v1`:s=`${l}://${n(t.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),r.forEach((n,l)=>{t.headers&&t.headers[l]&&r.set(l,t.headers[l])});let i=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),i=3),t.rateLimit&&(i=t.rateLimit),t.richTextSchema?this.richTextResolver=new b(t.richTextSchema):this.richTextResolver=new b,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=z(this.throttledRequest,i,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new w,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new ut({baseURL:s,timeout:t.timeout||0,headers:r,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let s="";return e.attrs.body&&e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=y[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(e==null?void 0:e.per_page)||25,i=`/${t}`,n=i.split("/"),l=s||n[n.length-1],a=1,c=await this.makeRequest(i,e,r,a),u=c.total?Math.ceil(c.total/r):1,g=await this.helpers.asyncMap(this.helpers.range(a,u),m=>this.makeRequest(i,e,r,m+1));return this.helpers.flatMap([c,...g],m=>Object.values(m.data[l]))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1){if(typeof t[e]=="string")this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const i=[];t[e].forEach(n=>{this.relations[r][n]&&i.push(this._cleanCopy(this.relations[r][n]))}),t[e]=i}}}iterateTree(t,e,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,e,s),this._insertLinks(i,n,s)),r(i[n])}}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const i=t.link_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const c=Math.min(i,a+l);n.push(t.link_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const i=t.rel_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const c=Math.min(i,a+l);n.push(t.rel_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=t.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,s){var r,i;let n=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(n=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],n,s);t.story?this.iterateTree(t.story,n,s):t.stories.forEach(l=>{this.iterateTree(l,n,s)}),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise((n,l)=>{try{(async()=>{var a;try{const c=await this.throttle("get",t,e);let u={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(u=Object.assign({},u,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0})),c.status!=200)return l(c);if(u.data.story||u.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,e,`${g}`)}return e.version==="published"&&t!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&e.token&&(e.version=="draft"&&y[e.token]!=u.data.cv&&await this.flushCache(),y[e.token]=u.data.cv),n(u)}catch(c){return l(c)}})()}catch{}})}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return y}cacheVersion(){return y[this.accessToken]}setCacheVersion(t){this.accessToken&&(y[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(v[t])},getAll(){return Promise.resolve(v)},set(t,e){return v[t]=e,Promise.resolve(void 0)},flush(){return v={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},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}}const dt=(o={})=>{const{apiOptions:t}=o;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new pt(t)}},gt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const t=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let $;const ft="https://app.storyblok.com/f/storyblok-v2-latest.js",E=(o,t,e={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===o?t(n.story):(n.action==="change"||n.action==="published")&&n.storyId===o&&window.location.reload()})})}},mt=(o={})=>{var t,e;const{bridge:s,accessToken:r,use:i=[],apiOptions:n={},richText:l={}}=o;n.accessToken=n.accessToken||r;const a={bridge:s,apiOptions:n};let c={};i.forEach(g=>{c={...c,...g(a)}});const u=!(typeof window>"u")&&((e=(t=window.location)==null?void 0:t.search)==null?void 0:e.includes("_storyblok_tk"));return s!==!1&&u&&A(ft),$=new b(l.schema),l.resolver&&I($,l.resolver),c},I=(o,t)=>{o.addNode("blok",e=>{let s="";return e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})},yt=o=>{var t,e;return!o||((t=o==null?void 0:o.content)==null?void 0:t[0].type)!=="blok"&&!((e=o==null?void 0:o.content)!=null&&e[0].content)},bt=(o,t,e)=>{let s=e||$;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return yt(o)?"":(t&&(s=new b(t.schema),t.resolver&&I(s,t.resolver)),s.render(o))},x=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o){return(t,e)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(t.blok.component),d.normalizeProps(d.guardReactiveProps({...t.$props,...t.$attrs})),null,16))}}),kt={beforeMount(o,t){if(t.value){const e=gt(t.value);o.setAttribute("data-blok-c",e["data-blok-c"]),o.setAttribute("data-blok-uid",e["data-blok-uid"]),o.classList.add("storyblok__outline")}}},C=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
25
- `)};let k=null;const vt=()=>(k||C("useStoryblokApi"),k),wt=async(o,t={},e={})=>{const s=d.ref(null);if(d.onMounted(()=>{s.value&&s.value.id&&E(s.value.id,r=>s.value=r,e)}),k){const{data:r}=await k.get(`cdn/stories/${o}`,t);s.value=r.story}else C("useStoryblok");return s},$t={install(o,t={}){o.directive("editable",kt),o.component("StoryblokComponent",x);const{storyblokApi:e}=mt(t);k=e}};p.RichTextResolver=b,p.RichTextSchema=P,p.StoryblokComponent=x,p.StoryblokVue=$t,p.apiPlugin=dt,p.renderRichText=bt,p.useStoryblok=wt,p.useStoryblokApi=vt,p.useStoryblokBridge=E,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
24
+ }`),""}optimizeImages(t,e){let s=0,r=0,i="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),typeof e.height=="number"&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),(e.loading==="lazy"||e.loading==="eager")&&(i+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const c=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var l,u;const g=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(g&&g.length>0){const m={srcset:(l=e.srcset)==null?void 0:l.map(f=>{if(typeof f=="number")return`//${g}/m/${f}x0${n} ${f}w`;if(typeof f=="object"&&f.length===2){let R=0,N=0;return typeof f[0]=="number"&&(R=f[0]),typeof f[1]=="number"&&(N=f[1]),`//${g}/m/${R}x${N}${n} ${R}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let _="";return m.srcset&&(_+=`srcset="${m.srcset}" `),m.sizes&&(_+=`sizes="${m.sizes}" `),a.replace(/<img/g,`<img ${_.trim()}`)}return a})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach(r=>{e.push(this.renderNode(r))}):t.text?e.push(dt(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&e.push(this.renderClosingTag(i.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}class w{constructor(){h(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(t,e=25,s=1)=>({...t,per_page:e,page:s})),h(this,"delay",t=>new Promise(e=>setTimeout(e,t))),h(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),h(this,"range",(t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,(i,n)=>n*r+t)}),h(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),h(this,"flatMap",(t=[],e)=>t.map(e).reduce((s,r)=>[...s,...r],[]))}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=t[i],c=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=this.stringify(n,e?e+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):a=(e?e+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),r.push(a)}return r.join("&")}getRegionURL(t){const e="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn";switch(t){case"us":return s;case"cn":return r;default:return e}}}class pt{constructor(t){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),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={}}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")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(r=>{s.data=r});for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if(t==="get"){const a=new w;e=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:n}=i;let c;this.timeout&&(c=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(c);const l=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise((s,r)=>{if(e.test(`${t.status}`))return s(t);const i={message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug};r(i)})}}const I="SB-Agent",$={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"2.2.3"};let v={};const y={};class gt{constructor(t,e){h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations");let s=t.endpoint||e;if(!s){const n=new w().getRegionURL,c=t.https===!1?"http":"https";t.oauthToken?s=`${c}://${n(t.region)}/v1`:s=`${c}://${n(t.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),t.headers)for(const n in t.headers)r.set(n,t.headers[n]);r.has(I)||(r.set(I,$.defaultAgentName),r.set($.defaultAgentVersion,$.packageVersion));let i=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),i=3),t.rateLimit&&(i=t.rateLimit),t.richTextSchema?this.richTextResolver=new b(t.richTextSchema):this.richTextResolver=new b,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=U(this.throttledRequest,i,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new w,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new pt({baseURL:s,timeout:t.timeout||0,headers:r,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let s="";return e.attrs.body&&e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=y[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(e==null?void 0:e.per_page)||25,i=`/${t}`,n=i.split("/"),c=s||n[n.length-1],a=1,l=await this.makeRequest(i,e,r,a),u=l.total?Math.ceil(l.total/r):1,g=await this.helpers.asyncMap(this.helpers.range(a,u),m=>this.makeRequest(i,e,r,m+1));return this.helpers.flatMap([l,...g],m=>Object.values(m.data[c]))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1){if(typeof t[e]=="string")this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const i=[];t[e].forEach(n=>{this.relations[r][n]&&i.push(this._cleanCopy(this.relations[r][n]))}),t[e]=i}}}iterateTree(t,e,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,e,s),this._insertLinks(i,n,s)),r(i[n])}}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const i=t.link_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(t.link_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const i=t.rel_uuids.length,n=[],c=50;for(let a=0;a<i;a+=c){const l=Math.min(i,a+c);n.push(t.rel_uuids.slice(a,l))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:c,language:e.language,version:e.version,by_uuids:n[a].join(",")})).data.stories.forEach(l=>{r.push(l)})}else r=t.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,s){var r,i;let n=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(n=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&((r=t.links)!=null&&r.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],n,s);t.story?this.iterateTree(t.story,n,s):t.stories.forEach(c=>{this.iterateTree(c,n,s)}),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise((n,c)=>{try{(async()=>{var a;try{const l=await this.throttle("get",t,e);let u={data:l.data,headers:l.headers};if((a=l.headers)!=null&&a["per-page"]&&(u=Object.assign({},u,{perPage:l.headers["per-page"]?parseInt(l.headers["per-page"]):0,total:l.headers["per-page"]?parseInt(l.headers.total):0})),l.status!=200)return c(l);if(u.data.story||u.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,e,`${g}`)}return e.version==="published"&&t!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&e.token&&(e.version=="draft"&&y[e.token]!=u.data.cv&&await this.flushCache(),y[e.token]=u.data.cv),n(u)}catch(l){return c(l)}})()}catch{}})}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return y}cacheVersion(){return y[this.accessToken]}setCacheVersion(t){this.accessToken&&(y[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(v[t])},getAll(){return Promise.resolve(v)},set(t,e){return v[t]=e,Promise.resolve(void 0)},flush(){return v={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},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}}const ft=(o={})=>{const{apiOptions:t}=o;if(!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new gt(t)}},mt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const t=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let T;const yt="https://app.storyblok.com/f/storyblok-v2-latest.js",A=(o,t,e={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===o?t(n.story):(n.action==="change"||n.action==="published")&&n.storyId===o&&window.location.reload()})})}},bt=(o={})=>{var t,e;const{bridge:s,accessToken:r,use:i=[],apiOptions:n={},richText:c={}}=o;n.accessToken=n.accessToken||r;const a={bridge:s,apiOptions:n};let l={};i.forEach(g=>{l={...l,...g(a)}});const u=!(typeof window>"u")&&((e=(t=window.location)==null?void 0:t.search)==null?void 0:e.includes("_storyblok_tk"));return s!==!1&&u&&M(yt),T=new b(c.schema),c.resolver&&C(T,c.resolver),l},C=(o,t)=>{o.addNode("blok",e=>{let s="";return e.attrs.body.forEach(r=>{s+=t(r.component,r)}),{html:s}})},kt=o=>{var t,e;return!o||((t=o==null?void 0:o.content)==null?void 0:t[0].type)!=="blok"&&!((e=o==null?void 0:o.content)!=null&&e[0].content)},vt=(o,t,e)=>{let s=e||T;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return kt(o)?"":(t&&(s=new b(t.schema),t.resolver&&C(s,t.resolver)),s.render(o))},x=p.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o){return(t,e)=>(p.openBlock(),p.createBlock(p.resolveDynamicComponent(t.blok.component),p.normalizeProps(p.guardReactiveProps({...t.$props,...t.$attrs})),null,16))}}),wt={beforeMount(o,t){if(t.value){const e=mt(t.value);o.setAttribute("data-blok-c",e["data-blok-c"]),o.setAttribute("data-blok-uid",e["data-blok-uid"]),o.classList.add("storyblok__outline")}}},O=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
25
+ `)};let k=null;const $t=()=>(k||O("useStoryblokApi"),k),Tt=async(o,t={},e={})=>{const s=p.ref(null);if(p.onMounted(()=>{s.value&&s.value.id&&A(s.value.id,r=>s.value=r,e)}),k){const{data:r}=await k.get(`cdn/stories/${o}`,t);s.value=r.story}else O("useStoryblok");return s},_t={install(o,t={}){o.directive("editable",wt),o.component("StoryblokComponent",x);const{storyblokApi:e}=bt(t);k=e}};d.RichTextResolver=b,d.RichTextSchema=E,d.StoryblokComponent=x,d.StoryblokVue=_t,d.apiPlugin=ft,d.renderRichText=vt,d.useStoryblok=Tt,d.useStoryblokApi=$t,d.useStoryblokBridge=A,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -1,27 +1,27 @@
1
- import { defineComponent as S, openBlock as E, createBlock as I, resolveDynamicComponent as C, normalizeProps as O, guardReactiveProps as A, ref as M, onMounted as N } from "vue";
2
- let T = !1;
3
- const R = [], z = (o) => new Promise((t, e) => {
1
+ import { defineComponent as I, openBlock as A, createBlock as C, resolveDynamicComponent as O, normalizeProps as N, guardReactiveProps as M, ref as z, onMounted as L } from "vue";
2
+ let R = !1;
3
+ const j = [], U = (o) => new Promise((t, e) => {
4
4
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
5
5
  if (window.location === window.parent.location) {
6
6
  console.warn("You are not in Draft Mode or in the Visual Editor.");
7
7
  return;
8
8
  }
9
- T ? r() : R.push(r);
9
+ R ? r() : j.push(r);
10
10
  }, document.getElementById("storyblok-javascript-bridge")))
11
11
  return;
12
12
  const s = document.createElement("script");
13
13
  s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => e(r), s.onload = (r) => {
14
- R.forEach((i) => i()), T = !0, t(r);
14
+ j.forEach((i) => i()), R = !0, t(r);
15
15
  }, document.getElementsByTagName("head")[0].appendChild(s);
16
16
  });
17
- var L = Object.defineProperty, U = (o, t, e) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, h = (o, t, e) => (U(o, typeof t != "symbol" ? t + "" : t, e), e);
18
- function j(o) {
17
+ var q = Object.defineProperty, H = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, h = (o, t, e) => (H(o, typeof t != "symbol" ? t + "" : t, e), e);
18
+ function S(o) {
19
19
  return !(o !== o || o === 1 / 0 || o === -1 / 0);
20
20
  }
21
- function q(o, t, e) {
22
- if (!j(t))
21
+ function V(o, t, e) {
22
+ if (!S(t))
23
23
  throw new TypeError("Expected `limit` to be a finite number");
24
- if (!j(e))
24
+ if (!S(e))
25
25
  throw new TypeError("Expected `interval` to be a finite number");
26
26
  const s = [];
27
27
  let r = [], i = 0;
@@ -33,41 +33,41 @@ function q(o, t, e) {
33
33
  });
34
34
  }, e);
35
35
  r.indexOf(a) < 0 && r.push(a);
36
- const c = s.shift();
37
- c.resolve(o.apply(c.self, c.args));
38
- }, l = function(...a) {
39
- const c = this;
40
- return new Promise(function(u, p) {
36
+ const l = s.shift();
37
+ l.resolve(o.apply(l.self, l.args));
38
+ }, c = function(...a) {
39
+ const l = this;
40
+ return new Promise(function(u, d) {
41
41
  s.push({
42
42
  resolve: u,
43
- reject: p,
43
+ reject: d,
44
44
  args: a,
45
- self: c
45
+ self: l
46
46
  }), i < t && n();
47
47
  });
48
48
  };
49
- return l.abort = function() {
49
+ return c.abort = function() {
50
50
  r.forEach(clearTimeout), r = [], s.forEach(function(a) {
51
51
  a.reject(function() {
52
52
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
53
53
  });
54
54
  }), s.length = 0;
55
- }, l;
55
+ }, c;
56
56
  }
57
- const H = function(o, t) {
57
+ const B = function(o, t) {
58
58
  const e = {};
59
59
  for (const s in o) {
60
60
  const r = o[s];
61
61
  t.indexOf(s) > -1 && r !== null && (e[s] = r);
62
62
  }
63
63
  return e;
64
- }, D = (o) => o === "email", B = () => ({
64
+ }, D = (o) => o === "email", J = () => ({
65
65
  singleTag: "hr"
66
- }), V = () => ({
66
+ }), F = () => ({
67
67
  tag: "blockquote"
68
- }), J = () => ({
68
+ }), Y = () => ({
69
69
  tag: "ul"
70
- }), F = (o) => ({
70
+ }), K = (o) => ({
71
71
  tag: [
72
72
  "pre",
73
73
  {
@@ -75,47 +75,47 @@ const H = function(o, t) {
75
75
  attrs: o.attrs
76
76
  }
77
77
  ]
78
- }), Y = () => ({
78
+ }), W = () => ({
79
79
  singleTag: "br"
80
- }), K = (o) => ({
80
+ }), G = (o) => ({
81
81
  tag: `h${o.attrs.level}`
82
- }), W = (o) => ({
82
+ }), Q = (o) => ({
83
83
  singleTag: [
84
84
  {
85
85
  tag: "img",
86
- attrs: H(o.attrs, ["src", "alt", "title"])
86
+ attrs: B(o.attrs, ["src", "alt", "title"])
87
87
  }
88
88
  ]
89
- }), G = () => ({
89
+ }), X = () => ({
90
90
  tag: "li"
91
- }), Q = () => ({
91
+ }), Z = () => ({
92
92
  tag: "ol"
93
- }), X = () => ({
93
+ }), tt = () => ({
94
94
  tag: "p"
95
- }), Z = (o) => ({
95
+ }), et = (o) => ({
96
96
  tag: [
97
97
  {
98
98
  tag: "span",
99
99
  attrs: {
100
- ["data-type"]: "emoji",
101
- ["data-name"]: o.attrs.name,
100
+ "data-type": "emoji",
101
+ "data-name": o.attrs.name,
102
102
  emoji: o.attrs.emoji
103
103
  }
104
104
  }
105
105
  ]
106
- }), tt = () => ({
106
+ }), st = () => ({
107
107
  tag: "b"
108
- }), et = () => ({
108
+ }), rt = () => ({
109
109
  tag: "strike"
110
- }), st = () => ({
110
+ }), ot = () => ({
111
111
  tag: "u"
112
- }), rt = () => ({
112
+ }), it = () => ({
113
113
  tag: "strong"
114
- }), ot = () => ({
114
+ }), nt = () => ({
115
115
  tag: "code"
116
- }), it = () => ({
116
+ }), at = () => ({
117
117
  tag: "i"
118
- }), nt = (o) => {
118
+ }), lt = (o) => {
119
119
  const t = { ...o.attrs }, { linktype: e = "url" } = o.attrs;
120
120
  if (D(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
121
121
  for (const s in t.custom)
@@ -130,25 +130,25 @@ const H = function(o, t) {
130
130
  }
131
131
  ]
132
132
  };
133
- }, at = (o) => ({
133
+ }, ct = (o) => ({
134
134
  tag: [
135
135
  {
136
136
  tag: "span",
137
137
  attrs: o.attrs
138
138
  }
139
139
  ]
140
- }), lt = () => ({
140
+ }), ht = () => ({
141
141
  tag: "sub"
142
- }), ct = () => ({
142
+ }), ut = () => ({
143
143
  tag: "sup"
144
- }), ht = (o) => ({
144
+ }), dt = (o) => ({
145
145
  tag: [
146
146
  {
147
147
  tag: "span",
148
148
  attrs: o.attrs
149
149
  }
150
150
  ]
151
- }), ut = (o) => {
151
+ }), pt = (o) => {
152
152
  var t;
153
153
  return (t = o.attrs) != null && t.color ? {
154
154
  tag: [
@@ -162,7 +162,7 @@ const H = function(o, t) {
162
162
  } : {
163
163
  tag: ""
164
164
  };
165
- }, pt = (o) => {
165
+ }, gt = (o) => {
166
166
  var t;
167
167
  return (t = o.attrs) != null && t.color ? {
168
168
  tag: [
@@ -176,36 +176,36 @@ const H = function(o, t) {
176
176
  } : {
177
177
  tag: ""
178
178
  };
179
- }, dt = {
179
+ }, ft = {
180
180
  nodes: {
181
- horizontal_rule: B,
182
- blockquote: V,
183
- bullet_list: J,
184
- code_block: F,
185
- hard_break: Y,
186
- heading: K,
187
- image: W,
188
- list_item: G,
189
- ordered_list: Q,
190
- paragraph: X,
191
- emoji: Z
181
+ horizontal_rule: J,
182
+ blockquote: F,
183
+ bullet_list: Y,
184
+ code_block: K,
185
+ hard_break: W,
186
+ heading: G,
187
+ image: Q,
188
+ list_item: X,
189
+ ordered_list: Z,
190
+ paragraph: tt,
191
+ emoji: et
192
192
  },
193
193
  marks: {
194
- bold: tt,
195
- strike: et,
196
- underline: st,
197
- strong: rt,
198
- code: ot,
199
- italic: it,
200
- link: nt,
201
- styled: at,
202
- subscript: lt,
203
- superscript: ct,
204
- anchor: ht,
205
- highlight: ut,
206
- textStyle: pt
207
- }
208
- }, gt = function(o) {
194
+ bold: st,
195
+ strike: rt,
196
+ underline: ot,
197
+ strong: it,
198
+ code: nt,
199
+ italic: at,
200
+ link: lt,
201
+ styled: ct,
202
+ subscript: ht,
203
+ superscript: ut,
204
+ anchor: dt,
205
+ highlight: pt,
206
+ textStyle: gt
207
+ }
208
+ }, mt = function(o) {
209
209
  const t = {
210
210
  "&": "&amp;",
211
211
  "<": "&lt;",
@@ -217,7 +217,7 @@ const H = function(o, t) {
217
217
  };
218
218
  class b {
219
219
  constructor(t) {
220
- h(this, "marks"), h(this, "nodes"), t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
220
+ h(this, "marks"), h(this, "nodes"), t || (t = ft), this.marks = t.marks || [], this.nodes = t.nodes || [];
221
221
  }
222
222
  addNode(t, e) {
223
223
  this.nodes[t] = e;
@@ -262,26 +262,26 @@ class b {
262
262
  optimizeImages(t, e) {
263
263
  let s = 0, r = 0, i = "", n = "";
264
264
  typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (i += `width="${e.width}" `, s = e.width), typeof e.height == "number" && e.height > 0 && (i += `height="${e.height}" `, r = e.height), (e.loading === "lazy" || e.loading === "eager") && (i += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (i += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (n += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (n += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-Fa-f]{6}/g) || e.filters.fill === "transparent") && (n += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (n += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (n += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (n += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (n += `:rotate(${e.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (t = t.replace(/<img/g, `<img ${i.trim()}`));
265
- const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
265
+ const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
266
266
  return t = t.replace(
267
267
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
268
- `a.storyblok.com/f/$1/$2.$3/m/${l}`
268
+ `a.storyblok.com/f/$1/$2.$3/m/${c}`
269
269
  ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
270
- var c, u;
271
- const p = a.match(
270
+ var l, u;
271
+ const d = a.match(
272
272
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
273
273
  );
274
- if (p && p.length > 0) {
274
+ if (d && d.length > 0) {
275
275
  const g = {
276
- srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
277
- if (typeof d == "number")
278
- return `//${p}/m/${d}x0${n} ${d}w`;
279
- if (typeof d == "object" && d.length === 2) {
280
- let k = 0, _ = 0;
281
- return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && (_ = d[1]), `//${p}/m/${k}x${_}${n} ${k}w`;
276
+ srcset: (l = e.srcset) == null ? void 0 : l.map((p) => {
277
+ if (typeof p == "number")
278
+ return `//${d}/m/${p}x0${n} ${p}w`;
279
+ if (typeof p == "object" && p.length === 2) {
280
+ let k = 0, T = 0;
281
+ return typeof p[0] == "number" && (k = p[0]), typeof p[1] == "number" && (T = p[1]), `//${d}/m/${k}x${T}${n} ${k}w`;
282
282
  }
283
283
  }).join(", "),
284
- sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
284
+ sizes: (u = e.sizes) == null ? void 0 : u.map((p) => p).join(", ")
285
285
  };
286
286
  let v = "";
287
287
  return g.srcset && (v += `srcset="${g.srcset}" `), g.sizes && (v += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${v.trim()}`);
@@ -298,7 +298,7 @@ class b {
298
298
  const s = this.getMatchingNode(t);
299
299
  return s && s.tag && e.push(this.renderOpeningTag(s.tag)), t.content ? t.content.forEach((r) => {
300
300
  e.push(this.renderNode(r));
301
- }) : t.text ? e.push(gt(t.text)) : s && s.singleTag ? e.push(this.renderTag(s.singleTag, " /")) : s && s.html ? e.push(s.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), s && s.tag && e.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((r) => {
301
+ }) : t.text ? e.push(mt(t.text)) : s && s.singleTag ? e.push(this.renderTag(s.singleTag, " /")) : s && s.html ? e.push(s.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), s && s.tag && e.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((r) => {
302
302
  const i = this.getMatchingMark(r);
303
303
  i && i.tag !== "" && e.push(this.renderClosingTag(i.tag));
304
304
  }), e.join("");
@@ -351,7 +351,7 @@ class b {
351
351
  return this.renderTag(e, " /");
352
352
  }
353
353
  }
354
- class w {
354
+ class $ {
355
355
  constructor() {
356
356
  h(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (t, e = 25, s = 1) => ({
357
357
  ...t,
@@ -374,13 +374,13 @@ class w {
374
374
  for (const i in t) {
375
375
  if (!Object.prototype.hasOwnProperty.call(t, i))
376
376
  continue;
377
- const n = t[i], l = s ? "" : encodeURIComponent(i);
377
+ const n = t[i], c = s ? "" : encodeURIComponent(i);
378
378
  let a;
379
379
  typeof n == "object" ? a = this.stringify(
380
380
  n,
381
- e ? e + encodeURIComponent("[" + l + "]") : l,
381
+ e ? e + encodeURIComponent("[" + c + "]") : c,
382
382
  Array.isArray(n)
383
- ) : a = (e ? e + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(n), r.push(a);
383
+ ) : a = (e ? e + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
384
384
  }
385
385
  return r.join("&");
386
386
  }
@@ -401,7 +401,7 @@ class w {
401
401
  }
402
402
  }
403
403
  }
404
- class ft {
404
+ class yt {
405
405
  constructor(t) {
406
406
  h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), 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 = {};
407
407
  }
@@ -440,15 +440,15 @@ class ft {
440
440
  async _methodHandler(t) {
441
441
  let e = `${this.baseURL}${this.url}`, s = null;
442
442
  if (t === "get") {
443
- const a = new w();
443
+ const a = new $();
444
444
  e = `${this.baseURL}${this.url}?${a.stringify(
445
445
  this.parameters
446
446
  )}`;
447
447
  } else
448
448
  s = JSON.stringify(this.parameters);
449
449
  const r = new URL(e), i = new AbortController(), { signal: n } = i;
450
- let l;
451
- this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
450
+ let c;
451
+ this.timeout && (c = setTimeout(() => i.abort(), this.timeout));
452
452
  try {
453
453
  const a = await this.fetch(`${r}`, {
454
454
  method: t,
@@ -456,9 +456,9 @@ class ft {
456
456
  body: s,
457
457
  signal: n
458
458
  });
459
- this.timeout && clearTimeout(l);
460
- const c = await this._responseHandler(a);
461
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
459
+ this.timeout && clearTimeout(c);
460
+ const l = await this._responseHandler(a);
461
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
462
462
  } catch (a) {
463
463
  return {
464
464
  message: a
@@ -482,9 +482,14 @@ class ft {
482
482
  });
483
483
  }
484
484
  }
485
+ const P = "SB-Agent", w = {
486
+ defaultAgentName: "SB-JS-CLIENT",
487
+ defaultAgentVersion: "SB-Agent-Version",
488
+ packageVersion: "2.2.3"
489
+ };
485
490
  let y = {};
486
491
  const f = {};
487
- class mt {
492
+ class bt {
488
493
  /**
489
494
  *
490
495
  * @param config ISbConfig interface
@@ -494,15 +499,16 @@ class mt {
494
499
  h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations");
495
500
  let s = t.endpoint || e;
496
501
  if (!s) {
497
- const n = new w().getRegionURL, l = t.https === !1 ? "http" : "https";
498
- t.oauthToken ? s = `${l}://${n(t.region)}/v1` : s = `${l}://${n(t.region)}/v2`;
502
+ const n = new $().getRegionURL, c = t.https === !1 ? "http" : "https";
503
+ t.oauthToken ? s = `${c}://${n(t.region)}/v1` : s = `${c}://${n(t.region)}/v2`;
499
504
  }
500
505
  const r = new Headers();
501
- r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((n, l) => {
502
- t.headers && t.headers[l] && r.set(l, t.headers[l]);
503
- });
506
+ if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), t.headers)
507
+ for (const n in t.headers)
508
+ r.set(n, t.headers[n]);
509
+ r.has(P) || (r.set(P, w.defaultAgentName), r.set(w.defaultAgentVersion, w.packageVersion));
504
510
  let i = 5;
505
- t.oauthToken && (r.set("Authorization", t.oauthToken), i = 3), t.rateLimit && (i = t.rateLimit), t.richTextSchema ? this.richTextResolver = new b(t.richTextSchema) : this.richTextResolver = new b(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = q(this.throttledRequest, i, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new w(), this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.client = new ft({
511
+ t.oauthToken && (r.set("Authorization", t.oauthToken), i = 3), t.rateLimit && (i = t.rateLimit), t.richTextSchema ? this.richTextResolver = new b(t.richTextSchema) : this.richTextResolver = new b(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = V(this.throttledRequest, i, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new $(), this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.client = new yt({
506
512
  baseURL: s,
507
513
  timeout: t.timeout || 0,
508
514
  headers: r,
@@ -539,13 +545,13 @@ class mt {
539
545
  return this.cacheResponse(s, r);
540
546
  }
541
547
  async getAll(t, e, s) {
542
- const r = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`, n = i.split("/"), l = s || n[n.length - 1], a = 1, c = await this.makeRequest(i, e, r, a), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
548
+ const r = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`, n = i.split("/"), c = s || n[n.length - 1], a = 1, l = await this.makeRequest(i, e, r, a), u = l.total ? Math.ceil(l.total / r) : 1, d = await this.helpers.asyncMap(
543
549
  this.helpers.range(a, u),
544
550
  (g) => this.makeRequest(i, e, r, g + 1)
545
551
  );
546
552
  return this.helpers.flatMap(
547
- [c, ...p],
548
- (g) => Object.values(g.data[l])
553
+ [l, ...d],
554
+ (g) => Object.values(g.data[c])
549
555
  );
550
556
  }
551
557
  post(t, e) {
@@ -621,20 +627,20 @@ class mt {
621
627
  async resolveLinks(t, e, s) {
622
628
  let r = [];
623
629
  if (t.link_uuids) {
624
- const i = t.link_uuids.length, n = [], l = 50;
625
- for (let a = 0; a < i; a += l) {
626
- const c = Math.min(i, a + l);
627
- n.push(t.link_uuids.slice(a, c));
630
+ const i = t.link_uuids.length, n = [], c = 50;
631
+ for (let a = 0; a < i; a += c) {
632
+ const l = Math.min(i, a + c);
633
+ n.push(t.link_uuids.slice(a, l));
628
634
  }
629
635
  for (let a = 0; a < n.length; a++)
630
636
  (await this.getStories({
631
- per_page: l,
637
+ per_page: c,
632
638
  language: e.language,
633
639
  version: e.version,
634
640
  by_uuids: n[a].join(",")
635
641
  })).data.stories.forEach(
636
- (c) => {
637
- r.push(c);
642
+ (l) => {
643
+ r.push(l);
638
644
  }
639
645
  );
640
646
  } else
@@ -649,19 +655,19 @@ class mt {
649
655
  async resolveRelations(t, e, s) {
650
656
  let r = [];
651
657
  if (t.rel_uuids) {
652
- const i = t.rel_uuids.length, n = [], l = 50;
653
- for (let a = 0; a < i; a += l) {
654
- const c = Math.min(i, a + l);
655
- n.push(t.rel_uuids.slice(a, c));
658
+ const i = t.rel_uuids.length, n = [], c = 50;
659
+ for (let a = 0; a < i; a += c) {
660
+ const l = Math.min(i, a + c);
661
+ n.push(t.rel_uuids.slice(a, l));
656
662
  }
657
663
  for (let a = 0; a < n.length; a++)
658
664
  (await this.getStories({
659
- per_page: l,
665
+ per_page: c,
660
666
  language: e.language,
661
667
  version: e.version,
662
668
  by_uuids: n[a].join(",")
663
- })).data.stories.forEach((c) => {
664
- r.push(c);
669
+ })).data.stories.forEach((l) => {
670
+ r.push(l);
665
671
  });
666
672
  } else
667
673
  r = t.rels;
@@ -676,14 +682,14 @@ class mt {
676
682
  var r, i;
677
683
  let n = [];
678
684
  if (this.links[s] = {}, this.relations[s] = {}, typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (n = e.resolve_relations.split(",")), await this.resolveRelations(t, e, s)), e.resolve_links && ["1", "story", "url"].indexOf(e.resolve_links) > -1 && ((r = t.links) != null && r.length || (i = t.link_uuids) != null && i.length) && await this.resolveLinks(t, e, s), this.resolveNestedRelations)
679
- for (const l in this.relations[s])
685
+ for (const c in this.relations[s])
680
686
  this.iterateTree(
681
- this.relations[s][l],
687
+ this.relations[s][c],
682
688
  n,
683
689
  s
684
690
  );
685
- t.story ? this.iterateTree(t.story, n, s) : t.stories.forEach((l) => {
686
- this.iterateTree(l, n, s);
691
+ t.story ? this.iterateTree(t.story, n, s) : t.stories.forEach((c) => {
692
+ this.iterateTree(c, n, s);
687
693
  }), delete this.links[s], delete this.relations[s];
688
694
  }
689
695
  async cacheResponse(t, e, s) {
@@ -693,25 +699,25 @@ class mt {
693
699
  if (n)
694
700
  return Promise.resolve(n);
695
701
  }
696
- return new Promise((n, l) => {
702
+ return new Promise((n, c) => {
697
703
  try {
698
704
  (async () => {
699
705
  var a;
700
706
  try {
701
- const c = await this.throttle("get", t, e);
702
- let u = { data: c.data, headers: c.headers };
703
- if ((a = c.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
704
- perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0,
705
- total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
706
- })), c.status != 200)
707
- return l(c);
707
+ const l = await this.throttle("get", t, e);
708
+ let u = { data: l.data, headers: l.headers };
709
+ if ((a = l.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
710
+ perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
711
+ total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
712
+ })), l.status != 200)
713
+ return c(l);
708
714
  if (u.data.story || u.data.stories) {
709
- const p = this.resolveCounter = ++this.resolveCounter % 1e3;
710
- await this.resolveStories(u.data, e, `${p}`);
715
+ const d = this.resolveCounter = ++this.resolveCounter % 1e3;
716
+ await this.resolveStories(u.data, e, `${d}`);
711
717
  }
712
718
  return e.version === "published" && t != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && e.token && (e.version == "draft" && f[e.token] != u.data.cv && await this.flushCache(), f[e.token] = u.data.cv), n(u);
713
- } catch (c) {
714
- return l(c);
719
+ } catch (l) {
720
+ return c(l);
715
721
  }
716
722
  })();
717
723
  } catch {
@@ -771,7 +777,7 @@ class mt {
771
777
  return await this.cacheProvider().flush(), this;
772
778
  }
773
779
  }
774
- const Rt = (o = {}) => {
780
+ const St = (o = {}) => {
775
781
  const { apiOptions: t } = o;
776
782
  if (!t.accessToken) {
777
783
  console.error(
@@ -779,8 +785,8 @@ const Rt = (o = {}) => {
779
785
  );
780
786
  return;
781
787
  }
782
- return { storyblokApi: new mt(t) };
783
- }, yt = (o) => {
788
+ return { storyblokApi: new bt(t) };
789
+ }, vt = (o) => {
784
790
  if (typeof o != "object" || typeof o._editable > "u")
785
791
  return {};
786
792
  const t = JSON.parse(
@@ -791,8 +797,8 @@ const Rt = (o = {}) => {
791
797
  "data-blok-uid": t.id + "-" + t.uid
792
798
  };
793
799
  };
794
- let $;
795
- const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", vt = (o, t, e = {}) => {
800
+ let _;
801
+ const kt = "https://app.storyblok.com/f/storyblok-v2-latest.js", wt = (o, t, e = {}) => {
796
802
  var s;
797
803
  const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
798
804
  "_storyblok"
@@ -808,24 +814,24 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", vt = (o, t, e =
808
814
  });
809
815
  });
810
816
  }
811
- }, kt = (o = {}) => {
817
+ }, $t = (o = {}) => {
812
818
  var t, e;
813
819
  const {
814
820
  bridge: s,
815
821
  accessToken: r,
816
822
  use: i = [],
817
823
  apiOptions: n = {},
818
- richText: l = {}
824
+ richText: c = {}
819
825
  } = o;
820
826
  n.accessToken = n.accessToken || r;
821
827
  const a = { bridge: s, apiOptions: n };
822
- let c = {};
823
- i.forEach((p) => {
824
- c = { ...c, ...p(a) };
828
+ let l = {};
829
+ i.forEach((d) => {
830
+ l = { ...l, ...d(a) };
825
831
  });
826
832
  const u = !(typeof window > "u") && ((e = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : e.includes("_storyblok_tk"));
827
- return s !== !1 && u && z(bt), $ = new b(l.schema), l.resolver && P($, l.resolver), c;
828
- }, P = (o, t) => {
833
+ return s !== !1 && u && U(kt), _ = new b(c.schema), c.resolver && x(_, c.resolver), l;
834
+ }, x = (o, t) => {
829
835
  o.addNode("blok", (e) => {
830
836
  let s = "";
831
837
  return e.attrs.body.forEach((r) => {
@@ -834,42 +840,42 @@ const bt = "https://app.storyblok.com/f/storyblok-v2-latest.js", vt = (o, t, e =
834
840
  html: s
835
841
  };
836
842
  });
837
- }, wt = (o) => {
843
+ }, _t = (o) => {
838
844
  var t, e;
839
845
  return !o || ((t = o == null ? void 0 : o.content) == null ? void 0 : t[0].type) !== "blok" && !((e = o == null ? void 0 : o.content) != null && e[0].content);
840
- }, jt = (o, t, e) => {
841
- let s = e || $;
846
+ }, Pt = (o, t, e) => {
847
+ let s = e || _;
842
848
  if (!s) {
843
849
  console.error(
844
850
  "Please initialize the Storyblok SDK before calling the renderRichText function"
845
851
  );
846
852
  return;
847
853
  }
848
- return wt(o) ? "" : (t && (s = new b(t.schema), t.resolver && P(s, t.resolver)), s.render(o));
849
- }, $t = /* @__PURE__ */ S({
854
+ return _t(o) ? "" : (t && (s = new b(t.schema), t.resolver && x(s, t.resolver)), s.render(o));
855
+ }, Tt = /* @__PURE__ */ I({
850
856
  __name: "StoryblokComponent",
851
857
  props: {
852
858
  blok: {}
853
859
  },
854
860
  setup(o) {
855
- return (t, e) => (E(), I(C(t.blok.component), O(A({ ...t.$props, ...t.$attrs })), null, 16));
861
+ return (t, e) => (A(), C(O(t.blok.component), N(M({ ...t.$props, ...t.$attrs })), null, 16));
856
862
  }
857
- }), _t = {
863
+ }), Rt = {
858
864
  beforeMount(o, t) {
859
865
  if (t.value) {
860
- const e = yt(t.value);
866
+ const e = vt(t.value);
861
867
  o.setAttribute("data-blok-c", e["data-blok-c"]), o.setAttribute("data-blok-uid", e["data-blok-uid"]), o.classList.add("storyblok__outline");
862
868
  }
863
869
  }
864
- }, x = (o) => {
870
+ }, E = (o) => {
865
871
  console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
866
872
  `);
867
873
  };
868
874
  let m = null;
869
- const Pt = () => (m || x("useStoryblokApi"), m), xt = async (o, t = {}, e = {}) => {
870
- const s = M(null);
871
- if (N(() => {
872
- s.value && s.value.id && vt(
875
+ const xt = () => (m || E("useStoryblokApi"), m), Et = async (o, t = {}, e = {}) => {
876
+ const s = z(null);
877
+ if (L(() => {
878
+ s.value && s.value.id && wt(
873
879
  s.value.id,
874
880
  (r) => s.value = r,
875
881
  e
@@ -881,23 +887,23 @@ const Pt = () => (m || x("useStoryblokApi"), m), xt = async (o, t = {}, e = {})
881
887
  );
882
888
  s.value = r.story;
883
889
  } else
884
- x("useStoryblok");
890
+ E("useStoryblok");
885
891
  return s;
886
- }, St = {
892
+ }, It = {
887
893
  install(o, t = {}) {
888
- o.directive("editable", _t), o.component("StoryblokComponent", $t);
889
- const { storyblokApi: e } = kt(t);
894
+ o.directive("editable", Rt), o.component("StoryblokComponent", Tt);
895
+ const { storyblokApi: e } = $t(t);
890
896
  m = e;
891
897
  }
892
898
  };
893
899
  export {
894
900
  b as RichTextResolver,
895
- dt as RichTextSchema,
896
- $t as StoryblokComponent,
897
- St as StoryblokVue,
898
- Rt as apiPlugin,
899
- jt as renderRichText,
900
- xt as useStoryblok,
901
- Pt as useStoryblokApi,
902
- vt as useStoryblokBridge
901
+ ft as RichTextSchema,
902
+ Tt as StoryblokComponent,
903
+ It as StoryblokVue,
904
+ St as apiPlugin,
905
+ Pt as renderRichText,
906
+ Et as useStoryblok,
907
+ xt as useStoryblokApi,
908
+ wt as useStoryblokBridge
903
909
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
- "version": "7.1.10",
3
+ "version": "7.1.12",
4
4
  "description": "Storyblok directive for get editable elements.",
5
5
  "main": "./dist/storyblok-vue.js",
6
6
  "module": "./dist/storyblok-vue.mjs",
@@ -25,26 +25,26 @@
25
25
  "prepublishOnly": "npm run build && cp ../README.md ./"
26
26
  },
27
27
  "dependencies": {
28
- "@storyblok/js": "^2.2.1"
28
+ "@storyblok/js": "^2.2.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.22.5",
31
+ "@babel/core": "^7.22.9",
32
32
  "@cypress/vite-dev-server": "^5.0.5",
33
33
  "@cypress/vue": "^5.0.5",
34
34
  "@vitejs/plugin-vue": "^4.2.3",
35
35
  "@vue/babel-preset-app": "^5.0.8",
36
- "@vue/test-utils": "2.4.0",
36
+ "@vue/test-utils": "2.4.1",
37
37
  "@vue/tsconfig": "^0.1.3",
38
38
  "@vue/vue3-jest": "^29.2.4",
39
39
  "babel-jest": "^29.4.3",
40
- "cypress": "^12.15.0",
40
+ "cypress": "^12.17.2",
41
41
  "eslint-plugin-cypress": "^2.13.3",
42
- "eslint-plugin-jest": "^27.2.2",
42
+ "eslint-plugin-jest": "^27.2.3",
43
43
  "jest": "^29.4.3",
44
44
  "typescript": "^4.9.5",
45
- "vite": "^4.3.9",
45
+ "vite": "^4.4.7",
46
46
  "vue": "^3.3.4",
47
- "vue-tsc": "^1.8.1"
47
+ "vue-tsc": "^1.8.6"
48
48
  },
49
49
  "babel": {
50
50
  "presets": [