@storyblok/react 4.5.2 → 4.5.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.
package/dist/richtext.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import o from "react";
2
- import s from "./storyblok-component.mjs";
2
+ import n from "./storyblok-component.mjs";
3
3
  import { BlockTypes as m, richTextResolver as a } from "./storyblok-js.mjs";
4
4
  function i(e) {
5
- var t, n;
5
+ var t, s;
6
6
  const r = (t = e == null ? void 0 : e.attrs) == null ? void 0 : t.body;
7
- return o.createElement(s, {
7
+ return o.createElement(n, {
8
8
  blok: Array.isArray(r) ? r[0] : void 0,
9
- key: (n = e.attrs) == null ? void 0 : n.id
9
+ key: (s = e.attrs) == null ? void 0 : s.id
10
10
  });
11
11
  }
12
12
  function p(e) {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=n=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{z.forEach(o=>o()),B=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var oe=Object.defineProperty,ie=(n,e,t)=>e in n?oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ie(n,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(n,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 r=[];let s=[],o=0,i=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const p=await n(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(p=>p!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),o<e&&l()});return a.abort=()=>{i=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),r.length=0},a}class C{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),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 r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(o,i)=>i*s+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),g(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,s=new RegExp(r.source);return e&&s.test(e)?e.replace(r,o=>t[o]):e})}stringify(e,t,r){const s=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o],l=r?"":encodeURIComponent(o);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,s.push(a)}return s.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",s="app.storyblokchina.cn",o="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return s;case"ap":return o;case"ca":return i;default:return t}}}const ce=function(n,e){const t={};for(const r in n){const s=n[r];e.includes(r)&&s!==null&&(t[r]=s)}return t},he=n=>n==="email",ue=()=>({singleTag:"hr"}),de=()=>({tag:"blockquote"}),pe=()=>({tag:"ul"}),ge=n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),fe=()=>({singleTag:"br"}),me=n=>({tag:`h${n.attrs.level}`}),ye=n=>({singleTag:[{tag:"img",attrs:ce(n.attrs,["src","alt","title"])}]}),be=()=>({tag:"li"}),ke=()=>({tag:"ol"}),$e=()=>({tag:"p"}),ve=n=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":n.attrs.name,emoji:n.attrs.emoji}}]}),we=()=>({tag:"b"}),Te=()=>({tag:"s"}),Re=()=>({tag:"u"}),_e=()=>({tag:"strong"}),Ee=()=>({tag:"code"}),Se=()=>({tag:"i"}),je=n=>{if(!n.attrs)return{tag:""};const e=new C().escapeHTML,t={...n.attrs},{linktype:r="url"}=n.attrs;if(delete t.linktype,t.href&&(t.href=e(n.attrs.href||"")),he(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ie=n=>({tag:[{tag:"span",attrs:n.attrs}]}),Ae=()=>({tag:"sub"}),Oe=()=>({tag:"sup"}),xe=n=>({tag:[{tag:"span",attrs:n.attrs}]}),Le=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${n.attrs.color};`}}]}:{tag:""}},Ce=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${n.attrs.color}`}}]}:{tag:""}},V={nodes:{horizontal_rule:ue,blockquote:de,bullet_list:pe,code_block:ge,hard_break:fe,heading:me,image:ye,list_item:be,ordered_list:ke,paragraph:$e,emoji:ve},marks:{bold:we,strike:Te,underline:Re,strong:_e,code:Ee,italic:Se,link:je,styled:Ie,subscript:Ae,superscript:Oe,anchor:xe,highlight:Le,textStyle:Ce}},Pe=function(n){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=new RegExp(t.source);return n&&r.test(n)?n.replace(t,s=>e[s]):n};let D=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=V),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},r=!0){if(!D&&r&&(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/"),D=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(o=>{s+=this.renderNode(o)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=o,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{z.forEach(n=>n()),B=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var ne=Object.defineProperty,ie=(o,e,t)=>e in o?ne(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e,t)=>ie(o,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(o,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 r=[];let s=[],n=0,i=!1;const l=async()=>{n++;const h=r.shift();if(h)try{const p=await o(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{n--,r.length>0&&l(),s=s.filter(p=>p!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),n<e&&l()});return a.abort=()=>{i=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),r.length=0},a}class C{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),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 r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(n,i)=>i*s+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),g(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,s=new RegExp(r.source);return e&&s.test(e)?e.replace(r,n=>t[n]):e})}stringify(e,t,r){const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n];if(i==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,s.push(a)}return s.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",s="app.storyblokchina.cn",n="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return s;case"ap":return n;case"ca":return i;default:return t}}}const ce=function(o,e){const t={};for(const r in o){const s=o[r];e.includes(r)&&s!==null&&(t[r]=s)}return t},he=o=>o==="email",ue=()=>({singleTag:"hr"}),de=()=>({tag:"blockquote"}),pe=()=>({tag:"ul"}),ge=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),fe=()=>({singleTag:"br"}),me=o=>({tag:`h${o.attrs.level}`}),ye=o=>({singleTag:[{tag:"img",attrs:ce(o.attrs,["src","alt","title"])}]}),be=()=>({tag:"li"}),ke=()=>({tag:"ol"}),ve=()=>({tag:"p"}),$e=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),we=()=>({tag:"b"}),Te=()=>({tag:"s"}),Re=()=>({tag:"u"}),_e=()=>({tag:"strong"}),Ee=()=>({tag:"code"}),Se=()=>({tag:"i"}),je=o=>{if(!o.attrs)return{tag:""};const e=new C().escapeHTML,t={...o.attrs},{linktype:r="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),he(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ie=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Ae=()=>({tag:"sub"}),Oe=()=>({tag:"sup"}),xe=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Le=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ce=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},V={nodes:{horizontal_rule:ue,blockquote:de,bullet_list:pe,code_block:ge,hard_break:fe,heading:me,image:ye,list_item:be,ordered_list:ke,paragraph:ve,emoji:$e},marks:{bold:we,strike:Te,underline:Re,strong:_e,code:Ee,italic:Se,link:je,styled:Ie,subscript:Ae,superscript:Oe,anchor:xe,highlight:Le,textStyle:Ce}},Pe=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=new RegExp(t.source);return o&&r.test(o)?o.replace(t,s=>e[s]):o};let D=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=V),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},r=!0){if(!D&&r&&(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/"),D=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(n=>{s+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
2
2
  The "content" field must be an array of nodes as the type ISbRichtext.
3
3
  ISbRichtext:
4
4
  content?: ISbRichtext[]
@@ -21,4 +21,4 @@
21
21
  }
22
22
  ],
23
23
  type: 'doc'
24
- }`),""}optimizeImages(e,t){let r=0,s=0,o="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(o+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(o+=`height="${t.height}" `,s=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&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i=`/filters${i}`))),o.length>0&&(e=e.replace(/<img/g,`<img ${o.trim()}`));const l=r>0||s>0||i.length>0?`${r}x${s}${i}`:"";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,d;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(w=>{if(typeof w=="number")return`//${p}/m/${w}x0${i} ${w}w`;if(typeof w=="object"&&w.length===2){let E=0,j=0;return typeof w[0]=="number"&&(E=w[0]),typeof w[1]=="number"&&(j=w[1]),`//${p}/m/${E}x${j}${i} ${E}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(w=>w).join(", ")};let $="";return b.srcset&&($+=`srcset="${b.srcset}" `),b.sizes&&($+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${$.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(Pe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs){for(const o in r.attrs)if(Object.prototype.hasOwnProperty.call(r.attrs,o)){const i=r.attrs[o];i!==null&&(s+=` ${o}="${i}"`)}}return`${s}${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 Ne{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=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const a=new C;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:i}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:i,...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((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};s(o)})}}const q="SB-Agent",N={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const S={};class He{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 r=e.endpoint||t;if(!r){const i=new C().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const s=new Headers;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(([i,l])=>{s.set(i,l)}),s.has(q)||(s.set(q,N.defaultAgentName),s.set(N.defaultAgentVersion,N.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=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=le(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new C,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ne({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}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,r,s,o){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,s));return this.cacheResponse(e,i,void 0,o)}get(e,t,r){t||(t={});const s=`/${e}`,o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t,r,s){const o=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1),a=1,h=await this.makeRequest(i,t,o,a,s),d=h.total?Math.ceil(h.total/o):1,p=await this.helpers.asyncMap(this.helpers.range(a,d),b=>this.makeRequest(i,t,o,b+1,s));return this.helpers.flatMap([h,...p],b=>Object.values(b.data[l]))}post(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t,r))}put(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t,r))}delete(e,t,r){t||(t={});const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t,r))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,i="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,a)=>s(l,`${i}[${a}]`));else if(typeof o=="object")for(const l in o){const a=i?`${i}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,i=[],l=50;for(let a=0;a<o;a+=l){const h=Math.min(o,a+l);i.push(e.link_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,i=[],l=50;for(let a=0;a<o;a+=l){const h=Math.min(o,a+l);i.push(e.rel_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)})}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let i=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],i,r);e.story?this.iterateTree(e.story,i,r):e.stories.forEach(l=>{this.iterateTree(l,i,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var h;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return a(d);let p={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),p.data.story||p.data.stories){const $=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${$}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(o,p);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(b&&S[t.token]&&S[t.token]!==p.data.cv&&await this.flushCache(),S[t.token]=p.data.cv),l(p)}catch(d){if(d.response&&d.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(d)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}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(x[e])},getAll(){return Promise.resolve(x)},set(e,t){return x[e]=t,Promise.resolve(void 0)},flush(){return x={},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 Me=(n={})=>{const{apiOptions:e}=n;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 He(e)}},Ue=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Be(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function i(a,h,d,p,b){typeof a!="number"||a<=h||a>=d?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`):b.push(`${p}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.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?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:d,fill:p,format:b,grayscale:$,quality:w,rotate:E}=a||{};h&&i(h,0,100,"blur",o),w&&i(w,0,100,"quality",o),d&&i(d,0,100,"brightness",o),p&&o.push(`fill(${p})`),$&&o.push("grayscale()"),E&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${E})`),b&&["webp","png","jpeg"].includes(b)&&o.push(`format(${b})`)}e.srcset&&(s.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${n}/m/${a}x0/${o.length>0?`filters:${o.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,d]=a;return`${n}/m/${h}x${d}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var k=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(k||{}),_=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))(_||{}),U=(n=>(n.TEXT="text",n))(U||{}),I=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(I||{});const ze=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),qe=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function Fe(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const L=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function F(n,e={},t){const r=De(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(ze.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function Ge(n={}){let e=0;const{renderFn:t=F,textFn:r=Fe,resolvers:s={},optimizeImages:o=!1,keyedResolvers:i=!1}=n,l=t!==F,a=c=>u=>{const f=u.attrs||{};return i&&(f.key=`${c}-${e}`),t(c,f,u.children||null)},h=c=>{const{src:u,alt:f,title:y,srcset:R,sizes:v}=c.attrs||{};let m=u,T={};if(o){const{src:se,attrs:ne}=Be(u,o);m=se,T=ne}i&&(T={...T,key:`img-${e}`});const re={src:m,alt:f,title:y,srcset:R,sizes:v,...T};return t("img",L(re))},d=c=>{const{level:u,...f}=c.attrs||{},y={...f};return i&&(y.key=`h${u}-${e}`),t(`h${u}`,y,c.children)},p=c=>{var u,f,y,R;const v=t("img",{src:(u=c.attrs)==null?void 0:u.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":(y=c.attrs)==null?void 0:y.name,"data-emoji":(R=c.attrs)==null?void 0:R.emoji};return i&&(m.key=`emoji-${e}`),t("span",m,v)},b=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),$=(c,u=!1)=>({text:f,attrs:y})=>{const{class:R,id:v,...m}=y||{},T=u?{class:R,id:v,style:qe(m)||void 0}:y||{};return i&&(T.key=`${c}-${e}`),t(c,L(T),f)},w=c=>P(c),E=c=>{const{marks:u,...f}=c;return"text"in c?u?u.reduce((y,R)=>w({...R,text:y}),w({...f,children:f.children})):r(f.text):""},j=c=>{const{linktype:u,href:f,anchor:y,...R}=c.attrs||{};let v="";switch(u){case I.ASSET:case I.URL:v=f;break;case I.EMAIL:v=`mailto:${f}`;break;case I.STORY:v=f,y&&(v=`${v}#${y}`);break;default:v=f;break}const m={...R};return v&&(m.href=v),i&&(m.key=`a-${e}`),t("a",m,c.text)},W=c=>{var u,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(u=c==null?void 0:c.attrs)==null?void 0:u.body[0],id:(f=c.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},X=c=>{const u={};return i&&(u.key=`table-${e}`),t("table",u,c.children)},Q=c=>{const u={};return i&&(u.key=`tr-${e}`),t("tr",u,c.children)},Z=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...v}=c.attrs||{},m={...v};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`td-${e}`),t("td",L(m),c.children)},ee=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...v}=c.attrs||{},m={...v};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`th-${e}`),t("th",L(m),c.children)},te=new Map([[k.DOCUMENT,a("")],[k.HEADING,d],[k.PARAGRAPH,a("p")],[k.UL_LIST,a("ul")],[k.OL_LIST,a("ol")],[k.LIST_ITEM,a("li")],[k.IMAGE,h],[k.EMOJI,p],[k.CODE_BLOCK,b],[k.HR,a("hr")],[k.BR,a("br")],[k.QUOTE,a("blockquote")],[k.COMPONENT,W],[U.TEXT,E],[_.LINK,j],[_.ANCHOR,j],[_.STYLED,$("span",!0)],[_.BOLD,$("strong")],[_.TEXT_STYLE,$("span",!0)],[_.ITALIC,$("em")],[_.UNDERLINE,$("u")],[_.STRIKE,$("s")],[_.CODE,$("code")],[_.SUPERSCRIPT,$("sup")],[_.SUBSCRIPT,$("sub")],[_.HIGHLIGHT,$("mark")],[k.TABLE,X],[k.TABLE_ROW,Q],[k.TABLE_CELL,Z],[k.TABLE_HEADER,ee],...Object.entries(s).map(([c,u])=>[c,u])]);function O(c){e+=1;const u=te.get(c.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return u(c);const f=c.content?c.content.map(P):void 0;return u({...c,children:f})}function P(c){return c.type==="doc"?l?c.content.map(O):c.content.map(O).join(""):Array.isArray(c)?c.map(O):O(c)}return{render:P}}let H,M="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),i=o!==null&&+o===n;if(!(!s||!i)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var a;l&&(l.action==="input"&&((a=l.story)==null?void 0:a.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},K=(n,e)=>{n.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Ve=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:i={},richText:l={},bridgeUrl:a}=n;i.accessToken=i.accessToken||s;const h={bridge:r,apiOptions:i};let d={};o.forEach(b=>{d={...d,...b(h)}}),a&&(M=a);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&p&&G(M),H=new A(l.schema),l.resolver&&K(H,l.resolver),d},Y=n=>{var e;return!n||!((e=n==null?void 0:n.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Je=(n,e,t)=>{let r=t||H;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Y(n)?"":(e&&(r=new A(e.schema),e.resolver&&K(r,e.resolver)),r.render(n,{},!1))},Ke=()=>G(M);exports.BlockTypes=k;exports.MarkTypes=_;exports.RichTextResolver=A;exports.RichTextSchema=V;exports.TextTypes=U;exports.apiPlugin=Me;exports.isRichTextEmpty=Y;exports.loadStoryblokBridge=Ke;exports.registerStoryblokBridge=J;exports.renderRichText=Je;exports.richTextResolver=Ge;exports.storyblokEditable=Ue;exports.storyblokInit=Ve;exports.useStoryblokBridge=J;
24
+ }`),""}optimizeImages(e,t){let r=0,s=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,s=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&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i=`/filters${i}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=r>0||s>0||i.length>0?`${r}x${s}${i}`:"";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,d;const p=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const b={srcset:(h=t.srcset)==null?void 0:h.map(w=>{if(typeof w=="number")return`//${p}/m/${w}x0${i} ${w}w`;if(typeof w=="object"&&w.length===2){let E=0,j=0;return typeof w[0]=="number"&&(E=w[0]),typeof w[1]=="number"&&(j=w[1]),`//${p}/m/${E}x${j}${i} ${E}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(w=>w).join(", ")};let v="";return b.srcset&&(v+=`srcset="${b.srcset}" `),b.sizes&&(v+=`sizes="${b.sizes}" `),a.replace(/<img/g,`<img ${v.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(s=>{t.push(this.renderNode(s))}):e.text?t.push(Pe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let s=`<${r.tag}`;if(r.attrs){for(const n in r.attrs)if(Object.prototype.hasOwnProperty.call(r.attrs,n)){const i=r.attrs[n];i!==null&&(s+=` ${n}="${i}"`)}}return`${s}${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 Ne{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=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const a=new C;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:i,...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((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};s(n)})}}const q="SB-Agent",N={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let x={};const S={};class He{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 r=e.endpoint||t;if(!r){const i=new C().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?r=`${l}://${i(e.region)}/v1`:r=`${l}://${i(e.region)}/v2`}const s=new Headers;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(([i,l])=>{s.set(i,l)}),s.has(q)||(s.set(q,N.defaultAgentName),s.set(N.defaultAgentVersion,N.packageVersion));let n=5;e.oauthToken&&(s.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=le(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new C,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Ne({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})}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,r,s,n){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,s));return this.cacheResponse(e,i,void 0,n)}get(e,t,r){t||(t={});const s=`/${e}`,n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t,r,s){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=r??i.substring(i.lastIndexOf("/")+1),a=1,h=await this.makeRequest(i,t,n,a,s),d=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(a,d),b=>this.makeRequest(i,t,n,b+1,s));return this.helpers.flatMap([h,...p],b=>Object.values(b.data[l]))}post(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t,r))}put(e,t,r){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t,r))}delete(e,t,r){t||(t={});const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t,r))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(i=>i.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,i="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${i}[${a}]`));else if(typeof n=="object")for(const l in n){const a=i?`${i}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);i.push(e.link_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const h=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,h))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)})}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let i=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],i,r);e.story?this.iterateTree(e.story,i,r):e.stories.forEach(l=>{this.iterateTree(l,i,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var h;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return a(d);let p={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),p.data.story||p.data.stories){const v=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${v}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(n,p);const b=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(b&&S[t.token]&&S[t.token]!==p.data.cv&&await this.flushCache(),S[t.token]=p.data.cv),l(p)}catch(d){if(d.response&&d.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(d)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}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(x[e])},getAll(){return Promise.resolve(x)},set(e,t){return x[e]=t,Promise.resolve(void 0)},flush(){return x={},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 Me=(o={})=>{const{apiOptions:e}=o;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 He(e)}},Ue=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function Be(o,e){if(!e)return{src:o,attrs:{}};let t=0,r=0;const s={},n=[];function i(a,h,d,p,b){typeof a!="number"||a<=h||a>=d?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`):b.push(`${p}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.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?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:d,fill:p,format:b,grayscale:v,quality:w,rotate:E}=a||{};h&&i(h,0,100,"blur",n),w&&i(w,0,100,"quality",n),d&&i(d,0,100,"brightness",n),p&&n.push(`fill(${p})`),v&&n.push("grayscale()"),E&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${E})`),b&&["webp","png","jpeg"].includes(b)&&n.push(`format(${b})`)}e.srcset&&(s.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${o}/m/${a}x0/${n.length>0?`filters:${n.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,d]=a;return`${o}/m/${h}x${d}/${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&&(s.sizes=e.sizes.join(", "))}let l=`${o}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:s}}var k=(o=>(o.DOCUMENT="doc",o.HEADING="heading",o.PARAGRAPH="paragraph",o.QUOTE="blockquote",o.OL_LIST="ordered_list",o.UL_LIST="bullet_list",o.LIST_ITEM="list_item",o.CODE_BLOCK="code_block",o.HR="horizontal_rule",o.BR="hard_break",o.IMAGE="image",o.EMOJI="emoji",o.COMPONENT="blok",o.TABLE="table",o.TABLE_ROW="tableRow",o.TABLE_CELL="tableCell",o.TABLE_HEADER="tableHeader",o))(k||{}),_=(o=>(o.BOLD="bold",o.STRONG="strong",o.STRIKE="strike",o.UNDERLINE="underline",o.ITALIC="italic",o.CODE="code",o.LINK="link",o.ANCHOR="anchor",o.STYLED="styled",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.TEXT_STYLE="textStyle",o.HIGHLIGHT="highlight",o))(_||{}),U=(o=>(o.TEXT="text",o))(U||{}),I=(o=>(o.URL="url",o.STORY="story",o.ASSET="asset",o.EMAIL="email",o))(I||{});const ze=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De=(o={})=>Object.keys(o).map(e=>`${e}="${o[e]}"`).join(" "),qe=(o={})=>Object.keys(o).map(e=>`${e}: ${o[e]}`).join("; ");function Fe(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const L=o=>Object.fromEntries(Object.entries(o).filter(([e,t])=>t!==void 0));function F(o,e={},t){const r=De(e),s=r?`${o} ${r}`:o,n=Array.isArray(t)?t.join(""):t||"";if(o){if(ze.includes(o))return`<${s}>`}else return n;return`<${s}>${n}</${o}>`}function Ge(o={}){let e=0;const{renderFn:t=F,textFn:r=Fe,resolvers:s={},optimizeImages:n=!1,keyedResolvers:i=!1}=o,l=t!==F,a=c=>u=>{const f=u.attrs||{};return i&&(f.key=`${c}-${e}`),t(c,f,u.children||null)},h=c=>{const{src:u,alt:f,title:y,srcset:R,sizes:$}=c.attrs||{};let m=u,T={};if(n){const{src:se,attrs:oe}=Be(u,n);m=se,T=oe}i&&(T={...T,key:`img-${e}`});const re={src:m,alt:f,title:y,srcset:R,sizes:$,...T};return t("img",L(re))},d=c=>{const{level:u,...f}=c.attrs||{},y={...f};return i&&(y.key=`h${u}-${e}`),t(`h${u}`,y,c.children)},p=c=>{var u,f,y,R;const $=t("img",{src:(u=c.attrs)==null?void 0:u.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":(y=c.attrs)==null?void 0:y.name,"data-emoji":(R=c.attrs)==null?void 0:R.emoji};return i&&(m.key=`emoji-${e}`),t("span",m,$)},b=c=>t("pre",{...c.attrs,key:`code-${e}`},t("code",{key:`code-${e}`},c.children||"")),v=(c,u=!1)=>({text:f,attrs:y})=>{const{class:R,id:$,...m}=y||{},T=u?{class:R,id:$,style:qe(m)||void 0}:y||{};return i&&(T.key=`${c}-${e}`),t(c,L(T),f)},w=c=>P(c),E=c=>{const{marks:u,...f}=c;return"text"in c?u?u.reduce((y,R)=>w({...R,text:y}),w({...f,children:f.children})):r(f.text):""},j=c=>{const{linktype:u,href:f,anchor:y,...R}=c.attrs||{};let $="";switch(u){case I.ASSET:case I.URL:$=f;break;case I.EMAIL:$=`mailto:${f}`;break;case I.STORY:$=f,y&&($=`${$}#${y}`);break;default:$=f;break}const m={...R};return $&&(m.href=$),i&&(m.key=`a-${e}`),t("a",m,c.text)},W=c=>{var u,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),t("span",{blok:(u=c==null?void 0:c.attrs)==null?void 0:u.body[0],id:(f=c.attrs)==null?void 0:f.id,key:`component-${e}`,style:"display: none"})},X=c=>{const u={};return i&&(u.key=`table-${e}`),t("table",u,c.children)},Q=c=>{const u={};return i&&(u.key=`tr-${e}`),t("tr",u,c.children)},Z=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...$}=c.attrs||{},m={...$};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`td-${e}`),t("td",L(m),c.children)},ee=c=>{const{colspan:u,rowspan:f,colwidth:y,backgroundColor:R,...$}=c.attrs||{},m={...$};u>1&&(m.colspan=u),f>1&&(m.rowspan=f);const T=[];return y&&T.push(`width: ${y}px;`),R&&T.push(`background-color: ${R};`),T.length>0&&(m.style=T.join(" ")),i&&(m.key=`th-${e}`),t("th",L(m),c.children)},te=new Map([[k.DOCUMENT,a("")],[k.HEADING,d],[k.PARAGRAPH,a("p")],[k.UL_LIST,a("ul")],[k.OL_LIST,a("ol")],[k.LIST_ITEM,a("li")],[k.IMAGE,h],[k.EMOJI,p],[k.CODE_BLOCK,b],[k.HR,a("hr")],[k.BR,a("br")],[k.QUOTE,a("blockquote")],[k.COMPONENT,W],[U.TEXT,E],[_.LINK,j],[_.ANCHOR,j],[_.STYLED,v("span",!0)],[_.BOLD,v("strong")],[_.TEXT_STYLE,v("span",!0)],[_.ITALIC,v("em")],[_.UNDERLINE,v("u")],[_.STRIKE,v("s")],[_.CODE,v("code")],[_.SUPERSCRIPT,v("sup")],[_.SUBSCRIPT,v("sub")],[_.HIGHLIGHT,v("mark")],[k.TABLE,X],[k.TABLE_ROW,Q],[k.TABLE_CELL,Z],[k.TABLE_HEADER,ee],...Object.entries(s).map(([c,u])=>[c,u])]);function O(c){e+=1;const u=te.get(c.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";if(c.type==="text")return u(c);const f=c.content?c.content.map(P):void 0;return u({...c,children:f})}function P(c){return c.type==="doc"?l?c.content.map(O):c.content.map(O).join(""):Array.isArray(c)?c.map(O):O(c)}return{render:P}}let H,M="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(o,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),i=n!==null&&+n===o;if(!(!s||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var a;l&&(l.action==="input"&&((a=l.story)==null?void 0:a.id)===o?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===o&&window.location.reload())})})}},K=(o,e)=>{o.addNode("blok",t=>{let r="";return t.attrs.body.forEach(s=>{r+=e(s.component,s)}),{html:r}})},Ve=(o={})=>{var e,t;const{bridge:r,accessToken:s,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||s;const h={bridge:r,apiOptions:i};let d={};n.forEach(b=>{d={...d,...b(h)}}),a&&(M=a);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&p&&G(M),H=new A(l.schema),l.resolver&&K(H,l.resolver),d},Y=o=>{var e;return!o||!((e=o==null?void 0:o.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Je=(o,e,t)=>{let r=t||H;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Y(o)?"":(e&&(r=new A(e.schema),e.resolver&&K(r,e.resolver)),r.render(o,{},!1))},Ke=()=>G(M);exports.BlockTypes=k;exports.MarkTypes=_;exports.RichTextResolver=A;exports.RichTextSchema=V;exports.TextTypes=U;exports.apiPlugin=Me;exports.isRichTextEmpty=Y;exports.loadStoryblokBridge=Ke;exports.registerStoryblokBridge=J;exports.renderRichText=Je;exports.richTextResolver=Ge;exports.storyblokEditable=Ue;exports.storyblokInit=Ve;exports.useStoryblokBridge=J;
@@ -1,5 +1,5 @@
1
1
  let U = !1;
2
- const B = [], F = (n) => new Promise((e, t) => {
2
+ const B = [], F = (o) => new Promise((e, t) => {
3
3
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
4
4
  if (window.location === window.parent.location) {
5
5
  console.warn("You are not in Draft Mode or in the Visual Editor.");
@@ -9,35 +9,35 @@ const B = [], F = (n) => new Promise((e, t) => {
9
9
  }, document.getElementById("storyblok-javascript-bridge")))
10
10
  return;
11
11
  const r = document.createElement("script");
12
- r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
13
- B.forEach((o) => o()), U = !0, e(s);
12
+ r.async = !0, r.src = o, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
13
+ B.forEach((n) => n()), U = !0, e(s);
14
14
  }, document.getElementsByTagName("head")[0].appendChild(r);
15
15
  });
16
- var re = Object.defineProperty, se = (n, e, t) => e in n ? re(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => se(n, typeof e != "symbol" ? e + "" : e, t);
17
- class ne extends Error {
16
+ var re = Object.defineProperty, se = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, g = (o, e, t) => se(o, typeof e != "symbol" ? e + "" : e, t);
17
+ class oe extends Error {
18
18
  constructor(e) {
19
19
  super(e), this.name = "AbortError";
20
20
  }
21
21
  }
22
- function oe(n, e, t) {
22
+ function ne(o, e, t) {
23
23
  if (!Number.isFinite(e))
24
24
  throw new TypeError("Expected `limit` to be a finite number");
25
25
  if (!Number.isFinite(t))
26
26
  throw new TypeError("Expected `interval` to be a finite number");
27
27
  const r = [];
28
- let s = [], o = 0, a = !1;
28
+ let s = [], n = 0, a = !1;
29
29
  const l = async () => {
30
- o++;
30
+ n++;
31
31
  const h = r.shift();
32
32
  if (h)
33
33
  try {
34
- const p = await n(...h.args);
34
+ const p = await o(...h.args);
35
35
  h.resolve(p);
36
36
  } catch (p) {
37
37
  h.reject(p);
38
38
  }
39
39
  const d = setTimeout(() => {
40
- o--, r.length > 0 && l(), s = s.filter((p) => p !== d);
40
+ n--, r.length > 0 && l(), s = s.filter((p) => p !== d);
41
41
  }, t);
42
42
  s.includes(d) || s.push(d);
43
43
  }, i = (...h) => a ? Promise.reject(
@@ -49,11 +49,11 @@ function oe(n, e, t) {
49
49
  resolve: d,
50
50
  reject: p,
51
51
  args: h
52
- }), o < e && l();
52
+ }), n < e && l();
53
53
  });
54
54
  return i.abort = () => {
55
55
  a = !0, s.forEach(clearTimeout), s = [], r.forEach(
56
- (h) => h.reject(() => new ne("Throttle function aborted"))
56
+ (h) => h.reject(() => new oe("Throttle function aborted"))
57
57
  ), r.length = 0;
58
58
  }, i;
59
59
  }
@@ -65,7 +65,7 @@ class L {
65
65
  page: r
66
66
  })), 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) => {
67
67
  const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
68
- return this.arrayFrom(r, (o, a) => a * s + e);
68
+ return this.arrayFrom(r, (n, a) => a * s + e);
69
69
  }), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], [])), g(this, "escapeHTML", function(e) {
70
70
  const t = {
71
71
  "&": "&amp;",
@@ -74,7 +74,7 @@ class L {
74
74
  '"': "&quot;",
75
75
  "'": "&#39;"
76
76
  }, r = /[&<>"']/g, s = new RegExp(r.source);
77
- return e && s.test(e) ? e.replace(r, (o) => t[o]) : e;
77
+ return e && s.test(e) ? e.replace(r, (n) => t[n]) : e;
78
78
  });
79
79
  }
80
80
  /**
@@ -86,10 +86,13 @@ class L {
86
86
  */
87
87
  stringify(e, t, r) {
88
88
  const s = [];
89
- for (const o in e) {
90
- if (!Object.prototype.hasOwnProperty.call(e, o))
89
+ for (const n in e) {
90
+ if (!Object.prototype.hasOwnProperty.call(e, n))
91
91
  continue;
92
- const a = e[o], l = r ? "" : encodeURIComponent(o);
92
+ const a = e[n];
93
+ if (a == null)
94
+ continue;
95
+ const l = r ? "" : encodeURIComponent(n);
93
96
  let i;
94
97
  typeof a == "object" ? i = this.stringify(
95
98
  a,
@@ -105,14 +108,14 @@ class L {
105
108
  * @return {string} The base URL of the region
106
109
  */
107
110
  getRegionURL(e) {
108
- const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
111
+ const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
109
112
  switch (e) {
110
113
  case "us":
111
114
  return r;
112
115
  case "cn":
113
116
  return s;
114
117
  case "ap":
115
- return o;
118
+ return n;
116
119
  case "ca":
117
120
  return a;
118
121
  default:
@@ -120,36 +123,36 @@ class L {
120
123
  }
121
124
  }
122
125
  }
123
- const ae = function(n, e) {
126
+ const ae = function(o, e) {
124
127
  const t = {};
125
- for (const r in n) {
126
- const s = n[r];
128
+ for (const r in o) {
129
+ const s = o[r];
127
130
  e.includes(r) && s !== null && (t[r] = s);
128
131
  }
129
132
  return t;
130
- }, ie = (n) => n === "email", le = () => ({
133
+ }, ie = (o) => o === "email", le = () => ({
131
134
  singleTag: "hr"
132
135
  }), ce = () => ({
133
136
  tag: "blockquote"
134
137
  }), he = () => ({
135
138
  tag: "ul"
136
- }), ue = (n) => ({
139
+ }), ue = (o) => ({
137
140
  tag: [
138
141
  "pre",
139
142
  {
140
143
  tag: "code",
141
- attrs: n.attrs
144
+ attrs: o.attrs
142
145
  }
143
146
  ]
144
147
  }), de = () => ({
145
148
  singleTag: "br"
146
- }), pe = (n) => ({
147
- tag: `h${n.attrs.level}`
148
- }), ge = (n) => ({
149
+ }), pe = (o) => ({
150
+ tag: `h${o.attrs.level}`
151
+ }), ge = (o) => ({
149
152
  singleTag: [
150
153
  {
151
154
  tag: "img",
152
- attrs: ae(n.attrs, ["src", "alt", "title"])
155
+ attrs: ae(o.attrs, ["src", "alt", "title"])
153
156
  }
154
157
  ]
155
158
  }), fe = () => ({
@@ -158,22 +161,22 @@ const ae = function(n, e) {
158
161
  tag: "ol"
159
162
  }), ye = () => ({
160
163
  tag: "p"
161
- }), be = (n) => ({
164
+ }), be = (o) => ({
162
165
  tag: [
163
166
  {
164
167
  tag: "span",
165
168
  attrs: {
166
169
  "data-type": "emoji",
167
- "data-name": n.attrs.name,
168
- emoji: n.attrs.emoji
170
+ "data-name": o.attrs.name,
171
+ emoji: o.attrs.emoji
169
172
  }
170
173
  }
171
174
  ]
172
175
  }), ke = () => ({
173
176
  tag: "b"
174
- }), $e = () => ({
175
- tag: "s"
176
177
  }), ve = () => ({
178
+ tag: "s"
179
+ }), $e = () => ({
177
180
  tag: "u"
178
181
  }), we = () => ({
179
182
  tag: "strong"
@@ -181,13 +184,13 @@ const ae = function(n, e) {
181
184
  tag: "code"
182
185
  }), Re = () => ({
183
186
  tag: "i"
184
- }), _e = (n) => {
185
- if (!n.attrs)
187
+ }), _e = (o) => {
188
+ if (!o.attrs)
186
189
  return {
187
190
  tag: ""
188
191
  };
189
- const e = new L().escapeHTML, t = { ...n.attrs }, { linktype: r = "url" } = n.attrs;
190
- if (delete t.linktype, t.href && (t.href = e(n.attrs.href || "")), ie(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
192
+ const e = new L().escapeHTML, t = { ...o.attrs }, { linktype: r = "url" } = o.attrs;
193
+ if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), ie(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
191
194
  for (const s in t.custom)
192
195
  t[s] = t.custom[s];
193
196
  delete t.custom;
@@ -200,46 +203,46 @@ const ae = function(n, e) {
200
203
  }
201
204
  ]
202
205
  };
203
- }, Ee = (n) => ({
206
+ }, Ee = (o) => ({
204
207
  tag: [
205
208
  {
206
209
  tag: "span",
207
- attrs: n.attrs
210
+ attrs: o.attrs
208
211
  }
209
212
  ]
210
213
  }), Se = () => ({
211
214
  tag: "sub"
212
215
  }), je = () => ({
213
216
  tag: "sup"
214
- }), Ie = (n) => ({
217
+ }), Ie = (o) => ({
215
218
  tag: [
216
219
  {
217
220
  tag: "span",
218
- attrs: n.attrs
221
+ attrs: o.attrs
219
222
  }
220
223
  ]
221
- }), xe = (n) => {
224
+ }), xe = (o) => {
222
225
  var e;
223
- return (e = n.attrs) != null && e.color ? {
226
+ return (e = o.attrs) != null && e.color ? {
224
227
  tag: [
225
228
  {
226
229
  tag: "span",
227
230
  attrs: {
228
- style: `background-color:${n.attrs.color};`
231
+ style: `background-color:${o.attrs.color};`
229
232
  }
230
233
  }
231
234
  ]
232
235
  } : {
233
236
  tag: ""
234
237
  };
235
- }, Ae = (n) => {
238
+ }, Ae = (o) => {
236
239
  var e;
237
- return (e = n.attrs) != null && e.color ? {
240
+ return (e = o.attrs) != null && e.color ? {
238
241
  tag: [
239
242
  {
240
243
  tag: "span",
241
244
  attrs: {
242
- style: `color:${n.attrs.color}`
245
+ style: `color:${o.attrs.color}`
243
246
  }
244
247
  }
245
248
  ]
@@ -262,8 +265,8 @@ const ae = function(n, e) {
262
265
  },
263
266
  marks: {
264
267
  bold: ke,
265
- strike: $e,
266
- underline: ve,
268
+ strike: ve,
269
+ underline: $e,
267
270
  strong: we,
268
271
  code: Te,
269
272
  italic: Re,
@@ -275,7 +278,7 @@ const ae = function(n, e) {
275
278
  highlight: xe,
276
279
  textStyle: Ae
277
280
  }
278
- }, Le = function(n) {
281
+ }, Le = function(o) {
279
282
  const e = {
280
283
  "&": "&amp;",
281
284
  "<": "&lt;",
@@ -283,7 +286,7 @@ const ae = function(n, e) {
283
286
  '"': "&quot;",
284
287
  "'": "&#39;"
285
288
  }, t = /[&<>"']/g, r = new RegExp(t.source);
286
- return n && r.test(n) ? n.replace(t, (s) => e[s]) : n;
289
+ return o && r.test(o) ? o.replace(t, (s) => e[s]) : o;
287
290
  };
288
291
  let z = !1;
289
292
  class C {
@@ -301,8 +304,8 @@ class C {
301
304
  "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/"
302
305
  ), z = !0), e && e.content && Array.isArray(e.content)) {
303
306
  let s = "";
304
- return e.content.forEach((o) => {
305
- s += this.renderNode(o);
307
+ return e.content.forEach((n) => {
308
+ s += this.renderNode(n);
306
309
  }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
307
310
  }
308
311
  return console.warn(
@@ -333,8 +336,8 @@ class C {
333
336
  ), "";
334
337
  }
335
338
  optimizeImages(e, t) {
336
- let r = 0, s = 0, o = "", a = "";
337
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, r = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, s = 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 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
339
+ let r = 0, s = 0, n = "", a = "";
340
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, r = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, s = 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 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
338
341
  const l = r > 0 || s > 0 || a.length > 0 ? `${r}x${s}${a}` : "";
339
342
  return e = e.replace(
340
343
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
@@ -366,15 +369,15 @@ class C {
366
369
  renderNode(e) {
367
370
  const t = [];
368
371
  e.marks && e.marks.forEach((s) => {
369
- const o = this.getMatchingMark(s);
370
- o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
372
+ const n = this.getMatchingMark(s);
373
+ n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
371
374
  });
372
375
  const r = this.getMatchingNode(e);
373
376
  return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((s) => {
374
377
  t.push(this.renderNode(s));
375
378
  }) : e.text ? t.push(Le(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html ? t.push(r.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
376
- const o = this.getMatchingMark(s);
377
- o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
379
+ const n = this.getMatchingMark(s);
380
+ n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
378
381
  }), t.join("");
379
382
  }
380
383
  renderTag(e, t) {
@@ -384,10 +387,10 @@ class C {
384
387
  {
385
388
  let s = `<${r.tag}`;
386
389
  if (r.attrs) {
387
- for (const o in r.attrs)
388
- if (Object.prototype.hasOwnProperty.call(r.attrs, o)) {
389
- const a = r.attrs[o];
390
- a !== null && (s += ` ${o}="${a}"`);
390
+ for (const n in r.attrs)
391
+ if (Object.prototype.hasOwnProperty.call(r.attrs, n)) {
392
+ const a = r.attrs[n];
393
+ a !== null && (s += ` ${n}="${a}"`);
391
394
  }
392
395
  }
393
396
  return `${s}${t}>`;
@@ -472,9 +475,9 @@ class Ce {
472
475
  )}`;
473
476
  } else
474
477
  r = JSON.stringify(this.parameters);
475
- const s = new URL(t), o = new AbortController(), { signal: a } = o;
478
+ const s = new URL(t), n = new AbortController(), { signal: a } = n;
476
479
  let l;
477
- this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
480
+ this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
478
481
  try {
479
482
  const i = await this.fetch(`${s}`, {
480
483
  method: e,
@@ -505,12 +508,12 @@ class Ce {
505
508
  return new Promise((r, s) => {
506
509
  if (t.test(`${e.status}`))
507
510
  return r(e);
508
- const o = {
511
+ const n = {
509
512
  message: e.statusText,
510
513
  status: e.status,
511
514
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
512
515
  };
513
- s(o);
516
+ s(n);
514
517
  });
515
518
  }
516
519
  }
@@ -541,10 +544,10 @@ class Pe {
541
544
  N.defaultAgentVersion,
542
545
  N.packageVersion
543
546
  ));
544
- let o = 5;
545
- e.oauthToken && (s.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(
547
+ let n = 5;
548
+ e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = 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 = ne(
546
549
  this.throttledRequest.bind(this),
547
- o,
550
+ n,
548
551
  1e3
549
552
  ), 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({
550
553
  baseURL: r,
@@ -570,28 +573,28 @@ class Pe {
570
573
  factoryParamOptions(e, t) {
571
574
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
572
575
  }
573
- makeRequest(e, t, r, s, o) {
576
+ makeRequest(e, t, r, s, n) {
574
577
  const a = this.factoryParamOptions(
575
578
  e,
576
579
  this.helpers.getOptionsPage(t, r, s)
577
580
  );
578
- return this.cacheResponse(e, a, void 0, o);
581
+ return this.cacheResponse(e, a, void 0, n);
579
582
  }
580
583
  get(e, t, r) {
581
584
  t || (t = {});
582
- const s = `/${e}`, o = this.factoryParamOptions(s, t);
583
- return this.cacheResponse(s, o, void 0, r);
585
+ const s = `/${e}`, n = this.factoryParamOptions(s, t);
586
+ return this.cacheResponse(s, n, void 0, r);
584
587
  }
585
588
  async getAll(e, t, r, s) {
586
- const o = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = r ?? a.substring(a.lastIndexOf("/") + 1), i = 1, h = await this.makeRequest(
589
+ const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = r ?? a.substring(a.lastIndexOf("/") + 1), i = 1, h = await this.makeRequest(
587
590
  a,
588
591
  t,
589
- o,
592
+ n,
590
593
  i,
591
594
  s
592
- ), d = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
595
+ ), d = h.total ? Math.ceil(h.total / n) : 1, p = await this.helpers.asyncMap(
593
596
  this.helpers.range(i, d),
594
- (b) => this.makeRequest(a, t, o, b + 1, s)
597
+ (b) => this.makeRequest(a, t, n, b + 1, s)
595
598
  );
596
599
  return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[l]));
597
600
  }
@@ -658,7 +661,7 @@ class Pe {
658
661
  _resolveField(e, t, r) {
659
662
  const s = e[t];
660
663
  typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map(
661
- (o) => this.getStoryReference(r, o)
664
+ (n) => this.getStoryReference(r, n)
662
665
  ).filter(Boolean));
663
666
  }
664
667
  /**
@@ -683,8 +686,8 @@ class Pe {
683
686
  this._resolveField(e, t, s);
684
687
  return;
685
688
  }
686
- const o = e.component ? `${e.component}.${t}` : t;
687
- (Array.isArray(r) ? r.includes(o) : r === o) && this._resolveField(e, t, s);
689
+ const n = e.component ? `${e.component}.${t}` : t;
690
+ (Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, s);
688
691
  }
689
692
  /**
690
693
  * Recursively traverses and resolves relations in the story content tree
@@ -693,14 +696,14 @@ class Pe {
693
696
  * @param resolveId - The unique identifier for the current resolution context
694
697
  */
695
698
  iterateTree(e, t, r) {
696
- const s = (o, a = "") => {
697
- if (!(!o || o._stopResolving)) {
698
- if (Array.isArray(o))
699
- o.forEach((l, i) => s(l, `${a}[${i}]`));
700
- else if (typeof o == "object")
701
- for (const l in o) {
699
+ const s = (n, a = "") => {
700
+ if (!(!n || n._stopResolving)) {
701
+ if (Array.isArray(n))
702
+ n.forEach((l, i) => s(l, `${a}[${i}]`));
703
+ else if (typeof n == "object")
704
+ for (const l in n) {
702
705
  const i = a ? `${a}.${l}` : l;
703
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, r), this._insertLinks(o, l, r)), s(o[l], i);
706
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, r), this._insertLinks(n, l, r)), s(n[l], i);
704
707
  }
705
708
  }
706
709
  };
@@ -709,9 +712,9 @@ class Pe {
709
712
  async resolveLinks(e, t, r) {
710
713
  let s = [];
711
714
  if (e.link_uuids) {
712
- const o = e.link_uuids.length, a = [], l = 50;
713
- for (let i = 0; i < o; i += l) {
714
- const h = Math.min(o, i + l);
715
+ const n = e.link_uuids.length, a = [], l = 50;
716
+ for (let i = 0; i < n; i += l) {
717
+ const h = Math.min(n, i + l);
715
718
  a.push(e.link_uuids.slice(i, h));
716
719
  }
717
720
  for (let i = 0; i < a.length; i++)
@@ -728,9 +731,9 @@ class Pe {
728
731
  );
729
732
  } else
730
733
  s = e.links;
731
- s.forEach((o) => {
732
- this.links[r][o.uuid] = {
733
- ...o,
734
+ s.forEach((n) => {
735
+ this.links[r][n.uuid] = {
736
+ ...n,
734
737
  _stopResolving: !0
735
738
  };
736
739
  });
@@ -738,9 +741,9 @@ class Pe {
738
741
  async resolveRelations(e, t, r) {
739
742
  let s = [];
740
743
  if (e.rel_uuids) {
741
- const o = e.rel_uuids.length, a = [], l = 50;
742
- for (let i = 0; i < o; i += l) {
743
- const h = Math.min(o, i + l);
744
+ const n = e.rel_uuids.length, a = [], l = 50;
745
+ for (let i = 0; i < n; i += l) {
746
+ const h = Math.min(n, i + l);
744
747
  a.push(e.rel_uuids.slice(i, h));
745
748
  }
746
749
  for (let i = 0; i < a.length; i++)
@@ -756,9 +759,9 @@ class Pe {
756
759
  });
757
760
  } else
758
761
  s = e.rels;
759
- s && s.length > 0 && s.forEach((o) => {
760
- this.relations[r][o.uuid] = {
761
- ...o,
762
+ s && s.length > 0 && s.forEach((n) => {
763
+ this.relations[r][n.uuid] = {
764
+ ...n,
762
765
  _stopResolving: !0
763
766
  };
764
767
  });
@@ -773,9 +776,9 @@ class Pe {
773
776
  *
774
777
  */
775
778
  async resolveStories(e, t, r) {
776
- var s, o;
779
+ var s, n;
777
780
  let a = [];
778
- if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
781
+ if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
779
782
  for (const l in this.relations[r])
780
783
  this.iterateTree(
781
784
  this.relations[r][l],
@@ -787,9 +790,9 @@ class Pe {
787
790
  }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
788
791
  }
789
792
  async cacheResponse(e, t, r, s) {
790
- const o = this.helpers.stringify({ url: e, params: t }), a = this.cacheProvider();
793
+ const n = this.helpers.stringify({ url: e, params: t }), a = this.cacheProvider();
791
794
  if (t.version === "published" && e !== "/cdn/spaces/me") {
792
- const l = await a.get(o);
795
+ const l = await a.get(n);
793
796
  if (l)
794
797
  return Promise.resolve(l);
795
798
  }
@@ -812,7 +815,7 @@ class Pe {
812
815
  const k = this.resolveCounter = ++this.resolveCounter % 1e3;
813
816
  await this.resolveStories(p.data, t, `${k}`);
814
817
  }
815
- t.version === "published" && e !== "/cdn/spaces/me" && await a.set(o, p);
818
+ t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, p);
816
819
  const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
817
820
  return t.token && p.data.cv && (b && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
818
821
  } catch (d) {
@@ -859,7 +862,6 @@ class Pe {
859
862
  case "custom":
860
863
  if (this.cache.custom)
861
864
  return this.cache.custom;
862
- // eslint-disable-next-line no-fallthrough
863
865
  default:
864
866
  return {
865
867
  get() {
@@ -881,8 +883,8 @@ class Pe {
881
883
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
882
884
  }
883
885
  }
884
- const De = (n = {}) => {
885
- const { apiOptions: e } = n;
886
+ const De = (o = {}) => {
887
+ const { apiOptions: e } = o;
886
888
  if (!e || !e.accessToken) {
887
889
  console.error(
888
890
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
@@ -890,12 +892,12 @@ const De = (n = {}) => {
890
892
  return;
891
893
  }
892
894
  return { storyblokApi: new Pe(e) };
893
- }, qe = (n) => {
894
- if (typeof n != "object" || typeof n._editable > "u")
895
+ }, qe = (o) => {
896
+ if (typeof o != "object" || typeof o._editable > "u")
895
897
  return {};
896
898
  try {
897
899
  const e = JSON.parse(
898
- n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
900
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
899
901
  );
900
902
  return e ? {
901
903
  "data-blok-c": JSON.stringify(e),
@@ -905,38 +907,38 @@ const De = (n = {}) => {
905
907
  return {};
906
908
  }
907
909
  };
908
- function Ne(n, e) {
910
+ function Ne(o, e) {
909
911
  if (!e)
910
- return { src: n, attrs: {} };
912
+ return { src: o, attrs: {} };
911
913
  let t = 0, r = 0;
912
- const s = {}, o = [];
914
+ const s = {}, n = [];
913
915
  function a(i, h, d, p, b) {
914
916
  typeof i != "number" || i <= h || i >= d ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`) : b.push(`${p}(${i})`);
915
917
  }
916
918
  if (typeof e == "object") {
917
919
  if (typeof e.width == "number" && e.width > 0 ? (s.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 ? (s.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
918
920
  const { filters: i } = e || {}, { blur: h, brightness: d, fill: p, format: b, grayscale: k, quality: w, rotate: E } = i || {};
919
- h && a(h, 0, 100, "blur", o), w && a(w, 0, 100, "quality", o), d && a(d, 0, 100, "brightness", o), p && o.push(`fill(${p})`), k && o.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && o.push(`format(${b})`);
921
+ h && a(h, 0, 100, "blur", n), w && a(w, 0, 100, "quality", n), d && a(d, 0, 100, "brightness", n), p && n.push(`fill(${p})`), k && n.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && n.push(`format(${b})`);
920
922
  }
921
923
  e.srcset && (s.srcset = e.srcset.map((i) => {
922
924
  if (typeof i == "number")
923
- return `${n}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
925
+ return `${o}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
924
926
  if (Array.isArray(i) && i.length === 2) {
925
927
  const [h, d] = i;
926
- return `${n}/m/${h}x${d}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
928
+ return `${o}/m/${h}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
927
929
  } else {
928
930
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
929
931
  return;
930
932
  }
931
933
  }).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
932
934
  }
933
- let l = `${n}/m/`;
934
- return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
935
+ let l = `${o}/m/`;
936
+ return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
935
937
  src: l,
936
938
  attrs: s
937
939
  };
938
940
  }
939
- var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), _ = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))(_ || {}), G = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(G || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
941
+ var $ = /* @__PURE__ */ ((o) => (o.DOCUMENT = "doc", o.HEADING = "heading", o.PARAGRAPH = "paragraph", o.QUOTE = "blockquote", o.OL_LIST = "ordered_list", o.UL_LIST = "bullet_list", o.LIST_ITEM = "list_item", o.CODE_BLOCK = "code_block", o.HR = "horizontal_rule", o.BR = "hard_break", o.IMAGE = "image", o.EMOJI = "emoji", o.COMPONENT = "blok", o.TABLE = "table", o.TABLE_ROW = "tableRow", o.TABLE_CELL = "tableCell", o.TABLE_HEADER = "tableHeader", o))($ || {}), _ = /* @__PURE__ */ ((o) => (o.BOLD = "bold", o.STRONG = "strong", o.STRIKE = "strike", o.UNDERLINE = "underline", o.ITALIC = "italic", o.CODE = "code", o.LINK = "link", o.ANCHOR = "anchor", o.STYLED = "styled", o.SUPERSCRIPT = "superscript", o.SUBSCRIPT = "subscript", o.TEXT_STYLE = "textStyle", o.HIGHLIGHT = "highlight", o))(_ || {}), G = /* @__PURE__ */ ((o) => (o.TEXT = "text", o))(G || {}), I = /* @__PURE__ */ ((o) => (o.URL = "url", o.STORY = "story", o.ASSET = "asset", o.EMAIL = "email", o))(I || {});
940
942
  const He = [
941
943
  "area",
942
944
  "base",
@@ -952,35 +954,35 @@ const He = [
952
954
  "source",
953
955
  "track",
954
956
  "wbr"
955
- ], Me = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), Ue = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
956
- function Be(n) {
957
- return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
957
+ ], Me = (o = {}) => Object.keys(o).map((e) => `${e}="${o[e]}"`).join(" "), Ue = (o = {}) => Object.keys(o).map((e) => `${e}: ${o[e]}`).join("; ");
958
+ function Be(o) {
959
+ return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
958
960
  }
959
- const O = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
960
- function q(n, e = {}, t) {
961
- const r = Me(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
962
- if (n) {
963
- if (He.includes(n))
961
+ const O = (o) => Object.fromEntries(Object.entries(o).filter(([e, t]) => t !== void 0));
962
+ function q(o, e = {}, t) {
963
+ const r = Me(e), s = r ? `${o} ${r}` : o, n = Array.isArray(t) ? t.join("") : t || "";
964
+ if (o) {
965
+ if (He.includes(o))
964
966
  return `<${s}>`;
965
- } else return o;
966
- return `<${s}>${o}</${n}>`;
967
+ } else return n;
968
+ return `<${s}>${n}</${o}>`;
967
969
  }
968
- function Fe(n = {}) {
970
+ function Fe(o = {}) {
969
971
  let e = 0;
970
972
  const {
971
973
  renderFn: t = q,
972
974
  textFn: r = Be,
973
975
  resolvers: s = {},
974
- optimizeImages: o = !1,
976
+ optimizeImages: n = !1,
975
977
  keyedResolvers: a = !1
976
- } = n, l = t !== q, i = (c) => (u) => {
978
+ } = o, l = t !== q, i = (c) => (u) => {
977
979
  const f = u.attrs || {};
978
980
  return a && (f.key = `${c}-${e}`), t(c, f, u.children || null);
979
981
  }, h = (c) => {
980
- const { src: u, alt: f, title: y, srcset: R, sizes: $ } = c.attrs || {};
982
+ const { src: u, alt: f, title: y, srcset: R, sizes: v } = c.attrs || {};
981
983
  let m = u, T = {};
982
- if (o) {
983
- const { src: ee, attrs: te } = Ne(u, o);
984
+ if (n) {
985
+ const { src: ee, attrs: te } = Ne(u, n);
984
986
  m = ee, T = te;
985
987
  }
986
988
  a && (T = {
@@ -992,7 +994,7 @@ function Fe(n = {}) {
992
994
  alt: f,
993
995
  title: y,
994
996
  srcset: R,
995
- sizes: $,
997
+ sizes: v,
996
998
  ...T
997
999
  };
998
1000
  return t("img", O(Z));
@@ -1003,7 +1005,7 @@ function Fe(n = {}) {
1003
1005
  return a && (y.key = `h${u}-${e}`), t(`h${u}`, y, c.children);
1004
1006
  }, p = (c) => {
1005
1007
  var u, f, y, R;
1006
- const $ = t("img", {
1008
+ const v = t("img", {
1007
1009
  src: (u = c.attrs) == null ? void 0 : u.fallbackImage,
1008
1010
  alt: (f = c.attrs) == null ? void 0 : f.alt,
1009
1011
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
@@ -1014,14 +1016,14 @@ function Fe(n = {}) {
1014
1016
  "data-name": (y = c.attrs) == null ? void 0 : y.name,
1015
1017
  "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1016
1018
  };
1017
- return a && (m.key = `emoji-${e}`), t("span", m, $);
1019
+ return a && (m.key = `emoji-${e}`), t("span", m, v);
1018
1020
  }, b = (c) => t("pre", {
1019
1021
  ...c.attrs,
1020
1022
  key: `code-${e}`
1021
1023
  }, t("code", { key: `code-${e}` }, c.children || "")), k = (c, u = !1) => ({ text: f, attrs: y }) => {
1022
- const { class: R, id: $, ...m } = y || {}, T = u ? {
1024
+ const { class: R, id: v, ...m } = y || {}, T = u ? {
1023
1025
  class: R,
1024
- id: $,
1026
+ id: v,
1025
1027
  style: Ue(m) || void 0
1026
1028
  } : y || {};
1027
1029
  return a && (T.key = `${c}-${e}`), t(c, O(T), f);
@@ -1035,24 +1037,24 @@ function Fe(n = {}) {
1035
1037
  ) : r(f.text) : "";
1036
1038
  }, j = (c) => {
1037
1039
  const { linktype: u, href: f, anchor: y, ...R } = c.attrs || {};
1038
- let $ = "";
1040
+ let v = "";
1039
1041
  switch (u) {
1040
1042
  case I.ASSET:
1041
1043
  case I.URL:
1042
- $ = f;
1044
+ v = f;
1043
1045
  break;
1044
1046
  case I.EMAIL:
1045
- $ = `mailto:${f}`;
1047
+ v = `mailto:${f}`;
1046
1048
  break;
1047
1049
  case I.STORY:
1048
- $ = f, y && ($ = `${$}#${y}`);
1050
+ v = f, y && (v = `${v}#${y}`);
1049
1051
  break;
1050
1052
  default:
1051
- $ = f;
1053
+ v = f;
1052
1054
  break;
1053
1055
  }
1054
1056
  const m = { ...R };
1055
- return $ && (m.href = $), a && (m.key = `a-${e}`), t("a", m, c.text);
1057
+ return v && (m.href = v), a && (m.key = `a-${e}`), t("a", m, c.text);
1056
1058
  }, J = (c) => {
1057
1059
  var u, f;
1058
1060
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
@@ -1068,33 +1070,33 @@ function Fe(n = {}) {
1068
1070
  const u = {};
1069
1071
  return a && (u.key = `tr-${e}`), t("tr", u, c.children);
1070
1072
  }, W = (c) => {
1071
- const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1072
- ...$
1073
+ const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, m = {
1074
+ ...v
1073
1075
  };
1074
1076
  u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1075
1077
  const T = [];
1076
1078
  return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `td-${e}`), t("td", O(m), c.children);
1077
1079
  }, X = (c) => {
1078
- const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1079
- ...$
1080
+ const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...v } = c.attrs || {}, m = {
1081
+ ...v
1080
1082
  };
1081
1083
  u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1082
1084
  const T = [];
1083
1085
  return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `th-${e}`), t("th", O(m), c.children);
1084
1086
  }, Q = new Map([
1085
- [v.DOCUMENT, i("")],
1086
- [v.HEADING, d],
1087
- [v.PARAGRAPH, i("p")],
1088
- [v.UL_LIST, i("ul")],
1089
- [v.OL_LIST, i("ol")],
1090
- [v.LIST_ITEM, i("li")],
1091
- [v.IMAGE, h],
1092
- [v.EMOJI, p],
1093
- [v.CODE_BLOCK, b],
1094
- [v.HR, i("hr")],
1095
- [v.BR, i("br")],
1096
- [v.QUOTE, i("blockquote")],
1097
- [v.COMPONENT, J],
1087
+ [$.DOCUMENT, i("")],
1088
+ [$.HEADING, d],
1089
+ [$.PARAGRAPH, i("p")],
1090
+ [$.UL_LIST, i("ul")],
1091
+ [$.OL_LIST, i("ol")],
1092
+ [$.LIST_ITEM, i("li")],
1093
+ [$.IMAGE, h],
1094
+ [$.EMOJI, p],
1095
+ [$.CODE_BLOCK, b],
1096
+ [$.HR, i("hr")],
1097
+ [$.BR, i("br")],
1098
+ [$.QUOTE, i("blockquote")],
1099
+ [$.COMPONENT, J],
1098
1100
  [G.TEXT, E],
1099
1101
  [_.LINK, j],
1100
1102
  [_.ANCHOR, j],
@@ -1108,10 +1110,10 @@ function Fe(n = {}) {
1108
1110
  [_.SUPERSCRIPT, k("sup")],
1109
1111
  [_.SUBSCRIPT, k("sub")],
1110
1112
  [_.HIGHLIGHT, k("mark")],
1111
- [v.TABLE, K],
1112
- [v.TABLE_ROW, Y],
1113
- [v.TABLE_CELL, W],
1114
- [v.TABLE_HEADER, X],
1113
+ [$.TABLE, K],
1114
+ [$.TABLE_ROW, Y],
1115
+ [$.TABLE_CELL, W],
1116
+ [$.TABLE_HEADER, X],
1115
1117
  ...Object.entries(s).map(([c, u]) => [c, u])
1116
1118
  ]);
1117
1119
  function x(c) {
@@ -1136,25 +1138,25 @@ function Fe(n = {}) {
1136
1138
  };
1137
1139
  }
1138
1140
  let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1139
- const Ge = (n, e, t = {}) => {
1141
+ const Ge = (o, e, t = {}) => {
1140
1142
  var r;
1141
- const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
1143
+ const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
1142
1144
  "_storyblok"
1143
- ), a = o !== null && +o === n;
1145
+ ), a = n !== null && +n === o;
1144
1146
  if (!(!s || !a)) {
1145
- if (!n) {
1147
+ if (!o) {
1146
1148
  console.warn("Story ID is not defined. Please provide a valid ID.");
1147
1149
  return;
1148
1150
  }
1149
1151
  window.storyblokRegisterEvent(() => {
1150
1152
  new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
1151
1153
  var i;
1152
- l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === n ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === n && window.location.reload());
1154
+ l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === o ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === o && window.location.reload());
1153
1155
  });
1154
1156
  });
1155
1157
  }
1156
- }, V = (n, e) => {
1157
- n.addNode("blok", (t) => {
1158
+ }, V = (o, e) => {
1159
+ o.addNode("blok", (t) => {
1158
1160
  let r = "";
1159
1161
  return t.attrs.body.forEach((s) => {
1160
1162
  r += e(s.component, s);
@@ -1162,28 +1164,28 @@ const Ge = (n, e, t = {}) => {
1162
1164
  html: r
1163
1165
  };
1164
1166
  });
1165
- }, Ve = (n = {}) => {
1167
+ }, Ve = (o = {}) => {
1166
1168
  var e, t;
1167
1169
  const {
1168
1170
  bridge: r,
1169
1171
  accessToken: s,
1170
- use: o = [],
1172
+ use: n = [],
1171
1173
  apiOptions: a = {},
1172
1174
  richText: l = {},
1173
1175
  bridgeUrl: i
1174
- } = n;
1176
+ } = o;
1175
1177
  a.accessToken = a.accessToken || s;
1176
1178
  const h = { bridge: r, apiOptions: a };
1177
1179
  let d = {};
1178
- o.forEach((b) => {
1180
+ n.forEach((b) => {
1179
1181
  d = { ...d, ...b(h) };
1180
1182
  }), i && (M = i);
1181
1183
  const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1182
1184
  return r !== !1 && p && F(M), H = new C(l.schema), l.resolver && V(H, l.resolver), d;
1183
- }, ze = (n) => {
1185
+ }, ze = (o) => {
1184
1186
  var e;
1185
- return !n || !((e = n == null ? void 0 : n.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1186
- }, Je = (n, e, t) => {
1187
+ return !o || !((e = o == null ? void 0 : o.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1188
+ }, Je = (o, e, t) => {
1187
1189
  let r = t || H;
1188
1190
  if (!r) {
1189
1191
  console.error(
@@ -1191,10 +1193,10 @@ const Ge = (n, e, t = {}) => {
1191
1193
  );
1192
1194
  return;
1193
1195
  }
1194
- return ze(n) ? "" : (e && (r = new C(e.schema), e.resolver && V(r, e.resolver)), r.render(n, {}, !1));
1196
+ return ze(o) ? "" : (e && (r = new C(e.schema), e.resolver && V(r, e.resolver)), r.render(o, {}, !1));
1195
1197
  }, Ke = () => F(M);
1196
1198
  export {
1197
- v as BlockTypes,
1199
+ $ as BlockTypes,
1198
1200
  _ as MarkTypes,
1199
1201
  C as RichTextResolver,
1200
1202
  Oe as RichTextSchema,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@storyblok/react",
3
3
  "type": "module",
4
- "version": "4.5.2",
4
+ "version": "4.5.4",
5
5
  "private": false,
6
- "packageManager": "pnpm@10.2.0",
6
+ "packageManager": "pnpm@10.7.0",
7
7
  "description": "SDK to integrate Storyblok into your project using React.",
8
8
  "author": "Storyblok",
9
9
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "react-dom": "^17 || ^18 || ^19"
60
60
  },
61
61
  "dependencies": {
62
- "@storyblok/js": "3.3.0"
62
+ "@storyblok/js": "3.3.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@babel/core": "^7.26.7",
@@ -85,13 +85,14 @@
85
85
  "simple-git-hooks": "^2.11.1",
86
86
  "start-server-and-test": "^2.0.10",
87
87
  "typescript": "5.7.3",
88
- "vite": "^6.1.0",
88
+ "vite": "^5.4.16",
89
89
  "vite-plugin-dts": "^4.5.0",
90
90
  "vitest": "^3.0.5"
91
91
  },
92
92
  "pnpm": {
93
93
  "onlyBuiltDependencies": [
94
- "cypress"
94
+ "cypress",
95
+ "simple-git-hooks"
95
96
  ]
96
97
  },
97
98
  "babel": {