@storyblok/js 3.2.5 → 3.3.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.
@@ -4,7 +4,7 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- (function(b,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(b=typeof globalThis<"u"?globalThis:b||self,I(b.storyblok={}))})(this,function(b){"use strict";let I=!1;const B=[],D=i=>new Promise((e,t)=>{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}I?r():B.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=i,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{B.forEach(o=>o()),I=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var X=Object.defineProperty,Q=(i,e,t)=>e in i?X(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e,t)=>Q(i,typeof e!="symbol"?e+"":e,t);class Z extends Error{constructor(e){super(e),this.name="AbortError"}}function ee(i,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],o=0,n=!1;const l=async()=>{o++;const c=s.shift();if(c)try{const d=await i(...c.args);c.resolve(d)}catch(d){c.reject(d)}const u=setTimeout(()=>{o--,s.length>0&&l(),r=r.filter(d=>d!==u)},t);r.includes(u)||r.push(u)},a=(...c)=>n?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,d)=>{s.push({resolve:u,reject:d,args:c}),o<e&&l()});return a.abort=()=>{n=!0,r.forEach(clearTimeout),r=[],s.forEach(c=>c.reject(()=>new Z("Throttle function aborted"))),s.length=0},a}let L=class{constructor(){p(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),p(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),p(this,"delay",e=>new Promise(t=>setTimeout(t,e))),p(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),p(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(o,n)=>n*r+e)}),p(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),p(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),p(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=new RegExp(s.source);return e&&r.test(e)?e.replace(s,o=>t[o]):e})}stringify(e,t,s){const r=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const n=e[o],l=s?"":encodeURIComponent(o);let a;typeof n=="object"?a=this.stringify(n,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(n)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(n)}`,r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",o="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return o;case"ca":return n;default:return t}}};const te=function(i,e){const t={};for(const s in i){const r=i[s];e.includes(s)&&r!==null&&(t[s]=r)}return t},se=i=>i==="email",re=()=>({singleTag:"hr"}),ie=()=>({tag:"blockquote"}),oe=()=>({tag:"ul"}),ne=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),ae=()=>({singleTag:"br"}),le=i=>({tag:`h${i.attrs.level}`}),ce=i=>({singleTag:[{tag:"img",attrs:te(i.attrs,["src","alt","title"])}]}),he=()=>({tag:"li"}),ue=()=>({tag:"ol"}),de=()=>({tag:"p"}),pe=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),ge=()=>({tag:"b"}),fe=()=>({tag:"s"}),me=()=>({tag:"u"}),ye=()=>({tag:"strong"}),be=()=>({tag:"code"}),ke=()=>({tag:"i"}),ve=i=>{if(!i.attrs)return{tag:""};const e=new L().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),se(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},$e=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Te=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Re=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Se=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},_e=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},q={nodes:{horizontal_rule:re,blockquote:ie,bullet_list:oe,code_block:ne,hard_break:ae,heading:le,image:ce,list_item:he,ordered_list:ue,paragraph:de,emoji:pe},marks:{bold:ge,strike:fe,underline:me,strong:ye,code:be,italic:ke,link:ve,styled:$e,subscript:Te,superscript:we,anchor:Re,highlight:Se,textStyle:_e}},Ee=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=new RegExp(t.source);return i&&s.test(i)?i.replace(t,r=>e[r]):i};let F=!1;class O{constructor(e){p(this,"marks"),p(this,"nodes"),e||(e=q),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},s=!0){if(!F&&s&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),F=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(o=>{r+=this.renderNode(o)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
7
+ (function($,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):($=typeof globalThis<"u"?globalThis:$||self,I($.storyblok={}))})(this,function($){"use strict";let I=!1;const D=[],q=i=>new Promise((e,t)=>{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}I?r():D.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=i,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{D.forEach(n=>n()),I=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var X=Object.defineProperty,Q=(i,e,t)=>e in i?X(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e,t)=>Q(i,typeof e!="symbol"?e+"":e,t);class Z extends Error{constructor(e){super(e),this.name="AbortError"}}function ee(i,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],n=0,o=!1;const l=async()=>{n++;const h=s.shift();if(h)try{const p=await i(...h.args);h.resolve(p)}catch(p){h.reject(p)}const u=setTimeout(()=>{n--,s.length>0&&l(),r=r.filter(p=>p!==u)},t);r.includes(u)||r.push(u)},a=(...h)=>o?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,p)=>{s.push({resolve:u,reject:p,args:h}),n<e&&l()});return a.abort=()=>{o=!0,r.forEach(clearTimeout),r=[],s.forEach(h=>h.reject(()=>new Z("Throttle function aborted"))),s.length=0},a}class x{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),g(this,"delay",e=>new Promise(t=>setTimeout(t,e))),g(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),g(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,o)=>o*r+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),g(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=new RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n],l=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=this.stringify(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",o="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return o;default:return t}}}const te=function(i,e){const t={};for(const s in i){const r=i[s];e.includes(s)&&r!==null&&(t[s]=r)}return t},se=i=>i==="email",re=()=>({singleTag:"hr"}),ie=()=>({tag:"blockquote"}),ne=()=>({tag:"ul"}),oe=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),ae=()=>({singleTag:"br"}),le=i=>({tag:`h${i.attrs.level}`}),ce=i=>({singleTag:[{tag:"img",attrs:te(i.attrs,["src","alt","title"])}]}),he=()=>({tag:"li"}),ue=()=>({tag:"ol"}),de=()=>({tag:"p"}),pe=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),ge=()=>({tag:"b"}),fe=()=>({tag:"s"}),me=()=>({tag:"u"}),ye=()=>({tag:"strong"}),be=()=>({tag:"code"}),ke=()=>({tag:"i"}),$e=i=>{if(!i.attrs)return{tag:""};const e=new x().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),se(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ve=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Te=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Re=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Ee=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},_e=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},F={nodes:{horizontal_rule:re,blockquote:ie,bullet_list:ne,code_block:oe,hard_break:ae,heading:le,image:ce,list_item:he,ordered_list:ue,paragraph:de,emoji:pe},marks:{bold:ge,strike:fe,underline:me,strong:ye,code:be,italic:ke,link:$e,styled:ve,subscript:Te,superscript:we,anchor:Re,highlight:Ee,textStyle:_e}},Se=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=new RegExp(t.source);return i&&s.test(i)?i.replace(t,r=>e[r]):i};let G=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=F),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},s=!0){if(!G&&s&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),G=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
8
8
  The "content" field must be an array of nodes as the type ISbRichtext.
9
9
  ISbRichtext:
10
10
  content?: ISbRichtext[]
@@ -27,4 +27,4 @@
27
27
  }
28
28
  ],
29
29
  type: 'doc'
30
- }`),""}optimizeImages(e,t){let s=0,r=0,o="",n="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(o+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(o+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(o+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(o+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(n+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(n+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(n+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(n+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(n+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(n+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(n+=`:rotate(${t.filters.rotate})`),n.length>0&&(n=`/filters${n}`))),o.length>0&&(e=e.replace(/<img/g,`<img ${o.trim()}`));const l=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,u;const d=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(d&&d.length>0){const m={srcset:(c=t.srcset)==null?void 0:c.map(k=>{if(typeof k=="number")return`//${d}/m/${k}x0${n} ${k}w`;if(typeof k=="object"&&k.length===2){let E=0,x=0;return typeof k[0]=="number"&&(E=k[0]),typeof k[1]=="number"&&(x=k[1]),`//${d}/m/${E}x${x}${n} ${E}w`}return""}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(k=>k).join(", ")};let y="";return m.srcset&&(y+=`srcset="${m.srcset}" `),m.sizes&&(y+=`sizes="${m.sizes}" `),a.replace(/<img/g,`<img ${y.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const o=this.getMatchingMark(r);o&&o.tag!==""&&t.push(this.renderOpeningTag(o.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(Ee(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const o=this.getMatchingMark(r);o&&o.tag!==""&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const o in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,o)){const n=s.attrs[o];n!==null&&(r+=` ${o}="${n}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class je{constructor(e){p(this,"baseURL"),p(this,"timeout"),p(this,"headers"),p(this,"responseInterceptor"),p(this,"fetch"),p(this,"ejectInterceptor"),p(this,"url"),p(this,"parameters"),p(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new L;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),o=new AbortController,{signal:n}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const o={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(o)})}}const G="SB-Agent",N={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let P={};const _={};class Ie{constructor(e,t){p(this,"client"),p(this,"maxRetries"),p(this,"retriesDelay"),p(this,"throttle"),p(this,"accessToken"),p(this,"cache"),p(this,"helpers"),p(this,"resolveCounter"),p(this,"relations"),p(this,"links"),p(this,"richTextResolver"),p(this,"resolveNestedRelations"),p(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const n=new L().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${n(e.region)}/v1`:s=`${l}://${n(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([n,l])=>{r.set(n,l)}),r.has(G)||(r.set(G,N.defaultAgentName),r.set(N.defaultAgentVersion,N.packageVersion));let o=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),e.richTextSchema?this.richTextResolver=new O(e.richTextSchema):this.richTextResolver=new O,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=ee(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new L,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new je({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=_[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,o){const n=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,n,void 0,o)}get(e,t,s){t||(t={});const r=`/${e}`,o=this.factoryParamOptions(r,t);return this.cacheResponse(r,o,void 0,s)}async getAll(e,t,s,r){const o=(t==null?void 0:t.per_page)||25,n=`/${e}`.replace(/\/$/,""),l=s??n.substring(n.lastIndexOf("/")+1),a=1,c=await this.makeRequest(n,t,o,a,r),u=c.total?Math.ceil(c.total/o):1,d=await this.helpers.asyncMap(this.helpers.range(a,u),m=>this.makeRequest(n,t,o,m+1,r));return this.helpers.flatMap([c,...d],m=>Object.values(m.data[l]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){t||(t={});const r=`/${e}`;return Promise.resolve(this.throttle("delete",r,t,s))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}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,s){const r=e[t];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]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,s){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(s,r):Array.isArray(r)&&(e[t]=r.map(o=>this.getStoryReference(s,o)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(n=>n.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(o):s===o)&&this._resolveField(e,t,r)}iterateTree(e,t,s){const r=(o,n="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,a)=>r(l,`${n}[${a}]`));else if(typeof o=="object")for(const l in o){const a=n?`${n}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,s),this._insertLinks(o,l,s)),r(o[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const o=e.link_uuids.length,n=[],l=50;for(let a=0;a<o;a+=l){const c=Math.min(o,a+l);n.push(e.link_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:n[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(o=>{this.links[s][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length,n=[],l=50;for(let a=0;a<o;a+=l){const c=Math.min(o,a+l);n.push(e.rel_uuids.slice(a,c))}for(let a=0;a<n.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:n[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(o=>{this.relations[s][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,s){var r,o;let n=[];if(this.links[s]={},this.relations[s]={},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,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],n,s);e.story?this.iterateTree(e.story,n,s):e.stories.forEach(l=>{this.iterateTree(l,n,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const o=this.helpers.stringify({url:e,params:t}),n=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await n.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,r);if(u.status!==200)return a(u);let d={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(d=Object.assign({},d,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),d.data.story||d.data.stories){const y=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(d.data,t,`${y}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await n.set(o,d);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&d.data.cv&&(m&&_[t.token]&&_[t.token]!==d.data.cv&&await this.flushCache(),_[t.token]=d.data.cv),l(d)}catch(u){if(u.response&&u.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(l).catch(a);a(u)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return _}cacheVersion(){return _[this.accessToken]}setCacheVersion(e){this.accessToken&&(_[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(_[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}}const Oe=(i={})=>{const{apiOptions:e}=i;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Ie(e)}},Ae=i=>{if(typeof i!="object"||typeof i._editable>"u")return{};try{const e=JSON.parse(i._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function xe(i,e){if(!e)return{src:i,attrs:{}};let t=0,s=0;const r={},o=[];function n(a,c,u,d,m){typeof a!="number"||a<=c||a>=u?console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase()+d.slice(1)} value must be a number between ${c} and ${u} (inclusive)`):m.push(`${d}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,s=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:a}=e||{},{blur:c,brightness:u,fill:d,format:m,grayscale:y,quality:k,rotate:E}=a||{};c&&n(c,0,100,"blur",o),k&&n(k,0,100,"quality",o),u&&n(u,0,100,"brightness",o),d&&o.push(`fill(${d})`),y&&o.push("grayscale()"),E&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${E})`),m&&["webp","png","jpeg"].includes(m)&&o.push(`format(${m})`)}e.srcset&&(r.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${i}/m/${a}x0/${o.length>0?`filters:${o.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[c,u]=a;return`${i}/m/${c}x${u}/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let l=`${i}/m/`;return t>0&&s>0&&(l=`${l}${t}x${s}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:r}}var v=(i=>(i.DOCUMENT="doc",i.HEADING="heading",i.PARAGRAPH="paragraph",i.QUOTE="blockquote",i.OL_LIST="ordered_list",i.UL_LIST="bullet_list",i.LIST_ITEM="list_item",i.CODE_BLOCK="code_block",i.HR="horizontal_rule",i.BR="hard_break",i.IMAGE="image",i.EMOJI="emoji",i.COMPONENT="blok",i))(v||{}),T=(i=>(i.BOLD="bold",i.STRONG="strong",i.STRIKE="strike",i.UNDERLINE="underline",i.ITALIC="italic",i.CODE="code",i.LINK="link",i.ANCHOR="anchor",i.STYLED="styled",i.SUPERSCRIPT="superscript",i.SUBSCRIPT="subscript",i.TEXT_STYLE="textStyle",i.HIGHLIGHT="highlight",i))(T||{}),M=(i=>(i.TEXT="text",i))(M||{}),A=(i=>(i.URL="url",i.STORY="story",i.ASSET="asset",i.EMAIL="email",i))(A||{});const Le=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Pe=(i={})=>Object.keys(i).map(e=>`${e}="${i[e]}"`).join(" "),Ce=(i={})=>Object.keys(i).map(e=>`${e}: ${i[e]}`).join("; ");function Ne(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const V=i=>Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==void 0));function J(i,e={},t){const s=Pe(e),r=s?`${i} ${s}`:i,o=Array.isArray(t)?t.join(""):t||"";if(i){if(Le.includes(i))return`<${r}>`}else return o;return`<${r}>${o}</${i}>`}function Me(i={}){let e=0;const{renderFn:t=J,textFn:s=Ne,resolvers:r={},optimizeImages:o=!1,keyedResolvers:n=!1}=i,l=t!==J,a=h=>g=>{const f=g.attrs||{};return n&&(f.key=`${h}-${e}`),t(h,f,g.children||null)},c=h=>{const{src:g,alt:f,title:$,srcset:S,sizes:w}=h.attrs||{};let R=g,j={};if(o){const{src:Fe,attrs:Ge}=xe(g,o);R=Fe,j=Ge}n&&(j={...j,key:`img-${e}`});const qe={src:R,alt:f,title:$,srcset:S,sizes:w,...j};return t("img",V(qe))},u=h=>{const{level:g,...f}=h.attrs||{},$={...f};return n&&($.key=`h${g}-${e}`),t(`h${g}`,$,h.children)},d=h=>{var g,f,$,S;const w=t("img",{src:(g=h.attrs)==null?void 0:g.fallbackImage,alt:(f=h.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}),R={"data-type":"emoji","data-name":($=h.attrs)==null?void 0:$.name,"data-emoji":(S=h.attrs)==null?void 0:S.emoji};return n&&(R.key=`emoji-${e}`),t("span",R,w)},m=h=>t("pre",{...h.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},h.children||"")),y=(h,g=!1)=>({text:f,attrs:$})=>{const{class:S,id:w,...R}=$||{},j=g?{class:S,id:w,style:Ce(R)||void 0}:$||{};return n&&(j.key=`${h}-${e}`),t(h,V(j),f)},k=h=>z(h),E=h=>{const{marks:g,...f}=h;return"text"in h?g?g.reduce(($,S)=>k({...S,text:$}),k({...f,children:f.children})):s(f.text):""},x=h=>{const{linktype:g,href:f,anchor:$,...S}=h.attrs||{};let w="";switch(g){case A.ASSET:case A.URL:w=f;break;case A.EMAIL:w=`mailto:${f}`;break;case A.STORY:w=f,$&&(w=`${w}#${$}`);break;default:w=f;break}const R={...S};return w&&(R.href=w),n&&(R.key=`a-${e}`),t("a",R,h.text)},Be=h=>{var g,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(g=h==null?void 0:h.attrs)==null?void 0:g.body[0],id:(f=h.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},De=new Map([[v.DOCUMENT,a("")],[v.HEADING,u],[v.PARAGRAPH,a("p")],[v.UL_LIST,a("ul")],[v.OL_LIST,a("ol")],[v.LIST_ITEM,a("li")],[v.IMAGE,c],[v.EMOJI,d],[v.CODE_BLOCK,m],[v.HR,a("hr")],[v.BR,a("br")],[v.QUOTE,a("blockquote")],[v.COMPONENT,Be],[M.TEXT,E],[T.LINK,x],[T.ANCHOR,x],[T.STYLED,y("span",!0)],[T.BOLD,y("strong")],[T.TEXT_STYLE,y("span",!0)],[T.ITALIC,y("em")],[T.UNDERLINE,y("u")],[T.STRIKE,y("s")],[T.CODE,y("code")],[T.SUPERSCRIPT,y("sup")],[T.SUBSCRIPT,y("sub")],[T.HIGHLIGHT,y("mark")],...Object.entries(r).map(([h,g])=>[h,g])]);function C(h){e+=1;const g=De.get(h.type);if(!g)return console.error("<Storyblok>",`No resolver found for node type ${h.type}`),"";if(h.type==="text")return g(h);const f=h.content?h.content.map(z):void 0;return g({...h,children:f})}function z(h){return h.type==="doc"?l?h.content.map(C):h.content.map(C).join(""):Array.isArray(h)?h.map(C):C(h)}return{render:z}}let H,U="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(i,e,t={})=>{var l;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((l=window.location)==null?void 0:l.href).searchParams.get("_storyblok"),n=o!==null&&+o===i;if(!(!r||!n)){if(!i){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],c=>{var u;c&&(c.action==="input"&&((u=c.story)==null?void 0:u.id)===i?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===i&&window.location.reload())})})}},Y=(i,e)=>{i.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},He=(i={})=>{var d,m;const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:o={},bridgeUrl:n}=i;r.accessToken=r.accessToken||t;const l={bridge:e,apiOptions:r};let a={};s.forEach(y=>{a={...a,...y(l)}}),n&&(U=n);const u=!(typeof window>"u")&&((m=(d=window.location)==null?void 0:d.search)==null?void 0:m.includes("_storyblok_tk"));return e!==!1&&u&&D(U),H=new O(o.schema),o.resolver&&Y(H,o.resolver),a},W=i=>{var e;return!i||!((e=i==null?void 0:i.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Ue=(i,e,t)=>{let s=t||H;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return W(i)?"":(e&&(s=new O(e.schema),e.resolver&&Y(s,e.resolver)),s.render(i,{},!1))},ze=()=>D(U);b.BlockTypes=v,b.MarkTypes=T,b.RichTextResolver=O,b.RichTextSchema=q,b.TextTypes=M,b.apiPlugin=Oe,b.isRichTextEmpty=W,b.loadStoryblokBridge=ze,b.registerStoryblokBridge=K,b.renderRichText=Ue,b.richTextResolver=Me,b.storyblokEditable=Ae,b.storyblokInit=He,b.useStoryblokBridge=K,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
30
+ }`),""}optimizeImages(e,t){let s=0,r=0,n="",o="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(o+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(o+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(o+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(o+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(o+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(o+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(o+=`:rotate(${t.filters.rotate})`),o.length>0&&(o=`/filters${o}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||r>0||o.length>0?`${s}x${r}${o}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var h,u;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const y={srcset:(h=t.srcset)==null?void 0:h.map(w=>{if(typeof w=="number")return`//${p}/m/${w}x0${o} ${w}w`;if(typeof w=="object"&&w.length===2){let j=0,L=0;return typeof w[0]=="number"&&(j=w[0]),typeof w[1]=="number"&&(L=w[1]),`//${p}/m/${j}x${L}${o} ${j}w`}return""}).join(", "),sizes:(u=t.sizes)==null?void 0:u.map(w=>w).join(", ")};let k="";return y.srcset&&(k+=`srcset="${y.srcset}" `),y.sizes&&(k+=`sizes="${y.sizes}" `),a.replace(/<img/g,`<img ${k.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(Se(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs){for(const n in s.attrs)if(Object.prototype.hasOwnProperty.call(s.attrs,n)){const o=s.attrs[n];o!==null&&(r+=` ${n}="${o}"`)}}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class je{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new x;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}const V="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let C={};const S={};class Ie{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"helpers"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const o=new x().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${o(e.region)}/v1`:s=`${l}://${o(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,l])=>{r.set(o,l)}),r.has(V)||(r.set(V,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new A(e.richTextSchema):this.richTextResolver=new A,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=ee(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new x,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new je({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r,n){const o=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,o,void 0,n)}get(e,t,s){t||(t={});const r=`/${e}`,n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,s)}async getAll(e,t,s,r){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=s??o.substring(o.lastIndexOf("/")+1),a=1,h=await this.makeRequest(o,t,n,a,r),u=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(a,u),y=>this.makeRequest(o,t,n,y+1,r));return this.helpers.flatMap([h,...p],y=>Object.values(y.data[l]))}post(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t,s))}put(e,t,s){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t,s))}delete(e,t,s){t||(t={});const r=`/${e}`;return Promise.resolve(this.throttle("delete",r,t,s))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}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,s){const r=e[t];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]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,s){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(s,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(s,n)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(o=>o.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(n):s===n)&&this._resolveField(e,t,r)}iterateTree(e,t,s){const r=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>r(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,s),this._insertLinks(n,l,s)),r(n[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);o.push(e.link_uuids.slice(a,h))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(h=>{r.push(h)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,h))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{r.push(h)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let o=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],o,s);e.story?this.iterateTree(e.story,o,s):e.stories.forEach(l=>{this.iterateTree(l,o,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const n=this.helpers.stringify({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var h;try{const u=await this.throttle("get",e,t,r);if(u.status!==200)return a(u);let p={data:u.data,headers:u.headers};if((h=u.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),p.data.story||p.data.stories){const k=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${k}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,p);const y=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(y&&S[t.token]&&S[t.token]!==p.data.cv&&await this.flushCache(),S[t.token]=p.data.cv),l(p)}catch(u){if(u.response&&u.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(l).catch(a);a(u)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(C[e])},getAll(){return Promise.resolve(C)},set(e,t){return C[e]=t,Promise.resolve(void 0)},flush(){return C={},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}}const Ae=(i={})=>{const{apiOptions:e}=i;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Ie(e)}},Oe=i=>{if(typeof i!="object"||typeof i._editable>"u")return{};try{const e=JSON.parse(i._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Le(i,e){if(!e)return{src:i,attrs:{}};let t=0,s=0;const r={},n=[];function o(a,h,u,p,y){typeof a!="number"||a<=h||a>=u?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`):y.push(`${p}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,s=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:u,fill:p,format:y,grayscale:k,quality:w,rotate:j}=a||{};h&&o(h,0,100,"blur",n),w&&o(w,0,100,"quality",n),u&&o(u,0,100,"brightness",n),p&&n.push(`fill(${p})`),k&&n.push("grayscale()"),j&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${j})`),y&&["webp","png","jpeg"].includes(y)&&n.push(`format(${y})`)}e.srcset&&(r.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${i}/m/${a}x0/${n.length>0?`filters:${n.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,u]=a;return`${i}/m/${h}x${u}/${n.length>0?`filters:${n.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let l=`${i}/m/`;return t>0&&s>0&&(l=`${l}${t}x${s}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:r}}var v=(i=>(i.DOCUMENT="doc",i.HEADING="heading",i.PARAGRAPH="paragraph",i.QUOTE="blockquote",i.OL_LIST="ordered_list",i.UL_LIST="bullet_list",i.LIST_ITEM="list_item",i.CODE_BLOCK="code_block",i.HR="horizontal_rule",i.BR="hard_break",i.IMAGE="image",i.EMOJI="emoji",i.COMPONENT="blok",i.TABLE="table",i.TABLE_ROW="tableRow",i.TABLE_CELL="tableCell",i.TABLE_HEADER="tableHeader",i))(v||{}),_=(i=>(i.BOLD="bold",i.STRONG="strong",i.STRIKE="strike",i.UNDERLINE="underline",i.ITALIC="italic",i.CODE="code",i.LINK="link",i.ANCHOR="anchor",i.STYLED="styled",i.SUPERSCRIPT="superscript",i.SUBSCRIPT="subscript",i.TEXT_STYLE="textStyle",i.HIGHLIGHT="highlight",i))(_||{}),B=(i=>(i.TEXT="text",i))(B||{}),O=(i=>(i.URL="url",i.STORY="story",i.ASSET="asset",i.EMAIL="email",i))(O||{});const xe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ce=(i={})=>Object.keys(i).map(e=>`${e}="${i[e]}"`).join(" "),Pe=(i={})=>Object.keys(i).map(e=>`${e}: ${i[e]}`).join("; ");function Ne(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const P=i=>Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==void 0));function J(i,e={},t){const s=Ce(e),r=s?`${i} ${s}`:i,n=Array.isArray(t)?t.join(""):t||"";if(i){if(xe.includes(i))return`<${r}>`}else return n;return`<${r}>${n}</${i}>`}function He(i={}){let e=0;const{renderFn:t=J,textFn:s=Ne,resolvers:r={},optimizeImages:n=!1,keyedResolvers:o=!1}=i,l=t!==J,a=c=>d=>{const f=d.attrs||{};return o&&(f.key=`${c}-${e}`),t(c,f,d.children||null)},h=c=>{const{src:d,alt:f,title:b,srcset:E,sizes:T}=c.attrs||{};let m=d,R={};if(n){const{src:Ke,attrs:Ye}=Le(d,n);m=Ke,R=Ye}o&&(R={...R,key:`img-${e}`});const Je={src:m,alt:f,title:b,srcset:E,sizes:T,...R};return t("img",P(Je))},u=c=>{const{level:d,...f}=c.attrs||{},b={...f};return o&&(b.key=`h${d}-${e}`),t(`h${d}`,b,c.children)},p=c=>{var d,f,b,E;const T=t("img",{src:(d=c.attrs)==null?void 0:d.fallbackImage,alt:(f=c.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}),m={"data-type":"emoji","data-name":(b=c.attrs)==null?void 0:b.name,"data-emoji":(E=c.attrs)==null?void 0:E.emoji};return o&&(m.key=`emoji-${e}`),t("span",m,T)},y=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),k=(c,d=!1)=>({text:f,attrs:b})=>{const{class:E,id:T,...m}=b||{},R=d?{class:E,id:T,style:Pe(m)||void 0}:b||{};return o&&(R.key=`${c}-${e}`),t(c,P(R),f)},w=c=>z(c),j=c=>{const{marks:d,...f}=c;return"text"in c?d?d.reduce((b,E)=>w({...E,text:b}),w({...f,children:f.children})):s(f.text):""},L=c=>{const{linktype:d,href:f,anchor:b,...E}=c.attrs||{};let T="";switch(d){case O.ASSET:case O.URL:T=f;break;case O.EMAIL:T=`mailto:${f}`;break;case O.STORY:T=f,b&&(T=`${T}#${b}`);break;default:T=f;break}const m={...E};return T&&(m.href=T),o&&(m.key=`a-${e}`),t("a",m,c.text)},ze=c=>{var d,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(d=c==null?void 0:c.attrs)==null?void 0:d.body[0],id:(f=c.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},De=c=>{const d={};return o&&(d.key=`table-${e}`),t("table",d,c.children)},qe=c=>{const d={};return o&&(d.key=`tr-${e}`),t("tr",d,c.children)},Fe=c=>{const{colspan:d,rowspan:f,colwidth:b,backgroundColor:E,...T}=c.attrs||{},m={...T};d>1&&(m.colspan=d),f>1&&(m.rowspan=f);const R=[];return b&&R.push(`width: ${b}px;`),E&&R.push(`background-color: ${E};`),R.length>0&&(m.style=R.join(" ")),o&&(m.key=`td-${e}`),t("td",P(m),c.children)},Ge=c=>{const{colspan:d,rowspan:f,colwidth:b,backgroundColor:E,...T}=c.attrs||{},m={...T};d>1&&(m.colspan=d),f>1&&(m.rowspan=f);const R=[];return b&&R.push(`width: ${b}px;`),E&&R.push(`background-color: ${E};`),R.length>0&&(m.style=R.join(" ")),o&&(m.key=`th-${e}`),t("th",P(m),c.children)},Ve=new Map([[v.DOCUMENT,a("")],[v.HEADING,u],[v.PARAGRAPH,a("p")],[v.UL_LIST,a("ul")],[v.OL_LIST,a("ol")],[v.LIST_ITEM,a("li")],[v.IMAGE,h],[v.EMOJI,p],[v.CODE_BLOCK,y],[v.HR,a("hr")],[v.BR,a("br")],[v.QUOTE,a("blockquote")],[v.COMPONENT,ze],[B.TEXT,j],[_.LINK,L],[_.ANCHOR,L],[_.STYLED,k("span",!0)],[_.BOLD,k("strong")],[_.TEXT_STYLE,k("span",!0)],[_.ITALIC,k("em")],[_.UNDERLINE,k("u")],[_.STRIKE,k("s")],[_.CODE,k("code")],[_.SUPERSCRIPT,k("sup")],[_.SUBSCRIPT,k("sub")],[_.HIGHLIGHT,k("mark")],[v.TABLE,De],[v.TABLE_ROW,qe],[v.TABLE_CELL,Fe],[v.TABLE_HEADER,Ge],...Object.entries(r).map(([c,d])=>[c,d])]);function N(c){e+=1;const d=Ve.get(c.type);if(!d)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return d(c);const f=c.content?c.content.map(z):void 0;return d({...c,children:f})}function z(c){return c.type==="doc"?l?c.content.map(N):c.content.map(N).join(""):Array.isArray(c)?c.map(N):N(c)}return{render:z}}let M,U="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(i,e,t={})=>{var l;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((l=window.location)==null?void 0:l.href).searchParams.get("_storyblok"),o=n!==null&&+n===i;if(!(!r||!o)){if(!i){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],h=>{var u;h&&(h.action==="input"&&((u=h.story)==null?void 0:u.id)===i?e(h.story):(h.action==="change"||h.action==="published")&&h.storyId===i&&window.location.reload())})})}},Y=(i,e)=>{i.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},Be=(i={})=>{var p,y;const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:n={},bridgeUrl:o}=i;r.accessToken=r.accessToken||t;const l={bridge:e,apiOptions:r};let a={};s.forEach(k=>{a={...a,...k(l)}}),o&&(U=o);const u=!(typeof window>"u")&&((y=(p=window.location)==null?void 0:p.search)==null?void 0:y.includes("_storyblok_tk"));return e!==!1&&u&&q(U),M=new A(n.schema),n.resolver&&Y(M,n.resolver),a},W=i=>{var e;return!i||!((e=i==null?void 0:i.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Me=(i,e,t)=>{let s=t||M;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return W(i)?"":(e&&(s=new A(e.schema),e.resolver&&Y(s,e.resolver)),s.render(i,{},!1))},Ue=()=>q(U);$.BlockTypes=v,$.MarkTypes=_,$.RichTextResolver=A,$.RichTextSchema=F,$.TextTypes=B,$.apiPlugin=Ae,$.isRichTextEmpty=W,$.loadStoryblokBridge=Ue,$.registerStoryblokBridge=K,$.renderRichText=Me,$.richTextResolver=He,$.storyblokEditable=Oe,$.storyblokInit=Be,$.useStoryblokBridge=K,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
@@ -4,28 +4,28 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- let H = !1;
7
+ let B = !1;
8
8
  const U = [], F = (i) => new Promise((e, t) => {
9
9
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
10
10
  if (window.location === window.parent.location) {
11
11
  console.warn("You are not in Draft Mode or in the Visual Editor.");
12
12
  return;
13
13
  }
14
- H ? r() : U.push(r);
14
+ B ? r() : U.push(r);
15
15
  }, document.getElementById("storyblok-javascript-bridge")))
16
16
  return;
17
17
  const s = document.createElement("script");
18
18
  s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
19
- U.forEach((o) => o()), H = !0, e(r);
19
+ U.forEach((o) => o()), B = !0, e(r);
20
20
  }, document.getElementsByTagName("head")[0].appendChild(s);
21
21
  });
