@storyblok/js 4.4.3 → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * name: @storyblok/js
3
- * (c) 2025
3
+ * (c) 2026
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- (function(_,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(_=typeof globalThis<"u"?globalThis:_||self,g(_.storyblok={}))})(this,function(_){"use strict";var Be=Object.defineProperty;var De=(_,g,A)=>g in _?Be(_,g,{enumerable:!0,configurable:!0,writable:!0,value:A}):_[g]=A;var b=(_,g,A)=>De(_,typeof g!="symbol"?g+"":g,A);let g=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),A=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),N=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(e={})=>{const{custom:t,...s}=e,r={...s,...t};return Object.keys(r).map(i=>`${i}="${r[i]}"`).join(" ")},le=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ce(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function ue(e,t){if(!t)return{src:e,attrs:{}};let s=0,r=0;const i={},n=[];function l(u,c,m,p,v){typeof u!="number"||u<=c||u>=m?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${c} and ${m} (inclusive)`):v.push(`${p}(${u})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(i.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(i.height=t.height,r=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete i.width,delete i.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(i.loading=t.loading),t.class&&(i.class=t.class),t.filters){const{filters:u}=t||{},{blur:c,brightness:m,fill:p,format:v,grayscale:L,quality:k,rotate:C}=u||{};c&&l(c,0,100,"blur",n),k&&l(k,0,100,"quality",n),m&&l(m,0,100,"brightness",n),p&&n.push(`fill(${p})`),L&&n.push("grayscale()"),C&&[0,90,180,270].includes(t.filters.rotate||0)&&n.push(`rotate(${C})`),v&&["webp","png","jpeg"].includes(v)&&n.push(`format(${v})`)}t.srcset&&(i.srcset=t.srcset.map(u=>{if(typeof u=="number")return`${e}/m/${u}x0/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`;if(Array.isArray(u)&&u.length===2){const[c,m]=u;return`${e}/m/${c}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${c}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(i.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(s>0||r>0)&&(a=`${a}${s}x${r}/`),n.length>0&&(a=`${a}filters:${n.join(":")}`),{src:a,attrs:i}}function Y(e,t={},s){const r=ae(t),i=r?`${e} ${r}`:e,n=Array.isArray(s)?s.join(""):s||"";if(e){if(oe.includes(e))return`<${i}>`}else return n;return`<${i}>${n}</${e}>`}function J(e={}){const t=new Map,{renderFn:s=Y,textFn:r=ce,resolvers:i={},optimizeImages:n=!1,keyedResolvers:l=!1}=e,a=s!==Y,u=(o={})=>{const{textAlign:h,class:d,id:f,style:y,...E}=o,R=[];return y&&R.push(y.endsWith(";")?y:`${y};`),h&&R.push(`text-align: ${h};`),O({...E,class:d,id:f,...R.length>0?{style:R.join(" ")}:{}})},c=o=>(h,d)=>{const f=u(h.attrs);return d.render(o,f,h.children||null)},m=(o,h)=>{const{src:d,alt:f,title:y,srcset:E,sizes:R}=o.attrs||{};let w=d,S={};if(n){const{src:qe,attrs:Fe}=ue(d,n);w=qe,S=Fe}const P={src:w,alt:f,title:y,srcset:E,sizes:R,...S};return h.render("img",O(P))},p=(o,h)=>{const{level:d,...f}=o.attrs||{},y=u(f);return h.render(`h${d}`,y,o.children)},v=(o,h)=>{var f,y,E,R;const d=h.render("img",{src:(f=o.attrs)==null?void 0:f.fallbackImage,alt:(y=o.attrs)==null?void 0:y.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(E=o.attrs)==null?void 0:E.name,"data-emoji":(R=o.attrs)==null?void 0:R.emoji},d)},L=(o,h)=>h.render("pre",o.attrs||{},h.render("code",{},o.children||"")),k=(o,h=!1)=>({text:d,attrs:f},y)=>{const{class:E,id:R,...w}=f||{},S=h?{class:E,id:R,style:le(w)||void 0}:f||{};return y.render(o,O(S),d)},C=o=>z(o),D=o=>{const{marks:h,...d}=o;if("text"in o){if(h)return h.reduce((y,E)=>C({...E,text:y}),C({...d,children:d.children}));const f=o.attrs||{};if(l){const y=t.get("txt")||0;t.set("txt",y+1),f.key=`txt-${y}`}return r(d.text,f)}return""},se=(o,h)=>{const{linktype:d,href:f,anchor:y,...E}=o.attrs||{};let R="";switch(d){case N.ASSET:case N.URL:R=f;break;case N.EMAIL:R=`mailto:${f}`;break;case N.STORY:R=f,y&&(R=`${R}#${y}`);break;default:R=f;break}const w={...E};return R&&(w.href=R),h.render("a",w,o.text)},Me=(o,h)=>{var d,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=o==null?void 0:o.attrs)==null?void 0:d.body[0],id:(f=o.attrs)==null?void 0:f.id,style:"display: none"})},He=(o,h)=>{const d=u(o.attrs),f=o.children||null;return h.render("table",d,h.render("tbody",{},f))},Ue=(o,h)=>{const d=u(o.attrs);return h.render("tr",d,o.children)},$e=(o,h)=>{const{colspan:d,rowspan:f,colwidth:y,backgroundColor:E,textAlign:R,...w}=o.attrs||{},S=[];y&&S.push(`width: ${y}px;`),E&&S.push(`background-color: ${E};`),R&&S.push(`text-align: ${R};`);const P={...w,...d>1?{colspan:d}:{},...f>1?{rowspan:f}:{},...S.length>0?{style:S.join(" ")}:{}};return h.render("td",O(P),o.children)},je=(o,h)=>{const{colspan:d,rowspan:f,colwidth:y,backgroundColor:E,textAlign:R,...w}=o.attrs||{},S=[];y&&S.push(`width: ${y}px;`),E&&S.push(`background-color: ${E};`),R&&S.push(`text-align: ${R};`);const P={...w,...d>1?{colspan:d}:{},...f>1?{rowspan:f}:{},...S.length>0?{style:S.join(" ")}:{}};return h.render("th",O(P),o.children)},ie=new Map([[g.DOCUMENT,c("")],[g.HEADING,p],[g.PARAGRAPH,c("p")],[g.UL_LIST,c("ul")],[g.OL_LIST,c("ol")],[g.LIST_ITEM,c("li")],[g.IMAGE,m],[g.EMOJI,v],[g.CODE_BLOCK,L],[g.HR,c("hr")],[g.BR,c("br")],[g.QUOTE,c("blockquote")],[g.COMPONENT,Me],[V.TEXT,D],[A.LINK,se],[A.ANCHOR,se],[A.STYLED,k("span",!0)],[A.BOLD,k("strong")],[A.TEXT_STYLE,k("span",!0)],[A.ITALIC,k("em")],[A.UNDERLINE,k("u")],[A.STRIKE,k("s")],[A.CODE,k("code")],[A.SUPERSCRIPT,k("sup")],[A.SUBSCRIPT,k("sub")],[A.HIGHLIGHT,k("mark")],[g.TABLE,He],[g.TABLE_ROW,Ue],[g.TABLE_CELL,$e],[g.TABLE_HEADER,je]]),ne=new Map([...ie,...Object.entries(i).map(([o,h])=>[o,h])]),Ge=()=>({render:(d,f={},y)=>{if(l&&d){const E=t.get(d)||0;t.set(d,E+1),f.key=`${d}-${E}`}return s(d,f,y)},originalResolvers:ie,mergedResolvers:ne});function U(o){const h=ne.get(o.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const d=Ge();if(o.type==="text")return h(o,d);const f=o.content?o.content.map(z):void 0;return h({...o,children:f},d)}function z(o){return o.type==="doc"?a?o.content.map(U):o.content.map(U).join(""):Array.isArray(o)?o.map(U):U(o)}return{render:z}}let K=!1;const W=[],Q=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=i=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}K?i():W.push(i)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const r=document.createElement("script");r.async=!0,r.src=e,r.id="storyblok-javascript-bridge",r.onerror=i=>s(i),r.onload=i=>{W.forEach(n=>n()),K=!0,t(i)},document.getElementsByTagName("head")[0].appendChild(r)}),$=(e="")=>e.includes("/cdn/"),he=(e,t=25,s=1)=>({...e,per_page:t,page:s}),de=e=>new Promise(t=>setTimeout(t,e)),fe=(e=0,t)=>Array.from({length:e},t),ge=(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return fe(s,(i,n)=>n*r+e)},ye=async(e,t)=>Promise.all(e.map(t)),be=(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]),j=(e,t,s)=>{const r=[];for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const n=e[i];if(n==null)continue;const l=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=j(n,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(n)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(n)}`,r.push(a)}return r.join("&")},X=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var me=class{constructor(e){b(this,"baseURL");b(this,"timeout");b(this,"headers");b(this,"responseInterceptor");b(this,"fetch");b(this,"ejectInterceptor");b(this,"url");b(this,"parameters");b(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;e==="get"?t=`${this.baseURL}${this.url}?${j(this.parameters)}`:s=JSON.stringify(this.parameters);const r=new URL(t),i=new AbortController,{signal:n}=i;let l=null;this.timeout&&(l=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const u=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}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}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const i={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(i)})}},pe=me;const Z="SB-Agent",G={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ee={DRAFT:"draft",PUBLISHED:"published"},Re=25,q={SMALL:25,MEDIUM:50,LARGE:75},I={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},F=1e3,x=3;function ve(e){return e.version===ee.DRAFT}function _e(e,t){const s=e.includes("/cdn/stories/"),r=e.split("/").length>3&&!e.endsWith("/cdn/stories"),i="find_by"in t;return s&&r||i}function Ee(e){return e<=q.SMALL?I.SINGLE_OR_SMALL:e<=q.MEDIUM?I.MEDIUM:e<=q.LARGE?I.LARGE:I.VERY_LARGE}function M(e,t,s={},r){if(s.userRateLimit!==void 0)return Math.min(s.userRateLimit,F);if(s.serverHeadersRateLimit!==void 0)return Math.min(s.serverHeadersRateLimit,F);if(r!==void 0)return r;if(t&&!ve(t))return F;if(_e(e,t))return I.SINGLE_OR_SMALL;const i=t.per_page||Re;return Ee(i)}function Ae(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],s=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!s)return null;const r={};if(t){const i=t.match(/r=(\d+)/);i&&(r.remaining=Number.parseInt(i[1],10))}if(s){const i=s.match(/q=(\d+)/);i&&(r.max=Number.parseInt(i[1],10))}return Object.keys(r).length>0?r:null}function ke(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var Le=class extends Error{constructor(e){super(e),this.name="AbortError"}};function Se(e,t,s){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let i=[],n=0,l=!1;const a=async()=>{n++;const c=r.shift();if(c)try{const p=await e(...c.args);c.resolve(p)}catch(p){c.reject(p)}const m=setTimeout(()=>{n--,r.length>0&&a(),i=i.filter(p=>p!==m)},s);i.includes(m)||i.push(m)},u=(...c)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,p)=>{r.push({resolve:m,reject:p,args:c}),n<t&&a()});return u.abort=()=>{l=!0,i.forEach(clearTimeout),i=[],r.forEach(c=>c.reject(()=>new Le("Throttle function aborted"))),r.length=0},u}var we=Se,Te=class{constructor(e,t=1e3){b(this,"queues");b(this,"interval");b(this,"throttledRequestFn");this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=we(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let H={};const T={};var Ce=class{constructor(e,t){b(this,"client");b(this,"maxRetries");b(this,"retriesDelay");b(this,"throttleManager");b(this,"accessToken");b(this,"cache");b(this,"resolveCounter");b(this,"relations");b(this,"links");b(this,"version");b(this,"rateLimitConfig");b(this,"richTextResolver");b(this,"resolveNestedRelations");b(this,"stringifiedStoriesCache");b(this,"inlineAssets");let s=e.endpoint||t;if(!s){const i=e.https===!1?"http":"https";e.oauthToken?s=`${i}://${X(e.region)}/v1`:s=`${i}://${X(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(Z)||(r.set(Z,G.defaultAgentName),r.set(G.defaultAgentVersion,G.packageVersion)),e.oauthToken&&r.set("Authorization",e.oauthToken),this.rateLimitConfig=ke(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttleManager=new Te(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||ee.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new pe({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=T[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 $(e)?this.parseParams(t):t}makeRequest(e,t,s,r,i){const n=this.factoryParamOptions(e,he(t,s,r));return this.cacheResponse(e,n,void 0,i)}get(e,t={},s){t||(t={});const r=`/${e}`;$(r)&&(t.version=t.version||this.version);const i=this.factoryParamOptions(r,t);return this.cacheResponse(r,i,void 0,s)}async getAll(e,t={},s,r){const i=(t==null?void 0:t.per_page)||25,n=`/${e}`.replace(/\/$/,""),l=s??n.substring(n.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,u=await this.makeRequest(n,t,i,a,r),c=u.total?Math.ceil(u.total/(u.perPage||i)):1,m=await ye(ge(a,c),p=>this.makeRequest(n,t,i,p+1,r));return be([u,...m],p=>Object.values(p.data[l]))}post(e,t={},s){const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"post",r,t,s)}put(e,t={},s){const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"put",r,t,s)}delete(e,t={},s){t||(t={});const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"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(i=>this.getStoryReference(s,i)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(l=>l.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=(i,n="")=>{if(!(!i||i._stopResolving)){if(Array.isArray(i))i.forEach((l,a)=>r(l,`${n}[${a}]`));else if(typeof i=="object")for(const l in i){const a=n?`${n}.${l}`:l;(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,l,t,s),this._insertLinks(i,l,s)),r(i[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const i=e.link_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const u=Math.min(i,a+l);n.push(e.link_uuids.slice(a,u))}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(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const i=e.rel_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const u=Math.min(i,a+l);n.push(e.rel_uuids.slice(a,u))}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)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(e,t,s){var i,n;let r=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(r=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((i=e.links)!=null&&i.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],r,s);e.story?this.iterateTree(e.story,r,s):e.stories.forEach(l=>{this.iterateTree(l,r,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const i=j({url:e,params:t}),n=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await n.get(i);if(c)return Promise.resolve(c)}const a=!$(e)&&this.rateLimitConfig.isManagementApi?x:void 0,u=M(e,t,this.rateLimitConfig,a);return new Promise(async(c,m)=>{var p;try{const v=await this.throttleManager.execute(u,"get",e,t,r);if(v.status!==200)return m(v);let L={data:v.data,headers:v.headers};const k=Ae(v.headers);if((k==null?void 0:k.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=k.max),(p=v.headers)!=null&&p["per-page"]&&(L=Object.assign({},L,{perPage:v.headers["per-page"]?Number.parseInt(v.headers["per-page"]):0,total:v.headers["per-page"]?Number.parseInt(v.headers.total):0})),L.data.story||L.data.stories){const D=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(L.data,t,`${D}`),L=await this.processInlineAssets(L)}t.version==="published"&&e!=="/cdn/spaces/me"&&await n.set(i,L);const C=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&L.data.cv&&(C&&T[t.token]&&T[t.token]!==L.data.cv&&await this.flushCache(),T[t.token]=L.data.cv),c(L)}catch(v){if(v.response&&v.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 de(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(m);m(v)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return T}cacheVersion(){return T[this.accessToken]}setCacheVersion(e){this.accessToken&&(T[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(T[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(H[e])},getAll(){return Promise.resolve(H)},set(e,t){return H[e]=t,Promise.resolve(void 0)},flush(){return H={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=s=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(i=>t(i));let r={...s};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...e.data.assets.find(i=>i.id===r.id),...r});for(const i in r)typeof r[i]=="object"&&(r[i]=t(r[i]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(s=>(s.content=t(s.content),s))),e}},te=Ce;const Oe=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new te(t)}},Ie=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let B="https://app.storyblok.com/f/storyblok-v2-latest.js";const re=(e,t,s={})=>{var a;const i=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((a=window.location)==null?void 0:a.href).searchParams.get("_storyblok"),l=n!==null&&+n===e;if(!(!i||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],c=>{var m;c&&(c.action==="input"&&((m=c.story)==null?void 0:m.id)===e?t(c.story):(c.action==="change"||c.action==="published")&&c.storyId===e&&window.location.reload())})})}},Pe=(e={})=>{var m,p;const{bridge:t,accessToken:s,use:r=[],apiOptions:i={},bridgeUrl:n}=e;i.accessToken=i.accessToken||s;const l={bridge:t,apiOptions:i};let a={};r.forEach(v=>{a={...a,...v(l)}}),n&&(B=n);const c=!(typeof window>"u")&&((p=(m=window.location)==null?void 0:m.search)==null?void 0:p.includes("_storyblok_tk"));return t!==!1&&c&&Q(B),a};function Ne(e,t){return J(t).render(e)}const xe=()=>Q(B);_.BlockTypes=g,_.MarkTypes=A,_.StoryblokClient=te,_.TextTypes=V,_.apiPlugin=Oe,_.loadStoryblokBridge=xe,_.registerStoryblokBridge=re,_.renderRichText=Ne,_.richTextResolver=J,_.storyblokEditable=Ie,_.storyblokInit=Pe,_.useStoryblokBridge=re,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
7
+ (function(_,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(_=typeof globalThis<"u"?globalThis:_||self,g(_.storyblok={}))})(this,function(_){"use strict";var Be=Object.defineProperty;var De=(_,g,E)=>g in _?Be(_,g,{enumerable:!0,configurable:!0,writable:!0,value:E}):_[g]=E;var b=(_,g,E)=>De(_,typeof g!="symbol"?g+"":g,E);let g=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),E=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),N=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(e={})=>{const{custom:t,...s}=e,r={...s,...t};return Object.keys(r).map(i=>`${i}="${r[i]}"`).join(" ")},le=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ce(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=e=>Object.fromEntries(Object.entries(e).filter(([t,s])=>s!==void 0));function ue(e,t){if(!t)return{src:e,attrs:{}};let s=0,r=0;const i={},n=[];function l(u,c,m,p,v){typeof u!="number"||u<=c||u>=m?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${c} and ${m} (inclusive)`):v.push(`${p}(${u})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(i.width=t.width,s=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(i.height=t.height,r=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete i.width,delete i.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(i.loading=t.loading),t.class&&(i.class=t.class),t.filters){const{filters:u}=t||{},{blur:c,brightness:m,fill:p,format:v,grayscale:w,quality:k,rotate:C}=u||{};c&&l(c,0,100,"blur",n),k&&l(k,0,100,"quality",n),m&&l(m,0,100,"brightness",n),p&&n.push(`fill(${p})`),w&&n.push("grayscale()"),C&&[0,90,180,270].includes(t.filters.rotate||0)&&n.push(`rotate(${C})`),v&&["webp","png","jpeg"].includes(v)&&n.push(`format(${v})`)}t.srcset&&(i.srcset=t.srcset.map(u=>{if(typeof u=="number")return`${e}/m/${u}x0/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`;if(Array.isArray(u)&&u.length===2){const[c,m]=u;return`${e}/m/${c}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${c}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(i.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(s>0||r>0)&&(a=`${a}${s}x${r}/`),n.length>0&&(a=`${a}filters:${n.join(":")}`),{src:a,attrs:i}}function Y(e,t={},s){const r=ae(t),i=r?`${e} ${r}`:e,n=Array.isArray(s)?s.join(""):s||"";if(e){if(oe.includes(e))return`<${i}>`}else return n;return`<${i}>${n}</${e}>`}function J(e={}){const t=new Map,{renderFn:s=Y,textFn:r=ce,resolvers:i={},optimizeImages:n=!1,keyedResolvers:l=!1}=e,a=s!==Y,u=(o={})=>{const{textAlign:h,class:d,id:f,style:y,...A}=o,R=[];return y&&R.push(y.endsWith(";")?y:`${y};`),h&&R.push(`text-align: ${h};`),O({...A,class:d,id:f,...R.length>0?{style:R.join(" ")}:{}})},c=o=>(h,d)=>{const f=u(h.attrs);return d.render(o,f,h.children||null)},m=(o,h)=>{const{src:d,alt:f,title:y,srcset:A,sizes:R}=o.attrs||{};let L=d,S={};if(n){const{src:Ge,attrs:Fe}=ue(d,n);L=Ge,S=Fe}const P={src:L,alt:f,title:y,srcset:A,sizes:R,...S};return h.render("img",O(P))},p=(o,h)=>{const{level:d,...f}=o.attrs||{},y=u(f);return h.render(`h${d}`,y,o.children)},v=(o,h)=>{var f,y,A,R;const d=h.render("img",{src:(f=o.attrs)==null?void 0:f.fallbackImage,alt:(y=o.attrs)==null?void 0:y.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(A=o.attrs)==null?void 0:A.name,"data-emoji":(R=o.attrs)==null?void 0:R.emoji},d)},w=(o,h)=>h.render("pre",o.attrs||{},h.render("code",{},o.children||"")),k=(o,h=!1)=>({text:d,attrs:f},y)=>{const{class:A,id:R,...L}=f||{},S=h?{class:A,id:R,style:le(L)||void 0}:f||{};return y.render(o,O(S),d)},C=o=>z(o),D=o=>{const{marks:h,...d}=o;if("text"in o){if(h)return h.reduce((y,A)=>C({...A,text:y}),C({...d,children:d.children}));const f=o.attrs||{};if(l){const y=t.get("txt")||0;t.set("txt",y+1),f.key=`txt-${y}`}return r(d.text,f)}return""},se=(o,h)=>{const{linktype:d,href:f,anchor:y,...A}=o.attrs||{};let R="";switch(d){case N.ASSET:case N.URL:R=f;break;case N.EMAIL:R=`mailto:${f}`;break;case N.STORY:R=f,y&&(R=`${R}#${y}`);break;default:R=f;break}const L={...A};return R&&(L.href=R),h.render("a",L,o.text)},Me=(o,h)=>{var d,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=o==null?void 0:o.attrs)==null?void 0:d.body[0],id:(f=o.attrs)==null?void 0:f.id,style:"display: none"})},He=(o,h)=>{const d=u(o.attrs),f=o.children||null;return h.render("table",d,h.render("tbody",{},f))},$e=(o,h)=>{const d=u(o.attrs);return h.render("tr",d,o.children)},Ue=(o,h)=>{const{colspan:d,rowspan:f,colwidth:y,backgroundColor:A,textAlign:R,...L}=o.attrs||{},S=[];y&&S.push(`width: ${y}px;`),A&&S.push(`background-color: ${A};`),R&&S.push(`text-align: ${R};`);const P={...L,...d>1?{colspan:d}:{},...f>1?{rowspan:f}:{},...S.length>0?{style:S.join(" ")}:{}};return h.render("td",O(P),o.children)},je=(o,h)=>{const{colspan:d,rowspan:f,colwidth:y,backgroundColor:A,textAlign:R,...L}=o.attrs||{},S=[];y&&S.push(`width: ${y}px;`),A&&S.push(`background-color: ${A};`),R&&S.push(`text-align: ${R};`);const P={...L,...d>1?{colspan:d}:{},...f>1?{rowspan:f}:{},...S.length>0?{style:S.join(" ")}:{}};return h.render("th",O(P),o.children)},ie=new Map([[g.DOCUMENT,c("")],[g.HEADING,p],[g.PARAGRAPH,c("p")],[g.UL_LIST,c("ul")],[g.OL_LIST,c("ol")],[g.LIST_ITEM,c("li")],[g.IMAGE,m],[g.EMOJI,v],[g.CODE_BLOCK,w],[g.HR,c("hr")],[g.BR,c("br")],[g.QUOTE,c("blockquote")],[g.COMPONENT,Me],[V.TEXT,D],[E.LINK,se],[E.ANCHOR,se],[E.STYLED,k("span",!0)],[E.BOLD,k("strong")],[E.TEXT_STYLE,k("span",!0)],[E.ITALIC,k("em")],[E.UNDERLINE,k("u")],[E.STRIKE,k("s")],[E.CODE,k("code")],[E.SUPERSCRIPT,k("sup")],[E.SUBSCRIPT,k("sub")],[E.HIGHLIGHT,k("mark")],[g.TABLE,He],[g.TABLE_ROW,$e],[g.TABLE_CELL,Ue],[g.TABLE_HEADER,je]]),ne=new Map([...ie,...Object.entries(i).map(([o,h])=>[o,h])]),qe=()=>({render:(d,f={},y)=>{if(l&&d){const A=t.get(d)||0;t.set(d,A+1),f.key=`${d}-${A}`}return s(d,f,y)},originalResolvers:ie,mergedResolvers:ne});function $(o){const h=ne.get(o.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const d=qe();if(o.type==="text")return h(o,d);const f=o.content?o.content.map(z):void 0;return h({...o,children:f},d)}function z(o){return o.type==="doc"?a?o.content.map($):o.content.map($).join(""):Array.isArray(o)?o.map($):$(o)}return{render:z}}let K=!1;const W=[],Q=e=>new Promise((t,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=i=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}K?i():W.push(i)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const r=document.createElement("script");r.async=!0,r.src=e,r.id="storyblok-javascript-bridge",r.onerror=i=>s(i),r.onload=i=>{W.forEach(n=>n()),K=!0,t(i)},document.getElementsByTagName("head")[0].appendChild(r)}),U=(e="")=>e.includes("/cdn/"),he=(e,t=25,s=1)=>({...e,per_page:t,page:s}),de=e=>new Promise(t=>setTimeout(t,e)),fe=(e=0,t)=>Array.from({length:e},t),ge=(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return fe(s,(i,n)=>n*r+e)},ye=async(e,t)=>Promise.all(e.map(t)),be=(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]),j=(e,t,s)=>{const r=[];for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const n=e[i];if(n==null)continue;const l=s?"":encodeURIComponent(i);let a;typeof n=="object"?a=j(n,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(n)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(n)}`,r.push(a)}return r.join("&")},X=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var me=class{constructor(e){b(this,"baseURL");b(this,"timeout");b(this,"headers");b(this,"responseInterceptor");b(this,"fetch");b(this,"ejectInterceptor");b(this,"url");b(this,"parameters");b(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;e==="get"?t=`${this.baseURL}${this.url}?${j(this.parameters)}`:s=JSON.stringify(this.parameters);const r=new URL(t),i=new AbortController,{signal:n}=i;let l=null;this.timeout&&(l=setTimeout(()=>i.abort(),this.timeout));try{const a=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n,...this.fetchOptions});this.timeout&&l&&clearTimeout(l);const u=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(a){return a.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:a.message||a.toString()||"An unknown error occurred"}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const i={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(i)})}},pe=me;const Z="SB-Agent",q={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ee={DRAFT:"draft",PUBLISHED:"published"},Re=25,G={SMALL:25,MEDIUM:50,LARGE:75},I={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},F=1e3,x=3;function ve(e){return e.version===ee.DRAFT}function _e(e,t){const s=e.includes("/cdn/stories/"),r=e.split("/").length>3&&!e.endsWith("/cdn/stories"),i="find_by"in t;return s&&r||i}function Ae(e){return e<=G.SMALL?I.SINGLE_OR_SMALL:e<=G.MEDIUM?I.MEDIUM:e<=G.LARGE?I.LARGE:I.VERY_LARGE}function M(e,t,s={},r){if(s.userRateLimit!==void 0)return Math.min(s.userRateLimit,F);if(s.serverHeadersRateLimit!==void 0)return Math.min(s.serverHeadersRateLimit,F);if(r!==void 0)return r;if(t&&!ve(t))return F;if(_e(e,t))return I.SINGLE_OR_SMALL;const i=t.per_page||Re;return Ae(i)}function Ee(e){if(!e)return null;const t=e["x-ratelimit"]||e["X-RateLimit"],s=e["x-ratelimit-policy"]||e["X-RateLimit-Policy"];if(!t&&!s)return null;const r={};if(t){const i=t.match(/r=(\d+)/);i&&(r.remaining=Number.parseInt(i[1],10))}if(s){const i=s.match(/q=(\d+)/);i&&(r.max=Number.parseInt(i[1],10))}return Object.keys(r).length>0?r:null}function ke(e,t=!1){return{userRateLimit:e,serverHeadersRateLimit:void 0,isManagementApi:t}}var we=class extends Error{constructor(e){super(e),this.name="AbortError"}};function Se(e,t,s){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let i=[],n=0,l=!1;const a=async()=>{n++;const c=r.shift();if(c)try{const p=await e(...c.args);c.resolve(p)}catch(p){c.reject(p)}const m=setTimeout(()=>{n--,r.length>0&&a(),i=i.filter(p=>p!==m)},s);i.includes(m)||i.push(m)},u=(...c)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,p)=>{r.push({resolve:m,reject:p,args:c}),n<t&&a()});return u.abort=()=>{l=!0,i.forEach(clearTimeout),i=[],r.forEach(c=>c.reject(()=>new we("Throttle function aborted"))),r.length=0},u}var Le=Se,Te=class{constructor(e,t=1e3){b(this,"queues");b(this,"interval");b(this,"throttledRequestFn");this.queues=new Map,this.interval=t,this.throttledRequestFn=e}getQueue(e){let t=this.queues.get(e);return t||(t=Le(this.throttledRequestFn,e,this.interval),this.queues.set(e,t)),t}execute(e,...t){return this.getQueue(e)(...t)}abortAll(){this.queues.forEach(e=>{var t;(t=e.abort)==null||t.call(e)}),this.queues.clear()}getQueueCount(){return this.queues.size}};let H={};const T={};var Ce=class{constructor(e,t){b(this,"client");b(this,"maxRetries");b(this,"retriesDelay");b(this,"throttleManager");b(this,"accessToken");b(this,"cache");b(this,"resolveCounter");b(this,"relations");b(this,"links");b(this,"version");b(this,"rateLimitConfig");b(this,"richTextResolver");b(this,"resolveNestedRelations");b(this,"stringifiedStoriesCache");b(this,"inlineAssets");let s=e.endpoint||t;if(!s){const i=e.https===!1?"http":"https";e.oauthToken?s=`${i}://${X(e.region)}/v1`:s=`${i}://${X(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(Z)||(r.set(Z,q.defaultAgentName),r.set(q.defaultAgentVersion,q.packageVersion)),e.oauthToken&&r.set("Authorization",e.oauthToken),this.rateLimitConfig=ke(e.rateLimit,!!e.oauthToken),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttleManager=new Te(this.throttledRequest.bind(this),1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||ee.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new pe({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=T[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 U(e)?this.parseParams(t):t}makeRequest(e,t,s,r,i){const n=this.factoryParamOptions(e,he(t,s,r));return this.cacheResponse(e,n,void 0,i)}get(e,t={},s){t||(t={});const r=`/${e}`;U(r)&&(t.version=t.version||this.version);const i=this.factoryParamOptions(r,t);return this.cacheResponse(r,i,void 0,s)}async getAll(e,t={},s,r){const i=(t==null?void 0:t.per_page)||25,n=`/${e}`.replace(/\/$/,""),l=s??n.substring(n.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,u=await this.makeRequest(n,t,i,a,r),c=u.total?Math.ceil(u.total/(u.perPage||i)):1,m=await ye(ge(a,c),p=>this.makeRequest(n,t,i,p+1,r));return be([u,...m],p=>Object.values(p.data[l]))}post(e,t={},s){const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"post",r,t,s)}put(e,t={},s){const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"put",r,t,s)}delete(e,t={},s){t||(t={});const r=`/${e}`,i=M(void 0,void 0,this.rateLimitConfig,x);return this.throttleManager.execute(i,"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(i=>this.getStoryReference(s,i)).filter(Boolean))}_insertRelations(e,t,s,r){if(Array.isArray(s)?s.find(l=>l.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=(i,n="")=>{if(!(!i||i._stopResolving)){if(Array.isArray(i))i.forEach((l,a)=>r(l,`${n}[${a}]`));else if(typeof i=="object")for(const l in i){const a=n?`${n}.${l}`:l;(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,l,t,s),this._insertLinks(i,l,s)),r(i[l],a)}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const i=e.link_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const u=Math.min(i,a+l);n.push(e.link_uuids.slice(a,u))}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(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const i=e.rel_uuids.length,n=[],l=50;for(let a=0;a<i;a+=l){const u=Math.min(i,a+l);n.push(e.rel_uuids.slice(a,u))}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)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(e,t,s){var i,n;let r=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(r=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((i=e.links)!=null&&i.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],r,s);e.story?this.iterateTree(e.story,r,s):e.stories.forEach(l=>{this.iterateTree(l,r,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,r){const i=j({url:e,params:t}),n=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await n.get(i);if(c)return Promise.resolve(c)}const a=!U(e)&&this.rateLimitConfig.isManagementApi?x:void 0,u=M(e,t,this.rateLimitConfig,a);return new Promise(async(c,m)=>{var p;try{const v=await this.throttleManager.execute(u,"get",e,t,r);if(v.status!==200)return m(v);let w={data:v.data,headers:v.headers};const k=Ee(v.headers);if((k==null?void 0:k.max)!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=k.max),(p=v.headers)!=null&&p["per-page"]&&(w=Object.assign({},w,{perPage:v.headers["per-page"]?Number.parseInt(v.headers["per-page"]):0,total:v.headers["per-page"]?Number.parseInt(v.headers.total):0})),w.data.story||w.data.stories){const D=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(w.data,t,`${D}`),w=await this.processInlineAssets(w)}t.version==="published"&&e!=="/cdn/spaces/me"&&await n.set(i,w);const C=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&w.data.cv&&(C&&T[t.token]&&T[t.token]!==w.data.cv&&await this.flushCache(),T[t.token]=w.data.cv),c(w)}catch(v){if(v.response&&v.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 de(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(m);m(v)}})}throttledRequest(e,t,s,r){return this.client.setFetchOptions(r),this.client[e](t,s)}cacheVersions(){return T}cacheVersion(){return T[this.accessToken]}setCacheVersion(e){this.accessToken&&(T[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(T[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(H[e])},getAll(){return Promise.resolve(H)},set(e,t){return H[e]=t,Promise.resolve(void 0)},flush(){return H={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=s=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(i=>t(i));let r={...s};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...e.data.assets.find(i=>i.id===r.id),...r});for(const i in r)typeof r[i]=="object"&&(r[i]=t(r[i]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(s=>(s.content=t(s.content),s))),e}},te=Ce;const Oe=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new te(t)}},Ie=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let B="https://app.storyblok.com/f/storyblok-v2-latest.js";const re=(e,t,s={})=>{var a;const i=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((a=window.location)==null?void 0:a.href).searchParams.get("_storyblok"),l=n!==null&&+n===e;if(!(!i||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],c=>{var m;c&&(c.action==="input"&&((m=c.story)==null?void 0:m.id)===e?t(c.story):(c.action==="change"||c.action==="published")&&c.storyId===e&&window.location.reload())})})}},Pe=(e={})=>{var m,p;const{bridge:t,accessToken:s,use:r=[],apiOptions:i={},bridgeUrl:n}=e;i.accessToken=i.accessToken||s;const l={bridge:t,apiOptions:i};let a={};r.forEach(v=>{a={...a,...v(l)}}),n&&(B=n);const c=!(typeof window>"u")&&((p=(m=window.location)==null?void 0:m.search)==null?void 0:p.includes("_storyblok_tk"));return t!==!1&&c&&Q(B),a};function Ne(e,t){return J(t).render(e)}const xe=()=>Q(B);_.BlockTypes=g,_.MarkTypes=E,_.StoryblokClient=te,_.TextTypes=V,_.apiPlugin=Oe,_.loadStoryblokBridge=xe,_.registerStoryblokBridge=re,_.renderRichText=Ne,_.richTextResolver=J,_.storyblokEditable=Ie,_.storyblokInit=Pe,_.useStoryblokBridge=re,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * name: @storyblok/js
3
- * (c) 2025
3
+ * (c) 2026
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
7
  var ce = Object.defineProperty;
8
8
  var ue = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
9
9
  var y = (e, t, r) => ue(e, typeof t != "symbol" ? t + "" : t, r);
10
- let E = /* @__PURE__ */ function(e) {
10
+ let A = /* @__PURE__ */ function(e) {
11
11
  return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
12
- }({}), w = /* @__PURE__ */ function(e) {
12
+ }({}), L = /* @__PURE__ */ function(e) {
13
13
  return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
14
14
  }({}), he = /* @__PURE__ */ function(e) {
15
15
  return e.TEXT = "text", e;
@@ -54,8 +54,8 @@ function be(e, t) {
54
54
  }
55
55
  if (typeof t == "object") {
56
56
  if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (i.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (i.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete i.width, delete i.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (i.loading = t.loading), t.class && (i.class = t.class), t.filters) {
57
- const { filters: u } = t || {}, { blur: c, brightness: b, fill: m, format: R, grayscale: A, quality: _, rotate: T } = u || {};
58
- c && l(c, 0, 100, "blur", n), _ && l(_, 0, 100, "quality", n), b && l(b, 0, 100, "brightness", n), m && n.push(`fill(${m})`), A && n.push("grayscale()"), T && [
57
+ const { filters: u } = t || {}, { blur: c, brightness: b, fill: m, format: R, grayscale: E, quality: _, rotate: T } = u || {};
58
+ c && l(c, 0, 100, "blur", n), _ && l(_, 0, 100, "quality", n), b && l(b, 0, 100, "brightness", n), m && n.push(`fill(${m})`), E && n.push("grayscale()"), T && [
59
59
  0,
60
60
  90,
61
61
  180,
@@ -104,10 +104,10 @@ function me(e = {}) {
104
104
  return d.render(o, f, h.children || null);
105
105
  }, b = (o, h) => {
106
106
  const { src: d, alt: f, title: g, srcset: v, sizes: p } = o.attrs || {};
107
- let k = d, L = {};
107
+ let k = d, w = {};
108
108
  if (n) {
109
109
  const { src: ae, attrs: le } = be(d, n);
110
- k = ae, L = le;
110
+ k = ae, w = le;
111
111
  }
112
112
  const C = {
113
113
  src: k,
@@ -115,7 +115,7 @@ function me(e = {}) {
115
115
  title: g,
116
116
  srcset: v,
117
117
  sizes: p,
118
- ...L
118
+ ...w
119
119
  };
120
120
  return h.render("img", O(C));
121
121
  }, m = (o, h) => {
@@ -135,14 +135,14 @@ function me(e = {}) {
135
135
  "data-name": (v = o.attrs) == null ? void 0 : v.name,
136
136
  "data-emoji": (p = o.attrs) == null ? void 0 : p.emoji
137
137
  }, d);
138
- }, A = (o, h) => h.render("pre", o.attrs || {}, h.render("code", {}, o.children || "")), _ = (o, h = !1) => ({ text: d, attrs: f }, g) => {
139
- const { class: v, id: p, ...k } = f || {}, L = h ? {
138
+ }, E = (o, h) => h.render("pre", o.attrs || {}, h.render("code", {}, o.children || "")), _ = (o, h = !1) => ({ text: d, attrs: f }, g) => {
139
+ const { class: v, id: p, ...k } = f || {}, w = h ? {
140
140
  class: v,
141
141
  id: p,
142
142
  style: ge(k) || void 0
143
143
  } : f || {};
144
- return g.render(o, O(L), d);
145
- }, T = (o) => $(o), U = (o) => {
144
+ return g.render(o, O(w), d);
145
+ }, T = (o) => U(o), M = (o) => {
146
146
  const { marks: h, ...d } = o;
147
147
  if ("text" in o) {
148
148
  if (h) return h.reduce((g, v) => T({
@@ -194,56 +194,56 @@ function me(e = {}) {
194
194
  const d = u(o.attrs);
195
195
  return h.render("tr", d, o.children);
196
196
  }, ie = (o, h) => {
197
- const { colspan: d, rowspan: f, colwidth: g, backgroundColor: v, textAlign: p, ...k } = o.attrs || {}, L = [];
198
- g && L.push(`width: ${g}px;`), v && L.push(`background-color: ${v};`), p && L.push(`text-align: ${p};`);
197
+ const { colspan: d, rowspan: f, colwidth: g, backgroundColor: v, textAlign: p, ...k } = o.attrs || {}, w = [];
198
+ g && w.push(`width: ${g}px;`), v && w.push(`background-color: ${v};`), p && w.push(`text-align: ${p};`);
199
199
  const C = {
200
200
  ...k,
201
201
  ...d > 1 ? { colspan: d } : {},
202
202
  ...f > 1 ? { rowspan: f } : {},
203
- ...L.length > 0 ? { style: L.join(" ") } : {}
203
+ ...w.length > 0 ? { style: w.join(" ") } : {}
204
204
  };
205
205
  return h.render("td", O(C), o.children);
206
206
  }, ne = (o, h) => {
207
- const { colspan: d, rowspan: f, colwidth: g, backgroundColor: v, textAlign: p, ...k } = o.attrs || {}, L = [];
208
- g && L.push(`width: ${g}px;`), v && L.push(`background-color: ${v};`), p && L.push(`text-align: ${p};`);
207
+ const { colspan: d, rowspan: f, colwidth: g, backgroundColor: v, textAlign: p, ...k } = o.attrs || {}, w = [];
208
+ g && w.push(`width: ${g}px;`), v && w.push(`background-color: ${v};`), p && w.push(`text-align: ${p};`);
209
209
  const C = {
210
210
  ...k,
211
211
  ...d > 1 ? { colspan: d } : {},
212
212
  ...f > 1 ? { rowspan: f } : {},
213
- ...L.length > 0 ? { style: L.join(" ") } : {}
213
+ ...w.length > 0 ? { style: w.join(" ") } : {}
214
214
  };
215
215
  return h.render("th", O(C), o.children);
216
216
  }, V = /* @__PURE__ */ new Map([
217
- [E.DOCUMENT, c("")],
218
- [E.HEADING, m],
219
- [E.PARAGRAPH, c("p")],
220
- [E.UL_LIST, c("ul")],
221
- [E.OL_LIST, c("ol")],
222
- [E.LIST_ITEM, c("li")],
223
- [E.IMAGE, b],
224
- [E.EMOJI, R],
225
- [E.CODE_BLOCK, A],
226
- [E.HR, c("hr")],
227
- [E.BR, c("br")],
228
- [E.QUOTE, c("blockquote")],
229
- [E.COMPONENT, te],
230
- [he.TEXT, U],
231
- [w.LINK, z],
232
- [w.ANCHOR, z],
233
- [w.STYLED, _("span", !0)],
234
- [w.BOLD, _("strong")],
235
- [w.TEXT_STYLE, _("span", !0)],
236
- [w.ITALIC, _("em")],
237
- [w.UNDERLINE, _("u")],
238
- [w.STRIKE, _("s")],
239
- [w.CODE, _("code")],
240
- [w.SUPERSCRIPT, _("sup")],
241
- [w.SUBSCRIPT, _("sub")],
242
- [w.HIGHLIGHT, _("mark")],
243
- [E.TABLE, re],
244
- [E.TABLE_ROW, se],
245
- [E.TABLE_CELL, ie],
246
- [E.TABLE_HEADER, ne]
217
+ [A.DOCUMENT, c("")],
218
+ [A.HEADING, m],
219
+ [A.PARAGRAPH, c("p")],
220
+ [A.UL_LIST, c("ul")],
221
+ [A.OL_LIST, c("ol")],
222
+ [A.LIST_ITEM, c("li")],
223
+ [A.IMAGE, b],
224
+ [A.EMOJI, R],
225
+ [A.CODE_BLOCK, E],
226
+ [A.HR, c("hr")],
227
+ [A.BR, c("br")],
228
+ [A.QUOTE, c("blockquote")],
229
+ [A.COMPONENT, te],
230
+ [he.TEXT, M],
231
+ [L.LINK, z],
232
+ [L.ANCHOR, z],
233
+ [L.STYLED, _("span", !0)],
234
+ [L.BOLD, _("strong")],
235
+ [L.TEXT_STYLE, _("span", !0)],
236
+ [L.ITALIC, _("em")],
237
+ [L.UNDERLINE, _("u")],
238
+ [L.STRIKE, _("s")],
239
+ [L.CODE, _("code")],
240
+ [L.SUPERSCRIPT, _("sup")],
241
+ [L.SUBSCRIPT, _("sub")],
242
+ [L.HIGHLIGHT, _("mark")],
243
+ [A.TABLE, re],
244
+ [A.TABLE_ROW, se],
245
+ [A.TABLE_CELL, ie],
246
+ [A.TABLE_HEADER, ne]
247
247
  ]), Y = new Map([...V, ...Object.entries(i).map(([o, h]) => [o, h])]), oe = () => ({
248
248
  render: (d, f = {}, g) => {
249
249
  if (l && d) {
@@ -261,16 +261,16 @@ function me(e = {}) {
261
261
  return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
262
262
  const d = oe();
263
263
  if (o.type === "text") return h(o, d);
264
- const f = o.content ? o.content.map($) : void 0;
264
+ const f = o.content ? o.content.map(U) : void 0;
265
265
  return h({
266
266
  ...o,
267
267
  children: f
268
268
  }, d);
269
269
  }
270
- function $(o) {
270
+ function U(o) {
271
271
  return o.type === "doc" ? a ? o.content.map(P) : o.content.map(P).join("") : Array.isArray(o) ? o.map(P) : P(o);
272
272
  }
273
- return { render: $ };
273
+ return { render: U };
274
274
  }
275
275
  let K = !1;
276
276
  const W = [], Z = (e) => new Promise((t, r) => {
@@ -299,7 +299,7 @@ const W = [], Z = (e) => new Promise((t, r) => {
299
299
  }), Re = (e) => new Promise((t) => setTimeout(t, e)), ve = (e = 0, t) => Array.from({ length: e }, t), _e = (e = 0, t = e) => {
300
300
  const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
301
301
  return ve(r, (i, n) => n * s + e);
302
- }, Ee = async (e, t) => Promise.all(e.map(t)), Ae = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), B = (e, t, r) => {
302
+ }, Ae = async (e, t) => Promise.all(e.map(t)), Ee = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), B = (e, t, r) => {
303
303
  const s = [];
304
304
  for (const i in e) {
305
305
  if (!Object.prototype.hasOwnProperty.call(e, i)) continue;
@@ -320,7 +320,7 @@ const W = [], Z = (e) => new Promise((t, r) => {
320
320
  };
321
321
  return t[e] ?? t.eu;
322
322
  };
323
- var Le = class {
323
+ var we = class {
324
324
  constructor(e) {
325
325
  y(this, "baseURL");
326
326
  y(this, "timeout");
@@ -382,7 +382,7 @@ var Le = class {
382
382
  const u = await this._responseHandler(a);
383
383
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
384
384
  } catch (a) {
385
- return { message: a };
385
+ return a.name === "AbortError" ? { message: "Request timeout: The request was aborted due to timeout" } : { message: a.message || a.toString() || "An unknown error occurred" };
386
386
  }
387
387
  }
388
388
  setFetchOptions(e = {}) {
@@ -420,15 +420,15 @@ var Le = class {
420
420
  s(i);
421
421
  });
422
422
  }
423
- }, we = Le;
424
- const X = "SB-Agent", G = {
423
+ }, Le = we;
424
+ const X = "SB-Agent", q = {
425
425
  defaultAgentName: "SB-JS-CLIENT",
426
426
  defaultAgentVersion: "SB-Agent-Version",
427
427
  packageVersion: "7.0.0"
428
428
  }, ee = {
429
429
  DRAFT: "draft",
430
430
  PUBLISHED: "published"
431
- }, ke = 25, q = {
431
+ }, ke = 25, G = {
432
432
  SMALL: 25,
433
433
  MEDIUM: 50,
434
434
  LARGE: 75
@@ -446,7 +446,7 @@ function Te(e, t) {
446
446
  return r && s || i;
447
447
  }
448
448
  function Ce(e) {
449
- return e <= q.SMALL ? I.SINGLE_OR_SMALL : e <= q.MEDIUM ? I.MEDIUM : e <= q.LARGE ? I.LARGE : I.VERY_LARGE;
449
+ return e <= G.SMALL ? I.SINGLE_OR_SMALL : e <= G.MEDIUM ? I.MEDIUM : e <= G.LARGE ? I.LARGE : I.VERY_LARGE;
450
450
  }
451
451
  function H(e, t, r = {}, s) {
452
452
  if (r.userRateLimit !== void 0) return Math.min(r.userRateLimit, F);
@@ -549,9 +549,9 @@ var Ne = xe, He = class {
549
549
  return this.queues.size;
550
550
  }
551
551
  };
552
- let M = {};
552
+ let $ = {};
553
553
  const S = {};
554
- var Me = class {
554
+ var $e = class {
555
555
  /**
556
556
  *
557
557
  * @param config ISbConfig interface
@@ -585,7 +585,7 @@ var Me = class {
585
585
  const s = new Headers();
586
586
  s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, l]) => {
587
587
  s.set(n, l);
588
- }), s.has(X) || (s.set(X, G.defaultAgentName), s.set(G.defaultAgentVersion, G.packageVersion)), e.oauthToken && s.set("Authorization", e.oauthToken), this.rateLimitConfig = Ie(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new He(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ee.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new we({
588
+ }), s.has(X) || (s.set(X, q.defaultAgentName), s.set(q.defaultAgentVersion, q.packageVersion)), e.oauthToken && s.set("Authorization", e.oauthToken), this.rateLimitConfig = Ie(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new He(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ee.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Le({
589
589
  baseURL: r,
590
590
  timeout: e.timeout || 0,
591
591
  headers: s,
@@ -613,8 +613,8 @@ var Me = class {
613
613
  async getAll(e, t = {}, r, s) {
614
614
  const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = r ?? n.substring(n.lastIndexOf("/") + 1);
615
615
  t.version = t.version || this.version;
616
- const a = 1, u = await this.makeRequest(n, t, i, a, s), c = u.total ? Math.ceil(u.total / (u.perPage || i)) : 1, b = await Ee(_e(a, c), (m) => this.makeRequest(n, t, i, m + 1, s));
617
- return Ae([u, ...b], (m) => Object.values(m.data[l]));
616
+ const a = 1, u = await this.makeRequest(n, t, i, a, s), c = u.total ? Math.ceil(u.total / (u.perPage || i)) : 1, b = await Ae(_e(a, c), (m) => this.makeRequest(n, t, i, m + 1, s));
617
+ return Ee([u, ...b], (m) => Object.values(m.data[l]));
618
618
  }
619
619
  post(e, t = {}, r) {
620
620
  const s = `/${e}`, i = H(void 0, void 0, this.rateLimitConfig, N);
@@ -808,21 +808,21 @@ var Me = class {
808
808
  try {
809
809
  const R = await this.throttleManager.execute(u, "get", e, t, s);
810
810
  if (R.status !== 200) return b(R);
811
- let A = {
811
+ let E = {
812
812
  data: R.data,
813
813
  headers: R.headers
814
814
  };
815
815
  const _ = Oe(R.headers);
816
- if ((_ == null ? void 0 : _.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = _.max), (m = R.headers) != null && m["per-page"] && (A = Object.assign({}, A, {
816
+ if ((_ == null ? void 0 : _.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = _.max), (m = R.headers) != null && m["per-page"] && (E = Object.assign({}, E, {
817
817
  perPage: R.headers["per-page"] ? Number.parseInt(R.headers["per-page"]) : 0,
818
818
  total: R.headers["per-page"] ? Number.parseInt(R.headers.total) : 0
819
- })), A.data.story || A.data.stories) {
820
- const U = this.resolveCounter = ++this.resolveCounter % 1e3;
821
- await this.resolveStories(A.data, t, `${U}`), A = await this.processInlineAssets(A);
819
+ })), E.data.story || E.data.stories) {
820
+ const M = this.resolveCounter = ++this.resolveCounter % 1e3;
821
+ await this.resolveStories(E.data, t, `${M}`), E = await this.processInlineAssets(E);
822
822
  }
823
- t.version === "published" && e !== "/cdn/spaces/me" && await n.set(i, A);
823
+ t.version === "published" && e !== "/cdn/spaces/me" && await n.set(i, E);
824
824
  const T = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
825
- return t.token && A.data.cv && (T && S[t.token] && S[t.token] !== A.data.cv && await this.flushCache(), S[t.token] = A.data.cv), c(A);
825
+ return t.token && E.data.cv && (T && S[t.token] && S[t.token] !== E.data.cv && await this.flushCache(), S[t.token] = E.data.cv), c(E);
826
826
  } catch (R) {
827
827
  if (R.response && R.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
828
828
  return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Re(this.retriesDelay), this.cacheResponse(e, t, r).then(c).catch(b);
@@ -850,16 +850,16 @@ var Me = class {
850
850
  case "memory":
851
851
  return {
852
852
  get(e) {
853
- return Promise.resolve(M[e]);
853
+ return Promise.resolve($[e]);
854
854
  },
855
855
  getAll() {
856
- return Promise.resolve(M);
856
+ return Promise.resolve($);
857
857
  },
858
858
  set(e, t) {
859
- return M[e] = t, Promise.resolve(void 0);
859
+ return $[e] = t, Promise.resolve(void 0);
860
860
  },
861
861
  flush() {
862
- return M = {}, Promise.resolve(void 0);
862
+ return $ = {}, Promise.resolve(void 0);
863
863
  }
864
864
  };
865
865
  case "custom":
@@ -899,7 +899,7 @@ var Me = class {
899
899
  };
900
900
  return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((r) => (r.content = t(r.content), r))), e;
901
901
  }
902
- }, Ue = Me;
902
+ }, Me = $e;
903
903
  const je = (e = {}) => {
904
904
  const { apiOptions: t } = e;
905
905
  if (!t || !t.accessToken) {
@@ -908,8 +908,8 @@ const je = (e = {}) => {
908
908
  );
909
909
  return;
910
910
  }
911
- return { storyblokApi: new Ue(t) };
912
- }, Ge = (e) => {
911
+ return { storyblokApi: new Me(t) };
912
+ }, qe = (e) => {
913
913
  if (typeof e != "object" || typeof e._editable > "u")
914
914
  return {};
915
915
  try {
@@ -925,7 +925,7 @@ const je = (e = {}) => {
925
925
  }
926
926
  };
927
927
  let D = "https://app.storyblok.com/f/storyblok-v2-latest.js";
928
- const qe = (e, t, r = {}) => {
928
+ const Ge = (e, t, r = {}) => {
929
929
  var a;
930
930
  const i = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
931
931
  "_storyblok"
@@ -965,16 +965,16 @@ function De(e, t) {
965
965
  }
966
966
  const Be = () => Z(D);
967
967
  export {
968
- E as BlockTypes,
969
- w as MarkTypes,
970
- Ue as StoryblokClient,
968
+ A as BlockTypes,
969
+ L as MarkTypes,
970
+ Me as StoryblokClient,
971
971
  he as TextTypes,
972
972
  je as apiPlugin,
973
973
  Be as loadStoryblokBridge,
974
- qe as registerStoryblokBridge,
974
+ Ge as registerStoryblokBridge,
975
975
  De as renderRichText,
976
976
  me as richTextResolver,
977
- Ge as storyblokEditable,
977
+ qe as storyblokEditable,
978
978
  Fe as storyblokInit,
979
- qe as useStoryblokBridge
979
+ Ge as useStoryblokBridge
980
980
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
3
  "type": "module",
4
- "version": "4.4.3",
4
+ "version": "4.4.4",
5
5
  "private": false,
6
6
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
7
7
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@storyblok/richtext": "3.8.2",
32
- "storyblok-js-client": "7.2.1"
32
+ "storyblok-js-client": "7.2.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@tsconfig/recommended": "^1.0.8",