@storyblok/astro 9.0.10 → 9.0.11
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.
|
@@ -38603,7 +38603,7 @@ var gj = class {
|
|
|
38603
38603
|
const a = new Headers();
|
|
38604
38604
|
!t.oauthToken && typeof window < "u" || a.set("Content-Type", "application/json"), a.set("Accept", "application/json"), t.headers && (t.headers.constructor.name === "Headers" ? t.headers.entries().toArray() : Object.entries(t.headers)).forEach(([n, s]) => {
|
|
38605
38605
|
a.set(n, s);
|
|
38606
|
-
}), t.oauthToken && a.set("Authorization", t.oauthToken), this.rateLimitConfig = cj(t.rateLimit, !!t.oauthToken), this.maxRetries = t.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new dj(this.throttledRequest.bind(this), 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.cvMode = t.cache?.cv ?? "auto", this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || sj.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new nj({
|
|
38606
|
+
}), t.oauthToken && a.set("Authorization", t.oauthToken), this.rateLimitConfig = cj(t.rateLimit, !!t.oauthToken), this.maxRetries = t.maxRetries || 10, this.retriesDelay = t.retriesDelay ?? 300, this.throttleManager = new dj(this.throttledRequest.bind(this), 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.cvMode = t.cache?.cv ?? "auto", this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || sj.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new nj({
|
|
38607
38607
|
baseURL: o,
|
|
38608
38608
|
timeout: t.timeout || 0,
|
|
38609
38609
|
headers: a,
|
|
@@ -140,4 +140,4 @@ ${o}
|
|
|
140
140
|
`,V1="️",K1="",Os="";let Ha=null,qa=null;function J1(t=[]){const e={};je.groups=e;const o=new je;Ha==null&&(Ha=xp($1)),qa==null&&(qa=xp(P1)),y(o,"'",xa),y(o,"{",co),y(o,"}",mo),y(o,"[",fa),y(o,"]",ha),y(o,"(",ba),y(o,")",ja),y(o,"<",va),y(o,">",ka),y(o,"(",ya),y(o,")",Fa),y(o,"「",_a),y(o,"」",Da),y(o,"『",wa),y(o,"』",Ia),y(o,"<",Ca),y(o,">",Ea),y(o,"&",Aa),y(o,"*",Sa),y(o,"@",it),y(o,"`",Ma),y(o,"^",Ba),y(o,":",rt),y(o,",",Ts),y(o,"$",Ra),y(o,".",Be),y(o,"=",La),y(o,"!",Ms),y(o,"-",we),y(o,"%",uo),y(o,"|",Na),y(o,"+",za),y(o,"#",Oa),y(o,"?",go),y(o,'"',Bs),y(o,"/",Re),y(o,";",Rs),y(o,"~",fo),y(o,"_",$a),y(o,"\\",Ta),y(o,"・",wp);const a=X(o,qe,As,{[ys]:!0});X(a,qe,a);const n=X(a,He,_p,{[ro]:!0}),s=X(a,ho,Dp,{[lo]:!0}),i=X(o,He,Pe,{[Fs]:!0});X(i,qe,n),X(i,He,i),X(n,qe,n),X(n,He,n);const r=X(o,ho,Is,{[_s]:!0});X(r,He),X(r,qe,s),X(r,ho,r),X(s,qe,s),X(s,He),X(s,ho,s);const l=y(o,zs,Ss,{[ws]:!0}),p=y(o,Ep,xs,{[ws]:!0}),c=X(o,Ns,xs,{[ws]:!0});y(o,Os,c),y(p,zs,l),y(p,Os,c),X(p,Ns,c),y(c,Ep),y(c,zs),X(c,Ns,c),y(c,Os,c);const m=X(o,Ls,Ip,{[yp]:!0});y(m,"#"),X(m,Ls,m),y(m,V1,m);const u=y(m,K1);y(u,"#"),X(u,Ls,m);const d=[[He,i],[qe,n]],g=[[He,null],[ho,r],[qe,s]];for(let f=0;f<Ha.length;f++)lt(o,Ha[f],Cs,Pe,d);for(let f=0;f<qa.length;f++)lt(o,qa[f],Es,Is,g);wt(Cs,{tld:!0,ascii:!0},e),wt(Es,{utld:!0,alpha:!0},e),lt(o,"file",ga,Pe,d),lt(o,"mailto",ga,Pe,d),lt(o,"http",Ot,Pe,d),lt(o,"https",Ot,Pe,d),lt(o,"ftp",Ot,Pe,d),lt(o,"ftps",Ot,Pe,d),wt(ga,{scheme:!0,ascii:!0},e),wt(Ot,{slashscheme:!0,ascii:!0},e),t=t.sort((f,h)=>f[0]>h[0]?1:-1);for(let f=0;f<t.length;f++){const h=t[f][0],k=t[f][1]?{[H1]:!0}:{[q1]:!0};h.indexOf("-")>=0?k[Ds]=!0:He.test(h)?qe.test(h)?k[ro]=!0:k[Fs]=!0:k[ys]=!0,Fp(o,h,h,k)}return Fp(o,"localhost",po,{ascii:!0}),o.jd=new je(Pa),{start:o,tokens:Object.assign({groups:e},Cp)}}function Ap(t,e){const o=G1(e.replace(/[A-Z]/g,r=>r.toLowerCase())),a=o.length,n=[];let s=0,i=0;for(;i<a;){let r=t,l=null,p=0,c=null,m=-1,u=-1;for(;i<a&&(l=r.go(o[i]));)r=l,r.accepts()?(m=0,u=0,c=r):m>=0&&(m+=o[i].length,u++),p+=o[i].length,s+=o[i].length,i++;s-=m,i-=u,p-=m,n.push({t:c.t,v:e.slice(s-p,s),s:s-p,e:s})}return n}function G1(t){const e=[],o=t.length;let a=0;for(;a<o;){let n=t.charCodeAt(a),s,i=n<55296||n>56319||a+1===o||(s=t.charCodeAt(a+1))<56320||s>57343?t[a]:t.slice(a,a+2);e.push(i),a+=i.length}return e}function lt(t,e,o,a,n){let s;const i=e.length;for(let r=0;r<i-1;r++){const l=e[r];t.j[l]?s=t.j[l]:(s=new je(a),s.jr=n.slice(),t.j[l]=s),t=s}return s=new je(o),s.jr=n.slice(),t.j[e[i-1]]=s,s}function xp(t){const e=[],o=[];let a=0,n="0123456789";for(;a<t.length;){let s=0;for(;n.indexOf(t[a+s])>=0;)s++;if(s>0){e.push(o.join(""));for(let i=parseInt(t.substring(a,a+s),10);i>0;i--)o.pop();a+=s}else o.push(t[a]),a++}return e}const bo={defaultProtocol:"http",events:null,format:Sp,formatHref:Sp,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function $s(t,e=null){let o=Object.assign({},bo);t&&(o=Object.assign(o,t instanceof $s?t.o:t));const a=o.ignoreTags,n=[];for(let s=0;s<a.length;s++)n.push(a[s].toUpperCase());this.o=o,e&&(this.defaultRender=e),this.ignoreTags=n}$s.prototype={o:bo,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,o){const a=e!=null;let n=this.o[t];return n&&(typeof n=="object"?(n=o.t in n?n[o.t]:bo[t],typeof n=="function"&&a&&(n=n(e,o))):typeof n=="function"&&a&&(n=n(e,o.t,o)),n)},getObj(t,e,o){let a=this.o[t];return typeof a=="function"&&e!=null&&(a=a(e,o.t,o)),a},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Sp(t){return t}function Tp(t,e){this.t="token",this.v=t,this.tk=e}Tp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),o=t.get("truncate",e,this),a=t.get("format",e,this);return o&&a.length>o?a.substring(0,o)+"…":a},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=bo.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,o=this.toHref(t.get("defaultProtocol")),a=t.get("formatHref",o,this),n=t.get("tagName",o,e),s=this.toFormattedString(t),i={},r=t.get("className",o,e),l=t.get("target",o,e),p=t.get("rel",o,e),c=t.getObj("attributes",o,e),m=t.getObj("events",o,e);return i.href=a,r&&(i.class=r),l&&(i.target=l),p&&(i.rel=p),c&&Object.assign(i,c),{tagName:n,attributes:i,content:s,eventListeners:m}}};function Wa(t,e){class o extends Tp{constructor(n,s){super(n,s),this.t=t}}for(const a in e)o.prototype[a]=e[a];return o.t=t,o}const Mp=Wa("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Bp=Wa("text"),X1=Wa("nl"),Ua=Wa("url",{isLink:!0,toHref(t=bo.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==po&&t[1].t===rt}}),Ie=t=>new je(t);function Y1({groups:t}){const e=t.domain.concat([Aa,Sa,it,Ta,Ma,Ba,Ra,La,we,As,uo,Na,za,Oa,Re,Pa,fo,$a]),o=[xa,rt,Ts,Be,Ms,uo,go,Bs,Rs,va,ka,co,mo,ha,fa,ba,ja,ya,Fa,_a,Da,wa,Ia,Ca,Ea],a=[Aa,xa,Sa,Ta,Ma,Ba,Ra,La,we,co,mo,uo,Na,za,Oa,go,Re,Pa,fo,$a],n=Ie(),s=y(n,fo);N(s,a,s),N(s,t.domain,s);const i=Ie(),r=Ie(),l=Ie();N(n,t.domain,i),N(n,t.scheme,r),N(n,t.slashscheme,l),N(i,a,s),N(i,t.domain,i);const p=y(i,it);y(s,it,p),y(r,it,p),y(l,it,p);const c=y(s,Be);N(c,a,s),N(c,t.domain,s);const m=Ie();N(p,t.domain,m),N(m,t.domain,m);const u=y(m,Be);N(u,t.domain,m);const d=Ie(Mp);N(u,t.tld,d),N(u,t.utld,d),y(p,po,d);const g=y(m,we);y(g,we,g),N(g,t.domain,m),N(d,t.domain,m),y(d,Be,u),y(d,we,g);const f=y(d,rt);N(f,t.numeric,Mp);const h=y(i,we),b=y(i,Be);y(h,we,h),N(h,t.domain,i),N(b,a,s),N(b,t.domain,i);const k=Ie(Ua);N(b,t.tld,k),N(b,t.utld,k),N(k,t.domain,i),N(k,a,s),y(k,Be,b),y(k,we,h),y(k,it,p);const j=y(k,rt),F=Ie(Ua);N(j,t.numeric,F);const _=Ie(Ua),I=Ie();N(_,e,_),N(_,o,I),N(I,e,_),N(I,o,I),y(k,Re,_),y(F,Re,_);const E=y(r,rt),L=y(l,rt),z=y(L,Re),C=y(z,Re);N(r,t.domain,i),y(r,Be,b),y(r,we,h),N(l,t.domain,i),y(l,Be,b),y(l,we,h),N(E,t.domain,_),y(E,Re,_),y(E,go,_),N(C,t.domain,_),N(C,e,_),y(C,Re,_);const R=[[co,mo],[fa,ha],[ba,ja],[va,ka],[ya,Fa],[_a,Da],[wa,Ia],[Ca,Ea]];for(let q=0;q<R.length;q++){const[T,M]=R[q],O=y(_,T);y(I,T,O),y(O,M,_);const Y=Ie(Ua);N(O,e,Y);const ue=Ie();N(O,o),N(Y,e,Y),N(Y,o,ue),N(ue,e,Y),N(ue,o,ue),y(Y,M,_),y(ue,M,_)}return y(n,po,k),y(n,Ss,X1),{start:n,tokens:Cp}}function Z1(t,e,o){let a=o.length,n=0,s=[],i=[];for(;n<a;){let r=t,l=null,p=null,c=0,m=null,u=-1;for(;n<a&&!(l=r.go(o[n].t));)i.push(o[n++]);for(;n<a&&(p=l||r.go(o[n].t));)l=null,r=p,r.accepts()?(u=0,m=r):u>=0&&u++,n++,c++;if(u<0)n-=c,n<a&&(i.push(o[n]),n++);else{i.length>0&&(s.push(Ps(Bp,e,i)),i=[]),n-=u,c-=u;const d=m.t,g=o.slice(n-c,n);s.push(Ps(d,e,g))}}return i.length>0&&s.push(Ps(Bp,e,i)),s}function Ps(t,e,o){const a=o[0].s,n=o[o.length-1].e,s=e.slice(a,n);return new t(s,o)}const Q1=typeof console<"u"&&console&&console.warn||(()=>{}),eb="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function tb(){return je.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function Rp(t,e=!1){if(V.initialized&&Q1(`linkifyjs: already initialized - will not register custom scheme "${t}" ${eb}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
141
141
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
142
142
|
2. Cannot start or end with "-"
|
|
143
|
-
3. "-" cannot repeat`);V.customSchemes.push([t,e])}function ob(){V.scanner=J1(V.customSchemes);for(let t=0;t<V.tokenQueue.length;t++)V.tokenQueue[t][1]({scanner:V.scanner});V.parser=Y1(V.scanner.tokens);for(let t=0;t<V.pluginQueue.length;t++)V.pluginQueue[t][1]({scanner:V.scanner,parser:V.parser});return V.initialized=!0,V}function Hs(t){return V.initialized||ob(),Z1(V.parser.start,t,Ap(V.scanner.start,t))}Hs.scan=Ap;function Lp(t,e=null,o=null){if(e&&typeof e=="object"){if(o)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);o=e,e=null}const a=new $s(o),n=Hs(t),s=[];for(let i=0;i<n.length;i++){const r=n[i];r.isLink&&(!e||r.t===e)&&a.check(r)&&s.push(r.toFormattedObject(a))}return s}var qs="[\0- -\u2029 ]",ab=new RegExp(qs),nb=new RegExp(`${qs}$`),sb=new RegExp(qs,"g");function ib(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function rb(t){return new le({key:new oe("autolink"),appendTransaction:(e,o,a)=>{const n=e.some(p=>p.docChanged)&&!o.doc.eq(a.doc),s=e.some(p=>p.getMeta("preventAutolink"));if(!n||s)return;const{tr:i}=a,r=Wn(o.doc,[...e]);if(Vn(r).forEach(({newRange:p})=>{const c=yl(a.doc,p,d=>d.isTextblock);let m,u;if(c.length>1)m=c[0],u=a.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(c.length){const d=a.doc.textBetween(p.from,p.to," "," ");if(!nb.test(d))return;m=c[0],u=a.doc.textBetween(m.pos,p.to,void 0," ")}if(m&&u){const d=u.split(ab).filter(Boolean);if(d.length<=0)return!1;const g=d[d.length-1],f=m.pos+u.lastIndexOf(g);if(!g)return!1;const h=Hs(g).map(b=>b.toObject(t.defaultProtocol));if(!ib(h))return!1;h.filter(b=>b.isLink).map(b=>({...b,from:f+b.start+1,to:f+b.end+1})).filter(b=>a.schema.marks.code?!a.doc.rangeHasMark(b.from,b.to,a.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Kn(b.from,b.to,a.doc).some(k=>k.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function lb(t){return new le({key:new oe("handleClickLink"),props:{handleClick:(e,o,a)=>{var n,s;if(a.button!==0||!e.editable)return!1;let i=null;if(a.target instanceof HTMLAnchorElement)i=a.target;else{const l=a.target;if(!l)return!1;const p=t.editor.view.dom;i=l.closest("a"),i&&!p.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(t.enableClickSelection&&(r=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=cg(e.state,t.type.name),p=(n=i.href)!=null?n:l.href,c=(s=i.target)!=null?s:l.target;p&&(window.open(p,c),r=!0)}return r}}})}function pb(t){return new le({key:new oe("handlePasteLink"),props:{handlePaste:(e,o,a)=>{const{shouldAutoLink:n}=t,{state:s}=e,{selection:i}=s,{empty:r}=i;if(r)return!1;let l="";a.content.forEach(c=>{l+=c.textContent});const p=Lp(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!p||n!==void 0&&!n(p.value)?!1:t.editor.commands.setMark(t.type,{href:p.href})}}})}function It(t,e){const o=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(a=>{const n=typeof a=="string"?a:a.scheme;n&&o.push(n)}),!t||t.replace(sb,"").match(new RegExp(`^(?:(?:${o.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var cb=be.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Rp(t);return}Rp(t.scheme,t.optionalSlashes)})},onDestroy(){tb()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!It(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),o=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||o&&!t.includes("@"))return!0;const n=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(n)||!/\./.test(n))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:o=>!!It(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!It(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var o,a,n,s;const i=(a=(o=t.attrs)==null?void 0:o.href)!=null?a:"",r=(s=(n=t.attrs)==null?void 0:n.title)!=null?s:"",l=e.renderChildren(t);return r?`[${l}](${i} "${r}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:o}=t;return this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:o}=t||{};return o&&!this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[nt({find:t=>{const e=[];if(t){const{protocols:o,defaultProtocol:a}=this.options,n=Lp(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!It(i,o),protocols:o,defaultProtocol:a}));n.length&&n.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:o}=this.options;return this.options.autolink&&t.push(rb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:a=>this.options.isAllowedUri(a,{defaultValidate:n=>!!It(n,e),protocols:e,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink})),t.push(lb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(pb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),mb=cb,ub=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,db=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gb=be.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ft({find:ub,type:this.type})]},addPasteRules(){return[nt({find:db,type:this.type})]}}),fb=gb,hb=be.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),bb=hb,jb=be.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),vb=jb,kb=20,Np=(t,e=0)=>{const o=[];return!t.children.length||e>kb||Array.from(t.children).forEach(a=>{a.tagName==="SPAN"?o.push(a):a.children.length&&o.push(...Np(a,e+1))}),o},yb=t=>{if(!t.children.length)return;const e=Np(t);e&&e.forEach(o=>{var a,n;const s=o.getAttribute("style"),i=(n=(a=o.parentElement)==null?void 0:a.closest("span"))==null?void 0:n.getAttribute("style");o.setAttribute("style",`${i};${s}`)})},Fb=be.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&yb(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",H(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(o,a)=>{if(o.isTextblock)return!0;o.marks.filter(n=>n.type===this.type).some(n=>Object.values(n.attrs).some(s=>!!s))||t.removeMark(a,a+o.nodeSize,this.type)}),!0}}}}),_b=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="background-color")return r.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Db=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="color")return r.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),wb=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Ib=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Cb=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(_b.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Db.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(wb.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(Ib.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Cb.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Fb.configure(this.options.textStyle)),t}});var Eb=be.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,o){const n=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!n)return;const s=n[2].trim();return{type:"underline",raw:n[0],text:s,tokens:o.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Ab=Eb;function xb(t,e){if(!e)return{src:t,attrs:{}};let o=0,a=0;const n={},s=[];function i(l,p,c,m,u){typeof l!="number"||l<=p||l>=c?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${p} and ${c} (inclusive)`):u.push(`${m}(${l})`)}if(typeof e=="object"){if(e.width!==void 0&&(typeof e.width=="number"&&e.width>=0?(n.width=e.width,o=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),e.height!==void 0&&(typeof e.height=="number"&&e.height>=0?(n.height=e.height,a=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),e.height===0&&e.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),e.loading&&["lazy","eager"].includes(e.loading)&&(n.loading=e.loading),e.class&&(n.class=e.class),e.filters){const{filters:l}=e||{},{blur:p,brightness:c,fill:m,format:u,grayscale:d,quality:g,rotate:f}=l||{};p&&i(p,0,100,"blur",s),g&&i(g,0,100,"quality",s),c&&i(c,0,100,"brightness",s),m&&s.push(`fill(${m})`),d&&s.push("grayscale()"),f&&[0,90,180,270].includes(e.filters.rotate||0)&&s.push(`rotate(${f})`),u&&["webp","png","jpeg"].includes(u)&&s.push(`format(${u})`)}e.srcset&&(n.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${t}/m/${l}x0/${s.length>0?`filters:${s.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[p,c]=l;return`${t}/m/${p}x${c}/${s.length>0?`filters:${s.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(n.sizes=e.sizes.join(", "))}let r=`${t}/m/`;return(o>0||a>0)&&(r=`${r}${o}x${a}/`),s.length>0&&(r=`${r}filters:${s.join(":")}`),{src:r,attrs:n}}function Ws(t,e){if(t===e)return!0;if(t==null||e===null||e===void 0)return t===e;if(typeof t!=typeof e||typeof t!="object"||Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t))return t.length!==e.length?!1:t.every((n,s)=>Ws(n,e[s]));const o=Object.keys(t),a=Object.keys(e);return o.length!==a.length?!1:o.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&Ws(t[n],e[n]))}function zp(t,e){return t.type===e.type&&Ws(t.attrs,e.attrs)}function Op(t){return t.type==="text"&&!!t.marks?.length}function Sb(t,e){const o=t.filter(a=>!e.some(n=>zp(n,a)));return o.length?o:void 0}function Tb(t,e){const o=t[e];if(!Op(o))return null;const a=[o];let n=o.marks,s=e+1;for(;s<t.length;){const i=t[s];if(!Op(i))break;const r=n.filter(l=>i.marks.some(p=>zp(l,p)));if(r.length===0)break;n=r,a.push(i),s++}return{group:a,shared:n,endIndex:s}}const Mb=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Bb=(t={})=>{const{custom:e,...o}=t,a={...o,...e};return Object.keys(a).filter(n=>a[n]!=null).map(n=>`${n}="${String(a[n]).replace(/&/g,"&").replace(/"/g,""")}"`).join(" ")},$p=(t={})=>Object.keys(t).map(e=>`${e}: ${t[e]}`).join("; ");function Rb(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ct=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));let Va=(function(t){return t.URL="url",t.STORY="story",t.ASSET="asset",t.EMAIL="email",t})({});function We(t={}){const{textAlign:e,class:o,id:a,style:n,...s}=t,i=[];return n&&i.push(n.endsWith(";")?n:`${n};`),e&&i.push(`text-align: ${e};`),Ct({...s,class:o,id:a,...i.length>0?{style:i.join(" ")}:{}})}function Lb(t={}){const{linktype:e,href:o,anchor:a,uuid:n,custom:s,...i}=t;let r=o??"";switch(e){case Va.ASSET:case Va.URL:break;case Va.EMAIL:r&&!r.startsWith("mailto:")&&(r=`mailto:${r}`);break;case Va.STORY:a&&(r=`${r}#${a}`);break}return{href:r,rest:{...i,...s||{}}}}function Pp(t={}){const{colspan:e,rowspan:o,colwidth:a,backgroundColor:n,textAlign:s,...i}=t,r=[];return a&&r.push(`width: ${a}px;`),n&&r.push(`background-color: ${n};`),s&&r.push(`text-align: ${s};`),Ct({...i,...e>1?{colspan:e}:{},...o>1?{rowspan:o}:{},...r.length>0?{style:r.join(" ")}:{}})}const Us={a:["href","target","data-uuid","data-anchor","data-linktype"],img:["alt","src","title"],span:["class"]};function Hp(t,{allowedStyles:e}){const o=(t.getAttribute("class")||"").split(" ").filter(Boolean);if(!o.length)return[];const a=o.filter(n=>!e.includes(n));for(const n of a)console.warn(`[StoryblokRichText] - \`class\` "${n}" on \`<${t.tagName.toLowerCase()}>\` can not be transformed to rich text.`);return e.filter(n=>o.includes(n))}const Nb=v1.configure({types:["heading","paragraph"]}),zb=Lh.extend({renderHTML({HTMLAttributes:t}){return["blockquote",We(t),0]}}),Ob=f1.extend({renderHTML({HTMLAttributes:t}){return["p",We(t),0]}}),$b=l1.extend({renderHTML({node:t,HTMLAttributes:e}){const{level:o,...a}=e;return[`h${t.attrs.level}`,We(a),0]}}),Pb=hp.extend({renderHTML({HTMLAttributes:t}){return["tr",We(t),0]}}),Hb=Ml.extend({name:"bullet_list",addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ul",We(t),0]}}),qb=Wl.extend({name:"ordered_list",addAttributes(){return{order:{default:1}}},addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ol",We(t),0]}}),Wb=Bl.extend({name:"list_item",addOptions(){return{...this.parent(),bulletListTypeName:"bullet_list",orderedListTypeName:"ordered_list"}},renderHTML({HTMLAttributes:t}){return["li",We(t),0]}}),Ub=$h.extend({name:"code_block",addAttributes(){return{class:{default:null}}},renderHTML({node:t,HTMLAttributes:e}){const{language:o,...a}=e,n=We(a),s=t.attrs.language;return["pre",n,["code",s?{class:`language-${s}`}:{},0]]}}),Vb=i1.extend({name:"hard_break"}),Kb=c1.extend({name:"horizontal_rule"}),Jb=vp.extend({renderHTML({HTMLAttributes:t}){return["table",We(t),0]}}),Gb=gp.extend({addAttributes(){return{...this.parent?.(),colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(Number):null}},backgroundColor:{default:null}}},renderHTML({HTMLAttributes:t}){return["td",Pp(t),0]}}),Xb=fp.extend({renderHTML({HTMLAttributes:t}){return["th",Pp(t),0]}}),qp=d1.extend({addOptions(){return{...this.parent?.(),optimizeImages:!1}},renderHTML({HTMLAttributes:t}){const{src:e,alt:o,title:a,srcset:n,sizes:s}=t;let i=e,r={};if(this.options.optimizeImages){const l=xb(e,this.options.optimizeImages);i=l.src,r=l.attrs}return["img",Ct({src:i,alt:o,title:a,srcset:n,sizes:s,...r})]}}),Yb=n1.extend({renderHTML({HTMLAttributes:t}){return["img",{"data-emoji":t.emoji,"data-name":t.name,src:t.fallbackImage,alt:t.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}]}}),Wp=J.create({name:"blok",group:"block",atom:!0,addOptions(){return{renderComponent:null}},addAttributes(){return{id:{default:null},body:{default:[]}}},parseHTML(){return[{tag:"div[data-blok]"}]},renderHTML({HTMLAttributes:t}){return console.warn("[StoryblokRichText] - BLOK resolver is not available for vanilla usage. Configure `renderComponent` option on the blok tiptapExtension."),["span",Ct({"data-blok":JSON.stringify(t?.body?.[0]??null),"data-blok-id":t?.id,style:"display: none"})]}}),Zb=M1.extend({addAttributes(){return{color:{default:null}}}}),Vs=mb.extend({addAttributes(){return{href:{parseHTML:t=>t.getAttribute("href")},uuid:{default:null,parseHTML:t=>t.getAttribute("data-uuid")||null},anchor:{default:null,parseHTML:t=>t.getAttribute("data-anchor")||null},target:{parseHTML:t=>t.getAttribute("target")||null},linktype:{default:"url",parseHTML:t=>t.getAttribute("data-linktype")||"url"}}},renderHTML({HTMLAttributes:t}){const{href:e,rest:o}=Lb(t);return["a",Ct({...e?{href:e}:{},...o}),0]}}),Qb=Vs.extend({addAttributes(){return{...this.parent?.(),custom:{default:null,parseHTML:t=>{const e=Us.a,o=t.getAttributeNames().filter(n=>!e.includes(n)),a={};for(const n of o)a[n]=t.getAttribute(n);return Object.keys(a).length?a:null}}}}}),ej=be.create({name:"anchor",addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"span[id]"}]},renderHTML({HTMLAttributes:t}){return["span",{id:t.id},0]}}),Up=be.create({name:"styled",addAttributes(){return{class:{parseHTML:t=>{const e=Hp(t,{allowedStyles:this.options.allowedStyles||[]});return e.length?e.join(" "):null}}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>Hp(t,{allowedStyles:this.options.allowedStyles||[]}).length?null:!1}]},renderHTML({HTMLAttributes:t}){const{class:e,...o}=t;return["span",Ct({class:e,style:$p(o)||void 0}),0]}}),tj=be.create({name:"textStyle",addAttributes(){return{class:{default:null},id:{default:null},color:{default:null}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>{const e=t.getAttribute("style");return e&&/color/i.test(e)?null:!1}}]},renderHTML({HTMLAttributes:t}){const{class:e,id:o,...a}=t;return["span",Ct({class:e,id:o,style:$p(a)||void 0}),0]}}),Vp=be.create({name:"reporter",priority:0,addOptions(){return{allowCustomAttributes:!1}},parseHTML(){return[{tag:"*",consuming:!1,getAttrs:t=>{const e=t.tagName.toLowerCase();if(e==="a"&&this.options.allowCustomAttributes)return!1;const o=t.getAttributeNames().filter(a=>!(e in Us?Us[e]:[]).includes(a));for(const a of o)console.warn(`[StoryblokRichText] - \`${a}\` "${t.getAttribute(a)}" on \`<${e}>\` can not be transformed to rich text.`);return!1}}]}}),oj={document:Hh,text:b1,paragraph:Ob,blockquote:zb,heading:$b,bulletList:Hb,orderedList:qb,listItem:Wb,codeBlock:Ub,hardBreak:Vb,horizontalRule:Kb,image:qp,emoji:Yb,table:Jb,tableRow:Pb,tableCell:Gb,tableHeader:Xb,blok:Wp,details:_f,detailsContent:Df,detailsSummary:wf,bold:w1,italic:O1,strike:fb,underline:Ab,code:A1,superscript:vb,subscript:bb,highlight:Zb,textStyle:tj,link:Vs,anchor:ej,styled:Up,reporter:Vp,textAlign:Nb};function aj(t={}){const e=t.allowCustomAttributes?Qb:Vs;return{...oj,image:qp.configure({optimizeImages:t.optimizeImages||!1}),link:e,styled:Up.configure({allowedStyles:t.styleOptions?.map(o=>o.value)}),reporter:Vp.configure({allowCustomAttributes:t.allowCustomAttributes})}}function Kp(t,e={},o){const a=Bb(e),n=a?`${t} ${a}`:t,s=Array.isArray(o)?o.join(""):o||"";if(t){if(Mb.includes(t))return`<${n}>`}else return s;return`<${n}>${s}</${t}>`}function jo(t,e,o){const[a,...n]=t;let s={},i=n;if(i.length>0&&i[0]!==null&&i[0]!==void 0&&typeof i[0]=="object"&&!Array.isArray(i[0])&&typeof i[0]!="number"&&(s=i[0],i=i.slice(1)),i=i.filter(l=>l!=null),i.length===0)return e(a,s);if(i.length===1&&i[0]===0)return e(a,s,o);const r=i.map(l=>l===0?o:Array.isArray(l)?jo(l,e,o):l);return e(a,s,r.length===1?r[0]:r)}function Ka(t,e,o){const a={options:t.options||{},name:t.name,type:t.type};return e==="node"?t.config.renderHTML.call(a,{node:{attrs:o},HTMLAttributes:o}):t.config.renderHTML.call(a,{mark:{attrs:o},HTMLAttributes:o})}function Ks(t={}){const e=new Map,{renderFn:o=Kp,textFn:a=Rb,optimizeImages:n=!1,keyedResolvers:s=!1,tiptapExtensions:i}=t,r=o!==Kp,l=aj({optimizeImages:n}),p=i?{...l,...i}:l,c=Object.values(p),m=new Map,u=new Map;for(const j of c)j.type==="node"?m.set(j.name,j):j.type==="mark"&&u.set(j.name,j);const d=(j,F={},_)=>{if(s&&j){const I=e.get(j)||0;e.set(j,I+1),F={...F,key:`${j}-${I}`}}return r&&typeof j!="string"&&_!==void 0?o(j,F,(()=>_)):o(j,F,_)};function g(j,F){const _=j.map(E=>b({...E,marks:Sb(E.marks||[],F)}));let I=r?_:_.join("");for(const E of F){const L=u.get(E.type);L?.config?.renderHTML&&(I=jo(Ka(L,"mark",E.attrs||{}),d,I))}return I}function f(j){const F=[];let _=0;for(;_<j.length;){const I=Tb(j,_);if(!I){F.push(k(j[_])),_++;continue}I.group.length===1?F.push(b(I.group[0])):F.push(g(I.group,I.shared)),_=I.endIndex}return F}function h(j){if(j.type==="text")return b(j);if(j.type==="doc")return k(j);const F=m.get(j.type);if(!F?.config?.renderHTML)return console.error("<Storyblok>",`No extension found for node type ${j.type}`),"";if(F.options?.renderComponent){const I=j.attrs?.body,E=j.attrs?.id;if(!Array.isArray(I)||I.length===0)return r?[]:"";const L=I.map(z=>F.options.renderComponent(z,E));return r?L:L.filter(z=>z!=null).join("")}if(j.type==="table"&&j.content?.length){const I=[],E=[];for(const C of j.content)E.length===0&&C.content?.every(R=>R.type==="tableHeader")?I.push(C):E.push(C);const L=Ka(F,"node",j.attrs||{}),z=[];return I.length>0&&z.push(d("thead",{},I.map(k))),E.length>0&&z.push(d("tbody",{},E.map(k))),jo(L,d,z)}const _=j.content?f(j.content):void 0;return jo(Ka(F,"node",j.attrs||{}),d,_)}function b(j){const{marks:F,..._}=j;if(F?.length){const E=(()=>{const L={};if(s){const z=e.get("txt")||0;e.set("txt",z+1),L.key=`txt-${z}`}return a(_.text,L)})();return F.reduce((L,z)=>{const C=u.get(z.type);return C?.config?.renderHTML?jo(Ka(C,"mark",z.attrs||{}),d,L):(console.error("<Storyblok>",`No extension found for node type ${z.type}`),L)},E)}const I=j.attrs||{};if(s){const E=e.get("txt")||0;e.set("txt",E+1),I.key=`txt-${E}`}return a(_.text,I)}function k(j){const F=j;return F.type==="doc"?r?F.content.map(h):F.content.map(h).join(""):Array.isArray(F)?F.map(h):h(F)}return{render:k}}const nj="SB_BLOK_GROUP_",sj=/<!--SB_BLOK_GROUP_(\d+)-->/;function ij(t,e={}){const o=[],a=[],n=Ks({...e,tiptapExtensions:{blok:Wp.configure({renderComponent:s=>{const i=[s];return`<!--${nj}${a.push(i)-1}-->`}}),...e.tiptapExtensions}}).render(t).split(sj);for(let s=0;s<n.length;s++)if(s%2===0){const i=n[s];i&&i.trim()&&o.push({type:"html",content:i})}else{const i=a[Number(n[s])];if(i)for(const r of i)o.push({type:"blok",blok:r})}return o}const Js=(t="")=>t.includes("/cdn/"),rj=(t,e=25,o=1)=>({...t,per_page:e,page:o}),lj=t=>new Promise(e=>setTimeout(e,t)),pj=(t=0,e)=>Array.from({length:t},e),cj=(t=0,e=t)=>{const o=Math.abs(e-t)||0,a=t<e?1:-1;return pj(o,(n,s)=>s*a+t)},mj=async(t,e)=>Promise.all(t.map(e)),uj=(t=[],e)=>t.map(e).reduce((o,a)=>[...o,...a],[]),Jp=t=>{if(/%[0-9A-F]{2}/i.test(t))try{return decodeURIComponent(t)}catch{return t}return t},Gs=(t,e,o)=>{const a=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];if(s==null)continue;const i=o?"":encodeURIComponent(n);let r;typeof s=="object"?r=Gs(s,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(s)):r=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(s)}`,a.push(r)}return a.join("&")},Gp=t=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[t]??e.eu};var dj=class{baseURL;timeout;headers;responseInterceptor;fetch;ejectInterceptor;url;parameters;fetchOptions;constructor(t){this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t?.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}patch(t,e){return this.url=t,this.parameters=e,this._methodHandler("patch")}delete(t,e){return this.url=t,this.parameters=e??{},this._methodHandler("delete")}async _responseHandler(t){const e=[],o={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(a=>{o.data=a});for(const a of t.headers.entries())e[a[0]]=a[1];return o.headers={...e},o.status=t.status,o.statusText=t.statusText,o}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,o=null;t==="get"?e=`${this.baseURL}${this.url}?${Gs(this.parameters)}`:o=JSON.stringify(this.parameters);const a=new URL(e),n=new AbortController,{signal:s}=n;let i=null;this.timeout&&(i=setTimeout(()=>n.abort(),this.timeout));try{const r=await this.fetch(`${a}`,{method:t,headers:this.headers,body:o,signal:s,...this.fetchOptions});this.timeout&&i&&clearTimeout(i);const l=await this._responseHandler(r);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(r){return r.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:r.message||r.toString()||"An unknown error occurred"}}}setFetchOptions(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(t){if(Array.isArray(t))return t[0]||"Unknown error";if(t&&typeof t=="object"){if(t.error)return t.error;for(const e in t){if(Array.isArray(t[e]))return`${e}: ${t[e][0]}`;if(typeof t[e]=="string")return`${e}: ${t[e]}`}if(t.slug)return t.slug}return"Unknown error"}_statusHandler(t){const e=/20[0-6]/g;return new Promise((o,a)=>{if(e.test(`${t.status}`))return o(t);a({message:this._normalizeErrorMessage(t.data),status:t.status,response:t})})}};const gj={PUBLISHED:"published"},fj=25,Xs={SMALL:25,MEDIUM:50,LARGE:75},$t={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Xp=1e3,vo=3;function hj(t,e){const o=t.includes("/cdn/stories/"),a=t.split("/").length>3&&!t.endsWith("/cdn/stories"),n="find_by"in e;return o&&a||n}function bj(t){return t<=Xs.SMALL?$t.SINGLE_OR_SMALL:t<=Xs.MEDIUM?$t.MEDIUM:t<=Xs.LARGE?$t.LARGE:$t.VERY_LARGE}function ko(t,e,o={},a){return o.userRateLimit!==void 0?Math.min(o.userRateLimit,Xp):o.serverHeadersRateLimit!==void 0?Math.min(o.serverHeadersRateLimit,Xp):a!==void 0?a:!t||!e||hj(t,e)?$t.SINGLE_OR_SMALL:bj(e.per_page||fj)}function jj(t){if(!t)return null;const e=t["x-ratelimit"]||t["X-RateLimit"],o=t["x-ratelimit-policy"]||t["X-RateLimit-Policy"];if(!e&&!o)return null;const a={};if(e){const n=e.match(/r=(\d+)/);n&&(a.remaining=Number.parseInt(n[1],10))}if(o){const n=o.match(/q=(\d+)/);n&&(a.max=Number.parseInt(n[1],10))}return Object.keys(a).length>0?a:null}function vj(t,e=!1){return{userRateLimit:t,serverHeadersRateLimit:void 0,isManagementApi:e}}var kj=class extends Error{constructor(t){super(t),this.name="AbortError"}};function yj(t,e,o){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(o))throw new TypeError("Expected `interval` to be a finite number");const a=[];let n=[],s=0,i=!1;const r=async()=>{s++;const p=a.shift();if(p)try{const m=await t(...p.args);p.resolve(m)}catch(m){p.reject(m)}const c=setTimeout(()=>{s--,a.length>0&&r(),n=n.filter(m=>m!==c)},o);n.includes(c)||n.push(c)},l=(...p)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((c,m)=>{a.push({resolve:c,reject:m,args:p}),s<e&&r()});return l.abort=()=>{i=!0,n.forEach(clearTimeout),n=[],a.forEach(p=>p.reject(()=>new kj("Throttle function aborted"))),a.length=0},l}var Fj=class{queues;interval;throttledRequestFn;constructor(t,e=1e3){this.queues=new Map,this.interval=e,this.throttledRequestFn=t}getQueue(t){let e=this.queues.get(t);return e||(e=yj(this.throttledRequestFn,t,this.interval),this.queues.set(t,e)),e}execute(t,...e){return this.getQueue(t)(...e)}abortAll(){this.queues.forEach(t=>{t.abort?.()}),this.queues.clear()}getQueueCount(){return this.queues.size}};let Ja={};const pt={};var _j=class{client;maxRetries;retriesDelay;throttleManager;accessToken;cache;resolveCounter;relations;links;version;rateLimitConfig;cvMode;richTextResolver;resolveNestedRelations;stringifiedStoriesCache;inlineAssets;constructor(t,e){let o=t.endpoint||e;if(!o){const n=t.https===!1?"http":"https";t.oauthToken?o=`${n}://${Gp(t.region)}/v1`:o=`${n}://${Gp(t.region)}/v2`}const a=new Headers;!t.oauthToken&&typeof window<"u"||a.set("Content-Type","application/json"),a.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([n,s])=>{a.set(n,s)}),t.oauthToken&&a.set("Authorization",t.oauthToken),this.rateLimitConfig=vj(t.rateLimit,!!t.oauthToken),this.maxRetries=t.maxRetries||10,this.retriesDelay=300,this.throttleManager=new Fj(this.throttledRequest.bind(this),1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.cvMode=t.cache?.cv??"auto",this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=t.version||gj.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new dj({baseURL:o,timeout:t.timeout||0,headers:a,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),!t.cv&&this.cvMode==="auto"&&(t.cv=pt[t.token]),Array.isArray(t.resolve_relations)?t.resolve_relations=t.resolve_relations.map(Jp).join(","):typeof t.resolve_relations=="string"&&(t.resolve_relations=Jp(t.resolve_relations)),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return Js(t)?this.parseParams(e):e}makeRequest(t,e,o,a,n){const s=this.factoryParamOptions(t,rj(e,o,a));return this.cacheResponse(t,s,void 0,n)}get(t,e={},o){e||(e={});const a=`/${t}`;Js(a)&&(e.version=e.version||this.version);const n=this.factoryParamOptions(a,e);return this.cacheResponse(a,n,void 0,o)}async getAll(t,e={},o,a){const n=e?.per_page||25,s=`/${t}`.replace(/\/$/,""),i=o??s.substring(s.lastIndexOf("/")+1);e.version=e.version||this.version;const r=1,l=await this.makeRequest(s,e,n,r,a);return uj([l,...await mj(cj(r,l.total?Math.ceil(l.total/(l.perPage||n)):1),p=>this.makeRequest(s,e,n,p+1,a))],p=>Object.values(p.data[i]))}post(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"post",a,e,o)}put(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"put",a,e,o)}patch(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"patch",a,e,o)}delete(t,e={},o){e||(e={});const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"delete",a,e,o)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},o){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(t){typeof t.resolve_relations<"u"&&(t.resolve_level=2)}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,o){const a=t[e];a&&a.fieldtype==="multilink"&&a.linktype==="story"&&typeof a.id=="string"&&this.links[o][a.id]?a.story=this._cleanCopy(this.links[o][a.id]):a&&a.linktype==="story"&&typeof a.uuid=="string"&&this.links[o][a.uuid]&&(a.story=this._cleanCopy(this.links[o][a.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,o){const a=t[e];typeof a=="string"?t[e]=this.getStoryReference(o,a):Array.isArray(a)&&(t[e]=a.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(t,e,o,a){if(Array.isArray(o)?o.find(s=>s.endsWith(`.${e}`)):o.endsWith(`.${e}`)){this._resolveField(t,e,a);return}const n=t.component?`${t.component}.${e}`:e;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(t,e,a)}iterateTree(t,e,o){const a=(n,s="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((i,r)=>a(i,`${s}[${r}]`));else if(typeof n=="object")for(const i in n){const r=s?`${s}.${i}`:i;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,e,o),this._insertLinks(n,i,o)),a(n[i],r)}}};a(t.content)}async resolveLinks(t,e,o){let a=[];if(t.link_uuids){const n=t.link_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.link_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(",")})).data.stories.forEach(l=>{a.push(l)})}else a=t.links;a.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(t,e,o){let a=[];if(t.rel_uuids){const n=t.rel_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.rel_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{a.push(l)});a.length>0&&(t.rels=a,delete t.rel_uuids)}else a=t.rels;a&&a.length>0&&a.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(t,e,o){let a=[];if(this.links[o]={},this.relations[o]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(a=e.resolve_relations.split(",")),await this.resolveRelations(t,e,o)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&(t.links?.length||t.link_uuids?.length)&&await this.resolveLinks(t,e,o),this.resolveNestedRelations)for(const n in this.relations[o])this.iterateTree(this.relations[o][n],a,o);t.story?this.iterateTree(t.story,a,o):t.stories.forEach(n=>{this.iterateTree(n,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(t,e,o,a){const n=Gs({url:t,params:e}),s=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const l=await s.get(n);if(l)return Promise.resolve(l)}const i=!Js(t)&&this.rateLimitConfig.isManagementApi?vo:void 0,r=ko(t,e,this.rateLimitConfig,i);return new Promise(async(l,p)=>{try{const c=await this.throttleManager.execute(r,"get",t,e,a);if(c.status!==200)return p(c);let m={data:c.data,headers:c.headers};const u=jj(c.headers);if(u?.max!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=u.max),c.headers?.["per-page"]&&(m=Object.assign({},m,{perPage:c.headers["per-page"]?Number.parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?Number.parseInt(c.headers.total):0})),m.data.story||m.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(m.data,e,`${g}`),m=await this.processInlineAssets(m)}e.version==="published"&&t!=="/cdn/spaces/me"&&await s.set(n,m);const d=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&m.data.cv&&(d&&pt[e.token]&&pt[e.token]!==m.data.cv&&await this.flushCache(),pt[e.token]=m.data.cv),l(m)}catch(c){if(c.response&&c.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await lj(this.retriesDelay),this.cacheResponse(t,e,o).then(l).catch(p);p(c)}})}throttledRequest(t,e,o,a){return this.client.setFetchOptions(a),this.client[t](e,o)}cacheVersions(){return pt}cacheVersion(){return pt[this.accessToken]}setCacheVersion(t){this.accessToken&&(pt[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(pt[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(Ja[t])},getAll(){return Promise.resolve(Ja)},set(t,e){return Ja[t]=e,Promise.resolve(void 0)},flush(){return Ja={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(t){if(!this.inlineAssets)return t;const e=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>e(n));let a={...o};a.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(a={...t.data.assets.find(n=>n.id===a.id),...a});for(const n in a)typeof a[n]=="object"&&(a[n]=e(a[n]));return a};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(o=>(o.content=e(o.content),o))),t}};let Yp=!1;const Zp=[],Qp=t=>new Promise((e,o)=>{if(typeof window>"u"){o(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}Yp?n():Zp.push(n)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const a=document.createElement("script");a.async=!0,a.src=t,a.id="storyblok-javascript-bridge",a.onerror=n=>o(n),a.onload=n=>{Zp.forEach(s=>s()),Yp=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(a)}),Dj=(t={})=>{const{apiOptions:e}=t;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 _j(e)}},wj=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let Ys="https://app.storyblok.com/f/storyblok-v2-latest.js";const Ij=(t={})=>{var e,o;const{bridge:a,accessToken:n,use:s=[],apiOptions:i={},bridgeUrl:r}=t;i.accessToken=i.accessToken||n;const l={bridge:a,apiOptions:i};let p={};s.forEach(m=>{p={...p,...m(l)}}),r&&(Ys=r);const c=!(typeof window>"u")&&((o=(e=window.location)==null?void 0:e.search)==null?void 0:o.includes("_storyblok_tk"));return a!==!1&&c&&Qp(Ys),p};function Cj(t,e){return Ks(e).render(t)}const Ej=()=>Qp(Ys);Q.apiPlugin=Dj,Q.getLiveStory=pc,Q.getPayload=cc,Q.handleStoryblokMessage=Uc,Q.isEditorRequest=em,Q.loadStoryblokBridge=Ej,Q.renderRichText=Cj,Q.richTextResolver=Ks,Q.sanitizeJSON=wc,Q.segmentStoryblokRichText=ij,Q.storyblok=Dc,Q.storyblokEditable=wj,Q.storyblokInit=Ij,Q.toCamelCase=si,Q.useStoryblokApi=lc,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
|
143
|
+
3. "-" cannot repeat`);V.customSchemes.push([t,e])}function ob(){V.scanner=J1(V.customSchemes);for(let t=0;t<V.tokenQueue.length;t++)V.tokenQueue[t][1]({scanner:V.scanner});V.parser=Y1(V.scanner.tokens);for(let t=0;t<V.pluginQueue.length;t++)V.pluginQueue[t][1]({scanner:V.scanner,parser:V.parser});return V.initialized=!0,V}function Hs(t){return V.initialized||ob(),Z1(V.parser.start,t,Ap(V.scanner.start,t))}Hs.scan=Ap;function Lp(t,e=null,o=null){if(e&&typeof e=="object"){if(o)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);o=e,e=null}const a=new $s(o),n=Hs(t),s=[];for(let i=0;i<n.length;i++){const r=n[i];r.isLink&&(!e||r.t===e)&&a.check(r)&&s.push(r.toFormattedObject(a))}return s}var qs="[\0- -\u2029 ]",ab=new RegExp(qs),nb=new RegExp(`${qs}$`),sb=new RegExp(qs,"g");function ib(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function rb(t){return new le({key:new oe("autolink"),appendTransaction:(e,o,a)=>{const n=e.some(p=>p.docChanged)&&!o.doc.eq(a.doc),s=e.some(p=>p.getMeta("preventAutolink"));if(!n||s)return;const{tr:i}=a,r=Wn(o.doc,[...e]);if(Vn(r).forEach(({newRange:p})=>{const c=yl(a.doc,p,d=>d.isTextblock);let m,u;if(c.length>1)m=c[0],u=a.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(c.length){const d=a.doc.textBetween(p.from,p.to," "," ");if(!nb.test(d))return;m=c[0],u=a.doc.textBetween(m.pos,p.to,void 0," ")}if(m&&u){const d=u.split(ab).filter(Boolean);if(d.length<=0)return!1;const g=d[d.length-1],f=m.pos+u.lastIndexOf(g);if(!g)return!1;const h=Hs(g).map(b=>b.toObject(t.defaultProtocol));if(!ib(h))return!1;h.filter(b=>b.isLink).map(b=>({...b,from:f+b.start+1,to:f+b.end+1})).filter(b=>a.schema.marks.code?!a.doc.rangeHasMark(b.from,b.to,a.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Kn(b.from,b.to,a.doc).some(k=>k.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function lb(t){return new le({key:new oe("handleClickLink"),props:{handleClick:(e,o,a)=>{var n,s;if(a.button!==0||!e.editable)return!1;let i=null;if(a.target instanceof HTMLAnchorElement)i=a.target;else{const l=a.target;if(!l)return!1;const p=t.editor.view.dom;i=l.closest("a"),i&&!p.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(t.enableClickSelection&&(r=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=cg(e.state,t.type.name),p=(n=i.href)!=null?n:l.href,c=(s=i.target)!=null?s:l.target;p&&(window.open(p,c),r=!0)}return r}}})}function pb(t){return new le({key:new oe("handlePasteLink"),props:{handlePaste:(e,o,a)=>{const{shouldAutoLink:n}=t,{state:s}=e,{selection:i}=s,{empty:r}=i;if(r)return!1;let l="";a.content.forEach(c=>{l+=c.textContent});const p=Lp(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!p||n!==void 0&&!n(p.value)?!1:t.editor.commands.setMark(t.type,{href:p.href})}}})}function It(t,e){const o=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(a=>{const n=typeof a=="string"?a:a.scheme;n&&o.push(n)}),!t||t.replace(sb,"").match(new RegExp(`^(?:(?:${o.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var cb=be.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Rp(t);return}Rp(t.scheme,t.optionalSlashes)})},onDestroy(){tb()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!It(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),o=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||o&&!t.includes("@"))return!0;const n=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(n)||!/\./.test(n))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:o=>!!It(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!It(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var o,a,n,s;const i=(a=(o=t.attrs)==null?void 0:o.href)!=null?a:"",r=(s=(n=t.attrs)==null?void 0:n.title)!=null?s:"",l=e.renderChildren(t);return r?`[${l}](${i} "${r}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:o}=t;return this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:o}=t||{};return o&&!this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[nt({find:t=>{const e=[];if(t){const{protocols:o,defaultProtocol:a}=this.options,n=Lp(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!It(i,o),protocols:o,defaultProtocol:a}));n.length&&n.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:o}=this.options;return this.options.autolink&&t.push(rb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:a=>this.options.isAllowedUri(a,{defaultValidate:n=>!!It(n,e),protocols:e,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink})),t.push(lb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(pb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),mb=cb,ub=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,db=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gb=be.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ft({find:ub,type:this.type})]},addPasteRules(){return[nt({find:db,type:this.type})]}}),fb=gb,hb=be.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),bb=hb,jb=be.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),vb=jb,kb=20,Np=(t,e=0)=>{const o=[];return!t.children.length||e>kb||Array.from(t.children).forEach(a=>{a.tagName==="SPAN"?o.push(a):a.children.length&&o.push(...Np(a,e+1))}),o},yb=t=>{if(!t.children.length)return;const e=Np(t);e&&e.forEach(o=>{var a,n;const s=o.getAttribute("style"),i=(n=(a=o.parentElement)==null?void 0:a.closest("span"))==null?void 0:n.getAttribute("style");o.setAttribute("style",`${i};${s}`)})},Fb=be.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&yb(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",H(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(o,a)=>{if(o.isTextblock)return!0;o.marks.filter(n=>n.type===this.type).some(n=>Object.values(n.attrs).some(s=>!!s))||t.removeMark(a,a+o.nodeSize,this.type)}),!0}}}}),_b=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="background-color")return r.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Db=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="color")return r.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),wb=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Ib=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Cb=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(_b.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Db.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(wb.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(Ib.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Cb.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Fb.configure(this.options.textStyle)),t}});var Eb=be.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,o){const n=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!n)return;const s=n[2].trim();return{type:"underline",raw:n[0],text:s,tokens:o.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Ab=Eb;function xb(t,e){if(!e)return{src:t,attrs:{}};let o=0,a=0;const n={},s=[];function i(l,p,c,m,u){typeof l!="number"||l<=p||l>=c?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${p} and ${c} (inclusive)`):u.push(`${m}(${l})`)}if(typeof e=="object"){if(e.width!==void 0&&(typeof e.width=="number"&&e.width>=0?(n.width=e.width,o=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),e.height!==void 0&&(typeof e.height=="number"&&e.height>=0?(n.height=e.height,a=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),e.height===0&&e.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),e.loading&&["lazy","eager"].includes(e.loading)&&(n.loading=e.loading),e.class&&(n.class=e.class),e.filters){const{filters:l}=e||{},{blur:p,brightness:c,fill:m,format:u,grayscale:d,quality:g,rotate:f}=l||{};p&&i(p,0,100,"blur",s),g&&i(g,0,100,"quality",s),c&&i(c,0,100,"brightness",s),m&&s.push(`fill(${m})`),d&&s.push("grayscale()"),f&&[0,90,180,270].includes(e.filters.rotate||0)&&s.push(`rotate(${f})`),u&&["webp","png","jpeg"].includes(u)&&s.push(`format(${u})`)}e.srcset&&(n.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${t}/m/${l}x0/${s.length>0?`filters:${s.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[p,c]=l;return`${t}/m/${p}x${c}/${s.length>0?`filters:${s.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(n.sizes=e.sizes.join(", "))}let r=`${t}/m/`;return(o>0||a>0)&&(r=`${r}${o}x${a}/`),s.length>0&&(r=`${r}filters:${s.join(":")}`),{src:r,attrs:n}}function Ws(t,e){if(t===e)return!0;if(t==null||e===null||e===void 0)return t===e;if(typeof t!=typeof e||typeof t!="object"||Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t))return t.length!==e.length?!1:t.every((n,s)=>Ws(n,e[s]));const o=Object.keys(t),a=Object.keys(e);return o.length!==a.length?!1:o.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&Ws(t[n],e[n]))}function zp(t,e){return t.type===e.type&&Ws(t.attrs,e.attrs)}function Op(t){return t.type==="text"&&!!t.marks?.length}function Sb(t,e){const o=t.filter(a=>!e.some(n=>zp(n,a)));return o.length?o:void 0}function Tb(t,e){const o=t[e];if(!Op(o))return null;const a=[o];let n=o.marks,s=e+1;for(;s<t.length;){const i=t[s];if(!Op(i))break;const r=n.filter(l=>i.marks.some(p=>zp(l,p)));if(r.length===0)break;n=r,a.push(i),s++}return{group:a,shared:n,endIndex:s}}const Mb=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Bb=(t={})=>{const{custom:e,...o}=t,a={...o,...e};return Object.keys(a).filter(n=>a[n]!=null).map(n=>`${n}="${String(a[n]).replace(/&/g,"&").replace(/"/g,""")}"`).join(" ")},$p=(t={})=>Object.keys(t).map(e=>`${e}: ${t[e]}`).join("; ");function Rb(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ct=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));let Va=(function(t){return t.URL="url",t.STORY="story",t.ASSET="asset",t.EMAIL="email",t})({});function We(t={}){const{textAlign:e,class:o,id:a,style:n,...s}=t,i=[];return n&&i.push(n.endsWith(";")?n:`${n};`),e&&i.push(`text-align: ${e};`),Ct({...s,class:o,id:a,...i.length>0?{style:i.join(" ")}:{}})}function Lb(t={}){const{linktype:e,href:o,anchor:a,uuid:n,custom:s,...i}=t;let r=o??"";switch(e){case Va.ASSET:case Va.URL:break;case Va.EMAIL:r&&!r.startsWith("mailto:")&&(r=`mailto:${r}`);break;case Va.STORY:a&&(r=`${r}#${a}`);break}return{href:r,rest:{...i,...s||{}}}}function Pp(t={}){const{colspan:e,rowspan:o,colwidth:a,backgroundColor:n,textAlign:s,...i}=t,r=[];return a&&r.push(`width: ${a}px;`),n&&r.push(`background-color: ${n};`),s&&r.push(`text-align: ${s};`),Ct({...i,...e>1?{colspan:e}:{},...o>1?{rowspan:o}:{},...r.length>0?{style:r.join(" ")}:{}})}const Us={a:["href","target","data-uuid","data-anchor","data-linktype"],img:["alt","src","title"],span:["class"]};function Hp(t,{allowedStyles:e}){const o=(t.getAttribute("class")||"").split(" ").filter(Boolean);if(!o.length)return[];const a=o.filter(n=>!e.includes(n));for(const n of a)console.warn(`[StoryblokRichText] - \`class\` "${n}" on \`<${t.tagName.toLowerCase()}>\` can not be transformed to rich text.`);return e.filter(n=>o.includes(n))}const Nb=v1.configure({types:["heading","paragraph"]}),zb=Lh.extend({renderHTML({HTMLAttributes:t}){return["blockquote",We(t),0]}}),Ob=f1.extend({renderHTML({HTMLAttributes:t}){return["p",We(t),0]}}),$b=l1.extend({renderHTML({node:t,HTMLAttributes:e}){const{level:o,...a}=e;return[`h${t.attrs.level}`,We(a),0]}}),Pb=hp.extend({renderHTML({HTMLAttributes:t}){return["tr",We(t),0]}}),Hb=Ml.extend({name:"bullet_list",addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ul",We(t),0]}}),qb=Wl.extend({name:"ordered_list",addAttributes(){return{order:{default:1}}},addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ol",We(t),0]}}),Wb=Bl.extend({name:"list_item",addOptions(){return{...this.parent(),bulletListTypeName:"bullet_list",orderedListTypeName:"ordered_list"}},renderHTML({HTMLAttributes:t}){return["li",We(t),0]}}),Ub=$h.extend({name:"code_block",addAttributes(){return{class:{default:null}}},renderHTML({node:t,HTMLAttributes:e}){const{language:o,...a}=e,n=We(a),s=t.attrs.language;return["pre",n,["code",s?{class:`language-${s}`}:{},0]]}}),Vb=i1.extend({name:"hard_break"}),Kb=c1.extend({name:"horizontal_rule"}),Jb=vp.extend({renderHTML({HTMLAttributes:t}){return["table",We(t),0]}}),Gb=gp.extend({addAttributes(){return{...this.parent?.(),colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(Number):null}},backgroundColor:{default:null}}},renderHTML({HTMLAttributes:t}){return["td",Pp(t),0]}}),Xb=fp.extend({renderHTML({HTMLAttributes:t}){return["th",Pp(t),0]}}),qp=d1.extend({addOptions(){return{...this.parent?.(),optimizeImages:!1}},renderHTML({HTMLAttributes:t}){const{src:e,alt:o,title:a,srcset:n,sizes:s}=t;let i=e,r={};if(this.options.optimizeImages){const l=xb(e,this.options.optimizeImages);i=l.src,r=l.attrs}return["img",Ct({src:i,alt:o,title:a,srcset:n,sizes:s,...r})]}}),Yb=n1.extend({renderHTML({HTMLAttributes:t}){return["img",{"data-emoji":t.emoji,"data-name":t.name,src:t.fallbackImage,alt:t.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}]}}),Wp=J.create({name:"blok",group:"block",atom:!0,addOptions(){return{renderComponent:null}},addAttributes(){return{id:{default:null},body:{default:[]}}},parseHTML(){return[{tag:"div[data-blok]"}]},renderHTML({HTMLAttributes:t}){return console.warn("[StoryblokRichText] - BLOK resolver is not available for vanilla usage. Configure `renderComponent` option on the blok tiptapExtension."),["span",Ct({"data-blok":JSON.stringify(t?.body?.[0]??null),"data-blok-id":t?.id,style:"display: none"})]}}),Zb=M1.extend({addAttributes(){return{color:{default:null}}}}),Vs=mb.extend({addAttributes(){return{href:{parseHTML:t=>t.getAttribute("href")},uuid:{default:null,parseHTML:t=>t.getAttribute("data-uuid")||null},anchor:{default:null,parseHTML:t=>t.getAttribute("data-anchor")||null},target:{parseHTML:t=>t.getAttribute("target")||null},linktype:{default:"url",parseHTML:t=>t.getAttribute("data-linktype")||"url"}}},renderHTML({HTMLAttributes:t}){const{href:e,rest:o}=Lb(t);return["a",Ct({...e?{href:e}:{},...o}),0]}}),Qb=Vs.extend({addAttributes(){return{...this.parent?.(),custom:{default:null,parseHTML:t=>{const e=Us.a,o=t.getAttributeNames().filter(n=>!e.includes(n)),a={};for(const n of o)a[n]=t.getAttribute(n);return Object.keys(a).length?a:null}}}}}),ej=be.create({name:"anchor",addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"span[id]"}]},renderHTML({HTMLAttributes:t}){return["span",{id:t.id},0]}}),Up=be.create({name:"styled",addAttributes(){return{class:{parseHTML:t=>{const e=Hp(t,{allowedStyles:this.options.allowedStyles||[]});return e.length?e.join(" "):null}}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>Hp(t,{allowedStyles:this.options.allowedStyles||[]}).length?null:!1}]},renderHTML({HTMLAttributes:t}){const{class:e,...o}=t;return["span",Ct({class:e,style:$p(o)||void 0}),0]}}),tj=be.create({name:"textStyle",addAttributes(){return{class:{default:null},id:{default:null},color:{default:null}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>{const e=t.getAttribute("style");return e&&/color/i.test(e)?null:!1}}]},renderHTML({HTMLAttributes:t}){const{class:e,id:o,...a}=t;return["span",Ct({class:e,id:o,style:$p(a)||void 0}),0]}}),Vp=be.create({name:"reporter",priority:0,addOptions(){return{allowCustomAttributes:!1}},parseHTML(){return[{tag:"*",consuming:!1,getAttrs:t=>{const e=t.tagName.toLowerCase();if(e==="a"&&this.options.allowCustomAttributes)return!1;const o=t.getAttributeNames().filter(a=>!(e in Us?Us[e]:[]).includes(a));for(const a of o)console.warn(`[StoryblokRichText] - \`${a}\` "${t.getAttribute(a)}" on \`<${e}>\` can not be transformed to rich text.`);return!1}}]}}),oj={document:Hh,text:b1,paragraph:Ob,blockquote:zb,heading:$b,bulletList:Hb,orderedList:qb,listItem:Wb,codeBlock:Ub,hardBreak:Vb,horizontalRule:Kb,image:qp,emoji:Yb,table:Jb,tableRow:Pb,tableCell:Gb,tableHeader:Xb,blok:Wp,details:_f,detailsContent:Df,detailsSummary:wf,bold:w1,italic:O1,strike:fb,underline:Ab,code:A1,superscript:vb,subscript:bb,highlight:Zb,textStyle:tj,link:Vs,anchor:ej,styled:Up,reporter:Vp,textAlign:Nb};function aj(t={}){const e=t.allowCustomAttributes?Qb:Vs;return{...oj,image:qp.configure({optimizeImages:t.optimizeImages||!1}),link:e,styled:Up.configure({allowedStyles:t.styleOptions?.map(o=>o.value)}),reporter:Vp.configure({allowCustomAttributes:t.allowCustomAttributes})}}function Kp(t,e={},o){const a=Bb(e),n=a?`${t} ${a}`:t,s=Array.isArray(o)?o.join(""):o||"";if(t){if(Mb.includes(t))return`<${n}>`}else return s;return`<${n}>${s}</${t}>`}function jo(t,e,o){const[a,...n]=t;let s={},i=n;if(i.length>0&&i[0]!==null&&i[0]!==void 0&&typeof i[0]=="object"&&!Array.isArray(i[0])&&typeof i[0]!="number"&&(s=i[0],i=i.slice(1)),i=i.filter(l=>l!=null),i.length===0)return e(a,s);if(i.length===1&&i[0]===0)return e(a,s,o);const r=i.map(l=>l===0?o:Array.isArray(l)?jo(l,e,o):l);return e(a,s,r.length===1?r[0]:r)}function Ka(t,e,o){const a={options:t.options||{},name:t.name,type:t.type};return e==="node"?t.config.renderHTML.call(a,{node:{attrs:o},HTMLAttributes:o}):t.config.renderHTML.call(a,{mark:{attrs:o},HTMLAttributes:o})}function Ks(t={}){const e=new Map,{renderFn:o=Kp,textFn:a=Rb,optimizeImages:n=!1,keyedResolvers:s=!1,tiptapExtensions:i}=t,r=o!==Kp,l=aj({optimizeImages:n}),p=i?{...l,...i}:l,c=Object.values(p),m=new Map,u=new Map;for(const j of c)j.type==="node"?m.set(j.name,j):j.type==="mark"&&u.set(j.name,j);const d=(j,F={},_)=>{if(s&&j){const I=e.get(j)||0;e.set(j,I+1),F={...F,key:`${j}-${I}`}}return r&&typeof j!="string"&&_!==void 0?o(j,F,(()=>_)):o(j,F,_)};function g(j,F){const _=j.map(E=>b({...E,marks:Sb(E.marks||[],F)}));let I=r?_:_.join("");for(const E of F){const L=u.get(E.type);L?.config?.renderHTML&&(I=jo(Ka(L,"mark",E.attrs||{}),d,I))}return I}function f(j){const F=[];let _=0;for(;_<j.length;){const I=Tb(j,_);if(!I){F.push(k(j[_])),_++;continue}I.group.length===1?F.push(b(I.group[0])):F.push(g(I.group,I.shared)),_=I.endIndex}return F}function h(j){if(j.type==="text")return b(j);if(j.type==="doc")return k(j);const F=m.get(j.type);if(!F?.config?.renderHTML)return console.error("<Storyblok>",`No extension found for node type ${j.type}`),"";if(F.options?.renderComponent){const I=j.attrs?.body,E=j.attrs?.id;if(!Array.isArray(I)||I.length===0)return r?[]:"";const L=I.map(z=>F.options.renderComponent(z,E));return r?L:L.filter(z=>z!=null).join("")}if(j.type==="table"&&j.content?.length){const I=[],E=[];for(const C of j.content)E.length===0&&C.content?.every(R=>R.type==="tableHeader")?I.push(C):E.push(C);const L=Ka(F,"node",j.attrs||{}),z=[];return I.length>0&&z.push(d("thead",{},I.map(k))),E.length>0&&z.push(d("tbody",{},E.map(k))),jo(L,d,z)}const _=j.content?f(j.content):void 0;return jo(Ka(F,"node",j.attrs||{}),d,_)}function b(j){const{marks:F,..._}=j;if(F?.length){const E=(()=>{const L={};if(s){const z=e.get("txt")||0;e.set("txt",z+1),L.key=`txt-${z}`}return a(_.text,L)})();return F.reduce((L,z)=>{const C=u.get(z.type);return C?.config?.renderHTML?jo(Ka(C,"mark",z.attrs||{}),d,L):(console.error("<Storyblok>",`No extension found for node type ${z.type}`),L)},E)}const I=j.attrs||{};if(s){const E=e.get("txt")||0;e.set("txt",E+1),I.key=`txt-${E}`}return a(_.text,I)}function k(j){const F=j;return F.type==="doc"?r?F.content.map(h):F.content.map(h).join(""):Array.isArray(F)?F.map(h):h(F)}return{render:k}}const nj="SB_BLOK_GROUP_",sj=/<!--SB_BLOK_GROUP_(\d+)-->/;function ij(t,e={}){const o=[],a=[],n=Ks({...e,tiptapExtensions:{blok:Wp.configure({renderComponent:s=>{const i=[s];return`<!--${nj}${a.push(i)-1}-->`}}),...e.tiptapExtensions}}).render(t).split(sj);for(let s=0;s<n.length;s++)if(s%2===0){const i=n[s];i&&i.trim()&&o.push({type:"html",content:i})}else{const i=a[Number(n[s])];if(i)for(const r of i)o.push({type:"blok",blok:r})}return o}const Js=(t="")=>t.includes("/cdn/"),rj=(t,e=25,o=1)=>({...t,per_page:e,page:o}),lj=t=>new Promise(e=>setTimeout(e,t)),pj=(t=0,e)=>Array.from({length:t},e),cj=(t=0,e=t)=>{const o=Math.abs(e-t)||0,a=t<e?1:-1;return pj(o,(n,s)=>s*a+t)},mj=async(t,e)=>Promise.all(t.map(e)),uj=(t=[],e)=>t.map(e).reduce((o,a)=>[...o,...a],[]),Jp=t=>{if(/%[0-9A-F]{2}/i.test(t))try{return decodeURIComponent(t)}catch{return t}return t},Gs=(t,e,o)=>{const a=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];if(s==null)continue;const i=o?"":encodeURIComponent(n);let r;typeof s=="object"?r=Gs(s,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(s)):r=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(s)}`,a.push(r)}return a.join("&")},Gp=t=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[t]??e.eu};var dj=class{baseURL;timeout;headers;responseInterceptor;fetch;ejectInterceptor;url;parameters;fetchOptions;constructor(t){this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t?.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}patch(t,e){return this.url=t,this.parameters=e,this._methodHandler("patch")}delete(t,e){return this.url=t,this.parameters=e??{},this._methodHandler("delete")}async _responseHandler(t){const e=[],o={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(a=>{o.data=a});for(const a of t.headers.entries())e[a[0]]=a[1];return o.headers={...e},o.status=t.status,o.statusText=t.statusText,o}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,o=null;t==="get"?e=`${this.baseURL}${this.url}?${Gs(this.parameters)}`:o=JSON.stringify(this.parameters);const a=new URL(e),n=new AbortController,{signal:s}=n;let i=null;this.timeout&&(i=setTimeout(()=>n.abort(),this.timeout));try{const r=await this.fetch(`${a}`,{method:t,headers:this.headers,body:o,signal:s,...this.fetchOptions});this.timeout&&i&&clearTimeout(i);const l=await this._responseHandler(r);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(r){return r.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:r.message||r.toString()||"An unknown error occurred"}}}setFetchOptions(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(t){if(Array.isArray(t))return t[0]||"Unknown error";if(t&&typeof t=="object"){if(t.error)return t.error;for(const e in t){if(Array.isArray(t[e]))return`${e}: ${t[e][0]}`;if(typeof t[e]=="string")return`${e}: ${t[e]}`}if(t.slug)return t.slug}return"Unknown error"}_statusHandler(t){const e=/20[0-6]/g;return new Promise((o,a)=>{if(e.test(`${t.status}`))return o(t);a({message:this._normalizeErrorMessage(t.data),status:t.status,response:t})})}};const gj={PUBLISHED:"published"},fj=25,Xs={SMALL:25,MEDIUM:50,LARGE:75},$t={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Xp=1e3,vo=3;function hj(t,e){const o=t.includes("/cdn/stories/"),a=t.split("/").length>3&&!t.endsWith("/cdn/stories"),n="find_by"in e;return o&&a||n}function bj(t){return t<=Xs.SMALL?$t.SINGLE_OR_SMALL:t<=Xs.MEDIUM?$t.MEDIUM:t<=Xs.LARGE?$t.LARGE:$t.VERY_LARGE}function ko(t,e,o={},a){return o.userRateLimit!==void 0?Math.min(o.userRateLimit,Xp):o.serverHeadersRateLimit!==void 0?Math.min(o.serverHeadersRateLimit,Xp):a!==void 0?a:!t||!e||hj(t,e)?$t.SINGLE_OR_SMALL:bj(e.per_page||fj)}function jj(t){if(!t)return null;const e=t["x-ratelimit"]||t["X-RateLimit"],o=t["x-ratelimit-policy"]||t["X-RateLimit-Policy"];if(!e&&!o)return null;const a={};if(e){const n=e.match(/r=(\d+)/);n&&(a.remaining=Number.parseInt(n[1],10))}if(o){const n=o.match(/q=(\d+)/);n&&(a.max=Number.parseInt(n[1],10))}return Object.keys(a).length>0?a:null}function vj(t,e=!1){return{userRateLimit:t,serverHeadersRateLimit:void 0,isManagementApi:e}}var kj=class extends Error{constructor(t){super(t),this.name="AbortError"}};function yj(t,e,o){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(o))throw new TypeError("Expected `interval` to be a finite number");const a=[];let n=[],s=0,i=!1;const r=async()=>{s++;const p=a.shift();if(p)try{const m=await t(...p.args);p.resolve(m)}catch(m){p.reject(m)}const c=setTimeout(()=>{s--,a.length>0&&r(),n=n.filter(m=>m!==c)},o);n.includes(c)||n.push(c)},l=(...p)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((c,m)=>{a.push({resolve:c,reject:m,args:p}),s<e&&r()});return l.abort=()=>{i=!0,n.forEach(clearTimeout),n=[],a.forEach(p=>p.reject(()=>new kj("Throttle function aborted"))),a.length=0},l}var Fj=class{queues;interval;throttledRequestFn;constructor(t,e=1e3){this.queues=new Map,this.interval=e,this.throttledRequestFn=t}getQueue(t){let e=this.queues.get(t);return e||(e=yj(this.throttledRequestFn,t,this.interval),this.queues.set(t,e)),e}execute(t,...e){return this.getQueue(t)(...e)}abortAll(){this.queues.forEach(t=>{t.abort?.()}),this.queues.clear()}getQueueCount(){return this.queues.size}};let Ja={};const pt={};var _j=class{client;maxRetries;retriesDelay;throttleManager;accessToken;cache;resolveCounter;relations;links;version;rateLimitConfig;cvMode;richTextResolver;resolveNestedRelations;stringifiedStoriesCache;inlineAssets;constructor(t,e){let o=t.endpoint||e;if(!o){const n=t.https===!1?"http":"https";t.oauthToken?o=`${n}://${Gp(t.region)}/v1`:o=`${n}://${Gp(t.region)}/v2`}const a=new Headers;!t.oauthToken&&typeof window<"u"||a.set("Content-Type","application/json"),a.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([n,s])=>{a.set(n,s)}),t.oauthToken&&a.set("Authorization",t.oauthToken),this.rateLimitConfig=vj(t.rateLimit,!!t.oauthToken),this.maxRetries=t.maxRetries||10,this.retriesDelay=t.retriesDelay??300,this.throttleManager=new Fj(this.throttledRequest.bind(this),1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.cvMode=t.cache?.cv??"auto",this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=t.version||gj.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new dj({baseURL:o,timeout:t.timeout||0,headers:a,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),!t.cv&&this.cvMode==="auto"&&(t.cv=pt[t.token]),Array.isArray(t.resolve_relations)?t.resolve_relations=t.resolve_relations.map(Jp).join(","):typeof t.resolve_relations=="string"&&(t.resolve_relations=Jp(t.resolve_relations)),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return Js(t)?this.parseParams(e):e}makeRequest(t,e,o,a,n){const s=this.factoryParamOptions(t,rj(e,o,a));return this.cacheResponse(t,s,void 0,n)}get(t,e={},o){e||(e={});const a=`/${t}`;Js(a)&&(e.version=e.version||this.version);const n=this.factoryParamOptions(a,e);return this.cacheResponse(a,n,void 0,o)}async getAll(t,e={},o,a){const n=e?.per_page||25,s=`/${t}`.replace(/\/$/,""),i=o??s.substring(s.lastIndexOf("/")+1);e.version=e.version||this.version;const r=1,l=await this.makeRequest(s,e,n,r,a);return uj([l,...await mj(cj(r,l.total?Math.ceil(l.total/(l.perPage||n)):1),p=>this.makeRequest(s,e,n,p+1,a))],p=>Object.values(p.data[i]))}post(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"post",a,e,o)}put(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"put",a,e,o)}patch(t,e={},o){const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"patch",a,e,o)}delete(t,e={},o){e||(e={});const a=`/${t}`,n=ko(void 0,void 0,this.rateLimitConfig,vo);return this.throttleManager.execute(n,"delete",a,e,o)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},o){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(t){typeof t.resolve_relations<"u"&&(t.resolve_level=2)}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,o){const a=t[e];a&&a.fieldtype==="multilink"&&a.linktype==="story"&&typeof a.id=="string"&&this.links[o][a.id]?a.story=this._cleanCopy(this.links[o][a.id]):a&&a.linktype==="story"&&typeof a.uuid=="string"&&this.links[o][a.uuid]&&(a.story=this._cleanCopy(this.links[o][a.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,o){const a=t[e];typeof a=="string"?t[e]=this.getStoryReference(o,a):Array.isArray(a)&&(t[e]=a.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(t,e,o,a){if(Array.isArray(o)?o.find(s=>s.endsWith(`.${e}`)):o.endsWith(`.${e}`)){this._resolveField(t,e,a);return}const n=t.component?`${t.component}.${e}`:e;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(t,e,a)}iterateTree(t,e,o){const a=(n,s="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((i,r)=>a(i,`${s}[${r}]`));else if(typeof n=="object")for(const i in n){const r=s?`${s}.${i}`:i;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,e,o),this._insertLinks(n,i,o)),a(n[i],r)}}};a(t.content)}async resolveLinks(t,e,o){let a=[];if(t.link_uuids){const n=t.link_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.link_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(",")})).data.stories.forEach(l=>{a.push(l)})}else a=t.links;a.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(t,e,o){let a=[];if(t.rel_uuids){const n=t.rel_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.rel_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{a.push(l)});a.length>0&&(t.rels=a,delete t.rel_uuids)}else a=t.rels;a&&a.length>0&&a.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(t,e,o){let a=[];if(this.links[o]={},this.relations[o]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(a=e.resolve_relations.split(",")),await this.resolveRelations(t,e,o)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&(t.links?.length||t.link_uuids?.length)&&await this.resolveLinks(t,e,o),this.resolveNestedRelations)for(const n in this.relations[o])this.iterateTree(this.relations[o][n],a,o);t.story?this.iterateTree(t.story,a,o):t.stories.forEach(n=>{this.iterateTree(n,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(t,e,o,a){const n=Gs({url:t,params:e}),s=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const l=await s.get(n);if(l)return Promise.resolve(l)}const i=!Js(t)&&this.rateLimitConfig.isManagementApi?vo:void 0,r=ko(t,e,this.rateLimitConfig,i);return new Promise(async(l,p)=>{try{const c=await this.throttleManager.execute(r,"get",t,e,a);if(c.status!==200)return p(c);let m={data:c.data,headers:c.headers};const u=jj(c.headers);if(u?.max!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=u.max),c.headers?.["per-page"]&&(m=Object.assign({},m,{perPage:c.headers["per-page"]?Number.parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?Number.parseInt(c.headers.total):0})),m.data.story||m.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(m.data,e,`${g}`),m=await this.processInlineAssets(m)}e.version==="published"&&t!=="/cdn/spaces/me"&&await s.set(n,m);const d=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&m.data.cv&&(d&&pt[e.token]&&pt[e.token]!==m.data.cv&&await this.flushCache(),pt[e.token]=m.data.cv),l(m)}catch(c){if(c.response&&c.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await lj(this.retriesDelay),this.cacheResponse(t,e,o).then(l).catch(p);p(c)}})}throttledRequest(t,e,o,a){return this.client.setFetchOptions(a),this.client[t](e,o)}cacheVersions(){return pt}cacheVersion(){return pt[this.accessToken]}setCacheVersion(t){this.accessToken&&(pt[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(pt[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(Ja[t])},getAll(){return Promise.resolve(Ja)},set(t,e){return Ja[t]=e,Promise.resolve(void 0)},flush(){return Ja={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(t){if(!this.inlineAssets)return t;const e=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>e(n));let a={...o};a.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(a={...t.data.assets.find(n=>n.id===a.id),...a});for(const n in a)typeof a[n]=="object"&&(a[n]=e(a[n]));return a};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(o=>(o.content=e(o.content),o))),t}};let Yp=!1;const Zp=[],Qp=t=>new Promise((e,o)=>{if(typeof window>"u"){o(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}Yp?n():Zp.push(n)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const a=document.createElement("script");a.async=!0,a.src=t,a.id="storyblok-javascript-bridge",a.onerror=n=>o(n),a.onload=n=>{Zp.forEach(s=>s()),Yp=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(a)}),Dj=(t={})=>{const{apiOptions:e}=t;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 _j(e)}},wj=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let Ys="https://app.storyblok.com/f/storyblok-v2-latest.js";const Ij=(t={})=>{var e,o;const{bridge:a,accessToken:n,use:s=[],apiOptions:i={},bridgeUrl:r}=t;i.accessToken=i.accessToken||n;const l={bridge:a,apiOptions:i};let p={};s.forEach(m=>{p={...p,...m(l)}}),r&&(Ys=r);const c=!(typeof window>"u")&&((o=(e=window.location)==null?void 0:e.search)==null?void 0:o.includes("_storyblok_tk"));return a!==!1&&c&&Qp(Ys),p};function Cj(t,e){return Ks(e).render(t)}const Ej=()=>Qp(Ys);Q.apiPlugin=Dj,Q.getLiveStory=pc,Q.getPayload=cc,Q.handleStoryblokMessage=Uc,Q.isEditorRequest=em,Q.loadStoryblokBridge=Ej,Q.renderRichText=Cj,Q.richTextResolver=Ks,Q.sanitizeJSON=wc,Q.segmentStoryblokRichText=ij,Q.storyblok=Dc,Q.storyblokEditable=wj,Q.storyblokInit=Ij,Q.toCamelCase=si,Q.useStoryblokApi=lc,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.11",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"camelcase": "^8.0.0",
|
|
57
57
|
"morphdom": "^2.7.8",
|
|
58
|
-
"@storyblok/js": "5.1.
|
|
58
|
+
"@storyblok/js": "5.1.9"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@cypress/vite-dev-server": "^6.0.3",
|