@fileverse-dev/ddoc 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +2 -2
- package/dist/index.umd.js +1 -1
- package/dist/packages/ddoc/types.d.ts +2 -3
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
@@ -434,4 +434,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_proc
|
|
434
434
|
`,Hz="️",zz="";let Mg=null,Dg=null;function Vz(n){n===void 0&&(n=[]);const e={};Qn.groups=e;const t=new Qn;Mg==null&&(Mg=yN(Lz)),Dg==null&&(Dg=yN(_z)),de(t,"'",yg),de(t,"{",sd),de(t,"}",id),de(t,"[",ng),de(t,"]",rg),de(t,"(",sg),de(t,")",ig),de(t,"<",og),de(t,">",ag),de(t,"(",lg),de(t,")",cg),de(t,"「",ug),de(t,"」",fg),de(t,"『",dg),de(t,"』",hg),de(t,"<",pg),de(t,">",gg),de(t,"&",mg),de(t,"*",bg),de(t,"@",fo),de(t,"`",vg),de(t,"^",xg),de(t,":",ho),de(t,",",qw),de(t,"$",Ag),de(t,".",Is),de(t,"=",Eg),de(t,"!",Qw),de(t,"-",Ls),de(t,"%",kg),de(t,"|",Cg),de(t,"+",Sg),de(t,"#",Tg),de(t,"?",Ng),de(t,'"',Yw),de(t,"/",_s),de(t,";",Xw),de(t,"~",od),de(t,"_",Og),de(t,"\\",wg);const r=Pr(t,tv,Kw,{[Uw]:!0});Pr(r,tv,r);const s=Pr(t,dc,pi,{[Hw]:!0});Pr(s,dc,s);const i=Pr(t,Zw,$w,{[zw]:!0});Pr(i,dc),Pr(i,Zw,i);const o=Pr(t,gN,dN,{[uN]:!0});de(t,mN,Jw,{[uN]:!0}),de(o,mN),Pr(o,gN,o);const a=Pr(t,ev,hN,{[cN]:!0});Pr(a,ev,a),de(a,Hz,a);const l=de(a,zz);Pr(l,ev,a);const c=[[dc,s]],u=[[dc,null],[Zw,i]];for(let f=0;f<Mg.length;f++)po(t,Mg[f],Ww,pi,c);for(let f=0;f<Dg.length;f++)po(t,Dg[f],Gw,$w,u);Ra(Ww,{tld:!0,ascii:!0},e),Ra(Gw,{utld:!0,alpha:!0},e),po(t,"file",tg,pi,c),po(t,"mailto",tg,pi,c),po(t,"http",fc,pi,c),po(t,"https",fc,pi,c),po(t,"ftp",fc,pi,c),po(t,"ftps",fc,pi,c),Ra(tg,{scheme:!0,ascii:!0},e),Ra(fc,{slashscheme:!0,ascii:!0},e),n=n.sort((f,d)=>f[0]>d[0]?1:-1);for(let f=0;f<n.length;f++){const d=n[f][0],p=n[f][1]?{[Bz]:!0}:{[Fz]:!0};d.indexOf("-")>=0?p[Vw]=!0:dc.test(d)?tv.test(d)?p[Zp]=!0:p[Hw]=!0:p[Uw]=!0,fN(t,d,d,p)}return fN(t,"localhost",rd,{ascii:!0}),t.jd=new Qn(Rg),{start:t,tokens:uc({groups:e},pN)}}function $z(n,e){const t=Wz(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let a=n,l=null,c=0,u=null,f=-1,d=-1;for(;o<r&&(l=a.go(t[o]));)a=l,a.accepts()?(f=0,d=0,u=a):f>=0&&(f+=t[o].length,d++),c+=t[o].length,i+=t[o].length,o++;i-=f,o-=d,c-=f,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function Wz(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function po(n,e,t,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];n.j[l]?i=n.j[l]:(i=new Qn(r),i.jr=s.slice(),n.j[l]=i),n=i}return i=new Qn(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function yN(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const ad={defaultProtocol:"http",events:null,format:bN,formatHref:bN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function nv(n,e){e===void 0&&(e=null);let t=uc({},ad);n&&(t=uc(t,n instanceof nv?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}nv.prototype={o:ad,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:ad[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function bN(n){return n}function wN(n,e){this.t="token",this.v=n,this.tk=e}wN.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=ad.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&uc(o,u),{tagName:s,attributes:o,content:i,eventListeners:f}}};function Pg(n,e){class t extends wN{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const vN=Pg("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xN=Pg("text"),Gz=Pg("nl"),Ig=Pg("url",{isLink:!0,toHref(n){return n===void 0&&(n=ad.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==rd&&n[1].t===ho}}),Ir=n=>new Qn(n);function Kz(n){let{groups:e}=n;const t=e.domain.concat([mg,bg,fo,wg,vg,xg,Ag,Eg,Ls,Kw,kg,Cg,Sg,Tg,_s,Rg,od,Og]),r=[yg,ho,qw,Is,Qw,Ng,Yw,Xw,og,ag,sd,id,rg,ng,sg,ig,lg,cg,ug,fg,dg,hg,pg,gg],s=[mg,yg,bg,wg,vg,xg,Ag,Eg,Ls,sd,id,kg,Cg,Sg,Tg,Ng,_s,Rg,od,Og],i=Ir(),o=de(i,od);Ye(o,s,o),Ye(o,e.domain,o);const a=Ir(),l=Ir(),c=Ir();Ye(i,e.domain,a),Ye(i,e.scheme,l),Ye(i,e.slashscheme,c),Ye(a,s,o),Ye(a,e.domain,a);const u=de(a,fo);de(o,fo,u),de(l,fo,u),de(c,fo,u);const f=de(o,Is);Ye(f,s,o),Ye(f,e.domain,o);const d=Ir();Ye(u,e.domain,d),Ye(d,e.domain,d);const h=de(d,Is);Ye(h,e.domain,d);const p=Ir(vN);Ye(h,e.tld,p),Ye(h,e.utld,p),de(u,rd,p);const g=de(d,Ls);Ye(g,e.domain,d),Ye(p,e.domain,d),de(p,Is,h),de(p,Ls,g);const b=de(p,ho);Ye(b,e.numeric,vN);const y=de(a,Ls),A=de(a,Is);Ye(y,e.domain,a),Ye(A,s,o),Ye(A,e.domain,a);const v=Ir(Ig);Ye(A,e.tld,v),Ye(A,e.utld,v),Ye(v,e.domain,a),Ye(v,s,o),de(v,Is,A),de(v,Ls,y),de(v,fo,u);const w=de(v,ho),E=Ir(Ig);Ye(w,e.numeric,E);const k=Ir(Ig),S=Ir();Ye(k,t,k),Ye(k,r,S),Ye(S,t,k),Ye(S,r,S),de(v,_s,k),de(E,_s,k);const M=de(l,ho),O=de(c,ho),R=de(O,_s),D=de(R,_s);Ye(l,e.domain,a),de(l,Is,A),de(l,Ls,y),Ye(c,e.domain,a),de(c,Is,A),de(c,Ls,y),Ye(M,e.domain,k),de(M,_s,k),Ye(D,e.domain,k),Ye(D,t,k),de(D,_s,k);const F=[[sd,id],[ng,rg],[sg,ig],[og,ag],[lg,cg],[ug,fg],[dg,hg],[pg,gg]];for(let U=0;U<F.length;U++){const[K,_]=F[U],G=de(k,K);de(S,K,G),de(G,_,k);const Y=Ir(Ig);Ye(G,t,Y);const re=Ir();Ye(G,r),Ye(Y,t,Y),Ye(Y,r,re),Ye(re,t,Y),Ye(re,r,re),de(Y,_,k),de(re,_,k)}return de(i,rd,v),de(i,Jw,Gz),{start:i,tokens:pN}}function Jz(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let a=n,l=null,c=null,u=0,f=null,d=-1;for(;s<r&&!(l=a.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=l||a.go(t[s].t));)l=null,a=c,a.accepts()?(d=0,f=a):d>=0&&d++,s++,u++;if(d<0)s-=u,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(rv(xN,e,o)),o=[]),s-=d,u-=d;const h=f.t,p=t.slice(s-u,s);i.push(rv(h,e,p))}}return o.length>0&&i.push(rv(xN,e,o)),i}function rv(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const qz=typeof console<"u"&&console&&console.warn||(()=>{}),Qz="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Dt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Yz(){Qn.groups={},Dt.scanner=null,Dt.parser=null,Dt.tokenQueue=[],Dt.pluginQueue=[],Dt.customSchemes=[],Dt.initialized=!1}function AN(n,e){if(e===void 0&&(e=!1),Dt.initialized&&qz(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Qz}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
435
435
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
436
436
|
2. Cannot start or end with "-"
|
437
|
-
3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function Xz(){Dt.scanner=Vz(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=Kz(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});Dt.initialized=!0}function EN(n){return Dt.initialized||Xz(),Jz(Dt.parser.start,n,$z(Dt.scanner.start,n))}function kN(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new nv(t),s=EN(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}function Zz(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function eV(n){return new bt({key:new Ot("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=xB(t.doc,[...e]);if(OB(a).forEach(({newRange:c})=>{const u=EB(r.doc,c,h=>h.isTextblock);let f,d;if(u.length>1?(f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")),f&&d){const h=d.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],g=f.pos+d.lastIndexOf(p);if(!p)return!1;const b=EN(p).map(y=>y.toObject());if(!Zz(b))return!1;b.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate?n.validate(y.value):!0).forEach(y=>{c0(y.from,y.to,r.doc).some(A=>A.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function tV(n){return new bt({key:new Ot("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(d=>d.nodeName==="A"))return!1;const l=BE(e.state,n.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,f=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,f),!0):!1}}})}function nV(n){return new bt({key:new Ot("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=kN(a).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(n.editor.commands.setMark(n.type,{href:l.href}),!0)}}})}const rV=$n.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){AN(n);return}AN(n.scheme,n.optionalSlashes)})},onDestroy(){Yz()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",tt(this.options.HTMLAttributes,{...n,href:""}),0]:["a",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[to({find:n=>{const e=[];if(n){const t=kN(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(eV({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(tV({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(nV({editor:this.editor,type:this.type})),n}}),sV=St.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new bt({key:new Ot("placeholder"),props:{decorations:({doc:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=e,i=[];if(!r)return null;const{firstChild:o}=n.content,a=o&&o.type.isLeaf,l=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!a||!l);return n.descendants((f,d)=>{const h=s>=d&&s<=d+f.nodeSize,p=!f.isLeaf&&!f.childCount;if((h||!this.options.showOnlyCurrent)&&p){const g=[this.options.emptyNodeClass];u&&g.push(this.options.emptyEditorClass);const b=Qt.node(d,d+f.nodeSize,{class:g.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:f,pos:d,hasAnchor:h}):this.options.placeholder});i.push(b)}return this.options.includeChildren}),wt.create(n,i)}}})]}}),iV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,oV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aV=$n.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[aa({find:iV,type:this.type})]},addPasteRules(){return[to({find:oV,type:this.type})]}}),lV=vt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",tt(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),cV=/^\s*(\[([( |x])?\])\s$/,uV=vt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",tt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return i.contentEditable="false",a.type="checkbox",a.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=c.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const d=t(),h=f.doc.nodeAt(d);return f.setNodeMarkup(d,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{s.setAttribute(c,u)}),s.dataset.checked=n.attrs.checked,n.attrs.checked&&a.setAttribute("checked","checked"),i.append(a,o),s.append(i,l),Object.entries(e).forEach(([c,u])=>{s.setAttribute(c,u)}),{dom:s,contentDOM:l,update:c=>c.type!==this.type?!1:(s.dataset.checked=c.attrs.checked,c.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[Fl({find:cV,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),fV=$n.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dV(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:o}=n,a=ZB(t),l=new RegExp(`\\s${a}$`),c=i?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),f=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!f)return null;const d=o.pos-f.length,h=Array.from(f.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),g=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(p);if(s!==null&&!g)return null;const b=d+h.index;let y=b+h[0].length;return r&&l.test(f.slice(y-1,y+1))&&(h[0]+=" ",y+=1),b<o.pos&&y>=o.pos?{range:{from:b,to:y},query:h[0].slice(t.length),text:h[0]}:null}const hV=new Ot("suggestion");function pV({pluginKey:n=hV,editor:e,char:t="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:f=()=>!0,findSuggestionMatch:d=dV}){let h;const p=u==null?void 0:u(),g=new bt({key:n,view(){return{update:async(b,y)=>{var A,v,w,E,k,S,M;const O=(A=this.key)===null||A===void 0?void 0:A.getState(y),R=(v=this.key)===null||v===void 0?void 0:v.getState(b.state),D=O.active&&R.active&&O.range.from!==R.range.from,F=!O.active&&R.active,U=O.active&&!R.active,K=!F&&!U&&O.query!==R.query,_=F||D,G=K&&!D,Y=U||D;if(!_&&!G&&!Y)return;const re=Y&&!_?O:R,Z=b.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`);h={editor:e,range:re.range,query:re.query,text:re.text,items:[],command:ge=>l({editor:e,range:re.range,props:ge}),decorationNode:Z,clientRect:Z?()=>{var ge;const{decorationId:ke}=(ge=this.key)===null||ge===void 0?void 0:ge.getState(e.state),Pe=b.dom.querySelector(`[data-decoration-id="${ke}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},_&&((w=p==null?void 0:p.onBeforeStart)===null||w===void 0||w.call(p,h)),G&&((E=p==null?void 0:p.onBeforeUpdate)===null||E===void 0||E.call(p,h)),(G||_)&&(h.items=await c({editor:e,query:re.query})),Y&&((k=p==null?void 0:p.onExit)===null||k===void 0||k.call(p,h)),G&&((S=p==null?void 0:p.onUpdate)===null||S===void 0||S.call(p,h)),_&&((M=p==null?void 0:p.onStart)===null||M===void 0||M.call(p,h))},destroy:()=>{var b;h&&((b=p==null?void 0:p.onExit)===null||b===void 0||b.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(b,y,A,v){const{isEditable:w}=e,{composing:E}=e.view,{selection:k}=b,{empty:S,from:M}=k,O={...y};if(O.composing=E,w&&(S||e.view.composing)){(M<y.range.from||M>y.range.to)&&!E&&!y.composing&&(O.active=!1);const R=d({char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:k.$from}),D=`id_${Math.floor(Math.random()*4294967295)}`;R&&f({editor:e,state:v,range:R.range})?(O.active=!0,O.decorationId=y.decorationId?y.decorationId:D,O.range=R.range,O.query=R.query,O.text=R.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(b,y){var A;const{active:v,range:w}=g.getState(b.state);return v&&((A=p==null?void 0:p.onKeyDown)===null||A===void 0?void 0:A.call(p,{view:b,event:y,range:w}))||!1},decorations(b){const{active:y,range:A,decorationId:v}=g.getState(b);return y?wt.create(b.doc,[Qt.inline(A.from,A.to,{nodeName:o,class:a,"data-decoration-id":v})]):null}}});return g}const gV=St.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[pV({editor:this.editor,...this.options.suggestion})]}}),mV=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:C.jsx($k,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:C.jsx(zk,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:C.jsx(Vh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:C.jsx($h,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:C.jsx(Wh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:C.jsx(Gh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:C.jsx(Wl,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:C.jsx(n4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:C.jsx(Kh,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:C.jsx(Af,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:C.jsx(Vk,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:C.jsx(e4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var s;if((s=r.files)!=null&&s.length){const i=r.files[0],o=e.view.state.selection.from;z0(i,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:C.jsx(Kk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:C.jsx(Gk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:C.jsx(jk,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:C.jsx(Q3,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),yV=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,s=e.offsetTop,i=s+r;s<n.scrollTop?n.scrollTop-=n.scrollTop-s+5:i>t+n.scrollTop&&(n.scrollTop+=i-t-n.scrollTop+5)},bV=({items:n,command:e,editor:t})=>{const[r,s]=L.useState(0),i=L.useCallback(a=>{const l=n[a];l&&(l.title==="Continue writing"||e(l))},[e,t,n]);L.useEffect(()=>{const a=["ArrowUp","ArrowDown","Enter"],l=c=>{if(a.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(s((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(s((r+1)%n.length),!0):c.key==="Enter"?(i(r),!0):!1};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[n,r,s,i]),L.useEffect(()=>{s(0)},[n]);const o=L.useRef(null);return L.useLayoutEffect(()=>{const a=o==null?void 0:o.current,l=a==null?void 0:a.children[r];l&&a&&yV(a,l)},[r]),n.length>0?C.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:n.map((a,l)=>C.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${l===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>i(l),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:a.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:a.title}),C.jsx("p",{className:"text-xs text-neutral-500",children:a.description})]})]},l))}):null},wV=()=>{let n=null,e=null;return{onStart:t=>{n=new Lk(bV,{props:t,editor:t.editor}),e=fa("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},vV=gV.configure({suggestion:{items:mV,render:wV}}),xV=oN.extend({renderHTML(){return["div",tt(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),AV=St.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(RS),this.options.columns!==!1&&n.push(gp),n}}),EV=St.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,s=r.selection.$from.start(),i=r.selection.$to.end();return e.setTextSelection({from:s,to:i})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,s=t.selection.to,i=t.selection.$from.start(),o=t.selection.$to.end();return r>i||s<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),kV=St.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CN=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:n=>n()}];let hc;const SN=({node:n,updateAttributes:e,deleteNode:t})=>{const r=mp(),[s,i]=L.useState(),[o,a]=L.useState(0),[l,c]=L.useState(0),[u,f]=L.useState({}),d=L.useRef(null),[h,p]=L.useState(!1),g=()=>{const U={};CN.forEach(({tooltip:K,isActive:_})=>{U[K]=!!(_!=null&&_(n.attrs))}),f(U)},b=()=>{const U=document.querySelector(".ProseMirror");if(U&&c(U==null?void 0:U.clientWidth),!!d.current){if(s==="video"){const K=d.current;K.addEventListener("loadeddata",function(){a(K.videoWidth/K.videoHeight),k("left",0)})}else if(s==="iframe"){const K=d.current;K.onload=()=>{a(K.offsetWidth/K.offsetHeight),k("left",0)}}else d.current.onload=()=>{a(d.current.naturalWidth/d.current.naturalHeight)};setTimeout(()=>g(),200)}},y=U=>{hc=U};L.useEffect(()=>{b()},[]);const A=({width:U,height:K})=>U<200||K<200,v=U=>{setTimeout(()=>S(U))},w=U=>{hc=U.clientX,setTimeout(()=>{document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),p(!0)},E=()=>{hc=-1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E),p(!1)},k=(U,K)=>{var Y,re;if(!d.current){console.error("Media ref is undefined|null",{resizableImg:d.current});return}const _={width:(Y=d.current)==null?void 0:Y.width,height:(re=d.current)==null?void 0:re.height},G={width:-1,height:-1};U==="left"?G.width=_.width-Math.abs(K):(typeof _.width=="string"&&(_.width=Number(_.width)),G.width=_.width+Math.abs(K)),G.width>l&&(G.width=l),s==="iframe"?G.height=G.width/(16/9):G.height=G.width/o,!A(G)&&e(G)},S=U=>{if(hc===-1)return;const{clientX:K}=U,_=hc-K;if(_===0)return;const G=_>0?"left":"right";setTimeout(()=>{k(G,Math.abs(_)),hc=K})},[M,O]=L.useState(),[R,D]=L.useState();L.useEffect(()=>{i(n.attrs["media-type"]),g(),O(n.attrs.dataFloat),D(n.attrs.dataAlign)},[n.attrs]);const F=U=>{switch(U){case"AlignLeft":return C.jsx(vf,{size:16});case"AlignCenter":return C.jsx(D0,{size:16});case"AlignRight":return C.jsx(P0,{size:16});case"Trash2":return C.jsx(Wk,{size:16});default:return null}};return C.jsx(wf,{as:"article",className:pe("media-node-view not-prose transition-all ease-in-out w-full",M&&`f-${n.attrs.dataFloat}`,R&&`justify-${n.attrs.dataAlign}`),children:C.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[s==="img"&&C.jsx("img",{src:n.attrs.src,ref:d,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),s==="video"&&C.jsx("video",{ref:d,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:C.jsx("source",{src:n.attrs.src})}),s==="iframe"&&C.jsx("iframe",{ref:d,className:pe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:U})=>y(U),onMouseDown:w,onMouseUp:E}),C.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200 flex",children:CN.map(U=>C.jsx("div",{className:"tooltip","data-tip":U.tooltip,children:C.jsx("button",{type:"button",className:pe("btn rounded-none h-8 px-2 py-1 transition",u[U.tooltip]&&"active"),onClick:()=>{var K;return U.tooltip==="Delete"?t():(K=U.action)==null?void 0:K.call(U,e)},children:U.icon&&F(U.icon)})}))})]})]})})},CV=vt.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return da(SN)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",tt(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,s=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,s),!0}}}});var SV="https://platform.twitter.com/widgets.js",sv="createTweet",TV=function(e){var t=L.useRef(null),r=L.useState(!0),s=r[0],i=r[1];return L.useEffect(function(){var o=!0,a=require("scriptjs");return a(SV,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[sv]){console.error("Method "+sv+" is not present anymore in twttr.widget api");return}window.twttr.widgets[sv](e.tweetId,t==null?void 0:t.current,e.options).then(function(l){i(!1),e.onLoad&&e.onLoad(l)})}}),function(){o=!1}},[]),L.createElement(L.Fragment,null,s&&L.createElement(L.Fragment,null,e.placeholder),L.createElement("div",{ref:t}))};const NV=({node:n,editor:e})=>{const[t,r]=L.useState(!0);return L.useEffect(()=>{e==null||e.chain().focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:C.jsxs("div",{className:"w-full max-w-sm",children:[t&&C.jsx(HS,{width:5,height:5}),C.jsx(TV,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},OV=vt.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(this.options.HTMLAttributes,n)]},addNodeView(){return da(NV)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),RV=n=>new bt({key:new Ot("media-paste-drop"),props:{handlePaste(e,t){var s;return Array.from(((s=t.clipboardData)==null?void 0:s.items)||[]).forEach(i=>{const o=i.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var a;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const s=Array.from(((a=t.dataTransfer)==null?void 0:a.files)??[]).filter(({type:l})=>/image|video/i.test(l));if(s.length===0)return!1;t.preventDefault();const{schema:i}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(s.forEach(async l=>{const c=new FileReader;if(n){const u=i.nodes.resizableMedia.create({src:await n(l),"media-type":l.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,u);e.dispatch(f)}else c.onload=u=>{var h;const f=i.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":l.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,f);e.dispatch(d)},c.readAsDataURL(l)}),!0):!1}}}),MV=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,DV=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,PV=vt.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",tt(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",tt(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return da(SN)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[h0({find:MV,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),h0({find:DV,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[RV(this.options.uploadFn),d4()]}});function iv(n,e){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>n(...s),e)}}const IV=["top","right","bottom","left"],Bs=Math.min,mr=Math.max,Lg=Math.round,_g=Math.floor,go=n=>({x:n,y:n}),LV={left:"right",right:"left",bottom:"top",top:"bottom"},_V={start:"end",end:"start"};function ov(n,e,t){return mr(n,Bs(e,t))}function gi(n,e){return typeof n=="function"?n(e):n}function mi(n){return n.split("-")[0]}function pc(n){return n.split("-")[1]}function av(n){return n==="x"?"y":"x"}function lv(n){return n==="y"?"height":"width"}function gc(n){return["top","bottom"].includes(mi(n))?"y":"x"}function cv(n){return av(gc(n))}function BV(n,e,t){t===void 0&&(t=!1);const r=pc(n),s=cv(n),i=lv(s);let o=s==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Bg(o)),[o,Bg(o)]}function FV(n){const e=Bg(n);return[uv(n),e,uv(e)]}function uv(n){return n.replace(/start|end/g,e=>_V[e])}function jV(n,e,t){const r=["left","right"],s=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?s:r:e?r:s;case"left":case"right":return e?i:o;default:return[]}}function UV(n,e,t,r){const s=pc(n);let i=jV(mi(n),t==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(uv)))),i}function Bg(n){return n.replace(/left|right|bottom|top/g,e=>LV[e])}function HV(n){return{top:0,right:0,bottom:0,left:0,...n}}function TN(n){return typeof n!="number"?HV(n):{top:n,right:n,bottom:n,left:n}}function Fg(n){const{x:e,y:t,width:r,height:s}=n;return{width:r,height:s,top:t,left:e,right:e+r,bottom:t+s,x:e,y:t}}function NN(n,e,t){let{reference:r,floating:s}=n;const i=gc(e),o=cv(e),a=lv(o),l=mi(e),c=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(pc(e)){case"start":h[o]-=d*(t&&c?-1:1);break;case"end":h[o]+=d*(t&&c?-1:1);break}return h}const zV=async(n,e,t)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:u,y:f}=NN(c,r,l),d=r,h={},p=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x:A,y:v,data:w,reset:E}=await y({x:u,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=A??u,f=v??f,h={...h,[b]:{...h[b],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:s}):E.rects),{x:u,y:f}=NN(c,d,l)),g=-1)}return{x:u,y:f,placement:d,strategy:s,middlewareData:h}};async function ld(n,e){var t;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=gi(e,n),p=TN(h),b=a[d?f==="floating"?"reference":"floating":f],y=Fg(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(b)))==null||t?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),A=f==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),w=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},E=Fg(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:A,offsetParent:v,strategy:l}):A);return{top:(y.top-E.top+p.top)/w.y,bottom:(E.bottom-y.bottom+p.bottom)/w.y,left:(y.left-E.left+p.left)/w.x,right:(E.right-y.right+p.right)/w.x}}const VV=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=gi(n,e)||{};if(c==null)return{};const f=TN(u),d={x:t,y:r},h=cv(s),p=lv(h),g=await o.getDimensions(c),b=h==="y",y=b?"top":"left",A=b?"bottom":"right",v=b?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[h]-d[h]-i.floating[p],E=d[h]-i.reference[h],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=k?k[v]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=a.floating[v]||i.floating[p]);const M=w/2-E/2,O=S/2-g[p]/2-1,R=Bs(f[y],O),D=Bs(f[A],O),F=R,U=S-g[p]-D,K=S/2-g[p]/2+M,_=ov(F,K,U),G=!l.arrow&&pc(s)!=null&&K!==_&&i.reference[p]/2-(K<F?R:D)-g[p]/2<0,Y=G?K<F?K-F:K-U:0;return{[h]:d[h]+Y,data:{[h]:_,centerOffset:K-_-Y,...G&&{alignmentOffset:Y}},reset:G}}}),$V=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...b}=gi(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const y=mi(s),A=mi(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=d||(A||!g?[Bg(a)]:FV(a));!d&&p!=="none"&&w.push(...UV(a,g,p,v));const E=[a,...w],k=await ld(e,b),S=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&S.push(k[y]),f){const F=BV(s,o,v);S.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:s,overflows:S}],!S.every(F=>F<=0)){var O,R;const F=(((O=i.flip)==null?void 0:O.index)||0)+1,U=E[F];if(U)return{data:{index:F,overflows:M},reset:{placement:U}};let K=(R=M.filter(_=>_.overflows[0]<=0).sort((_,G)=>_.overflows[1]-G.overflows[1])[0])==null?void 0:R.placement;if(!K)switch(h){case"bestFit":{var D;const _=(D=M.map(G=>[G.placement,G.overflows.filter(Y=>Y>0).reduce((Y,re)=>Y+re,0)]).sort((G,Y)=>G[1]-Y[1])[0])==null?void 0:D[0];_&&(K=_);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function ON(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function RN(n){return IV.some(e=>n[e]>=0)}const WV=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...s}=gi(n,e);switch(r){case"referenceHidden":{const i=await ld(e,{...s,elementContext:"reference"}),o=ON(i,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:RN(o)}}}case"escaped":{const i=await ld(e,{...s,altBoundary:!0}),o=ON(i,t.floating);return{data:{escapedOffsets:o,escaped:RN(o)}}}default:return{}}}}};async function GV(n,e){const{placement:t,platform:r,elements:s}=n,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=mi(t),a=pc(t),l=gc(t)==="y",c=["left","top"].includes(o)?-1:1,u=i&&l?-1:1,f=gi(e,n);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:d*c}:{x:d*c,y:h*u}}const KV=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await GV(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},JV=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:b=>{let{x:y,y:A}=b;return{x:y,y:A}}},...l}=gi(n,e),c={x:t,y:r},u=await ld(e,l),f=gc(mi(s)),d=av(f);let h=c[d],p=c[f];if(i){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",A=h+u[b],v=h-u[y];h=ov(A,h,v)}if(o){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",A=p+u[b],v=p-u[y];p=ov(A,p,v)}const g=a.fn({...e,[d]:h,[f]:p});return{...g,data:{x:g.x-t,y:g.y-r}}}}},qV=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=gi(n,e),u={x:t,y:r},f=gc(s),d=av(f);let h=u[d],p=u[f];const g=gi(a,e),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=d==="y"?"height":"width",w=i.reference[d]-i.floating[v]+b.mainAxis,E=i.reference[d]+i.reference[v]-b.mainAxis;h<w?h=w:h>E&&(h=E)}if(c){var y,A;const v=d==="y"?"width":"height",w=["top","left"].includes(mi(s)),E=i.reference[f]-i.floating[v]+(w&&((y=o.offset)==null?void 0:y[f])||0)+(w?0:b.crossAxis),k=i.reference[f]+i.reference[v]+(w?0:((A=o.offset)==null?void 0:A[f])||0)-(w?b.crossAxis:0);p<E?p=E:p>k&&(p=k)}return{[d]:h,[f]:p}}}},QV=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...a}=gi(n,e),l=await ld(e,a),c=mi(t),u=pc(t),f=gc(t)==="y",{width:d,height:h}=r.floating;let p,g;c==="top"||c==="bottom"?(p=c,g=u===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(g=c,p=u==="end"?"top":"bottom");const b=h-l.top-l.bottom,y=d-l.left-l.right,A=Bs(h-l[p],b),v=Bs(d-l[g],y),w=!e.middlewareData.shift;let E=A,k=v;if(f?k=u||w?Bs(v,y):y:E=u||w?Bs(A,b):b,w&&!u){const M=mr(l.left,0),O=mr(l.right,0),R=mr(l.top,0),D=mr(l.bottom,0);f?k=d-2*(M!==0||O!==0?M+O:mr(l.left,l.right)):E=h-2*(R!==0||D!==0?R+D:mr(l.top,l.bottom))}await o({...e,availableWidth:k,availableHeight:E});const S=await s.getDimensions(i.floating);return d!==S.width||h!==S.height?{reset:{rects:!0}}:{}}}};function mc(n){return MN(n)?(n.nodeName||"").toLowerCase():"#document"}function yr(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yi(n){var e;return(e=(MN(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function MN(n){return n instanceof Node||n instanceof yr(n).Node}function Fs(n){return n instanceof Element||n instanceof yr(n).Element}function js(n){return n instanceof HTMLElement||n instanceof yr(n).HTMLElement}function DN(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof yr(n).ShadowRoot}function cd(n){const{overflow:e,overflowX:t,overflowY:r,display:s}=ns(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(s)}function YV(n){return["table","td","th"].includes(mc(n))}function fv(n){const e=dv(),t=ns(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function XV(n){let e=mo(n);for(;js(e)&&!yc(e);){if(fv(e))return e;e=mo(e)}return null}function dv(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function yc(n){return["html","body","#document"].includes(mc(n))}function ns(n){return yr(n).getComputedStyle(n)}function jg(n){return Fs(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function mo(n){if(mc(n)==="html")return n;const e=n.assignedSlot||n.parentNode||DN(n)&&n.host||yi(n);return DN(e)?e.host:e}function PN(n){const e=mo(n);return yc(e)?n.ownerDocument?n.ownerDocument.body:n.body:js(e)&&cd(e)?e:PN(e)}function ud(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=PN(n),i=s===((r=n.ownerDocument)==null?void 0:r.body),o=yr(s);return i?e.concat(o,o.visualViewport||[],cd(s)?s:[],o.frameElement&&t?ud(o.frameElement):[]):e.concat(s,ud(s,[],t))}function IN(n){const e=ns(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=js(n),i=s?n.offsetWidth:t,o=s?n.offsetHeight:r,a=Lg(t)!==i||Lg(r)!==o;return a&&(t=i,r=o),{width:t,height:r,$:a}}function hv(n){return Fs(n)?n:n.contextElement}function bc(n){const e=hv(n);if(!js(e))return go(1);const t=e.getBoundingClientRect(),{width:r,height:s,$:i}=IN(e);let o=(i?Lg(t.width):t.width)/r,a=(i?Lg(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const ZV=go(0);function LN(n){const e=yr(n);return!dv()||!e.visualViewport?ZV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function e$(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==yr(n)?!1:e}function Ma(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),i=hv(n);let o=go(1);e&&(r?Fs(r)&&(o=bc(r)):o=bc(n));const a=e$(i,t,r)?LN(i):go(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,f=s.height/o.y;if(i){const d=yr(i),h=r&&Fs(r)?yr(r):r;let p=d,g=p.frameElement;for(;g&&r&&h!==p;){const b=bc(g),y=g.getBoundingClientRect(),A=ns(g),v=y.left+(g.clientLeft+parseFloat(A.paddingLeft))*b.x,w=y.top+(g.clientTop+parseFloat(A.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=v,c+=w,p=yr(g),g=p.frameElement}}return Fg({width:u,height:f,x:l,y:c})}const t$=[":popover-open",":modal"];function pv(n){return t$.some(e=>{try{return n.matches(e)}catch{return!1}})}function n$(n){let{elements:e,rect:t,offsetParent:r,strategy:s}=n;const i=s==="fixed",o=yi(r),a=e?pv(e.floating):!1;if(r===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=go(1);const u=go(0),f=js(r);if((f||!f&&!i)&&((mc(r)!=="body"||cd(o))&&(l=jg(r)),js(r))){const d=Ma(r);c=bc(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x,y:t.y*c.y-l.scrollTop*c.y+u.y}}function r$(n){return Array.from(n.getClientRects())}function _N(n){return Ma(yi(n)).left+jg(n).scrollLeft}function s$(n){const e=yi(n),t=jg(n),r=n.ownerDocument.body,s=mr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=mr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+_N(n);const a=-t.scrollTop;return ns(r).direction==="rtl"&&(o+=mr(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:a}}function i$(n,e){const t=yr(n),r=yi(n),s=t.visualViewport;let i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=dv();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}function o$(n,e){const t=Ma(n,!0,e==="fixed"),r=t.top+n.clientTop,s=t.left+n.clientLeft,i=js(n)?bc(n):go(1),o=n.clientWidth*i.x,a=n.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function BN(n,e,t){let r;if(e==="viewport")r=i$(n,t);else if(e==="document")r=s$(yi(n));else if(Fs(e))r=o$(e,t);else{const s=LN(n);r={...e,x:e.x-s.x,y:e.y-s.y}}return Fg(r)}function FN(n,e){const t=mo(n);return t===e||!Fs(t)||yc(t)?!1:ns(t).position==="fixed"||FN(t,e)}function a$(n,e){const t=e.get(n);if(t)return t;let r=ud(n,[],!1).filter(a=>Fs(a)&&mc(a)!=="body"),s=null;const i=ns(n).position==="fixed";let o=i?mo(n):n;for(;Fs(o)&&!yc(o);){const a=ns(o),l=fv(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||cd(o)&&!l&&FN(n,o))?r=r.filter(u=>u!==o):s=a,o=mo(o)}return e.set(n,r),r}function l$(n){let{element:e,boundary:t,rootBoundary:r,strategy:s}=n;const o=[...t==="clippingAncestors"?pv(e)?[]:a$(e,this._c):[].concat(t),r],a=o[0],l=o.reduce((c,u)=>{const f=BN(e,u,s);return c.top=mr(f.top,c.top),c.right=Bs(f.right,c.right),c.bottom=Bs(f.bottom,c.bottom),c.left=mr(f.left,c.left),c},BN(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function c$(n){const{width:e,height:t}=IN(n);return{width:e,height:t}}function u$(n,e,t){const r=js(e),s=yi(e),i=t==="fixed",o=Ma(n,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=go(0);if(r||!r&&!i)if((mc(e)!=="body"||cd(s))&&(a=jg(e)),r){const f=Ma(e,!0,i,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&(l.x=_N(s));const c=o.left+a.scrollLeft-l.x,u=o.top+a.scrollTop-l.y;return{x:c,y:u,width:o.width,height:o.height}}function gv(n){return ns(n).position==="static"}function jN(n,e){return!js(n)||ns(n).position==="fixed"?null:e?e(n):n.offsetParent}function UN(n,e){const t=yr(n);if(pv(n))return t;if(!js(n)){let s=mo(n);for(;s&&!yc(s);){if(Fs(s)&&!gv(s))return s;s=mo(s)}return t}let r=jN(n,e);for(;r&&YV(r)&&gv(r);)r=jN(r,e);return r&&yc(r)&&gv(r)&&!fv(r)?t:r||XV(n)||t}const f$=async function(n){const e=this.getOffsetParent||UN,t=this.getDimensions,r=await t(n.floating);return{reference:u$(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function d$(n){return ns(n).direction==="rtl"}const h$={convertOffsetParentRelativeRectToViewportRelativeRect:n$,getDocumentElement:yi,getClippingRect:l$,getOffsetParent:UN,getElementRects:f$,getClientRects:r$,getDimensions:c$,getScale:bc,isElement:Fs,isRTL:d$};function p$(n,e){let t=null,r;const s=yi(n);function i(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:d}=n.getBoundingClientRect();if(a||e(),!f||!d)return;const h=_g(u),p=_g(s.clientWidth-(c+f)),g=_g(s.clientHeight-(u+d)),b=_g(c),A={rootMargin:-h+"px "+-p+"px "+-g+"px "+-b+"px",threshold:mr(0,Bs(1,l))||1};let v=!0;function w(E){const k=E[0].intersectionRatio;if(k!==l){if(!v)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}v=!1}try{t=new IntersectionObserver(w,{...A,root:s.ownerDocument})}catch{t=new IntersectionObserver(w,A)}t.observe(n)}return o(!0),i}function g$(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=hv(n),u=s||i?[...c?ud(c):[],...ud(e)]:[];u.forEach(y=>{s&&y.addEventListener("scroll",t,{passive:!0}),i&&y.addEventListener("resize",t)});const f=c&&a?p$(c,t):null;let d=-1,h=null;o&&(h=new ResizeObserver(y=>{let[A]=y;A&&A.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),t()}),c&&!l&&h.observe(c),h.observe(e));let p,g=l?Ma(n):null;l&&b();function b(){const y=Ma(n);g&&(y.x!==g.x||y.y!==g.y||y.width!==g.width||y.height!==g.height)&&t(),g=y,p=requestAnimationFrame(b)}return t(),()=>{var y;u.forEach(A=>{s&&A.removeEventListener("scroll",t),i&&A.removeEventListener("resize",t)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const m$=KV,y$=JV,b$=$V,w$=QV,v$=WV,HN=VV,x$=qV,A$=(n,e,t)=>{const r=new Map,s={platform:h$,...t},i={...s.platform,_c:r};return zV(n,e,{...s,platform:i})};var Ug=typeof document<"u"?L.useLayoutEffect:L.useEffect;function Hg(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!Hg(n[r],e[r]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=t;r--!==0;){const i=s[r];if(!(i==="_owner"&&n.$$typeof)&&!Hg(n[i],e[i]))return!1}return!0}return n!==n&&e!==e}function zN(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function VN(n,e){const t=zN(n);return Math.round(e*t)/t}function $N(n){const e=H.useRef(n);return Ug(()=>{e.current=n}),e}function E$(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=H.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,h]=H.useState(r);Hg(d,r)||h(r);const[p,g]=H.useState(null),[b,y]=H.useState(null),A=H.useCallback(Y=>{Y!==k.current&&(k.current=Y,g(Y))},[]),v=H.useCallback(Y=>{Y!==S.current&&(S.current=Y,y(Y))},[]),w=i||p,E=o||b,k=H.useRef(null),S=H.useRef(null),M=H.useRef(u),O=l!=null,R=$N(l),D=$N(s),F=H.useCallback(()=>{if(!k.current||!S.current)return;const Y={placement:e,strategy:t,middleware:d};D.current&&(Y.platform=D.current),A$(k.current,S.current,Y).then(re=>{const Z={...re,isPositioned:!0};U.current&&!Hg(M.current,Z)&&(M.current=Z,sy.flushSync(()=>{f(Z)}))})},[d,e,t,D]);Ug(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(Y=>({...Y,isPositioned:!1})))},[c]);const U=H.useRef(!1);Ug(()=>(U.current=!0,()=>{U.current=!1}),[]),Ug(()=>{if(w&&(k.current=w),E&&(S.current=E),w&&E){if(R.current)return R.current(w,E,F);F()}},[w,E,F,R,O]);const K=H.useMemo(()=>({reference:k,floating:S,setReference:A,setFloating:v}),[A,v]),_=H.useMemo(()=>({reference:w,floating:E}),[w,E]),G=H.useMemo(()=>{const Y={position:t,left:0,top:0};if(!_.floating)return Y;const re=VN(_.floating,u.x),Z=VN(_.floating,u.y);return a?{...Y,transform:"translate("+re+"px, "+Z+"px)",...zN(_.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:re,top:Z}},[t,a,_.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:F,refs:K,elements:_,floatingStyles:G}),[u,F,K,_,G])}const k$=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:s}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?HN({element:r.current,padding:s}).fn(t):{}:r?HN({element:r,padding:s}).fn(t):{}}}},C$=(n,e)=>({...m$(n),options:[n,e]}),S$=(n,e)=>({...y$(n),options:[n,e]}),T$=(n,e)=>({...x$(n),options:[n,e]}),N$=(n,e)=>({...b$(n),options:[n,e]}),O$=(n,e)=>({...w$(n),options:[n,e]}),R$=(n,e)=>({...v$(n),options:[n,e]}),M$=(n,e)=>({...k$(n),options:[n,e]});var D$="Arrow",WN=H.forwardRef((n,e)=>{const{children:t,width:r=10,height:s=5,...i}=n;return C.jsx(Kn.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});WN.displayName=D$;var P$=WN;function I$(n){const[e,t]=H.useState(void 0);return ha(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=n.offsetWidth,a=n.offsetHeight;t({width:o,height:a})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}var mv="Popper",[GN,KN]=V0(mv),[L$,JN]=GN(mv),qN=n=>{const{__scopePopper:e,children:t}=n,[r,s]=H.useState(null);return C.jsx(L$,{scope:e,anchor:r,onAnchorChange:s,children:t})};qN.displayName=mv;var QN="PopperAnchor",YN=H.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...s}=n,i=JN(QN,t),o=H.useRef(null),a=Or(e,o);return H.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:C.jsx(Kn.div,{...s,ref:a})});YN.displayName=QN;var yv="PopperContent",[_$,B$]=GN(yv),XN=H.forwardRef((n,e)=>{var He,Le,Ze,le,ze,ae;const{__scopePopper:t,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:p,...g}=n,b=JN(yv,t),[y,A]=H.useState(null),v=Or(e,be=>A(be)),[w,E]=H.useState(null),k=I$(w),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,O=r+(i!=="center"?"-"+i:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],F=D.length>0,U={padding:R,boundary:D.filter(j$),altBoundary:F},{refs:K,floatingStyles:_,placement:G,isPositioned:Y,middlewareData:re}=E$({strategy:"fixed",placement:O,whileElementsMounted:(...be)=>g$(...be,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[C$({mainAxis:s+M,alignmentAxis:o}),l&&S$({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T$():void 0,...U}),l&&N$({...U}),O$({...U,apply:({elements:be,rects:_e,availableWidth:z,availableHeight:J})=>{const{width:ne,height:ce}=_e.reference,P=be.floating.style;P.setProperty("--radix-popper-available-width",`${z}px`),P.setProperty("--radix-popper-available-height",`${J}px`),P.setProperty("--radix-popper-anchor-width",`${ne}px`),P.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),w&&M$({element:w,padding:a}),U$({arrowWidth:S,arrowHeight:M}),d&&R$({strategy:"referenceHidden",...U})]}),[Z,ge]=tO(G),ke=ro(p);ha(()=>{Y&&(ke==null||ke())},[Y,ke]);const Pe=(He=re.arrow)==null?void 0:He.x,Ce=(Le=re.arrow)==null?void 0:Le.y,Ee=((Ze=re.arrow)==null?void 0:Ze.centerOffset)!==0,[Ue,Fe]=H.useState();return ha(()=>{y&&Fe(window.getComputedStyle(y).zIndex)},[y]),C.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:Y?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ue,"--radix-popper-transform-origin":[(le=re.transformOrigin)==null?void 0:le.x,(ze=re.transformOrigin)==null?void 0:ze.y].join(" "),...((ae=re.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:C.jsx(_$,{scope:t,placedSide:Z,onArrowChange:E,arrowX:Pe,arrowY:Ce,shouldHideArrow:Ee,children:C.jsx(Kn.div,{"data-side":Z,"data-align":ge,...g,ref:v,style:{...g.style,animation:Y?void 0:"none"}})})})});XN.displayName=yv;var ZN="PopperArrow",F$={top:"bottom",right:"left",bottom:"top",left:"right"},eO=H.forwardRef(function(e,t){const{__scopePopper:r,...s}=e,i=B$(ZN,r),o=F$[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(P$,{...s,ref:t,style:{...s.style,display:"block"}})})});eO.displayName=ZN;function j$(n){return n!==null}var U$=n=>({name:"transformOrigin",options:n,fn(e){var b,y,A;const{placement:t,rects:r,middlewareData:s}=e,o=((b=s.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:n.arrowWidth,l=o?0:n.arrowHeight,[c,u]=tO(t),f={start:"0%",center:"50%",end:"100%"}[u],d=(((y=s.arrow)==null?void 0:y.x)??0)+a/2,h=(((A=s.arrow)==null?void 0:A.y)??0)+l/2;let p="",g="";return c==="bottom"?(p=o?f:`${d}px`,g=`${-l}px`):c==="top"?(p=o?f:`${d}px`,g=`${r.floating.height+l}px`):c==="right"?(p=`${-l}px`,g=o?f:`${h}px`):c==="left"&&(p=`${r.floating.width+l}px`,g=o?f:`${h}px`),{data:{x:p,y:g}}}});function tO(n){const[e,t="center"]=n.split("-");return[e,t]}var H$=qN,nO=YN,z$=XN,V$=eO,bv="Popover",[rO,oQ]=V0(bv,[KN]),fd=KN(),[$$,Da]=rO(bv),sO=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=fd(e),l=H.useRef(null),[c,u]=H.useState(!1),[f=!1,d]=qk({prop:r,defaultProp:s,onChange:i});return C.jsx(H$,{...a,children:C.jsx($$,{scope:e,contentId:qh(),triggerRef:l,open:f,onOpenChange:d,onOpenToggle:H.useCallback(()=>d(h=>!h),[d]),hasCustomAnchor:c,onCustomAnchorAdd:H.useCallback(()=>u(!0),[]),onCustomAnchorRemove:H.useCallback(()=>u(!1),[]),modal:o,children:t})})};sO.displayName=bv;var iO="PopoverAnchor",W$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(iO,t),i=fd(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return H.useEffect(()=>(o(),()=>a()),[o,a]),C.jsx(nO,{...i,...r,ref:e})});W$.displayName=iO;var oO="PopoverTrigger",aO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(oO,t),i=fd(t),o=Or(e,s.triggerRef),a=C.jsx(Kn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":dO(s.open),...r,ref:o,onClick:fr(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:C.jsx(nO,{asChild:!0,...i,children:a})});aO.displayName=oO;var G$="PopoverPortal",[aQ,K$]=rO(G$,{forceMount:void 0}),wc="PopoverContent",lO=H.forwardRef((n,e)=>{const t=K$(wc,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=Da(wc,n.__scopePopover);return C.jsx(kf,{present:r||i.open,children:i.modal?C.jsx(J$,{...s,ref:e}):C.jsx(q$,{...s,ref:e})})});lO.displayName=wc;var J$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(null),s=Or(e,r),i=H.useRef(!1);return H.useEffect(()=>{const o=r.current;if(o)return xC(o)},[]),C.jsx(eb,{as:Qh,allowPinchZoom:!0,children:C.jsx(cO,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fr(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fr(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fr(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),q$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(!1),s=H.useRef(!1);return C.jsx(cO,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),cO=H.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=n,d=Da(wc,t),h=fd(t);return oC(),C.jsx(Ef,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:C.jsx(G0,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),children:C.jsx(z$,{"data-state":dO(d.open),role:"dialog",id:d.contentId,...h,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),uO="PopoverClose",fO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(uO,t);return C.jsx(Kn.button,{type:"button",...r,ref:e,onClick:fr(n.onClick,()=>s.onOpenChange(!1))})});fO.displayName=uO;var Q$="PopoverArrow",Y$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=fd(t);return C.jsx(V$,{...s,...r,ref:e})});Y$.displayName=Q$;function dO(n){return n?"open":"closed"}var X$=sO,Z$=aO,e9=lO,zg=fO;const Vg=({children:n,isActive:e,onClick:t,disabled:r,className:s})=>{const i=pe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",s);return C.jsx("button",{className:i,disabled:r,onClick:t,children:n})},t9=(n,e,t)=>{const r=L.useCallback(()=>{const a=n.chain();a.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&a.setParagraph(),a.run()},[n,t,e==null?void 0:e.type.name]),s=L.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:a}=n.state.selection,l=a.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),l.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:s,copyNodeToClipboard:i,deleteNode:o}},n9=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[s,i]=L.useState(!1),o=t9(t,n,e()),a=mp(),l=["https://twitter.com","https://x.com"],c=L.useMemo(()=>{const{content:O}=n.content;return O[0].type.name==="table"},[n.content]),u=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[0])==null?void 0:R.text},[n.content]),f=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[1])==null?void 0:R.text},[n.content]),d=L.useMemo(()=>{const{content:O}=n.content;return O[0].content.content.find(R=>{var D;return(D=R==null?void 0:R.text)==null?void 0:D.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let O=u;if(u.includes("<iframe"))O=f;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://www.youtube.com/embed/${K[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://player.vimeo.com/video/${K[1]}`);break}default:return}const R=640,D=360,F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===0?F:F+1,to:U}).setIframe({src:O,width:R,height:D}).run())},p=O=>{const R=O.match(/\/status\/([0-9]*)/);return R&&R.length>0?R[1]:null},g=()=>{if(!u)return;let O=u;const R=l.some(K=>u.includes(K)),D=p(u);R&&D?O=D:d&&(O=p(d.text));const F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===2?F:F+1,to:U}).setTweetEmbed({tweetId:O}).run())},b=()=>{const O=e()+n.nodeSize;t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},y=()=>{const O=e();t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},A=()=>{r()},v=O=>{O.altKey?E():w()},w=()=>{b()},E=()=>{y()},k=O=>{O.altKey&&A()},M=iv(()=>{if(l.some(O=>u.includes(O))||d!=null&&d.text){g();return}else{h();return}},1e3);return L.useEffect(()=>{u&&M()},[u]),C.jsxs(wf,{as:"div",className:pe("flex gap-2 group w-full relative justify-center items-start",a&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[C.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[C.jsx(_S,{content:C.jsxs("div",{className:"flex flex-col w-40",children:[C.jsx("div",{className:"text-xs",children:"Click to add below"}),C.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:v,children:C.jsx(i4,{size:18})})}),C.jsxs(X$,{open:s,onOpenChange:i,children:[C.jsx(Z$,{asChild:!0,children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:k,children:C.jsx(Z3,{size:18})})}),C.jsx(e9,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:C.jsxs(Tb,{className:"p-2 flex flex-col min-w-[16rem]",children:[C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.resetTextFormatting,children:[C.jsx(o4,{size:18}),"Clear formatting"]})}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.copyNodeToClipboard,children:[C.jsx(q3,{size:18}),"Copy to clipboard"]})}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.duplicateNode,children:[C.jsx(Y3,{size:18}),"Duplicate"]})}),C.jsx(If.Divider,{horizontal:!0}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[C.jsx(Wk,{size:18}),"Delete"]})})]})})]})]}),C.jsx(Ik,{className:pe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r9=vt.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,s=n!==void 0||n!==null?r:n;return t().insertContentAt(s,{type:this.name,content:[{type:"paragraph"}]}).focus(s+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;const o=[];if(e.doc.nodesBetween(r,s,l=>{if(l.type.name===this.name){const c=e.schema.nodes.listItem.create(null,l.content);c&&o.push(c)}}),o.length===0)return!1;const a=e.schema.nodes[n].create(null,o);return a?(i=i.replaceRangeWith(r,s,a),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,s,(o,a)=>{if(o.type.name===n){const l=e.schema.nodes[this.name].create(null,o.content);i=i.insert(a,l)}}),t(i),!0}}},addNodeView(){return da(n9)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:s}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let o=-1,a="";s.descendants((u,f)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[d,h]=[f,f+u.nodeSize];return d<=t&&r<=h&&(o=h,a=u.type.name),!1});const l=(c=s.slice(t,o))==null?void 0:c.toJSON().content;try{return a==="codeBlock"?n.chain().newlineInCode().focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let wv,vv;if(typeof WeakMap<"u"){let n=new WeakMap;wv=e=>n.get(e),vv=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;wv=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},vv=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class vc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Bt{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new vc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new vc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return wv(e)||vv(e,s9(e))}}function s9(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=i9(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let g=f.child(p),{colspan:b,rowspan:y,colwidth:A}=g.attrs;for(let v=0;v<y;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-v});break}let w=s+v*e;for(let E=0;E<b;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:b-E});let k=A&&A[E];if(k){let S=(w+E)%e*2,M=o[S];M==null||M!=k&&o[S+1]==1?(o[S]=k,o[S+1]=1):M==k&&o[S+1]++}}}s+=b,u+=g.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Bt(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&o9(a,o,n),a}function i9(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function o9(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=a9(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a9(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const yo=new Ot("selectingCells");function xc(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function l9(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function rs(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function $g(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:xc(e.$head)||c9(e.$head)}function c9(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function xv(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u9(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Av(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function hO(n,e,t){let r=n.start(-1),i=Bt.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function an(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function Pa(n,e,t=1){let r=an(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function pO(n,e,t=1){let r=an(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function f9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class it extends Ie{constructor(e,t=e){let r=e.node(-1),s=Bt.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Ay(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(xv(r)&&xv(s)&&Av(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?it.rowSelection(r,s):i&&this.isColSelection()?it.colSelection(r,s):new it(r,s)}return Me.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Bt.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),g=s.left-h.left,b=h.right-s.right;if(g>0||b>0){let y=p.attrs;g>0&&(y=Pa(y,0,g)),b>0&&(y=Pa(y,y.colspan-b,b)),h.left<s.left?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){let y=an(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}}o.push(e.child(l).copy(oe.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new ue(oe.from(a),1,1)}replace(e,t=ue.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?ue.empty:t)}let i=Ie.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ue(oe.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Bt.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new it(e,t)}isRowSelection(){let e=Bt.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof it&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new it(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new it(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new it(e.resolve(t),e.resolve(r))}getBookmark(){return new Ev(this.$anchorCell.pos,this.$headCell.pos)}}it.prototype.visible=!1,Ie.jsonID("cell",it);class Ev{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ev(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Av(t,r)?new it(t,r):Ie.near(r,1)}}function d9(n){if(!(n.selection instanceof it))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Qt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),wt.create(n.doc,e)}function h9({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function p9({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function g9(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof Ne&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=it.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=it.rowSelection(a,a)}else if(!t){let a=Bt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=it.create(s,l+1,c)}}else r instanceof Me&&h9(r)?i=Me.create(s,r.from):r instanceof Me&&p9(r)&&(i=Me.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function m9(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=kv(xn(o).row,new ue(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?kv(xn(o).row,new ue(e,t,r)).content:e);else return null;return y9(o,a)}function y9(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(oe.empty),t[s]<r){let i=xn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(oe.from(o))}return{height:e.length,width:r,rows:e}}function kv(n,e){let t=n.createAndFill();return new vy(t).replace(0,t.content.size,e).doc}function b9({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(Pa(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(oe.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(an(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(oe.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function w9(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=xn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let b=e.width;b<s;b++)p.push(g);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let b=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==l.header_cell;f.push(b?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,oe.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function gO(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,an(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(an(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function mO(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,Pa(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(Pa(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function yO(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Bt.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Bt.get(i),d=f.mapping.maps.length}w9(f,o,i,t,c,u,d)&&h(),gO(f,o,i,t,l,c,a,d)&&h(),gO(f,o,i,t,l,c,u,d)&&h(),mO(f,o,i,t,a,u,l,d)&&h(),mO(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let g=o.positionAt(p,l,i),b=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(g+t),f.mapping.slice(d).map(b+t),new ue(s.rows[p-a],0,0))}h(),f.setSelection(new it(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const v9=Yy({ArrowLeft:Gg("horiz",-1),ArrowRight:Gg("horiz",1),ArrowUp:Gg("vert",-1),ArrowDown:Gg("vert",1),"Shift-ArrowLeft":Kg("horiz",-1),"Shift-ArrowRight":Kg("horiz",1),"Shift-ArrowUp":Kg("vert",-1),"Shift-ArrowDown":Kg("vert",1),Backspace:Jg,"Mod-Backspace":Jg,Delete:Jg,"Mod-Delete":Jg});function Wg(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gg(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof it)return Wg(t,r,Ie.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=bO(s,n,e);if(o==null)return!1;if(n=="horiz")return Wg(t,r,Ie.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=hO(a,n,e),c;return l?c=Ie.near(l,1):e<0?c=Ie.near(t.doc.resolve(a.before(-1)),-1):c=Ie.near(t.doc.resolve(a.after(-1)),1),Wg(t,r,c)}}}function Kg(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof it)){let a=bO(s,n,e);if(a==null)return!1;i=new it(t.doc.resolve(a))}let o=hO(i.$headCell,n,e);return o?Wg(t,r,new it(i.$anchorCell,o)):!1}}function Jg(n,e){let t=n.selection;if(!(t instanceof it))return!1;if(e){let r=n.tr,s=xn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new ue(s,0,0))}),r.docChanged&&e(r)}return!0}function x9(n,e){let t=n.state.doc,r=xc(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new it(r))),!0):!1}function A9(n,e,t){if(!rs(n.state))return!1;let r=m9(t),s=n.state.selection;if(s instanceof it){r||(r={width:1,height:1,rows:[oe.from(kv(xn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Bt.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=b9(r,a.right-a.left,a.bottom-a.top),yO(n.state,n.dispatch,o,a,r),!0}else if(r){let i=$g(n.state),o=i.start(-1);return yO(n.state,n.dispatch,o,Bt.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function E9(n,e){if(e.ctrlKey||e.metaKey)return;let t=wO(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof it)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=xc(n.state.selection.$anchor))!=null&&Cv(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=Cv(n,l),u=yo.getState(n.state)==null;if(!c||!Av(a,c))if(u)c=a;else return;let f=new it(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(yo,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),yo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(yo,-1))}function o(a){let l=yo.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(wO(n,a.target)!=t&&(c=Cv(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function bO(n,e,t){if(!(n.state.selection instanceof Me))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function wO(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Cv(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?xc(n.state.doc.resolve(t.pos)):null}const k9=new Ot("fix-tables");function vO(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?vO(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function xO(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=C9(n,s,i,t))};return e?e.doc!=n.doc&&vO(e.doc,n.doc,0,r):n.doc.descendants(r),t}function C9(n,e,t,r){let s=Bt.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pa(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let b=0;b<d;b++)p.push(xn(n.schema)[h].createAndFill());let g=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(g),p)}c=f}return r.setMeta(k9,{fixTables:!0})}function Us(n){let e=n.selection,t=$g(n),r=t.node(-1),s=t.start(-1),i=Bt.get(r),o;return e instanceof it?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function AO(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;f9(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,pO(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?xn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function S9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.left))}return!0}function T9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.right))}return!0}function N9(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,Pa(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;N9(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function R9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function EO(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;R9(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,an(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?xn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,xn(r.type.schema).row.create(null,o)),n}function M9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.top))}return!0}function D9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.bottom))}return!0}function P9(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,an(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(an(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function I9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;P9(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function kO(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function L9({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function CO(n,e){let t=n.selection;if(!(t instanceof it)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Us(n),{map:s}=r;if(L9(s,r))return!1;if(e){let i=n.tr,o={},a=oe.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{kO(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,an(pO(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=kO(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new it(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function SO(n,e){const t=xn(n.schema);return _9(({node:r})=>t[r.type.spec.tableRole])(n,e)}function _9(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof it){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=l9(r.$from),!s)return!1;i=xc(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=an(o,"rowspan",1)),o.colspan>1&&(o=an(o,"colspan",1));let c=Us(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?an(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[g]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof it&&u.setSelection(new it(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function B9(n,e){return function(t,r){if(!rs(t))return!1;let s=$g(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof it?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,an(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,an(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function F9(n){return function(e,t){if(!rs(e))return!1;if(t){let r=xn(e.schema),s=Us(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new vc(s.left,0,s.right,s.map.height):n=="row"?new vc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function TO(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function dd(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?F9(n):function(t,r){if(!rs(t))return!1;if(r){let s=xn(t.schema),i=Us(t),o=t.tr,a=TO("row",i,s),l=TO("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new vc(0,u,1,i.map.height):n=="row"?new vc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,d,g.attrs)}),r(o)}return!0}}dd("row",{useDeprecatedLogic:!0}),dd("column",{useDeprecatedLogic:!0});let j9=dd("cell",{useDeprecatedLogic:!0});function U9(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function NO(n){return function(e,t){if(!rs(e))return!1;let r=U9($g(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Me.between(s,u9(s))).scrollIntoView())}return!0}}}function H9(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let z9=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Sv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sv(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let g=s==f?i:h&&h[p],b=g?g+"px":"";o+=g||r,g||(a=!1),l?(l.style.width!=b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const Lr=new Ot("tableColumnResizing");function V9({handleWidth:n=5,cellMinWidth:e=25,View:t=z9,lastColumnResizable:r=!0}={}){return new bt({key:Lr,state:{init(i,o){return this.spec.props.nodeViews[xn(o.schema).table.name]=(a,l)=>new t(a,e,l),new hd(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return Lr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){$9(i,o,n,e,r)},mouseleave(i){W9(i)},mousedown(i,o){G9(i,o,e)}},decorations(i){let o=Lr.getState(i);if(o.activeHandle>-1)return X9(i,o.activeHandle)},nodeViews:{}}})}class hd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new hd(r.setHandle,null);if(r&&r.setDragging!==void 0)return new hd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);xv(e.doc.resolve(s))||(s=null),t=new hd(s,t.dragging)}return t}}function $9(n,e,t,r,s){let i=Lr.getState(n.state);if(!i.dragging){let o=J9(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=OO(n,e,"left"):c-e.clientX<=t&&(a=OO(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Bt.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}MO(n,a)}}}function W9(n){let e=Lr.getState(n.state);e.activeHandle>-1&&!e.dragging&&MO(n,-1)}function G9(n,e,t){let r=Lr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=K9(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=Lr.getState(n.state);c.dragging&&(q9(n,c.activeHandle,RO(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(Lr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=Lr.getState(n.state),u=RO(c.dragging,l,t);Q9(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function K9(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function J9(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function OO(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=xc(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Bt.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function RO(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function MO(n,e){n.dispatch(n.state.tr.setMeta(Lr,{setHandle:e}))}function q9(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():Y9(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,an(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function Q9(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Bt.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Sv(i,l.firstChild,l,r,a,t)}function Y9(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X9(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Qt.widget(f,d))}}return wt.create(n.doc,t)}function Z9({allowTableNodeSelection:n=!1}={}){return new bt({key:yo,state:{init(){return null},apply(e,t){let r=e.getMeta(yo);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:d9,handleDOMEvents:{mousedown:E9},createSelectionBetween(e){if(yo.getState(e.state)!=null)return e.state.selection},handleTripleClick:x9,handleKeyDown:v9,handlePaste:A9},appendTransaction(e,t,r){return g9(r,xO(r,t),n)}})}function DO(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let g=0;g<h;g+=1,d+=1){const b=s===d?i:p&&p[g],y=b?`${b}px`:"";o+=b||r,b||(a=!1),l?(l.style.width!==y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eW{constructor(e,t){$(this,"node");$(this,"cellMinWidth");$(this,"dom");$(this,"table");$(this,"colgroup");$(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),DO(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,DO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function PO(n,e){return n.createAndFill()}function tW(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nW(n,e,t,r,s){const i=tW(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=PO(i.cell);if(u&&a.push(u),r){const f=PO(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function rW(n){return n instanceof it}const qg=({editor:n})=>{const{selection:e}=n.state;if(!rW(e))return!1;let t=0;const r=a0(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},sW=vt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eW,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",tt(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=nW(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Me.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>S9(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>T9(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O9(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M9(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D9(n,e),deleteRow:()=>({state:n,dispatch:e})=>I9(n,e),deleteTable:()=>({state:n,dispatch:e})=>H9(n,e),mergeCells:()=>({state:n,dispatch:e})=>CO(n,e),splitCell:()=>({state:n,dispatch:e})=>SO(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dd("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dd("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>j9(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>CO(n,e)?!0:SO(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>B9(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>NO(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>NO(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&xO(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=it.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:qg,"Mod-Backspace":qg,Delete:qg,"Mod-Delete":qg}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[V9({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z9({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(xe(n,"tableRole",e))}}});function IO(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var LO=typeof window<"u"&&typeof document<"u";function Tv(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function _O(){return LO&&document.createElement("div")}function iW(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function BO(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!BO(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oW(n){var e=[];return n.forEach(function(t){e.find(function(r){return BO(t,r)})||e.push(t)}),e}function aW(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oW([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Nv=LO?L.useLayoutEffect:L.useEffect;function lW(n){var e=L.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function FO(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cW={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}FO(t,"add",e.props.className)}function i(){r()&&FO(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function uW(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=IO(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,g=o!==void 0,b=L.useState(!1),y=b[0],A=b[1],v=L.useState({}),w=v[0],E=v[1],k=L.useState(),S=k[0],M=k[1],O=lW(function(){return{container:_O(),renders:1}}),R=Object.assign({ignoreAttributes:d},h,{content:O.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(K){R[K]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+K+"` prop in","controlled mode (`visible` prop)"].join(" "))}),R.trigger="manual",R.hideOnClick=!1),g&&(u=!0);var D=R,F=R.plugins||[];a&&(D=Object.assign({},R,{plugins:g&&o.data!=null?[].concat(F,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var ge=Z.instance;return ge.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,M(re.content)}}}}]):F,render:function(){return{popper:O.container}}}));var U=[l].concat(r?[r.type]:[]);return Nv(function(){var K=l;l&&l.hasOwnProperty("current")&&(K=l.current);var _=n(K||O.ref||_O(),Object.assign({},D,{plugins:[cW].concat(R.plugins||[])}));return O.instance=_,u&&_.disable(),i&&_.show(),g&&o.hook({instance:_,content:s,props:D,setSingletonContent:M}),A(!0),function(){_.destroy(),o==null||o.cleanup(_)}},U),Nv(function(){var K;if(O.renders===1){O.renders++;return}var _=O.instance;_.setProps(aW(_.props,D)),(K=_.popperInstance)==null||K.forceUpdate(),u?_.disable():_.enable(),p&&(i?_.show():_.hide()),g&&o.hook({instance:_,content:s,props:D,setSingletonContent:M})}),Nv(function(){var K;if(a){var _=O.instance;_.setProps({popperOptions:Object.assign({},_.props.popperOptions,{modifiers:[].concat((((K=_.props.popperOptions)==null?void 0:K.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,ge=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(ge==null?void 0:ge.isReferenceHidden)||w.escaped!==(ge==null?void 0:ge.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:ge==null?void 0:ge.isReferenceHidden,escaped:ge==null?void 0:ge.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat(U)),L.createElement(L.Fragment,null,r?L.cloneElement(r,{ref:function(_){O.ref=_,Tv(r.ref,_)}}):null,y&&Et.createPortal(a?a(iW(w),S,O.instance):s,O.container))}return e}var fW=function(n,e){return L.forwardRef(function(r,s){var i=r.children,o=IO(r,["children"]);return L.createElement(n,Object.assign({},e,o),i?L.cloneElement(i,{ref:function(l){Tv(s,l),Tv(i.ref,l)}}):null)})},dW=fW(uW(fa));const hW=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],jO=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=L.useState(!1),o=mp(),a=L.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};L.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return C.jsxs(wf,{className:"group",children:[C.jsx(Ik,{as:"span"}),(s||t)&&C.jsx(dW,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:C.jsx("article",{className:"dropdown",contentEditable:!1,children:C.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hW.map(u=>C.jsx("li",{children:C.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[C.jsx("span",{children:u.icon}),C.jsx("span",{children:u.name})]})},u.name))})}),children:C.jsx("label",{tabIndex:0,className:pe("trigger-button",{hidden:o}),contentEditable:!1,children:C.jsx(X3,{fontSize:"small"})})})]})},pW=vt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"td",className:"relative"})}}),gW=vt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"th",className:"relative"})}}),UO=n=>(n.stopPropagation(),n.preventDefault(),n),mW=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},HO=function(n){return!n||n===document.body?document.body:mW(n)?n:HO(n.parentNode)},Ov=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},yW=vt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=HO(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const y=r(),A=n.state.doc.resolve(y),v=new Ne(A);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Ov("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:y=>{y&&UO(y),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Ov("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:y=>{y&&UO(y),o.deleteRow()}}),f=()=>{g(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Ov("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const y=h.getBoundingClientRect(),A=JSON.stringify(y);p!==A&&(c.style.top=`${y.top+document.documentElement.scrollTop}px`,c.style.left=`${y.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${y.height+1}px`,p=A)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),s==null||s.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),s==null||s.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),bW=[sW.configure({resizable:!0}),pW,gW,yW],wW=Y2.extend({content:"(dBlock|columns)+"});function zO({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const vW=St.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ot(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new bt({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!zO({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!zO({node:s,types:e})}}})]}}),xW=({node:n,editor:e,getPos:t})=>{const[r,s]=L.useState(""),i=mp(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return C.jsx(Gk,{});case"iframe":return C.jsx(Kk,{});default:return C.jsx(a4,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,b=360,y=t(),A=y+n.nodeSize;p&&(e==null||e.chain().focus(y).deleteRange({from:y,to:A}).setIframe({src:p,width:g,height:b}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(w=>r.includes(w)),b=r.match(/\/status\/([0-9]*)/),y=b&&b.length>0;if(g&&y)p=b[1];else{alert("invalid url");return}const A=t(),v=A+n.nodeSize;p&&(e==null||e.chain().focus(A).deleteRange({from:A,to:v}).setTweetEmbed({tweetId:p}).run())},d=iv(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);L.useEffect(()=>{r&&d()},[r]),L.useEffect(()=>{e==null||e.chain().focus()},[]);const h=L.useRef(null);return L.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&C.jsxs("div",{className:"relative w-full",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),C.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},AW=vt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return da(xW)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),EW=[Pz,Mz.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-[#E8EBEC] p-5 font-serif italic text-black"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-black"},exitOnArrowDown:!0},code:{HTMLAttributes:{class:"rounded bg-transparent p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Iz.configure({types:["heading","paragraph"]}),xV,rV.extend({exitable:!0}).configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),sV.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),aV.configure({multicolor:!0}),vV,fV.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),Dz,kV,lV.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),uV.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),X2.configure({width:3,color:"#d1d5db"}),Z2,r9,vW,wW,...bW,PV.configure({uploadFn:g4}),EV,CV,OV,AW.extend({addInputRules(){return[VO(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),VO(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),AV],VO=(n,e,t)=>new of({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),kW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXM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ement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},TW=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=kW,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=CW,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},NW=n=>n.isEns?TW(n):SW(n),OW="6.13.1";function RW(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function An(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function Oe(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&RW(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ac(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ac).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ac(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ac(t)}: ${Ac(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ln(n,e){return n&&n.code===e}function Rv(n){return ln(n,"CALL_EXCEPTION")}function Nt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ac(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+Ac(a))}}i.push(`code=${e}`),i.push(`version=${OW}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return Oe(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Oe(s,{shortMessage:r}),s}function ee(n,e,t,r){if(!n)throw Nt(e,t,r)}function V(n,e,t,r){ee(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function $O(n,e,t){t==null&&(t=""),t&&(t=": "+t),ee(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),ee(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Qg(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),ee(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function WO(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}V(!1,"invalid BytesLike value",e||"value",n)}function lt(n,e){return WO(n,e,!1)}function Pn(n,e){return WO(n,e,!0)}function At(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mv(n){return At(n,!0)||n instanceof Uint8Array}const GO="0123456789abcdef";function we(n){const e=lt(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=GO[(s&240)>>4]+GO[s&15]}return t}function Ut(n){return"0x"+n.map(e=>we(e).substring(2)).join("")}function Ec(n){return At(n,!0)?(n.length-2)/2:lt(n).length}function Ft(n,e,t){const r=lt(n);return t!=null&&t>r.length&&ee(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),we(r.slice(e??0,t??r.length))}function KO(n,e,t){const r=lt(n);ee(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),we(s)}function Ia(n,e){return KO(n,e,!0)}function MW(n,e){return KO(n,e,!1)}const Yg=BigInt(0),ss=BigInt(1),kc=9007199254740991;function DW(n,e){const t=Xg(n,"value"),r=BigInt(Je(e,"width"));if(ee(t>>r===Yg,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-ss){const s=(ss<<r)-ss;return-((~t&s)+ss)}return t}function JO(n,e){let t=Ae(n,"value");const r=BigInt(Je(e,"width")),s=ss<<r-ss;if(t<Yg){t=-t,ee(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(ss<<r)-ss;return(~t&i)+ss}else ee(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function pd(n,e){const t=Xg(n,"value"),r=BigInt(Je(e,"bits"));return t&(ss<<r)-ss}function Ae(n,e){switch(typeof n){case"bigint":return n;case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}V(!1,"invalid BigNumberish value",e||"value",n)}function Xg(n,e){const t=Ae(n,e);return ee(t>=Yg,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const qO="0123456789abcdef";function Dv(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=qO[t>>4],e+=qO[t&15];return BigInt(e)}return Ae(n)}function Je(n,e){switch(typeof n){case"bigint":return V(n>=-kc&&n<=kc,"overflow",e||"value",n),Number(n);case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Je(BigInt(n),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}V(!1,"invalid numeric value",e||"value",n)}function PW(n){return Je(Dv(n))}function bo(n,e){let r=Xg(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Je(e,"width");for(ee(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function In(n){const e=Xg(n,"value");if(e===Yg)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function La(n){let e=we(Mv(n)?n:In(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const QO="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const YO=BigInt(58);function IW(n){const e=lt(n);let t=Dv(e),r="";for(;t;)r=QO[Number(t%YO)]+r,t/=YO;for(let s=0;s<e.length&&!e[s];s++)r=QO[0]+r;return r}function LW(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return lt(e)}function _W(n){const e=lt(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class XO{constructor(e,t,r){$(this,"filter");$(this,"emitter");q(this,$c);I(this,$c,t),Oe(this,{emitter:e,filter:r})}async removeListener(){T(this,$c)!=null&&await this.emitter.off(this.filter,T(this,$c))}}$c=new WeakMap;function BW(n,e,t,r,s){V(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ZO(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function FW(n,e,t,r,s){return n==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ZO(n,e,t))}const jW=Object.freeze({error:BW,ignore:ZO,replace:FW});function UW(n,e){e==null&&(e=jW.error);const t=lt(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function bi(n,e){V(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);V(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function HW(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Cc(n,e){return HW(UW(n,e))}function eR(n){async function e(t,r){ee(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();ee(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),ee(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=Nt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=Nt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const zW=12,VW=250;let tR=eR();const $W=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),WW=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pv=!1;async function nR(n,e){try{const t=n.match($W);if(!t)throw new Error("invalid data");return new wo(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?LW(t[3]):KW(t[3]))}catch{return new wo(599,"BAD REQUEST (invalid data: URI)",{},null,new Ln(n))}}function rR(n){async function e(t,r){try{const s=t.match(WW);if(!s)throw new Error("invalid link");return new Ln(`${n}${s[2]}`)}catch{return new wo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ln(t))}}return e}const Zg={data:nR,ipfs:rR("https://gateway.ipfs.io/ipfs/")},sR=new WeakMap;class GW{constructor(e){q(this,qa);q(this,To);I(this,qa,[]),I(this,To,!1),sR.set(e,()=>{if(!T(this,To)){I(this,To,!0);for(const t of T(this,qa))setTimeout(()=>{t()},0);I(this,qa,[])}})}addListener(e){ee(!T(this,To),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,qa).push(e)}get cancelled(){return T(this,To)}checkSignal(){ee(!this.cancelled,"cancelled","CANCELLED",{})}}qa=new WeakMap,To=new WeakMap;function em(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const $m=class $m{constructor(e){q(this,Za);q(this,Wc);q(this,Gc);q(this,us);q(this,Ti);q(this,Kc);q(this,Jc);q(this,fn);q(this,wr);q(this,Ni);q(this,Qa);q(this,Ya);q(this,Xa);q(this,$s);q(this,fs);q(this,No);I(this,Jc,String(e)),I(this,Wc,!1),I(this,Gc,!0),I(this,us,{}),I(this,Ti,""),I(this,Kc,3e5),I(this,fs,{slotInterval:VW,maxAttempts:zW}),I(this,No,null)}get url(){return T(this,Jc)}set url(e){I(this,Jc,String(e))}get body(){return T(this,fn)==null?null:new Uint8Array(T(this,fn))}set body(e){if(e==null)I(this,fn,void 0),I(this,wr,void 0);else if(typeof e=="string")I(this,fn,bi(e)),I(this,wr,"text/plain");else if(e instanceof Uint8Array)I(this,fn,e),I(this,wr,"application/octet-stream");else if(typeof e=="object")I(this,fn,bi(JSON.stringify(e))),I(this,wr,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,fn)!=null}get method(){return T(this,Ti)?T(this,Ti):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),I(this,Ti,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,us));return T(this,Ni)&&(e.authorization=`Basic ${_W(bi(T(this,Ni)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,wr)&&(e["content-type"]=T(this,wr)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,us)[String(e).toLowerCase()]=String(t)}clearHeaders(){I(this,us,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Ni)||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),I(this,Ni,`${e}:${t}`)}get allowGzip(){return T(this,Gc)}set allowGzip(e){I(this,Gc,!!e)}get allowInsecureAuthentication(){return!!T(this,Wc)}set allowInsecureAuthentication(e){I(this,Wc,!!e)}get timeout(){return T(this,Kc)}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),I(this,Kc,e)}get preflightFunc(){return T(this,Qa)||null}set preflightFunc(e){I(this,Qa,e)}get processFunc(){return T(this,Ya)||null}set processFunc(e){I(this,Ya,e)}get retryFunc(){return T(this,Xa)||null}set retryFunc(e){I(this,Xa,e)}get getUrlFunc(){return T(this,No)||tR}set getUrlFunc(e){I(this,No,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,fn)?we(T(this,fn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,fs).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,fs).maxAttempts=e.maxAttempts)}send(){return ee(T(this,$s)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),I(this,$s,new GW(this)),fe(this,Za,eh).call(this,0,iR()+this.timeout,0,this,new wo(0,"",{},null,this))}cancel(){ee(T(this,$s)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=sR.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();ee(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new $m(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,I(s,us,Object.assign({},T(this,us))),T(this,fn)&&I(s,fn,new Uint8Array(T(this,fn))),I(s,wr,T(this,wr)),s}clone(){const e=new $m(this.url);return I(e,Ti,T(this,Ti)),T(this,fn)&&I(e,fn,T(this,fn)),I(e,wr,T(this,wr)),I(e,us,Object.assign({},T(this,us))),I(e,Ni,T(this,Ni)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),I(e,Qa,T(this,Qa)),I(e,Ya,T(this,Ya)),I(e,Xa,T(this,Xa)),I(e,fs,Object.assign({},T(this,fs))),I(e,No,T(this,No)),e}static lockConfig(){Pv=!0}static getGateway(e){return Zg[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pv)throw new Error("gateways locked");Zg[e]=t}static registerGetUrl(e){if(Pv)throw new Error("gateways locked");tR=e}static createGetUrlFunc(e){return eR()}static createDataGateway(){return nR}static createIpfsGatewayFunc(e){return rR(e)}};Wc=new WeakMap,Gc=new WeakMap,us=new WeakMap,Ti=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,fn=new WeakMap,wr=new WeakMap,Ni=new WeakMap,Qa=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,$s=new WeakMap,fs=new WeakMap,No=new WeakMap,Za=new WeakSet,eh=async function(e,t,r,s,i){var u,f,d;if(e>=T(this,fs).maxAttempts)return i.makeServerError("exceeded maximum retry limit");ee(iR()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await JW(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Zg){const h=await Zg[a](o.url,em(T(s,$s)));if(h instanceof wo){let p=h;if(this.processFunc){em(T(s,$s));try{p=await this.processFunc(o,p)}catch(g){(g.throttle==null||typeof g.stall!="number")&&p.makeServerError("error in post-processing function",g).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,em(T(s,$s)));let c=new wo(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return fe(u=o.redirect(h),Za,eh).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),fe(f=o.clone(),Za,eh).call(f,e+1,t,p,s,c)}if(this.processFunc){em(T(s,$s));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),fe(d=o.clone(),Za,eh).call(d,e+1,t,p,s,c)}}return c};let Ln=$m;const G1=class G1{constructor(e,t,r,s,i){q(this,Fd);q(this,jd);q(this,Ud);q(this,vr);q(this,qc);q(this,el);I(this,Fd,e),I(this,jd,t),I(this,Ud,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),I(this,vr,s==null?null:new Uint8Array(s)),I(this,qc,i||null),I(this,el,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,vr)?we(T(this,vr)):"null"}>`}get statusCode(){return T(this,Fd)}get statusMessage(){return T(this,jd)}get headers(){return Object.assign({},T(this,Ud))}get body(){return T(this,vr)==null?null:new Uint8Array(T(this,vr))}get bodyText(){try{return T(this,vr)==null?"":Cc(T(this,vr))}catch{ee(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ee(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new G1(599,r,this.headers,this.body,T(this,qc)||void 0);return I(s,el,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw Oe(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,vr)!=null}get request(){return T(this,qc)}ok(){return T(this,el).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,el);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{T(this,vr)&&(s=Cc(T(this,vr)))}catch{}ee(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Fd=new WeakMap,jd=new WeakMap,Ud=new WeakMap,vr=new WeakMap,qc=new WeakMap,el=new WeakMap;let wo=G1;function iR(){return new Date().getTime()}function KW(n){return bi(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function JW(n){return new Promise(e=>setTimeout(e,n))}function qW(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function oR(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function aR(n,e,t,r){const s=[];for(;t<e+1+r;){const i=lR(n,t);s.push(i.result),t+=i.consumed,ee(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function lR(n,e){ee(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{ee(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=oR(n,e+1,r);return t(e+1+r+s),aR(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),aR(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=oR(n,e+1,r);t(e+1+r+s);const i=we(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=we(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:qW(n[e])}}function tm(n){const e=lt(n,"data"),t=lR(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function cR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function uR(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(uR(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=cR(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(lt(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=cR(e.length);return t.unshift(183+t.length),t.concat(e)}const fR="0123456789abcdef";function _a(n){let e="0x";for(const t of uR(n))e+=fR[t>>4],e+=fR[t&15];return e}const _n=32,Iv=new Uint8Array(_n),QW=["then"],nm={},dR=new WeakMap;function Ba(n){return dR.get(n)}function hR(n,e){dR.set(n,e)}function gd(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Lv(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof Sc?Lv(Ba(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof Sc&&(o=Lv(Ba(o),o,t)),r[s]=o),r},{})}const Yc=class Yc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==nm&&(s=t,i=[],o=!1);super(s.length);q(this,Qc);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(hR(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),I(this,Qc,[]),T(this,Qc)==null&&T(this,Qc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Je(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&gd(`index ${h}`,p),p}if(QW.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return hR(l,Ba(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&gd(`index ${i}`,s),t&&s instanceof Yc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=Ba(this);return r.reduce((s,i,o)=>(ee(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Lv(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=Ba(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Yc(nm,i,o)}filter(t,r){const s=Ba(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&gd(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Yc(nm,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&gd(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=Ba(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&gd(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Yc(nm,t,r)}};Qc=new WeakMap;let Sc=Yc;function pR(n){let e=In(n);return ee(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=Pn(Ut([Iv.slice(e.length%_n),e]))),e}class wi{constructor(e,t,r,s){$(this,"name");$(this,"type");$(this,"localName");$(this,"dynamic");Oe(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class _v{constructor(){q(this,Xc);q(this,Oi);q(this,tl);I(this,Oi,[]),I(this,tl,0)}get data(){return Ut(T(this,Oi))}get length(){return T(this,tl)}appendWriter(e){return fe(this,Xc,Ym).call(this,Pn(e.data))}writeBytes(e){let t=Pn(e);const r=t.length%_n;return r&&(t=Pn(Ut([t,Iv.slice(r)]))),fe(this,Xc,Ym).call(this,t)}writeValue(e){return fe(this,Xc,Ym).call(this,pR(e))}writeUpdatableValue(){const e=T(this,Oi).length;return T(this,Oi).push(Iv),I(this,tl,T(this,tl)+_n),t=>{T(this,Oi)[e]=pR(t)}}}Oi=new WeakMap,tl=new WeakMap,Xc=new WeakSet,Ym=function(e){return T(this,Oi).push(e),I(this,tl,T(this,tl)+e.length),e.length};const K1=class K1{constructor(e,t,r){q(this,sl);$(this,"allowLoose");q(this,er);q(this,xr);q(this,nl);q(this,rl);q(this,Oo);Oe(this,{allowLoose:!!t}),I(this,er,Pn(e)),I(this,nl,0),I(this,rl,null),I(this,Oo,r??1024),I(this,xr,0)}get data(){return we(T(this,er))}get dataLength(){return T(this,er).length}get consumed(){return T(this,xr)}get bytes(){return new Uint8Array(T(this,er))}subReader(e){const t=new K1(T(this,er).slice(T(this,xr)+e),this.allowLoose,T(this,Oo));return I(t,rl,this),t}readBytes(e,t){let r=fe(this,sl,eP).call(this,0,e,!!t);return fe(this,sl,nx).call(this,e),I(this,xr,T(this,xr)+r.length),r.slice(0,e)}readValue(){return Dv(this.readBytes(_n))}readIndex(){return PW(this.readBytes(_n))}};er=new WeakMap,xr=new WeakMap,nl=new WeakMap,rl=new WeakMap,Oo=new WeakMap,sl=new WeakSet,nx=function(e){var t;if(T(this,rl))return fe(t=T(this,rl),sl,nx).call(t,e);I(this,nl,T(this,nl)+e),ee(T(this,Oo)<1||T(this,nl)<=T(this,Oo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Oo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Pn(T(this,er)),offset:T(this,xr),length:e,info:{bytesRead:T(this,nl),dataLength:this.dataLength}})},eP=function(e,t,r){let s=Math.ceil(t/_n)*_n;return T(this,xr)+s>T(this,er).length&&(this.allowLoose&&r&&T(this,xr)+t<=T(this,er).length?s=t:ee(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Pn(T(this,er)),length:T(this,er).length,offset:T(this,xr)+s})),T(this,er).slice(T(this,xr),T(this,xr)+s)};let Bv=K1;function rm(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Fv(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function YW(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rm(n.outputLen),rm(n.blockLen)}function Tc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function gR(n,e){Fv(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const jv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mR=n=>n instanceof Uint8Array,XW=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uv=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hs=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function ZW(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function sm(n){if(typeof n=="string"&&(n=ZW(n)),!mR(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function e7(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!mR(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hv{clone(){return this._cloneInto()}}function zv(n){const e=r=>n().update(sm(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function t7(n=32){if(jv&&typeof jv.getRandomValues=="function")return jv.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class yR extends Hv{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,YW(e);const r=sm(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tc(this),this.iHash.update(e),this}digestInto(e){Tc(this),Fv(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bR=(n,e,t)=>new yR(n,e).update(t).digest();bR.create=(n,e)=>new yR(n,e);function n7(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class wR extends Hv{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uv(this.buffer)}update(e){Tc(this);const{view:t,buffer:r,blockLen:s}=this;e=sm(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uv(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tc(this),gR(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;n7(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uv(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const r7=(n,e,t)=>n&e^~n&t,s7=(n,e,t)=>n&e^n&t^e&t,i7=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xo=new Uint32Array(64);class o7 extends wR{constructor(){super(64,32,8,!1),this.A=vo[0]|0,this.B=vo[1]|0,this.C=vo[2]|0,this.D=vo[3]|0,this.E=vo[4]|0,this.F=vo[5]|0,this.G=vo[6]|0,this.H=vo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)xo[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=xo[f-15],h=xo[f-2],p=Hs(d,7)^Hs(d,18)^d>>>3,g=Hs(h,17)^Hs(h,19)^h>>>10;xo[f]=g+xo[f-7]+p+xo[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Hs(a,6)^Hs(a,11)^Hs(a,25),h=u+d+r7(a,l,c)+i7[f]+xo[f]|0,g=(Hs(r,2)^Hs(r,13)^Hs(r,22))+s7(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+g|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){xo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const vR=zv(()=>new o7),im=BigInt(2**32-1),Vv=BigInt(32);function xR(n,e=!1){return e?{h:Number(n&im),l:Number(n>>Vv&im)}:{h:Number(n>>Vv&im)|0,l:Number(n&im)|0}}function AR(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xR(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const a7=(n,e)=>BigInt(n>>>0)<<Vv|BigInt(e>>>0),l7=(n,e,t)=>n>>>t,c7=(n,e,t)=>n<<32-t|e>>>t,u7=(n,e,t)=>n>>>t|e<<32-t,f7=(n,e,t)=>n<<32-t|e>>>t,d7=(n,e,t)=>n<<64-t|e>>>t-32,h7=(n,e,t)=>n>>>t-32|e<<64-t,p7=(n,e)=>e,g7=(n,e)=>n,ER=(n,e,t)=>n<<t|e>>>32-t,kR=(n,e,t)=>e<<t|n>>>32-t,CR=(n,e,t)=>e<<t-32|n>>>64-t,SR=(n,e,t)=>n<<t-32|e>>>64-t;function m7(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Xe={fromBig:xR,split:AR,toBig:a7,shrSH:l7,shrSL:c7,rotrSH:u7,rotrSL:f7,rotrBH:d7,rotrBL:h7,rotr32H:p7,rotr32L:g7,rotlSH:ER,rotlSL:kR,rotlBH:CR,rotlBL:SR,add:m7,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[y7,b7]=Xe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Ao=new Uint32Array(80),Eo=new Uint32Array(80);class w7 extends wR{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:g,Hl:b}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,b]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,b){this.Ah=e|0,this.Al=t|0,this.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{h:f,l:d}=Xe.add(c|0,u|0,O|0,R|0),c=a|0,u=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const _=Xe.add3L(R,F,K);r=Xe.add3H(_,O,D,U),s=_|0}({h:r,l:s}=Xe.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Xe.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Xe.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=Xe.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:f,l:d}=Xe.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Xe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:g,l:b}=Xe.add(this.Gh|0,this.Gl|0,g|0,b|0),{h:y,l:A}=Xe.add(this.Hh|0,this.Hl|0,y|0,A|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,g,b,y,A)}roundClean(){Ao.fill(0),Eo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const v7=zv(()=>new w7);function x7(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const TR=x7();TR.crypto||TR.msCrypto;function A7(n){switch(n){case"sha256":return vR.create();case"sha512":return v7.create()}V(!1,"invalid hashing algorithm name","algorithm",n)}const[NR,OR,RR]=[[],[],[]],E7=BigInt(0),md=BigInt(1),k7=BigInt(2),C7=BigInt(7),S7=BigInt(256),T7=BigInt(113);for(let n=0,e=md,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],NR.push(2*(5*r+t)),OR.push((n+1)*(n+2)/2%64);let s=E7;for(let i=0;i<7;i++)e=(e<<md^(e>>C7)*T7)%S7,e&k7&&(s^=md<<(md<<BigInt(i))-md);RR.push(s)}const[N7,O7]=AR(RR,!0),MR=(n,e,t)=>t>32?CR(n,e,t):ER(n,e,t),DR=(n,e,t)=>t>32?SR(n,e,t):kR(n,e,t);function R7(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=MR(c,u,1)^t[a],d=DR(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=OR[o],l=MR(s,i,a),c=DR(s,i,a),u=NR[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=N7[r],n[1]^=O7[r]}t.fill(0)}class $v extends Hv{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rm(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=XW(this.state)}keccak(){R7(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Tc(this);const{blockLen:t,state:r}=this;e=sm(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Tc(this,!1),Fv(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rm(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gR(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $v(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const M7=((n,e,t)=>zv(()=>new $v(e,n,t)))(1,136,256/8);let PR=!1;const IR=function(n){return M7(n)};let LR=IR;function Jt(n){const e=lt(n,"data");return we(LR(e))}Jt._=IR,Jt.lock=function(){PR=!0},Jt.register=function(n){if(PR)throw new TypeError("keccak256 is locked");LR=n},Object.freeze(Jt);const _R=function(n){return A7("sha256").update(n).digest()};let BR=_R,FR=!1;function Nc(n){const e=lt(n,"data");return we(BR(e))}Nc._=_R,Nc.lock=function(){FR=!0},Nc.register=function(n){if(FR)throw new Error("sha256 is locked");BR=n},Object.freeze(Nc),Object.freeze(Nc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jR=BigInt(0),om=BigInt(1),D7=BigInt(2),am=n=>n instanceof Uint8Array,P7=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Oc(n){if(!am(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=P7[n[t]];return e}function UR(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Wv(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Rc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Fa(n){return Wv(Oc(n))}function Gv(n){if(!am(n))throw new Error("Uint8Array expected");return Wv(Oc(Uint8Array.from(n).reverse()))}function Mc(n,e){return Rc(n.toString(16).padStart(e*2,"0"))}function Kv(n,e){return Mc(n,e).reverse()}function I7(n){return Rc(UR(n))}function is(n,e,t){let r;if(typeof e=="string")try{r=Rc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(am(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function yd(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!am(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function L7(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function _7(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function B7(n){let e;for(e=0;n>jR;n>>=om,e+=1);return e}function F7(n,e){return n>>BigInt(e)&om}const j7=(n,e,t)=>n|(t?om:jR)<<BigInt(e),Jv=n=>(D7<<BigInt(n-1))-om,qv=n=>new Uint8Array(n),HR=n=>Uint8Array.from(n);function zR(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=qv(n),s=qv(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=qv())=>{s=a(HR([0]),f),r=a(),f.length!==0&&(s=a(HR([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return yd(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const U7={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function bd(n,e,t={}){const r=(s,i,o)=>{const a=U7[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const H7=Object.freeze(Object.defineProperty({__proto__:null,bitGet:F7,bitLen:B7,bitMask:Jv,bitSet:j7,bytesToHex:Oc,bytesToNumberBE:Fa,bytesToNumberLE:Gv,concatBytes:yd,createHmacDrbg:zR,ensureBytes:is,equalBytes:L7,hexToBytes:Rc,hexToNumber:Wv,numberToBytesBE:Mc,numberToBytesLE:Kv,numberToHexUnpadded:UR,numberToVarBytesBE:I7,utf8ToBytes:_7,validateObject:bd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cn=BigInt(0),Ht=BigInt(1),ja=BigInt(2),z7=BigInt(3),Qv=BigInt(4),VR=BigInt(5),$R=BigInt(8);BigInt(9),BigInt(16);function Yn(n,e){const t=n%e;return t>=cn?t:e+t}function V7(n,e,t){if(t<=cn||e<cn)throw new Error("Expected power/modulo > 0");if(t===Ht)return cn;let r=Ht;for(;e>cn;)e&Ht&&(r=r*n%t),n=n*n%t,e>>=Ht;return r}function _r(n,e,t){let r=n;for(;e-- >cn;)r*=r,r%=t;return r}function Yv(n,e){if(n===cn||e<=cn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Yn(n,e),r=e,s=cn,i=Ht;for(;t!==cn;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Ht)throw new Error("invert: does not exist");return Yn(s,e)}function $7(n){const e=(n-Ht)/ja;let t,r,s;for(t=n-Ht,r=0;t%ja===cn;t/=ja,r++);for(s=ja;s<n&&V7(s,e,n)!==n-Ht;s++);if(r===1){const o=(n+Ht)/Qv;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Ht)/ja;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let g=a.sqr(d);h<c&&!a.eql(g,a.ONE);h++)g=a.sqr(g);const p=a.pow(u,Ht<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function W7(n){if(n%Qv===z7){const e=(n+Ht)/Qv;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%$R===VR){const e=(n-VR)/$R;return function(r,s){const i=r.mul(s,ja),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,ja),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return $7(n)}const G7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function K7(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=G7.reduce((r,s)=>(r[s]="function",r),e);return bd(n,t)}function J7(n,e,t){if(t<cn)throw new Error("Expected power > 0");if(t===cn)return n.ONE;if(t===Ht)return e;let r=n.ONE,s=e;for(;t>cn;)t&Ht&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Ht;return r}function q7(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function WR(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Q7(n,e,t=!1,r={}){if(n<=cn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=WR(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=W7(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Jv(s),ZERO:cn,ONE:Ht,create:l=>Yn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return cn<=l&&l<n},is0:l=>l===cn,isOdd:l=>(l&Ht)===Ht,neg:l=>Yn(-l,n),eql:(l,c)=>l===c,sqr:l=>Yn(l*l,n),add:(l,c)=>Yn(l+c,n),sub:(l,c)=>Yn(l-c,n),mul:(l,c)=>Yn(l*c,n),pow:(l,c)=>J7(a,l,c),div:(l,c)=>Yn(l*Yv(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Yv(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>q7(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Kv(l,i):Mc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Gv(l):Fa(l)}});return Object.freeze(a)}function GR(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function KR(n){const e=GR(n);return e+Math.ceil(e/2)}function Y7(n,e,t=!1){const r=n.length,s=GR(e),i=KR(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Fa(n):Gv(n),a=Yn(o,e-Ht)+Ht;return t?Kv(a,s):Mc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const X7=BigInt(0),Xv=BigInt(1);function Z7(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>X7;)i&Xv&&(o=o.add(a)),a=a.double(),i>>=Xv;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const g=p*l;let b=Number(o&f);o>>=h,b>l&&(b-=d,o+=Xv);const y=g,A=g+Math.abs(b)-1,v=p%2!==0,w=b<0;b===0?u=u.add(t(v,i[y])):c=c.add(t(w,i[A]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function JR(n){return K7(n.Fp),bd(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...WR(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eG(n){const e=JR(n);bd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:tG,hexToBytes:nG}=H7,Ua={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ua;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:tG(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ua,t=typeof n=="string"?nG(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ua._parseInt(t.subarray(2)),{d:o,l:a}=Ua._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},vi=BigInt(0),Br=BigInt(1);BigInt(2);const qR=BigInt(3);BigInt(4);function rG(n){const e=eG(n),{Fp:t}=e,r=e.toBytes||((p,g,b)=>{const y=g.toAffine();return yd(Uint8Array.from([4]),t.toBytes(y.x),t.toBytes(y.y))}),s=e.fromBytes||(p=>{const g=p.subarray(1),b=t.fromBytes(g.subarray(0,t.BYTES)),y=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:b,y}});function i(p){const{a:g,b}=e,y=t.sqr(p),A=t.mul(y,p);return t.add(t.add(A,t.mul(p,g)),b)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&vi<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:g,nByteLength:b,wrapPrivateKey:y,n:A}=e;if(g&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=Oc(p)),typeof p!="string"||!g.includes(p.length))throw new Error("Invalid key");p=p.padStart(b*2,"0")}let v;try{v=typeof p=="bigint"?p:Fa(is("private key",p,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof p}`)}return y&&(v=Yn(v,A)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(g,b,y){if(this.px=g,this.py=b,this.pz=y,g==null||!t.isValid(g))throw new Error("x required");if(b==null||!t.isValid(b))throw new Error("y required");if(y==null||!t.isValid(y))throw new Error("z required")}static fromAffine(g){const{x:b,y}=g||{};if(!g||!t.isValid(b)||!t.isValid(y))throw new Error("invalid affine point");if(g instanceof f)throw new Error("projective point not allowed");const A=v=>t.eql(v,t.ZERO);return A(b)&&A(y)?f.ZERO:new f(b,y,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const b=t.invertBatch(g.map(y=>y.pz));return g.map((y,A)=>y.toAffine(b[A])).map(f.fromAffine)}static fromHex(g){const b=f.fromAffine(s(is("pointHex",g)));return b.assertValidity(),b}static fromPrivateKey(g){return f.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:b}=this.toAffine();if(!t.isValid(g)||!t.isValid(b))throw new Error("bad point: x or y not FE");const y=t.sqr(b),A=i(g);if(!t.eql(y,A))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){u(g);const{px:b,py:y,pz:A}=this,{px:v,py:w,pz:E}=g,k=t.eql(t.mul(b,E),t.mul(v,A)),S=t.eql(t.mul(y,E),t.mul(w,A));return k&&S}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:g,b}=e,y=t.mul(b,qR),{px:A,py:v,pz:w}=this;let E=t.ZERO,k=t.ZERO,S=t.ZERO,M=t.mul(A,A),O=t.mul(v,v),R=t.mul(w,w),D=t.mul(A,v);return D=t.add(D,D),S=t.mul(A,w),S=t.add(S,S),E=t.mul(g,S),k=t.mul(y,R),k=t.add(E,k),E=t.sub(O,k),k=t.add(O,k),k=t.mul(E,k),E=t.mul(D,E),S=t.mul(y,S),R=t.mul(g,R),D=t.sub(M,R),D=t.mul(g,D),D=t.add(D,S),S=t.add(M,M),M=t.add(S,M),M=t.add(M,R),M=t.mul(M,D),k=t.add(k,M),R=t.mul(v,w),R=t.add(R,R),M=t.mul(R,D),E=t.sub(E,M),S=t.mul(R,O),S=t.add(S,S),S=t.add(S,S),new f(E,k,S)}add(g){u(g);const{px:b,py:y,pz:A}=this,{px:v,py:w,pz:E}=g;let k=t.ZERO,S=t.ZERO,M=t.ZERO;const O=e.a,R=t.mul(e.b,qR);let D=t.mul(b,v),F=t.mul(y,w),U=t.mul(A,E),K=t.add(b,y),_=t.add(v,w);K=t.mul(K,_),_=t.add(D,F),K=t.sub(K,_),_=t.add(b,A);let G=t.add(v,E);return _=t.mul(_,G),G=t.add(D,U),_=t.sub(_,G),G=t.add(y,A),k=t.add(w,E),G=t.mul(G,k),k=t.add(F,U),G=t.sub(G,k),M=t.mul(O,_),k=t.mul(R,U),M=t.add(k,M),k=t.sub(F,M),M=t.add(F,M),S=t.mul(k,M),F=t.add(D,D),F=t.add(F,D),U=t.mul(O,U),_=t.mul(R,_),F=t.add(F,U),U=t.sub(D,U),U=t.mul(O,U),_=t.add(_,U),D=t.mul(F,_),S=t.add(S,D),D=t.mul(G,_),k=t.mul(K,k),k=t.sub(k,D),D=t.mul(K,F),M=t.mul(G,M),M=t.add(M,D),new f(k,S,M)}subtract(g){return this.add(g.negate())}is0(){return this.equals(f.ZERO)}wNAF(g){return h.wNAFCached(this,c,g,b=>{const y=t.invertBatch(b.map(A=>A.pz));return b.map((A,v)=>A.toAffine(y[v])).map(f.fromAffine)})}multiplyUnsafe(g){const b=f.ZERO;if(g===vi)return b;if(a(g),g===Br)return this;const{endo:y}=e;if(!y)return h.unsafeLadder(this,g);let{k1neg:A,k1:v,k2neg:w,k2:E}=y.splitScalar(g),k=b,S=b,M=this;for(;v>vi||E>vi;)v&Br&&(k=k.add(M)),E&Br&&(S=S.add(M)),M=M.double(),v>>=Br,E>>=Br;return A&&(k=k.negate()),w&&(S=S.negate()),S=new f(t.mul(S.px,y.beta),S.py,S.pz),k.add(S)}multiply(g){a(g);let b=g,y,A;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:k,k2:S}=v.splitScalar(b);let{p:M,f:O}=this.wNAF(E),{p:R,f:D}=this.wNAF(S);M=h.constTimeNegate(w,M),R=h.constTimeNegate(k,R),R=new f(t.mul(R.px,v.beta),R.py,R.pz),y=M.add(R),A=O.add(D)}else{const{p:w,f:E}=this.wNAF(b);y=w,A=E}return f.normalizeZ([y,A])[0]}multiplyAndAddUnsafe(g,b,y){const A=f.BASE,v=(E,k)=>k===vi||k===Br||!E.equals(A)?E.multiplyUnsafe(k):E.multiply(k),w=v(this,b).add(v(g,y));return w.is0()?void 0:w}toAffine(g){const{px:b,py:y,pz:A}=this,v=this.is0();g==null&&(g=v?t.ONE:t.inv(A));const w=t.mul(b,g),E=t.mul(y,g),k=t.mul(A,g);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:g,isTorsionFree:b}=e;if(g===Br)return!0;if(b)return b(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:b}=e;return g===Br?this:b?b(f,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),r(f,this,g)}toHex(g=!0){return Oc(this.toRawBytes(g))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=Z7(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function sG(n){const e=JR(n);return bd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iG(n){const e=sG(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(_){return vi<_&&_<t.ORDER}function a(_){return Yn(_,r)}function l(_){return Yv(_,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=rG({...e,toBytes(_,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),ge=yd;return Y?ge(Uint8Array.from([G.hasEvenY()?2:3]),Z):ge(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(_){const G=_.length,Y=_[0],re=_.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Fa(re);if(!o(Z))throw new Error("Point is not on curve");const ge=f(Z);let ke=t.sqrt(ge);const Pe=(ke&Br)===Br;return(Y&1)===1!==Pe&&(ke=t.neg(ke)),{x:Z,y:ke}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),ge=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:ge}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>Oc(Mc(_,e.nByteLength));function p(_){const G=r>>Br;return _>G}function g(_){return p(_)?a(-_):_}const b=(_,G,Y)=>Fa(_.slice(G,Y));class y{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=is("compactSignature",G,Y*2),new y(b(G,0,Y),b(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ua.toSig(is("DER",G));return new y(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new y(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,ge=S(is("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const ke=Z===2||Z===3?Y+e.n:Y;if(ke>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Pe=Z&1?"03":"02",Ce=c.fromHex(Pe+h(ke)),Ee=l(ke),Ue=a(-ge*Ee),Fe=a(re*Ee),He=c.BASE.multiplyAndAddUnsafe(Ce,Ue,Fe);if(!He)throw new Error("point at infinify");return He.assertValidity(),He}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rc(this.toDERHex())}toDERHex(){return Ua.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const A={isValidPrivateKey(_){try{return u(_),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const _=KR(e.n);return Y7(e.randomBytes(_),e.n)},precompute(_=8,G=c.BASE){return G._setWindowSize(_),G.multiply(BigInt(3)),G}};function v(_,G=!0){return c.fromPrivateKey(_).toRawBytes(G)}function w(_){const G=_ instanceof Uint8Array,Y=typeof _=="string",re=(G||Y)&&_.length;return G?re===s||re===i:Y?re===2*s||re===2*i:_ instanceof c}function E(_,G,Y=!0){if(w(_))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(_)).toRawBytes(Y)}const k=e.bits2int||function(_){const G=Fa(_),Y=_.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},S=e.bits2int_modN||function(_){return a(k(_))},M=Jv(e.nBitLength);function O(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(vi<=_&&_<M))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Mc(_,e.nByteLength)}function R(_,G,Y=D){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:ge,prehash:ke,extraEntropy:Pe}=Y;ge==null&&(ge=!0),_=is("msgHash",_),ke&&(_=is("prehashed msgHash",re(_)));const Ce=S(_),Ee=u(G),Ue=[O(Ee),O(Ce)];if(Pe!=null){const Ze=Pe===!0?Z(t.BYTES):Pe;Ue.push(is("extraEntropy",Ze))}const Fe=yd(...Ue),He=Ce;function Le(Ze){const le=k(Ze);if(!d(le))return;const ze=l(le),ae=c.BASE.multiply(le).toAffine(),be=a(ae.x);if(be===vi)return;const _e=a(ze*a(He+be*Ee));if(_e===vi)return;let z=(ae.x===be?0:2)|Number(ae.y&Br),J=_e;return ge&&p(_e)&&(J=g(_e),z^=1),new y(be,J,z)}return{seed:Fe,k2sig:Le}}const D={lowS:e.lowS,prehash:!1},F={lowS:e.lowS,prehash:!1};function U(_,G,Y=D){const{seed:re,k2sig:Z}=R(_,G,Y),ge=e;return zR(ge.hash.outputLen,ge.nByteLength,ge.hmac)(re,Z)}c.BASE._setWindowSize(8);function K(_,G,Y,re=F){var ae;const Z=_;if(G=is("msgHash",G),Y=is("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:ge,prehash:ke}=re;let Pe,Ce;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{Pe=y.fromDER(Z)}catch(be){if(!(be instanceof Ua.Err))throw be;Pe=y.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:be,s:_e}=Z;Pe=new y(be,_e)}else throw new Error("PARSE");Ce=c.fromHex(Y)}catch(be){if(be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ge&&Pe.hasHighS())return!1;ke&&(G=e.hash(G));const{r:Ee,s:Ue}=Pe,Fe=S(G),He=l(Ue),Le=a(Fe*He),Ze=a(Ee*He),le=(ae=c.BASE.multiplyAndAddUnsafe(Ce,Le,Ze))==null?void 0:ae.toAffine();return le?a(le.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:U,verify:K,ProjectivePoint:c,Signature:y,utils:A}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oG(n){return{hash:n,hmac:(e,...t)=>bR(n,e,e7(...t)),randomBytes:t7}}function aG(n,e){const t=r=>iG({...n,...oG(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const QR=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),YR=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lG=BigInt(1),Zv=BigInt(2),XR=(n,e)=>(n+e/Zv)/e;function cG(n){const e=QR,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=_r(u,t,e)*u%e,d=_r(f,t,e)*u%e,h=_r(d,Zv,e)*c%e,p=_r(h,s,e)*h%e,g=_r(p,i,e)*p%e,b=_r(g,a,e)*g%e,y=_r(b,l,e)*b%e,A=_r(y,a,e)*g%e,v=_r(A,t,e)*u%e,w=_r(v,o,e)*p%e,E=_r(w,r,e)*c%e,k=_r(E,Zv,e);if(!e1.eql(e1.sqr(k),n))throw new Error("Cannot find square root");return k}const e1=Q7(QR,void 0,void 0,{sqrt:cG}),ko=aG({a:BigInt(0),b:BigInt(7),Fp:e1,n:YR,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=YR,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-lG*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=XR(i*n,e),l=XR(-r*n,e);let c=Yn(n-a*t-l*s,e),u=Yn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},vR);BigInt(0),ko.ProjectivePoint;const wd="0x0000000000000000000000000000000000000000",ZR="0x0000000000000000000000000000000000000000000000000000000000000000",eM=BigInt(0),tM=BigInt(1),nM=BigInt(2),rM=BigInt(27),sM=BigInt(28),lm=BigInt(35),Dc={};function iM(n){return Ia(In(n),32)}const ds=class ds{constructor(e,t,r,s){q(this,Zc);q(this,eu);q(this,tu);q(this,il);Qg(e,Dc,"Signature"),I(this,Zc,t),I(this,eu,r),I(this,tu,s),I(this,il,null)}get r(){return T(this,Zc)}set r(e){V(Ec(e)===32,"invalid r","value",e),I(this,Zc,we(e))}get s(){return T(this,eu)}set s(e){V(Ec(e)===32,"invalid s","value",e);const t=we(e);V(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),I(this,eu,t)}get v(){return T(this,tu)}set v(e){const t=Je(e,"value");V(t===27||t===28,"invalid v","v",e),I(this,tu,t)}get networkV(){return T(this,il)}get legacyChainId(){const e=this.networkV;return e==null?null:ds.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),we(e)}get compactSerialized(){return Ut([this.r,this.yParityAndS])}get serialized(){return Ut([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ds(Dc,this.r,this.s,this.v);return this.networkV&&I(e,il,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Ae(e,"v");return t==rM||t==sM?eM:(V(t>=lm,"invalid EIP-155 v","v",e),(t-lm)/nM)}static getChainIdV(e,t){return Ae(e)*nM+BigInt(35+t-27)}static getNormalizedV(e){const t=Ae(e);return t===eM||t===rM?27:t===tM||t===sM?28:(V(t>=lm,"invalid v","v",e),t&tM?27:28)}static from(e){function t(c,u){V(c,u,"signature",e)}if(e==null)return new ds(Dc,ZR,ZR,27);if(typeof e=="string"){const c=lt(e,"signature");if(c.length===64){const u=we(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new ds(Dc,u,we(f),d)}if(c.length===65){const u=we(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=ds.getNormalizedV(c[64]);return new ds(Dc,u,we(f),d)}t(!1,"invalid raw signature length")}if(e instanceof ds)return e.clone();const r=e.r;t(r!=null,"missing r");const s=iM(r),i=function(c,u){if(c!=null)return iM(c);if(u!=null){t(At(u,32),"invalid yParityAndS");const f=lt(u);return f[0]&=127,we(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((lt(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=Ae(c);return{networkV:d>=lm?d:void 0,v:ds.getNormalizedV(d)}}if(u!=null)return t(At(u,32),"invalid yParityAndS"),{v:lt(u)[0]&128?28:27};if(f!=null){switch(Je(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new ds(Dc,s,i,a);return o&&I(l,il,o),t(e.yParity==null||Je(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Zc=new WeakMap,eu=new WeakMap,tu=new WeakMap,il=new WeakMap;let as=ds;const ol=class ol{constructor(e){q(this,Ri);V(Ec(e)===32,"invalid private key","privateKey","[REDACTED]"),I(this,Ri,we(e))}get privateKey(){return T(this,Ri)}get publicKey(){return ol.computePublicKey(T(this,Ri))}get compressedPublicKey(){return ol.computePublicKey(T(this,Ri),!0)}sign(e){V(Ec(e)===32,"invalid digest length","digest",e);const t=ko.sign(Pn(e),Pn(T(this,Ri)),{lowS:!0});return as.from({r:bo(t.r,32),s:bo(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=ol.computePublicKey(e);return we(ko.getSharedSecret(Pn(T(this,Ri)),lt(t),!1))}static computePublicKey(e,t){let r=lt(e,"key");if(r.length===32){const i=ko.getPublicKey(r,!!t);return we(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=ko.ProjectivePoint.fromHex(r);return we(s.toRawBytes(t))}static recoverPublicKey(e,t){V(Ec(e)===32,"invalid digest length","digest",e);const r=as.from(t);let s=ko.Signature.fromCompact(Pn(Ut([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Pn(e));return V(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=ko.ProjectivePoint.fromHex(ol.computePublicKey(e).substring(2)),i=ko.ProjectivePoint.fromHex(ol.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};Ri=new WeakMap;let vd=ol;const uG=BigInt(0),fG=BigInt(36);function oM(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=lt(Jt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const t1={};for(let n=0;n<10;n++)t1[String(n)]=String(n);for(let n=0;n<26;n++)t1[String.fromCharCode(65+n)]=String(10+n);const aM=15;function dG(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>t1[r]).join("");for(;e.length>=aM;){let r=e.substring(0,aM);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const hG=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function pG(n){n=n.toLowerCase();let e=uG;for(let t=0;t<n.length;t++)e=e*fG+hG[n[t]];return e}function dt(n){if(V(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=oM(n);return V(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(n.substring(2,4)===dG(n),"bad icap checksum","address",n);let e=pG(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return oM("0x"+e)}V(!1,"invalid address","address",n)}function gG(n){const e=dt(n.from);let r=Ae(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,dt(Ft(Jt(_a([e,r])),12))}function lM(n){return n&&typeof n.getAddress=="function"}function mG(n){try{return dt(n),!0}catch{}return!1}async function n1(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ee(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),dt(t)}function Bn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?dt(n):(ee(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),n1(n,e.resolveName(n)));if(lM(n))return n1(n,n.getAddress());if(n&&typeof n.then=="function")return n1(n,n);V(!1,"unsupported addressable value","target",n)}const xi={};function ve(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new En(xi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function ut(n,e){return new En(xi,`bytes${e||""}`,n,{size:e})}const cM=Symbol.for("_ethers_typed"),Mi=class Mi{constructor(e,t,r,s){$(this,"type");$(this,"value");q(this,al);$(this,"_typedSymbol");s==null&&(s=null),Qg(xi,e,"Typed"),Oe(this,{_typedSymbol:cM,type:t,value:r}),I(this,al,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,al)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,al)===!0?-1:T(this,al)===!1?this.value.length:null}static from(e,t){return new Mi(xi,e,t)}static uint8(e){return ve(e,8)}static uint16(e){return ve(e,16)}static uint24(e){return ve(e,24)}static uint32(e){return ve(e,32)}static uint40(e){return ve(e,40)}static uint48(e){return ve(e,48)}static uint56(e){return ve(e,56)}static uint64(e){return ve(e,64)}static uint72(e){return ve(e,72)}static uint80(e){return ve(e,80)}static uint88(e){return ve(e,88)}static uint96(e){return ve(e,96)}static uint104(e){return ve(e,104)}static uint112(e){return ve(e,112)}static uint120(e){return ve(e,120)}static uint128(e){return ve(e,128)}static uint136(e){return ve(e,136)}static uint144(e){return ve(e,144)}static uint152(e){return ve(e,152)}static uint160(e){return ve(e,160)}static uint168(e){return ve(e,168)}static uint176(e){return ve(e,176)}static uint184(e){return ve(e,184)}static uint192(e){return ve(e,192)}static uint200(e){return ve(e,200)}static uint208(e){return ve(e,208)}static uint216(e){return ve(e,216)}static uint224(e){return ve(e,224)}static uint232(e){return ve(e,232)}static uint240(e){return ve(e,240)}static uint248(e){return ve(e,248)}static uint256(e){return ve(e,256)}static uint(e){return ve(e,256)}static int8(e){return ve(e,-8)}static int16(e){return ve(e,-16)}static int24(e){return ve(e,-24)}static int32(e){return ve(e,-32)}static int40(e){return ve(e,-40)}static int48(e){return ve(e,-48)}static int56(e){return ve(e,-56)}static int64(e){return ve(e,-64)}static int72(e){return ve(e,-72)}static int80(e){return ve(e,-80)}static int88(e){return ve(e,-88)}static int96(e){return ve(e,-96)}static int104(e){return ve(e,-104)}static int112(e){return ve(e,-112)}static int120(e){return ve(e,-120)}static int128(e){return ve(e,-128)}static int136(e){return ve(e,-136)}static int144(e){return ve(e,-144)}static int152(e){return ve(e,-152)}static int160(e){return ve(e,-160)}static int168(e){return ve(e,-168)}static int176(e){return ve(e,-176)}static int184(e){return ve(e,-184)}static int192(e){return ve(e,-192)}static int200(e){return ve(e,-200)}static int208(e){return ve(e,-208)}static int216(e){return ve(e,-216)}static int224(e){return ve(e,-224)}static int232(e){return ve(e,-232)}static int240(e){return ve(e,-240)}static int248(e){return ve(e,-248)}static int256(e){return ve(e,-256)}static int(e){return ve(e,-256)}static bytes1(e){return ut(e,1)}static bytes2(e){return ut(e,2)}static bytes3(e){return ut(e,3)}static bytes4(e){return ut(e,4)}static bytes5(e){return ut(e,5)}static bytes6(e){return ut(e,6)}static bytes7(e){return ut(e,7)}static bytes8(e){return ut(e,8)}static bytes9(e){return ut(e,9)}static bytes10(e){return ut(e,10)}static bytes11(e){return ut(e,11)}static bytes12(e){return ut(e,12)}static bytes13(e){return ut(e,13)}static bytes14(e){return ut(e,14)}static bytes15(e){return ut(e,15)}static bytes16(e){return ut(e,16)}static bytes17(e){return ut(e,17)}static bytes18(e){return ut(e,18)}static bytes19(e){return ut(e,19)}static bytes20(e){return ut(e,20)}static bytes21(e){return ut(e,21)}static bytes22(e){return ut(e,22)}static bytes23(e){return ut(e,23)}static bytes24(e){return ut(e,24)}static bytes25(e){return ut(e,25)}static bytes26(e){return ut(e,26)}static bytes27(e){return ut(e,27)}static bytes28(e){return ut(e,28)}static bytes29(e){return ut(e,29)}static bytes30(e){return ut(e,30)}static bytes31(e){return ut(e,31)}static bytes32(e){return ut(e,32)}static address(e){return new Mi(xi,"address",e)}static bool(e){return new Mi(xi,"bool",!!e)}static bytes(e){return new Mi(xi,"bytes",e)}static string(e){return new Mi(xi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Mi(xi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===cM}static dereference(e,t){if(Mi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};al=new WeakMap;let En=Mi;class yG extends wi{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=En.dereference(t,"string");try{r=dt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return dt(bo(e.readValue(),20))}}class bG extends wi{constructor(t){super(t.name,t.type,"_",t.dynamic);$(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function uM(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return ee(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),ee(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _v,i=new _v,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function fM(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(ln(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(ln(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Sc.fromItems(t,r)}class wG extends wi{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);$(this,"coder");$(this,"length");Oe(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=En.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),$O(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return uM(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),ee(r*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*_n,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new bG(this.coder));return fM(t,s)}}class vG extends wi{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=En.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class dM extends wi{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Pn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class xG extends dM{constructor(e){super("bytes",e)}decode(e){return we(super.decode(e))}}class AG extends wi{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);$(this,"size");Oe(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Pn(En.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return we(t.readBytes(this.size))}}const EG=new Uint8Array([]);class kG extends wi{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(EG)}decode(e){return e.readBytes(0),null}}const CG=BigInt(0),SG=BigInt(1),TG=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class NG extends wi{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);$(this,"size");$(this,"signed");Oe(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Ae(En.dereference(r,this.type)),i=pd(TG,_n*8);if(this.signed){let o=pd(i,this.size*8-1);(s>o||s<-(o+SG))&&this._throwError("value out-of-bounds",r),s=JO(s,8*_n)}else(s<CG||s>pd(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=pd(t.readValue(),this.size*8);return this.signed&&(r=DW(r,this.size*8)),r}}class OG extends dM{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,bi(En.dereference(t,"string")))}decode(e){return Cc(super.decode(e))}}class cm extends wi{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);$(this,"coders");Oe(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=En.dereference(r,"tuple");return uM(t,this.coders,s)}decode(t){return fM(t,this.coders)}}function Ha(n){return Jt(bi(n))}var RG="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUh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oeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const hM=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),pM=4;function MG(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,g=d-1;let b=0;for(let E=0;E<f;E++)b=b<<1|u();let y=[],A=0,v=d;for(;;){let E=Math.floor(((b-A+1)*s-1)/v),k=0,S=r;for(;S-k>1;){let R=k+S>>>1;E<i[R]?S=R:k=R}if(k==0)break;y.push(k);let M=A+Math.floor(v*i[k]/s),O=A+Math.floor(v*i[k+1]/s)-1;for(;!((M^O)&h);)b=b<<1&g|u(),M=M<<1&g,O=O<<1&g|1;for(;M&~O&p;)b=b&h|b<<1&g>>>1|u(),M=M<<1^h,O=(O^h)<<1|h|1;A=M,v=1+O-M}let w=r-4;return y.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function DG(n){let e=0;return()=>n[e++]}function gM(n){return DG(MG(PG(n)))}function PG(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function IG(n){return n&1?~n>>1:n>>1}function LG(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=IG(e());return t}function xd(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function mM(n){return Ad(()=>{let e=xd(n);if(e.length)return e})}function yM(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(_G(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(BG(t,n))}return e.flat()}function Ad(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function bM(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)LG(n,t).forEach((i,o)=>r[o].push(i));return r}function _G(n,e){let t=1+e(),r=e(),s=Ad(e);return bM(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function BG(n,e){let t=1+e();return bM(t,1+n,e).map(s=>[s[0],s.slice(1)])}function FG(n){let e=[],t=xd(n);return s(r([]),[]),e;function r(i){let o=n(),a=Ad(()=>{let l=xd(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function jG(n){return n.toString(16).toUpperCase().padStart(2,"0")}function wM(n){return`{${jG(n)}}`}function UG(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Pc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function HG(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var zG="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYB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qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Ed=44032,um=4352,fm=4449,dm=4519,vM=19,xM=21,Ic=28,hm=xM*Ic,VG=vM*hm,$G=Ed+VG,WG=um+vM,GG=fm+xM,KG=dm+Ic;function kd(n){return n>>24&255}function AM(n){return n&16777215}let r1,EM,s1,pm;function JG(){let n=gM(zG);r1=new Map(mM(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),EM=new Set(xd(n)),s1=new Map,pm=new Map;for(let[e,t]of yM(n)){if(!EM.has(e)&&t.length==2){let[r,s]=t,i=pm.get(r);i||(i=new Map,pm.set(r,i)),i.set(s,e)}s1.set(e,t.reverse())}}function kM(n){return n>=Ed&&n<$G}function qG(n,e){if(n>=um&&n<WG&&e>=fm&&e<GG)return Ed+(n-um)*hm+(e-fm)*Ic;if(kM(n)&&e>dm&&e<KG&&(n-Ed)%Ic==0)return n+(e-dm);{let t=pm.get(n);return t&&(t=t.get(e),t)?t:-1}}function CM(n){r1||JG();let e=[],t=[],r=!1;function s(i){let o=r1.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(kM(i)){let o=i-Ed,a=o/hm|0,l=o%hm/Ic|0,c=o%Ic;s(um+a),s(fm+l),c>0&&s(dm+c)}else{let o=s1.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=kd(e[0]);for(let o=1;o<e.length;o++){let a=kd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=kd(e[--l]),i<=a))break}i=kd(e[o])}}return e}function QG(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=kd(i),a=AM(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=qG(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function SM(n){return CM(n).map(AM)}function YG(n){return QG(CM(n))}const TM=45,NM=".",OM=65039,RM=1,gm=n=>Array.from(n);function Cd(n,e){return n.P.has(e)||n.Q.has(e)}class XG extends Array{get is_emoji(){return!0}}let i1,MM,za,o1,DM,Lc,a1,_c,Va,PM,l1;function c1(){if(i1)return;let n=gM(RG);const e=()=>xd(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));i1=new Map(yM(n)),MM=t(),za=e(),o1=new Set(e().map(u=>za[u])),za=new Set(za),DM=t(),t();let s=mM(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Lc=Ad(u=>{let f=Ad(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=Pc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),g=!n();return{N:f,P:h,Q:p,M:g,R:d}}}),a1=t(),_c=new Map;let a=e().concat(gm(a1)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),a1.has(u)||_c.set(u,h)});for(let{V:u,M:f}of new Set(_c.values())){let d=[];for(let p of u){let g=Lc.filter(y=>Cd(y,p)),b=d.find(({G:y})=>g.some(A=>y.has(A)));b||(b={G:new Set,V:[]},d.push(b)),b.V.push(p),r(b.G,g)}let h=d.flatMap(p=>gm(p.G));for(let{G:p,V:g}of d){let b=new Set(h.filter(y=>!p.has(y)));for(let y of g)f.set(y,b)}}Va=new Set;let l=new Set;const c=u=>Va.has(u)?l.add(u):Va.add(u);for(let u of Lc){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Va)!_c.has(u)&&!l.has(u)&&_c.set(u,RM);r(Va,SM(Va)),PM=FG(n).map(u=>XG.from(u)).sort(HG),l1=new Map;for(let u of PM){let f=[l1];for(let d of u){let h=f.map(p=>{let g=p.get(d);return g||(g=new Map,p.set(d,g)),g});d===OM?f.push(...h):f=h}for(let d of f)d.V=u}}function u1(n){return(IM(n)?"":`${f1(mm([n]))} `)+wM(n)}function f1(n){return`"${n}"`}function ZG(n){if(n.length>=4&&n[2]==TM&&n[3]==TM)throw new Error(`invalid label extension: "${Pc(n.slice(0,4))}"`)}function eK(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function tK(n){let e=n[0],t=hM.get(e);if(t)throw Sd(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=hM.get(e);if(o){if(s==i)throw Sd(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw Sd(`trailing ${t}`)}function mm(n,e=1/0,t=wM){let r=[];nK(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];IM(a)&&(r.push(Pc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(Pc(n.slice(s,i))),r.join("")}function nK(n){return c1(),za.has(n)}function IM(n){return c1(),DM.has(n)}function rK(n){return aK(sK(n,YG,uK))}function sK(n,e,t){if(!n)return[];c1();let r=0;return n.split(NM).map(s=>{let i=UG(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=cK(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(eK(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))ZG(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(za.has(u[0]))throw Sd("leading combining mark");for(let g=1;g<l;g++){let b=a[g];if(!b.is_emoji&&za.has(b[0]))throw Sd(`emoji + combining mark: "${Pc(a[g-1])} + ${mm([b[0]])}"`)}tK(u);let h=gm(new Set(d)),[p]=oK(h);lK(p,d),iK(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function iK(n,e){let t,r=[];for(let s of e){let i=_c.get(s);if(i===RM)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):gm(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>Cd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function oK(n){let e=Lc;for(let t of n){let r=e.filter(s=>Cd(s,t));if(!r.length)throw Lc.some(s=>Cd(s,t))?_M(e[0],t):LM(t);if(e=r,r.length==1)break}return e}function aK(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${f1(mm(e,63))}: ${s}`)}return Pc(r)}).join(NM)}function LM(n){return new Error(`disallowed character: ${u1(n)}`)}function _M(n,e){let t=u1(e),r=Lc.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function Sd(n){return new Error(`illegal placement: ${n}`)}function lK(n,e){for(let t of e)if(!Cd(n,t))throw _M(n,t);if(n.M){let t=SM(e);for(let r=1,s=t.length;r<s;r++)if(o1.has(t[r])){let i=r+1;for(let o;i<s&&o1.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${u1(o)}`);if(i-r>pM)throw new Error(`excessive non-spacing marks: ${f1(mm(t.slice(r-1,i)))} (${i-r}/${pM})`);r=i}}}function cK(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=fK(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Va.has(o))s.push(o);else{let a=i1.get(o);if(a)s.push(...a);else if(!MM.has(o))throw LM(o)}}}return s.length&&r.push(e(s)),r}function uK(n){return n.filter(e=>e!=OM)}function fK(n,e){let t=l1,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const BM=new Uint8Array(32);BM.fill(0);function FM(n){return V(n.length!==0,"invalid ENS name; empty component","comp",n),n}function jM(n){const e=bi(dK(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(FM(e.slice(r,s))),r=s+1);return V(r<e.length,"invalid ENS name; empty component","name",n),t.push(FM(e.slice(r))),t}function dK(n){try{if(n.length===0)throw new Error("empty label");return rK(n)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",n)}}function d1(n){V(typeof n=="string","invalid ENS name; not a string","name",n),V(n.length,"invalid ENS name (empty label)","name",n);let e=BM;const t=jM(n);for(;t.length;)e=Jt(Ut([e,Jt(t.pop())]));return we(e)}function hK(n,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),we(Ut(jM(n).map(r=>{V(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function h1(n,e){return{address:dt(n),storageKeys:e.map((t,r)=>(V(At(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Co(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${r}]`,t),h1(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",n),h1(t.address,t.storageKeys)));V(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return h1(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function pK(n){let e;return typeof n=="string"?e=vd.computePublicKey(n,!1):e=n.publicKey,dt(Jt("0x"+e.substring(4)).substring(26))}function gK(n,e){return pK(vd.recoverPublicKey(n,e))}const un=BigInt(0),mK=BigInt(2),yK=BigInt(27),bK=BigInt(28),wK=BigInt(35),vK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),p1=4096*32;function UM(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=Nc(e).substring(4),"0x"+t}function ym(n){return n==="0x"?null:dt(n)}function g1(n,e){try{return Co(n)}catch(t){V(!1,t.message,e,n)}}function Td(n,e){return n==="0x"?0:Je(n,e)}function zt(n,e){if(n==="0x")return un;const t=Ae(n,e);return V(t<=vK,"value exceeds uint size",e,t),t}function Ct(n,e){const t=Ae(n,"value"),r=In(t);return V(r.length<=32,"value too large",`tx.${e}`,t),r}function m1(n){return Co(n).map(e=>[e.address,e.storageKeys])}function xK(n,e){V(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)V(At(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function AK(n){const e=tm(n);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:Td(e[0],"nonce"),gasPrice:zt(e[1],"gasPrice"),gasLimit:zt(e[2],"gasLimit"),to:ym(e[3]),value:zt(e[4],"value"),data:we(e[5]),chainId:un};if(e.length===6)return t;const r=zt(e[6],"v"),s=zt(e[7],"r"),i=zt(e[8],"s");if(s===un&&i===un)t.chainId=r;else{let o=(r-wK)/mK;o<un&&(o=un),t.chainId=o,V(o!==un||r===yK||r===bK,"non-canonical legacy v","v",e[6]),t.signature=as.from({r:Ia(e[7],32),s:Ia(e[8],32),v:r})}return t}function EK(n,e){const t=[Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data];let r=un;if(n.chainId!=un)r=Ae(n.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==un&&(t.push(In(r)),t.push("0x"),t.push("0x")),_a(t);let s=BigInt(27+e.yParity);return r!==un?s=as.getChainIdV(r,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(In(s)),t.push(In(e.r)),t.push(In(e.s)),_a(t)}function y1(n,e){let t;try{if(t=Td(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const r=Ia(e[1],32),s=Ia(e[2],32),i=as.from({r,s,yParity:t});n.signature=i}function kK(n){const e=tm(lt(n).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",we(n));const t={type:2,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:ym(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:g1(e[8],"accessList")};return e.length===9||y1(t,e.slice(9)),t}function CK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,m1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"yParity")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x02",_a(t)])}function SK(n){const e=tm(lt(n).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",we(n));const t={type:1,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),gasPrice:zt(e[2],"gasPrice"),gasLimit:zt(e[3],"gasLimit"),to:ym(e[4]),value:zt(e[5],"value"),data:we(e[6]),accessList:g1(e[7],"accessList")};return e.length===8||y1(t,e.slice(8)),t}function TK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,m1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"recoveryParam")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x01",_a(t)])}function NK(n){let e=tm(lt(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];V(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),V(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",we(n));const s={type:3,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:ym(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:g1(e[8],"accessList"),maxFeePerBlobGas:zt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),V(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),V(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)V(At(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||y1(s,e.slice(11)),s}function OK(n,e,t){const r=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||wd,Ct(n.value,"value"),n.data,m1(n.accessList||[]),Ct(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),xK(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Ct(e.yParity,"yParity")),r.push(In(e.r)),r.push(In(e.s)),t)?Ut(["0x03",_a([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Ut(["0x03",_a(r)])}const Pi=class Pi{constructor(){q(this,hu);q(this,Ws);q(this,nu);q(this,ru);q(this,su);q(this,iu);q(this,ou);q(this,au);q(this,lu);q(this,cu);q(this,uu);q(this,fu);q(this,du);q(this,ll);q(this,Ro);q(this,Di);q(this,Mo);I(this,Ws,null),I(this,nu,null),I(this,su,0),I(this,iu,un),I(this,ou,null),I(this,au,null),I(this,lu,null),I(this,ru,"0x"),I(this,cu,un),I(this,uu,un),I(this,fu,null),I(this,du,null),I(this,ll,null),I(this,Ro,null),I(this,Mo,null),I(this,Di,null)}get type(){return T(this,Ws)}set type(e){switch(e){case null:I(this,Ws,null);break;case 0:case"legacy":I(this,Ws,0);break;case 1:case"berlin":case"eip-2930":I(this,Ws,1);break;case 2:case"london":case"eip-1559":I(this,Ws,2);break;case 3:case"cancun":case"eip-4844":I(this,Ws,3);break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,nu);return e==null&&this.type===3?wd:e}set to(e){I(this,nu,e==null?null:dt(e))}get nonce(){return T(this,su)}set nonce(e){I(this,su,Je(e,"value"))}get gasLimit(){return T(this,iu)}set gasLimit(e){I(this,iu,Ae(e))}get gasPrice(){const e=T(this,ou);return e==null&&(this.type===0||this.type===1)?un:e}set gasPrice(e){I(this,ou,e==null?null:Ae(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,au);return e??(this.type===2||this.type===3?un:null)}set maxPriorityFeePerGas(e){I(this,au,e==null?null:Ae(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,lu);return e??(this.type===2||this.type===3?un:null)}set maxFeePerGas(e){I(this,lu,e==null?null:Ae(e,"maxFeePerGas"))}get data(){return T(this,ru)}set data(e){I(this,ru,we(e))}get value(){return T(this,cu)}set value(e){I(this,cu,Ae(e,"value"))}get chainId(){return T(this,uu)}set chainId(e){I(this,uu,Ae(e))}get signature(){return T(this,fu)||null}set signature(e){I(this,fu,e==null?null:as.from(e))}get accessList(){const e=T(this,du)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){I(this,du,e==null?null:Co(e))}get maxFeePerBlobGas(){const e=T(this,ll);return e==null&&this.type===3?un:e}set maxFeePerBlobGas(e){I(this,ll,e==null?null:Ae(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,Ro);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(At(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}I(this,Ro,e)}get blobs(){return T(this,Mo)==null?null:T(this,Mo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){I(this,Mo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mv(i)){ee(T(this,Di),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=lt(i);if(V(o.length<=p1,"blob is too large",`blobs[${s}]`,i),o.length!==p1){const c=new Uint8Array(p1);c.set(o),o=c}const a=T(this,Di).blobToKzgCommitment(o),l=we(T(this,Di).computeBlobKzgProof(o,a));t.push({data:we(o),commitment:we(a),proof:l}),r.push(UM(1,a))}else{const o=we(i.commitment);t.push({data:we(i.data),commitment:o,proof:we(i.proof)}),r.push(UM(1,o))}}I(this,Mo,t),I(this,Ro,r)}get kzg(){return T(this,Di)}set kzg(e){I(this,Di,e)}get hash(){return this.signature==null?null:Jt(fe(this,hu,Xm).call(this,!0,!1))}get unsignedHash(){return Jt(this.unsignedSerialized)}get from(){return this.signature==null?null:gK(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:vd.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return fe(this,hu,Xm).call(this,!0,!0)}get unsignedSerialized(){return fe(this,hu,Xm).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=T(this,ll)!=null||T(this,Ro);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ee(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ee(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ee(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Pi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Pi;if(typeof e=="string"){const r=lt(e);if(r[0]>=127)return Pi.from(AK(r));switch(r[0]){case 1:return Pi.from(SK(r));case 2:return Pi.from(kK(r));case 3:return Pi.from(NK(r))}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Pi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=as.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ws=new WeakMap,nu=new WeakMap,ru=new WeakMap,su=new WeakMap,iu=new WeakMap,ou=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,uu=new WeakMap,fu=new WeakMap,du=new WeakMap,ll=new WeakMap,Ro=new WeakMap,Di=new WeakMap,Mo=new WeakMap,hu=new WeakSet,Xm=function(e,t){ee(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return EK(this,r);case 1:return TK(this,r);case 2:return CK(this,r);case 3:return OK(this,r,t?this.blobs:null)}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Nd=Pi;const HM=new Uint8Array(32);HM.fill(0);const RK=BigInt(-1),zM=BigInt(0),VM=BigInt(1),MK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function DK(n){const e=lt(n),t=e.length%32;return t?Ut([e,HM.slice(t)]):we(e)}const PK=bo(VM,32),IK=bo(zM,32),$M={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},b1=["name","version","chainId","verifyingContract","salt"];function WM(n){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const LK={name:WM("name"),version:WM("version"),chainId:function(n){const e=Ae(n,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):La(e)},verifyingContract:function(n){try{return dt(n).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=lt(n,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",n),we(e)}};function w1(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);V(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=pd(MK,t?r-1:r),i=t?(s+VM)*RK:zM;return function(o){const a=Ae(o,"value");return V(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),bo(t?JO(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=lt(r);return V(s.length===t,`invalid length for ${n}`,"value",r),DK(r)}}}switch(n){case"address":return function(e){return Ia(dt(e),32)};case"bool":return function(e){return e?PK:IK};case"bytes":return function(e){return Jt(e)};case"string":return function(e){return Ha(e)}}return null}function GM(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function bm(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Fr=class Fr{constructor(e){q(this,Wm);$(this,"primaryType");q(this,Hd);q(this,Ii);q(this,pu);I(this,Ii,new Map),I(this,pu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=bm(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),I(this,Hd,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){V(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=bm(u.type).base;V(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!w1(f)&&(V(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);V(o.length!==0,"missing primary type","types",e),V(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),Oe(this,{primaryType:o[0]});function a(l,c){V(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),T(this,Ii).set(l,GM(l,i[l])+u.map(f=>GM(f,i[f])).join(""))}}get types(){return JSON.parse(T(this,Hd))}getEncoder(e){let t=T(this,pu).get(e);return t||(t=fe(this,Wm,tP).call(this,e),T(this,pu).set(e,t)),t}encodeType(e){const t=T(this,Ii).get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Jt(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(w1(e))return r(e,t);const s=bm(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Fr(e)}static getPrimaryType(e){return Fr.from(e).primaryType}static hashStruct(e,t,r){return Fr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=$M[r];V(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>b1.indexOf(r.name)-b1.indexOf(s.name)),Fr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ut(["0x1901",Fr.hashDomain(e),Fr.from(t).hash(r)])}static hash(e,t,r){return Jt(Fr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!At(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Fr.from(t);o.visit(r,(a,l)=>(a==="address"&&!At(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Fr.hashDomain(e);const s={},i=[];b1.forEach(l=>{const c=e[l];c!=null&&(s[l]=LK[l](c),i.push({name:l,type:$M[l]}))});const o=Fr.from(t);t=o.types;const a=Object.assign({},t);return V(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return we(lt(c));if(l.match(/^u?int/))return Ae(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return V(typeof c=="string","invalid string","value",c),c}V(!1,"unsupported type","type",l)})}}};Hd=new WeakMap,Ii=new WeakMap,pu=new WeakMap,Wm=new WeakSet,tP=function(e){{const s=w1(e);if(s)return s}const t=bm(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{V(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return T(this,Ii).has(s)&&(a=a.map(Jt)),Jt(Ut(a))}}const r=this.types[e];if(r){const s=Ha(T(this,Ii).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return T(this,Ii).has(l)?Jt(c):c});return o.unshift(s),Ut(o)}}V(!1,`unknown type: ${e}`,"type",e)};let wm=Fr;function Fn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const _K=Fn("external public payable override".split(" ")),KM="constant external internal payable private public pure view override",BK=Fn(KM.split(" ")),JM="constructor error event fallback function receive struct",qM=Fn(JM.split(" ")),QM="calldata memory storage payable indexed",FK=Fn(QM.split(" ")),jK=[JM,QM,"tuple returns",KM].join(" "),UK=Fn(jK.split(" ")),HK={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},zK=new RegExp("^(\\s*)"),VK=new RegExp("^([0-9]+)"),$K=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),YM=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),XM=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Gm=class Gm{constructor(e){q(this,zd);q(this,bn);q(this,hs);I(this,bn,0),I(this,hs,e.slice())}get offset(){return T(this,bn)}get length(){return T(this,hs).length-T(this,bn)}clone(){return new Gm(T(this,hs))}reset(){I(this,bn,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=fe(this,zd,rx).call(this,T(this,bn)+1,e.match+1);return I(this,bn,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,bn)<e.match-1;){const r=this.peek().linkNext;t.push(fe(this,zd,rx).call(this,T(this,bn)+1,r)),I(this,bn,r)}return I(this,bn,e.match+1),t}peek(){if(T(this,bn)>=T(this,hs).length)throw new Error("out-of-bounds");return T(this,hs)[T(this,bn)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Zd(this,bn)._++,e}toString(){const e=[];for(let t=T(this,bn);t<T(this,hs).length;t++){const r=T(this,hs)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};bn=new WeakMap,hs=new WeakMap,zd=new WeakSet,rx=function(e=0,t=0){return new Gm(T(this,hs).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let ls=Gm;function So(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(zK);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=HK[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Je(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match($K),a){if(l.text=a[1],i+=l.text.length,UK.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(XM)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(VK),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ls(e.map(o=>Object.freeze(o)))}function ZM(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function vm(n,e){if(e.peekKeyword(qM)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function eD(n){let e=Ai(n,BK);return ZM(e,Fn("constant payable nonpayable".split(" "))),ZM(e,Fn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ei(n,e){return n.popParams().map(t=>mn.from(t,e))}function tD(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ae(n.pop().text);throw new Error("invalid gas")}return null}function $a(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const WK=new RegExp(/^(.*)\[([0-9]*)\]$/);function nD(n){const e=n.match(XM);if(V(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const Pt={},Xn=Symbol.for("_ethers_internal"),rD="_ParamTypeInternal",sD="_ErrorInternal",iD="_EventInternal",oD="_ConstructorInternal",aD="_FallbackInternal",lD="_FunctionInternal",cD="_StructInternal",jr=class jr{constructor(e,t,r,s,i,o,a,l){q(this,gu);$(this,"name");$(this,"type");$(this,"baseType");$(this,"indexed");$(this,"components");$(this,"arrayLength");$(this,"arrayChildren");if(Qg(e,Pt,"ParamType"),Object.defineProperty(this,Xn,{value:rD}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");Oe(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return fe(this,gu,Zm).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(jr.isParamType(e))return e;if(typeof e=="string")try{return jr.from(So(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ls){let a="",l="",c=null;Ai(e,Fn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(g=>jr.from(g)),a=`tuple(${c.map(g=>g.format()).join(",")})`):(a=nD(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const g=e.pop();u=new jr(Pt,"",a,l,null,c,f,u),f=g.value,a+=g.text,l="array",c=null}let d=null;if(Ai(e,FK).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new jr(Pt,p,a,l,d,c,f,u)}const r=e.name;V(!r||typeof r=="string"&&r.match(YM),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(WK);if(o){const a=parseInt(o[2]||"-1"),l=jr.from({type:o[1],components:e.components});return new jr(Pt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>jr.from(c)):null;return new jr(Pt,r||"",i,"tuple",s,a,null,null)}return i=nD(e.type),new jr(Pt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Xn]===rD}};gu=new WeakSet,Zm=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;fe(u=o,gu,Zm).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;fe(u=o[c],gu,Zm).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let mn=jr;class Wa{constructor(e,t,r){$(this,"type");$(this,"inputs");Qg(e,Pt,"Fragment"),r=Object.freeze(r.slice()),Oe(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Wa.from(JSON.parse(e))}catch{}return Wa.from(So(e))}if(e instanceof ls)switch(e.peekKeyword(qM)){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}ee(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ki.isFragment(e)}static isError(e){return Zn.isFragment(e)}static isEvent(e){return zs.isFragment(e)}static isFunction(e){return Vs.isFragment(e)}static isStruct(e){return Ga.isFragment(e)}}class xm extends Wa{constructor(t,r,s,i){super(t,r,i);$(this,"name");V(typeof s=="string"&&s.match(YM),"invalid identifier","name",s),i=Object.freeze(i.slice()),Oe(this,{name:s})}}function Od(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Zn extends xm{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Xn,{value:sD})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Od(e,this.inputs)),t.join(" ")}static from(e){if(Zn.isFragment(e))return e;if(typeof e=="string")return Zn.from(So(e));if(e instanceof ls){const t=vm("error",e),r=Ei(e);return $a(e),new Zn(Pt,t,r)}return new Zn(Pt,e.name,e.inputs?e.inputs.map(mn.from):[])}static isFragment(e){return e&&e[Xn]===sD}}class zs extends xm{constructor(t,r,s,i){super(t,"event",r,s);$(this,"anonymous");Object.defineProperty(this,Xn,{value:iD}),Oe(this,{anonymous:i})}get topicHash(){return Ha(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>mn.from(i)),new zs(Pt,t,r,!1).topicHash}static from(t){if(zs.isFragment(t))return t;if(typeof t=="string")try{return zs.from(So(t))}catch{V(!1,"invalid event fragment","obj",t)}else if(t instanceof ls){const r=vm("event",t),s=Ei(t,!0),i=!!Ai(t,Fn(["anonymous"])).has("anonymous");return $a(t),new zs(Pt,r,s,i)}return new zs(Pt,t.name,t.inputs?t.inputs.map(r=>mn.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Xn]===iD}}class ki extends Wa{constructor(t,r,s,i,o){super(t,r,s);$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:oD}),Oe(this,{payable:i,gas:o})}format(t){if(ee(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${Od(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ki.isFragment(t))return t;if(typeof t=="string")try{return ki.from(So(t))}catch{V(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ls){Ai(t,Fn(["constructor"]));const r=Ei(t),s=!!Ai(t,_K).has("payable"),i=tD(t);return $a(t),new ki(Pt,"constructor",r,s,i)}return new ki(Pt,"constructor",t.inputs?t.inputs.map(mn.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===oD}}class Ci extends Wa{constructor(t,r,s){super(t,"fallback",r);$(this,"payable");Object.defineProperty(this,Xn,{value:aD}),Oe(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Ci.isFragment(t))return t;if(typeof t=="string")try{return Ci.from(So(t))}catch{V(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ls){const r=t.toString(),s=t.peekKeyword(Fn(["fallback","receive"]));if(V(s,"type must be fallback or receive","obj",r),t.popKeyword(Fn(["fallback","receive"]))==="receive"){const l=Ei(t);return V(l.length===0,"receive cannot have arguments","obj.inputs",l),Ai(t,Fn(["payable"])),$a(t),new Ci(Pt,[],!0)}let o=Ei(t);o.length?V(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[mn.from("bytes")];const a=eD(t);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Ai(t,Fn(["returns"])).has("returns")){const l=Ei(t);V(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return $a(t),new Ci(Pt,o,a==="payable")}if(t.type==="receive")return new Ci(Pt,[],!0);if(t.type==="fallback"){const r=[mn.from("bytes")],s=t.stateMutability==="payable";return new Ci(Pt,r,s)}V(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Xn]===aD}}class Vs extends xm{constructor(t,r,s,i,o,a){super(t,"function",r,i);$(this,"constant");$(this,"outputs");$(this,"stateMutability");$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:lD}),o=Object.freeze(o.slice()),Oe(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Od(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>mn.from(i)),new Vs(Pt,t,"view",r,[],null).selector}static from(t){if(Vs.isFragment(t))return t;if(typeof t=="string")try{return Vs.from(So(t))}catch{V(!1,"invalid function fragment","obj",t)}else if(t instanceof ls){const s=vm("function",t),i=Ei(t),o=eD(t);let a=[];Ai(t,Fn(["returns"])).has("returns")&&(a=Ei(t));const l=tD(t);return $a(t),new Vs(Pt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Vs(Pt,t.name,r,t.inputs?t.inputs.map(mn.from):[],t.outputs?t.outputs.map(mn.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===lD}}class Ga extends xm{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Xn,{value:cD})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Ga.from(So(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ls){const t=vm("struct",e),r=Ei(e);return $a(e),new Ga(Pt,t,r)}return new Ga(Pt,e.name,e.inputs?e.inputs.map(mn.from):[])}static isFragment(e){return e&&e[Xn]===cD}}const cs=new Map;cs.set(0,"GENERIC_PANIC"),cs.set(1,"ASSERT_FALSE"),cs.set(17,"OVERFLOW"),cs.set(18,"DIVIDE_BY_ZERO"),cs.set(33,"ENUM_RANGE_ERROR"),cs.set(34,"BAD_STORAGE_DATA"),cs.set(49,"STACK_UNDERFLOW"),cs.set(50,"ARRAY_RANGE_ERROR"),cs.set(65,"OUT_OF_MEMORY"),cs.set(81,"UNINITIALIZED_FUNCTION_CALL");const GK=new RegExp(/^bytes([0-9]*)$/),KK=new RegExp(/^(u?int)([0-9]*)$/);let v1=null,uD=1024;function JK(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=lt(t);if(t=we(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(we(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(we(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${cs.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?dt(e.to):null,data:e.data||"0x"};return e.from&&(l.from=dt(e.from)),Nt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Km=class Km{constructor(){q(this,Do)}getDefaultValue(e){const t=e.map(s=>fe(this,Do,Fu).call(this,mn.from(s)));return new cm(t,"_").defaultValue()}encode(e,t){$O(t.length,e.length,"types/values length mismatch");const r=e.map(o=>fe(this,Do,Fu).call(this,mn.from(o))),s=new cm(r,"_"),i=new _v;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>fe(this,Do,Fu).call(this,mn.from(o)));return new cm(s,"_").decode(new Bv(t,r,uD))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),uD=e}static defaultAbiCoder(){return v1==null&&(v1=new Km),v1}static getBuiltinCallException(e,t,r){return JK(e,t,r,Km.defaultAbiCoder())}};Do=new WeakSet,Fu=function(e){if(e.isArray())return new wG(fe(this,Do,Fu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new cm(e.components.map(r=>fe(this,Do,Fu).call(this,r)),e.name);switch(e.baseType){case"address":return new yG(e.name);case"bool":return new vG(e.name);case"string":return new OG(e.name);case"bytes":return new xG(e.name);case"":return new kG(e.name)}let t=e.type.match(KK);if(t){let r=parseInt(t[2]||"256");return V(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new NG(r/8,t[1]==="int",e.name)}if(t=e.type.match(GK),t){let r=parseInt(t[1]);return V(r!==0&&r<=32,"invalid bytes length","param",e),new AG(r,e.name)}V(!1,"invalid type","type",e.type)};let Bc=Km;class qK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"signature");$(this,"topic");$(this,"args");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class QK{constructor(e,t,r,s){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");$(this,"value");const i=e.name,o=e.format();Oe(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class YK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class fD{constructor(e){$(this,"hash");$(this,"_isIndexed");Oe(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const dD={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},hD={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&dD[n.toString()]&&(e=dD[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},cl=class cl{constructor(e){q(this,qs);$(this,"fragments");$(this,"deploy");$(this,"fallback");$(this,"receive");q(this,Gs);q(this,Ks);q(this,Js);q(this,kn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Js,new Map),I(this,Gs,new Map),I(this,Ks,new Map);const r=[];for(const o of t)try{r.push(Wa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}Oe(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,kn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Oe(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(V(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=T(this,Js);break;case"event":l=T(this,Ks);break;case"error":l=T(this,Gs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||Oe(this,{deploy:ki.from("constructor()")}),Oe(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Bc.defaultAbiCoder()}getFunctionName(e){const t=fe(this,qs,ey).call(this,e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!fe(this,qs,ey).call(this,e,null,!1)}getFunction(e,t){return fe(this,qs,ey).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,Js).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Js).get(s),r)}}getEventName(e){const t=fe(this,qs,ty).call(this,e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!fe(this,qs,ty).call(this,e,null,!1)}getEvent(e,t){return fe(this,qs,ty).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,Ks).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Ks).get(s),r)}}getError(e,t){if(At(e)){const s=e.toLowerCase();if(hD[s])return Zn.from(hD[s].signature);for(const i of T(this,Gs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of T(this,Gs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Zn.from("error Error(string)"):e==="Panic"?Zn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Zn.from(e).format(),e==="Error(string)")return Zn.from("error Error(string)");if(e==="Panic(uint256)")return Zn.from("error Panic(uint256)");const r=T(this,Gs).get(e);return r||null}forEachError(e){const t=Array.from(T(this,Gs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Gs).get(s),r)}}_decodeParams(e,t){return T(this,kn).decode(e,t)}_encodeParams(e,t){return T(this,kn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);V(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Pn(t);if(s.length%32===0)try{return T(this,kn).decode(e.outputs,s)}catch{r="could not decode result data"}ee(!1,r,"BAD_DATA",{value:we(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=lt(e,"data"),s=Bc.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=we(r.slice(0,4)),l=this.getError(a);if(l)try{const c=T(this,kn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return we(T(this,kn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);V(i,"unknown event","eventFragment",e),e=i}ee(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?Ha(o):i.type==="bytes"?Jt(we(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=bo(o):i.type.match(/^bytes/)?o=MW(o,32):i.type==="address"&&T(this,kn).encode(["address"],[o]),Ia(we(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){V(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);V(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(Ha(l));else if(o.type==="bytes")r.push(Jt(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,kn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:T(this,kn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);V(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;V(At(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(mn.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?T(this,kn).decode(s,Ut(r)):null,l=T(this,kn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let g=null;if(h.indexed)if(a==null)g=new fD(null);else if(o[p])g=new fD(a[d++]);else try{g=a[d++]}catch(b){g=b}else try{g=l[f++]}catch(b){g=b}c.push(g),u.push(h.name||null)}),Sc.fromItems(c,u)}parseTransaction(e){const t=lt(e.data,"tx.data"),r=Ae(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(we(t.slice(0,4)));if(!s)return null;const i=T(this,kn).decode(s.inputs,t.slice(4));return new QK(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new qK(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=we(e),r=this.getError(Ft(t,0,4));if(!r)return null;const s=T(this,kn).decode(r.inputs,Ft(t,4));return new YK(r,r.selector,s)}static from(e){return e instanceof cl?e:typeof e=="string"?new cl(JSON.parse(e)):typeof e.formatJson=="function"?new cl(e.formatJson()):typeof e.format=="function"?new cl(e.format("json")):new cl(e)}};Gs=new WeakMap,Ks=new WeakMap,Js=new WeakMap,kn=new WeakMap,qs=new WeakSet,ey=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Js).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Js))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;En.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(En.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Js).get(Vs.from(e).format());return s||null},ty=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Ks).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Ks))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(En.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Ks).get(zs.from(e).format());return s||null};let x1=cl;const pD=BigInt(0);function Fc(n){return n??null}function Vt(n){return n==null?null:n.toString()}class gD{constructor(e,t,r){$(this,"gasPrice");$(this,"maxFeePerGas");$(this,"maxPriorityFeePerGas");Oe(this,{gasPrice:Fc(e),maxFeePerGas:Fc(t),maxPriorityFeePerGas:Fc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Vt(e),maxFeePerGas:Vt(t),maxPriorityFeePerGas:Vt(r)}}}function Am(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=we(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Ae(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Je(n[s],`request.${s}`));return n.accessList&&(e.accessList=Co(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mv(s)?we(s):Object.assign({},s))),e}class XK{constructor(e,t){$(this,"provider");$(this,"number");$(this,"hash");$(this,"timestamp");$(this,"parentHash");$(this,"parentBeaconBlockRoot");$(this,"nonce");$(this,"difficulty");$(this,"gasLimit");$(this,"gasUsed");$(this,"stateRoot");$(this,"receiptsRoot");$(this,"blobGasUsed");$(this,"excessBlobGas");$(this,"miner");$(this,"prevRandao");$(this,"extraData");$(this,"baseFeePerGas");q(this,Li);I(this,Li,e.transactions.map(r=>typeof r!="string"?new Md(r,t):r)),Oe(this,{provider:t,hash:Fc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Fc(e.prevRandao),extraData:e.extraData,baseFeePerGas:Fc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Li).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Li).slice();return e.length===0?[]:(ee(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:g,transactions:b}=this;return{_type:"Block",baseFeePerGas:Vt(e),difficulty:Vt(t),extraData:r,gasLimit:Vt(s),gasUsed:Vt(i),blobGasUsed:Vt(this.blobGasUsed),excessBlobGas:Vt(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:g,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:b}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Li).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Li)[e];else{const r=e.toLowerCase();for(const s of T(this,Li))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ZK(this)}}Li=new WeakMap;class Rd{constructor(e,t){$(this,"provider");$(this,"transactionHash");$(this,"blockHash");$(this,"blockNumber");$(this,"removed");$(this,"address");$(this,"data");$(this,"topics");$(this,"index");$(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());Oe(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ee(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return eJ(this)}}class mD{constructor(e,t){$(this,"provider");$(this,"to");$(this,"from");$(this,"contractAddress");$(this,"hash");$(this,"index");$(this,"blockHash");$(this,"blockNumber");$(this,"logsBloom");$(this,"gasUsed");$(this,"blobGasUsed");$(this,"cumulativeGasUsed");$(this,"gasPrice");$(this,"blobGasPrice");$(this,"type");$(this,"status");$(this,"root");q(this,Vd);I(this,Vd,Object.freeze(e.logs.map(s=>new Rd(s,t))));let r=pD;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),Oe(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Vd)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Vt(this.cumulativeGasUsed),from:t,gasPrice:Vt(this.gasPrice),blobGasUsed:Vt(this.blobGasUsed),blobGasPrice:Vt(this.blobGasPrice),gasUsed:Vt(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return bD(this)}reorderedEvent(e){return ee(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),yD(this,e)}}Vd=new WeakMap;const J1=class J1{constructor(e,t){$(this,"provider");$(this,"blockNumber");$(this,"blockHash");$(this,"index");$(this,"hash");$(this,"type");$(this,"to");$(this,"from");$(this,"nonce");$(this,"gasLimit");$(this,"gasPrice");$(this,"maxPriorityFeePerGas");$(this,"maxFeePerGas");$(this,"maxFeePerBlobGas");$(this,"data");$(this,"value");$(this,"chainId");$(this,"signature");$(this,"accessList");$(this,"blobVersionedHashes");q(this,Po);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,I(this,Po,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Vt(this.chainId),data:c,from:a,gasLimit:Vt(this.gasLimit),gasPrice:Vt(this.gasPrice),hash:s,maxFeePerGas:Vt(this.maxFeePerGas),maxPriorityFeePerGas:Vt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Vt(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:Vt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await An({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=T(this,Po),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await An({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<T(this,Po)&&(o=T(this,Po)));o<=d;){if(a)return null;const g=await this.provider.getBlock(o,!0);if(g==null)return;for(const b of g)if(b===this.hash)return;for(let b=0;b<g.length;b++){const y=await g.getTransaction(b);if(y.from===this.from&&y.nonce===this.nonce){if(a)return null;const A=await this.provider.getTransactionReceipt(y.hash);if(A==null||d-A.blockNumber+1<r)return;let v="replaced";y.data===this.data&&y.to===this.to&&y.value===this.value?v="repriced":y.data==="0x"&&y.from===y.to&&y.value===pD&&(v="cancelled"),ee(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:y.replaceableTransaction(i),hash:y.hash,receipt:A})}}o++}},c=d=>{if(d==null||d.status!==0)return d;ee(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],g=()=>{p.forEach(y=>y())};if(p.push(()=>{a=!0}),s>0){const y=setTimeout(()=>{g(),h(Nt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(y)})}const b=async y=>{if(await y.confirmations()>=r){g();try{d(c(y))}catch(A){h(A)}}};if(p.push(()=>{this.provider.off(this.hash,b)}),this.provider.on(this.hash,b),i>=0){const y=async()=>{try{await l()}catch(A){if(ln(A,"TRANSACTION_REPLACED")){g(),h(A);return}}a||this.provider.once("block",y)};p.push(()=>{this.provider.off("block",y)}),this.provider.once("block",y)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),bD(this)}reorderedEvent(e){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ee(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),yD(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new J1(this,this.provider);return I(t,Po,e),t}};Po=new WeakMap;let Md=J1;function ZK(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function yD(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function bD(n){return{orphan:"drop-transaction",tx:n}}function eJ(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class A1 extends Rd{constructor(t,r,s){super(t,t.provider);$(this,"interface");$(this,"fragment");$(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);Oe(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class wD extends Rd{constructor(t,r){super(t,t.provider);$(this,"error");Oe(this,{error:r})}}class tJ extends mD{constructor(t,r,s){super(s,r);q(this,mu);I(this,mu,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?T(this,mu).getEvent(t.topics[0]):null;if(r)try{return new A1(t,T(this,mu),r)}catch(s){return new wD(t,s)}return t})}}mu=new WeakMap;class E1 extends Md{constructor(t,r,s){super(s,r);q(this,$d);I(this,$d,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new tJ(T(this,$d),this.provider,s)}}$d=new WeakMap;class vD extends XO{constructor(t,r,s,i){super(t,r,s);$(this,"log");Oe(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class nJ extends vD{constructor(e,t,r,s,i){super(e,t,r,new A1(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Oe(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const xD=BigInt(0);function AD(n){return n&&typeof n.call=="function"}function ED(n){return n&&typeof n.estimateGas=="function"}function Em(n){return n&&typeof n.resolveName=="function"}function kD(n){return n&&typeof n.sendTransaction=="function"}function CD(n){if(n!=null){if(Em(n))return n;if(n.provider)return n.provider}}class rJ{constructor(e,t,r){q(this,Wd);$(this,"fragment");if(Oe(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ka(e.runner,"resolveName"),i=Em(s)?s:null;I(this,Wd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Bn(d,i))):Bn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Wd)}}Wd=new WeakMap;function Ka(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ja(n){return n==null?null:n.provider||null}async function SD(n,e){const t=En.dereference(n,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",n);const r=Am(t);return V(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),V(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function sJ(n,e,t){const r=Ka(n,"resolveName"),s=Em(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=En.dereference(l,a),a==="address"?Bn(l,s):l))))}function iJ(n){const e=async function(o){const a=await SD(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Bn(a.from,CD(n.runner)));const l=n.interface,c=Ae(a.value||xD,"overrides.value")===xD,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return V(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ka(n.runner,"call");ee(AD(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Rv(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;ee(kD(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ja(n.runner);return new E1(n.interface,c,l)},s=async function(o){const a=Ka(n.runner,"estimateGas");return ee(ED(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return Oe(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function oJ(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return ee(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await SD(c.pop()),f.from&&(f.from=await Bn(f.from,CD(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await sJ(n.runner,u.inputs,c);return Object.assign({},f,await An({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;ee(kD(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ja(n.runner);return new E1(n.interface,d,f)},o=async function(...c){const u=Ka(n.runner,"estimateGas");return ee(ED(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ka(n.runner,"call");ee(AD(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Rv(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return Oe(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return ee(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function aJ(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return ee(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new rJ(n,t(...s),s)};return Oe(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return ee(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const km=Symbol.for("_ethersInternal_contract"),TD=new WeakMap;function lJ(n,e){TD.set(n[km],e)}function br(n){return TD.get(n[km])}function cJ(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function k1(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(At(o,32))return o;const a=n.interface.getEvent(o);return V(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?At(e,32)?t=[e]:(r=n.interface.getEvent(e),V(r,"unknown fragment","event",e),t=[r.topicHash]):cJ(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):V(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Dd(n,e){const{subs:t}=br(n);return t.get((await k1(n,e)).tag)||null}async function ND(n,e,t){const r=Ja(n.runner);ee(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await k1(n,t),{addr:a,subs:l}=br(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=b=>{let y=s;if(y==null)try{y=n.interface.getEvent(b.topics[0])}catch{}if(y){const A=y,v=s?n.interface.decodeEventLog(s,b.data,b.topics):[];S1(n,t,v,w=>new nJ(n,w,t,A,b))}else S1(n,t,[],A=>new vD(n,A,t,b))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let b=h;h=[],await Promise.all(b),r.off(f,d)}},l.set(i,c)}return c}let C1=Promise.resolve();async function uJ(n,e,t,r){await C1;const s=await Dd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),br(n).subs.delete(s.tag)),i>0}async function S1(n,e,t,r){try{await C1}catch{}const s=uJ(n,e,t,r);return C1=s,await s}const Cm=["then"];qD=km;const Gd=class Gd{constructor(e,t,r,s){$(this,"target");$(this,"interface");$(this,"runner");$(this,"filters");$(this,qD);$(this,"fallback");V(typeof e=="string"||lM(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=x1.from(t);Oe(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,km,{value:{}});let o,a=null,l=null;if(s){const f=Ja(r);l=new E1(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(At(e))a=e,o=Promise.resolve(e);else{const f=Ka(r,"resolveName");if(!Em(f))throw Nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw Nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return br(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return br(this).addr=f,f});lJ(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Cm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Cm.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return Oe(this,{filters:u}),Oe(this,{fallback:i.receive||i.fallback?iJ(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Cm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Cm.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Gd(this.target,this.interface,e)}attach(e){return new Gd(e,this.interface,this.runner)}async getAddress(){return await br(this).addrPromise}async getDeployedCode(){const e=Ja(this.runner);ee(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ja(this.runner);return ee(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return br(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),oJ(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),aJ(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=br(this),o=s||await i,{fragment:a,topics:l}=await k1(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ja(this.runner);return ee(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new A1(f,this.interface,d)}catch(h){return new wD(f,h)}return new Rd(f,u)})}async on(e,t){const r=await ND(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await ND(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await S1(this,e,t,null)}async listenerCount(e){if(e){const s=await Dd(this,e);return s?s.listeners.length:0}const{subs:t}=br(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Dd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=br(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Dd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),br(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Dd(this,e);if(!t)return this;t.stop(),br(this).subs.delete(t.tag)}else{const{subs:t}=br(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let T1=Gd;function fJ(){return T1}class jc extends fJ(){}function N1(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):V(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class dJ{constructor(e){$(this,"name");Oe(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const OD=new RegExp("^(ipfs)://(.*)$","i"),RD=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),OD,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],yu=class yu{constructor(e,t,r){q(this,Lo);$(this,"provider");$(this,"address");$(this,"name");q(this,Io);q(this,ul);Oe(this,{provider:e,address:t,name:r}),I(this,Io,null),I(this,ul,new jc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Io)==null&&I(this,Io,(async()=>{try{return await T(this,ul).supportsInterface("0x9061b923")}catch(e){if(ln(e,"CALL_EXCEPTION"))return!1;throw I(this,Io,null),e}})()),await T(this,Io)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await fe(this,Lo,ju).call(this,"addr(bytes32)");return i==null||i===wd?null:i}catch(i){if(ln(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[i]);if(At(o,20))return dt(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof dJ&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;ee(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await fe(this,Lo,ju).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await fe(this,Lo,ju).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${IW("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ee(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<RD.length;r++){const s=t.match(RD[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=N1(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new jc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const g=await u.ownerOf(c);if(a!==g)return e.push({type:"!owner",value:g}),{url:null,linkage:e};e.push({type:"owner",value:g})}else if(i==="erc1155"){const g=await u.balanceOf(a,c);if(!g)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:g.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",bo(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=N1(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Ln(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const y=h.body;return y&&e.push({type:"!metadata",value:we(y)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(OD)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=N1(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return ee(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await fe(s=yu,Jm,nP).call(s,e,r);if(i!=null){const o=new yu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Io=new WeakMap,ul=new WeakMap,Lo=new WeakSet,ju=async function(e,t){t=(t||[]).slice();const r=T(this,ul).interface;t.unshift(d1(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),ee(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[hK(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await T(this,ul)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ln(i,"CALL_EXCEPTION"))throw i}return null},Jm=new WeakSet,nP=async function(e,t){const r=await yu.getEnsAddress(e);try{const i=await new jc(r,["function resolver(bytes32) view returns (address)"],e).resolver(d1(t),{enableCcipRead:!0});return i===wd?null:i}catch(s){throw s}return null},q(yu,Jm);let Sm=yu;const MD=BigInt(0);function ot(n,e){return function(t){return t==null?e:n(t)}}function Tm(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function Pd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ee(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function hJ(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Uc(n){return V(At(n,!0),"invalid data","value",n),n}function yn(n){return V(At(n,32),"invalid hash","value",n),n}const pJ=Pd({address:dt,blockHash:yn,blockNumber:Je,data:Uc,index:Je,removed:ot(hJ,!1),topics:Tm(yn),transactionHash:yn,transactionIndex:Je},{index:["logIndex"]});function gJ(n){return pJ(n)}const mJ=Pd({hash:ot(yn),parentHash:yn,parentBeaconBlockRoot:ot(yn,null),number:Je,timestamp:Je,nonce:ot(Uc),difficulty:Ae,gasLimit:Ae,gasUsed:Ae,stateRoot:ot(yn,null),receiptsRoot:ot(yn,null),blobGasUsed:ot(Ae,null),excessBlobGas:ot(Ae,null),miner:ot(dt),prevRandao:ot(yn,null),extraData:Uc,baseFeePerGas:ot(Ae)},{prevRandao:["mixHash"]});function yJ(n){const e=mJ(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:DD(t)),e}const bJ=Pd({transactionIndex:Je,blockNumber:Je,transactionHash:yn,address:dt,topics:Tm(yn),data:Uc,index:Je,blockHash:yn},{index:["logIndex"]});function wJ(n){return bJ(n)}const vJ=Pd({to:ot(dt,null),from:ot(dt,null),contractAddress:ot(dt,null),index:Je,root:ot(we),gasUsed:Ae,blobGasUsed:ot(Ae,null),logsBloom:ot(Uc),blockHash:yn,hash:yn,logs:Tm(wJ),blockNumber:Je,cumulativeGasUsed:Ae,effectiveGasPrice:ot(Ae),blobGasPrice:ot(Ae,null),status:ot(Je),type:ot(Je,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function xJ(n){return vJ(n)}function DD(n){n.to&&Ae(n.to)===MD&&(n.to="0x0000000000000000000000000000000000000000");const e=Pd({hash:yn,index:ot(Je,void 0),type:t=>t==="0x"||t==null?0:Je(t),accessList:ot(Co,null),blobVersionedHashes:ot(Tm(yn,!0),null),blockHash:ot(yn,null),blockNumber:ot(Je,null),transactionIndex:ot(Je,null),from:dt,gasPrice:ot(Ae),maxPriorityFeePerGas:ot(Ae),maxFeePerGas:ot(Ae),maxFeePerBlobGas:ot(Ae,null),gasLimit:Ae,to:ot(dt,null),value:Ae,nonce:Je,data:Uc,creates:ot(dt,null),chainId:ot(Ae,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=gG(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=as.from(n.signature):e.signature=as.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Ae(e.blockHash)===MD&&(e.blockHash=null),e}const AJ="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Id{constructor(e){$(this,"name");Oe(this,{name:e})}clone(){return new Id(this.name)}}class Nm extends Id{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);$(this,"effectiveBlock");$(this,"txBase");$(this,"txCreate");$(this,"txDataZero");$(this,"txDataNonzero");$(this,"txAccessListStorageKey");$(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),V(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),Oe(this,s)}clone(){return new Nm(this.effectiveBlock,this)}}class Om extends Id{constructor(t,r){super("org.ethers.plugins.network.Ens");$(this,"address");$(this,"targetNetwork");Oe(this,{address:t||AJ,targetNetwork:r??1})}clone(){return new Om(this.address,this.targetNetwork)}}class EJ extends Id{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");q(this,Kd);q(this,Jd);I(this,Kd,t),I(this,Jd,r)}get url(){return T(this,Kd)}get processFunc(){return T(this,Jd)}clone(){return this}}Kd=new WeakMap,Jd=new WeakMap;const O1=new Map,vu=class vu{constructor(e,t){q(this,bu);q(this,wu);q(this,_o);I(this,bu,e),I(this,wu,Ae(t)),I(this,_o,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,bu)}set name(e){I(this,bu,e)}get chainId(){return T(this,wu)}set chainId(e){I(this,wu,Ae(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Ae(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Ae(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Ae(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,_o).values())}attachPlugin(e){if(T(this,_o).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,_o).set(e.name,e.clone()),this}getPlugin(e){return T(this,_o).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new vu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new Nm;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=Co(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(kJ(),e==null)return vu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=O1.get(e);if(t)return t();if(typeof e=="bigint")return new vu("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new vu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Om(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=O1.get(e);r&&V(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),O1.set(e,t)}};bu=new WeakMap,wu=new WeakMap,_o=new WeakMap;let Yt=vu;function PD(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function ID(n){return new EJ(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:PD(a.maxFee,9),maxPriorityFeePerGas:PD(a.maxPriorityFee,9)}}catch(i){ee(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let LD=!1;function kJ(){if(LD)return;LD=!0;function n(e,t,r){const s=function(){const i=new Yt(e,t);return r.ensNetwork!=null&&i.attachPlugin(new Om(null,r.ensNetwork)),i.attachPlugin(new Nm),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};Yt.register(e,s),Yt.register(t,s),r.altNames&&r.altNames.forEach(i=>{Yt.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[ID("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[ID("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function R1(n){return JSON.parse(JSON.stringify(n))}class CJ{constructor(e){q(this,xu);q(this,_i);q(this,Ur);q(this,Bo);q(this,Qs);I(this,_i,e),I(this,Ur,null),I(this,Bo,4e3),I(this,Qs,-2)}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){I(this,Bo,e)}start(){T(this,Ur)||(I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo))),fe(this,xu,ny).call(this))}stop(){T(this,Ur)&&(T(this,_i)._clearTimeout(T(this,Ur)),I(this,Ur,null))}pause(e){this.stop(),e&&I(this,Qs,-2)}resume(){this.start()}}_i=new WeakMap,Ur=new WeakMap,Bo=new WeakMap,Qs=new WeakMap,xu=new WeakSet,ny=async function(){try{const e=await T(this,_i).getBlockNumber();if(T(this,Qs)===-2){I(this,Qs,e);return}if(e!==T(this,Qs)){for(let t=T(this,Qs)+1;t<=e;t++){if(T(this,Ur)==null)return;await T(this,_i).emit("block",t)}I(this,Qs,e)}}catch{}T(this,Ur)!=null&&I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo)))};class M1{constructor(e){q(this,fl);q(this,dl);q(this,Fo);I(this,fl,e),I(this,Fo,!1),I(this,dl,t=>{this._poll(t,T(this,fl))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Fo)||(I(this,Fo,!0),T(this,dl).call(this,-2),T(this,fl).on("block",T(this,dl)))}stop(){T(this,Fo)&&(I(this,Fo,!1),T(this,fl).off("block",T(this,dl)))}pause(e){this.stop()}resume(){this.start()}}fl=new WeakMap,dl=new WeakMap,Fo=new WeakMap;class SJ extends M1{constructor(t,r){super(t);q(this,Au);q(this,Bi);I(this,Au,r),I(this,Bi,-2)}pause(t){t&&I(this,Bi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(T(this,Au));s!=null&&(T(this,Bi)===-2?I(this,Bi,s.number):s.number>T(this,Bi)&&(r.emit(T(this,Au),s.number),I(this,Bi,s.number)))}}Au=new WeakMap,Bi=new WeakMap;class TJ extends M1{constructor(t,r){super(t);q(this,qm);I(this,qm,R1(r))}async _poll(t,r){throw new Error("@TODO")}}qm=new WeakMap;class NJ extends M1{constructor(t,r){super(t);q(this,Eu);I(this,Eu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(T(this,Eu));s&&r.emit(T(this,Eu),s)}}Eu=new WeakMap;class D1{constructor(e,t){q(this,Qm);q(this,Fi);q(this,ku);q(this,Cu);q(this,jo);q(this,Hr);I(this,Fi,e),I(this,ku,R1(t)),I(this,Cu,fe(this,Qm,rP).bind(this)),I(this,jo,!1),I(this,Hr,-2)}start(){T(this,jo)||(I(this,jo,!0),T(this,Hr)===-2&&T(this,Fi).getBlockNumber().then(e=>{I(this,Hr,e)}),T(this,Fi).on("block",T(this,Cu)))}stop(){T(this,jo)&&(I(this,jo,!1),T(this,Fi).off("block",T(this,Cu)))}pause(e){this.stop(),e&&I(this,Hr,-2)}resume(){this.start()}}Fi=new WeakMap,ku=new WeakMap,Cu=new WeakMap,jo=new WeakMap,Hr=new WeakMap,Qm=new WeakSet,rP=async function(e){if(T(this,Hr)===-2)return;const t=R1(T(this,ku));t.fromBlock=T(this,Hr)+1,t.toBlock=e;const r=await T(this,Fi).getLogs(t);if(r.length===0){T(this,Hr)<e-60&&I(this,Hr,e-60);return}for(const s of r)T(this,Fi).emit(T(this,ku),s),I(this,Hr,s.blockNumber)};const OJ=BigInt(2),RJ=10;function Rm(n){return n&&typeof n.then=="function"}function Mm(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class Dm{constructor(e){$(this,"name");Oe(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function MJ(n){return JSON.parse(JSON.stringify(n))}function P1(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function I1(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(At(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:Mm("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:Mm("orphan",t),filter:MJ(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?P1(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{At(a)?s.push(a):i.push((async()=>{s.push(await Bn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=P1(s.map(a=>a.toLowerCase()))}return{filter:r,tag:Mm("event",r),type:"event"}}V(!1,"unknown ProviderEvent","event",n)}function L1(){return new Date().getTime()}const DJ={cacheTimeout:250,pollingInterval:4e3};class Pm{constructor(e,t){q(this,nt);q(this,Cn);q(this,Uo);q(this,Sn);q(this,Su);q(this,Ar);q(this,hl);q(this,Ho);q(this,ji);q(this,qd);q(this,zr);q(this,Tu);q(this,Nu);if(I(this,Nu,Object.assign({},DJ,t||{})),e==="any")I(this,hl,!0),I(this,Ar,null);else if(e){const r=Yt.from(e);I(this,hl,!1),I(this,Ar,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else I(this,hl,!1),I(this,Ar,null);I(this,ji,-1),I(this,Ho,new Map),I(this,Cn,new Map),I(this,Uo,new Map),I(this,Sn,null),I(this,Su,!1),I(this,qd,1),I(this,zr,new Map),I(this,Tu,!1)}get pollingInterval(){return T(this,Nu).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Uo).values())}attachPlugin(e){if(T(this,Uo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Uo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Uo).get(e)||null}get disableCcipRead(){return T(this,Tu)}set disableCcipRead(e){I(this,Tu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Ln(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}ee(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}ee(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new XK(yJ(e),this)}_wrapLog(e,t){return new Rd(gJ(e),this)}_wrapTransactionReceipt(e,t){return new mD(xJ(e),this)}_wrapTransactionResponse(e,t){return new Md(DD(e),this)}_detectNetwork(){ee(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ee(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Je(await fe(this,nt,Er).call(this,{method:"getBlockNumber"}),"%response");return T(this,ji)>=0&&I(this,ji,e),e}_getAddress(e){return Bn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(At(e))return At(e,32)?e:La(e);if(typeof e=="bigint"&&(e=Je(e,"blockTag")),typeof e=="number")return e>=0?La(e):T(this,ji)>=0?La(T(this,ji)+e):this.getBlockNumber().then(t=>La(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?P1(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=Am(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Bn(t[s],this);Rm(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);Rm(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(T(this,Ar)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw T(this,Ar)===s&&I(this,Ar,null),i}})();return I(this,Ar,s),(await s).clone()}const e=T(this,Ar),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(T(this,hl)?(this.emit("network",r,t),T(this,Ar)===e&&I(this,Ar,Promise.resolve(r))):ee(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await An({_block:fe(this,nt,ox).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getGasPrice"});return Ae(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getPriorityFee"});return Ae(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*OJ+l),new gD(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Ln(r.url),i=await r.processFunc(t,this,s);return new gD(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Rm(t)&&(t=await t),Ae(await fe(this,nt,Er).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await An({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await fe(this,nt,ix).call(this,fe(this,nt,sx).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return Ae(await fe(this,nt,th).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Je(await fe(this,nt,th).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return we(await fe(this,nt,th).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=Ae(t,"position");return we(await fe(this,nt,th).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await An({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Nd.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,ox).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await fe(this,nt,Er).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await An({network:this.getNetwork(),result:fe(this,nt,Er).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:we(t)}async getLogs(e){let t=this._getFilter(e);Rm(t)&&(t=await t);const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){ee(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Sm.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=dt(e);const t=d1(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Sm.getEnsAddress(this),i=await new jc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===wd)return null;const a=await new jc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(ln(r,"BAD_DATA")&&r.value==="0x"||ln(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(Nt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){ee(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,zr).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,zr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Zd(this,qd)._++,s=()=>{T(this,zr).delete(r),e()};if(this.paused)T(this,zr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);T(this,zr).set(r,{timer:i,func:s,time:L1()})}return r}_forEachSubscriber(e){for(const t of T(this,Cn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Dm(e.type);case"block":{const t=new CJ(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new SJ(this,e.type);case"event":return new D1(this,e.filter);case"transaction":return new NJ(this,e.hash);case"orphan":return new TJ(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of T(this,Cn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),T(this,Sn)!=null&&t.pause(T(this,Sn));break}}async on(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async once(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async emit(e,...t){const r=await fe(this,nt,nh).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new XO(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of T(this,Cn).values())t+=r.length;return t}async listeners(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of T(this,Cn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await fe(this,nt,nh).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await fe(this,nt,ry).call(this,e);r&&s.stop(),T(this,Cn).delete(t)}else for(const[t,{started:r,subscriber:s}]of T(this,Cn))r&&s.stop(),T(this,Cn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Su)}destroy(){this.removeAllListeners();for(const e of T(this,zr).keys())this._clearTimeout(e);I(this,Su,!0)}get paused(){return T(this,Sn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(I(this,ji,-1),T(this,Sn)!=null){if(T(this,Sn)==!!e)return;ee(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),I(this,Sn,!!e);for(const t of T(this,zr).values())t.timer&&clearTimeout(t.timer),t.time=L1()-t.time}resume(){if(T(this,Sn)!=null){this._forEachSubscriber(e=>e.resume()),I(this,Sn,null);for(const e of T(this,zr).values()){let t=e.time;t<0&&(t=0),e.time=L1(),setTimeout(e.func,t)}}}}Cn=new WeakMap,Uo=new WeakMap,Sn=new WeakMap,Su=new WeakMap,Ar=new WeakMap,hl=new WeakMap,Ho=new WeakMap,ji=new WeakMap,qd=new WeakMap,zr=new WeakMap,Tu=new WeakMap,Nu=new WeakMap,nt=new WeakSet,Er=async function(e){const t=T(this,Nu).cacheTimeout;if(t<0)return await this._perform(e);const r=Mm(e.method,e);let s=T(this,Ho).get(r);return s||(s=this._perform(e),T(this,Ho).set(r,s),setTimeout(()=>{T(this,Ho).get(r)===s&&T(this,Ho).delete(r)},t)),await s},sx=async function(e,t,r){ee(r<RJ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=Am(e);try{return we(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Rv(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Ft(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Bn(s.to,this);let l;try{l=BJ(Ft(i.data,4))}catch(f){ee(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}ee(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);ee(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Ut([l.selector,_J([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await fe(this,nt,sx).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},ix=async function(e){const{value:t}=await An({network:this.getNetwork(),value:e});return t},th=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await fe(this,nt,ix).call(this,fe(this,nt,Er).call(this,Object.assign(e,{address:s,blockTag:i})))},ox=async function(e,t){if(At(e,32))return await fe(this,nt,Er).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await fe(this,nt,Er).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},nh=async function(e,t){let r=await I1(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await I1({orphan:"drop-log",log:t[0]},this)),T(this,Cn).get(r.tag)||null},ry=async function(e){const t=await I1(e,this),r=t.tag;let s=T(this,Cn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,Cn).set(r,s)),s};function PJ(n,e){try{const t=_1(n,e);if(t)return Cc(t)}catch{}return null}function _1(n,e){if(n==="0x")return null;try{const t=Je(Ft(n,e,e+32)),r=Je(Ft(n,t,t+32));return Ft(n,t+32,t+32+r)}catch{}return null}function _D(n){const e=In(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function IJ(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const LJ=new Uint8Array([]);function _J(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(LJ),t+=32;for(let r=0;r<n.length;r++){const s=lt(n[r]);e[r]=_D(t),e.push(_D(s.length)),e.push(IJ(s)),t+=32+Math.ceil(s.length/32)*32}return Ut(e)}const BD="0x0000000000000000000000000000000000000000000000000000000000000000";function BJ(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ee(Ec(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Ft(n,0,32);ee(Ft(t,0,12)===Ft(BD,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Ft(t,12);try{const r=[],s=Je(Ft(n,32,64)),i=Je(Ft(n,s,s+32)),o=Ft(n,s+32);for(let a=0;a<i;a++){const l=PJ(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{ee(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_1(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{ee(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ee(Ft(n,100,128)===Ft(BD,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Ft(n,96,100);try{const r=_1(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{ee(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Hc(n,e){if(n.provider)return n.provider;ee(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function FD(n,e){let t=Am(e);if(t.to!=null&&(t.to=Bn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Bn(r,n)]).then(([s,i])=>(V(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await An(t)}class FJ{constructor(e){$(this,"provider");Oe(this,{provider:e||null})}async getNonce(e){return Hc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await FD(this,e)}async populateTransaction(e){const t=Hc(this,"populateTransaction"),r=await FD(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=Ae(r.chainId);V(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();ee(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ee(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ee(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await An(r)}async estimateGas(e){return Hc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Hc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Hc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Hc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=Nd.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const jD=new Set;function zc(n){jD.has(n)||(jD.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function jJ(n){return JSON.parse(JSON.stringify(n))}class UD{constructor(e){q(this,Vo);q(this,jn);q(this,Ys);q(this,pl);q(this,zo);q(this,gl);q(this,Ou);I(this,jn,e),I(this,Ys,null),I(this,pl,fe(this,Vo,ax).bind(this)),I(this,zo,!1),I(this,gl,null),I(this,Ou,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,zo)||(I(this,zo,!0),fe(this,Vo,ax).call(this,-2))}stop(){T(this,zo)&&(I(this,zo,!1),I(this,Ou,!0),fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl)))}pause(e){e&&fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl))}resume(){this.start()}}jn=new WeakMap,Ys=new WeakMap,pl=new WeakMap,zo=new WeakMap,gl=new WeakMap,Ou=new WeakMap,Vo=new WeakSet,ax=async function(e){try{T(this,Ys)==null&&I(this,Ys,this._subscribe(T(this,jn)));let t=null;try{t=await T(this,Ys)}catch(i){if(!ln(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){I(this,Ys,null),T(this,jn)._recoverSubscriber(this,this._recover(T(this,jn)));return}const r=await T(this,jn).getNetwork();if(T(this,gl)||I(this,gl,r),T(this,gl).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,Ou))return;const s=await T(this,jn).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,jn),s)}catch(t){console.log("@TODO",t)}T(this,jn).once("block",T(this,pl))},lx=function(){const e=T(this,Ys);e&&(I(this,Ys,null),e.then(t=>{T(this,jn).destroyed||T(this,jn).send("eth_uninstallFilter",[t])}))};class UJ extends UD{constructor(t,r){super(t);q(this,ml);I(this,ml,jJ(r))}_recover(t){return new D1(t,T(this,ml))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,ml)])}async _emitResults(t,r){for(const s of r)t.emit(T(this,ml),t._wrapLog(s,t._network))}}ml=new WeakMap;class HJ extends UD{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const zJ="bigint,boolean,function,number,string,symbol".split(/,/g);function Im(n){if(n==null||zJ.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(Im);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function VJ(n){return new Promise(e=>{setTimeout(e,n)})}function Vc(n){return n&&n.toLowerCase()}function HD(n){return n&&typeof n.pollingInterval=="number"}const zD={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class B1 extends FJ{constructor(t,r){super(t);$(this,"address");r=dt(r),Oe(this,{address:r})}connect(t){ee(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=Im(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Bn(o,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Bn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(ln(u,"CANCELLED")||ln(u,"BAD_DATA")||ln(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(ln(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",Nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=Im(t);if(r.from){const i=await Bn(r.from,this.provider);V(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("personal_sign",[we(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=Im(s),o=await wm.resolveNames(t,r,i,async a=>{const l=await Bn(a);return V(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(wm.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),we(r)])}}class VD extends Pm{constructor(t,r){super(t,r);q(this,Qd);q(this,yl);q(this,Ru);q(this,Ui);q(this,Xs);q(this,ps);q(this,Vr);q(this,tr);I(this,Ru,1),I(this,yl,Object.assign({},zD,r||{})),I(this,Ui,[]),I(this,Xs,null),I(this,Vr,null),I(this,tr,null);{let i=null;const o=new Promise(a=>{i=a});I(this,ps,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(V(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&I(this,Vr,Yt.from(t))):s&&(V(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),I(this,Vr,s))}_getOption(t){return T(this,yl)[t]}get _network(){return ee(T(this,Vr),"network is not available yet","NETWORK_ERROR"),T(this,Vr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&Ae(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,Vr))return T(this,Vr)}else return t;return T(this,tr)?await T(this,tr):this.ready?(I(this,tr,(async()=>{try{const r=Yt.from(Ae(await this.send("eth_chainId",[])));return I(this,tr,null),r}catch(r){throw I(this,tr,null),r}})()),await T(this,tr)):(I(this,tr,(async()=>{const r={id:Zd(this,Ru)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],I(this,tr,null)}catch(i){throw I(this,tr,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return Yt.from(Ae(s.result));throw this.getRpcError(r,s)})()),await T(this,tr))}_start(){T(this,ps)==null||T(this,ps).resolve==null||(T(this,ps).resolve(),I(this,ps,null),(async()=>{for(;T(this,Vr)==null&&!this.destroyed;)try{I(this,Vr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await VJ(1e3)}fe(this,Qd,cx).call(this)})())}async _waitUntilReady(){if(T(this,ps)!=null)return await T(this,ps).promise}_getSubscriber(t){return t.type==="pending"?new HJ(this):t.type==="event"?this._getOption("polling")?new D1(this,t.filter):new UJ(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Dm("orphan"):super._getSubscriber(t)}get ready(){return T(this,ps)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=La(Ae(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=we(t[s]))}),t.accessList&&(r.accessList=Co(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Vc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Vc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Vc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Vc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Vc):t.filter.address=Vc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return Nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=F1(i),c=Bc.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify(WJ(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return Nt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return Nt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return Nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?Nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):Nt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Zd(this,Ru)._++,i=new Promise((o,a)=>{T(this,Ui).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return fe(this,Qd,cx).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new B1(this,i[t])}const{accounts:s}=await An({network:this.getNetwork(),accounts:r});t=dt(t);for(const i of s)if(dt(i)===t)return new B1(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new B1(this,r))}destroy(){T(this,Xs)&&(clearTimeout(T(this,Xs)),I(this,Xs,null));for(const{payload:t,reject:r}of T(this,Ui))r(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));I(this,Ui,[]),super.destroy()}}yl=new WeakMap,Ru=new WeakMap,Ui=new WeakMap,Xs=new WeakMap,ps=new WeakMap,Vr=new WeakMap,tr=new WeakMap,Qd=new WeakSet,cx=function(){if(T(this,Xs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");I(this,Xs,setTimeout(()=>{I(this,Xs,null);const r=T(this,Ui);for(I(this,Ui,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==T(this,yl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>T(this,yl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=Nt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class $J extends VD{constructor(t,r){super(t,r);q(this,$o);let s=this._getOption("pollingInterval");s==null&&(s=zD.pollingInterval),I(this,$o,s)}_getSubscriber(t){const r=super._getSubscriber(t);return HD(r)&&(r.pollingInterval=T(this,$o)),r}get pollingInterval(){return T(this,$o)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");I(this,$o,t),this._forEachSubscriber(r=>{HD(r)&&(r.pollingInterval=T(this,$o))})}}$o=new WeakMap;class Si extends $J{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);q(this,Mu);typeof t=="string"?I(this,Mu,new Ln(t)):I(this,Mu,t.clone())}_getConnection(){return T(this,Mu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}Mu=new WeakMap;function F1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&At(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=F1(n[e]);if(t)return t}return null}if(typeof n=="string")try{return F1(JSON.parse(n))}catch{}return null}function j1(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)j1(n[t],e);if(typeof n=="string")try{return j1(JSON.parse(n),e)}catch{}}}function WJ(n){const e=[];return j1(n,e),e}const Lm="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function GJ(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}V(!1,"unsupported network","network",n)}class _m extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Lm);const i={polling:!0,staticNetwork:s},o=_m.getRequest(s,r);super(o,s,i);$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new _m(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=Lm);const s=new Ln(`https://${GJ(t.name)}/${r}`);return s.allowGzip=!0,r===Lm&&(s.retryFunc=async(i,o,a)=>(zc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===Lm}}const Bm="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function KJ(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}V(!1,"unsupported network","network",n)}class Fm extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Bm);const i=Fm.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Fm(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await An({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return ee(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;ee(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===Bm}static getRequest(t,r){r==null&&(r=Bm);const s=new Ln(`https://${KJ(t.name)}/v2/${r}`);return s.allowGzip=!0,r===Bm&&(s.retryFunc=async(i,o,a)=>(zc("alchemy"),!0)),s}}function jm(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}V(!1,"unsupported network","network",n)}function JJ(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}V(!1,"unsupported network","network",n)}class Um extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=jm(s.name));const i=Um.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Um(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===jm(this._network.name)}static getRequest(t,r){r==null&&(r=jm(t.name));const s=new Ln(`https://${JJ(t.name)}/${r}`);return s.allowGzip=!0,r===jm(t.name)&&(s.retryFunc=async(i,o,a)=>(zc("ChainstackProvider"),!0)),s}}class qJ extends Si{constructor(e){e==null&&(e="mainnet");const t=Yt.from(e);V(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const $D=2e3;function QJ(n){return n&&typeof n.then=="function"}const YJ="org.ethers.plugins.provider.Etherscan",XJ=["enableCcipRead"];let ZJ=1;class eq extends Pm{constructor(t,r){const s=r??null;super();$(this,"network");$(this,"apiKey");q(this,Du);const i=Yt.from(t);I(this,Du,i.getPlugin(YJ)),Oe(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(T(this,Du))return T(this,Du).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}V(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=ZJ++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Ln(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&zc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(Cc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,$D)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,$D)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),ee(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),ee(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(Cc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),ee(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(XJ.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=La(i);else if(s==="accessList")i="["+Co(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;ee(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=we(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(ln(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&ee(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Bc.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=Nd.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&ee(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&ee(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&ee(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});ee(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);QJ(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new jc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Du=new WeakMap;function tq(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const nq=tq().WebSocket;class U1{constructor(e,t){q(this,Zs);q(this,Yd);q(this,Wo);q(this,bl);q(this,Go);I(this,Zs,e),I(this,Yd,JSON.stringify(t)),I(this,Wo,null),I(this,bl,null),I(this,Go,null)}get filter(){return JSON.parse(T(this,Yd))}start(){I(this,Wo,T(this,Zs).send("eth_subscribe",this.filter).then(e=>(T(this,Zs)._register(e,this),e)))}stop(){T(this,Wo).then(e=>{T(this,Zs).destroyed||T(this,Zs).send("eth_unsubscribe",[e])}),I(this,Wo,null)}pause(e){ee(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),I(this,bl,!!e)}resume(){I(this,bl,null)}_handleMessage(e){if(T(this,Wo)!=null&&T(this,bl)===null){let t=T(this,Go);t==null?t=this._emit(T(this,Zs),e):t=t.then(async()=>{await this._emit(T(this,Zs),e)}),I(this,Go,t.then(()=>{T(this,Go)===t&&I(this,Go,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Zs=new WeakMap,Yd=new WeakMap,Wo=new WeakMap,bl=new WeakMap,Go=new WeakMap;class rq extends U1{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class sq extends U1{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class iq extends U1{constructor(t,r){super(t,["logs",r]);q(this,Xd);I(this,Xd,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Xd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Xd=new WeakMap;class oq extends VD{constructor(t,r){const s=Object.assign({},r??{});V(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);q(this,wl);q(this,Pu);q(this,Ko);I(this,wl,new Map),I(this,Pu,new Map),I(this,Ko,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Dm("close");case"block":return new rq(this);case"pending":return new sq(this);case"event":return new iq(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Dm("drop-log")}return super._getSubscriber(t)}_register(t,r){T(this,Pu).set(t,r);const s=T(this,Ko).get(t);if(s){for(const i of s)r._handleMessage(i);T(this,Ko).delete(t)}}async _send(t){V(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{T(this,wl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=T(this,wl).get(r.id);if(s==null){this.emit("error",Nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,wl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=T(this,Pu).get(s);if(i)i._handleMessage(r.params.result);else{let o=T(this,Ko).get(s);o==null&&(o=[],T(this,Ko).set(s,o)),o.push(r.params.result)}}else{this.emit("error",Nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}wl=new WeakMap,Pu=new WeakMap,Ko=new WeakMap;class WD extends oq{constructor(t,r,s){super(r,s);q(this,vl);q(this,gs);typeof t=="string"?(I(this,vl,()=>new nq(t)),I(this,gs,T(this,vl).call(this))):typeof t=="function"?(I(this,vl,t),I(this,gs,t())):(I(this,vl,null),I(this,gs,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(T(this,gs)==null)throw new Error("websocket closed");return T(this,gs)}async _write(t){this.websocket.send(t)}async destroy(){T(this,gs)!=null&&(T(this,gs).close(),I(this,gs,null)),super.destroy()}}vl=new WeakMap,gs=new WeakMap;const Ld="84842078b09946638c03157f83405213";function aq(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}V(!1,"unsupported network","network",n)}class lq extends WD{constructor(t,r){const s=new _d(t,r),i=s._getConnection();ee(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ld}}class _d extends Si{constructor(t,r,s){t==null&&(t="mainnet");const i=Yt.from(t);r==null&&(r=Ld),s==null&&(s=null);const o=_d.getRequest(i,r,s);super(o,i,{staticNetwork:i});$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new _d(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ld}static getWebSocketProvider(t,r){return new lq(t,r)}static getRequest(t,r,s){r==null&&(r=Ld),s==null&&(s=null);const i=new Ln(`https://${aq(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===Ld&&(i.retryFunc=async(o,a,l)=>(zc("InfuraProvider"),!0)),i}}const Hm="919b412a057b5e9c9b6dce193c5a60242d6efadb";function cq(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}V(!1,"unsupported network","network",n)}class zm extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Hm);const i=zm.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"token");Oe(this,{token:r})}_getProvider(t){try{return new zm(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===Hm}static getRequest(t,r){r==null&&(r=Hm);const s=new Ln(`https://${cq(t.name)}/${r}`);return s.allowGzip=!0,r===Hm&&(s.retryFunc=async(i,o,a)=>(zc("QuickNodeProvider"),!0)),s}}const uq=BigInt("1"),fq=BigInt("2");function dq(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function hq(n){return new Promise(e=>{setTimeout(e,n)})}function H1(){return new Date().getTime()}function z1(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const GD={stallTimeout:400,priority:1,weight:1},KD={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function pq(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=H1()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function Bd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(Bd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return Bd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${Bd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function V1(n){if("error"in n){const t=n.error;return{tag:Bd(t),value:t}}const e=n.result;return{tag:Bd(e),value:e}}function Vm(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function $1(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+uq)/fq}function W1(n,e){const t=Vm(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function gq(n,e){if(n===1)return Je($1(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Je(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class mq extends Pm{constructor(t,r,s){super(r,s);q(this,rr);$(this,"quorum");$(this,"eventQuorum");$(this,"eventWorkers");q(this,nr);q(this,Hi);q(this,Iu);I(this,nr,t.map(i=>i instanceof Pm?Object.assign({provider:i},GD,KD):Object.assign({},GD,i,KD))),I(this,Hi,-2),I(this,Iu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(T(this,nr).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,V(this.quorum<=T(this,nr).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return T(this,nr).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return Yt.from(Ae(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=T(this,nr).map(c=>null),a=T(this,nr).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign(V1({result:d}),{weight:u})}catch(d){o[f]=Object.assign(V1({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=Vm(this.quorum,o.filter(d=>d!=null));if(ln(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=W1(this.quorum,o);if(ee(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(z1)}}),l instanceof Error)throw l;return l}await fe(this,rr,iP).call(this);const r=new Set;let s=0;for(;;){const o=fe(this,rr,ux).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await fe(this,rr,fx).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of T(this,nr))t.destroy();super.destroy()}}nr=new WeakMap,Hi=new WeakMap,Iu=new WeakMap,rr=new WeakSet,sP=function(t){const r=Array.from(t).map(i=>i.config),s=T(this,nr).slice();dq(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},ux=function(t,r){const s=fe(this,rr,sP).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=H1();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=H1()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await hq(s.stallTimeout),i.staller=null})(),t.add(i),i},iP=async function(){let t=T(this,Iu);if(!t){const r=[];T(this,nr).forEach(s=>{r.push((async()=>{await pq(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),I(this,Iu,t=(async()=>{await Promise.all(r);let s=null;for(const i of T(this,nr)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&ee(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},oP=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=V1(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{T(this,Hi)===-2&&I(this,Hi,Math.ceil(Je($1(this.quorum,T(this,nr).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Je(o.blockNumber).toString(),weight:o.weight}))))));const i=gq(this.quorum,s);return i===void 0?void 0:(i>T(this,Hi)&&I(this,Hi,i),T(this,Hi))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return $1(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?W1(this.quorum,s):Vm(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return Vm(this.quorum,s);case"broadcastTransaction":return W1(this.quorum,s)}ee(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${z1(r.method)})`})}},fx=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await fe(this,rr,oP).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)fe(this,rr,ux).call(this,t,r);return ee(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>z1(a.result))}}),await Promise.race(s),await fe(this,rr,fx).call(this,t,r)};function yq(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const bq="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function wq(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new Si(n);if(typeof n=="string"&&n.match(/^wss?:/)||yq(n))return new WD(n);let r=null;try{r=Yt.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new Si("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new Si("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new Fm(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new _m(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new Um(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new qJ(n))}catch{}if(t("etherscan"))try{s.push(new eq(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new _d(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new zm(n,o))}catch{}if(ee(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&bq.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new mq(s,void 0,{quorum:i})}const vq=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!mG(n))return t;try{const r=await xq(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},xq=async(n,e)=>await Aq(e).lookupAddress(n),Aq=n=>wq(n),JD=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],Eq=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o})=>{const[a]=L.useState(new xa),[l,c]=L.useState(!1),[u,f]=L.useState([...EW]),d=Ok({extensions:u,editorProps:j2,autofocus:"start"},[u]),h=Ok({extensions:u,editorProps:j2,autofocus:"start"}),p=L.useRef(()=>{}),g=(E,k=!1)=>{if(!t||!r||!E)throw new Error("docId or username is not provided");c(!0);const S=new l6(r,a,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});f([...u,I6.configure({document:a}),L6.configure({provider:S,user:{name:E,color:JD[Math.floor(Math.random()*JD.length)],isEns:k},render:NW})]);const M=setTimeout(()=>{c(!1)},100);return p.current=()=>{clearTimeout(M),S.destroy(),a.destroy(),c(!1)},p.current},b=L.useRef(null),y=L.useMemo(()=>t&&r&&d&&!l?d:h,[d,h,l]),A=E=>{var k;(k=b.current)!=null&&k.contains(E.target)||y==null||y.chain().focus().run()};L.useEffect(()=>{y==null||y.chain().focus()},[]),L.useEffect(()=>{y==null||y.setEditable(!n)},[n,y]),L.useEffect(()=>{e&&y&&setTimeout(()=>{y==null||y.commands.setContent(e.editorJSONData)})},[e,y]);const v=async()=>{if(!i)return;let E=i,k=!1;if(s){const{name:S,isEns:M}=await vq(i,s);E=S,k=M}g(E,k)};L.useEffect(()=>{t&&i?v():p.current()},[t]);const w=L.useMemo(()=>iv((E,k)=>{k({editorJSONData:E.getJSON()})},1e3),[o]);return L.useEffect(()=>{if(y&&o){const E=()=>{w(y,o)};return y.on("update",E),()=>{y.off("update",E)}}},[y,o,w]),{editor:y,focusEditor:A,ref:b,loading:l,connect:g}},kq=({title:n,content:e,contentClassName:t,open:r,onOpenChange:s,primaryAction:i,secondaryAction:o})=>C.jsx(uU,{open:r,onOpenChange:s,children:C.jsxs(fS,{className:"max-w-md sm:w-full w-[90%] z-20",children:[C.jsx(dS,{className:"px-4 pt-0 border-b-[1px]",children:C.jsx(pS,{className:"text-left text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e}),C.jsxs(hS,{className:"px-5 pb-5 justify-end sm:",children:[o&&C.jsx(hU,{asChild:!0,children:C.jsx(Pf,{disabled:o==null?void 0:o.isLoading,isLoading:o==null?void 0:o.isLoading,className:o==null?void 0:o.className,variant:(o==null?void 0:o.variant)||"ghost",onClick:o==null?void 0:o.onClick,children:o==null?void 0:o.label})}),i&&C.jsx(Pf,{disabled:i==null?void 0:i.isLoading,isLoading:i==null?void 0:i.isLoading,className:i==null?void 0:i.className,variant:(i==null?void 0:i.variant)||"primary",onClick:i==null?void 0:i.onClick,children:i==null?void 0:i.label})]})]})}),Cq=({editor:n})=>{const{toolVisibilty:e,setToolVisibility:t,bottomToolbar:r}=Sb({editor:n}),[s,i]=L.useState(""),[o,a]=L.useState(""),[l,c]=L.useState(!0),u=()=>{if(s===null){c(!1);return}if(s===""){n.chain().focus().extendMarkRange("link").unsetLink().run(),c(!1);return}let d=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(d="https://"+s);try{d.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0)}catch{console.error("Invalid URL"),c(!1);return}n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0),t(Re.NONE)},f=d=>{const{from:h,to:p}=d.state.selection;return d.state.doc.textBetween(h,p)};return C.jsxs(sS,{children:[C.jsx("div",{className:"flex w-full justify-between sm:justify-evenly",children:r.map(d=>{if(d)return C.jsx("div",{className:"flex items-center",children:d.title==="Text formating"||d.title==="Text color"?C.jsx(aU,{asChild:!0,children:C.jsx("button",{onClick:()=>d.onClick(),children:d.icon})}):C.jsx("button",{className:pe("flex items-center rounded px-2 py-1 text-black transition"),onClick:()=>d.onClick(),children:d.icon})},d.title)})}),e===Re.TEXT_FORMATING&&C.jsx(e8,{editor:n,setToolVisibility:t}),e===Re.TEXT_COLOR_PICKER&&C.jsx(t8,{editor:n,setToolVisibility:t}),e===Re.LINK_POPUP&&C.jsx(kq,{open:e===Re.LINK_POPUP,onOpenChange:()=>t(Re.NONE),title:"Link",content:C.jsxs("div",{className:"flex flex-col gap-4 w-full h-full px-4",children:[C.jsx(dp,{label:"Text",placeholder:"Link text",className:"w-full",defaultValue:f(n),onChange:d=>a(d.target.value)}),C.jsx(dp,{label:"Link",placeholder:"Paste URL",className:"w-full",defaultValue:n.getAttributes("link").href,onChange:d=>{i(d.target.value)},isValid:l,message:l?"":"Invalid URL"})]}),primaryAction:{label:"Save",onClick:()=>u(),isLoading:!1,className:"w-auto min-w-[80px]"},secondaryAction:{label:"Cancel",variant:"secondary",onClick:()=>t(Re.NONE),className:"w-auto min-w-[80px]"}})]})},Sq=({isPreviewMode:n=!1,data:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,renderToolLeftSection:a,ensProviderUrl:l})=>{const{editor:c,focusEditor:u,ref:f,loading:d}=Eq({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:l,username:s,onAutoSave:i});return!c||d?C.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[C.jsx(HS,{}),C.jsx("p",{children:"Loading Editor..."})]}):C.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:C.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:C.jsxs("div",{className:"w-full h-full",children:[C.jsx("div",{className:"flex items-center w-full h-16 fixed z-10 px-4 bg-[#f8f9fa]",children:C.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[C.jsx("div",{className:"grow",children:a==null?void 0:a({editor:c})}),!n&&C.jsx("div",{className:"grow relative hidden xl:block",children:C.jsx(f8,{editor:c})}),o==null?void 0:o({editor:c})]})}),C.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:C.jsx("div",{onClick:u,className:"mt-8 lg:mt-[5rem] w-full flex justify-center relative",children:C.jsx("div",{className:"px-4 pt-12 sm:p-[88px] h-screen bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:C.jsxs("div",{ref:f,className:"w-full h-full",children:[!n&&C.jsxs("div",{children:[C.jsx(n8,{editor:c}),C.jsx(c8,{editor:c,appendTo:f})]}),C.jsx(u8,{isPreviewMode:n,children:C.jsx(j3,{editor:c})})]})})})}),C.jsx("div",{className:"flex xl:hidden items-center w-full h-16 fixed bottom-0 z-10 px-4 bg-[#f8f9fa]",children:C.jsx(Cq,{editor:c})})]})})})};st.DdocEditor=Sq,Object.defineProperty(st,Symbol.toStringTag,{value:"Module"})});
|
437
|
+
3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function Xz(){Dt.scanner=Vz(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=Kz(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});Dt.initialized=!0}function EN(n){return Dt.initialized||Xz(),Jz(Dt.parser.start,n,$z(Dt.scanner.start,n))}function kN(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new nv(t),s=EN(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}function Zz(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function eV(n){return new bt({key:new Ot("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=xB(t.doc,[...e]);if(OB(a).forEach(({newRange:c})=>{const u=EB(r.doc,c,h=>h.isTextblock);let f,d;if(u.length>1?(f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")),f&&d){const h=d.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],g=f.pos+d.lastIndexOf(p);if(!p)return!1;const b=EN(p).map(y=>y.toObject());if(!Zz(b))return!1;b.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate?n.validate(y.value):!0).forEach(y=>{c0(y.from,y.to,r.doc).some(A=>A.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function tV(n){return new bt({key:new Ot("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(d=>d.nodeName==="A"))return!1;const l=BE(e.state,n.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,f=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,f),!0):!1}}})}function nV(n){return new bt({key:new Ot("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=kN(a).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(n.editor.commands.setMark(n.type,{href:l.href}),!0)}}})}const rV=$n.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){AN(n);return}AN(n.scheme,n.optionalSlashes)})},onDestroy(){Yz()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",tt(this.options.HTMLAttributes,{...n,href:""}),0]:["a",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[to({find:n=>{const e=[];if(n){const t=kN(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(eV({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(tV({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(nV({editor:this.editor,type:this.type})),n}}),sV=St.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new bt({key:new Ot("placeholder"),props:{decorations:({doc:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=e,i=[];if(!r)return null;const{firstChild:o}=n.content,a=o&&o.type.isLeaf,l=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!a||!l);return n.descendants((f,d)=>{const h=s>=d&&s<=d+f.nodeSize,p=!f.isLeaf&&!f.childCount;if((h||!this.options.showOnlyCurrent)&&p){const g=[this.options.emptyNodeClass];u&&g.push(this.options.emptyEditorClass);const b=Qt.node(d,d+f.nodeSize,{class:g.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:f,pos:d,hasAnchor:h}):this.options.placeholder});i.push(b)}return this.options.includeChildren}),wt.create(n,i)}}})]}}),iV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,oV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aV=$n.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[aa({find:iV,type:this.type})]},addPasteRules(){return[to({find:oV,type:this.type})]}}),lV=vt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",tt(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),cV=/^\s*(\[([( |x])?\])\s$/,uV=vt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",tt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return i.contentEditable="false",a.type="checkbox",a.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=c.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const d=t(),h=f.doc.nodeAt(d);return f.setNodeMarkup(d,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{s.setAttribute(c,u)}),s.dataset.checked=n.attrs.checked,n.attrs.checked&&a.setAttribute("checked","checked"),i.append(a,o),s.append(i,l),Object.entries(e).forEach(([c,u])=>{s.setAttribute(c,u)}),{dom:s,contentDOM:l,update:c=>c.type!==this.type?!1:(s.dataset.checked=c.attrs.checked,c.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[Fl({find:cV,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),fV=$n.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dV(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:o}=n,a=ZB(t),l=new RegExp(`\\s${a}$`),c=i?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),f=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!f)return null;const d=o.pos-f.length,h=Array.from(f.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),g=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(p);if(s!==null&&!g)return null;const b=d+h.index;let y=b+h[0].length;return r&&l.test(f.slice(y-1,y+1))&&(h[0]+=" ",y+=1),b<o.pos&&y>=o.pos?{range:{from:b,to:y},query:h[0].slice(t.length),text:h[0]}:null}const hV=new Ot("suggestion");function pV({pluginKey:n=hV,editor:e,char:t="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:f=()=>!0,findSuggestionMatch:d=dV}){let h;const p=u==null?void 0:u(),g=new bt({key:n,view(){return{update:async(b,y)=>{var A,v,w,E,k,S,M;const O=(A=this.key)===null||A===void 0?void 0:A.getState(y),R=(v=this.key)===null||v===void 0?void 0:v.getState(b.state),D=O.active&&R.active&&O.range.from!==R.range.from,F=!O.active&&R.active,U=O.active&&!R.active,K=!F&&!U&&O.query!==R.query,_=F||D,G=K&&!D,Y=U||D;if(!_&&!G&&!Y)return;const re=Y&&!_?O:R,Z=b.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`);h={editor:e,range:re.range,query:re.query,text:re.text,items:[],command:ge=>l({editor:e,range:re.range,props:ge}),decorationNode:Z,clientRect:Z?()=>{var ge;const{decorationId:ke}=(ge=this.key)===null||ge===void 0?void 0:ge.getState(e.state),Pe=b.dom.querySelector(`[data-decoration-id="${ke}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},_&&((w=p==null?void 0:p.onBeforeStart)===null||w===void 0||w.call(p,h)),G&&((E=p==null?void 0:p.onBeforeUpdate)===null||E===void 0||E.call(p,h)),(G||_)&&(h.items=await c({editor:e,query:re.query})),Y&&((k=p==null?void 0:p.onExit)===null||k===void 0||k.call(p,h)),G&&((S=p==null?void 0:p.onUpdate)===null||S===void 0||S.call(p,h)),_&&((M=p==null?void 0:p.onStart)===null||M===void 0||M.call(p,h))},destroy:()=>{var b;h&&((b=p==null?void 0:p.onExit)===null||b===void 0||b.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(b,y,A,v){const{isEditable:w}=e,{composing:E}=e.view,{selection:k}=b,{empty:S,from:M}=k,O={...y};if(O.composing=E,w&&(S||e.view.composing)){(M<y.range.from||M>y.range.to)&&!E&&!y.composing&&(O.active=!1);const R=d({char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:k.$from}),D=`id_${Math.floor(Math.random()*4294967295)}`;R&&f({editor:e,state:v,range:R.range})?(O.active=!0,O.decorationId=y.decorationId?y.decorationId:D,O.range=R.range,O.query=R.query,O.text=R.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(b,y){var A;const{active:v,range:w}=g.getState(b.state);return v&&((A=p==null?void 0:p.onKeyDown)===null||A===void 0?void 0:A.call(p,{view:b,event:y,range:w}))||!1},decorations(b){const{active:y,range:A,decorationId:v}=g.getState(b);return y?wt.create(b.doc,[Qt.inline(A.from,A.to,{nodeName:o,class:a,"data-decoration-id":v})]):null}}});return g}const gV=St.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[pV({editor:this.editor,...this.options.suggestion})]}}),mV=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:C.jsx($k,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:C.jsx(zk,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:C.jsx(Vh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:C.jsx($h,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:C.jsx(Wh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:C.jsx(Gh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:C.jsx(Wl,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:C.jsx(n4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:C.jsx(Kh,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:C.jsx(Af,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:C.jsx(Vk,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:C.jsx(e4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var s;if((s=r.files)!=null&&s.length){const i=r.files[0],o=e.view.state.selection.from;z0(i,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:C.jsx(Kk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:C.jsx(Gk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:C.jsx(jk,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:C.jsx(Q3,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),yV=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,s=e.offsetTop,i=s+r;s<n.scrollTop?n.scrollTop-=n.scrollTop-s+5:i>t+n.scrollTop&&(n.scrollTop+=i-t-n.scrollTop+5)},bV=({items:n,command:e,editor:t})=>{const[r,s]=L.useState(0),i=L.useCallback(a=>{const l=n[a];l&&(l.title==="Continue writing"||e(l))},[e,t,n]);L.useEffect(()=>{const a=["ArrowUp","ArrowDown","Enter"],l=c=>{if(a.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(s((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(s((r+1)%n.length),!0):c.key==="Enter"?(i(r),!0):!1};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[n,r,s,i]),L.useEffect(()=>{s(0)},[n]);const o=L.useRef(null);return L.useLayoutEffect(()=>{const a=o==null?void 0:o.current,l=a==null?void 0:a.children[r];l&&a&&yV(a,l)},[r]),n.length>0?C.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:n.map((a,l)=>C.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${l===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>i(l),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:a.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:a.title}),C.jsx("p",{className:"text-xs text-neutral-500",children:a.description})]})]},l))}):null},wV=()=>{let n=null,e=null;return{onStart:t=>{n=new Lk(bV,{props:t,editor:t.editor}),e=fa("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},vV=gV.configure({suggestion:{items:mV,render:wV}}),xV=oN.extend({renderHTML(){return["div",tt(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),AV=St.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(RS),this.options.columns!==!1&&n.push(gp),n}}),EV=St.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,s=r.selection.$from.start(),i=r.selection.$to.end();return e.setTextSelection({from:s,to:i})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,s=t.selection.to,i=t.selection.$from.start(),o=t.selection.$to.end();return r>i||s<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),kV=St.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CN=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:n=>n()}];let hc;const SN=({node:n,updateAttributes:e,deleteNode:t})=>{const r=mp(),[s,i]=L.useState(),[o,a]=L.useState(0),[l,c]=L.useState(0),[u,f]=L.useState({}),d=L.useRef(null),[h,p]=L.useState(!1),g=()=>{const U={};CN.forEach(({tooltip:K,isActive:_})=>{U[K]=!!(_!=null&&_(n.attrs))}),f(U)},b=()=>{const U=document.querySelector(".ProseMirror");if(U&&c(U==null?void 0:U.clientWidth),!!d.current){if(s==="video"){const K=d.current;K.addEventListener("loadeddata",function(){a(K.videoWidth/K.videoHeight),k("left",0)})}else if(s==="iframe"){const K=d.current;K.onload=()=>{a(K.offsetWidth/K.offsetHeight),k("left",0)}}else d.current.onload=()=>{a(d.current.naturalWidth/d.current.naturalHeight)};setTimeout(()=>g(),200)}},y=U=>{hc=U};L.useEffect(()=>{b()},[]);const A=({width:U,height:K})=>U<200||K<200,v=U=>{setTimeout(()=>S(U))},w=U=>{hc=U.clientX,setTimeout(()=>{document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),p(!0)},E=()=>{hc=-1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E),p(!1)},k=(U,K)=>{var Y,re;if(!d.current){console.error("Media ref is undefined|null",{resizableImg:d.current});return}const _={width:(Y=d.current)==null?void 0:Y.width,height:(re=d.current)==null?void 0:re.height},G={width:-1,height:-1};U==="left"?G.width=_.width-Math.abs(K):(typeof _.width=="string"&&(_.width=Number(_.width)),G.width=_.width+Math.abs(K)),G.width>l&&(G.width=l),s==="iframe"?G.height=G.width/(16/9):G.height=G.width/o,!A(G)&&e(G)},S=U=>{if(hc===-1)return;const{clientX:K}=U,_=hc-K;if(_===0)return;const G=_>0?"left":"right";setTimeout(()=>{k(G,Math.abs(_)),hc=K})},[M,O]=L.useState(),[R,D]=L.useState();L.useEffect(()=>{i(n.attrs["media-type"]),g(),O(n.attrs.dataFloat),D(n.attrs.dataAlign)},[n.attrs]);const F=U=>{switch(U){case"AlignLeft":return C.jsx(vf,{size:16});case"AlignCenter":return C.jsx(D0,{size:16});case"AlignRight":return C.jsx(P0,{size:16});case"Trash2":return C.jsx(Wk,{size:16});default:return null}};return C.jsx(wf,{as:"article",className:pe("media-node-view not-prose transition-all ease-in-out w-full",M&&`f-${n.attrs.dataFloat}`,R&&`justify-${n.attrs.dataAlign}`),children:C.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[s==="img"&&C.jsx("img",{src:n.attrs.src,ref:d,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),s==="video"&&C.jsx("video",{ref:d,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:C.jsx("source",{src:n.attrs.src})}),s==="iframe"&&C.jsx("iframe",{ref:d,className:pe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:U})=>y(U),onMouseDown:w,onMouseUp:E}),C.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200 flex",children:CN.map(U=>C.jsx("div",{className:"tooltip","data-tip":U.tooltip,children:C.jsx("button",{type:"button",className:pe("btn rounded-none h-8 px-2 py-1 transition",u[U.tooltip]&&"active"),onClick:()=>{var K;return U.tooltip==="Delete"?t():(K=U.action)==null?void 0:K.call(U,e)},children:U.icon&&F(U.icon)})}))})]})]})})},CV=vt.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return da(SN)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",tt(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,s=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,s),!0}}}});var SV="https://platform.twitter.com/widgets.js",sv="createTweet",TV=function(e){var t=L.useRef(null),r=L.useState(!0),s=r[0],i=r[1];return L.useEffect(function(){var o=!0,a=require("scriptjs");return a(SV,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[sv]){console.error("Method "+sv+" is not present anymore in twttr.widget api");return}window.twttr.widgets[sv](e.tweetId,t==null?void 0:t.current,e.options).then(function(l){i(!1),e.onLoad&&e.onLoad(l)})}}),function(){o=!1}},[]),L.createElement(L.Fragment,null,s&&L.createElement(L.Fragment,null,e.placeholder),L.createElement("div",{ref:t}))};const NV=({node:n,editor:e})=>{const[t,r]=L.useState(!0);return L.useEffect(()=>{e==null||e.chain().focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:C.jsxs("div",{className:"w-full max-w-sm",children:[t&&C.jsx(HS,{width:5,height:5}),C.jsx(TV,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},OV=vt.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(this.options.HTMLAttributes,n)]},addNodeView(){return da(NV)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),RV=n=>new bt({key:new Ot("media-paste-drop"),props:{handlePaste(e,t){var s;return Array.from(((s=t.clipboardData)==null?void 0:s.items)||[]).forEach(i=>{const o=i.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var a;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const s=Array.from(((a=t.dataTransfer)==null?void 0:a.files)??[]).filter(({type:l})=>/image|video/i.test(l));if(s.length===0)return!1;t.preventDefault();const{schema:i}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(s.forEach(async l=>{const c=new FileReader;if(n){const u=i.nodes.resizableMedia.create({src:await n(l),"media-type":l.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,u);e.dispatch(f)}else c.onload=u=>{var h;const f=i.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":l.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,f);e.dispatch(d)},c.readAsDataURL(l)}),!0):!1}}}),MV=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,DV=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,PV=vt.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",tt(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",tt(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return da(SN)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[h0({find:MV,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),h0({find:DV,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[RV(this.options.uploadFn),d4()]}});function iv(n,e){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>n(...s),e)}}const IV=["top","right","bottom","left"],Bs=Math.min,mr=Math.max,Lg=Math.round,_g=Math.floor,go=n=>({x:n,y:n}),LV={left:"right",right:"left",bottom:"top",top:"bottom"},_V={start:"end",end:"start"};function ov(n,e,t){return mr(n,Bs(e,t))}function gi(n,e){return typeof n=="function"?n(e):n}function mi(n){return n.split("-")[0]}function pc(n){return n.split("-")[1]}function av(n){return n==="x"?"y":"x"}function lv(n){return n==="y"?"height":"width"}function gc(n){return["top","bottom"].includes(mi(n))?"y":"x"}function cv(n){return av(gc(n))}function BV(n,e,t){t===void 0&&(t=!1);const r=pc(n),s=cv(n),i=lv(s);let o=s==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Bg(o)),[o,Bg(o)]}function FV(n){const e=Bg(n);return[uv(n),e,uv(e)]}function uv(n){return n.replace(/start|end/g,e=>_V[e])}function jV(n,e,t){const r=["left","right"],s=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?s:r:e?r:s;case"left":case"right":return e?i:o;default:return[]}}function UV(n,e,t,r){const s=pc(n);let i=jV(mi(n),t==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(uv)))),i}function Bg(n){return n.replace(/left|right|bottom|top/g,e=>LV[e])}function HV(n){return{top:0,right:0,bottom:0,left:0,...n}}function TN(n){return typeof n!="number"?HV(n):{top:n,right:n,bottom:n,left:n}}function Fg(n){const{x:e,y:t,width:r,height:s}=n;return{width:r,height:s,top:t,left:e,right:e+r,bottom:t+s,x:e,y:t}}function NN(n,e,t){let{reference:r,floating:s}=n;const i=gc(e),o=cv(e),a=lv(o),l=mi(e),c=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(pc(e)){case"start":h[o]-=d*(t&&c?-1:1);break;case"end":h[o]+=d*(t&&c?-1:1);break}return h}const zV=async(n,e,t)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:u,y:f}=NN(c,r,l),d=r,h={},p=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x:A,y:v,data:w,reset:E}=await y({x:u,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=A??u,f=v??f,h={...h,[b]:{...h[b],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:s}):E.rects),{x:u,y:f}=NN(c,d,l)),g=-1)}return{x:u,y:f,placement:d,strategy:s,middlewareData:h}};async function ld(n,e){var t;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=gi(e,n),p=TN(h),b=a[d?f==="floating"?"reference":"floating":f],y=Fg(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(b)))==null||t?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),A=f==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),w=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},E=Fg(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:A,offsetParent:v,strategy:l}):A);return{top:(y.top-E.top+p.top)/w.y,bottom:(E.bottom-y.bottom+p.bottom)/w.y,left:(y.left-E.left+p.left)/w.x,right:(E.right-y.right+p.right)/w.x}}const VV=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=gi(n,e)||{};if(c==null)return{};const f=TN(u),d={x:t,y:r},h=cv(s),p=lv(h),g=await o.getDimensions(c),b=h==="y",y=b?"top":"left",A=b?"bottom":"right",v=b?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[h]-d[h]-i.floating[p],E=d[h]-i.reference[h],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=k?k[v]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=a.floating[v]||i.floating[p]);const M=w/2-E/2,O=S/2-g[p]/2-1,R=Bs(f[y],O),D=Bs(f[A],O),F=R,U=S-g[p]-D,K=S/2-g[p]/2+M,_=ov(F,K,U),G=!l.arrow&&pc(s)!=null&&K!==_&&i.reference[p]/2-(K<F?R:D)-g[p]/2<0,Y=G?K<F?K-F:K-U:0;return{[h]:d[h]+Y,data:{[h]:_,centerOffset:K-_-Y,...G&&{alignmentOffset:Y}},reset:G}}}),$V=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...b}=gi(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const y=mi(s),A=mi(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=d||(A||!g?[Bg(a)]:FV(a));!d&&p!=="none"&&w.push(...UV(a,g,p,v));const E=[a,...w],k=await ld(e,b),S=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&S.push(k[y]),f){const F=BV(s,o,v);S.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:s,overflows:S}],!S.every(F=>F<=0)){var O,R;const F=(((O=i.flip)==null?void 0:O.index)||0)+1,U=E[F];if(U)return{data:{index:F,overflows:M},reset:{placement:U}};let K=(R=M.filter(_=>_.overflows[0]<=0).sort((_,G)=>_.overflows[1]-G.overflows[1])[0])==null?void 0:R.placement;if(!K)switch(h){case"bestFit":{var D;const _=(D=M.map(G=>[G.placement,G.overflows.filter(Y=>Y>0).reduce((Y,re)=>Y+re,0)]).sort((G,Y)=>G[1]-Y[1])[0])==null?void 0:D[0];_&&(K=_);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function ON(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function RN(n){return IV.some(e=>n[e]>=0)}const WV=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...s}=gi(n,e);switch(r){case"referenceHidden":{const i=await ld(e,{...s,elementContext:"reference"}),o=ON(i,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:RN(o)}}}case"escaped":{const i=await ld(e,{...s,altBoundary:!0}),o=ON(i,t.floating);return{data:{escapedOffsets:o,escaped:RN(o)}}}default:return{}}}}};async function GV(n,e){const{placement:t,platform:r,elements:s}=n,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=mi(t),a=pc(t),l=gc(t)==="y",c=["left","top"].includes(o)?-1:1,u=i&&l?-1:1,f=gi(e,n);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:d*c}:{x:d*c,y:h*u}}const KV=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await GV(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},JV=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:b=>{let{x:y,y:A}=b;return{x:y,y:A}}},...l}=gi(n,e),c={x:t,y:r},u=await ld(e,l),f=gc(mi(s)),d=av(f);let h=c[d],p=c[f];if(i){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",A=h+u[b],v=h-u[y];h=ov(A,h,v)}if(o){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",A=p+u[b],v=p-u[y];p=ov(A,p,v)}const g=a.fn({...e,[d]:h,[f]:p});return{...g,data:{x:g.x-t,y:g.y-r}}}}},qV=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=gi(n,e),u={x:t,y:r},f=gc(s),d=av(f);let h=u[d],p=u[f];const g=gi(a,e),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=d==="y"?"height":"width",w=i.reference[d]-i.floating[v]+b.mainAxis,E=i.reference[d]+i.reference[v]-b.mainAxis;h<w?h=w:h>E&&(h=E)}if(c){var y,A;const v=d==="y"?"width":"height",w=["top","left"].includes(mi(s)),E=i.reference[f]-i.floating[v]+(w&&((y=o.offset)==null?void 0:y[f])||0)+(w?0:b.crossAxis),k=i.reference[f]+i.reference[v]+(w?0:((A=o.offset)==null?void 0:A[f])||0)-(w?b.crossAxis:0);p<E?p=E:p>k&&(p=k)}return{[d]:h,[f]:p}}}},QV=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...a}=gi(n,e),l=await ld(e,a),c=mi(t),u=pc(t),f=gc(t)==="y",{width:d,height:h}=r.floating;let p,g;c==="top"||c==="bottom"?(p=c,g=u===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(g=c,p=u==="end"?"top":"bottom");const b=h-l.top-l.bottom,y=d-l.left-l.right,A=Bs(h-l[p],b),v=Bs(d-l[g],y),w=!e.middlewareData.shift;let E=A,k=v;if(f?k=u||w?Bs(v,y):y:E=u||w?Bs(A,b):b,w&&!u){const M=mr(l.left,0),O=mr(l.right,0),R=mr(l.top,0),D=mr(l.bottom,0);f?k=d-2*(M!==0||O!==0?M+O:mr(l.left,l.right)):E=h-2*(R!==0||D!==0?R+D:mr(l.top,l.bottom))}await o({...e,availableWidth:k,availableHeight:E});const S=await s.getDimensions(i.floating);return d!==S.width||h!==S.height?{reset:{rects:!0}}:{}}}};function mc(n){return MN(n)?(n.nodeName||"").toLowerCase():"#document"}function yr(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yi(n){var e;return(e=(MN(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function MN(n){return n instanceof Node||n instanceof yr(n).Node}function Fs(n){return n instanceof Element||n instanceof yr(n).Element}function js(n){return n instanceof HTMLElement||n instanceof yr(n).HTMLElement}function DN(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof yr(n).ShadowRoot}function cd(n){const{overflow:e,overflowX:t,overflowY:r,display:s}=ns(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(s)}function YV(n){return["table","td","th"].includes(mc(n))}function fv(n){const e=dv(),t=ns(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function XV(n){let e=mo(n);for(;js(e)&&!yc(e);){if(fv(e))return e;e=mo(e)}return null}function dv(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function yc(n){return["html","body","#document"].includes(mc(n))}function ns(n){return yr(n).getComputedStyle(n)}function jg(n){return Fs(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function mo(n){if(mc(n)==="html")return n;const e=n.assignedSlot||n.parentNode||DN(n)&&n.host||yi(n);return DN(e)?e.host:e}function PN(n){const e=mo(n);return yc(e)?n.ownerDocument?n.ownerDocument.body:n.body:js(e)&&cd(e)?e:PN(e)}function ud(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=PN(n),i=s===((r=n.ownerDocument)==null?void 0:r.body),o=yr(s);return i?e.concat(o,o.visualViewport||[],cd(s)?s:[],o.frameElement&&t?ud(o.frameElement):[]):e.concat(s,ud(s,[],t))}function IN(n){const e=ns(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=js(n),i=s?n.offsetWidth:t,o=s?n.offsetHeight:r,a=Lg(t)!==i||Lg(r)!==o;return a&&(t=i,r=o),{width:t,height:r,$:a}}function hv(n){return Fs(n)?n:n.contextElement}function bc(n){const e=hv(n);if(!js(e))return go(1);const t=e.getBoundingClientRect(),{width:r,height:s,$:i}=IN(e);let o=(i?Lg(t.width):t.width)/r,a=(i?Lg(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const ZV=go(0);function LN(n){const e=yr(n);return!dv()||!e.visualViewport?ZV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function e$(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==yr(n)?!1:e}function Ma(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),i=hv(n);let o=go(1);e&&(r?Fs(r)&&(o=bc(r)):o=bc(n));const a=e$(i,t,r)?LN(i):go(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,f=s.height/o.y;if(i){const d=yr(i),h=r&&Fs(r)?yr(r):r;let p=d,g=p.frameElement;for(;g&&r&&h!==p;){const b=bc(g),y=g.getBoundingClientRect(),A=ns(g),v=y.left+(g.clientLeft+parseFloat(A.paddingLeft))*b.x,w=y.top+(g.clientTop+parseFloat(A.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=v,c+=w,p=yr(g),g=p.frameElement}}return Fg({width:u,height:f,x:l,y:c})}const t$=[":popover-open",":modal"];function pv(n){return t$.some(e=>{try{return n.matches(e)}catch{return!1}})}function n$(n){let{elements:e,rect:t,offsetParent:r,strategy:s}=n;const i=s==="fixed",o=yi(r),a=e?pv(e.floating):!1;if(r===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=go(1);const u=go(0),f=js(r);if((f||!f&&!i)&&((mc(r)!=="body"||cd(o))&&(l=jg(r)),js(r))){const d=Ma(r);c=bc(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x,y:t.y*c.y-l.scrollTop*c.y+u.y}}function r$(n){return Array.from(n.getClientRects())}function _N(n){return Ma(yi(n)).left+jg(n).scrollLeft}function s$(n){const e=yi(n),t=jg(n),r=n.ownerDocument.body,s=mr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=mr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+_N(n);const a=-t.scrollTop;return ns(r).direction==="rtl"&&(o+=mr(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:a}}function i$(n,e){const t=yr(n),r=yi(n),s=t.visualViewport;let i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=dv();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}function o$(n,e){const t=Ma(n,!0,e==="fixed"),r=t.top+n.clientTop,s=t.left+n.clientLeft,i=js(n)?bc(n):go(1),o=n.clientWidth*i.x,a=n.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function BN(n,e,t){let r;if(e==="viewport")r=i$(n,t);else if(e==="document")r=s$(yi(n));else if(Fs(e))r=o$(e,t);else{const s=LN(n);r={...e,x:e.x-s.x,y:e.y-s.y}}return Fg(r)}function FN(n,e){const t=mo(n);return t===e||!Fs(t)||yc(t)?!1:ns(t).position==="fixed"||FN(t,e)}function a$(n,e){const t=e.get(n);if(t)return t;let r=ud(n,[],!1).filter(a=>Fs(a)&&mc(a)!=="body"),s=null;const i=ns(n).position==="fixed";let o=i?mo(n):n;for(;Fs(o)&&!yc(o);){const a=ns(o),l=fv(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||cd(o)&&!l&&FN(n,o))?r=r.filter(u=>u!==o):s=a,o=mo(o)}return e.set(n,r),r}function l$(n){let{element:e,boundary:t,rootBoundary:r,strategy:s}=n;const o=[...t==="clippingAncestors"?pv(e)?[]:a$(e,this._c):[].concat(t),r],a=o[0],l=o.reduce((c,u)=>{const f=BN(e,u,s);return c.top=mr(f.top,c.top),c.right=Bs(f.right,c.right),c.bottom=Bs(f.bottom,c.bottom),c.left=mr(f.left,c.left),c},BN(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function c$(n){const{width:e,height:t}=IN(n);return{width:e,height:t}}function u$(n,e,t){const r=js(e),s=yi(e),i=t==="fixed",o=Ma(n,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=go(0);if(r||!r&&!i)if((mc(e)!=="body"||cd(s))&&(a=jg(e)),r){const f=Ma(e,!0,i,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&(l.x=_N(s));const c=o.left+a.scrollLeft-l.x,u=o.top+a.scrollTop-l.y;return{x:c,y:u,width:o.width,height:o.height}}function gv(n){return ns(n).position==="static"}function jN(n,e){return!js(n)||ns(n).position==="fixed"?null:e?e(n):n.offsetParent}function UN(n,e){const t=yr(n);if(pv(n))return t;if(!js(n)){let s=mo(n);for(;s&&!yc(s);){if(Fs(s)&&!gv(s))return s;s=mo(s)}return t}let r=jN(n,e);for(;r&&YV(r)&&gv(r);)r=jN(r,e);return r&&yc(r)&&gv(r)&&!fv(r)?t:r||XV(n)||t}const f$=async function(n){const e=this.getOffsetParent||UN,t=this.getDimensions,r=await t(n.floating);return{reference:u$(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function d$(n){return ns(n).direction==="rtl"}const h$={convertOffsetParentRelativeRectToViewportRelativeRect:n$,getDocumentElement:yi,getClippingRect:l$,getOffsetParent:UN,getElementRects:f$,getClientRects:r$,getDimensions:c$,getScale:bc,isElement:Fs,isRTL:d$};function p$(n,e){let t=null,r;const s=yi(n);function i(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:d}=n.getBoundingClientRect();if(a||e(),!f||!d)return;const h=_g(u),p=_g(s.clientWidth-(c+f)),g=_g(s.clientHeight-(u+d)),b=_g(c),A={rootMargin:-h+"px "+-p+"px "+-g+"px "+-b+"px",threshold:mr(0,Bs(1,l))||1};let v=!0;function w(E){const k=E[0].intersectionRatio;if(k!==l){if(!v)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}v=!1}try{t=new IntersectionObserver(w,{...A,root:s.ownerDocument})}catch{t=new IntersectionObserver(w,A)}t.observe(n)}return o(!0),i}function g$(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=hv(n),u=s||i?[...c?ud(c):[],...ud(e)]:[];u.forEach(y=>{s&&y.addEventListener("scroll",t,{passive:!0}),i&&y.addEventListener("resize",t)});const f=c&&a?p$(c,t):null;let d=-1,h=null;o&&(h=new ResizeObserver(y=>{let[A]=y;A&&A.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),t()}),c&&!l&&h.observe(c),h.observe(e));let p,g=l?Ma(n):null;l&&b();function b(){const y=Ma(n);g&&(y.x!==g.x||y.y!==g.y||y.width!==g.width||y.height!==g.height)&&t(),g=y,p=requestAnimationFrame(b)}return t(),()=>{var y;u.forEach(A=>{s&&A.removeEventListener("scroll",t),i&&A.removeEventListener("resize",t)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const m$=KV,y$=JV,b$=$V,w$=QV,v$=WV,HN=VV,x$=qV,A$=(n,e,t)=>{const r=new Map,s={platform:h$,...t},i={...s.platform,_c:r};return zV(n,e,{...s,platform:i})};var Ug=typeof document<"u"?L.useLayoutEffect:L.useEffect;function Hg(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!Hg(n[r],e[r]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=t;r--!==0;){const i=s[r];if(!(i==="_owner"&&n.$$typeof)&&!Hg(n[i],e[i]))return!1}return!0}return n!==n&&e!==e}function zN(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function VN(n,e){const t=zN(n);return Math.round(e*t)/t}function $N(n){const e=H.useRef(n);return Ug(()=>{e.current=n}),e}function E$(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=H.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,h]=H.useState(r);Hg(d,r)||h(r);const[p,g]=H.useState(null),[b,y]=H.useState(null),A=H.useCallback(Y=>{Y!==k.current&&(k.current=Y,g(Y))},[]),v=H.useCallback(Y=>{Y!==S.current&&(S.current=Y,y(Y))},[]),w=i||p,E=o||b,k=H.useRef(null),S=H.useRef(null),M=H.useRef(u),O=l!=null,R=$N(l),D=$N(s),F=H.useCallback(()=>{if(!k.current||!S.current)return;const Y={placement:e,strategy:t,middleware:d};D.current&&(Y.platform=D.current),A$(k.current,S.current,Y).then(re=>{const Z={...re,isPositioned:!0};U.current&&!Hg(M.current,Z)&&(M.current=Z,sy.flushSync(()=>{f(Z)}))})},[d,e,t,D]);Ug(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(Y=>({...Y,isPositioned:!1})))},[c]);const U=H.useRef(!1);Ug(()=>(U.current=!0,()=>{U.current=!1}),[]),Ug(()=>{if(w&&(k.current=w),E&&(S.current=E),w&&E){if(R.current)return R.current(w,E,F);F()}},[w,E,F,R,O]);const K=H.useMemo(()=>({reference:k,floating:S,setReference:A,setFloating:v}),[A,v]),_=H.useMemo(()=>({reference:w,floating:E}),[w,E]),G=H.useMemo(()=>{const Y={position:t,left:0,top:0};if(!_.floating)return Y;const re=VN(_.floating,u.x),Z=VN(_.floating,u.y);return a?{...Y,transform:"translate("+re+"px, "+Z+"px)",...zN(_.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:re,top:Z}},[t,a,_.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:F,refs:K,elements:_,floatingStyles:G}),[u,F,K,_,G])}const k$=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:s}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?HN({element:r.current,padding:s}).fn(t):{}:r?HN({element:r,padding:s}).fn(t):{}}}},C$=(n,e)=>({...m$(n),options:[n,e]}),S$=(n,e)=>({...y$(n),options:[n,e]}),T$=(n,e)=>({...x$(n),options:[n,e]}),N$=(n,e)=>({...b$(n),options:[n,e]}),O$=(n,e)=>({...w$(n),options:[n,e]}),R$=(n,e)=>({...v$(n),options:[n,e]}),M$=(n,e)=>({...k$(n),options:[n,e]});var D$="Arrow",WN=H.forwardRef((n,e)=>{const{children:t,width:r=10,height:s=5,...i}=n;return C.jsx(Kn.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});WN.displayName=D$;var P$=WN;function I$(n){const[e,t]=H.useState(void 0);return ha(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=n.offsetWidth,a=n.offsetHeight;t({width:o,height:a})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}var mv="Popper",[GN,KN]=V0(mv),[L$,JN]=GN(mv),qN=n=>{const{__scopePopper:e,children:t}=n,[r,s]=H.useState(null);return C.jsx(L$,{scope:e,anchor:r,onAnchorChange:s,children:t})};qN.displayName=mv;var QN="PopperAnchor",YN=H.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...s}=n,i=JN(QN,t),o=H.useRef(null),a=Or(e,o);return H.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:C.jsx(Kn.div,{...s,ref:a})});YN.displayName=QN;var yv="PopperContent",[_$,B$]=GN(yv),XN=H.forwardRef((n,e)=>{var He,Le,Ze,le,ze,ae;const{__scopePopper:t,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:p,...g}=n,b=JN(yv,t),[y,A]=H.useState(null),v=Or(e,be=>A(be)),[w,E]=H.useState(null),k=I$(w),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,O=r+(i!=="center"?"-"+i:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],F=D.length>0,U={padding:R,boundary:D.filter(j$),altBoundary:F},{refs:K,floatingStyles:_,placement:G,isPositioned:Y,middlewareData:re}=E$({strategy:"fixed",placement:O,whileElementsMounted:(...be)=>g$(...be,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[C$({mainAxis:s+M,alignmentAxis:o}),l&&S$({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T$():void 0,...U}),l&&N$({...U}),O$({...U,apply:({elements:be,rects:_e,availableWidth:z,availableHeight:J})=>{const{width:ne,height:ce}=_e.reference,P=be.floating.style;P.setProperty("--radix-popper-available-width",`${z}px`),P.setProperty("--radix-popper-available-height",`${J}px`),P.setProperty("--radix-popper-anchor-width",`${ne}px`),P.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),w&&M$({element:w,padding:a}),U$({arrowWidth:S,arrowHeight:M}),d&&R$({strategy:"referenceHidden",...U})]}),[Z,ge]=tO(G),ke=ro(p);ha(()=>{Y&&(ke==null||ke())},[Y,ke]);const Pe=(He=re.arrow)==null?void 0:He.x,Ce=(Le=re.arrow)==null?void 0:Le.y,Ee=((Ze=re.arrow)==null?void 0:Ze.centerOffset)!==0,[Ue,Fe]=H.useState();return ha(()=>{y&&Fe(window.getComputedStyle(y).zIndex)},[y]),C.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:Y?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ue,"--radix-popper-transform-origin":[(le=re.transformOrigin)==null?void 0:le.x,(ze=re.transformOrigin)==null?void 0:ze.y].join(" "),...((ae=re.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:C.jsx(_$,{scope:t,placedSide:Z,onArrowChange:E,arrowX:Pe,arrowY:Ce,shouldHideArrow:Ee,children:C.jsx(Kn.div,{"data-side":Z,"data-align":ge,...g,ref:v,style:{...g.style,animation:Y?void 0:"none"}})})})});XN.displayName=yv;var ZN="PopperArrow",F$={top:"bottom",right:"left",bottom:"top",left:"right"},eO=H.forwardRef(function(e,t){const{__scopePopper:r,...s}=e,i=B$(ZN,r),o=F$[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(P$,{...s,ref:t,style:{...s.style,display:"block"}})})});eO.displayName=ZN;function j$(n){return n!==null}var U$=n=>({name:"transformOrigin",options:n,fn(e){var b,y,A;const{placement:t,rects:r,middlewareData:s}=e,o=((b=s.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:n.arrowWidth,l=o?0:n.arrowHeight,[c,u]=tO(t),f={start:"0%",center:"50%",end:"100%"}[u],d=(((y=s.arrow)==null?void 0:y.x)??0)+a/2,h=(((A=s.arrow)==null?void 0:A.y)??0)+l/2;let p="",g="";return c==="bottom"?(p=o?f:`${d}px`,g=`${-l}px`):c==="top"?(p=o?f:`${d}px`,g=`${r.floating.height+l}px`):c==="right"?(p=`${-l}px`,g=o?f:`${h}px`):c==="left"&&(p=`${r.floating.width+l}px`,g=o?f:`${h}px`),{data:{x:p,y:g}}}});function tO(n){const[e,t="center"]=n.split("-");return[e,t]}var H$=qN,nO=YN,z$=XN,V$=eO,bv="Popover",[rO,oQ]=V0(bv,[KN]),fd=KN(),[$$,Da]=rO(bv),sO=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=fd(e),l=H.useRef(null),[c,u]=H.useState(!1),[f=!1,d]=qk({prop:r,defaultProp:s,onChange:i});return C.jsx(H$,{...a,children:C.jsx($$,{scope:e,contentId:qh(),triggerRef:l,open:f,onOpenChange:d,onOpenToggle:H.useCallback(()=>d(h=>!h),[d]),hasCustomAnchor:c,onCustomAnchorAdd:H.useCallback(()=>u(!0),[]),onCustomAnchorRemove:H.useCallback(()=>u(!1),[]),modal:o,children:t})})};sO.displayName=bv;var iO="PopoverAnchor",W$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(iO,t),i=fd(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return H.useEffect(()=>(o(),()=>a()),[o,a]),C.jsx(nO,{...i,...r,ref:e})});W$.displayName=iO;var oO="PopoverTrigger",aO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(oO,t),i=fd(t),o=Or(e,s.triggerRef),a=C.jsx(Kn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":dO(s.open),...r,ref:o,onClick:fr(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:C.jsx(nO,{asChild:!0,...i,children:a})});aO.displayName=oO;var G$="PopoverPortal",[aQ,K$]=rO(G$,{forceMount:void 0}),wc="PopoverContent",lO=H.forwardRef((n,e)=>{const t=K$(wc,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=Da(wc,n.__scopePopover);return C.jsx(kf,{present:r||i.open,children:i.modal?C.jsx(J$,{...s,ref:e}):C.jsx(q$,{...s,ref:e})})});lO.displayName=wc;var J$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(null),s=Or(e,r),i=H.useRef(!1);return H.useEffect(()=>{const o=r.current;if(o)return xC(o)},[]),C.jsx(eb,{as:Qh,allowPinchZoom:!0,children:C.jsx(cO,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fr(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fr(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fr(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),q$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(!1),s=H.useRef(!1);return C.jsx(cO,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),cO=H.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=n,d=Da(wc,t),h=fd(t);return oC(),C.jsx(Ef,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:C.jsx(G0,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),children:C.jsx(z$,{"data-state":dO(d.open),role:"dialog",id:d.contentId,...h,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),uO="PopoverClose",fO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(uO,t);return C.jsx(Kn.button,{type:"button",...r,ref:e,onClick:fr(n.onClick,()=>s.onOpenChange(!1))})});fO.displayName=uO;var Q$="PopoverArrow",Y$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=fd(t);return C.jsx(V$,{...s,...r,ref:e})});Y$.displayName=Q$;function dO(n){return n?"open":"closed"}var X$=sO,Z$=aO,e9=lO,zg=fO;const Vg=({children:n,isActive:e,onClick:t,disabled:r,className:s})=>{const i=pe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",s);return C.jsx("button",{className:i,disabled:r,onClick:t,children:n})},t9=(n,e,t)=>{const r=L.useCallback(()=>{const a=n.chain();a.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&a.setParagraph(),a.run()},[n,t,e==null?void 0:e.type.name]),s=L.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:a}=n.state.selection,l=a.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),l.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:s,copyNodeToClipboard:i,deleteNode:o}},n9=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[s,i]=L.useState(!1),o=t9(t,n,e()),a=mp(),l=["https://twitter.com","https://x.com"],c=L.useMemo(()=>{const{content:O}=n.content;return O[0].type.name==="table"},[n.content]),u=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[0])==null?void 0:R.text},[n.content]),f=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[1])==null?void 0:R.text},[n.content]),d=L.useMemo(()=>{const{content:O}=n.content;return O[0].content.content.find(R=>{var D;return(D=R==null?void 0:R.text)==null?void 0:D.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let O=u;if(u.includes("<iframe"))O=f;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://www.youtube.com/embed/${K[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://player.vimeo.com/video/${K[1]}`);break}default:return}const R=640,D=360,F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===0?F:F+1,to:U}).setIframe({src:O,width:R,height:D}).run())},p=O=>{const R=O.match(/\/status\/([0-9]*)/);return R&&R.length>0?R[1]:null},g=()=>{if(!u)return;let O=u;const R=l.some(K=>u.includes(K)),D=p(u);R&&D?O=D:d&&(O=p(d.text));const F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===2?F:F+1,to:U}).setTweetEmbed({tweetId:O}).run())},b=()=>{const O=e()+n.nodeSize;t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},y=()=>{const O=e();t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},A=()=>{r()},v=O=>{O.altKey?E():w()},w=()=>{b()},E=()=>{y()},k=O=>{O.altKey&&A()},M=iv(()=>{if(l.some(O=>u.includes(O))||d!=null&&d.text){g();return}else{h();return}},1e3);return L.useEffect(()=>{u&&M()},[u]),C.jsxs(wf,{as:"div",className:pe("flex gap-2 group w-full relative justify-center items-start",a&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[C.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[C.jsx(_S,{content:C.jsxs("div",{className:"flex flex-col w-40",children:[C.jsx("div",{className:"text-xs",children:"Click to add below"}),C.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:v,children:C.jsx(i4,{size:18})})}),C.jsxs(X$,{open:s,onOpenChange:i,children:[C.jsx(Z$,{asChild:!0,children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:k,children:C.jsx(Z3,{size:18})})}),C.jsx(e9,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:C.jsxs(Tb,{className:"p-2 flex flex-col min-w-[16rem]",children:[C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.resetTextFormatting,children:[C.jsx(o4,{size:18}),"Clear formatting"]})}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.copyNodeToClipboard,children:[C.jsx(q3,{size:18}),"Copy to clipboard"]})}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.duplicateNode,children:[C.jsx(Y3,{size:18}),"Duplicate"]})}),C.jsx(If.Divider,{horizontal:!0}),C.jsx(zg,{children:C.jsxs(Vg,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[C.jsx(Wk,{size:18}),"Delete"]})})]})})]})]}),C.jsx(Ik,{className:pe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r9=vt.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,s=n!==void 0||n!==null?r:n;return t().insertContentAt(s,{type:this.name,content:[{type:"paragraph"}]}).focus(s+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;const o=[];if(e.doc.nodesBetween(r,s,l=>{if(l.type.name===this.name){const c=e.schema.nodes.listItem.create(null,l.content);c&&o.push(c)}}),o.length===0)return!1;const a=e.schema.nodes[n].create(null,o);return a?(i=i.replaceRangeWith(r,s,a),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,s,(o,a)=>{if(o.type.name===n){const l=e.schema.nodes[this.name].create(null,o.content);i=i.insert(a,l)}}),t(i),!0}}},addNodeView(){return da(n9)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:s}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let o=-1,a="";s.descendants((u,f)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[d,h]=[f,f+u.nodeSize];return d<=t&&r<=h&&(o=h,a=u.type.name),!1});const l=(c=s.slice(t,o))==null?void 0:c.toJSON().content;try{return a==="codeBlock"?n.chain().newlineInCode().focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let wv,vv;if(typeof WeakMap<"u"){let n=new WeakMap;wv=e=>n.get(e),vv=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;wv=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},vv=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class vc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Bt{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new vc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new vc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return wv(e)||vv(e,s9(e))}}function s9(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=i9(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let g=f.child(p),{colspan:b,rowspan:y,colwidth:A}=g.attrs;for(let v=0;v<y;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-v});break}let w=s+v*e;for(let E=0;E<b;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:b-E});let k=A&&A[E];if(k){let S=(w+E)%e*2,M=o[S];M==null||M!=k&&o[S+1]==1?(o[S]=k,o[S+1]=1):M==k&&o[S+1]++}}}s+=b,u+=g.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Bt(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&o9(a,o,n),a}function i9(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function o9(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=a9(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a9(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const yo=new Ot("selectingCells");function xc(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function l9(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function rs(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function $g(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:xc(e.$head)||c9(e.$head)}function c9(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function xv(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u9(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Av(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function hO(n,e,t){let r=n.start(-1),i=Bt.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function an(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function Pa(n,e,t=1){let r=an(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function pO(n,e,t=1){let r=an(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function f9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class it extends Ie{constructor(e,t=e){let r=e.node(-1),s=Bt.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Ay(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(xv(r)&&xv(s)&&Av(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?it.rowSelection(r,s):i&&this.isColSelection()?it.colSelection(r,s):new it(r,s)}return Me.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Bt.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),g=s.left-h.left,b=h.right-s.right;if(g>0||b>0){let y=p.attrs;g>0&&(y=Pa(y,0,g)),b>0&&(y=Pa(y,y.colspan-b,b)),h.left<s.left?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){let y=an(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}}o.push(e.child(l).copy(oe.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new ue(oe.from(a),1,1)}replace(e,t=ue.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?ue.empty:t)}let i=Ie.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ue(oe.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Bt.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new it(e,t)}isRowSelection(){let e=Bt.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof it&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new it(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new it(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new it(e.resolve(t),e.resolve(r))}getBookmark(){return new Ev(this.$anchorCell.pos,this.$headCell.pos)}}it.prototype.visible=!1,Ie.jsonID("cell",it);class Ev{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ev(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Av(t,r)?new it(t,r):Ie.near(r,1)}}function d9(n){if(!(n.selection instanceof it))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Qt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),wt.create(n.doc,e)}function h9({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function p9({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function g9(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof Ne&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=it.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=it.rowSelection(a,a)}else if(!t){let a=Bt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=it.create(s,l+1,c)}}else r instanceof Me&&h9(r)?i=Me.create(s,r.from):r instanceof Me&&p9(r)&&(i=Me.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function m9(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=kv(xn(o).row,new ue(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?kv(xn(o).row,new ue(e,t,r)).content:e);else return null;return y9(o,a)}function y9(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(oe.empty),t[s]<r){let i=xn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(oe.from(o))}return{height:e.length,width:r,rows:e}}function kv(n,e){let t=n.createAndFill();return new vy(t).replace(0,t.content.size,e).doc}function b9({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(Pa(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(oe.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(an(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(oe.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function w9(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=xn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let b=e.width;b<s;b++)p.push(g);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let b=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==l.header_cell;f.push(b?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,oe.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function gO(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,an(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(an(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function mO(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,Pa(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(Pa(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function yO(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Bt.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Bt.get(i),d=f.mapping.maps.length}w9(f,o,i,t,c,u,d)&&h(),gO(f,o,i,t,l,c,a,d)&&h(),gO(f,o,i,t,l,c,u,d)&&h(),mO(f,o,i,t,a,u,l,d)&&h(),mO(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let g=o.positionAt(p,l,i),b=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(g+t),f.mapping.slice(d).map(b+t),new ue(s.rows[p-a],0,0))}h(),f.setSelection(new it(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const v9=Yy({ArrowLeft:Gg("horiz",-1),ArrowRight:Gg("horiz",1),ArrowUp:Gg("vert",-1),ArrowDown:Gg("vert",1),"Shift-ArrowLeft":Kg("horiz",-1),"Shift-ArrowRight":Kg("horiz",1),"Shift-ArrowUp":Kg("vert",-1),"Shift-ArrowDown":Kg("vert",1),Backspace:Jg,"Mod-Backspace":Jg,Delete:Jg,"Mod-Delete":Jg});function Wg(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gg(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof it)return Wg(t,r,Ie.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=bO(s,n,e);if(o==null)return!1;if(n=="horiz")return Wg(t,r,Ie.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=hO(a,n,e),c;return l?c=Ie.near(l,1):e<0?c=Ie.near(t.doc.resolve(a.before(-1)),-1):c=Ie.near(t.doc.resolve(a.after(-1)),1),Wg(t,r,c)}}}function Kg(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof it)){let a=bO(s,n,e);if(a==null)return!1;i=new it(t.doc.resolve(a))}let o=hO(i.$headCell,n,e);return o?Wg(t,r,new it(i.$anchorCell,o)):!1}}function Jg(n,e){let t=n.selection;if(!(t instanceof it))return!1;if(e){let r=n.tr,s=xn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new ue(s,0,0))}),r.docChanged&&e(r)}return!0}function x9(n,e){let t=n.state.doc,r=xc(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new it(r))),!0):!1}function A9(n,e,t){if(!rs(n.state))return!1;let r=m9(t),s=n.state.selection;if(s instanceof it){r||(r={width:1,height:1,rows:[oe.from(kv(xn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Bt.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=b9(r,a.right-a.left,a.bottom-a.top),yO(n.state,n.dispatch,o,a,r),!0}else if(r){let i=$g(n.state),o=i.start(-1);return yO(n.state,n.dispatch,o,Bt.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function E9(n,e){if(e.ctrlKey||e.metaKey)return;let t=wO(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof it)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=xc(n.state.selection.$anchor))!=null&&Cv(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=Cv(n,l),u=yo.getState(n.state)==null;if(!c||!Av(a,c))if(u)c=a;else return;let f=new it(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(yo,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),yo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(yo,-1))}function o(a){let l=yo.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(wO(n,a.target)!=t&&(c=Cv(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function bO(n,e,t){if(!(n.state.selection instanceof Me))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function wO(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Cv(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?xc(n.state.doc.resolve(t.pos)):null}const k9=new Ot("fix-tables");function vO(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?vO(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function xO(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=C9(n,s,i,t))};return e?e.doc!=n.doc&&vO(e.doc,n.doc,0,r):n.doc.descendants(r),t}function C9(n,e,t,r){let s=Bt.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pa(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let b=0;b<d;b++)p.push(xn(n.schema)[h].createAndFill());let g=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(g),p)}c=f}return r.setMeta(k9,{fixTables:!0})}function Us(n){let e=n.selection,t=$g(n),r=t.node(-1),s=t.start(-1),i=Bt.get(r),o;return e instanceof it?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function AO(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;f9(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,pO(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?xn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function S9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.left))}return!0}function T9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.right))}return!0}function N9(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,Pa(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;N9(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function R9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function EO(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;R9(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,an(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?xn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,xn(r.type.schema).row.create(null,o)),n}function M9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.top))}return!0}function D9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.bottom))}return!0}function P9(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,an(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(an(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function I9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;P9(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function kO(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function L9({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function CO(n,e){let t=n.selection;if(!(t instanceof it)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Us(n),{map:s}=r;if(L9(s,r))return!1;if(e){let i=n.tr,o={},a=oe.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{kO(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,an(pO(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=kO(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new it(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function SO(n,e){const t=xn(n.schema);return _9(({node:r})=>t[r.type.spec.tableRole])(n,e)}function _9(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof it){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=l9(r.$from),!s)return!1;i=xc(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=an(o,"rowspan",1)),o.colspan>1&&(o=an(o,"colspan",1));let c=Us(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?an(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[g]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof it&&u.setSelection(new it(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function B9(n,e){return function(t,r){if(!rs(t))return!1;let s=$g(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof it?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,an(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,an(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function F9(n){return function(e,t){if(!rs(e))return!1;if(t){let r=xn(e.schema),s=Us(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new vc(s.left,0,s.right,s.map.height):n=="row"?new vc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function TO(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function dd(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?F9(n):function(t,r){if(!rs(t))return!1;if(r){let s=xn(t.schema),i=Us(t),o=t.tr,a=TO("row",i,s),l=TO("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new vc(0,u,1,i.map.height):n=="row"?new vc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,d,g.attrs)}),r(o)}return!0}}dd("row",{useDeprecatedLogic:!0}),dd("column",{useDeprecatedLogic:!0});let j9=dd("cell",{useDeprecatedLogic:!0});function U9(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function NO(n){return function(e,t){if(!rs(e))return!1;let r=U9($g(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Me.between(s,u9(s))).scrollIntoView())}return!0}}}function H9(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let z9=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Sv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sv(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let g=s==f?i:h&&h[p],b=g?g+"px":"";o+=g||r,g||(a=!1),l?(l.style.width!=b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const Lr=new Ot("tableColumnResizing");function V9({handleWidth:n=5,cellMinWidth:e=25,View:t=z9,lastColumnResizable:r=!0}={}){return new bt({key:Lr,state:{init(i,o){return this.spec.props.nodeViews[xn(o.schema).table.name]=(a,l)=>new t(a,e,l),new hd(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return Lr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){$9(i,o,n,e,r)},mouseleave(i){W9(i)},mousedown(i,o){G9(i,o,e)}},decorations(i){let o=Lr.getState(i);if(o.activeHandle>-1)return X9(i,o.activeHandle)},nodeViews:{}}})}class hd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new hd(r.setHandle,null);if(r&&r.setDragging!==void 0)return new hd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);xv(e.doc.resolve(s))||(s=null),t=new hd(s,t.dragging)}return t}}function $9(n,e,t,r,s){let i=Lr.getState(n.state);if(!i.dragging){let o=J9(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=OO(n,e,"left"):c-e.clientX<=t&&(a=OO(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Bt.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}MO(n,a)}}}function W9(n){let e=Lr.getState(n.state);e.activeHandle>-1&&!e.dragging&&MO(n,-1)}function G9(n,e,t){let r=Lr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=K9(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=Lr.getState(n.state);c.dragging&&(q9(n,c.activeHandle,RO(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(Lr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=Lr.getState(n.state),u=RO(c.dragging,l,t);Q9(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function K9(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function J9(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function OO(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=xc(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Bt.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function RO(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function MO(n,e){n.dispatch(n.state.tr.setMeta(Lr,{setHandle:e}))}function q9(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():Y9(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,an(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function Q9(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Bt.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Sv(i,l.firstChild,l,r,a,t)}function Y9(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X9(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Qt.widget(f,d))}}return wt.create(n.doc,t)}function Z9({allowTableNodeSelection:n=!1}={}){return new bt({key:yo,state:{init(){return null},apply(e,t){let r=e.getMeta(yo);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:d9,handleDOMEvents:{mousedown:E9},createSelectionBetween(e){if(yo.getState(e.state)!=null)return e.state.selection},handleTripleClick:x9,handleKeyDown:v9,handlePaste:A9},appendTransaction(e,t,r){return g9(r,xO(r,t),n)}})}function DO(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let g=0;g<h;g+=1,d+=1){const b=s===d?i:p&&p[g],y=b?`${b}px`:"";o+=b||r,b||(a=!1),l?(l.style.width!==y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eW{constructor(e,t){$(this,"node");$(this,"cellMinWidth");$(this,"dom");$(this,"table");$(this,"colgroup");$(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),DO(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,DO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function PO(n,e){return n.createAndFill()}function tW(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nW(n,e,t,r,s){const i=tW(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=PO(i.cell);if(u&&a.push(u),r){const f=PO(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function rW(n){return n instanceof it}const qg=({editor:n})=>{const{selection:e}=n.state;if(!rW(e))return!1;let t=0;const r=a0(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},sW=vt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eW,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",tt(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=nW(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Me.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>S9(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>T9(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O9(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M9(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D9(n,e),deleteRow:()=>({state:n,dispatch:e})=>I9(n,e),deleteTable:()=>({state:n,dispatch:e})=>H9(n,e),mergeCells:()=>({state:n,dispatch:e})=>CO(n,e),splitCell:()=>({state:n,dispatch:e})=>SO(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dd("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dd("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>j9(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>CO(n,e)?!0:SO(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>B9(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>NO(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>NO(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&xO(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=it.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:qg,"Mod-Backspace":qg,Delete:qg,"Mod-Delete":qg}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[V9({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z9({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(xe(n,"tableRole",e))}}});function IO(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var LO=typeof window<"u"&&typeof document<"u";function Tv(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function _O(){return LO&&document.createElement("div")}function iW(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function BO(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!BO(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oW(n){var e=[];return n.forEach(function(t){e.find(function(r){return BO(t,r)})||e.push(t)}),e}function aW(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oW([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Nv=LO?L.useLayoutEffect:L.useEffect;function lW(n){var e=L.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function FO(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cW={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}FO(t,"add",e.props.className)}function i(){r()&&FO(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function uW(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=IO(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,g=o!==void 0,b=L.useState(!1),y=b[0],A=b[1],v=L.useState({}),w=v[0],E=v[1],k=L.useState(),S=k[0],M=k[1],O=lW(function(){return{container:_O(),renders:1}}),R=Object.assign({ignoreAttributes:d},h,{content:O.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(K){R[K]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+K+"` prop in","controlled mode (`visible` prop)"].join(" "))}),R.trigger="manual",R.hideOnClick=!1),g&&(u=!0);var D=R,F=R.plugins||[];a&&(D=Object.assign({},R,{plugins:g&&o.data!=null?[].concat(F,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var ge=Z.instance;return ge.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,M(re.content)}}}}]):F,render:function(){return{popper:O.container}}}));var U=[l].concat(r?[r.type]:[]);return Nv(function(){var K=l;l&&l.hasOwnProperty("current")&&(K=l.current);var _=n(K||O.ref||_O(),Object.assign({},D,{plugins:[cW].concat(R.plugins||[])}));return O.instance=_,u&&_.disable(),i&&_.show(),g&&o.hook({instance:_,content:s,props:D,setSingletonContent:M}),A(!0),function(){_.destroy(),o==null||o.cleanup(_)}},U),Nv(function(){var K;if(O.renders===1){O.renders++;return}var _=O.instance;_.setProps(aW(_.props,D)),(K=_.popperInstance)==null||K.forceUpdate(),u?_.disable():_.enable(),p&&(i?_.show():_.hide()),g&&o.hook({instance:_,content:s,props:D,setSingletonContent:M})}),Nv(function(){var K;if(a){var _=O.instance;_.setProps({popperOptions:Object.assign({},_.props.popperOptions,{modifiers:[].concat((((K=_.props.popperOptions)==null?void 0:K.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,ge=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(ge==null?void 0:ge.isReferenceHidden)||w.escaped!==(ge==null?void 0:ge.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:ge==null?void 0:ge.isReferenceHidden,escaped:ge==null?void 0:ge.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat(U)),L.createElement(L.Fragment,null,r?L.cloneElement(r,{ref:function(_){O.ref=_,Tv(r.ref,_)}}):null,y&&Et.createPortal(a?a(iW(w),S,O.instance):s,O.container))}return e}var fW=function(n,e){return L.forwardRef(function(r,s){var i=r.children,o=IO(r,["children"]);return L.createElement(n,Object.assign({},e,o),i?L.cloneElement(i,{ref:function(l){Tv(s,l),Tv(i.ref,l)}}):null)})},dW=fW(uW(fa));const hW=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],jO=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=L.useState(!1),o=mp(),a=L.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};L.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return C.jsxs(wf,{className:"group",children:[C.jsx(Ik,{as:"span"}),(s||t)&&C.jsx(dW,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:C.jsx("article",{className:"dropdown",contentEditable:!1,children:C.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hW.map(u=>C.jsx("li",{children:C.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[C.jsx("span",{children:u.icon}),C.jsx("span",{children:u.name})]})},u.name))})}),children:C.jsx("label",{tabIndex:0,className:pe("trigger-button",{hidden:o}),contentEditable:!1,children:C.jsx(X3,{fontSize:"small"})})})]})},pW=vt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"td",className:"relative"})}}),gW=vt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"th",className:"relative"})}}),UO=n=>(n.stopPropagation(),n.preventDefault(),n),mW=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},HO=function(n){return!n||n===document.body?document.body:mW(n)?n:HO(n.parentNode)},Ov=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},yW=vt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=HO(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const y=r(),A=n.state.doc.resolve(y),v=new Ne(A);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Ov("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:y=>{y&&UO(y),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Ov("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:y=>{y&&UO(y),o.deleteRow()}}),f=()=>{g(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Ov("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const y=h.getBoundingClientRect(),A=JSON.stringify(y);p!==A&&(c.style.top=`${y.top+document.documentElement.scrollTop}px`,c.style.left=`${y.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${y.height+1}px`,p=A)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),s==null||s.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),s==null||s.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),bW=[sW.configure({resizable:!0}),pW,gW,yW],wW=Y2.extend({content:"(dBlock|columns)+"});function zO({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const vW=St.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ot(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new bt({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!zO({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!zO({node:s,types:e})}}})]}}),xW=({node:n,editor:e,getPos:t})=>{const[r,s]=L.useState(""),i=mp(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return C.jsx(Gk,{});case"iframe":return C.jsx(Kk,{});default:return C.jsx(a4,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,b=360,y=t(),A=y+n.nodeSize;p&&(e==null||e.chain().focus(y).deleteRange({from:y,to:A}).setIframe({src:p,width:g,height:b}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(w=>r.includes(w)),b=r.match(/\/status\/([0-9]*)/),y=b&&b.length>0;if(g&&y)p=b[1];else{alert("invalid url");return}const A=t(),v=A+n.nodeSize;p&&(e==null||e.chain().focus(A).deleteRange({from:A,to:v}).setTweetEmbed({tweetId:p}).run())},d=iv(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);L.useEffect(()=>{r&&d()},[r]),L.useEffect(()=>{e==null||e.chain().focus()},[]);const h=L.useRef(null);return L.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&C.jsxs("div",{className:"relative w-full",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),C.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},AW=vt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return da(xW)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),EW=[Pz,Mz.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-[#E8EBEC] p-5 font-serif italic text-black"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-black"},exitOnArrowDown:!0},code:{HTMLAttributes:{class:"rounded bg-transparent p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Iz.configure({types:["heading","paragraph"]}),xV,rV.extend({exitable:!0}).configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),sV.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),aV.configure({multicolor:!0}),vV,fV.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),Dz,kV,lV.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),uV.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),X2.configure({width:3,color:"#d1d5db"}),Z2,r9,vW,wW,...bW,PV.configure({uploadFn:g4}),EV,CV,OV,AW.extend({addInputRules(){return[VO(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),VO(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),AV],VO=(n,e,t)=>new of({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),kW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAE/SURBVHgBhVJBTsJQEH3zMcElR+gRuIF6gwYPAOwkLoQTUE6ArEA3xbWJ4gnQE8gNwBuwhMR2fPNLk9o0ZZImM/P/e39e3wgqojPXXiPFJnFovw1kWT53xSKca3C70LXlr/eySYFdZ6Fb61eCePnBCb6VF3P21UA+WX+wv+086fgfyMbh4aPlqWJSZH2/k6EINlBEJI6tdxHG2tIDrsUqxYzsO5Qi+UXfNfwUPT7w49wRU1EyZWNFqIgV9REw84Wga+P1Uj7PsW5QE9pEZMT8Aq+JQmNcYl8HwgEtEvf9fc3RR4zrMCRe84WA6dJRz8upPwyftV0FOP3ugHqu0iZGzsSbF3bYUMRlgDdWMcyE4WvVl73XRC9CNiaqaHMDpkUQrYh8kmKUmy5lVpvdBNs2mOk0tptk9a5AVKHhzML+AZaSjR/r++n9AAAAAElFTkSuQmCC",CW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEjSURBVHgBjZJBToNQEIb/NzTeoMbGjTeoN5Au1S7wBrqwyk5OoD1B46pRF9UbsEBc9nmEHsI08QhGZnxMpaGUEv4EwoP/mxnyj0GNTp++AoPORA+Gx+mo91r1mOJh+LL0WYwDqC8i/obJGCuSfRJ1bHLdtWtQIaY5WoiYBknYtZQfmOGjpTIvC7TAahTvpMksmUQCvK0A6itzNl1egmi2k2K+2gPsD+mvHGkh4MIVoPuSLYbIYxOk3YAJVRuktwd3DhjvggqRB0Slc3D+/D1Lw95DE5Rnq3E487ySXeyu4zooz/R9tD/QUYV5Ufke1HbKvW4RdFS9icRoKeKO1c7Fi+HUbQ/BzzPdXjmxDCy8TOIk7G2CZf1nqzEJfqOPm8Otif4AFnp3K1F5HHAAAAAASUVORK5CYII=",SW=n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},TW=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=kW,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=CW,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},NW=n=>n.isEns?TW(n):SW(n),OW="6.13.1";function RW(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function An(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function Oe(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&RW(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ac(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ac).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ac(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ac(t)}: ${Ac(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ln(n,e){return n&&n.code===e}function Rv(n){return ln(n,"CALL_EXCEPTION")}function Nt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ac(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+Ac(a))}}i.push(`code=${e}`),i.push(`version=${OW}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return Oe(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Oe(s,{shortMessage:r}),s}function ee(n,e,t,r){if(!n)throw Nt(e,t,r)}function V(n,e,t,r){ee(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function $O(n,e,t){t==null&&(t=""),t&&(t=": "+t),ee(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),ee(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Qg(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),ee(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function WO(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}V(!1,"invalid BytesLike value",e||"value",n)}function lt(n,e){return WO(n,e,!1)}function Pn(n,e){return WO(n,e,!0)}function At(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mv(n){return At(n,!0)||n instanceof Uint8Array}const GO="0123456789abcdef";function we(n){const e=lt(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=GO[(s&240)>>4]+GO[s&15]}return t}function Ut(n){return"0x"+n.map(e=>we(e).substring(2)).join("")}function Ec(n){return At(n,!0)?(n.length-2)/2:lt(n).length}function Ft(n,e,t){const r=lt(n);return t!=null&&t>r.length&&ee(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),we(r.slice(e??0,t??r.length))}function KO(n,e,t){const r=lt(n);ee(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),we(s)}function Ia(n,e){return KO(n,e,!0)}function MW(n,e){return KO(n,e,!1)}const Yg=BigInt(0),ss=BigInt(1),kc=9007199254740991;function DW(n,e){const t=Xg(n,"value"),r=BigInt(Je(e,"width"));if(ee(t>>r===Yg,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-ss){const s=(ss<<r)-ss;return-((~t&s)+ss)}return t}function JO(n,e){let t=Ae(n,"value");const r=BigInt(Je(e,"width")),s=ss<<r-ss;if(t<Yg){t=-t,ee(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(ss<<r)-ss;return(~t&i)+ss}else ee(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function pd(n,e){const t=Xg(n,"value"),r=BigInt(Je(e,"bits"));return t&(ss<<r)-ss}function Ae(n,e){switch(typeof n){case"bigint":return n;case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}V(!1,"invalid BigNumberish value",e||"value",n)}function Xg(n,e){const t=Ae(n,e);return ee(t>=Yg,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const qO="0123456789abcdef";function Dv(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=qO[t>>4],e+=qO[t&15];return BigInt(e)}return Ae(n)}function Je(n,e){switch(typeof n){case"bigint":return V(n>=-kc&&n<=kc,"overflow",e||"value",n),Number(n);case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Je(BigInt(n),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}V(!1,"invalid numeric value",e||"value",n)}function PW(n){return Je(Dv(n))}function bo(n,e){let r=Xg(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Je(e,"width");for(ee(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function In(n){const e=Xg(n,"value");if(e===Yg)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function La(n){let e=we(Mv(n)?n:In(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const QO="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const YO=BigInt(58);function IW(n){const e=lt(n);let t=Dv(e),r="";for(;t;)r=QO[Number(t%YO)]+r,t/=YO;for(let s=0;s<e.length&&!e[s];s++)r=QO[0]+r;return r}function LW(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return lt(e)}function _W(n){const e=lt(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class XO{constructor(e,t,r){$(this,"filter");$(this,"emitter");q(this,$c);I(this,$c,t),Oe(this,{emitter:e,filter:r})}async removeListener(){T(this,$c)!=null&&await this.emitter.off(this.filter,T(this,$c))}}$c=new WeakMap;function BW(n,e,t,r,s){V(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ZO(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function FW(n,e,t,r,s){return n==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ZO(n,e,t))}const jW=Object.freeze({error:BW,ignore:ZO,replace:FW});function UW(n,e){e==null&&(e=jW.error);const t=lt(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function bi(n,e){V(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);V(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function HW(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Cc(n,e){return HW(UW(n,e))}function eR(n){async function e(t,r){ee(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();ee(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),ee(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=Nt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=Nt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const zW=12,VW=250;let tR=eR();const $W=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),WW=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pv=!1;async function nR(n,e){try{const t=n.match($W);if(!t)throw new Error("invalid data");return new wo(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?LW(t[3]):KW(t[3]))}catch{return new wo(599,"BAD REQUEST (invalid data: URI)",{},null,new Ln(n))}}function rR(n){async function e(t,r){try{const s=t.match(WW);if(!s)throw new Error("invalid link");return new Ln(`${n}${s[2]}`)}catch{return new wo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ln(t))}}return e}const Zg={data:nR,ipfs:rR("https://gateway.ipfs.io/ipfs/")},sR=new WeakMap;class GW{constructor(e){q(this,qa);q(this,To);I(this,qa,[]),I(this,To,!1),sR.set(e,()=>{if(!T(this,To)){I(this,To,!0);for(const t of T(this,qa))setTimeout(()=>{t()},0);I(this,qa,[])}})}addListener(e){ee(!T(this,To),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,qa).push(e)}get cancelled(){return T(this,To)}checkSignal(){ee(!this.cancelled,"cancelled","CANCELLED",{})}}qa=new WeakMap,To=new WeakMap;function em(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const $m=class $m{constructor(e){q(this,Za);q(this,Wc);q(this,Gc);q(this,us);q(this,Ti);q(this,Kc);q(this,Jc);q(this,fn);q(this,wr);q(this,Ni);q(this,Qa);q(this,Ya);q(this,Xa);q(this,$s);q(this,fs);q(this,No);I(this,Jc,String(e)),I(this,Wc,!1),I(this,Gc,!0),I(this,us,{}),I(this,Ti,""),I(this,Kc,3e5),I(this,fs,{slotInterval:VW,maxAttempts:zW}),I(this,No,null)}get url(){return T(this,Jc)}set url(e){I(this,Jc,String(e))}get body(){return T(this,fn)==null?null:new Uint8Array(T(this,fn))}set body(e){if(e==null)I(this,fn,void 0),I(this,wr,void 0);else if(typeof e=="string")I(this,fn,bi(e)),I(this,wr,"text/plain");else if(e instanceof Uint8Array)I(this,fn,e),I(this,wr,"application/octet-stream");else if(typeof e=="object")I(this,fn,bi(JSON.stringify(e))),I(this,wr,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,fn)!=null}get method(){return T(this,Ti)?T(this,Ti):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),I(this,Ti,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,us));return T(this,Ni)&&(e.authorization=`Basic ${_W(bi(T(this,Ni)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,wr)&&(e["content-type"]=T(this,wr)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,us)[String(e).toLowerCase()]=String(t)}clearHeaders(){I(this,us,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Ni)||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),I(this,Ni,`${e}:${t}`)}get allowGzip(){return T(this,Gc)}set allowGzip(e){I(this,Gc,!!e)}get allowInsecureAuthentication(){return!!T(this,Wc)}set allowInsecureAuthentication(e){I(this,Wc,!!e)}get timeout(){return T(this,Kc)}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),I(this,Kc,e)}get preflightFunc(){return T(this,Qa)||null}set preflightFunc(e){I(this,Qa,e)}get processFunc(){return T(this,Ya)||null}set processFunc(e){I(this,Ya,e)}get retryFunc(){return T(this,Xa)||null}set retryFunc(e){I(this,Xa,e)}get getUrlFunc(){return T(this,No)||tR}set getUrlFunc(e){I(this,No,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,fn)?we(T(this,fn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,fs).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,fs).maxAttempts=e.maxAttempts)}send(){return ee(T(this,$s)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),I(this,$s,new GW(this)),fe(this,Za,eh).call(this,0,iR()+this.timeout,0,this,new wo(0,"",{},null,this))}cancel(){ee(T(this,$s)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=sR.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();ee(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new $m(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,I(s,us,Object.assign({},T(this,us))),T(this,fn)&&I(s,fn,new Uint8Array(T(this,fn))),I(s,wr,T(this,wr)),s}clone(){const e=new $m(this.url);return I(e,Ti,T(this,Ti)),T(this,fn)&&I(e,fn,T(this,fn)),I(e,wr,T(this,wr)),I(e,us,Object.assign({},T(this,us))),I(e,Ni,T(this,Ni)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),I(e,Qa,T(this,Qa)),I(e,Ya,T(this,Ya)),I(e,Xa,T(this,Xa)),I(e,fs,Object.assign({},T(this,fs))),I(e,No,T(this,No)),e}static lockConfig(){Pv=!0}static getGateway(e){return Zg[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pv)throw new Error("gateways locked");Zg[e]=t}static registerGetUrl(e){if(Pv)throw new Error("gateways locked");tR=e}static createGetUrlFunc(e){return eR()}static createDataGateway(){return nR}static createIpfsGatewayFunc(e){return rR(e)}};Wc=new WeakMap,Gc=new WeakMap,us=new WeakMap,Ti=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,fn=new WeakMap,wr=new WeakMap,Ni=new WeakMap,Qa=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,$s=new WeakMap,fs=new WeakMap,No=new WeakMap,Za=new WeakSet,eh=async function(e,t,r,s,i){var u,f,d;if(e>=T(this,fs).maxAttempts)return i.makeServerError("exceeded maximum retry limit");ee(iR()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await JW(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Zg){const h=await Zg[a](o.url,em(T(s,$s)));if(h instanceof wo){let p=h;if(this.processFunc){em(T(s,$s));try{p=await this.processFunc(o,p)}catch(g){(g.throttle==null||typeof g.stall!="number")&&p.makeServerError("error in post-processing function",g).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,em(T(s,$s)));let c=new wo(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return fe(u=o.redirect(h),Za,eh).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),fe(f=o.clone(),Za,eh).call(f,e+1,t,p,s,c)}if(this.processFunc){em(T(s,$s));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),fe(d=o.clone(),Za,eh).call(d,e+1,t,p,s,c)}}return c};let Ln=$m;const G1=class G1{constructor(e,t,r,s,i){q(this,Fd);q(this,jd);q(this,Ud);q(this,vr);q(this,qc);q(this,el);I(this,Fd,e),I(this,jd,t),I(this,Ud,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),I(this,vr,s==null?null:new Uint8Array(s)),I(this,qc,i||null),I(this,el,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,vr)?we(T(this,vr)):"null"}>`}get statusCode(){return T(this,Fd)}get statusMessage(){return T(this,jd)}get headers(){return Object.assign({},T(this,Ud))}get body(){return T(this,vr)==null?null:new Uint8Array(T(this,vr))}get bodyText(){try{return T(this,vr)==null?"":Cc(T(this,vr))}catch{ee(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ee(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new G1(599,r,this.headers,this.body,T(this,qc)||void 0);return I(s,el,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw Oe(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,vr)!=null}get request(){return T(this,qc)}ok(){return T(this,el).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,el);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{T(this,vr)&&(s=Cc(T(this,vr)))}catch{}ee(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Fd=new WeakMap,jd=new WeakMap,Ud=new WeakMap,vr=new WeakMap,qc=new WeakMap,el=new WeakMap;let wo=G1;function iR(){return new Date().getTime()}function KW(n){return bi(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function JW(n){return new Promise(e=>setTimeout(e,n))}function qW(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function oR(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function aR(n,e,t,r){const s=[];for(;t<e+1+r;){const i=lR(n,t);s.push(i.result),t+=i.consumed,ee(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function lR(n,e){ee(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{ee(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=oR(n,e+1,r);return t(e+1+r+s),aR(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),aR(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=oR(n,e+1,r);t(e+1+r+s);const i=we(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=we(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:qW(n[e])}}function tm(n){const e=lt(n,"data"),t=lR(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function cR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function uR(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(uR(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=cR(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(lt(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=cR(e.length);return t.unshift(183+t.length),t.concat(e)}const fR="0123456789abcdef";function _a(n){let e="0x";for(const t of uR(n))e+=fR[t>>4],e+=fR[t&15];return e}const _n=32,Iv=new Uint8Array(_n),QW=["then"],nm={},dR=new WeakMap;function Ba(n){return dR.get(n)}function hR(n,e){dR.set(n,e)}function gd(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Lv(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof Sc?Lv(Ba(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof Sc&&(o=Lv(Ba(o),o,t)),r[s]=o),r},{})}const Yc=class Yc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==nm&&(s=t,i=[],o=!1);super(s.length);q(this,Qc);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(hR(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),I(this,Qc,[]),T(this,Qc)==null&&T(this,Qc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Je(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&gd(`index ${h}`,p),p}if(QW.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return hR(l,Ba(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&gd(`index ${i}`,s),t&&s instanceof Yc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=Ba(this);return r.reduce((s,i,o)=>(ee(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Lv(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=Ba(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Yc(nm,i,o)}filter(t,r){const s=Ba(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&gd(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Yc(nm,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&gd(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=Ba(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&gd(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Yc(nm,t,r)}};Qc=new WeakMap;let Sc=Yc;function pR(n){let e=In(n);return ee(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=Pn(Ut([Iv.slice(e.length%_n),e]))),e}class wi{constructor(e,t,r,s){$(this,"name");$(this,"type");$(this,"localName");$(this,"dynamic");Oe(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class _v{constructor(){q(this,Xc);q(this,Oi);q(this,tl);I(this,Oi,[]),I(this,tl,0)}get data(){return Ut(T(this,Oi))}get length(){return T(this,tl)}appendWriter(e){return fe(this,Xc,Ym).call(this,Pn(e.data))}writeBytes(e){let t=Pn(e);const r=t.length%_n;return r&&(t=Pn(Ut([t,Iv.slice(r)]))),fe(this,Xc,Ym).call(this,t)}writeValue(e){return fe(this,Xc,Ym).call(this,pR(e))}writeUpdatableValue(){const e=T(this,Oi).length;return T(this,Oi).push(Iv),I(this,tl,T(this,tl)+_n),t=>{T(this,Oi)[e]=pR(t)}}}Oi=new WeakMap,tl=new WeakMap,Xc=new WeakSet,Ym=function(e){return T(this,Oi).push(e),I(this,tl,T(this,tl)+e.length),e.length};const K1=class K1{constructor(e,t,r){q(this,sl);$(this,"allowLoose");q(this,er);q(this,xr);q(this,nl);q(this,rl);q(this,Oo);Oe(this,{allowLoose:!!t}),I(this,er,Pn(e)),I(this,nl,0),I(this,rl,null),I(this,Oo,r??1024),I(this,xr,0)}get data(){return we(T(this,er))}get dataLength(){return T(this,er).length}get consumed(){return T(this,xr)}get bytes(){return new Uint8Array(T(this,er))}subReader(e){const t=new K1(T(this,er).slice(T(this,xr)+e),this.allowLoose,T(this,Oo));return I(t,rl,this),t}readBytes(e,t){let r=fe(this,sl,eP).call(this,0,e,!!t);return fe(this,sl,nx).call(this,e),I(this,xr,T(this,xr)+r.length),r.slice(0,e)}readValue(){return Dv(this.readBytes(_n))}readIndex(){return PW(this.readBytes(_n))}};er=new WeakMap,xr=new WeakMap,nl=new WeakMap,rl=new WeakMap,Oo=new WeakMap,sl=new WeakSet,nx=function(e){var t;if(T(this,rl))return fe(t=T(this,rl),sl,nx).call(t,e);I(this,nl,T(this,nl)+e),ee(T(this,Oo)<1||T(this,nl)<=T(this,Oo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Oo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Pn(T(this,er)),offset:T(this,xr),length:e,info:{bytesRead:T(this,nl),dataLength:this.dataLength}})},eP=function(e,t,r){let s=Math.ceil(t/_n)*_n;return T(this,xr)+s>T(this,er).length&&(this.allowLoose&&r&&T(this,xr)+t<=T(this,er).length?s=t:ee(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Pn(T(this,er)),length:T(this,er).length,offset:T(this,xr)+s})),T(this,er).slice(T(this,xr),T(this,xr)+s)};let Bv=K1;function rm(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Fv(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function YW(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rm(n.outputLen),rm(n.blockLen)}function Tc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function gR(n,e){Fv(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const jv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mR=n=>n instanceof Uint8Array,XW=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uv=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hs=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function ZW(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function sm(n){if(typeof n=="string"&&(n=ZW(n)),!mR(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function e7(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!mR(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hv{clone(){return this._cloneInto()}}function zv(n){const e=r=>n().update(sm(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function t7(n=32){if(jv&&typeof jv.getRandomValues=="function")return jv.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class yR extends Hv{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,YW(e);const r=sm(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tc(this),this.iHash.update(e),this}digestInto(e){Tc(this),Fv(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bR=(n,e,t)=>new yR(n,e).update(t).digest();bR.create=(n,e)=>new yR(n,e);function n7(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class wR extends Hv{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uv(this.buffer)}update(e){Tc(this);const{view:t,buffer:r,blockLen:s}=this;e=sm(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uv(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tc(this),gR(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;n7(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uv(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const r7=(n,e,t)=>n&e^~n&t,s7=(n,e,t)=>n&e^n&t^e&t,i7=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xo=new Uint32Array(64);class o7 extends wR{constructor(){super(64,32,8,!1),this.A=vo[0]|0,this.B=vo[1]|0,this.C=vo[2]|0,this.D=vo[3]|0,this.E=vo[4]|0,this.F=vo[5]|0,this.G=vo[6]|0,this.H=vo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)xo[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=xo[f-15],h=xo[f-2],p=Hs(d,7)^Hs(d,18)^d>>>3,g=Hs(h,17)^Hs(h,19)^h>>>10;xo[f]=g+xo[f-7]+p+xo[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Hs(a,6)^Hs(a,11)^Hs(a,25),h=u+d+r7(a,l,c)+i7[f]+xo[f]|0,g=(Hs(r,2)^Hs(r,13)^Hs(r,22))+s7(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+g|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){xo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const vR=zv(()=>new o7),im=BigInt(2**32-1),Vv=BigInt(32);function xR(n,e=!1){return e?{h:Number(n&im),l:Number(n>>Vv&im)}:{h:Number(n>>Vv&im)|0,l:Number(n&im)|0}}function AR(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xR(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const a7=(n,e)=>BigInt(n>>>0)<<Vv|BigInt(e>>>0),l7=(n,e,t)=>n>>>t,c7=(n,e,t)=>n<<32-t|e>>>t,u7=(n,e,t)=>n>>>t|e<<32-t,f7=(n,e,t)=>n<<32-t|e>>>t,d7=(n,e,t)=>n<<64-t|e>>>t-32,h7=(n,e,t)=>n>>>t-32|e<<64-t,p7=(n,e)=>e,g7=(n,e)=>n,ER=(n,e,t)=>n<<t|e>>>32-t,kR=(n,e,t)=>e<<t|n>>>32-t,CR=(n,e,t)=>e<<t-32|n>>>64-t,SR=(n,e,t)=>n<<t-32|e>>>64-t;function m7(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Xe={fromBig:xR,split:AR,toBig:a7,shrSH:l7,shrSL:c7,rotrSH:u7,rotrSL:f7,rotrBH:d7,rotrBL:h7,rotr32H:p7,rotr32L:g7,rotlSH:ER,rotlSL:kR,rotlBH:CR,rotlBL:SR,add:m7,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[y7,b7]=Xe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Ao=new Uint32Array(80),Eo=new Uint32Array(80);class w7 extends wR{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:g,Hl:b}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,b]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,b){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=p|0,this.Hh=g|0,this.Hl=b|0}process(e,t){for(let v=0;v<16;v++,t+=4)Ao[v]=e.getUint32(t),Eo[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){const w=Ao[v-15]|0,E=Eo[v-15]|0,k=Xe.rotrSH(w,E,1)^Xe.rotrSH(w,E,8)^Xe.shrSH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add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Xe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:g,l:b}=Xe.add(this.Gh|0,this.Gl|0,g|0,b|0),{h:y,l:A}=Xe.add(this.Hh|0,this.Hl|0,y|0,A|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,g,b,y,A)}roundClean(){Ao.fill(0),Eo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const v7=zv(()=>new w7);function x7(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const TR=x7();TR.crypto||TR.msCrypto;function A7(n){switch(n){case"sha256":return vR.create();case"sha512":return v7.create()}V(!1,"invalid hashing algorithm name","algorithm",n)}const[NR,OR,RR]=[[],[],[]],E7=BigInt(0),md=BigInt(1),k7=BigInt(2),C7=BigInt(7),S7=BigInt(256),T7=BigInt(113);for(let n=0,e=md,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],NR.push(2*(5*r+t)),OR.push((n+1)*(n+2)/2%64);let s=E7;for(let i=0;i<7;i++)e=(e<<md^(e>>C7)*T7)%S7,e&k7&&(s^=md<<(md<<BigInt(i))-md);RR.push(s)}const[N7,O7]=AR(RR,!0),MR=(n,e,t)=>t>32?CR(n,e,t):ER(n,e,t),DR=(n,e,t)=>t>32?SR(n,e,t):kR(n,e,t);function R7(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=MR(c,u,1)^t[a],d=DR(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=OR[o],l=MR(s,i,a),c=DR(s,i,a),u=NR[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=N7[r],n[1]^=O7[r]}t.fill(0)}class $v extends Hv{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rm(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=XW(this.state)}keccak(){R7(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Tc(this);const{blockLen:t,state:r}=this;e=sm(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Tc(this,!1),Fv(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rm(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gR(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $v(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const M7=((n,e,t)=>zv(()=>new $v(e,n,t)))(1,136,256/8);let PR=!1;const IR=function(n){return M7(n)};let LR=IR;function Jt(n){const e=lt(n,"data");return we(LR(e))}Jt._=IR,Jt.lock=function(){PR=!0},Jt.register=function(n){if(PR)throw new TypeError("keccak256 is locked");LR=n},Object.freeze(Jt);const _R=function(n){return A7("sha256").update(n).digest()};let BR=_R,FR=!1;function Nc(n){const e=lt(n,"data");return we(BR(e))}Nc._=_R,Nc.lock=function(){FR=!0},Nc.register=function(n){if(FR)throw new Error("sha256 is locked");BR=n},Object.freeze(Nc),Object.freeze(Nc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jR=BigInt(0),om=BigInt(1),D7=BigInt(2),am=n=>n instanceof Uint8Array,P7=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Oc(n){if(!am(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=P7[n[t]];return e}function UR(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Wv(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Rc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Fa(n){return Wv(Oc(n))}function Gv(n){if(!am(n))throw new Error("Uint8Array expected");return Wv(Oc(Uint8Array.from(n).reverse()))}function Mc(n,e){return Rc(n.toString(16).padStart(e*2,"0"))}function Kv(n,e){return Mc(n,e).reverse()}function I7(n){return Rc(UR(n))}function is(n,e,t){let r;if(typeof e=="string")try{r=Rc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(am(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function yd(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!am(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function L7(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function _7(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function B7(n){let e;for(e=0;n>jR;n>>=om,e+=1);return e}function F7(n,e){return n>>BigInt(e)&om}const j7=(n,e,t)=>n|(t?om:jR)<<BigInt(e),Jv=n=>(D7<<BigInt(n-1))-om,qv=n=>new Uint8Array(n),HR=n=>Uint8Array.from(n);function zR(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=qv(n),s=qv(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=qv())=>{s=a(HR([0]),f),r=a(),f.length!==0&&(s=a(HR([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return yd(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const U7={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function bd(n,e,t={}){const r=(s,i,o)=>{const a=U7[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const H7=Object.freeze(Object.defineProperty({__proto__:null,bitGet:F7,bitLen:B7,bitMask:Jv,bitSet:j7,bytesToHex:Oc,bytesToNumberBE:Fa,bytesToNumberLE:Gv,concatBytes:yd,createHmacDrbg:zR,ensureBytes:is,equalBytes:L7,hexToBytes:Rc,hexToNumber:Wv,numberToBytesBE:Mc,numberToBytesLE:Kv,numberToHexUnpadded:UR,numberToVarBytesBE:I7,utf8ToBytes:_7,validateObject:bd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cn=BigInt(0),Ht=BigInt(1),ja=BigInt(2),z7=BigInt(3),Qv=BigInt(4),VR=BigInt(5),$R=BigInt(8);BigInt(9),BigInt(16);function Yn(n,e){const t=n%e;return t>=cn?t:e+t}function V7(n,e,t){if(t<=cn||e<cn)throw new Error("Expected power/modulo > 0");if(t===Ht)return cn;let r=Ht;for(;e>cn;)e&Ht&&(r=r*n%t),n=n*n%t,e>>=Ht;return r}function _r(n,e,t){let r=n;for(;e-- >cn;)r*=r,r%=t;return r}function Yv(n,e){if(n===cn||e<=cn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Yn(n,e),r=e,s=cn,i=Ht;for(;t!==cn;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Ht)throw new Error("invert: does not exist");return Yn(s,e)}function $7(n){const e=(n-Ht)/ja;let t,r,s;for(t=n-Ht,r=0;t%ja===cn;t/=ja,r++);for(s=ja;s<n&&V7(s,e,n)!==n-Ht;s++);if(r===1){const o=(n+Ht)/Qv;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Ht)/ja;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let g=a.sqr(d);h<c&&!a.eql(g,a.ONE);h++)g=a.sqr(g);const p=a.pow(u,Ht<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function W7(n){if(n%Qv===z7){const e=(n+Ht)/Qv;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%$R===VR){const e=(n-VR)/$R;return function(r,s){const i=r.mul(s,ja),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,ja),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return $7(n)}const G7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function K7(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=G7.reduce((r,s)=>(r[s]="function",r),e);return bd(n,t)}function J7(n,e,t){if(t<cn)throw new Error("Expected power > 0");if(t===cn)return n.ONE;if(t===Ht)return e;let r=n.ONE,s=e;for(;t>cn;)t&Ht&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Ht;return r}function q7(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function WR(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Q7(n,e,t=!1,r={}){if(n<=cn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=WR(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=W7(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Jv(s),ZERO:cn,ONE:Ht,create:l=>Yn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return cn<=l&&l<n},is0:l=>l===cn,isOdd:l=>(l&Ht)===Ht,neg:l=>Yn(-l,n),eql:(l,c)=>l===c,sqr:l=>Yn(l*l,n),add:(l,c)=>Yn(l+c,n),sub:(l,c)=>Yn(l-c,n),mul:(l,c)=>Yn(l*c,n),pow:(l,c)=>J7(a,l,c),div:(l,c)=>Yn(l*Yv(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Yv(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>q7(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Kv(l,i):Mc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Gv(l):Fa(l)}});return Object.freeze(a)}function GR(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function KR(n){const e=GR(n);return e+Math.ceil(e/2)}function Y7(n,e,t=!1){const r=n.length,s=GR(e),i=KR(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Fa(n):Gv(n),a=Yn(o,e-Ht)+Ht;return t?Kv(a,s):Mc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const X7=BigInt(0),Xv=BigInt(1);function Z7(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>X7;)i&Xv&&(o=o.add(a)),a=a.double(),i>>=Xv;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const g=p*l;let b=Number(o&f);o>>=h,b>l&&(b-=d,o+=Xv);const y=g,A=g+Math.abs(b)-1,v=p%2!==0,w=b<0;b===0?u=u.add(t(v,i[y])):c=c.add(t(w,i[A]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function JR(n){return K7(n.Fp),bd(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...WR(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eG(n){const e=JR(n);bd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:tG,hexToBytes:nG}=H7,Ua={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ua;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:tG(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ua,t=typeof n=="string"?nG(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ua._parseInt(t.subarray(2)),{d:o,l:a}=Ua._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},vi=BigInt(0),Br=BigInt(1);BigInt(2);const qR=BigInt(3);BigInt(4);function rG(n){const e=eG(n),{Fp:t}=e,r=e.toBytes||((p,g,b)=>{const y=g.toAffine();return yd(Uint8Array.from([4]),t.toBytes(y.x),t.toBytes(y.y))}),s=e.fromBytes||(p=>{const g=p.subarray(1),b=t.fromBytes(g.subarray(0,t.BYTES)),y=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:b,y}});function i(p){const{a:g,b}=e,y=t.sqr(p),A=t.mul(y,p);return t.add(t.add(A,t.mul(p,g)),b)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&vi<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:g,nByteLength:b,wrapPrivateKey:y,n:A}=e;if(g&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=Oc(p)),typeof p!="string"||!g.includes(p.length))throw new Error("Invalid key");p=p.padStart(b*2,"0")}let v;try{v=typeof p=="bigint"?p:Fa(is("private key",p,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof p}`)}return y&&(v=Yn(v,A)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(g,b,y){if(this.px=g,this.py=b,this.pz=y,g==null||!t.isValid(g))throw new Error("x required");if(b==null||!t.isValid(b))throw new Error("y required");if(y==null||!t.isValid(y))throw new Error("z required")}static fromAffine(g){const{x:b,y}=g||{};if(!g||!t.isValid(b)||!t.isValid(y))throw new Error("invalid affine point");if(g instanceof f)throw new Error("projective point not allowed");const A=v=>t.eql(v,t.ZERO);return A(b)&&A(y)?f.ZERO:new f(b,y,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const b=t.invertBatch(g.map(y=>y.pz));return g.map((y,A)=>y.toAffine(b[A])).map(f.fromAffine)}static fromHex(g){const b=f.fromAffine(s(is("pointHex",g)));return b.assertValidity(),b}static fromPrivateKey(g){return f.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:b}=this.toAffine();if(!t.isValid(g)||!t.isValid(b))throw new Error("bad point: x or y not FE");const y=t.sqr(b),A=i(g);if(!t.eql(y,A))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){u(g);const{px:b,py:y,pz:A}=this,{px:v,py:w,pz:E}=g,k=t.eql(t.mul(b,E),t.mul(v,A)),S=t.eql(t.mul(y,E),t.mul(w,A));return k&&S}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:g,b}=e,y=t.mul(b,qR),{px:A,py:v,pz:w}=this;let E=t.ZERO,k=t.ZERO,S=t.ZERO,M=t.mul(A,A),O=t.mul(v,v),R=t.mul(w,w),D=t.mul(A,v);return D=t.add(D,D),S=t.mul(A,w),S=t.add(S,S),E=t.mul(g,S),k=t.mul(y,R),k=t.add(E,k),E=t.sub(O,k),k=t.add(O,k),k=t.mul(E,k),E=t.mul(D,E),S=t.mul(y,S),R=t.mul(g,R),D=t.sub(M,R),D=t.mul(g,D),D=t.add(D,S),S=t.add(M,M),M=t.add(S,M),M=t.add(M,R),M=t.mul(M,D),k=t.add(k,M),R=t.mul(v,w),R=t.add(R,R),M=t.mul(R,D),E=t.sub(E,M),S=t.mul(R,O),S=t.add(S,S),S=t.add(S,S),new f(E,k,S)}add(g){u(g);const{px:b,py:y,pz:A}=this,{px:v,py:w,pz:E}=g;let k=t.ZERO,S=t.ZERO,M=t.ZERO;const O=e.a,R=t.mul(e.b,qR);let D=t.mul(b,v),F=t.mul(y,w),U=t.mul(A,E),K=t.add(b,y),_=t.add(v,w);K=t.mul(K,_),_=t.add(D,F),K=t.sub(K,_),_=t.add(b,A);let G=t.add(v,E);return _=t.mul(_,G),G=t.add(D,U),_=t.sub(_,G),G=t.add(y,A),k=t.add(w,E),G=t.mul(G,k),k=t.add(F,U),G=t.sub(G,k),M=t.mul(O,_),k=t.mul(R,U),M=t.add(k,M),k=t.sub(F,M),M=t.add(F,M),S=t.mul(k,M),F=t.add(D,D),F=t.add(F,D),U=t.mul(O,U),_=t.mul(R,_),F=t.add(F,U),U=t.sub(D,U),U=t.mul(O,U),_=t.add(_,U),D=t.mul(F,_),S=t.add(S,D),D=t.mul(G,_),k=t.mul(K,k),k=t.sub(k,D),D=t.mul(K,F),M=t.mul(G,M),M=t.add(M,D),new f(k,S,M)}subtract(g){return this.add(g.negate())}is0(){return this.equals(f.ZERO)}wNAF(g){return h.wNAFCached(this,c,g,b=>{const y=t.invertBatch(b.map(A=>A.pz));return b.map((A,v)=>A.toAffine(y[v])).map(f.fromAffine)})}multiplyUnsafe(g){const b=f.ZERO;if(g===vi)return b;if(a(g),g===Br)return this;const{endo:y}=e;if(!y)return h.unsafeLadder(this,g);let{k1neg:A,k1:v,k2neg:w,k2:E}=y.splitScalar(g),k=b,S=b,M=this;for(;v>vi||E>vi;)v&Br&&(k=k.add(M)),E&Br&&(S=S.add(M)),M=M.double(),v>>=Br,E>>=Br;return A&&(k=k.negate()),w&&(S=S.negate()),S=new f(t.mul(S.px,y.beta),S.py,S.pz),k.add(S)}multiply(g){a(g);let b=g,y,A;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:k,k2:S}=v.splitScalar(b);let{p:M,f:O}=this.wNAF(E),{p:R,f:D}=this.wNAF(S);M=h.constTimeNegate(w,M),R=h.constTimeNegate(k,R),R=new f(t.mul(R.px,v.beta),R.py,R.pz),y=M.add(R),A=O.add(D)}else{const{p:w,f:E}=this.wNAF(b);y=w,A=E}return f.normalizeZ([y,A])[0]}multiplyAndAddUnsafe(g,b,y){const A=f.BASE,v=(E,k)=>k===vi||k===Br||!E.equals(A)?E.multiplyUnsafe(k):E.multiply(k),w=v(this,b).add(v(g,y));return w.is0()?void 0:w}toAffine(g){const{px:b,py:y,pz:A}=this,v=this.is0();g==null&&(g=v?t.ONE:t.inv(A));const w=t.mul(b,g),E=t.mul(y,g),k=t.mul(A,g);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:g,isTorsionFree:b}=e;if(g===Br)return!0;if(b)return b(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:b}=e;return g===Br?this:b?b(f,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),r(f,this,g)}toHex(g=!0){return Oc(this.toRawBytes(g))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=Z7(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function sG(n){const e=JR(n);return bd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iG(n){const e=sG(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(_){return vi<_&&_<t.ORDER}function a(_){return Yn(_,r)}function l(_){return Yv(_,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=rG({...e,toBytes(_,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),ge=yd;return Y?ge(Uint8Array.from([G.hasEvenY()?2:3]),Z):ge(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(_){const G=_.length,Y=_[0],re=_.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Fa(re);if(!o(Z))throw new Error("Point is not on curve");const ge=f(Z);let ke=t.sqrt(ge);const Pe=(ke&Br)===Br;return(Y&1)===1!==Pe&&(ke=t.neg(ke)),{x:Z,y:ke}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),ge=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:ge}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>Oc(Mc(_,e.nByteLength));function p(_){const G=r>>Br;return _>G}function g(_){return p(_)?a(-_):_}const b=(_,G,Y)=>Fa(_.slice(G,Y));class y{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=is("compactSignature",G,Y*2),new y(b(G,0,Y),b(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ua.toSig(is("DER",G));return new y(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new y(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,ge=S(is("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const ke=Z===2||Z===3?Y+e.n:Y;if(ke>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Pe=Z&1?"03":"02",Ce=c.fromHex(Pe+h(ke)),Ee=l(ke),Ue=a(-ge*Ee),Fe=a(re*Ee),He=c.BASE.multiplyAndAddUnsafe(Ce,Ue,Fe);if(!He)throw new Error("point at infinify");return He.assertValidity(),He}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rc(this.toDERHex())}toDERHex(){return Ua.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const A={isValidPrivateKey(_){try{return u(_),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const _=KR(e.n);return Y7(e.randomBytes(_),e.n)},precompute(_=8,G=c.BASE){return G._setWindowSize(_),G.multiply(BigInt(3)),G}};function v(_,G=!0){return c.fromPrivateKey(_).toRawBytes(G)}function w(_){const G=_ instanceof Uint8Array,Y=typeof _=="string",re=(G||Y)&&_.length;return G?re===s||re===i:Y?re===2*s||re===2*i:_ instanceof c}function E(_,G,Y=!0){if(w(_))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(_)).toRawBytes(Y)}const k=e.bits2int||function(_){const G=Fa(_),Y=_.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},S=e.bits2int_modN||function(_){return a(k(_))},M=Jv(e.nBitLength);function O(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(vi<=_&&_<M))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Mc(_,e.nByteLength)}function R(_,G,Y=D){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:ge,prehash:ke,extraEntropy:Pe}=Y;ge==null&&(ge=!0),_=is("msgHash",_),ke&&(_=is("prehashed msgHash",re(_)));const Ce=S(_),Ee=u(G),Ue=[O(Ee),O(Ce)];if(Pe!=null){const Ze=Pe===!0?Z(t.BYTES):Pe;Ue.push(is("extraEntropy",Ze))}const Fe=yd(...Ue),He=Ce;function Le(Ze){const le=k(Ze);if(!d(le))return;const ze=l(le),ae=c.BASE.multiply(le).toAffine(),be=a(ae.x);if(be===vi)return;const _e=a(ze*a(He+be*Ee));if(_e===vi)return;let z=(ae.x===be?0:2)|Number(ae.y&Br),J=_e;return ge&&p(_e)&&(J=g(_e),z^=1),new y(be,J,z)}return{seed:Fe,k2sig:Le}}const D={lowS:e.lowS,prehash:!1},F={lowS:e.lowS,prehash:!1};function U(_,G,Y=D){const{seed:re,k2sig:Z}=R(_,G,Y),ge=e;return zR(ge.hash.outputLen,ge.nByteLength,ge.hmac)(re,Z)}c.BASE._setWindowSize(8);function K(_,G,Y,re=F){var ae;const Z=_;if(G=is("msgHash",G),Y=is("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:ge,prehash:ke}=re;let Pe,Ce;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{Pe=y.fromDER(Z)}catch(be){if(!(be instanceof Ua.Err))throw be;Pe=y.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:be,s:_e}=Z;Pe=new y(be,_e)}else throw new Error("PARSE");Ce=c.fromHex(Y)}catch(be){if(be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ge&&Pe.hasHighS())return!1;ke&&(G=e.hash(G));const{r:Ee,s:Ue}=Pe,Fe=S(G),He=l(Ue),Le=a(Fe*He),Ze=a(Ee*He),le=(ae=c.BASE.multiplyAndAddUnsafe(Ce,Le,Ze))==null?void 0:ae.toAffine();return le?a(le.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:U,verify:K,ProjectivePoint:c,Signature:y,utils:A}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oG(n){return{hash:n,hmac:(e,...t)=>bR(n,e,e7(...t)),randomBytes:t7}}function aG(n,e){const t=r=>iG({...n,...oG(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const QR=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),YR=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lG=BigInt(1),Zv=BigInt(2),XR=(n,e)=>(n+e/Zv)/e;function cG(n){const e=QR,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=_r(u,t,e)*u%e,d=_r(f,t,e)*u%e,h=_r(d,Zv,e)*c%e,p=_r(h,s,e)*h%e,g=_r(p,i,e)*p%e,b=_r(g,a,e)*g%e,y=_r(b,l,e)*b%e,A=_r(y,a,e)*g%e,v=_r(A,t,e)*u%e,w=_r(v,o,e)*p%e,E=_r(w,r,e)*c%e,k=_r(E,Zv,e);if(!e1.eql(e1.sqr(k),n))throw new Error("Cannot find square root");return k}const e1=Q7(QR,void 0,void 0,{sqrt:cG}),ko=aG({a:BigInt(0),b:BigInt(7),Fp:e1,n:YR,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=YR,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-lG*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=XR(i*n,e),l=XR(-r*n,e);let c=Yn(n-a*t-l*s,e),u=Yn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},vR);BigInt(0),ko.ProjectivePoint;const wd="0x0000000000000000000000000000000000000000",ZR="0x0000000000000000000000000000000000000000000000000000000000000000",eM=BigInt(0),tM=BigInt(1),nM=BigInt(2),rM=BigInt(27),sM=BigInt(28),lm=BigInt(35),Dc={};function iM(n){return Ia(In(n),32)}const ds=class ds{constructor(e,t,r,s){q(this,Zc);q(this,eu);q(this,tu);q(this,il);Qg(e,Dc,"Signature"),I(this,Zc,t),I(this,eu,r),I(this,tu,s),I(this,il,null)}get r(){return T(this,Zc)}set r(e){V(Ec(e)===32,"invalid r","value",e),I(this,Zc,we(e))}get s(){return T(this,eu)}set s(e){V(Ec(e)===32,"invalid s","value",e);const t=we(e);V(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),I(this,eu,t)}get v(){return T(this,tu)}set v(e){const t=Je(e,"value");V(t===27||t===28,"invalid v","v",e),I(this,tu,t)}get networkV(){return T(this,il)}get legacyChainId(){const e=this.networkV;return e==null?null:ds.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),we(e)}get compactSerialized(){return Ut([this.r,this.yParityAndS])}get serialized(){return Ut([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ds(Dc,this.r,this.s,this.v);return this.networkV&&I(e,il,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Ae(e,"v");return t==rM||t==sM?eM:(V(t>=lm,"invalid EIP-155 v","v",e),(t-lm)/nM)}static getChainIdV(e,t){return Ae(e)*nM+BigInt(35+t-27)}static getNormalizedV(e){const t=Ae(e);return t===eM||t===rM?27:t===tM||t===sM?28:(V(t>=lm,"invalid v","v",e),t&tM?27:28)}static from(e){function t(c,u){V(c,u,"signature",e)}if(e==null)return new ds(Dc,ZR,ZR,27);if(typeof e=="string"){const c=lt(e,"signature");if(c.length===64){const u=we(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new ds(Dc,u,we(f),d)}if(c.length===65){const u=we(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=ds.getNormalizedV(c[64]);return new ds(Dc,u,we(f),d)}t(!1,"invalid raw signature length")}if(e instanceof ds)return e.clone();const r=e.r;t(r!=null,"missing r");const s=iM(r),i=function(c,u){if(c!=null)return iM(c);if(u!=null){t(At(u,32),"invalid yParityAndS");const f=lt(u);return f[0]&=127,we(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((lt(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=Ae(c);return{networkV:d>=lm?d:void 0,v:ds.getNormalizedV(d)}}if(u!=null)return t(At(u,32),"invalid yParityAndS"),{v:lt(u)[0]&128?28:27};if(f!=null){switch(Je(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new ds(Dc,s,i,a);return o&&I(l,il,o),t(e.yParity==null||Je(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Zc=new WeakMap,eu=new WeakMap,tu=new WeakMap,il=new WeakMap;let as=ds;const ol=class ol{constructor(e){q(this,Ri);V(Ec(e)===32,"invalid private key","privateKey","[REDACTED]"),I(this,Ri,we(e))}get privateKey(){return T(this,Ri)}get publicKey(){return ol.computePublicKey(T(this,Ri))}get compressedPublicKey(){return ol.computePublicKey(T(this,Ri),!0)}sign(e){V(Ec(e)===32,"invalid digest length","digest",e);const t=ko.sign(Pn(e),Pn(T(this,Ri)),{lowS:!0});return as.from({r:bo(t.r,32),s:bo(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=ol.computePublicKey(e);return we(ko.getSharedSecret(Pn(T(this,Ri)),lt(t),!1))}static computePublicKey(e,t){let r=lt(e,"key");if(r.length===32){const i=ko.getPublicKey(r,!!t);return we(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=ko.ProjectivePoint.fromHex(r);return we(s.toRawBytes(t))}static recoverPublicKey(e,t){V(Ec(e)===32,"invalid digest length","digest",e);const r=as.from(t);let s=ko.Signature.fromCompact(Pn(Ut([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Pn(e));return V(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=ko.ProjectivePoint.fromHex(ol.computePublicKey(e).substring(2)),i=ko.ProjectivePoint.fromHex(ol.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};Ri=new WeakMap;let vd=ol;const uG=BigInt(0),fG=BigInt(36);function oM(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=lt(Jt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const t1={};for(let n=0;n<10;n++)t1[String(n)]=String(n);for(let n=0;n<26;n++)t1[String.fromCharCode(65+n)]=String(10+n);const aM=15;function dG(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>t1[r]).join("");for(;e.length>=aM;){let r=e.substring(0,aM);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const hG=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function pG(n){n=n.toLowerCase();let e=uG;for(let t=0;t<n.length;t++)e=e*fG+hG[n[t]];return e}function dt(n){if(V(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=oM(n);return V(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(n.substring(2,4)===dG(n),"bad icap checksum","address",n);let e=pG(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return oM("0x"+e)}V(!1,"invalid address","address",n)}function gG(n){const e=dt(n.from);let r=Ae(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,dt(Ft(Jt(_a([e,r])),12))}function lM(n){return n&&typeof n.getAddress=="function"}function mG(n){try{return dt(n),!0}catch{}return!1}async function n1(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ee(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),dt(t)}function Bn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?dt(n):(ee(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),n1(n,e.resolveName(n)));if(lM(n))return n1(n,n.getAddress());if(n&&typeof n.then=="function")return n1(n,n);V(!1,"unsupported addressable value","target",n)}const xi={};function ve(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new En(xi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function ut(n,e){return new En(xi,`bytes${e||""}`,n,{size:e})}const cM=Symbol.for("_ethers_typed"),Mi=class Mi{constructor(e,t,r,s){$(this,"type");$(this,"value");q(this,al);$(this,"_typedSymbol");s==null&&(s=null),Qg(xi,e,"Typed"),Oe(this,{_typedSymbol:cM,type:t,value:r}),I(this,al,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,al)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,al)===!0?-1:T(this,al)===!1?this.value.length:null}static from(e,t){return new Mi(xi,e,t)}static uint8(e){return ve(e,8)}static uint16(e){return ve(e,16)}static uint24(e){return ve(e,24)}static uint32(e){return ve(e,32)}static uint40(e){return ve(e,40)}static uint48(e){return ve(e,48)}static uint56(e){return ve(e,56)}static uint64(e){return ve(e,64)}static uint72(e){return ve(e,72)}static uint80(e){return ve(e,80)}static uint88(e){return ve(e,88)}static uint96(e){return ve(e,96)}static uint104(e){return ve(e,104)}static uint112(e){return ve(e,112)}static uint120(e){return ve(e,120)}static uint128(e){return ve(e,128)}static uint136(e){return ve(e,136)}static uint144(e){return ve(e,144)}static uint152(e){return ve(e,152)}static uint160(e){return ve(e,160)}static uint168(e){return ve(e,168)}static uint176(e){return ve(e,176)}static uint184(e){return ve(e,184)}static uint192(e){return ve(e,192)}static uint200(e){return ve(e,200)}static uint208(e){return ve(e,208)}static uint216(e){return ve(e,216)}static uint224(e){return ve(e,224)}static uint232(e){return ve(e,232)}static uint240(e){return ve(e,240)}static uint248(e){return ve(e,248)}static uint256(e){return ve(e,256)}static uint(e){return ve(e,256)}static int8(e){return ve(e,-8)}static int16(e){return ve(e,-16)}static int24(e){return ve(e,-24)}static int32(e){return ve(e,-32)}static int40(e){return ve(e,-40)}static int48(e){return ve(e,-48)}static int56(e){return ve(e,-56)}static int64(e){return ve(e,-64)}static int72(e){return ve(e,-72)}static int80(e){return ve(e,-80)}static int88(e){return ve(e,-88)}static int96(e){return ve(e,-96)}static int104(e){return ve(e,-104)}static int112(e){return ve(e,-112)}static int120(e){return ve(e,-120)}static int128(e){return ve(e,-128)}static int136(e){return ve(e,-136)}static int144(e){return ve(e,-144)}static int152(e){return ve(e,-152)}static int160(e){return ve(e,-160)}static int168(e){return ve(e,-168)}static int176(e){return ve(e,-176)}static int184(e){return ve(e,-184)}static int192(e){return ve(e,-192)}static int200(e){return ve(e,-200)}static int208(e){return ve(e,-208)}static int216(e){return ve(e,-216)}static int224(e){return ve(e,-224)}static int232(e){return ve(e,-232)}static int240(e){return ve(e,-240)}static int248(e){return ve(e,-248)}static int256(e){return ve(e,-256)}static int(e){return ve(e,-256)}static bytes1(e){return ut(e,1)}static bytes2(e){return ut(e,2)}static bytes3(e){return ut(e,3)}static bytes4(e){return ut(e,4)}static bytes5(e){return ut(e,5)}static bytes6(e){return ut(e,6)}static bytes7(e){return ut(e,7)}static bytes8(e){return ut(e,8)}static bytes9(e){return ut(e,9)}static bytes10(e){return ut(e,10)}static bytes11(e){return ut(e,11)}static bytes12(e){return ut(e,12)}static bytes13(e){return ut(e,13)}static bytes14(e){return ut(e,14)}static bytes15(e){return ut(e,15)}static bytes16(e){return ut(e,16)}static bytes17(e){return ut(e,17)}static bytes18(e){return ut(e,18)}static bytes19(e){return ut(e,19)}static bytes20(e){return ut(e,20)}static bytes21(e){return ut(e,21)}static bytes22(e){return ut(e,22)}static bytes23(e){return ut(e,23)}static bytes24(e){return ut(e,24)}static bytes25(e){return ut(e,25)}static bytes26(e){return ut(e,26)}static bytes27(e){return ut(e,27)}static bytes28(e){return ut(e,28)}static bytes29(e){return ut(e,29)}static bytes30(e){return ut(e,30)}static bytes31(e){return ut(e,31)}static bytes32(e){return ut(e,32)}static address(e){return new Mi(xi,"address",e)}static bool(e){return new Mi(xi,"bool",!!e)}static bytes(e){return new Mi(xi,"bytes",e)}static string(e){return new Mi(xi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Mi(xi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===cM}static dereference(e,t){if(Mi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};al=new WeakMap;let En=Mi;class yG extends wi{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=En.dereference(t,"string");try{r=dt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return dt(bo(e.readValue(),20))}}class bG extends wi{constructor(t){super(t.name,t.type,"_",t.dynamic);$(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function uM(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return ee(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),ee(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _v,i=new _v,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function fM(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(ln(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(ln(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Sc.fromItems(t,r)}class wG extends wi{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);$(this,"coder");$(this,"length");Oe(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=En.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),$O(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return uM(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),ee(r*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*_n,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new bG(this.coder));return fM(t,s)}}class vG extends wi{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=En.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class dM extends wi{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Pn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class xG extends dM{constructor(e){super("bytes",e)}decode(e){return we(super.decode(e))}}class AG extends wi{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);$(this,"size");Oe(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Pn(En.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return we(t.readBytes(this.size))}}const EG=new Uint8Array([]);class kG extends wi{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(EG)}decode(e){return e.readBytes(0),null}}const CG=BigInt(0),SG=BigInt(1),TG=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class NG extends wi{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);$(this,"size");$(this,"signed");Oe(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Ae(En.dereference(r,this.type)),i=pd(TG,_n*8);if(this.signed){let o=pd(i,this.size*8-1);(s>o||s<-(o+SG))&&this._throwError("value out-of-bounds",r),s=JO(s,8*_n)}else(s<CG||s>pd(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=pd(t.readValue(),this.size*8);return this.signed&&(r=DW(r,this.size*8)),r}}class OG extends dM{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,bi(En.dereference(t,"string")))}decode(e){return Cc(super.decode(e))}}class cm extends wi{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);$(this,"coders");Oe(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=En.dereference(r,"tuple");return uM(t,this.coders,s)}decode(t){return fM(t,this.coders)}}function Ha(n){return Jt(bi(n))}var RG="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAj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WWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const hM=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),pM=4;function MG(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,g=d-1;let b=0;for(let E=0;E<f;E++)b=b<<1|u();let y=[],A=0,v=d;for(;;){let E=Math.floor(((b-A+1)*s-1)/v),k=0,S=r;for(;S-k>1;){let R=k+S>>>1;E<i[R]?S=R:k=R}if(k==0)break;y.push(k);let M=A+Math.floor(v*i[k]/s),O=A+Math.floor(v*i[k+1]/s)-1;for(;!((M^O)&h);)b=b<<1&g|u(),M=M<<1&g,O=O<<1&g|1;for(;M&~O&p;)b=b&h|b<<1&g>>>1|u(),M=M<<1^h,O=(O^h)<<1|h|1;A=M,v=1+O-M}let w=r-4;return y.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function DG(n){let e=0;return()=>n[e++]}function gM(n){return DG(MG(PG(n)))}function PG(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function IG(n){return n&1?~n>>1:n>>1}function LG(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=IG(e());return t}function xd(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function mM(n){return Ad(()=>{let e=xd(n);if(e.length)return e})}function yM(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(_G(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(BG(t,n))}return e.flat()}function Ad(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function bM(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)LG(n,t).forEach((i,o)=>r[o].push(i));return r}function _G(n,e){let t=1+e(),r=e(),s=Ad(e);return bM(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function BG(n,e){let t=1+e();return bM(t,1+n,e).map(s=>[s[0],s.slice(1)])}function FG(n){let e=[],t=xd(n);return s(r([]),[]),e;function r(i){let o=n(),a=Ad(()=>{let l=xd(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function jG(n){return n.toString(16).toUpperCase().padStart(2,"0")}function wM(n){return`{${jG(n)}}`}function UG(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Pc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function HG(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var zG="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAA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KhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Ed=44032,um=4352,fm=4449,dm=4519,vM=19,xM=21,Ic=28,hm=xM*Ic,VG=vM*hm,$G=Ed+VG,WG=um+vM,GG=fm+xM,KG=dm+Ic;function kd(n){return n>>24&255}function AM(n){return n&16777215}let r1,EM,s1,pm;function JG(){let n=gM(zG);r1=new Map(mM(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),EM=new Set(xd(n)),s1=new Map,pm=new Map;for(let[e,t]of yM(n)){if(!EM.has(e)&&t.length==2){let[r,s]=t,i=pm.get(r);i||(i=new Map,pm.set(r,i)),i.set(s,e)}s1.set(e,t.reverse())}}function kM(n){return n>=Ed&&n<$G}function qG(n,e){if(n>=um&&n<WG&&e>=fm&&e<GG)return Ed+(n-um)*hm+(e-fm)*Ic;if(kM(n)&&e>dm&&e<KG&&(n-Ed)%Ic==0)return n+(e-dm);{let t=pm.get(n);return t&&(t=t.get(e),t)?t:-1}}function CM(n){r1||JG();let e=[],t=[],r=!1;function s(i){let o=r1.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(kM(i)){let o=i-Ed,a=o/hm|0,l=o%hm/Ic|0,c=o%Ic;s(um+a),s(fm+l),c>0&&s(dm+c)}else{let o=s1.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=kd(e[0]);for(let o=1;o<e.length;o++){let a=kd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=kd(e[--l]),i<=a))break}i=kd(e[o])}}return e}function QG(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=kd(i),a=AM(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=qG(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function SM(n){return CM(n).map(AM)}function YG(n){return QG(CM(n))}const TM=45,NM=".",OM=65039,RM=1,gm=n=>Array.from(n);function Cd(n,e){return n.P.has(e)||n.Q.has(e)}class XG extends Array{get is_emoji(){return!0}}let i1,MM,za,o1,DM,Lc,a1,_c,Va,PM,l1;function c1(){if(i1)return;let n=gM(RG);const e=()=>xd(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));i1=new Map(yM(n)),MM=t(),za=e(),o1=new Set(e().map(u=>za[u])),za=new Set(za),DM=t(),t();let s=mM(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Lc=Ad(u=>{let f=Ad(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=Pc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),g=!n();return{N:f,P:h,Q:p,M:g,R:d}}}),a1=t(),_c=new Map;let a=e().concat(gm(a1)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),a1.has(u)||_c.set(u,h)});for(let{V:u,M:f}of new Set(_c.values())){let d=[];for(let p of u){let g=Lc.filter(y=>Cd(y,p)),b=d.find(({G:y})=>g.some(A=>y.has(A)));b||(b={G:new Set,V:[]},d.push(b)),b.V.push(p),r(b.G,g)}let h=d.flatMap(p=>gm(p.G));for(let{G:p,V:g}of d){let b=new Set(h.filter(y=>!p.has(y)));for(let y of g)f.set(y,b)}}Va=new Set;let l=new Set;const c=u=>Va.has(u)?l.add(u):Va.add(u);for(let u of Lc){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Va)!_c.has(u)&&!l.has(u)&&_c.set(u,RM);r(Va,SM(Va)),PM=FG(n).map(u=>XG.from(u)).sort(HG),l1=new Map;for(let u of PM){let f=[l1];for(let d of u){let h=f.map(p=>{let g=p.get(d);return g||(g=new Map,p.set(d,g)),g});d===OM?f.push(...h):f=h}for(let d of f)d.V=u}}function u1(n){return(IM(n)?"":`${f1(mm([n]))} `)+wM(n)}function f1(n){return`"${n}"`}function ZG(n){if(n.length>=4&&n[2]==TM&&n[3]==TM)throw new Error(`invalid label extension: "${Pc(n.slice(0,4))}"`)}function eK(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function tK(n){let e=n[0],t=hM.get(e);if(t)throw Sd(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=hM.get(e);if(o){if(s==i)throw Sd(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw Sd(`trailing ${t}`)}function mm(n,e=1/0,t=wM){let r=[];nK(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];IM(a)&&(r.push(Pc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(Pc(n.slice(s,i))),r.join("")}function nK(n){return c1(),za.has(n)}function IM(n){return c1(),DM.has(n)}function rK(n){return aK(sK(n,YG,uK))}function sK(n,e,t){if(!n)return[];c1();let r=0;return n.split(NM).map(s=>{let i=UG(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=cK(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(eK(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))ZG(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(za.has(u[0]))throw Sd("leading combining mark");for(let g=1;g<l;g++){let b=a[g];if(!b.is_emoji&&za.has(b[0]))throw Sd(`emoji + combining mark: "${Pc(a[g-1])} + ${mm([b[0]])}"`)}tK(u);let h=gm(new Set(d)),[p]=oK(h);lK(p,d),iK(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function iK(n,e){let t,r=[];for(let s of e){let i=_c.get(s);if(i===RM)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):gm(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>Cd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function oK(n){let e=Lc;for(let t of n){let r=e.filter(s=>Cd(s,t));if(!r.length)throw Lc.some(s=>Cd(s,t))?_M(e[0],t):LM(t);if(e=r,r.length==1)break}return e}function aK(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${f1(mm(e,63))}: ${s}`)}return Pc(r)}).join(NM)}function LM(n){return new Error(`disallowed character: ${u1(n)}`)}function _M(n,e){let t=u1(e),r=Lc.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function Sd(n){return new Error(`illegal placement: ${n}`)}function lK(n,e){for(let t of e)if(!Cd(n,t))throw _M(n,t);if(n.M){let t=SM(e);for(let r=1,s=t.length;r<s;r++)if(o1.has(t[r])){let i=r+1;for(let o;i<s&&o1.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${u1(o)}`);if(i-r>pM)throw new Error(`excessive non-spacing marks: ${f1(mm(t.slice(r-1,i)))} (${i-r}/${pM})`);r=i}}}function cK(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=fK(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Va.has(o))s.push(o);else{let a=i1.get(o);if(a)s.push(...a);else if(!MM.has(o))throw LM(o)}}}return s.length&&r.push(e(s)),r}function uK(n){return n.filter(e=>e!=OM)}function fK(n,e){let t=l1,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const BM=new Uint8Array(32);BM.fill(0);function FM(n){return V(n.length!==0,"invalid ENS name; empty component","comp",n),n}function jM(n){const e=bi(dK(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(FM(e.slice(r,s))),r=s+1);return V(r<e.length,"invalid ENS name; empty component","name",n),t.push(FM(e.slice(r))),t}function dK(n){try{if(n.length===0)throw new Error("empty label");return rK(n)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",n)}}function d1(n){V(typeof n=="string","invalid ENS name; not a string","name",n),V(n.length,"invalid ENS name (empty label)","name",n);let e=BM;const t=jM(n);for(;t.length;)e=Jt(Ut([e,Jt(t.pop())]));return we(e)}function hK(n,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),we(Ut(jM(n).map(r=>{V(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function h1(n,e){return{address:dt(n),storageKeys:e.map((t,r)=>(V(At(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Co(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${r}]`,t),h1(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",n),h1(t.address,t.storageKeys)));V(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return h1(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function pK(n){let e;return typeof n=="string"?e=vd.computePublicKey(n,!1):e=n.publicKey,dt(Jt("0x"+e.substring(4)).substring(26))}function gK(n,e){return pK(vd.recoverPublicKey(n,e))}const un=BigInt(0),mK=BigInt(2),yK=BigInt(27),bK=BigInt(28),wK=BigInt(35),vK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),p1=4096*32;function UM(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=Nc(e).substring(4),"0x"+t}function ym(n){return n==="0x"?null:dt(n)}function g1(n,e){try{return Co(n)}catch(t){V(!1,t.message,e,n)}}function Td(n,e){return n==="0x"?0:Je(n,e)}function zt(n,e){if(n==="0x")return un;const t=Ae(n,e);return V(t<=vK,"value exceeds uint size",e,t),t}function Ct(n,e){const t=Ae(n,"value"),r=In(t);return V(r.length<=32,"value too large",`tx.${e}`,t),r}function m1(n){return Co(n).map(e=>[e.address,e.storageKeys])}function xK(n,e){V(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)V(At(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function AK(n){const e=tm(n);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:Td(e[0],"nonce"),gasPrice:zt(e[1],"gasPrice"),gasLimit:zt(e[2],"gasLimit"),to:ym(e[3]),value:zt(e[4],"value"),data:we(e[5]),chainId:un};if(e.length===6)return t;const r=zt(e[6],"v"),s=zt(e[7],"r"),i=zt(e[8],"s");if(s===un&&i===un)t.chainId=r;else{let o=(r-wK)/mK;o<un&&(o=un),t.chainId=o,V(o!==un||r===yK||r===bK,"non-canonical legacy v","v",e[6]),t.signature=as.from({r:Ia(e[7],32),s:Ia(e[8],32),v:r})}return t}function EK(n,e){const t=[Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data];let r=un;if(n.chainId!=un)r=Ae(n.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==un&&(t.push(In(r)),t.push("0x"),t.push("0x")),_a(t);let s=BigInt(27+e.yParity);return r!==un?s=as.getChainIdV(r,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(In(s)),t.push(In(e.r)),t.push(In(e.s)),_a(t)}function y1(n,e){let t;try{if(t=Td(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const r=Ia(e[1],32),s=Ia(e[2],32),i=as.from({r,s,yParity:t});n.signature=i}function kK(n){const e=tm(lt(n).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",we(n));const t={type:2,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:ym(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:g1(e[8],"accessList")};return e.length===9||y1(t,e.slice(9)),t}function CK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,m1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"yParity")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x02",_a(t)])}function SK(n){const e=tm(lt(n).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",we(n));const t={type:1,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),gasPrice:zt(e[2],"gasPrice"),gasLimit:zt(e[3],"gasLimit"),to:ym(e[4]),value:zt(e[5],"value"),data:we(e[6]),accessList:g1(e[7],"accessList")};return e.length===8||y1(t,e.slice(8)),t}function TK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,m1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"recoveryParam")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x01",_a(t)])}function NK(n){let e=tm(lt(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];V(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),V(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",we(n));const s={type:3,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:ym(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:g1(e[8],"accessList"),maxFeePerBlobGas:zt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),V(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),V(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)V(At(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||y1(s,e.slice(11)),s}function OK(n,e,t){const r=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||wd,Ct(n.value,"value"),n.data,m1(n.accessList||[]),Ct(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),xK(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Ct(e.yParity,"yParity")),r.push(In(e.r)),r.push(In(e.s)),t)?Ut(["0x03",_a([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Ut(["0x03",_a(r)])}const Pi=class Pi{constructor(){q(this,hu);q(this,Ws);q(this,nu);q(this,ru);q(this,su);q(this,iu);q(this,ou);q(this,au);q(this,lu);q(this,cu);q(this,uu);q(this,fu);q(this,du);q(this,ll);q(this,Ro);q(this,Di);q(this,Mo);I(this,Ws,null),I(this,nu,null),I(this,su,0),I(this,iu,un),I(this,ou,null),I(this,au,null),I(this,lu,null),I(this,ru,"0x"),I(this,cu,un),I(this,uu,un),I(this,fu,null),I(this,du,null),I(this,ll,null),I(this,Ro,null),I(this,Mo,null),I(this,Di,null)}get type(){return T(this,Ws)}set type(e){switch(e){case null:I(this,Ws,null);break;case 0:case"legacy":I(this,Ws,0);break;case 1:case"berlin":case"eip-2930":I(this,Ws,1);break;case 2:case"london":case"eip-1559":I(this,Ws,2);break;case 3:case"cancun":case"eip-4844":I(this,Ws,3);break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,nu);return e==null&&this.type===3?wd:e}set to(e){I(this,nu,e==null?null:dt(e))}get nonce(){return T(this,su)}set nonce(e){I(this,su,Je(e,"value"))}get gasLimit(){return T(this,iu)}set gasLimit(e){I(this,iu,Ae(e))}get gasPrice(){const e=T(this,ou);return e==null&&(this.type===0||this.type===1)?un:e}set gasPrice(e){I(this,ou,e==null?null:Ae(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,au);return e??(this.type===2||this.type===3?un:null)}set maxPriorityFeePerGas(e){I(this,au,e==null?null:Ae(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,lu);return e??(this.type===2||this.type===3?un:null)}set maxFeePerGas(e){I(this,lu,e==null?null:Ae(e,"maxFeePerGas"))}get data(){return T(this,ru)}set data(e){I(this,ru,we(e))}get value(){return T(this,cu)}set value(e){I(this,cu,Ae(e,"value"))}get chainId(){return T(this,uu)}set chainId(e){I(this,uu,Ae(e))}get signature(){return T(this,fu)||null}set signature(e){I(this,fu,e==null?null:as.from(e))}get accessList(){const e=T(this,du)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){I(this,du,e==null?null:Co(e))}get maxFeePerBlobGas(){const e=T(this,ll);return e==null&&this.type===3?un:e}set maxFeePerBlobGas(e){I(this,ll,e==null?null:Ae(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,Ro);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(At(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}I(this,Ro,e)}get blobs(){return T(this,Mo)==null?null:T(this,Mo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){I(this,Mo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mv(i)){ee(T(this,Di),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=lt(i);if(V(o.length<=p1,"blob is too large",`blobs[${s}]`,i),o.length!==p1){const c=new Uint8Array(p1);c.set(o),o=c}const a=T(this,Di).blobToKzgCommitment(o),l=we(T(this,Di).computeBlobKzgProof(o,a));t.push({data:we(o),commitment:we(a),proof:l}),r.push(UM(1,a))}else{const o=we(i.commitment);t.push({data:we(i.data),commitment:o,proof:we(i.proof)}),r.push(UM(1,o))}}I(this,Mo,t),I(this,Ro,r)}get kzg(){return T(this,Di)}set kzg(e){I(this,Di,e)}get hash(){return this.signature==null?null:Jt(fe(this,hu,Xm).call(this,!0,!1))}get unsignedHash(){return Jt(this.unsignedSerialized)}get from(){return this.signature==null?null:gK(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:vd.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return fe(this,hu,Xm).call(this,!0,!0)}get unsignedSerialized(){return fe(this,hu,Xm).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=T(this,ll)!=null||T(this,Ro);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ee(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ee(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ee(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Pi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Pi;if(typeof e=="string"){const r=lt(e);if(r[0]>=127)return Pi.from(AK(r));switch(r[0]){case 1:return Pi.from(SK(r));case 2:return Pi.from(kK(r));case 3:return Pi.from(NK(r))}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Pi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=as.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ws=new WeakMap,nu=new WeakMap,ru=new WeakMap,su=new WeakMap,iu=new WeakMap,ou=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,uu=new WeakMap,fu=new WeakMap,du=new WeakMap,ll=new WeakMap,Ro=new WeakMap,Di=new WeakMap,Mo=new WeakMap,hu=new WeakSet,Xm=function(e,t){ee(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return EK(this,r);case 1:return TK(this,r);case 2:return CK(this,r);case 3:return OK(this,r,t?this.blobs:null)}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Nd=Pi;const HM=new Uint8Array(32);HM.fill(0);const RK=BigInt(-1),zM=BigInt(0),VM=BigInt(1),MK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function DK(n){const e=lt(n),t=e.length%32;return t?Ut([e,HM.slice(t)]):we(e)}const PK=bo(VM,32),IK=bo(zM,32),$M={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},b1=["name","version","chainId","verifyingContract","salt"];function WM(n){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const LK={name:WM("name"),version:WM("version"),chainId:function(n){const e=Ae(n,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):La(e)},verifyingContract:function(n){try{return dt(n).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=lt(n,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",n),we(e)}};function w1(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);V(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=pd(MK,t?r-1:r),i=t?(s+VM)*RK:zM;return function(o){const a=Ae(o,"value");return V(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),bo(t?JO(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=lt(r);return V(s.length===t,`invalid length for ${n}`,"value",r),DK(r)}}}switch(n){case"address":return function(e){return Ia(dt(e),32)};case"bool":return function(e){return e?PK:IK};case"bytes":return function(e){return Jt(e)};case"string":return function(e){return Ha(e)}}return null}function GM(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function bm(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Fr=class Fr{constructor(e){q(this,Wm);$(this,"primaryType");q(this,Hd);q(this,Ii);q(this,pu);I(this,Ii,new Map),I(this,pu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=bm(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),I(this,Hd,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){V(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=bm(u.type).base;V(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!w1(f)&&(V(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);V(o.length!==0,"missing primary type","types",e),V(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),Oe(this,{primaryType:o[0]});function a(l,c){V(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),T(this,Ii).set(l,GM(l,i[l])+u.map(f=>GM(f,i[f])).join(""))}}get types(){return JSON.parse(T(this,Hd))}getEncoder(e){let t=T(this,pu).get(e);return t||(t=fe(this,Wm,tP).call(this,e),T(this,pu).set(e,t)),t}encodeType(e){const t=T(this,Ii).get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Jt(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(w1(e))return r(e,t);const s=bm(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Fr(e)}static getPrimaryType(e){return Fr.from(e).primaryType}static hashStruct(e,t,r){return Fr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=$M[r];V(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>b1.indexOf(r.name)-b1.indexOf(s.name)),Fr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ut(["0x1901",Fr.hashDomain(e),Fr.from(t).hash(r)])}static hash(e,t,r){return Jt(Fr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!At(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Fr.from(t);o.visit(r,(a,l)=>(a==="address"&&!At(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Fr.hashDomain(e);const s={},i=[];b1.forEach(l=>{const c=e[l];c!=null&&(s[l]=LK[l](c),i.push({name:l,type:$M[l]}))});const o=Fr.from(t);t=o.types;const a=Object.assign({},t);return V(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return we(lt(c));if(l.match(/^u?int/))return Ae(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return V(typeof c=="string","invalid string","value",c),c}V(!1,"unsupported type","type",l)})}}};Hd=new WeakMap,Ii=new WeakMap,pu=new WeakMap,Wm=new WeakSet,tP=function(e){{const s=w1(e);if(s)return s}const t=bm(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{V(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return T(this,Ii).has(s)&&(a=a.map(Jt)),Jt(Ut(a))}}const r=this.types[e];if(r){const s=Ha(T(this,Ii).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return T(this,Ii).has(l)?Jt(c):c});return o.unshift(s),Ut(o)}}V(!1,`unknown type: ${e}`,"type",e)};let wm=Fr;function Fn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const _K=Fn("external public payable override".split(" ")),KM="constant external internal payable private public pure view override",BK=Fn(KM.split(" ")),JM="constructor error event fallback function receive struct",qM=Fn(JM.split(" ")),QM="calldata memory storage payable indexed",FK=Fn(QM.split(" ")),jK=[JM,QM,"tuple returns",KM].join(" "),UK=Fn(jK.split(" ")),HK={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},zK=new RegExp("^(\\s*)"),VK=new RegExp("^([0-9]+)"),$K=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),YM=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),XM=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Gm=class Gm{constructor(e){q(this,zd);q(this,bn);q(this,hs);I(this,bn,0),I(this,hs,e.slice())}get offset(){return T(this,bn)}get length(){return T(this,hs).length-T(this,bn)}clone(){return new Gm(T(this,hs))}reset(){I(this,bn,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=fe(this,zd,rx).call(this,T(this,bn)+1,e.match+1);return I(this,bn,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,bn)<e.match-1;){const r=this.peek().linkNext;t.push(fe(this,zd,rx).call(this,T(this,bn)+1,r)),I(this,bn,r)}return I(this,bn,e.match+1),t}peek(){if(T(this,bn)>=T(this,hs).length)throw new Error("out-of-bounds");return T(this,hs)[T(this,bn)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Zd(this,bn)._++,e}toString(){const e=[];for(let t=T(this,bn);t<T(this,hs).length;t++){const r=T(this,hs)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};bn=new WeakMap,hs=new WeakMap,zd=new WeakSet,rx=function(e=0,t=0){return new Gm(T(this,hs).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let ls=Gm;function So(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(zK);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=HK[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Je(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match($K),a){if(l.text=a[1],i+=l.text.length,UK.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(XM)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(VK),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ls(e.map(o=>Object.freeze(o)))}function ZM(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function vm(n,e){if(e.peekKeyword(qM)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function eD(n){let e=Ai(n,BK);return ZM(e,Fn("constant payable nonpayable".split(" "))),ZM(e,Fn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ei(n,e){return n.popParams().map(t=>mn.from(t,e))}function tD(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ae(n.pop().text);throw new Error("invalid gas")}return null}function $a(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const WK=new RegExp(/^(.*)\[([0-9]*)\]$/);function nD(n){const e=n.match(XM);if(V(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const Pt={},Xn=Symbol.for("_ethers_internal"),rD="_ParamTypeInternal",sD="_ErrorInternal",iD="_EventInternal",oD="_ConstructorInternal",aD="_FallbackInternal",lD="_FunctionInternal",cD="_StructInternal",jr=class jr{constructor(e,t,r,s,i,o,a,l){q(this,gu);$(this,"name");$(this,"type");$(this,"baseType");$(this,"indexed");$(this,"components");$(this,"arrayLength");$(this,"arrayChildren");if(Qg(e,Pt,"ParamType"),Object.defineProperty(this,Xn,{value:rD}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");Oe(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return fe(this,gu,Zm).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(jr.isParamType(e))return e;if(typeof e=="string")try{return jr.from(So(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ls){let a="",l="",c=null;Ai(e,Fn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(g=>jr.from(g)),a=`tuple(${c.map(g=>g.format()).join(",")})`):(a=nD(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const g=e.pop();u=new jr(Pt,"",a,l,null,c,f,u),f=g.value,a+=g.text,l="array",c=null}let d=null;if(Ai(e,FK).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new jr(Pt,p,a,l,d,c,f,u)}const r=e.name;V(!r||typeof r=="string"&&r.match(YM),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(WK);if(o){const a=parseInt(o[2]||"-1"),l=jr.from({type:o[1],components:e.components});return new jr(Pt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>jr.from(c)):null;return new jr(Pt,r||"",i,"tuple",s,a,null,null)}return i=nD(e.type),new jr(Pt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Xn]===rD}};gu=new WeakSet,Zm=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;fe(u=o,gu,Zm).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;fe(u=o[c],gu,Zm).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let mn=jr;class Wa{constructor(e,t,r){$(this,"type");$(this,"inputs");Qg(e,Pt,"Fragment"),r=Object.freeze(r.slice()),Oe(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Wa.from(JSON.parse(e))}catch{}return Wa.from(So(e))}if(e instanceof ls)switch(e.peekKeyword(qM)){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}ee(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ki.isFragment(e)}static isError(e){return Zn.isFragment(e)}static isEvent(e){return zs.isFragment(e)}static isFunction(e){return Vs.isFragment(e)}static isStruct(e){return Ga.isFragment(e)}}class xm extends Wa{constructor(t,r,s,i){super(t,r,i);$(this,"name");V(typeof s=="string"&&s.match(YM),"invalid identifier","name",s),i=Object.freeze(i.slice()),Oe(this,{name:s})}}function Od(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Zn extends xm{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Xn,{value:sD})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Od(e,this.inputs)),t.join(" ")}static from(e){if(Zn.isFragment(e))return e;if(typeof e=="string")return Zn.from(So(e));if(e instanceof ls){const t=vm("error",e),r=Ei(e);return $a(e),new Zn(Pt,t,r)}return new Zn(Pt,e.name,e.inputs?e.inputs.map(mn.from):[])}static isFragment(e){return e&&e[Xn]===sD}}class zs extends xm{constructor(t,r,s,i){super(t,"event",r,s);$(this,"anonymous");Object.defineProperty(this,Xn,{value:iD}),Oe(this,{anonymous:i})}get topicHash(){return Ha(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>mn.from(i)),new zs(Pt,t,r,!1).topicHash}static from(t){if(zs.isFragment(t))return t;if(typeof t=="string")try{return zs.from(So(t))}catch{V(!1,"invalid event fragment","obj",t)}else if(t instanceof ls){const r=vm("event",t),s=Ei(t,!0),i=!!Ai(t,Fn(["anonymous"])).has("anonymous");return $a(t),new zs(Pt,r,s,i)}return new zs(Pt,t.name,t.inputs?t.inputs.map(r=>mn.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Xn]===iD}}class ki extends Wa{constructor(t,r,s,i,o){super(t,r,s);$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:oD}),Oe(this,{payable:i,gas:o})}format(t){if(ee(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${Od(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ki.isFragment(t))return t;if(typeof t=="string")try{return ki.from(So(t))}catch{V(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ls){Ai(t,Fn(["constructor"]));const r=Ei(t),s=!!Ai(t,_K).has("payable"),i=tD(t);return $a(t),new ki(Pt,"constructor",r,s,i)}return new ki(Pt,"constructor",t.inputs?t.inputs.map(mn.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===oD}}class Ci extends Wa{constructor(t,r,s){super(t,"fallback",r);$(this,"payable");Object.defineProperty(this,Xn,{value:aD}),Oe(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Ci.isFragment(t))return t;if(typeof t=="string")try{return Ci.from(So(t))}catch{V(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ls){const r=t.toString(),s=t.peekKeyword(Fn(["fallback","receive"]));if(V(s,"type must be fallback or receive","obj",r),t.popKeyword(Fn(["fallback","receive"]))==="receive"){const l=Ei(t);return V(l.length===0,"receive cannot have arguments","obj.inputs",l),Ai(t,Fn(["payable"])),$a(t),new Ci(Pt,[],!0)}let o=Ei(t);o.length?V(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[mn.from("bytes")];const a=eD(t);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Ai(t,Fn(["returns"])).has("returns")){const l=Ei(t);V(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return $a(t),new Ci(Pt,o,a==="payable")}if(t.type==="receive")return new Ci(Pt,[],!0);if(t.type==="fallback"){const r=[mn.from("bytes")],s=t.stateMutability==="payable";return new Ci(Pt,r,s)}V(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Xn]===aD}}class Vs extends xm{constructor(t,r,s,i,o,a){super(t,"function",r,i);$(this,"constant");$(this,"outputs");$(this,"stateMutability");$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:lD}),o=Object.freeze(o.slice()),Oe(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Od(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>mn.from(i)),new Vs(Pt,t,"view",r,[],null).selector}static from(t){if(Vs.isFragment(t))return t;if(typeof t=="string")try{return Vs.from(So(t))}catch{V(!1,"invalid function fragment","obj",t)}else if(t instanceof ls){const s=vm("function",t),i=Ei(t),o=eD(t);let a=[];Ai(t,Fn(["returns"])).has("returns")&&(a=Ei(t));const l=tD(t);return $a(t),new Vs(Pt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Vs(Pt,t.name,r,t.inputs?t.inputs.map(mn.from):[],t.outputs?t.outputs.map(mn.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===lD}}class Ga extends xm{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Xn,{value:cD})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Ga.from(So(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ls){const t=vm("struct",e),r=Ei(e);return $a(e),new Ga(Pt,t,r)}return new Ga(Pt,e.name,e.inputs?e.inputs.map(mn.from):[])}static isFragment(e){return e&&e[Xn]===cD}}const cs=new Map;cs.set(0,"GENERIC_PANIC"),cs.set(1,"ASSERT_FALSE"),cs.set(17,"OVERFLOW"),cs.set(18,"DIVIDE_BY_ZERO"),cs.set(33,"ENUM_RANGE_ERROR"),cs.set(34,"BAD_STORAGE_DATA"),cs.set(49,"STACK_UNDERFLOW"),cs.set(50,"ARRAY_RANGE_ERROR"),cs.set(65,"OUT_OF_MEMORY"),cs.set(81,"UNINITIALIZED_FUNCTION_CALL");const GK=new RegExp(/^bytes([0-9]*)$/),KK=new RegExp(/^(u?int)([0-9]*)$/);let v1=null,uD=1024;function JK(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=lt(t);if(t=we(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(we(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(we(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${cs.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?dt(e.to):null,data:e.data||"0x"};return e.from&&(l.from=dt(e.from)),Nt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Km=class Km{constructor(){q(this,Do)}getDefaultValue(e){const t=e.map(s=>fe(this,Do,Fu).call(this,mn.from(s)));return new cm(t,"_").defaultValue()}encode(e,t){$O(t.length,e.length,"types/values length mismatch");const r=e.map(o=>fe(this,Do,Fu).call(this,mn.from(o))),s=new cm(r,"_"),i=new _v;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>fe(this,Do,Fu).call(this,mn.from(o)));return new cm(s,"_").decode(new Bv(t,r,uD))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),uD=e}static defaultAbiCoder(){return v1==null&&(v1=new Km),v1}static getBuiltinCallException(e,t,r){return JK(e,t,r,Km.defaultAbiCoder())}};Do=new WeakSet,Fu=function(e){if(e.isArray())return new wG(fe(this,Do,Fu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new cm(e.components.map(r=>fe(this,Do,Fu).call(this,r)),e.name);switch(e.baseType){case"address":return new yG(e.name);case"bool":return new vG(e.name);case"string":return new OG(e.name);case"bytes":return new xG(e.name);case"":return new kG(e.name)}let t=e.type.match(KK);if(t){let r=parseInt(t[2]||"256");return V(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new NG(r/8,t[1]==="int",e.name)}if(t=e.type.match(GK),t){let r=parseInt(t[1]);return V(r!==0&&r<=32,"invalid bytes length","param",e),new AG(r,e.name)}V(!1,"invalid type","type",e.type)};let Bc=Km;class qK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"signature");$(this,"topic");$(this,"args");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class QK{constructor(e,t,r,s){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");$(this,"value");const i=e.name,o=e.format();Oe(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class YK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class fD{constructor(e){$(this,"hash");$(this,"_isIndexed");Oe(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const dD={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},hD={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&dD[n.toString()]&&(e=dD[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},cl=class cl{constructor(e){q(this,qs);$(this,"fragments");$(this,"deploy");$(this,"fallback");$(this,"receive");q(this,Gs);q(this,Ks);q(this,Js);q(this,kn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Js,new Map),I(this,Gs,new Map),I(this,Ks,new Map);const r=[];for(const o of t)try{r.push(Wa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}Oe(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,kn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Oe(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(V(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=T(this,Js);break;case"event":l=T(this,Ks);break;case"error":l=T(this,Gs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||Oe(this,{deploy:ki.from("constructor()")}),Oe(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Bc.defaultAbiCoder()}getFunctionName(e){const t=fe(this,qs,ey).call(this,e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!fe(this,qs,ey).call(this,e,null,!1)}getFunction(e,t){return fe(this,qs,ey).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,Js).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Js).get(s),r)}}getEventName(e){const t=fe(this,qs,ty).call(this,e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!fe(this,qs,ty).call(this,e,null,!1)}getEvent(e,t){return fe(this,qs,ty).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,Ks).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Ks).get(s),r)}}getError(e,t){if(At(e)){const s=e.toLowerCase();if(hD[s])return Zn.from(hD[s].signature);for(const i of T(this,Gs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of T(this,Gs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Zn.from("error Error(string)"):e==="Panic"?Zn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Zn.from(e).format(),e==="Error(string)")return Zn.from("error Error(string)");if(e==="Panic(uint256)")return Zn.from("error Panic(uint256)");const r=T(this,Gs).get(e);return r||null}forEachError(e){const t=Array.from(T(this,Gs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Gs).get(s),r)}}_decodeParams(e,t){return T(this,kn).decode(e,t)}_encodeParams(e,t){return T(this,kn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);V(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Pn(t);if(s.length%32===0)try{return T(this,kn).decode(e.outputs,s)}catch{r="could not decode result data"}ee(!1,r,"BAD_DATA",{value:we(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=lt(e,"data"),s=Bc.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=we(r.slice(0,4)),l=this.getError(a);if(l)try{const c=T(this,kn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return we(T(this,kn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);V(i,"unknown event","eventFragment",e),e=i}ee(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?Ha(o):i.type==="bytes"?Jt(we(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=bo(o):i.type.match(/^bytes/)?o=MW(o,32):i.type==="address"&&T(this,kn).encode(["address"],[o]),Ia(we(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){V(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);V(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(Ha(l));else if(o.type==="bytes")r.push(Jt(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,kn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:T(this,kn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);V(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;V(At(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(mn.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?T(this,kn).decode(s,Ut(r)):null,l=T(this,kn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let g=null;if(h.indexed)if(a==null)g=new fD(null);else if(o[p])g=new fD(a[d++]);else try{g=a[d++]}catch(b){g=b}else try{g=l[f++]}catch(b){g=b}c.push(g),u.push(h.name||null)}),Sc.fromItems(c,u)}parseTransaction(e){const t=lt(e.data,"tx.data"),r=Ae(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(we(t.slice(0,4)));if(!s)return null;const i=T(this,kn).decode(s.inputs,t.slice(4));return new QK(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new qK(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=we(e),r=this.getError(Ft(t,0,4));if(!r)return null;const s=T(this,kn).decode(r.inputs,Ft(t,4));return new YK(r,r.selector,s)}static from(e){return e instanceof cl?e:typeof e=="string"?new cl(JSON.parse(e)):typeof e.formatJson=="function"?new cl(e.formatJson()):typeof e.format=="function"?new cl(e.format("json")):new cl(e)}};Gs=new WeakMap,Ks=new WeakMap,Js=new WeakMap,kn=new WeakMap,qs=new WeakSet,ey=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Js).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Js))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;En.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(En.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Js).get(Vs.from(e).format());return s||null},ty=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Ks).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Ks))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(En.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Ks).get(zs.from(e).format());return s||null};let x1=cl;const pD=BigInt(0);function Fc(n){return n??null}function Vt(n){return n==null?null:n.toString()}class gD{constructor(e,t,r){$(this,"gasPrice");$(this,"maxFeePerGas");$(this,"maxPriorityFeePerGas");Oe(this,{gasPrice:Fc(e),maxFeePerGas:Fc(t),maxPriorityFeePerGas:Fc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Vt(e),maxFeePerGas:Vt(t),maxPriorityFeePerGas:Vt(r)}}}function Am(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=we(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Ae(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Je(n[s],`request.${s}`));return n.accessList&&(e.accessList=Co(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mv(s)?we(s):Object.assign({},s))),e}class XK{constructor(e,t){$(this,"provider");$(this,"number");$(this,"hash");$(this,"timestamp");$(this,"parentHash");$(this,"parentBeaconBlockRoot");$(this,"nonce");$(this,"difficulty");$(this,"gasLimit");$(this,"gasUsed");$(this,"stateRoot");$(this,"receiptsRoot");$(this,"blobGasUsed");$(this,"excessBlobGas");$(this,"miner");$(this,"prevRandao");$(this,"extraData");$(this,"baseFeePerGas");q(this,Li);I(this,Li,e.transactions.map(r=>typeof r!="string"?new Md(r,t):r)),Oe(this,{provider:t,hash:Fc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Fc(e.prevRandao),extraData:e.extraData,baseFeePerGas:Fc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Li).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Li).slice();return e.length===0?[]:(ee(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:g,transactions:b}=this;return{_type:"Block",baseFeePerGas:Vt(e),difficulty:Vt(t),extraData:r,gasLimit:Vt(s),gasUsed:Vt(i),blobGasUsed:Vt(this.blobGasUsed),excessBlobGas:Vt(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:g,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:b}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Li).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Li)[e];else{const r=e.toLowerCase();for(const s of T(this,Li))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ZK(this)}}Li=new WeakMap;class Rd{constructor(e,t){$(this,"provider");$(this,"transactionHash");$(this,"blockHash");$(this,"blockNumber");$(this,"removed");$(this,"address");$(this,"data");$(this,"topics");$(this,"index");$(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());Oe(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ee(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return eJ(this)}}class mD{constructor(e,t){$(this,"provider");$(this,"to");$(this,"from");$(this,"contractAddress");$(this,"hash");$(this,"index");$(this,"blockHash");$(this,"blockNumber");$(this,"logsBloom");$(this,"gasUsed");$(this,"blobGasUsed");$(this,"cumulativeGasUsed");$(this,"gasPrice");$(this,"blobGasPrice");$(this,"type");$(this,"status");$(this,"root");q(this,Vd);I(this,Vd,Object.freeze(e.logs.map(s=>new Rd(s,t))));let r=pD;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),Oe(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Vd)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Vt(this.cumulativeGasUsed),from:t,gasPrice:Vt(this.gasPrice),blobGasUsed:Vt(this.blobGasUsed),blobGasPrice:Vt(this.blobGasPrice),gasUsed:Vt(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return bD(this)}reorderedEvent(e){return ee(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),yD(this,e)}}Vd=new WeakMap;const J1=class J1{constructor(e,t){$(this,"provider");$(this,"blockNumber");$(this,"blockHash");$(this,"index");$(this,"hash");$(this,"type");$(this,"to");$(this,"from");$(this,"nonce");$(this,"gasLimit");$(this,"gasPrice");$(this,"maxPriorityFeePerGas");$(this,"maxFeePerGas");$(this,"maxFeePerBlobGas");$(this,"data");$(this,"value");$(this,"chainId");$(this,"signature");$(this,"accessList");$(this,"blobVersionedHashes");q(this,Po);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,I(this,Po,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Vt(this.chainId),data:c,from:a,gasLimit:Vt(this.gasLimit),gasPrice:Vt(this.gasPrice),hash:s,maxFeePerGas:Vt(this.maxFeePerGas),maxPriorityFeePerGas:Vt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Vt(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:Vt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await An({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=T(this,Po),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await An({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<T(this,Po)&&(o=T(this,Po)));o<=d;){if(a)return null;const g=await this.provider.getBlock(o,!0);if(g==null)return;for(const b of g)if(b===this.hash)return;for(let b=0;b<g.length;b++){const y=await g.getTransaction(b);if(y.from===this.from&&y.nonce===this.nonce){if(a)return null;const A=await this.provider.getTransactionReceipt(y.hash);if(A==null||d-A.blockNumber+1<r)return;let v="replaced";y.data===this.data&&y.to===this.to&&y.value===this.value?v="repriced":y.data==="0x"&&y.from===y.to&&y.value===pD&&(v="cancelled"),ee(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:y.replaceableTransaction(i),hash:y.hash,receipt:A})}}o++}},c=d=>{if(d==null||d.status!==0)return d;ee(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],g=()=>{p.forEach(y=>y())};if(p.push(()=>{a=!0}),s>0){const y=setTimeout(()=>{g(),h(Nt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(y)})}const b=async y=>{if(await y.confirmations()>=r){g();try{d(c(y))}catch(A){h(A)}}};if(p.push(()=>{this.provider.off(this.hash,b)}),this.provider.on(this.hash,b),i>=0){const y=async()=>{try{await l()}catch(A){if(ln(A,"TRANSACTION_REPLACED")){g(),h(A);return}}a||this.provider.once("block",y)};p.push(()=>{this.provider.off("block",y)}),this.provider.once("block",y)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),bD(this)}reorderedEvent(e){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ee(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),yD(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new J1(this,this.provider);return I(t,Po,e),t}};Po=new WeakMap;let Md=J1;function ZK(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function yD(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function bD(n){return{orphan:"drop-transaction",tx:n}}function eJ(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class A1 extends Rd{constructor(t,r,s){super(t,t.provider);$(this,"interface");$(this,"fragment");$(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);Oe(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class wD extends Rd{constructor(t,r){super(t,t.provider);$(this,"error");Oe(this,{error:r})}}class tJ extends mD{constructor(t,r,s){super(s,r);q(this,mu);I(this,mu,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?T(this,mu).getEvent(t.topics[0]):null;if(r)try{return new A1(t,T(this,mu),r)}catch(s){return new wD(t,s)}return t})}}mu=new WeakMap;class E1 extends Md{constructor(t,r,s){super(s,r);q(this,$d);I(this,$d,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new tJ(T(this,$d),this.provider,s)}}$d=new WeakMap;class vD extends XO{constructor(t,r,s,i){super(t,r,s);$(this,"log");Oe(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class nJ extends vD{constructor(e,t,r,s,i){super(e,t,r,new A1(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Oe(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const xD=BigInt(0);function AD(n){return n&&typeof n.call=="function"}function ED(n){return n&&typeof n.estimateGas=="function"}function Em(n){return n&&typeof n.resolveName=="function"}function kD(n){return n&&typeof n.sendTransaction=="function"}function CD(n){if(n!=null){if(Em(n))return n;if(n.provider)return n.provider}}class rJ{constructor(e,t,r){q(this,Wd);$(this,"fragment");if(Oe(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ka(e.runner,"resolveName"),i=Em(s)?s:null;I(this,Wd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Bn(d,i))):Bn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Wd)}}Wd=new WeakMap;function Ka(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ja(n){return n==null?null:n.provider||null}async function SD(n,e){const t=En.dereference(n,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",n);const r=Am(t);return V(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),V(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function sJ(n,e,t){const r=Ka(n,"resolveName"),s=Em(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=En.dereference(l,a),a==="address"?Bn(l,s):l))))}function iJ(n){const e=async function(o){const a=await SD(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Bn(a.from,CD(n.runner)));const l=n.interface,c=Ae(a.value||xD,"overrides.value")===xD,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return V(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ka(n.runner,"call");ee(AD(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Rv(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;ee(kD(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ja(n.runner);return new E1(n.interface,c,l)},s=async function(o){const a=Ka(n.runner,"estimateGas");return ee(ED(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return Oe(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function oJ(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return ee(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await SD(c.pop()),f.from&&(f.from=await Bn(f.from,CD(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await sJ(n.runner,u.inputs,c);return Object.assign({},f,await An({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;ee(kD(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ja(n.runner);return new E1(n.interface,d,f)},o=async function(...c){const u=Ka(n.runner,"estimateGas");return ee(ED(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ka(n.runner,"call");ee(AD(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Rv(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return Oe(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return ee(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function aJ(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return ee(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new rJ(n,t(...s),s)};return Oe(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return ee(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const km=Symbol.for("_ethersInternal_contract"),TD=new WeakMap;function lJ(n,e){TD.set(n[km],e)}function br(n){return TD.get(n[km])}function cJ(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function k1(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(At(o,32))return o;const a=n.interface.getEvent(o);return V(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?At(e,32)?t=[e]:(r=n.interface.getEvent(e),V(r,"unknown fragment","event",e),t=[r.topicHash]):cJ(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):V(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Dd(n,e){const{subs:t}=br(n);return t.get((await k1(n,e)).tag)||null}async function ND(n,e,t){const r=Ja(n.runner);ee(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await k1(n,t),{addr:a,subs:l}=br(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=b=>{let y=s;if(y==null)try{y=n.interface.getEvent(b.topics[0])}catch{}if(y){const A=y,v=s?n.interface.decodeEventLog(s,b.data,b.topics):[];S1(n,t,v,w=>new nJ(n,w,t,A,b))}else S1(n,t,[],A=>new vD(n,A,t,b))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let b=h;h=[],await Promise.all(b),r.off(f,d)}},l.set(i,c)}return c}let C1=Promise.resolve();async function uJ(n,e,t,r){await C1;const s=await Dd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),br(n).subs.delete(s.tag)),i>0}async function S1(n,e,t,r){try{await C1}catch{}const s=uJ(n,e,t,r);return C1=s,await s}const Cm=["then"];qD=km;const Gd=class Gd{constructor(e,t,r,s){$(this,"target");$(this,"interface");$(this,"runner");$(this,"filters");$(this,qD);$(this,"fallback");V(typeof e=="string"||lM(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=x1.from(t);Oe(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,km,{value:{}});let o,a=null,l=null;if(s){const f=Ja(r);l=new E1(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(At(e))a=e,o=Promise.resolve(e);else{const f=Ka(r,"resolveName");if(!Em(f))throw Nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw Nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return br(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return br(this).addr=f,f});lJ(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Cm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Cm.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return Oe(this,{filters:u}),Oe(this,{fallback:i.receive||i.fallback?iJ(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Cm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Cm.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Gd(this.target,this.interface,e)}attach(e){return new Gd(e,this.interface,this.runner)}async getAddress(){return await br(this).addrPromise}async getDeployedCode(){const e=Ja(this.runner);ee(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ja(this.runner);return ee(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return br(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),oJ(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),aJ(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=br(this),o=s||await i,{fragment:a,topics:l}=await k1(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ja(this.runner);return ee(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new A1(f,this.interface,d)}catch(h){return new wD(f,h)}return new Rd(f,u)})}async on(e,t){const r=await ND(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await ND(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await S1(this,e,t,null)}async listenerCount(e){if(e){const s=await Dd(this,e);return s?s.listeners.length:0}const{subs:t}=br(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Dd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=br(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Dd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),br(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Dd(this,e);if(!t)return this;t.stop(),br(this).subs.delete(t.tag)}else{const{subs:t}=br(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let T1=Gd;function fJ(){return T1}class jc extends fJ(){}function N1(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):V(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class dJ{constructor(e){$(this,"name");Oe(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const OD=new RegExp("^(ipfs)://(.*)$","i"),RD=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),OD,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],yu=class yu{constructor(e,t,r){q(this,Lo);$(this,"provider");$(this,"address");$(this,"name");q(this,Io);q(this,ul);Oe(this,{provider:e,address:t,name:r}),I(this,Io,null),I(this,ul,new jc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Io)==null&&I(this,Io,(async()=>{try{return await T(this,ul).supportsInterface("0x9061b923")}catch(e){if(ln(e,"CALL_EXCEPTION"))return!1;throw I(this,Io,null),e}})()),await T(this,Io)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await fe(this,Lo,ju).call(this,"addr(bytes32)");return i==null||i===wd?null:i}catch(i){if(ln(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[i]);if(At(o,20))return dt(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof dJ&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;ee(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await fe(this,Lo,ju).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await fe(this,Lo,ju).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${IW("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ee(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<RD.length;r++){const s=t.match(RD[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=N1(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new jc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const g=await u.ownerOf(c);if(a!==g)return e.push({type:"!owner",value:g}),{url:null,linkage:e};e.push({type:"owner",value:g})}else if(i==="erc1155"){const g=await u.balanceOf(a,c);if(!g)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:g.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",bo(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=N1(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Ln(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const y=h.body;return y&&e.push({type:"!metadata",value:we(y)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(OD)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=N1(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return ee(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await fe(s=yu,Jm,nP).call(s,e,r);if(i!=null){const o=new yu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Io=new WeakMap,ul=new WeakMap,Lo=new WeakSet,ju=async function(e,t){t=(t||[]).slice();const r=T(this,ul).interface;t.unshift(d1(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),ee(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[hK(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await T(this,ul)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ln(i,"CALL_EXCEPTION"))throw i}return null},Jm=new WeakSet,nP=async function(e,t){const r=await yu.getEnsAddress(e);try{const i=await new jc(r,["function resolver(bytes32) view returns (address)"],e).resolver(d1(t),{enableCcipRead:!0});return i===wd?null:i}catch(s){throw s}return null},q(yu,Jm);let Sm=yu;const MD=BigInt(0);function ot(n,e){return function(t){return t==null?e:n(t)}}function Tm(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function Pd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ee(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function hJ(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Uc(n){return V(At(n,!0),"invalid data","value",n),n}function yn(n){return V(At(n,32),"invalid hash","value",n),n}const pJ=Pd({address:dt,blockHash:yn,blockNumber:Je,data:Uc,index:Je,removed:ot(hJ,!1),topics:Tm(yn),transactionHash:yn,transactionIndex:Je},{index:["logIndex"]});function gJ(n){return pJ(n)}const mJ=Pd({hash:ot(yn),parentHash:yn,parentBeaconBlockRoot:ot(yn,null),number:Je,timestamp:Je,nonce:ot(Uc),difficulty:Ae,gasLimit:Ae,gasUsed:Ae,stateRoot:ot(yn,null),receiptsRoot:ot(yn,null),blobGasUsed:ot(Ae,null),excessBlobGas:ot(Ae,null),miner:ot(dt),prevRandao:ot(yn,null),extraData:Uc,baseFeePerGas:ot(Ae)},{prevRandao:["mixHash"]});function yJ(n){const e=mJ(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:DD(t)),e}const bJ=Pd({transactionIndex:Je,blockNumber:Je,transactionHash:yn,address:dt,topics:Tm(yn),data:Uc,index:Je,blockHash:yn},{index:["logIndex"]});function wJ(n){return bJ(n)}const vJ=Pd({to:ot(dt,null),from:ot(dt,null),contractAddress:ot(dt,null),index:Je,root:ot(we),gasUsed:Ae,blobGasUsed:ot(Ae,null),logsBloom:ot(Uc),blockHash:yn,hash:yn,logs:Tm(wJ),blockNumber:Je,cumulativeGasUsed:Ae,effectiveGasPrice:ot(Ae),blobGasPrice:ot(Ae,null),status:ot(Je),type:ot(Je,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function xJ(n){return vJ(n)}function DD(n){n.to&&Ae(n.to)===MD&&(n.to="0x0000000000000000000000000000000000000000");const e=Pd({hash:yn,index:ot(Je,void 0),type:t=>t==="0x"||t==null?0:Je(t),accessList:ot(Co,null),blobVersionedHashes:ot(Tm(yn,!0),null),blockHash:ot(yn,null),blockNumber:ot(Je,null),transactionIndex:ot(Je,null),from:dt,gasPrice:ot(Ae),maxPriorityFeePerGas:ot(Ae),maxFeePerGas:ot(Ae),maxFeePerBlobGas:ot(Ae,null),gasLimit:Ae,to:ot(dt,null),value:Ae,nonce:Je,data:Uc,creates:ot(dt,null),chainId:ot(Ae,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=gG(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=as.from(n.signature):e.signature=as.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Ae(e.blockHash)===MD&&(e.blockHash=null),e}const AJ="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Id{constructor(e){$(this,"name");Oe(this,{name:e})}clone(){return new Id(this.name)}}class Nm extends Id{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);$(this,"effectiveBlock");$(this,"txBase");$(this,"txCreate");$(this,"txDataZero");$(this,"txDataNonzero");$(this,"txAccessListStorageKey");$(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),V(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),Oe(this,s)}clone(){return new Nm(this.effectiveBlock,this)}}class Om extends Id{constructor(t,r){super("org.ethers.plugins.network.Ens");$(this,"address");$(this,"targetNetwork");Oe(this,{address:t||AJ,targetNetwork:r??1})}clone(){return new Om(this.address,this.targetNetwork)}}class EJ extends Id{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");q(this,Kd);q(this,Jd);I(this,Kd,t),I(this,Jd,r)}get url(){return T(this,Kd)}get processFunc(){return T(this,Jd)}clone(){return this}}Kd=new WeakMap,Jd=new WeakMap;const O1=new Map,vu=class vu{constructor(e,t){q(this,bu);q(this,wu);q(this,_o);I(this,bu,e),I(this,wu,Ae(t)),I(this,_o,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,bu)}set name(e){I(this,bu,e)}get chainId(){return T(this,wu)}set chainId(e){I(this,wu,Ae(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Ae(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Ae(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Ae(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,_o).values())}attachPlugin(e){if(T(this,_o).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,_o).set(e.name,e.clone()),this}getPlugin(e){return T(this,_o).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new vu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new Nm;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=Co(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(kJ(),e==null)return vu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=O1.get(e);if(t)return t();if(typeof e=="bigint")return new vu("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new vu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Om(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=O1.get(e);r&&V(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),O1.set(e,t)}};bu=new WeakMap,wu=new WeakMap,_o=new WeakMap;let Yt=vu;function PD(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function ID(n){return new EJ(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:PD(a.maxFee,9),maxPriorityFeePerGas:PD(a.maxPriorityFee,9)}}catch(i){ee(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let LD=!1;function kJ(){if(LD)return;LD=!0;function n(e,t,r){const s=function(){const i=new Yt(e,t);return r.ensNetwork!=null&&i.attachPlugin(new Om(null,r.ensNetwork)),i.attachPlugin(new Nm),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};Yt.register(e,s),Yt.register(t,s),r.altNames&&r.altNames.forEach(i=>{Yt.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[ID("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[ID("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function R1(n){return JSON.parse(JSON.stringify(n))}class CJ{constructor(e){q(this,xu);q(this,_i);q(this,Ur);q(this,Bo);q(this,Qs);I(this,_i,e),I(this,Ur,null),I(this,Bo,4e3),I(this,Qs,-2)}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){I(this,Bo,e)}start(){T(this,Ur)||(I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo))),fe(this,xu,ny).call(this))}stop(){T(this,Ur)&&(T(this,_i)._clearTimeout(T(this,Ur)),I(this,Ur,null))}pause(e){this.stop(),e&&I(this,Qs,-2)}resume(){this.start()}}_i=new WeakMap,Ur=new WeakMap,Bo=new WeakMap,Qs=new WeakMap,xu=new WeakSet,ny=async function(){try{const e=await T(this,_i).getBlockNumber();if(T(this,Qs)===-2){I(this,Qs,e);return}if(e!==T(this,Qs)){for(let t=T(this,Qs)+1;t<=e;t++){if(T(this,Ur)==null)return;await T(this,_i).emit("block",t)}I(this,Qs,e)}}catch{}T(this,Ur)!=null&&I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo)))};class M1{constructor(e){q(this,fl);q(this,dl);q(this,Fo);I(this,fl,e),I(this,Fo,!1),I(this,dl,t=>{this._poll(t,T(this,fl))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Fo)||(I(this,Fo,!0),T(this,dl).call(this,-2),T(this,fl).on("block",T(this,dl)))}stop(){T(this,Fo)&&(I(this,Fo,!1),T(this,fl).off("block",T(this,dl)))}pause(e){this.stop()}resume(){this.start()}}fl=new WeakMap,dl=new WeakMap,Fo=new WeakMap;class SJ extends M1{constructor(t,r){super(t);q(this,Au);q(this,Bi);I(this,Au,r),I(this,Bi,-2)}pause(t){t&&I(this,Bi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(T(this,Au));s!=null&&(T(this,Bi)===-2?I(this,Bi,s.number):s.number>T(this,Bi)&&(r.emit(T(this,Au),s.number),I(this,Bi,s.number)))}}Au=new WeakMap,Bi=new WeakMap;class TJ extends M1{constructor(t,r){super(t);q(this,qm);I(this,qm,R1(r))}async _poll(t,r){throw new Error("@TODO")}}qm=new WeakMap;class NJ extends M1{constructor(t,r){super(t);q(this,Eu);I(this,Eu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(T(this,Eu));s&&r.emit(T(this,Eu),s)}}Eu=new WeakMap;class D1{constructor(e,t){q(this,Qm);q(this,Fi);q(this,ku);q(this,Cu);q(this,jo);q(this,Hr);I(this,Fi,e),I(this,ku,R1(t)),I(this,Cu,fe(this,Qm,rP).bind(this)),I(this,jo,!1),I(this,Hr,-2)}start(){T(this,jo)||(I(this,jo,!0),T(this,Hr)===-2&&T(this,Fi).getBlockNumber().then(e=>{I(this,Hr,e)}),T(this,Fi).on("block",T(this,Cu)))}stop(){T(this,jo)&&(I(this,jo,!1),T(this,Fi).off("block",T(this,Cu)))}pause(e){this.stop(),e&&I(this,Hr,-2)}resume(){this.start()}}Fi=new WeakMap,ku=new WeakMap,Cu=new WeakMap,jo=new WeakMap,Hr=new WeakMap,Qm=new WeakSet,rP=async function(e){if(T(this,Hr)===-2)return;const t=R1(T(this,ku));t.fromBlock=T(this,Hr)+1,t.toBlock=e;const r=await T(this,Fi).getLogs(t);if(r.length===0){T(this,Hr)<e-60&&I(this,Hr,e-60);return}for(const s of r)T(this,Fi).emit(T(this,ku),s),I(this,Hr,s.blockNumber)};const OJ=BigInt(2),RJ=10;function Rm(n){return n&&typeof n.then=="function"}function Mm(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class Dm{constructor(e){$(this,"name");Oe(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function MJ(n){return JSON.parse(JSON.stringify(n))}function P1(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function I1(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(At(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:Mm("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:Mm("orphan",t),filter:MJ(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?P1(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{At(a)?s.push(a):i.push((async()=>{s.push(await Bn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=P1(s.map(a=>a.toLowerCase()))}return{filter:r,tag:Mm("event",r),type:"event"}}V(!1,"unknown ProviderEvent","event",n)}function L1(){return new Date().getTime()}const DJ={cacheTimeout:250,pollingInterval:4e3};class Pm{constructor(e,t){q(this,nt);q(this,Cn);q(this,Uo);q(this,Sn);q(this,Su);q(this,Ar);q(this,hl);q(this,Ho);q(this,ji);q(this,qd);q(this,zr);q(this,Tu);q(this,Nu);if(I(this,Nu,Object.assign({},DJ,t||{})),e==="any")I(this,hl,!0),I(this,Ar,null);else if(e){const r=Yt.from(e);I(this,hl,!1),I(this,Ar,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else I(this,hl,!1),I(this,Ar,null);I(this,ji,-1),I(this,Ho,new Map),I(this,Cn,new Map),I(this,Uo,new Map),I(this,Sn,null),I(this,Su,!1),I(this,qd,1),I(this,zr,new Map),I(this,Tu,!1)}get pollingInterval(){return T(this,Nu).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Uo).values())}attachPlugin(e){if(T(this,Uo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Uo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Uo).get(e)||null}get disableCcipRead(){return T(this,Tu)}set disableCcipRead(e){I(this,Tu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Ln(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}ee(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}ee(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new XK(yJ(e),this)}_wrapLog(e,t){return new Rd(gJ(e),this)}_wrapTransactionReceipt(e,t){return new mD(xJ(e),this)}_wrapTransactionResponse(e,t){return new Md(DD(e),this)}_detectNetwork(){ee(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ee(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Je(await fe(this,nt,Er).call(this,{method:"getBlockNumber"}),"%response");return T(this,ji)>=0&&I(this,ji,e),e}_getAddress(e){return Bn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(At(e))return At(e,32)?e:La(e);if(typeof e=="bigint"&&(e=Je(e,"blockTag")),typeof e=="number")return e>=0?La(e):T(this,ji)>=0?La(T(this,ji)+e):this.getBlockNumber().then(t=>La(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?P1(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=Am(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Bn(t[s],this);Rm(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);Rm(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(T(this,Ar)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw T(this,Ar)===s&&I(this,Ar,null),i}})();return I(this,Ar,s),(await s).clone()}const e=T(this,Ar),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(T(this,hl)?(this.emit("network",r,t),T(this,Ar)===e&&I(this,Ar,Promise.resolve(r))):ee(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await An({_block:fe(this,nt,ox).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getGasPrice"});return Ae(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getPriorityFee"});return Ae(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*OJ+l),new gD(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Ln(r.url),i=await r.processFunc(t,this,s);return new gD(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Rm(t)&&(t=await t),Ae(await fe(this,nt,Er).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await An({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await fe(this,nt,ix).call(this,fe(this,nt,sx).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return Ae(await fe(this,nt,th).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Je(await fe(this,nt,th).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return we(await fe(this,nt,th).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=Ae(t,"position");return we(await fe(this,nt,th).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await An({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Nd.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,ox).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await fe(this,nt,Er).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await An({network:this.getNetwork(),result:fe(this,nt,Er).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:we(t)}async getLogs(e){let t=this._getFilter(e);Rm(t)&&(t=await t);const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){ee(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Sm.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=dt(e);const t=d1(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Sm.getEnsAddress(this),i=await new jc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===wd)return null;const a=await new jc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(ln(r,"BAD_DATA")&&r.value==="0x"||ln(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(Nt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){ee(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,zr).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,zr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Zd(this,qd)._++,s=()=>{T(this,zr).delete(r),e()};if(this.paused)T(this,zr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);T(this,zr).set(r,{timer:i,func:s,time:L1()})}return r}_forEachSubscriber(e){for(const t of T(this,Cn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Dm(e.type);case"block":{const t=new CJ(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new SJ(this,e.type);case"event":return new D1(this,e.filter);case"transaction":return new NJ(this,e.hash);case"orphan":return new TJ(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of T(this,Cn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),T(this,Sn)!=null&&t.pause(T(this,Sn));break}}async on(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async once(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async emit(e,...t){const r=await fe(this,nt,nh).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new XO(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of T(this,Cn).values())t+=r.length;return t}async listeners(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of T(this,Cn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await fe(this,nt,nh).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await fe(this,nt,ry).call(this,e);r&&s.stop(),T(this,Cn).delete(t)}else for(const[t,{started:r,subscriber:s}]of T(this,Cn))r&&s.stop(),T(this,Cn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Su)}destroy(){this.removeAllListeners();for(const e of T(this,zr).keys())this._clearTimeout(e);I(this,Su,!0)}get paused(){return T(this,Sn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(I(this,ji,-1),T(this,Sn)!=null){if(T(this,Sn)==!!e)return;ee(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),I(this,Sn,!!e);for(const t of T(this,zr).values())t.timer&&clearTimeout(t.timer),t.time=L1()-t.time}resume(){if(T(this,Sn)!=null){this._forEachSubscriber(e=>e.resume()),I(this,Sn,null);for(const e of T(this,zr).values()){let t=e.time;t<0&&(t=0),e.time=L1(),setTimeout(e.func,t)}}}}Cn=new WeakMap,Uo=new WeakMap,Sn=new WeakMap,Su=new WeakMap,Ar=new WeakMap,hl=new WeakMap,Ho=new WeakMap,ji=new WeakMap,qd=new WeakMap,zr=new WeakMap,Tu=new WeakMap,Nu=new WeakMap,nt=new WeakSet,Er=async function(e){const t=T(this,Nu).cacheTimeout;if(t<0)return await this._perform(e);const r=Mm(e.method,e);let s=T(this,Ho).get(r);return s||(s=this._perform(e),T(this,Ho).set(r,s),setTimeout(()=>{T(this,Ho).get(r)===s&&T(this,Ho).delete(r)},t)),await s},sx=async function(e,t,r){ee(r<RJ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=Am(e);try{return we(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Rv(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Ft(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Bn(s.to,this);let l;try{l=BJ(Ft(i.data,4))}catch(f){ee(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}ee(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);ee(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Ut([l.selector,_J([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await fe(this,nt,sx).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},ix=async function(e){const{value:t}=await An({network:this.getNetwork(),value:e});return t},th=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await fe(this,nt,ix).call(this,fe(this,nt,Er).call(this,Object.assign(e,{address:s,blockTag:i})))},ox=async function(e,t){if(At(e,32))return await fe(this,nt,Er).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await fe(this,nt,Er).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},nh=async function(e,t){let r=await I1(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await I1({orphan:"drop-log",log:t[0]},this)),T(this,Cn).get(r.tag)||null},ry=async function(e){const t=await I1(e,this),r=t.tag;let s=T(this,Cn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,Cn).set(r,s)),s};function PJ(n,e){try{const t=_1(n,e);if(t)return Cc(t)}catch{}return null}function _1(n,e){if(n==="0x")return null;try{const t=Je(Ft(n,e,e+32)),r=Je(Ft(n,t,t+32));return Ft(n,t+32,t+32+r)}catch{}return null}function _D(n){const e=In(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function IJ(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const LJ=new Uint8Array([]);function _J(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(LJ),t+=32;for(let r=0;r<n.length;r++){const s=lt(n[r]);e[r]=_D(t),e.push(_D(s.length)),e.push(IJ(s)),t+=32+Math.ceil(s.length/32)*32}return Ut(e)}const BD="0x0000000000000000000000000000000000000000000000000000000000000000";function BJ(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ee(Ec(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Ft(n,0,32);ee(Ft(t,0,12)===Ft(BD,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Ft(t,12);try{const r=[],s=Je(Ft(n,32,64)),i=Je(Ft(n,s,s+32)),o=Ft(n,s+32);for(let a=0;a<i;a++){const l=PJ(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{ee(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_1(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{ee(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ee(Ft(n,100,128)===Ft(BD,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Ft(n,96,100);try{const r=_1(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{ee(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Hc(n,e){if(n.provider)return n.provider;ee(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function FD(n,e){let t=Am(e);if(t.to!=null&&(t.to=Bn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Bn(r,n)]).then(([s,i])=>(V(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await An(t)}class FJ{constructor(e){$(this,"provider");Oe(this,{provider:e||null})}async getNonce(e){return Hc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await FD(this,e)}async populateTransaction(e){const t=Hc(this,"populateTransaction"),r=await FD(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=Ae(r.chainId);V(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();ee(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ee(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ee(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await An(r)}async estimateGas(e){return Hc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Hc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Hc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Hc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=Nd.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const jD=new Set;function zc(n){jD.has(n)||(jD.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function jJ(n){return JSON.parse(JSON.stringify(n))}class UD{constructor(e){q(this,Vo);q(this,jn);q(this,Ys);q(this,pl);q(this,zo);q(this,gl);q(this,Ou);I(this,jn,e),I(this,Ys,null),I(this,pl,fe(this,Vo,ax).bind(this)),I(this,zo,!1),I(this,gl,null),I(this,Ou,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,zo)||(I(this,zo,!0),fe(this,Vo,ax).call(this,-2))}stop(){T(this,zo)&&(I(this,zo,!1),I(this,Ou,!0),fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl)))}pause(e){e&&fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl))}resume(){this.start()}}jn=new WeakMap,Ys=new WeakMap,pl=new WeakMap,zo=new WeakMap,gl=new WeakMap,Ou=new WeakMap,Vo=new WeakSet,ax=async function(e){try{T(this,Ys)==null&&I(this,Ys,this._subscribe(T(this,jn)));let t=null;try{t=await T(this,Ys)}catch(i){if(!ln(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){I(this,Ys,null),T(this,jn)._recoverSubscriber(this,this._recover(T(this,jn)));return}const r=await T(this,jn).getNetwork();if(T(this,gl)||I(this,gl,r),T(this,gl).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,Ou))return;const s=await T(this,jn).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,jn),s)}catch(t){console.log("@TODO",t)}T(this,jn).once("block",T(this,pl))},lx=function(){const e=T(this,Ys);e&&(I(this,Ys,null),e.then(t=>{T(this,jn).destroyed||T(this,jn).send("eth_uninstallFilter",[t])}))};class UJ extends UD{constructor(t,r){super(t);q(this,ml);I(this,ml,jJ(r))}_recover(t){return new D1(t,T(this,ml))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,ml)])}async _emitResults(t,r){for(const s of r)t.emit(T(this,ml),t._wrapLog(s,t._network))}}ml=new WeakMap;class HJ extends UD{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const zJ="bigint,boolean,function,number,string,symbol".split(/,/g);function Im(n){if(n==null||zJ.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(Im);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function VJ(n){return new Promise(e=>{setTimeout(e,n)})}function Vc(n){return n&&n.toLowerCase()}function HD(n){return n&&typeof n.pollingInterval=="number"}const zD={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class B1 extends FJ{constructor(t,r){super(t);$(this,"address");r=dt(r),Oe(this,{address:r})}connect(t){ee(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=Im(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Bn(o,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Bn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(ln(u,"CANCELLED")||ln(u,"BAD_DATA")||ln(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(ln(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",Nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=Im(t);if(r.from){const i=await Bn(r.from,this.provider);V(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("personal_sign",[we(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=Im(s),o=await wm.resolveNames(t,r,i,async a=>{const l=await Bn(a);return V(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(wm.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),we(r)])}}class VD extends Pm{constructor(t,r){super(t,r);q(this,Qd);q(this,yl);q(this,Ru);q(this,Ui);q(this,Xs);q(this,ps);q(this,Vr);q(this,tr);I(this,Ru,1),I(this,yl,Object.assign({},zD,r||{})),I(this,Ui,[]),I(this,Xs,null),I(this,Vr,null),I(this,tr,null);{let i=null;const o=new Promise(a=>{i=a});I(this,ps,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(V(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&I(this,Vr,Yt.from(t))):s&&(V(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),I(this,Vr,s))}_getOption(t){return T(this,yl)[t]}get _network(){return ee(T(this,Vr),"network is not available yet","NETWORK_ERROR"),T(this,Vr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&Ae(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,Vr))return T(this,Vr)}else return t;return T(this,tr)?await T(this,tr):this.ready?(I(this,tr,(async()=>{try{const r=Yt.from(Ae(await this.send("eth_chainId",[])));return I(this,tr,null),r}catch(r){throw I(this,tr,null),r}})()),await T(this,tr)):(I(this,tr,(async()=>{const r={id:Zd(this,Ru)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],I(this,tr,null)}catch(i){throw I(this,tr,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return Yt.from(Ae(s.result));throw this.getRpcError(r,s)})()),await T(this,tr))}_start(){T(this,ps)==null||T(this,ps).resolve==null||(T(this,ps).resolve(),I(this,ps,null),(async()=>{for(;T(this,Vr)==null&&!this.destroyed;)try{I(this,Vr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await VJ(1e3)}fe(this,Qd,cx).call(this)})())}async _waitUntilReady(){if(T(this,ps)!=null)return await T(this,ps).promise}_getSubscriber(t){return t.type==="pending"?new HJ(this):t.type==="event"?this._getOption("polling")?new D1(this,t.filter):new UJ(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Dm("orphan"):super._getSubscriber(t)}get ready(){return T(this,ps)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=La(Ae(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=we(t[s]))}),t.accessList&&(r.accessList=Co(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Vc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Vc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Vc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Vc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Vc):t.filter.address=Vc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return Nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=F1(i),c=Bc.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify(WJ(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return Nt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return Nt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return Nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?Nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):Nt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Zd(this,Ru)._++,i=new Promise((o,a)=>{T(this,Ui).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return fe(this,Qd,cx).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new B1(this,i[t])}const{accounts:s}=await An({network:this.getNetwork(),accounts:r});t=dt(t);for(const i of s)if(dt(i)===t)return new B1(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new B1(this,r))}destroy(){T(this,Xs)&&(clearTimeout(T(this,Xs)),I(this,Xs,null));for(const{payload:t,reject:r}of T(this,Ui))r(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));I(this,Ui,[]),super.destroy()}}yl=new WeakMap,Ru=new WeakMap,Ui=new WeakMap,Xs=new WeakMap,ps=new WeakMap,Vr=new WeakMap,tr=new WeakMap,Qd=new WeakSet,cx=function(){if(T(this,Xs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");I(this,Xs,setTimeout(()=>{I(this,Xs,null);const r=T(this,Ui);for(I(this,Ui,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==T(this,yl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>T(this,yl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=Nt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class $J extends VD{constructor(t,r){super(t,r);q(this,$o);let s=this._getOption("pollingInterval");s==null&&(s=zD.pollingInterval),I(this,$o,s)}_getSubscriber(t){const r=super._getSubscriber(t);return HD(r)&&(r.pollingInterval=T(this,$o)),r}get pollingInterval(){return T(this,$o)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");I(this,$o,t),this._forEachSubscriber(r=>{HD(r)&&(r.pollingInterval=T(this,$o))})}}$o=new WeakMap;class Si extends $J{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);q(this,Mu);typeof t=="string"?I(this,Mu,new Ln(t)):I(this,Mu,t.clone())}_getConnection(){return T(this,Mu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}Mu=new WeakMap;function F1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&At(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=F1(n[e]);if(t)return t}return null}if(typeof n=="string")try{return F1(JSON.parse(n))}catch{}return null}function j1(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)j1(n[t],e);if(typeof n=="string")try{return j1(JSON.parse(n),e)}catch{}}}function WJ(n){const e=[];return j1(n,e),e}const Lm="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function GJ(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}V(!1,"unsupported network","network",n)}class _m extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Lm);const i={polling:!0,staticNetwork:s},o=_m.getRequest(s,r);super(o,s,i);$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new _m(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=Lm);const s=new Ln(`https://${GJ(t.name)}/${r}`);return s.allowGzip=!0,r===Lm&&(s.retryFunc=async(i,o,a)=>(zc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===Lm}}const Bm="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function KJ(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}V(!1,"unsupported network","network",n)}class Fm extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Bm);const i=Fm.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Fm(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await An({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return ee(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;ee(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===Bm}static getRequest(t,r){r==null&&(r=Bm);const s=new Ln(`https://${KJ(t.name)}/v2/${r}`);return s.allowGzip=!0,r===Bm&&(s.retryFunc=async(i,o,a)=>(zc("alchemy"),!0)),s}}function jm(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}V(!1,"unsupported network","network",n)}function JJ(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}V(!1,"unsupported network","network",n)}class Um extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=jm(s.name));const i=Um.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Um(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===jm(this._network.name)}static getRequest(t,r){r==null&&(r=jm(t.name));const s=new Ln(`https://${JJ(t.name)}/${r}`);return s.allowGzip=!0,r===jm(t.name)&&(s.retryFunc=async(i,o,a)=>(zc("ChainstackProvider"),!0)),s}}class qJ extends Si{constructor(e){e==null&&(e="mainnet");const t=Yt.from(e);V(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const $D=2e3;function QJ(n){return n&&typeof n.then=="function"}const YJ="org.ethers.plugins.provider.Etherscan",XJ=["enableCcipRead"];let ZJ=1;class eq extends Pm{constructor(t,r){const s=r??null;super();$(this,"network");$(this,"apiKey");q(this,Du);const i=Yt.from(t);I(this,Du,i.getPlugin(YJ)),Oe(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(T(this,Du))return T(this,Du).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}V(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=ZJ++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Ln(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&zc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(Cc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,$D)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,$D)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),ee(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),ee(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(Cc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),ee(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(XJ.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=La(i);else if(s==="accessList")i="["+Co(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;ee(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=we(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(ln(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&ee(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Bc.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=Nd.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&ee(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&ee(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&ee(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});ee(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);QJ(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new jc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Du=new WeakMap;function tq(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const nq=tq().WebSocket;class U1{constructor(e,t){q(this,Zs);q(this,Yd);q(this,Wo);q(this,bl);q(this,Go);I(this,Zs,e),I(this,Yd,JSON.stringify(t)),I(this,Wo,null),I(this,bl,null),I(this,Go,null)}get filter(){return JSON.parse(T(this,Yd))}start(){I(this,Wo,T(this,Zs).send("eth_subscribe",this.filter).then(e=>(T(this,Zs)._register(e,this),e)))}stop(){T(this,Wo).then(e=>{T(this,Zs).destroyed||T(this,Zs).send("eth_unsubscribe",[e])}),I(this,Wo,null)}pause(e){ee(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),I(this,bl,!!e)}resume(){I(this,bl,null)}_handleMessage(e){if(T(this,Wo)!=null&&T(this,bl)===null){let t=T(this,Go);t==null?t=this._emit(T(this,Zs),e):t=t.then(async()=>{await this._emit(T(this,Zs),e)}),I(this,Go,t.then(()=>{T(this,Go)===t&&I(this,Go,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Zs=new WeakMap,Yd=new WeakMap,Wo=new WeakMap,bl=new WeakMap,Go=new WeakMap;class rq extends U1{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class sq extends U1{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class iq extends U1{constructor(t,r){super(t,["logs",r]);q(this,Xd);I(this,Xd,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Xd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Xd=new WeakMap;class oq extends VD{constructor(t,r){const s=Object.assign({},r??{});V(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);q(this,wl);q(this,Pu);q(this,Ko);I(this,wl,new Map),I(this,Pu,new Map),I(this,Ko,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Dm("close");case"block":return new rq(this);case"pending":return new sq(this);case"event":return new iq(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Dm("drop-log")}return super._getSubscriber(t)}_register(t,r){T(this,Pu).set(t,r);const s=T(this,Ko).get(t);if(s){for(const i of s)r._handleMessage(i);T(this,Ko).delete(t)}}async _send(t){V(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{T(this,wl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=T(this,wl).get(r.id);if(s==null){this.emit("error",Nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,wl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=T(this,Pu).get(s);if(i)i._handleMessage(r.params.result);else{let o=T(this,Ko).get(s);o==null&&(o=[],T(this,Ko).set(s,o)),o.push(r.params.result)}}else{this.emit("error",Nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}wl=new WeakMap,Pu=new WeakMap,Ko=new WeakMap;class WD extends oq{constructor(t,r,s){super(r,s);q(this,vl);q(this,gs);typeof t=="string"?(I(this,vl,()=>new nq(t)),I(this,gs,T(this,vl).call(this))):typeof t=="function"?(I(this,vl,t),I(this,gs,t())):(I(this,vl,null),I(this,gs,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(T(this,gs)==null)throw new Error("websocket closed");return T(this,gs)}async _write(t){this.websocket.send(t)}async destroy(){T(this,gs)!=null&&(T(this,gs).close(),I(this,gs,null)),super.destroy()}}vl=new WeakMap,gs=new WeakMap;const Ld="84842078b09946638c03157f83405213";function aq(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}V(!1,"unsupported network","network",n)}class lq extends WD{constructor(t,r){const s=new _d(t,r),i=s._getConnection();ee(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ld}}class _d extends Si{constructor(t,r,s){t==null&&(t="mainnet");const i=Yt.from(t);r==null&&(r=Ld),s==null&&(s=null);const o=_d.getRequest(i,r,s);super(o,i,{staticNetwork:i});$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new _d(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ld}static getWebSocketProvider(t,r){return new lq(t,r)}static getRequest(t,r,s){r==null&&(r=Ld),s==null&&(s=null);const i=new Ln(`https://${aq(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===Ld&&(i.retryFunc=async(o,a,l)=>(zc("InfuraProvider"),!0)),i}}const Hm="919b412a057b5e9c9b6dce193c5a60242d6efadb";function cq(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}V(!1,"unsupported network","network",n)}class zm extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Hm);const i=zm.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"token");Oe(this,{token:r})}_getProvider(t){try{return new zm(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===Hm}static getRequest(t,r){r==null&&(r=Hm);const s=new Ln(`https://${cq(t.name)}/${r}`);return s.allowGzip=!0,r===Hm&&(s.retryFunc=async(i,o,a)=>(zc("QuickNodeProvider"),!0)),s}}const uq=BigInt("1"),fq=BigInt("2");function dq(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function hq(n){return new Promise(e=>{setTimeout(e,n)})}function H1(){return new Date().getTime()}function z1(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const GD={stallTimeout:400,priority:1,weight:1},KD={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function pq(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=H1()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function Bd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(Bd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return Bd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${Bd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function V1(n){if("error"in n){const t=n.error;return{tag:Bd(t),value:t}}const e=n.result;return{tag:Bd(e),value:e}}function Vm(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function $1(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+uq)/fq}function W1(n,e){const t=Vm(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function gq(n,e){if(n===1)return Je($1(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Je(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class mq extends Pm{constructor(t,r,s){super(r,s);q(this,rr);$(this,"quorum");$(this,"eventQuorum");$(this,"eventWorkers");q(this,nr);q(this,Hi);q(this,Iu);I(this,nr,t.map(i=>i instanceof Pm?Object.assign({provider:i},GD,KD):Object.assign({},GD,i,KD))),I(this,Hi,-2),I(this,Iu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(T(this,nr).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,V(this.quorum<=T(this,nr).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return T(this,nr).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return Yt.from(Ae(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=T(this,nr).map(c=>null),a=T(this,nr).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign(V1({result:d}),{weight:u})}catch(d){o[f]=Object.assign(V1({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=Vm(this.quorum,o.filter(d=>d!=null));if(ln(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=W1(this.quorum,o);if(ee(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(z1)}}),l instanceof Error)throw l;return l}await fe(this,rr,iP).call(this);const r=new Set;let s=0;for(;;){const o=fe(this,rr,ux).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await fe(this,rr,fx).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of T(this,nr))t.destroy();super.destroy()}}nr=new WeakMap,Hi=new WeakMap,Iu=new WeakMap,rr=new WeakSet,sP=function(t){const r=Array.from(t).map(i=>i.config),s=T(this,nr).slice();dq(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},ux=function(t,r){const s=fe(this,rr,sP).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=H1();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=H1()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await hq(s.stallTimeout),i.staller=null})(),t.add(i),i},iP=async function(){let t=T(this,Iu);if(!t){const r=[];T(this,nr).forEach(s=>{r.push((async()=>{await pq(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),I(this,Iu,t=(async()=>{await Promise.all(r);let s=null;for(const i of T(this,nr)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&ee(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},oP=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=V1(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{T(this,Hi)===-2&&I(this,Hi,Math.ceil(Je($1(this.quorum,T(this,nr).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Je(o.blockNumber).toString(),weight:o.weight}))))));const i=gq(this.quorum,s);return i===void 0?void 0:(i>T(this,Hi)&&I(this,Hi,i),T(this,Hi))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return $1(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?W1(this.quorum,s):Vm(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return Vm(this.quorum,s);case"broadcastTransaction":return W1(this.quorum,s)}ee(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${z1(r.method)})`})}},fx=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await fe(this,rr,oP).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)fe(this,rr,ux).call(this,t,r);return ee(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>z1(a.result))}}),await Promise.race(s),await fe(this,rr,fx).call(this,t,r)};function yq(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const bq="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function wq(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new Si(n);if(typeof n=="string"&&n.match(/^wss?:/)||yq(n))return new WD(n);let r=null;try{r=Yt.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new Si("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new Si("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new Fm(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new _m(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new Um(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new qJ(n))}catch{}if(t("etherscan"))try{s.push(new eq(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new _d(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new zm(n,o))}catch{}if(ee(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&bq.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new mq(s,void 0,{quorum:i})}const vq=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!mG(n))return t;try{const r=await xq(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},xq=async(n,e)=>await Aq(e).lookupAddress(n),Aq=n=>wq(n),JD=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],Eq=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o})=>{const[a]=L.useState(new xa),[l,c]=L.useState(!1),[u,f]=L.useState([...EW]),d=Ok({extensions:u,editorProps:j2,autofocus:"start"},[u]),h=Ok({extensions:u,editorProps:j2,autofocus:"start"}),p=L.useRef(()=>{}),g=(E,k=!1)=>{if(!t||!r||!E)throw new Error("docId or username is not provided");c(!0);const S=new l6(r,a,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});f([...u,I6.configure({document:a}),L6.configure({provider:S,user:{name:E,color:JD[Math.floor(Math.random()*JD.length)],isEns:k},render:NW})]);const M=setTimeout(()=>{c(!1)},100);return p.current=()=>{clearTimeout(M),S.destroy(),a.destroy(),c(!1)},p.current},b=L.useRef(null),y=L.useMemo(()=>t&&r&&d&&!l?d:h,[d,h,l]),A=E=>{var k;(k=b.current)!=null&&k.contains(E.target)||y==null||y.chain().focus().run()};L.useEffect(()=>{y==null||y.chain().focus()},[]),L.useEffect(()=>{y==null||y.setEditable(!n)},[n,y]),L.useEffect(()=>{e&&y&&setTimeout(()=>{y==null||y.commands.setContent(e.editorJSONData)})},[e,y]);const v=async()=>{if(!i)return;let E=i,k=!1;if(s){const{name:S,isEns:M}=await vq(i,s);E=S,k=M}g(E,k)};L.useEffect(()=>{t&&i?v():p.current()},[t]);const w=L.useMemo(()=>iv((E,k)=>{k({editorJSONData:E.getJSON()})},1e3),[o]);return L.useEffect(()=>{if(y&&o){const E=()=>{w(y,o)};return y.on("update",E),()=>{y.off("update",E)}}},[y,o,w]),{editor:y,focusEditor:A,ref:b,loading:l,connect:g}},kq=({title:n,content:e,contentClassName:t,open:r,onOpenChange:s,primaryAction:i,secondaryAction:o})=>C.jsx(uU,{open:r,onOpenChange:s,children:C.jsxs(fS,{className:"max-w-md sm:w-full w-[90%] z-20",children:[C.jsx(dS,{className:"px-4 pt-0 border-b-[1px]",children:C.jsx(pS,{className:"text-left text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e}),C.jsxs(hS,{className:"px-5 pb-5 justify-end sm:",children:[o&&C.jsx(hU,{asChild:!0,children:C.jsx(Pf,{disabled:o==null?void 0:o.isLoading,isLoading:o==null?void 0:o.isLoading,className:o==null?void 0:o.className,variant:(o==null?void 0:o.variant)||"ghost",onClick:o==null?void 0:o.onClick,children:o==null?void 0:o.label})}),i&&C.jsx(Pf,{disabled:i==null?void 0:i.isLoading,isLoading:i==null?void 0:i.isLoading,className:i==null?void 0:i.className,variant:(i==null?void 0:i.variant)||"primary",onClick:i==null?void 0:i.onClick,children:i==null?void 0:i.label})]})]})}),Cq=({editor:n})=>{const{toolVisibilty:e,setToolVisibility:t,bottomToolbar:r}=Sb({editor:n}),[s,i]=L.useState(""),[o,a]=L.useState(""),[l,c]=L.useState(!0),u=()=>{if(s===null){c(!1);return}if(s===""){n.chain().focus().extendMarkRange("link").unsetLink().run(),c(!1);return}let d=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(d="https://"+s);try{d.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0)}catch{console.error("Invalid URL"),c(!1);return}n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0),t(Re.NONE)},f=d=>{const{from:h,to:p}=d.state.selection;return d.state.doc.textBetween(h,p)};return C.jsxs(sS,{children:[C.jsx("div",{className:"flex w-full justify-between sm:justify-evenly",children:r.map(d=>{if(d)return C.jsx("div",{className:"flex items-center",children:d.title==="Text formating"||d.title==="Text color"?C.jsx(aU,{asChild:!0,children:C.jsx("button",{onClick:()=>d.onClick(),children:d.icon})}):C.jsx("button",{className:pe("flex items-center rounded px-2 py-1 text-black transition"),onClick:()=>d.onClick(),children:d.icon})},d.title)})}),e===Re.TEXT_FORMATING&&C.jsx(e8,{editor:n,setToolVisibility:t}),e===Re.TEXT_COLOR_PICKER&&C.jsx(t8,{editor:n,setToolVisibility:t}),e===Re.LINK_POPUP&&C.jsx(kq,{open:e===Re.LINK_POPUP,onOpenChange:()=>t(Re.NONE),title:"Link",content:C.jsxs("div",{className:"flex flex-col gap-4 w-full h-full px-4",children:[C.jsx(dp,{label:"Text",placeholder:"Link text",className:"w-full",defaultValue:f(n),onChange:d=>a(d.target.value)}),C.jsx(dp,{label:"Link",placeholder:"Paste URL",className:"w-full",defaultValue:n.getAttributes("link").href,onChange:d=>{i(d.target.value)},isValid:l,message:l?"":"Invalid URL"})]}),primaryAction:{label:"Save",onClick:()=>u(),isLoading:!1,className:"w-auto min-w-[80px]"},secondaryAction:{label:"Cancel",variant:"secondary",onClick:()=>t(Re.NONE),className:"w-auto min-w-[80px]"}})]})},Sq=({isPreviewMode:n=!1,data:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,renderToolLeftSection:a,ensProviderUrl:l})=>{const{editor:c,focusEditor:u,ref:f,loading:d}=Eq({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:l,username:s,onAutoSave:i});return!c||d?C.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[C.jsx(HS,{}),C.jsx("p",{children:"Loading Editor..."})]}):C.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:C.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:C.jsxs("div",{className:"w-full h-full",children:[C.jsx("div",{className:"flex items-center w-full h-16 fixed z-10 px-4 bg-[#f8f9fa]",children:C.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[C.jsx("div",{className:"grow",children:a==null?void 0:a({editor:c.getJSON()})}),!n&&C.jsx("div",{className:"grow relative hidden xl:block",children:C.jsx(f8,{editor:c})}),o==null?void 0:o({editor:c.getJSON()})]})}),C.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:C.jsx("div",{onClick:u,className:"mt-8 lg:mt-[5rem] w-full flex justify-center relative",children:C.jsx("div",{className:"px-4 pt-12 sm:p-[88px] h-screen bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:C.jsxs("div",{ref:f,className:"w-full h-full",children:[!n&&C.jsxs("div",{children:[C.jsx(n8,{editor:c}),C.jsx(c8,{editor:c,appendTo:f})]}),C.jsx(u8,{isPreviewMode:n,children:C.jsx(j3,{editor:c})})]})})})}),C.jsx("div",{className:"flex xl:hidden items-center w-full h-16 fixed bottom-0 z-10 px-4 bg-[#f8f9fa]",children:C.jsx(Cq,{editor:c})})]})})})};st.DdocEditor=Sq,Object.defineProperty(st,Symbol.toStringTag,{value:"Module"})});
|