22
- var Q = Object.defineProperty, Z = (i, e, t) => e in i ? Q(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, p = (i, e, t) => Z(i, typeof e != "symbol" ? e + "" : e, t);
23
- class ee extends Error {
22
+ var se = Object.defineProperty, re = (i, e, t) => e in i ? se(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, g = (i, e, t) => re(i, typeof e != "symbol" ? e + "" : e, t);
23
+ class ie extends Error {
24
24
  constructor(e) {
25
25
  super(e), this.name = "AbortError";
26
26
  }
27
27
  }
28
- function te(i, e, t) {
28
+ function oe(i, e, t) {
29
29
  if (!Number.isFinite(e))
30
30
  throw new TypeError("Expected `limit` to be a finite number");
31
31
  if (!Number.isFinite(t))
@@ -34,45 +34,45 @@ function te(i, e, t) {
34
34
  let r = [], o = 0, n = !1;
35
35
  const l = async () => {
36
36
  o++;
37
- const c = s.shift();
38
- if (c)
37
+ const h = s.shift();
38
+ if (h)
39
39
  try {
40
- const d = await i(...c.args);
41
- c.resolve(d);
42
- } catch (d) {
43
- c.reject(d);
40
+ const p = await i(...h.args);
41
+ h.resolve(p);
42
+ } catch (p) {
43
+ h.reject(p);
44
44
  }
45
45
  const u = setTimeout(() => {
46
- o--, s.length > 0 && l(), r = r.filter((d) => d !== u);
46
+ o--, s.length > 0 && l(), r = r.filter((p) => p !== u);
47
47
  }, t);
48
48
  r.includes(u) || r.push(u);
49
- }, a = (...c) => n ? Promise.reject(
49
+ }, a = (...h) => n ? Promise.reject(
50
50
  new Error(
51
51
  "Throttled function is already aborted and not accepting new promises"
52
52
  )
53
- ) : new Promise((u, d) => {
53
+ ) : new Promise((u, p) => {
54
54
  s.push({
55
55
  resolve: u,
56
- reject: d,
57
- args: c
56
+ reject: p,
57
+ args: h
58
58
  }), o < e && l();
59
59
  });
60
60
  return a.abort = () => {
61
61
  n = !0, r.forEach(clearTimeout), r = [], s.forEach(
62
- (c) => c.reject(() => new ee("Throttle function aborted"))
62
+ (h) => h.reject(() => new ie("Throttle function aborted"))
63
63
  ), s.length = 0;
64
64
  }, a;
65
65
  }
66
- let A = class {
66
+ class L {
67
67
  constructor() {
68
- p(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), p(this, "getOptionsPage", (e, t = 25, s = 1) => ({
68
+ g(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), g(this, "getOptionsPage", (e, t = 25, s = 1) => ({
69
69
  ...e,
70
70
  per_page: t,
71
71
  page: s
72
- })), p(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), p(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), p(this, "range", (e = 0, t = e) => {
72
+ })), g(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), g(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), g(this, "range", (e = 0, t = e) => {
73
73
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
74
74
  return this.arrayFrom(s, (o, n) => n * r + e);
75
- }), p(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), p(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), p(this, "escapeHTML", function(e) {
75
+ }), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), g(this, "escapeHTML", function(e) {
76
76
  const t = {
77
77
  "&": "&amp;",
78
78
  "<": "&lt;",
@@ -125,21 +125,21 @@ let A = class {
125
125
  return t;
126
126
  }
127
127
  }
128
- };
129
- const se = function(i, e) {
128
+ }
129
+ const ne = function(i, e) {
130
130
  const t = {};
131
131
  for (const s in i) {
132
132
  const r = i[s];
133
133
  e.includes(s) && r !== null && (t[s] = r);
134
134
  }
135
135
  return t;
136
- }, re = (i) => i === "email", ie = () => ({
136
+ }, ae = (i) => i === "email", le = () => ({
137
137
  singleTag: "hr"
138
- }), oe = () => ({
138
+ }), ce = () => ({
139
139
  tag: "blockquote"
140
- }), ne = () => ({
140
+ }), he = () => ({
141
141
  tag: "ul"
142
- }), ae = (i) => ({
142
+ }), ue = (i) => ({
143
143
  tag: [
144
144
  "pre",
145
145
  {
@@ -147,24 +147,24 @@ const se = function(i, e) {
147
147
  attrs: i.attrs
148
148
  }
149
149
  ]
150
- }), le = () => ({
150
+ }), de = () => ({
151
151
  singleTag: "br"
152
- }), ce = (i) => ({
152
+ }), pe = (i) => ({
153
153
  tag: `h${i.attrs.level}`
154
- }), he = (i) => ({
154
+ }), ge = (i) => ({
155
155
  singleTag: [
156
156
  {
157
157
  tag: "img",
158
- attrs: se(i.attrs, ["src", "alt", "title"])
158
+ attrs: ne(i.attrs, ["src", "alt", "title"])
159
159
  }
160
160
  ]
161
- }), ue = () => ({
161
+ }), fe = () => ({
162
162
  tag: "li"
163
- }), de = () => ({
163
+ }), me = () => ({
164
164
  tag: "ol"
165
- }), pe = () => ({
165
+ }), ye = () => ({
166
166
  tag: "p"
167
- }), ge = (i) => ({
167
+ }), be = (i) => ({
168
168
  tag: [
169
169
  {
170
170
  tag: "span",
@@ -175,25 +175,25 @@ const se = function(i, e) {
175
175
  }
176
176
  }
177
177
  ]
178
- }), fe = () => ({
178
+ }), ke = () => ({
179
179
  tag: "b"
180
- }), me = () => ({
180
+ }), $e = () => ({
181
181
  tag: "s"
182
- }), ye = () => ({
182
+ }), ve = () => ({
183
183
  tag: "u"
184
- }), be = () => ({
184
+ }), Te = () => ({
185
185
  tag: "strong"
186
- }), ke = () => ({
186
+ }), we = () => ({
187
187
  tag: "code"
188
- }), ve = () => ({
188
+ }), Re = () => ({
189
189
  tag: "i"
190
- }), $e = (i) => {
190
+ }), Ee = (i) => {
191
191
  if (!i.attrs)
192
192
  return {
193
193
  tag: ""
194
194
  };
195
- const e = new A().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
196
- if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), re(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
195
+ const e = new L().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
196
+ if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), ae(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
197
197
  for (const r in t.custom)
198
198
  t[r] = t.custom[r];
199
199
  delete t.custom;
@@ -206,25 +206,25 @@ const se = function(i, e) {
206
206
  }
207
207
  ]
208
208
  };
209
- }, Te = (i) => ({
209
+ }, _e = (i) => ({
210
210
  tag: [
211
211
  {
212
212
  tag: "span",
213
213
  attrs: i.attrs
214
214
  }
215
215
  ]
216
- }), we = () => ({
216
+ }), Se = () => ({
217
217
  tag: "sub"
218
- }), Re = () => ({
218
+ }), je = () => ({
219
219
  tag: "sup"
220
- }), _e = (i) => ({
220
+ }), Ie = (i) => ({
221
221
  tag: [
222
222
  {
223
223
  tag: "span",
224
224
  attrs: i.attrs
225
225
  }
226
226
  ]
227
- }), Se = (i) => {
227
+ }), Ae = (i) => {
228
228
  var e;
229
229
  return (e = i.attrs) != null && e.color ? {
230
230
  tag: [
@@ -238,7 +238,7 @@ const se = function(i, e) {
238
238
  } : {
239
239
  tag: ""
240
240
  };
241
- }, Ee = (i) => {
241
+ }, xe = (i) => {
242
242
  var e;
243
243
  return (e = i.attrs) != null && e.color ? {
244
244
  tag: [
@@ -252,36 +252,36 @@ const se = function(i, e) {
252
252
  } : {
253
253
  tag: ""
254
254
  };
255
- }, je = {
255
+ }, Oe = {
256
256
  nodes: {
257
- horizontal_rule: ie,
258
- blockquote: oe,
259
- bullet_list: ne,
260
- code_block: ae,
261
- hard_break: le,
262
- heading: ce,
263
- image: he,
264
- list_item: ue,
265
- ordered_list: de,
266
- paragraph: pe,
267
- emoji: ge
257
+ horizontal_rule: le,
258
+ blockquote: ce,
259
+ bullet_list: he,
260
+ code_block: ue,
261
+ hard_break: de,
262
+ heading: pe,
263
+ image: ge,
264
+ list_item: fe,
265
+ ordered_list: me,
266
+ paragraph: ye,
267
+ emoji: be
268
268
  },
269
269
  marks: {
270
- bold: fe,
271
- strike: me,
272
- underline: ye,
273
- strong: be,
274
- code: ke,
275
- italic: ve,
276
- link: $e,
277
- styled: Te,
278
- subscript: we,
279
- superscript: Re,
280
- anchor: _e,
281
- highlight: Se,
282
- textStyle: Ee
283
- }
284
- }, Ie = function(i) {
270
+ bold: ke,
271
+ strike: $e,
272
+ underline: ve,
273
+ strong: Te,
274
+ code: we,
275
+ italic: Re,
276
+ link: Ee,
277
+ styled: _e,
278
+ subscript: Se,
279
+ superscript: je,
280
+ anchor: Ie,
281
+ highlight: Ae,
282
+ textStyle: xe
283
+ }
284
+ }, Le = function(i) {
285
285
  const e = {
286
286
  "&": "&amp;",
287
287
  "<": "&lt;",
@@ -292,9 +292,9 @@ const se = function(i, e) {
292
292
  return i && s.test(i) ? i.replace(t, (r) => e[r]) : i;
293
293
  };
294
294
  let z = !1;
295
- class L {
295
+ class C {
296
296
  constructor(e) {
297
- p(this, "marks"), p(this, "nodes"), e || (e = je), this.marks = e.marks || [], this.nodes = e.nodes || [];
297
+ g(this, "marks"), g(this, "nodes"), e || (e = Oe), this.marks = e.marks || [], this.nodes = e.nodes || [];
298
298
  }
299
299
  addNode(e, t) {
300
300
  this.nodes[e] = t;
@@ -346,25 +346,25 @@ class L {
346
346
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
347
347
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
348
348
  ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
349
- var c, u;
350
- const d = a.match(
349
+ var h, u;
350
+ const p = a.match(
351
351
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
352
352
  );
353
- if (d && d.length > 0) {
354
- const m = {
355
- srcset: (c = t.srcset) == null ? void 0 : c.map((b) => {
356
- if (typeof b == "number")
357
- return `//${d}/m/${b}x0${n} ${b}w`;
358
- if (typeof b == "object" && b.length === 2) {
353
+ if (p && p.length > 0) {
354
+ const y = {
355
+ srcset: (h = t.srcset) == null ? void 0 : h.map((T) => {
356
+ if (typeof T == "number")
357
+ return `//${p}/m/${T}x0${n} ${T}w`;
358
+ if (typeof T == "object" && T.length === 2) {
359
359
  let _ = 0, j = 0;
360
- return typeof b[0] == "number" && (_ = b[0]), typeof b[1] == "number" && (j = b[1]), `//${d}/m/${_}x${j}${n} ${_}w`;
360
+ return typeof T[0] == "number" && (_ = T[0]), typeof T[1] == "number" && (j = T[1]), `//${p}/m/${_}x${j}${n} ${_}w`;
361
361
  }
362
362
  return "";
363
363
  }).join(", "),
364
- sizes: (u = t.sizes) == null ? void 0 : u.map((b) => b).join(", ")
364
+ sizes: (u = t.sizes) == null ? void 0 : u.map((T) => T).join(", ")
365
365
  };
366
- let y = "";
367
- return m.srcset && (y += `srcset="${m.srcset}" `), m.sizes && (y += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${y.trim()}`);
366
+ let k = "";
367
+ return y.srcset && (k += `srcset="${y.srcset}" `), y.sizes && (k += `sizes="${y.sizes}" `), a.replace(/<img/g, `<img ${k.trim()}`);
368
368
  }
369
369
  return a;
370
370
  })), e;
@@ -378,7 +378,7 @@ class L {
378
378
  const s = this.getMatchingNode(e);
379
379
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
380
380
  t.push(this.renderNode(r));
381
- }) : e.text ? t.push(Ie(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
381
+ }) : e.text ? t.push(Le(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
382
382
  const o = this.getMatchingMark(r);
383
383
  o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
384
384
  }), t.join("");
@@ -433,9 +433,9 @@ class L {
433
433
  return this.renderTag(t, " /");
434
434
  }
435
435
  }
436
- class xe {
436
+ class Ce {
437
437
  constructor(e) {
438
- p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(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 = {};
438
+ g(this, "baseURL"), g(this, "timeout"), g(this, "headers"), g(this, "responseInterceptor"), g(this, "fetch"), g(this, "ejectInterceptor"), g(this, "url"), g(this, "parameters"), g(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 = {};
439
439
  }
440
440
  /**
441
441
  *
@@ -472,7 +472,7 @@ class xe {
472
472
  async _methodHandler(e) {
473
473
  let t = `${this.baseURL}${this.url}`, s = null;
474
474
  if (e === "get") {
475
- const a = new A();
475
+ const a = new L();
476
476
  t = `${this.baseURL}${this.url}?${a.stringify(
477
477
  this.parameters
478
478
  )}`;
@@ -490,10 +490,10 @@ class xe {
490
490
  ...this.fetchOptions
491
491
  });
492
492
  this.timeout && clearTimeout(l);
493
- const c = await this._responseHandler(
493
+ const h = await this._responseHandler(
494
494
  a
495
495
  );
496
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
496
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
497
497
  } catch (a) {
498
498
  return {
499
499
  message: a
@@ -520,39 +520,39 @@ class xe {
520
520
  });
521
521
  }
522
522
  }
523
- const D = "SB-Agent", P = {
523
+ const D = "SB-Agent", N = {
524
524
  defaultAgentName: "SB-JS-CLIENT",
525
525
  defaultAgentVersion: "SB-Agent-Version",
526
526
  packageVersion: "6.0.0"
527
527
  };
528
- let O = {};
528
+ let x = {};
529
529
  const S = {};
530
- class Oe {
530
+ class Pe {
531
531
  /**
532
532
  *
533
533
  * @param config ISbConfig interface
534
534
  * @param pEndpoint string, optional
535
535
  */
536
536
  constructor(e, t) {
537
- p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
537
+ g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "helpers"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache");
538
538
  let s = e.endpoint || t;
539
539
  if (!s) {
540
- const n = new A().getRegionURL, l = e.https === !1 ? "http" : "https";
540
+ const n = new L().getRegionURL, l = e.https === !1 ? "http" : "https";
541
541
  e.oauthToken ? s = `${l}://${n(e.region)}/v1` : s = `${l}://${n(e.region)}/v2`;
542
542
  }
543
543
  const r = new Headers();
544
544
  r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, l]) => {
545
545
  r.set(n, l);
546
- }), r.has(D) || (r.set(D, P.defaultAgentName), r.set(
547
- P.defaultAgentVersion,
548
- P.packageVersion
546
+ }), r.has(D) || (r.set(D, N.defaultAgentName), r.set(
547
+ N.defaultAgentVersion,
548
+ N.packageVersion
549
549
  ));
550
550
  let o = 5;
551
- e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = te(
551
+ e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new C(e.richTextSchema) : this.richTextResolver = new C(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = oe(
552
552
  this.throttledRequest.bind(this),
553
553
  o,
554
554
  1e3
555
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new xe({
555
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new L(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ce({
556
556
  baseURL: s,
557
557
  timeout: e.timeout || 0,
558
558
  headers: r,
@@ -589,17 +589,17 @@ class Oe {
589
589
  return this.cacheResponse(r, o, void 0, s);
590
590
  }
591
591
  async getAll(e, t, s, r) {
592
- const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1), a = 1, c = await this.makeRequest(
592
+ const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
593
593
  n,
594
594
  t,
595
595
  o,
596
596
  a,
597
597
  r
598
- ), u = c.total ? Math.ceil(c.total / o) : 1, d = await this.helpers.asyncMap(
598
+ ), u = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
599
599
  this.helpers.range(a, u),
600
- (m) => this.makeRequest(n, t, o, m + 1, r)
600
+ (y) => this.makeRequest(n, t, o, y + 1, r)
601
601
  );
602
- return this.helpers.flatMap([c, ...d], (m) => Object.values(m.data[l]));
602
+ return this.helpers.flatMap([h, ...p], (y) => Object.values(y.data[l]));
603
603
  }
604
604
  post(e, t, s) {
605
605
  const r = `/${e}`;
@@ -717,8 +717,8 @@ class Oe {
717
717
  if (e.link_uuids) {
718
718
  const o = e.link_uuids.length, n = [], l = 50;
719
719
  for (let a = 0; a < o; a += l) {
720
- const c = Math.min(o, a + l);
721
- n.push(e.link_uuids.slice(a, c));
720
+ const h = Math.min(o, a + l);
721
+ n.push(e.link_uuids.slice(a, h));
722
722
  }
723
723
  for (let a = 0; a < n.length; a++)
724
724
  (await this.getStories({
@@ -728,8 +728,8 @@ class Oe {
728
728
  starts_with: t.starts_with,
729
729
  by_uuids: n[a].join(",")
730
730
  })).data.stories.forEach(
731
- (c) => {
732
- r.push(c);
731
+ (h) => {
732
+ r.push(h);
733
733
  }
734
734
  );
735
735
  } else
@@ -746,8 +746,8 @@ class Oe {
746
746
  if (e.rel_uuids) {
747
747
  const o = e.rel_uuids.length, n = [], l = 50;
748
748
  for (let a = 0; a < o; a += l) {
749
- const c = Math.min(o, a + l);
750
- n.push(e.rel_uuids.slice(a, c));
749
+ const h = Math.min(o, a + l);
750
+ n.push(e.rel_uuids.slice(a, h));
751
751
  }
752
752
  for (let a = 0; a < n.length; a++)
753
753
  (await this.getStories({
@@ -757,8 +757,8 @@ class Oe {
757
757
  starts_with: t.starts_with,
758
758
  by_uuids: n[a].join(","),
759
759
  excluding_fields: t.excluding_fields
760
- })).data.stories.forEach((c) => {
761
- r.push(c);
760
+ })).data.stories.forEach((h) => {
761
+ r.push(h);
762
762
  });
763
763
  } else
764
764
  r = e.rels;
@@ -800,7 +800,7 @@ class Oe {
800
800
  return Promise.resolve(l);
801
801
  }
802
802
  return new Promise(async (l, a) => {
803
- var c;
803
+ var h;
804
804
  try {
805
805
  const u = await this.throttle(
806
806
  "get",
@@ -810,17 +810,17 @@ class Oe {
810
810
  );
811
811
  if (u.status !== 200)
812
812
  return a(u);
813
- let d = { data: u.data, headers: u.headers };
814
- if ((c = u.headers) != null && c["per-page"] && (d = Object.assign({}, d, {
813
+ let p = { data: u.data, headers: u.headers };
814
+ if ((h = u.headers) != null && h["per-page"] && (p = Object.assign({}, p, {
815
815
  perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
816
816
  total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
817
- })), d.data.story || d.data.stories) {
818
- const y = this.resolveCounter = ++this.resolveCounter % 1e3;
819
- await this.resolveStories(d.data, t, `${y}`);
817
+ })), p.data.story || p.data.stories) {
818
+ const k = this.resolveCounter = ++this.resolveCounter % 1e3;
819
+ await this.resolveStories(p.data, t, `${k}`);
820
820
  }
821
- t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, d);
822
- const m = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
823
- return t.token && d.data.cv && (m && S[t.token] && S[t.token] !== d.data.cv && await this.flushCache(), S[t.token] = d.data.cv), l(d);
821
+ t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, p);
822
+ const y = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
823
+ return t.token && p.data.cv && (y && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
824
824
  } catch (u) {
825
825
  if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
826
826
  return console.log(
@@ -850,16 +850,16 @@ class Oe {
850
850
  case "memory":
851
851
  return {
852
852
  get(e) {
853
- return Promise.resolve(O[e]);
853
+ return Promise.resolve(x[e]);
854
854
  },
855
855
  getAll() {
856
- return Promise.resolve(O);
856
+ return Promise.resolve(x);
857
857
  },
858
858
  set(e, t) {
859
- return O[e] = t, Promise.resolve(void 0);
859
+ return x[e] = t, Promise.resolve(void 0);
860
860
  },
861
861
  flush() {
862
- return O = {}, Promise.resolve(void 0);
862
+ return x = {}, Promise.resolve(void 0);
863
863
  }
864
864
  };
865
865
  case "custom":
@@ -887,7 +887,7 @@ class Oe {
887
887
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
888
888
  }
889
889
  }
890
- const Ue = (i = {}) => {
890
+ const De = (i = {}) => {
891
891
  const { apiOptions: e } = i;
892
892
  if (!e || !e.accessToken) {
893
893
  console.error(
@@ -895,8 +895,8 @@ const Ue = (i = {}) => {
895
895
  );
896
896
  return;
897
897
  }
898
- return { storyblokApi: new Oe(e) };
899
- }, ze = (i) => {
898
+ return { storyblokApi: new Pe(e) };
899
+ }, qe = (i) => {
900
900
  if (typeof i != "object" || typeof i._editable > "u")
901
901
  return {};
902
902
  try {
@@ -911,25 +911,25 @@ const Ue = (i = {}) => {
911
911
  return {};
912
912
  }
913
913
  };
914
- function Ae(i, e) {
914
+ function Ne(i, e) {
915
915
  if (!e)
916
916
  return { src: i, attrs: {} };
917
917
  let t = 0, s = 0;
918
918
  const r = {}, o = [];
919
- function n(a, c, u, d, m) {
920
- typeof a != "number" || a <= c || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${c} and ${u} (inclusive)`) : m.push(`${d}(${a})`);
919
+ function n(a, h, u, p, y) {
920
+ typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : y.push(`${p}(${a})`);
921
921
  }
922
922
  if (typeof e == "object") {
923
923
  if (typeof e.width == "number" && e.width > 0 ? (r.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (r.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (r.loading = e.loading), e.class && (r.class = e.class), e.filters) {
924
- const { filters: a } = e || {}, { blur: c, brightness: u, fill: d, format: m, grayscale: y, quality: b, rotate: _ } = a || {};
925
- c && n(c, 0, 100, "blur", o), b && n(b, 0, 100, "quality", o), u && n(u, 0, 100, "brightness", o), d && o.push(`fill(${d})`), y && o.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${_})`), m && ["webp", "png", "jpeg"].includes(m) && o.push(`format(${m})`);
924
+ const { filters: a } = e || {}, { blur: h, brightness: u, fill: p, format: y, grayscale: k, quality: T, rotate: _ } = a || {};
925
+ h && n(h, 0, 100, "blur", o), T && n(T, 0, 100, "quality", o), u && n(u, 0, 100, "brightness", o), p && o.push(`fill(${p})`), k && o.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${_})`), y && ["webp", "png", "jpeg"].includes(y) && o.push(`format(${y})`);
926
926
  }
927
927
  e.srcset && (r.srcset = e.srcset.map((a) => {
928
928
  if (typeof a == "number")
929
929
  return `${i}/m/${a}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${a}w`;
930
930
  if (Array.isArray(a) && a.length === 2) {
931
- const [c, u] = a;
932
- return `${i}/m/${c}x${u}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${c}w`;
931
+ const [h, u] = a;
932
+ return `${i}/m/${h}x${u}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
933
933
  } else {
934
934
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
935
935
  return;
@@ -942,8 +942,8 @@ function Ae(i, e) {
942
942
  attrs: r
943
943
  };
944
944
  }
945
- var $ = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i))($ || {}), T = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(T || {}), G = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(G || {}), I = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(I || {});
946
- const Le = [
945
+ var v = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))(v || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), G = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(G || {}), I = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(I || {});
946
+ const He = [
947
947
  "area",
948
948
  "base",
949
949
  "br",
@@ -958,167 +958,191 @@ const Le = [
958
958
  "source",
959
959
  "track",
960
960
  "wbr"
961
- ], Ce = (i = {}) => Object.keys(i).map((e) => `${e}="${i[e]}"`).join(" "), Pe = (i = {}) => Object.keys(i).map((e) => `${e}: ${i[e]}`).join("; ");
962
- function Ne(i) {
961
+ ], Me = (i = {}) => Object.keys(i).map((e) => `${e}="${i[e]}"`).join(" "), Be = (i = {}) => Object.keys(i).map((e) => `${e}: ${i[e]}`).join("; ");
962
+ function Ue(i) {
963
963
  return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
964
964
  }
965
- const B = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
965
+ const O = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
966
966
  function q(i, e = {}, t) {
967
- const s = Ce(e), r = s ? `${i} ${s}` : i, o = Array.isArray(t) ? t.join("") : t || "";
967
+ const s = Me(e), r = s ? `${i} ${s}` : i, o = Array.isArray(t) ? t.join("") : t || "";
968
968
  if (i) {
969
- if (Le.includes(i))
969
+ if (He.includes(i))
970
970
  return `<${r}>`;
971
971
  } else return o;
972
972
  return `<${r}>${o}</${i}>`;
973
973
  }
974
- function De(i = {}) {
974
+ function Fe(i = {}) {
975
975
  let e = 0;
976
976
  const {
977
977
  renderFn: t = q,
978
- textFn: s = Ne,
978
+ textFn: s = Ue,
979
979
  resolvers: r = {},
980
980
  optimizeImages: o = !1,
981
981
  keyedResolvers: n = !1
982
- } = i, l = t !== q, a = (h) => (g) => {
983
- const f = g.attrs || {};
984
- return n && (f.key = `${h}-${e}`), t(h, f, g.children || null);
985
- }, c = (h) => {
986
- const { src: g, alt: f, title: k, srcset: R, sizes: v } = h.attrs || {};
987
- let w = g, E = {};
982
+ } = i, l = t !== q, a = (c) => (d) => {
983
+ const f = d.attrs || {};
984
+ return n && (f.key = `${c}-${e}`), t(c, f, d.children || null);
985
+ }, h = (c) => {
986
+ const { src: d, alt: f, title: b, srcset: R, sizes: $ } = c.attrs || {};
987
+ let m = d, w = {};
988
988
  if (o) {
989
- const { src: W, attrs: X } = Ae(g, o);
990
- w = W, E = X;
989
+ const { src: ee, attrs: te } = Ne(d, o);
990
+ m = ee, w = te;
991
991
  }
992
- n && (E = {
993
- ...E,
992
+ n && (w = {
993
+ ...w,
994
994
  key: `img-${e}`
995
995
  });
996
- const Y = {
997
- src: w,
996
+ const Z = {
997
+ src: m,
998
998
  alt: f,
999
- title: k,
999
+ title: b,
1000
1000
  srcset: R,
1001
- sizes: v,
1002
- ...E
1001
+ sizes: $,
1002
+ ...w
1003
1003
  };
1004
- return t("img", B(Y));
1005
- }, u = (h) => {
1006
- const { level: g, ...f } = h.attrs || {}, k = {
1004
+ return t("img", O(Z));
1005
+ }, u = (c) => {
1006
+ const { level: d, ...f } = c.attrs || {}, b = {
1007
1007
  ...f
1008
1008
  };
1009
- return n && (k.key = `h${g}-${e}`), t(`h${g}`, k, h.children);
1010
- }, d = (h) => {
1011
- var g, f, k, R;
1012
- const v = t("img", {
1013
- src: (g = h.attrs) == null ? void 0 : g.fallbackImage,
1014
- alt: (f = h.attrs) == null ? void 0 : f.alt,
1009
+ return n && (b.key = `h${d}-${e}`), t(`h${d}`, b, c.children);
1010
+ }, p = (c) => {
1011
+ var d, f, b, R;
1012
+ const $ = t("img", {
1013
+ src: (d = c.attrs) == null ? void 0 : d.fallbackImage,
1014
+ alt: (f = c.attrs) == null ? void 0 : f.alt,
1015
1015
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
1016
1016
  draggable: "false",
1017
1017
  loading: "lazy"
1018
- }), w = {
1018
+ }), m = {
1019
1019
  "data-type": "emoji",
1020
- "data-name": (k = h.attrs) == null ? void 0 : k.name,
1021
- "data-emoji": (R = h.attrs) == null ? void 0 : R.emoji
1020
+ "data-name": (b = c.attrs) == null ? void 0 : b.name,
1021
+ "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1022
1022
  };
1023
- return n && (w.key = `emoji-${e}`), t("span", w, v);
1024
- }, m = (h) => t("pre", {
1025
- ...h.attrs,
1023
+ return n && (m.key = `emoji-${e}`), t("span", m, $);
1024
+ }, y = (c) => t("pre", {
1025
+ ...c.attrs,
1026
1026
  key: `code-${e}`
1027
- }, t("code", { key: `code-${e}` }, h.children || "")), y = (h, g = !1) => ({ text: f, attrs: k }) => {
1028
- const { class: R, id: v, ...w } = k || {}, E = g ? {
1027
+ }, t("code", { key: `code-${e}` }, c.children || "")), k = (c, d = !1) => ({ text: f, attrs: b }) => {
1028
+ const { class: R, id: $, ...m } = b || {}, w = d ? {
1029
1029
  class: R,
1030
- id: v,
1031
- style: Pe(w) || void 0
1032
- } : k || {};
1033
- return n && (E.key = `${h}-${e}`), t(h, B(E), f);
1034
- }, b = (h) => C(h), _ = (h) => {
1035
- const { marks: g, ...f } = h;
1036
- return "text" in h ? g ? g.reduce(
1037
- (k, R) => b({ ...R, text: k }),
1030
+ id: $,
1031
+ style: Be(m) || void 0
1032
+ } : b || {};
1033
+ return n && (w.key = `${c}-${e}`), t(c, O(w), f);
1034
+ }, T = (c) => P(c), _ = (c) => {
1035
+ const { marks: d, ...f } = c;
1036
+ return "text" in c ? d ? d.reduce(
1037
+ (b, R) => T({ ...R, text: b }),
1038
1038
  // Fix: Ensure render function returns a string
1039
- b({ ...f, children: f.children })
1039
+ T({ ...f, children: f.children })
1040
1040
  // Fix: Cast children to string
1041
1041
  ) : s(f.text) : "";
1042
- }, j = (h) => {
1043
- const { linktype: g, href: f, anchor: k, ...R } = h.attrs || {};
1044
- let v = "";
1045
- switch (g) {
1042
+ }, j = (c) => {
1043
+ const { linktype: d, href: f, anchor: b, ...R } = c.attrs || {};
1044
+ let $ = "";
1045
+ switch (d) {
1046
1046
  case I.ASSET:
1047
1047
  case I.URL:
1048
- v = f;
1048
+ $ = f;
1049
1049
  break;
1050
1050
  case I.EMAIL:
1051
- v = `mailto:${f}`;
1051
+ $ = `mailto:${f}`;
1052
1052
  break;
1053
1053
  case I.STORY:
1054
- v = f, k && (v = `${v}#${k}`);
1054
+ $ = f, b && ($ = `${$}#${b}`);
1055
1055
  break;
1056
1056
  default:
1057
- v = f;
1057
+ $ = f;
1058
1058
  break;
1059
1059
  }
1060
- const w = { ...R };
1061
- return v && (w.href = v), n && (w.key = `a-${e}`), t("a", w, h.text);
1062
- }, J = (h) => {
1063
- var g, f;
1060
+ const m = { ...R };
1061
+ return $ && (m.href = $), n && (m.key = `a-${e}`), t("a", m, c.text);
1062
+ }, J = (c) => {
1063
+ var d, f;
1064
1064
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1065
- blok: (g = h == null ? void 0 : h.attrs) == null ? void 0 : g.body[0],
1066
- id: (f = h.attrs) == null ? void 0 : f.id,
1065
+ blok: (d = c == null ? void 0 : c.attrs) == null ? void 0 : d.body[0],
1066
+ id: (f = c.attrs) == null ? void 0 : f.id,
1067
1067
  key: `component-${e}`,
1068
1068
  style: "display: none"
1069
1069
  });
1070
- }, K = new Map([
1071
- [$.DOCUMENT, a("")],
1072
- [$.HEADING, u],
1073
- [$.PARAGRAPH, a("p")],
1074
- [$.UL_LIST, a("ul")],
1075
- [$.OL_LIST, a("ol")],
1076
- [$.LIST_ITEM, a("li")],
1077
- [$.IMAGE, c],
1078
- [$.EMOJI, d],
1079
- [$.CODE_BLOCK, m],
1080
- [$.HR, a("hr")],
1081
- [$.BR, a("br")],
1082
- [$.QUOTE, a("blockquote")],
1083
- [$.COMPONENT, J],
1070
+ }, K = (c) => {
1071
+ const d = {};
1072
+ return n && (d.key = `table-${e}`), t("table", d, c.children);
1073
+ }, Y = (c) => {
1074
+ const d = {};
1075
+ return n && (d.key = `tr-${e}`), t("tr", d, c.children);
1076
+ }, W = (c) => {
1077
+ const { colspan: d, rowspan: f, colwidth: b, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1078
+ ...$
1079
+ };
1080
+ d > 1 && (m.colspan = d), f > 1 && (m.rowspan = f);
1081
+ const w = [];
1082
+ return b && w.push(`width: ${b}px;`), R && w.push(`background-color: ${R};`), w.length > 0 && (m.style = w.join(" ")), n && (m.key = `td-${e}`), t("td", O(m), c.children);
1083
+ }, X = (c) => {
1084
+ const { colspan: d, rowspan: f, colwidth: b, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1085
+ ...$
1086
+ };
1087
+ d > 1 && (m.colspan = d), f > 1 && (m.rowspan = f);
1088
+ const w = [];
1089
+ return b && w.push(`width: ${b}px;`), R && w.push(`background-color: ${R};`), w.length > 0 && (m.style = w.join(" ")), n && (m.key = `th-${e}`), t("th", O(m), c.children);
1090
+ }, Q = new Map([
1091
+ [v.DOCUMENT, a("")],
1092
+ [v.HEADING, u],
1093
+ [v.PARAGRAPH, a("p")],
1094
+ [v.UL_LIST, a("ul")],
1095
+ [v.OL_LIST, a("ol")],
1096
+ [v.LIST_ITEM, a("li")],
1097
+ [v.IMAGE, h],
1098
+ [v.EMOJI, p],
1099
+ [v.CODE_BLOCK, y],
1100
+ [v.HR, a("hr")],
1101
+ [v.BR, a("br")],
1102
+ [v.QUOTE, a("blockquote")],
1103
+ [v.COMPONENT, J],
1084
1104
  [G.TEXT, _],
1085
- [T.LINK, j],
1086
- [T.ANCHOR, j],
1087
- [T.STYLED, y("span", !0)],
1088
- [T.BOLD, y("strong")],
1089
- [T.TEXT_STYLE, y("span", !0)],
1090
- [T.ITALIC, y("em")],
1091
- [T.UNDERLINE, y("u")],
1092
- [T.STRIKE, y("s")],
1093
- [T.CODE, y("code")],
1094
- [T.SUPERSCRIPT, y("sup")],
1095
- [T.SUBSCRIPT, y("sub")],
1096
- [T.HIGHLIGHT, y("mark")],
1097
- ...Object.entries(r).map(([h, g]) => [h, g])
1105
+ [E.LINK, j],
1106
+ [E.ANCHOR, j],
1107
+ [E.STYLED, k("span", !0)],
1108
+ [E.BOLD, k("strong")],
1109
+ [E.TEXT_STYLE, k("span", !0)],
1110
+ [E.ITALIC, k("em")],
1111
+ [E.UNDERLINE, k("u")],
1112
+ [E.STRIKE, k("s")],
1113
+ [E.CODE, k("code")],
1114
+ [E.SUPERSCRIPT, k("sup")],
1115
+ [E.SUBSCRIPT, k("sub")],
1116
+ [E.HIGHLIGHT, k("mark")],
1117
+ [v.TABLE, K],
1118
+ [v.TABLE_ROW, Y],
1119
+ [v.TABLE_CELL, W],
1120
+ [v.TABLE_HEADER, X],
1121
+ ...Object.entries(r).map(([c, d]) => [c, d])
1098
1122
  ]);
1099
- function x(h) {
1123
+ function A(c) {
1100
1124
  e += 1;
1101
- const g = K.get(h.type);
1102
- if (!g)
1103
- return console.error("<Storyblok>", `No resolver found for node type ${h.type}`), "";
1104
- if (h.type === "text")
1105
- return g(h);
1106
- const f = h.content ? h.content.map(C) : void 0;
1107
- return g({
1108
- ...h,
1125
+ const d = Q.get(c.type);
1126
+ if (!d)
1127
+ return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1128
+ if (c.type === "text")
1129
+ return d(c);
1130
+ const f = c.content ? c.content.map(P) : void 0;
1131
+ return d({
1132
+ ...c,
1109
1133
  children: f
1110
1134
  // Fix: Update the type of 'children' to Node[]
1111
1135
  });
1112
1136
  }
1113
- function C(h) {
1114
- return h.type === "doc" ? l ? h.content.map(x) : h.content.map(x).join("") : Array.isArray(h) ? h.map(x) : x(h);
1137
+ function P(c) {
1138
+ return c.type === "doc" ? l ? c.content.map(A) : c.content.map(A).join("") : Array.isArray(c) ? c.map(A) : A(c);
1115
1139
  }
1116
1140
  return {
1117
- render: C
1141
+ render: P
1118
1142
  };
1119
1143
  }
1120
- let N, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1121
- const Be = (i, e, t = {}) => {
1144
+ let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1145
+ const Ge = (i, e, t = {}) => {
1122
1146
  var l;
1123
1147
  const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((l = window.location) == null ? void 0 : l.href).searchParams.get(
1124
1148
  "_storyblok"
@@ -1129,9 +1153,9 @@ const Be = (i, e, t = {}) => {
1129
1153
  return;
1130
1154
  }
1131
1155
  window.storyblokRegisterEvent(() => {
1132
- new window.StoryblokBridge(t).on(["input", "published", "change"], (c) => {
1156
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (h) => {
1133
1157
  var u;
1134
- c && (c.action === "input" && ((u = c.story) == null ? void 0 : u.id) === i ? e(c.story) : (c.action === "change" || c.action === "published") && c.storyId === i && window.location.reload());
1158
+ h && (h.action === "input" && ((u = h.story) == null ? void 0 : u.id) === i ? e(h.story) : (h.action === "change" || h.action === "published") && h.storyId === i && window.location.reload());
1135
1159
  });
1136
1160
  });
1137
1161
  }
@@ -1144,8 +1168,8 @@ const Be = (i, e, t = {}) => {
1144
1168
  html: s
1145
1169
  };
1146
1170
  });
1147
- }, qe = (i = {}) => {
1148
- var d, m;
1171
+ }, Ve = (i = {}) => {
1172
+ var p, y;
1149
1173
  const {
1150
1174
  bridge: e,
1151
1175
  accessToken: t,
@@ -1157,37 +1181,37 @@ const Be = (i, e, t = {}) => {
1157
1181
  r.accessToken = r.accessToken || t;
1158
1182
  const l = { bridge: e, apiOptions: r };
1159
1183
  let a = {};
1160
- s.forEach((y) => {
1161
- a = { ...a, ...y(l) };
1184
+ s.forEach((k) => {
1185
+ a = { ...a, ...k(l) };
1162
1186
  }), n && (M = n);
1163
- const u = !(typeof window > "u") && ((m = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : m.includes("_storyblok_tk"));
1164
- return e !== !1 && u && F(M), N = new L(o.schema), o.resolver && V(N, o.resolver), a;
1165
- }, Me = (i) => {
1187
+ const u = !(typeof window > "u") && ((y = (p = window.location) == null ? void 0 : p.search) == null ? void 0 : y.includes("_storyblok_tk"));
1188
+ return e !== !1 && u && F(M), H = new C(o.schema), o.resolver && V(H, o.resolver), a;
1189
+ }, ze = (i) => {
1166
1190
  var e;
1167
1191
  return !i || !((e = i == null ? void 0 : i.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1168
- }, Fe = (i, e, t) => {
1169
- let s = t || N;
1192
+ }, Je = (i, e, t) => {
1193
+ let s = t || H;
1170
1194
  if (!s) {
1171
1195
  console.error(
1172
1196
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1173
1197
  );
1174
1198
  return;
1175
1199
  }
1176
- return Me(i) ? "" : (e && (s = new L(e.schema), e.resolver && V(s, e.resolver)), s.render(i, {}, !1));
1177
- }, Ge = () => F(M);
1200
+ return ze(i) ? "" : (e && (s = new C(e.schema), e.resolver && V(s, e.resolver)), s.render(i, {}, !1));
1201
+ }, Ke = () => F(M);
1178
1202
  export {
1179
- $ as BlockTypes,
1180
- T as MarkTypes,
1181
- L as RichTextResolver,
1182
- je as RichTextSchema,
1203
+ v as BlockTypes,
1204
+ E as MarkTypes,
1205
+ C as RichTextResolver,
1206
+ Oe as RichTextSchema,
1183
1207
  G as TextTypes,
1184
- Ue as apiPlugin,
1185
- Me as isRichTextEmpty,
1186
- Ge as loadStoryblokBridge,
1187
- Be as registerStoryblokBridge,
1188
- Fe as renderRichText,
1189
- De as richTextResolver,
1190
- ze as storyblokEditable,
1191
- qe as storyblokInit,
1192
- Be as useStoryblokBridge
1208
+ De as apiPlugin,
1209
+ ze as isRichTextEmpty,
1210
+ Ke as loadStoryblokBridge,
1211
+ Ge as registerStoryblokBridge,
1212
+ Je as renderRichText,
1213
+ Fe as richTextResolver,
1214
+ qe as storyblokEditable,
1215
+ Ve as storyblokInit,
1216
+ Ge as useStoryblokBridge
1193
1217
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
3
  "type": "module",
4
- "version": "3.2.5",
4
+ "version": "3.3.0",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@10.2.0",
7
7
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
@@ -42,7 +42,7 @@
42
42
  "cy:open": "cypress open"
43
43
  },
44
44
  "dependencies": {
45
- "@storyblok/richtext": "3.0.2",
45
+ "@storyblok/richtext": "3.1.0",
46
46
  "storyblok-js-client": "6.10.10"
47
47
  },
48
48
  "devDependencies": {