@solarpunkltd/swarm-chat-js 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/index.d.ts +5 -2
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.esm.js +4494 -40026
  4. package/dist/index.js +11 -25
  5. package/dist/{src/lib → lib}/constants.d.ts +0 -3
  6. package/dist/lib/constants.d.ts.map +1 -0
  7. package/dist/lib/core.d.ts +30 -0
  8. package/dist/lib/core.d.ts.map +1 -0
  9. package/dist/{src/lib → lib}/history.d.ts +2 -1
  10. package/dist/lib/history.d.ts.map +1 -0
  11. package/dist/{src/lib → lib}/mine.d.ts.map +1 -1
  12. package/dist/lib/types/chat.d.ts +35 -0
  13. package/dist/lib/types/chat.d.ts.map +1 -0
  14. package/dist/lib/types/index.d.ts +3 -0
  15. package/dist/lib/types/index.d.ts.map +1 -0
  16. package/dist/{src/lib → lib}/types/message.d.ts +3 -5
  17. package/dist/lib/types/message.d.ts.map +1 -0
  18. package/dist/{src/lib → lib}/utils.d.ts +2 -5
  19. package/dist/lib/utils.d.ts.map +1 -0
  20. package/dist/swarm-chat-umd.js +11 -25
  21. package/dist/utils/bee.d.ts.map +1 -0
  22. package/dist/utils/common.d.ts.map +1 -0
  23. package/dist/utils/error.d.ts.map +1 -0
  24. package/dist/utils/eventEmitter.d.ts.map +1 -0
  25. package/dist/utils/logger.d.ts.map +1 -0
  26. package/dist/{src/utils → utils}/validation.d.ts +0 -1
  27. package/dist/utils/validation.d.ts.map +1 -0
  28. package/package.json +4 -1
  29. package/dist/src/index.d.ts +0 -5
  30. package/dist/src/index.d.ts.map +0 -1
  31. package/dist/src/lib/constants.d.ts.map +0 -1
  32. package/dist/src/lib/core.d.ts +0 -48
  33. package/dist/src/lib/core.d.ts.map +0 -1
  34. package/dist/src/lib/history.d.ts.map +0 -1
  35. package/dist/src/lib/swarmEventEmitterReader.d.ts +0 -15
  36. package/dist/src/lib/swarmEventEmitterReader.d.ts.map +0 -1
  37. package/dist/src/lib/types/chat.d.ts +0 -61
  38. package/dist/src/lib/types/chat.d.ts.map +0 -1
  39. package/dist/src/lib/types/index.d.ts +0 -4
  40. package/dist/src/lib/types/index.d.ts.map +0 -1
  41. package/dist/src/lib/types/message.d.ts.map +0 -1
  42. package/dist/src/lib/types/user.d.ts +0 -21
  43. package/dist/src/lib/types/user.d.ts.map +0 -1
  44. package/dist/src/lib/utils.d.ts.map +0 -1
  45. package/dist/src/utils/bee.d.ts.map +0 -1
  46. package/dist/src/utils/common.d.ts.map +0 -1
  47. package/dist/src/utils/error.d.ts.map +0 -1
  48. package/dist/src/utils/eventEmitter.d.ts.map +0 -1
  49. package/dist/src/utils/logger.d.ts.map +0 -1
  50. package/dist/src/utils/queue.d.ts +0 -16
  51. package/dist/src/utils/queue.d.ts.map +0 -1
  52. package/dist/src/utils/validation.d.ts.map +0 -1
  53. package/dist/src/utils/waitForBroadcast.d.ts +0 -10
  54. package/dist/src/utils/waitForBroadcast.d.ts.map +0 -1
  55. /package/dist/{src/lib → lib}/mine.d.ts +0 -0
  56. /package/dist/{src/utils → utils}/bee.d.ts +0 -0
  57. /package/dist/{src/utils → utils}/common.d.ts +0 -0
  58. /package/dist/{src/utils → utils}/error.d.ts +0 -0
  59. /package/dist/{src/utils → utils}/eventEmitter.d.ts +0 -0
  60. /package/dist/{src/utils → utils}/logger.d.ts +0 -0
@@ -1,25 +1,11 @@
1
- (function(ue,xt){typeof exports=="object"&&typeof module<"u"?xt(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],xt):(ue=typeof globalThis<"u"?globalThis:ue||self,xt(ue.SwarmChatJs={},ue.BeeJs))})(this,function(ue,xt){"use strict";var rZ=Object.defineProperty;var IT=ue=>{throw TypeError(ue)};var iZ=(ue,xt,ae)=>xt in ue?rZ(ue,xt,{enumerable:!0,configurable:!0,writable:!0,value:ae}):ue[xt]=ae;var Z=(ue,xt,ae)=>iZ(ue,typeof xt!="symbol"?xt+"":xt,ae),ib=(ue,xt,ae)=>xt.has(ue)||IT("Cannot "+ae);var T=(ue,xt,ae)=>(ib(ue,xt,"read from private field"),ae?ae.call(ue):xt.get(ue)),nt=(ue,xt,ae)=>xt.has(ue)?IT("Cannot add the same private member more than once"):xt instanceof WeakSet?xt.add(ue):xt.set(ue,ae),$=(ue,xt,ae,Br)=>(ib(ue,xt,"write to private field"),Br?Br.call(ue,ae):xt.set(ue,ae),ae),_t=(ue,xt,ae)=>(ib(ue,xt,"access private method"),ae);var rd=(ue,xt,ae,Br)=>({set _(kc){$(ue,xt,kc,ae)},get _(){return T(ue,xt,Br)}});var zu,Ya,Po,Gu,Vu,vi,Fs,Ku,ju,Fn,Vr,$s,Ja,Xa,tc,ts,xi,Mo,ec,id,gh,yh,mh,Kr,Wu,nc,Zu,Hs,rc,Qu,zp,Nr,jr,ic,sc,Lo,oc,ob,OT,Yu,Ju,Xu,ac,zs,uc,es,tl,el,nl,rl,il,sl,ol,al,cl,ul,ll,lc,Uo,Vs,Do,fl,Gp,wh,js,hl,Ap,NT,Yn,Si,bh,ab,dl,Vp,Fo,Fl,ns,rs,is,sr,ss,Kp,jp,Ws,_h,$o,pl,Ah,Eh,bk,Ho,hc,zo,$l,xp,CT,xh,Rh,yl,ml,Go,Zs,oi,Vo,os,bl,Wp,dc,pc,Ko,_l,qs,Rp,Al,Qs,El,vl,jo,ai,Sp,BT,or,Wo,ar,xl,Wr,gc,Zo,Ys,Sh,ci,Rl,Sl,se,Zr,cb,ub,sd,lb,od,Zp,_r,as,yc,qo,mc,Il,Qo,fb,hb,wc,bc,kl,Js,cs,Ii,ui,Cr,Ih,db,Yo,Tl,us,kh,Jo,_c,Xo,Th,Ac,Ol,ta,Ec,ki;var ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Br(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function kc(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}function PT(){this.__data__=[],this.size=0}var MT=PT;function LT(n,t){return n===t||n!==n&&t!==t}var pb=LT,UT=pb;function DT(n,t){for(var e=n.length;e--;)if(UT(n[e][0],t))return e;return-1}var ad=DT,FT=ad,$T=Array.prototype,HT=$T.splice;function zT(n){var t=this.__data__,e=FT(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():HT.call(t,e,1),--this.size,!0}var GT=zT,VT=ad;function KT(n){var t=this.__data__,e=VT(t,n);return e<0?void 0:t[e][1]}var jT=KT,WT=ad;function ZT(n){return WT(this.__data__,n)>-1}var qT=ZT,QT=ad;function YT(n,t){var e=this.__data__,r=QT(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var JT=YT,XT=MT,tO=GT,eO=jT,nO=qT,rO=JT;function Tc(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Tc.prototype.clear=XT,Tc.prototype.delete=tO,Tc.prototype.get=eO,Tc.prototype.has=nO,Tc.prototype.set=rO;var cd=Tc,iO=cd;function sO(){this.__data__=new iO,this.size=0}var oO=sO;function aO(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var cO=aO;function uO(n){return this.__data__.get(n)}var lO=uO;function fO(n){return this.__data__.has(n)}var hO=fO,dO=typeof ae=="object"&&ae&&ae.Object===Object&&ae,gb=dO,pO=gb,gO=typeof self=="object"&&self&&self.Object===Object&&self,yO=pO||gO||Function("return this")(),hs=yO,mO=hs,wO=mO.Symbol,qp=wO,yb=qp,mb=Object.prototype,bO=mb.hasOwnProperty,_O=mb.toString,Hl=yb?yb.toStringTag:void 0;function AO(n){var t=bO.call(n,Hl),e=n[Hl];try{n[Hl]=void 0;var r=!0}catch{}var i=_O.call(n);return r&&(t?n[Hl]=e:delete n[Hl]),i}var EO=AO,vO=Object.prototype,xO=vO.toString;function RO(n){return xO.call(n)}var SO=RO,wb=qp,IO=EO,kO=SO,TO="[object Null]",OO="[object Undefined]",bb=wb?wb.toStringTag:void 0;function NO(n){return n==null?n===void 0?OO:TO:bb&&bb in Object(n)?IO(n):kO(n)}var ud=NO;function CO(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var _b=CO,BO=ud,PO=_b,MO="[object AsyncFunction]",LO="[object Function]",UO="[object GeneratorFunction]",DO="[object Proxy]";function FO(n){if(!PO(n))return!1;var t=BO(n);return t==LO||t==UO||t==MO||t==DO}var Ab=FO,$O=hs,HO=$O["__core-js_shared__"],zO=HO,Qp=zO,Eb=function(){var n=/[^.]+$/.exec(Qp&&Qp.keys&&Qp.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function GO(n){return!!Eb&&Eb in n}var VO=GO,KO=Function.prototype,jO=KO.toString;function WO(n){if(n!=null){try{return jO.call(n)}catch{}try{return n+""}catch{}}return""}var vb=WO,ZO=Ab,qO=VO,QO=_b,YO=vb,JO=/[\\^$.*+?()[\]{}|]/g,XO=/^\[object .+?Constructor\]$/,tN=Function.prototype,eN=Object.prototype,nN=tN.toString,rN=eN.hasOwnProperty,iN=RegExp("^"+nN.call(rN).replace(JO,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sN(n){if(!QO(n)||qO(n))return!1;var t=ZO(n)?iN:XO;return t.test(YO(n))}var oN=sN;function aN(n,t){return n==null?void 0:n[t]}var cN=aN,uN=oN,lN=cN;function fN(n,t){var e=lN(n,t);return uN(e)?e:void 0}var Oc=fN,hN=Oc,dN=hs,pN=hN(dN,"Map"),Yp=pN,gN=Oc,yN=gN(Object,"create"),ld=yN,xb=ld;function mN(){this.__data__=xb?xb(null):{},this.size=0}var wN=mN;function bN(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var _N=bN,AN=ld,EN="__lodash_hash_undefined__",vN=Object.prototype,xN=vN.hasOwnProperty;function RN(n){var t=this.__data__;if(AN){var e=t[n];return e===EN?void 0:e}return xN.call(t,n)?t[n]:void 0}var SN=RN,IN=ld,kN=Object.prototype,TN=kN.hasOwnProperty;function ON(n){var t=this.__data__;return IN?t[n]!==void 0:TN.call(t,n)}var NN=ON,CN=ld,BN="__lodash_hash_undefined__";function PN(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=CN&&t===void 0?BN:t,this}var MN=PN,LN=wN,UN=_N,DN=SN,FN=NN,$N=MN;function Nc(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Nc.prototype.clear=LN,Nc.prototype.delete=UN,Nc.prototype.get=DN,Nc.prototype.has=FN,Nc.prototype.set=$N;var HN=Nc,Rb=HN,zN=cd,GN=Yp;function VN(){this.size=0,this.__data__={hash:new Rb,map:new(GN||zN),string:new Rb}}var KN=VN;function jN(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var WN=jN,ZN=WN;function qN(n,t){var e=n.__data__;return ZN(t)?e[typeof t=="string"?"string":"hash"]:e.map}var fd=qN,QN=fd;function YN(n){var t=QN(this,n).delete(n);return this.size-=t?1:0,t}var JN=YN,XN=fd;function t6(n){return XN(this,n).get(n)}var e6=t6,n6=fd;function r6(n){return n6(this,n).has(n)}var i6=r6,s6=fd;function o6(n,t){var e=s6(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var a6=o6,c6=KN,u6=JN,l6=e6,f6=i6,h6=a6;function Cc(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Cc.prototype.clear=c6,Cc.prototype.delete=u6,Cc.prototype.get=l6,Cc.prototype.has=f6,Cc.prototype.set=h6;var Sb=Cc,d6=cd,p6=Yp,g6=Sb,y6=200;function m6(n,t){var e=this.__data__;if(e instanceof d6){var r=e.__data__;if(!p6||r.length<y6-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new g6(r)}return e.set(n,t),this.size=e.size,this}var w6=m6,b6=cd,_6=oO,A6=cO,E6=lO,v6=hO,x6=w6;function Bc(n){var t=this.__data__=new b6(n);this.size=t.size}Bc.prototype.clear=_6,Bc.prototype.delete=A6,Bc.prototype.get=E6,Bc.prototype.has=v6,Bc.prototype.set=x6;var R6=Bc,S6="__lodash_hash_undefined__";function I6(n){return this.__data__.set(n,S6),this}var k6=I6;function T6(n){return this.__data__.has(n)}var O6=T6,N6=Sb,C6=k6,B6=O6;function hd(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new N6;++t<e;)this.add(n[t])}hd.prototype.add=hd.prototype.push=C6,hd.prototype.has=B6;var P6=hd;function M6(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var L6=M6;function U6(n,t){return n.has(t)}var D6=U6,F6=P6,$6=L6,H6=D6,z6=1,G6=2;function V6(n,t,e,r,i,s){var o=e&z6,c=n.length,u=t.length;if(c!=u&&!(o&&u>c))return!1;var f=s.get(n),h=s.get(t);if(f&&h)return f==t&&h==n;var y=-1,A=!0,b=e&G6?new F6:void 0;for(s.set(n,t),s.set(t,n);++y<c;){var R=n[y],k=t[y];if(r)var S=o?r(k,R,y,t,n,s):r(R,k,y,n,t,s);if(S!==void 0){if(S)continue;A=!1;break}if(b){if(!$6(t,function(B,H){if(!H6(b,H)&&(R===B||i(R,B,e,r,s)))return b.push(H)})){A=!1;break}}else if(!(R===k||i(R,k,e,r,s))){A=!1;break}}return s.delete(n),s.delete(t),A}var Ib=V6,K6=hs,j6=K6.Uint8Array,W6=j6;function Z6(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var q6=Z6;function Q6(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var Y6=Q6,kb=qp,Tb=W6,J6=pb,X6=Ib,tC=q6,eC=Y6,nC=1,rC=2,iC="[object Boolean]",sC="[object Date]",oC="[object Error]",aC="[object Map]",cC="[object Number]",uC="[object RegExp]",lC="[object Set]",fC="[object String]",hC="[object Symbol]",dC="[object ArrayBuffer]",pC="[object DataView]",Ob=kb?kb.prototype:void 0,Jp=Ob?Ob.valueOf:void 0;function gC(n,t,e,r,i,s,o){switch(e){case pC:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case dC:return!(n.byteLength!=t.byteLength||!s(new Tb(n),new Tb(t)));case iC:case sC:case cC:return J6(+n,+t);case oC:return n.name==t.name&&n.message==t.message;case uC:case fC:return n==t+"";case aC:var c=tC;case lC:var u=r&nC;if(c||(c=eC),n.size!=t.size&&!u)return!1;var f=o.get(n);if(f)return f==t;r|=rC,o.set(n,t);var h=X6(c(n),c(t),r,i,s,o);return o.delete(n),h;case hC:if(Jp)return Jp.call(n)==Jp.call(t)}return!1}var yC=gC;function mC(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var wC=mC,bC=Array.isArray,Xp=bC,_C=wC,AC=Xp;function EC(n,t,e){var r=t(n);return AC(n)?r:_C(r,e(n))}var vC=EC;function xC(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var RC=xC;function SC(){return[]}var IC=SC,kC=RC,TC=IC,OC=Object.prototype,NC=OC.propertyIsEnumerable,Nb=Object.getOwnPropertySymbols,CC=Nb?function(n){return n==null?[]:(n=Object(n),kC(Nb(n),function(t){return NC.call(n,t)}))}:TC,BC=CC;function PC(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var MC=PC;function LC(n){return n!=null&&typeof n=="object"}var dd=LC,UC=ud,DC=dd,FC="[object Arguments]";function $C(n){return DC(n)&&UC(n)==FC}var HC=$C,Cb=HC,zC=dd,Bb=Object.prototype,GC=Bb.hasOwnProperty,VC=Bb.propertyIsEnumerable,KC=Cb(function(){return arguments}())?Cb:function(n){return zC(n)&&GC.call(n,"callee")&&!VC.call(n,"callee")},jC=KC,pd={exports:{}};function WC(){return!1}var ZC=WC;pd.exports,function(n,t){var e=hs,r=ZC,i=t&&!t.nodeType&&t,s=i&&!0&&n&&!n.nodeType&&n,o=s&&s.exports===i,c=o?e.Buffer:void 0,u=c?c.isBuffer:void 0,f=u||r;n.exports=f}(pd,pd.exports);var Pb=pd.exports,qC=9007199254740991,QC=/^(?:0|[1-9]\d*)$/;function YC(n,t){var e=typeof n;return t=t??qC,!!t&&(e=="number"||e!="symbol"&&QC.test(n))&&n>-1&&n%1==0&&n<t}var JC=YC,XC=9007199254740991;function t3(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=XC}var Mb=t3,e3=ud,n3=Mb,r3=dd,i3="[object Arguments]",s3="[object Array]",o3="[object Boolean]",a3="[object Date]",c3="[object Error]",u3="[object Function]",l3="[object Map]",f3="[object Number]",h3="[object Object]",d3="[object RegExp]",p3="[object Set]",g3="[object String]",y3="[object WeakMap]",m3="[object ArrayBuffer]",w3="[object DataView]",b3="[object Float32Array]",_3="[object Float64Array]",A3="[object Int8Array]",E3="[object Int16Array]",v3="[object Int32Array]",x3="[object Uint8Array]",R3="[object Uint8ClampedArray]",S3="[object Uint16Array]",I3="[object Uint32Array]",Ve={};Ve[b3]=Ve[_3]=Ve[A3]=Ve[E3]=Ve[v3]=Ve[x3]=Ve[R3]=Ve[S3]=Ve[I3]=!0,Ve[i3]=Ve[s3]=Ve[m3]=Ve[o3]=Ve[w3]=Ve[a3]=Ve[c3]=Ve[u3]=Ve[l3]=Ve[f3]=Ve[h3]=Ve[d3]=Ve[p3]=Ve[g3]=Ve[y3]=!1;function k3(n){return r3(n)&&n3(n.length)&&!!Ve[e3(n)]}var T3=k3;function O3(n){return function(t){return n(t)}}var N3=O3,gd={exports:{}};gd.exports,function(n,t){var e=gb,r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s&&e.process,c=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();n.exports=c}(gd,gd.exports);var C3=gd.exports,B3=T3,P3=N3,Lb=C3,Ub=Lb&&Lb.isTypedArray,M3=Ub?P3(Ub):B3,Db=M3,L3=MC,U3=jC,D3=Xp,F3=Pb,$3=JC,H3=Db,z3=Object.prototype,G3=z3.hasOwnProperty;function V3(n,t){var e=D3(n),r=!e&&U3(n),i=!e&&!r&&F3(n),s=!e&&!r&&!i&&H3(n),o=e||r||i||s,c=o?L3(n.length,String):[],u=c.length;for(var f in n)(t||G3.call(n,f))&&!(o&&(f=="length"||i&&(f=="offset"||f=="parent")||s&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||$3(f,u)))&&c.push(f);return c}var K3=V3,j3=Object.prototype;function W3(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||j3;return n===e}var Z3=W3;function q3(n,t){return function(e){return n(t(e))}}var Q3=q3,Y3=Q3,J3=Y3(Object.keys,Object),X3=J3,tB=Z3,eB=X3,nB=Object.prototype,rB=nB.hasOwnProperty;function iB(n){if(!tB(n))return eB(n);var t=[];for(var e in Object(n))rB.call(n,e)&&e!="constructor"&&t.push(e);return t}var sB=iB,oB=Ab,aB=Mb;function cB(n){return n!=null&&aB(n.length)&&!oB(n)}var uB=cB,lB=K3,fB=sB,hB=uB;function dB(n){return hB(n)?lB(n):fB(n)}var pB=dB,gB=vC,yB=BC,mB=pB;function wB(n){return gB(n,mB,yB)}var bB=wB,Fb=bB,_B=1,AB=Object.prototype,EB=AB.hasOwnProperty;function vB(n,t,e,r,i,s){var o=e&_B,c=Fb(n),u=c.length,f=Fb(t),h=f.length;if(u!=h&&!o)return!1;for(var y=u;y--;){var A=c[y];if(!(o?A in t:EB.call(t,A)))return!1}var b=s.get(n),R=s.get(t);if(b&&R)return b==t&&R==n;var k=!0;s.set(n,t),s.set(t,n);for(var S=o;++y<u;){A=c[y];var B=n[A],H=t[A];if(r)var U=o?r(H,B,A,t,n,s):r(B,H,A,n,t,s);if(!(U===void 0?B===H||i(B,H,e,r,s):U)){k=!1;break}S||(S=A=="constructor")}if(k&&!S){var G=n.constructor,W=t.constructor;G!=W&&"constructor"in n&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof W=="function"&&W instanceof W)&&(k=!1)}return s.delete(n),s.delete(t),k}var xB=vB,RB=Oc,SB=hs,IB=RB(SB,"DataView"),kB=IB,TB=Oc,OB=hs,NB=TB(OB,"Promise"),CB=NB,BB=Oc,PB=hs,MB=BB(PB,"Set"),LB=MB,UB=Oc,DB=hs,FB=UB(DB,"WeakMap"),$B=FB,tg=kB,eg=Yp,ng=CB,rg=LB,ig=$B,$b=ud,Pc=vb,Hb="[object Map]",HB="[object Object]",zb="[object Promise]",Gb="[object Set]",Vb="[object WeakMap]",Kb="[object DataView]",zB=Pc(tg),GB=Pc(eg),VB=Pc(ng),KB=Pc(rg),jB=Pc(ig),sa=$b;(tg&&sa(new tg(new ArrayBuffer(1)))!=Kb||eg&&sa(new eg)!=Hb||ng&&sa(ng.resolve())!=zb||rg&&sa(new rg)!=Gb||ig&&sa(new ig)!=Vb)&&(sa=function(n){var t=$b(n),e=t==HB?n.constructor:void 0,r=e?Pc(e):"";if(r)switch(r){case zB:return Kb;case GB:return Hb;case VB:return zb;case KB:return Gb;case jB:return Vb}return t});var WB=sa,sg=R6,ZB=Ib,qB=yC,QB=xB,jb=WB,Wb=Xp,Zb=Pb,YB=Db,JB=1,qb="[object Arguments]",Qb="[object Array]",yd="[object Object]",XB=Object.prototype,Yb=XB.hasOwnProperty;function t8(n,t,e,r,i,s){var o=Wb(n),c=Wb(t),u=o?Qb:jb(n),f=c?Qb:jb(t);u=u==qb?yd:u,f=f==qb?yd:f;var h=u==yd,y=f==yd,A=u==f;if(A&&Zb(n)){if(!Zb(t))return!1;o=!0,h=!1}if(A&&!h)return s||(s=new sg),o||YB(n)?ZB(n,t,e,r,i,s):qB(n,t,u,e,r,i,s);if(!(e&JB)){var b=h&&Yb.call(n,"__wrapped__"),R=y&&Yb.call(t,"__wrapped__");if(b||R){var k=b?n.value():n,S=R?t.value():t;return s||(s=new sg),i(k,S,e,r,s)}}return A?(s||(s=new sg),QB(n,t,e,r,i,s)):!1}var e8=t8,n8=e8,Jb=dd;function Xb(n,t,e,r,i){return n===t?!0:n==null||t==null||!Jb(n)&&!Jb(t)?n!==n&&t!==t:n8(n,t,e,r,Xb,i)}var r8=Xb,i8=r8;function s8(n,t){return i8(n,t)}var o8=s8;const a8=Br(o8),zn=[];for(let n=0;n<256;++n)zn.push((n+256).toString(16).slice(1));function c8(n,t=0){return(zn[n[t+0]]+zn[n[t+1]]+zn[n[t+2]]+zn[n[t+3]]+"-"+zn[n[t+4]]+zn[n[t+5]]+"-"+zn[n[t+6]]+zn[n[t+7]]+"-"+zn[n[t+8]]+zn[n[t+9]]+"-"+zn[n[t+10]]+zn[n[t+11]]+zn[n[t+12]]+zn[n[t+13]]+zn[n[t+14]]+zn[n[t+15]]).toLowerCase()}let og;const u8=new Uint8Array(16);function l8(){if(!og){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");og=crypto.getRandomValues.bind(crypto)}return og(u8)}const t_={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function f8(n,t,e){if(t_.randomUUID&&!t&&!n)return t_.randomUUID();n=n||{};const r=n.random||(n.rng||l8)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,c8(r)}function ag(n){return new Promise(t=>{setTimeout(t,n)})}function zl(n){return(n.startsWith("0x")?n.slice(2):n).toLowerCase()}class Oi{constructor(){}static getInstance(){return Oi.instance||(Oi.instance=new Oi),Oi.instance}formatMessage(t,...e){return`[${new Date().toISOString()}] [${t.toUpperCase()}] - ${e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...t){console.log(this.formatMessage("log",...t))}info(...t){console.info(this.formatMessage("info",...t))}warn(...t){console.warn(this.formatMessage("warn",...t))}error(...t){console.error(this.formatMessage("error",...t))}debug(...t){console.debug(this.formatMessage("debug",...t))}}class md{constructor(){this.logger=Oi.getInstance()}handleError(t,e){const r=t instanceof Error?t.message:"Unknown error occurred",i=t instanceof Error?t.stack:null;this.logger.error(`Error in ${e||"unknown context"}: ${r}`,{stack:i})}}let h8=class{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}off(t,e){if(!this.events[t])return;const r=this.events[t].indexOf(e);r>-1&&this.events[t].splice(r,1)}cleanAll(){this.events={}}emit(t,e){this.events[t]&&this.events[t].forEach(r=>r(e))}};class e_{constructor(t={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new md,this.clearWaitTime=t.clearWaitTime||500}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const t=this.tasks.shift();if(t)try{const e=t();e instanceof Promise&&await e}catch(e){this.errorHandler.handleError(e,"Queue.processQueue")}}this.isProcessing=!1}}enqueue(t){this.tasks.push(t),this.processQueue()}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await ag(this.clearWaitTime);return this.isWaiting=!1,!1}}var n_={};(function(n){var t;Object.defineProperty(n,"__esModule",{value:!0}),n.Vector=n.Cache=n.Assertions=n.Strings=n.Types=n.Objects=n.Dates=n.Promises=n.Numbers=n.System=n.Arrays=n.Random=n.Elliptic=n.Binary=n.AsyncQueue=n.PubSubChannel=n.FixedPointNumber=n.MerkleTree=n.Chunk=n.Uint8ArrayWriter=n.Uint8ArrayReader=n.AsyncLazy=n.Lazy=n.Optional=void 0;async function e(a){return new Promise((l,d)=>a.then(d,l))}async function r(a){return e(Promise.all(a.map(e)))}async function i(a,l=1){const d=Jk(a,l),g=[],x=d.map(async L=>{for(const Q of L)g.push(await Q())});return await Promise.all(x),g}async function s(a){return new Promise(l=>setTimeout(()=>{l(!0)},a))}function o(a,l=Math.random){for(let d=a.length-1;d>0;d--){const g=Math.floor(l()*(d+1)),x=a[d];a[d]=a[g],a[g]=x}return a}function c(a){if(a.length===1)return a[0];throw Error(`Expected exactly one element, actual: ${a.length}`)}function u(a){return a.length===1?a[0]:null}function f(a){return a.length>0?a[0]:null}function h(a){if(!a.length)throw Error("Received empty array");return a[0]}function y(a,l){const d=[];for(let g=0;g<a;g++)d.push(l(g));return d}function A(a){const l=[];for(let d=0;d<a[0].length;d++){l.push([]);for(let g=0;g<a.length;g++)l[d].push(a[g][d])}return l}function b(a,l,d){const g=[];for(let x=0;x<a;x++){g.push([]);for(let L=0;L<l;L++)g[x].push(d)}return g}function R(a,l,d,g){if(d<0||g<0||g+l[0].length>a[0].length||d+l.length>a.length)return!1;for(let x=0;x<l.length;x++)for(let L=0;L<l[x].length;L++)if(l[x][L]!==void 0&&a[d+x][g+L]!==l[x][L])return!1;return!0}function k(a,l,d=Math.random){return o(_k(0,a.length-1),d).slice(0,l)}function S(a,l){return a.map(d=>d[l])}function B(a){let l=a,d=3405648695,g=3735928559;return function(){return l+=d,d^=l<<7,l*=g,g^=l<<13,l^=d^g,(l>>>0)/4294967296}}function H(a,l,d=Math.random){return Math.floor(d()*(l-a+1))+a}function U(a,l,d=Math.random){return d()*(l-a)+a}function G(){return Math.random()*2-1}function W(a,l,d){return l>=a.x&&l<a.x+a.width&&d>=a.y&&d<a.y+a.height}function J(a,l,d,g=Math.random){let x,L;do x=H(0,a-1,g),L=H(0,l-1,g);while(d&&W(d,x,L));return[x,L]}function j(a,l=Math.random){const d=Math.floor(a),g=a-d;return Y(g,l)?d+1:d}function Y(a,l=Math.random){return l()<a}function it(a,l=Math.random){return a[Math.floor(a.length*l())]}function ut(a,l,d=Math.random){if(l>a.length)throw new Error(`Count (${l}) is greater than array length (${a.length})`);return k(a,l,d).map(g=>a[g])}function rt(a,l,d,g=Math.random){if(l>a.length)throw new Error(`Count (${l}) is greater than array length (${a.length})`);const x=[];for(;x.length<l;){const L=it(a,g);x.some(Q=>d(Q,L))||x.push(L)}return x}function ot(a,l,d,g,x,L=Math.random){const Q=a.filter(at=>at!==l&&at!==d),lt=[];for(l!==null&&lt.push(l);Q.length&&lt.length<g;){const at=n.Random.intBetween(0,Q.length-1,L);x(Q[at],lt)&&lt.push(Q[at]),Q.splice(at,1)}return o(lt,L),{values:lt,indexOfGuaranteed:l!==null?lt.indexOf(l):-1}}function C(a){if(!a.length)throw Error("Received empty array");return a[a.length-1]}function p(a,l,d){return d(l.reduce((g,x)=>x(g),a))}function m(a,l){return d=>p(d,a,l)}function v(a,l,d){if(d===void 0&&(d=Math.random()),a.length!==l.length)throw new Error("Array length mismatch");let g=l.reduce((L,Q)=>L+Q,0);const x=d*g;for(let L=0;L<a.length-1;L++)if(g-=l[L],x>=g)return a[L];return C(a)}function I(a,l,d=Math.random){const g=l.map(L=>d()*L),x=[];for(let L=0;L<a.length;L++)x.push([a[L],g[L]]);return x.sort((L,Q)=>Q[1]-L[1]).map(L=>L[0])}function N(a,l){if(a==null)return null;const d=l.split(".");let g=a;for(const x of d){if(g[x]===null||g[x]===void 0)return null;g=g[x]}return g}function M(a,l,d){const g=l.split(/\.|\[/);let x=a;for(let L=0;L<g.length;L++){const Q=g[L],lt=L<g.length-1&&g[L+1].includes("]"),at=Q.includes("]")?Q.replace(/\[|\]/g,""):Q;if(L===g.length-1)return x[at]=d,d;rn(x[at])||(lt?x[at]=[]:x[at]={}),x=x[at]}return d}function z(a,l,d=1){const g=N(a,l)||0;return M(a,l,g+d),g}function P(a,l,d){return N(a,l)||M(a,l,d)}function _(a,l){const d=Gw(l,"."),g=Ek(l,".");if(!d||!g)return;const x=N(a,d);delete x[g]}function F(a,l,d){const g=N(a,l);if(!g)throw new Error("Key '"+l+"' does not exist.");return M(a,l,d),g}function ct(a,l,d){for(const g of l){const x=N(a,g);if(x)return x}if(d){const g=Object.values(a);if(g.length)return g[0]}return null}async function dt(a,l,d){for(;;){try{await a()}catch(g){d&&d("Error in forever",g)}await s(l)}}function mt(a,l){a();const d=setInterval(()=>{a()},l);return()=>clearInterval(d)}function Gt(a){return a/1024/1024}function Ut(a){return a>=1024*1024*1024*1024?(a/1024/1024/1024/1024).toFixed(3)+" TB":a>=1024*1024*1024?(a/1024/1024/1024).toFixed(3)+" GB":a>=1024*1024?(a/1024/1024).toFixed(3)+" MB":a>=1024?(a/1024).toFixed(3)+" KB":a+" B"}function Lt(a){const l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a.toLowerCase());if(!l)throw new Error("Invalid hex color: "+a);return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}function xe(a){return"#"+a.map(l=>l.toString(16).padStart(2,"0")).join("")}function Kt(a,l,d,g){const x=a*Math.PI/180,L=d*Math.PI/180,Q=(d-a)*Math.PI/180,lt=(g-l)*Math.PI/180,at=Math.sin(Q/2)*Math.sin(Q/2)+Math.cos(x)*Math.cos(L)*Math.sin(lt/2)*Math.sin(lt/2);return 6371e3*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)))}function Ft(a,l){return Math.round(a/l)*l}function ke(a){return a>1e3?(a/1e3).toFixed(0)+" km":a>=500?Ft(a,100)+" m":a>=100?Ft(a,50)+" m":Ft(a,10)+" m"}function re(a){return a*(a+1)/2}function oe(a){const l=a.match(/-?\d+(\.\d+)?/);if(!l)throw Error("No float found in "+a);return parseFloat(l[0])}function rn(a,l=!0){return!a||l&&!Re(a._readableState)||l&&a.constructor&&(a.constructor.isBuffer||a.constructor.name=="Uint8Array"||a.constructor.name==="ArrayBuffer"||a.constructor.name==="ReadableStream")?!1:typeof a=="object"}function fe(a){return rn(a)&&!Array.isArray(a)}function Ue(a){return Array.isArray(a)&&a.length===0}function ea(a){return fe(a)&&Object.keys(a).length===0}function Re(a){return a===void 0}function Ce(a){return Object.prototype.toString.call(a)==="[object Function]"||Object.prototype.toString.call(a)==="[object AsyncFunction]"}function In(a){return Object.prototype.toString.call(a)==="[object String]"}function he(a){return typeof a=="number"&&isFinite(a)}function Se(a){return a===!0||a===!1}function sn(a){return Object.prototype.toString.call(a)==="[object Date]"}function Ee(a){return!In(a)||a.trim().length===0}function Be(a){return he(a)&&Number.isInteger(a)&&a>=1}function cr(a){return In(a)&&a.match(/^-?\d+$/)!==null}function De(a){return In(a)&&a.match(/^(0x)?[0-9a-f]+$/i)!==null}const O="!@#$%^&*()_+-=[]{}|;:<>?,./",w="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),E="abcdefghijklmnopqrstuvwxyz",D="ABCDEFGHIJKLMNOPQRSTUVWXYZ",V="1234567890",q=E+D+V,st=q+O,qt=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],Wt="0123456789abcdef";function jt(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=E[Math.floor(l()*E.length)];return d}function Fe(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=q[Math.floor(l()*q.length)];return d}function Ht(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=st[Math.floor(l()*st.length)];return d}function ln(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=qt[Math.floor(l()*qt.length)];return d}function Ip(a,l){const d=new RegExp(`[0-9a-f]{${l}}`,"i"),g=a.match(d);return g?g[0]:null}function fn(a,l,d=w){const g=vk(a,d);for(const x of g)if(l(x))return x;return null}function hn(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=Wt[Math.floor(l()*Wt.length)];return d}function kp(a,l){if(!cr(a))throw new TypeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=BigInt(a);if(l&&(l.min&&d<l.min||l.max&&d>l.max))throw RangeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: `+d);return a}function on(a,l){if(Ee(a))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);if(l&&(l.min!==void 0&&a.length<l.min||l.max!==void 0&&a.length>l.max))throw RangeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""} length in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${a.length}`);return a}function dn(a,l){if(!De(a))throw new TypeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=a.replace(/^0x/,"");if(l&&l.byteLength&&d.length!==l.byteLength*2)throw RangeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""} of byte length ${l.byteLength}; got: `+d);return d}function Tp(a,l){if(!on(a,l).split("").every(d=>d==="_"||Vh(d)))throw new TypeError(`Expected safe string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function an(a,l){if(l.min!==void 0&&a<l.min||l.max!==void 0&&a>l.max)throw RangeError(`Expected value${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${a}`)}function pn(a,l){if(!Ce(a))throw new TypeError(`Expected function${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function vc(a,l){if(he(a))return l&&an(a,l),a;if(!In(a)||!a.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=parseFloat(a);return l&&an(d,l),d}function Ye(a,l){return vc(a,l)|0}function gn(a,l){if(a==="true")return!0;if(a==="false")return!1;if(!Se(a))throw new TypeError(`Expected boolean${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function Op(a,l){if(!sn(a))throw new TypeError(`Expected date${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function yn(a){return Ee(a)?null:a}function mn(a,l){if(!In(a))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function Np(a,l){if(Be(a))return a;const d=parseInt(a,10);if(!Be(d))throw new TypeError(`Expected id${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function wn(a,l){if(!In(a))throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=a.split(":");if(d.length!==2)throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const g=parseInt(d[0],10),x=parseInt(d[1],10);if(!he(g)||!he(x)||g<0||g>23||x<0||x>59)throw new TypeError(`Expected time, got${l!=null&&l.name?` for ${l.name}`:""}: `+a);return`${String(g).padStart(2,"0")}:${String(x).padStart(2,"0")}`}function bn(a,l){if(!Array.isArray(a))throw new TypeError(`Expected array${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function xc(a,l){if(!fe(a))throw new TypeError(`Expected object${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function _n(a,l){return a===null?null:xc(a,l)}function An(a,l){const d=xc(a,l);for(const g of Object.keys(d))if(!In(d[g]))throw new TypeError(`Expected string map${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function Oh(a,l){const d=xc(a),g=Object.keys(d),x=Object.values(d);if(!g.every(In)||!x.every(he))throw new TypeError(`Expected numeric dictionary${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function Nl(a){return In(a)&&a.match(/^https?:\/\/.+/)!==null}function Nh(a,l){if(!Nl(a))throw new TypeError(`Expected url${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function Ch(a,l){return l==null?!0:a(l)}function Bh(a,l){return l==null?null:a(l)}function Ph(a,l){return l==null?void 0:a(l)}function Cl(a,l){for(const[d,g]of Object.entries(l))if(!g(a[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(a))if(!l[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Mh(a,l){return a.every(d=>Cl(d,l))}function Xs(a,l="json",d=0){if(rn(a,!1)){if(d>1)return"[object Object]";if(l==="json"){if(Array.isArray(a)){const x=a.map(L=>Xs(L,"json",d+1));return d===0?JSON.stringify(x):x}const g={};a.message&&(g.message=Xs(a.message,"json",d+1));for(const[x,L]of Object.entries(a))g[x]=Xs(L,"json",d+1);return d===0?JSON.stringify(g):g}else if(l==="key-value"){const g=Object.keys(a);return a.message&&!g.includes("message")&&g.unshift("message"),g.map(x=>`${x}=${JSON.stringify(Xs(a[x],"json",d+1))}`).join(" ")}}return Re(a)&&(a="undefined"),d===0?JSON.stringify(a):a}function Lh(a,l){if(In(a))return a;const d=Object.keys(a);a.message&&!d.includes("message")&&d.push("message");const g=d.map(x=>`${x}: ${a[x]}`).join("; ");return l&&a.stack?g+`
2
- `+a.stack:g}function Ti(a,l){if(fe(a)&&fe(l))for(const d in l)fe(l[d])?(a[d]||(a[d]={}),Ti(a[d],l[d])):Array.isArray(l[d])?a[d]=[...l[d]]:(l[d]!==null&&l[d]!==void 0||a[d]===null||a[d]===void 0)&&(a[d]=l[d]);return a}function Uh(a,l){const d={};return Ti(d,a),Ti(d,l),d}function Dh(a,l,d){const g={};return Ti(g,a),Ti(g,l),Ti(g,d),g}function Bl(a,l){const d={};for(const g of a)for(const x of Object.keys(g))d[x]?d[x]=l(d[x],g[x]):d[x]=g[x];return d}function Fh(a){return Bl(a,(l,d)=>l+d)}function $h(a,l,d){a[l]||(a[l]=[]),a[l].push(d)}function Hh(a,l,d){for(a.unshift(l);a.length>d;)a.pop()}function zh(a,l){let d=l%a.length;return d<0&&(d+=a.length),a[d]}function na(a,l){Array.prototype.push.apply(a,l)}function eV(a,l){Array.prototype.unshift.apply(a,l)}async function nV(a,l){const d=[];for(const g of a)d.push(await l(g));return d}function rV(a,l){const d=[];for(let g=0;g<a.length;g++)d.push(a[g]),g<a.length-1&&(Ce(l)?d.push(l()):d.push(l));return d}function iV(a,l){if(a!==l)throw Error(`Expected [${a}] to equal [${l}]`);return[a,l]}function sV(a){if(a!==!0)throw Error(`Expected [true], got: [${a}]`);return a}function oV(a){if(!a)throw Error(`Expected truthy value, got: [${a}]`);return a}function aV(a){if(a!==!1)throw Error(`Expected [false], got: [${a}]`);return a}function cV(a){if(a)throw Error(`Expected falsy value, got: [${a}]`);return a}function uV(a,l){if(!l.includes(a))throw Error(`Expected any of [${l.join(", ")}], got: [${a}]`);return a}function lV(a,l){for(let d=0;d<a.length;d++){const g=a[d],x=l[d],L=Math.max(0,x.getTime()-Date.now());setTimeout(g,L)}}function fV(a,l,d){return a+(l-a)*d}function hV(a){return a.reduce((l,d)=>l+d,0)}function dV(a){return a.reduce((l,d)=>l+d,0)/a.length}function pV(a){const l=[...a].sort((g,x)=>g-x),d=Math.floor(l.length/2);return l.length%2===0?(l[d]+l[d-1])/2:l[d]}function gV(a,l){return a-(l-1)/2}function _k(a,l){const d=[];for(let g=a;g<=l;g++)d.push(g);return d}function yV(a,l){return l.some(d=>a.includes(d))}function mV(a){return/^[\u4E00-\u9FA5]+$/.test(a)}function Hw(a,l=()=>!1){return a.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||l(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function wV(a){return Hw(a).replaceAll("-","")}function bV(a){return Bp(a.replace(/([A-Z])/g," $1"))}function _V(a){return a.split("-").map(Bp).join(" ")}function AV(a){return Rk(a.split("-").map(Bp).join(""))}function EV(a,l=", ",d=" and "){return!a||!a.length?"":a.length===1?a[0]:a.length===2?`${a[0]}${d}${a[1]}`:`${a.slice(0,a.length-1).join(l)}${d}${a[a.length-1]}`}function vV(a,l){return l+a.split("").join(l)+l}function xV(a){return Hw(a).replace(/-/g,"_").toUpperCase()}function Cp(a,l){if(l.length===0)return 0;const d=a.toLowerCase(),g=l.toLowerCase();return a===l?1e4:d.startsWith(g)?1e4-a.length:d.includes(g)?5e3-a.length:new RegExp(".*"+g.split("").join(".*")+".*").test(d)?1e3-a.length:0}function RV(a,l){return a.filter(d=>Cp(d,l)).sort((d,g)=>Cp(g,l)-Cp(d,l))}function SV(a){return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const IV={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function kV(a){let l=a.replace(/&#(\d+);/g,(d,g)=>String.fromCharCode(g)).replace(/&#x(\d+);/g,(d,g)=>String.fromCharCode(parseInt(g,16)));for(const[d,g]of Object.entries(IV))l=l.replaceAll(d,g);return l}function Ak(a,l){const d=a.indexOf(l);return d===-1?null:a.slice(0,d)}function zw(a,l){const d=a.indexOf(l);return d===-1?null:a.slice(d+l.length)}function Gw(a,l){const d=a.lastIndexOf(l);return d===-1?null:a.slice(0,d)}function Ek(a,l){const d=a.lastIndexOf(l);return d===-1?null:a.slice(d+l.length)}function TV(a,l,d){const g=Gw(a,d);return g?zw(g,l):null}function OV(a,l,d){const g=zw(a,l);return g?Ak(g,d):null}function Vw(a,l,d=!1){const g=d?a.lastIndexOf(l):a.indexOf(l);return g===-1?d?[null,a]:[a,null]:[a.slice(0,g),a.slice(g+l.length)]}function vk(a,l){let d=[a];for(const g of l)d=d.flatMap(x=>x.split(g));return d.filter(g=>g)}function Kw(a){const l=C(a.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?"":l.slice(d+1)}function jw(a){const l=C(a.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?l:l.slice(0,d)}function NV(a){let[l,d]=a.split("@");l=Gh(l.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[g]=l.split("+");if(!g||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=Gh(d.toLowerCase()).replaceAll(" ",""),`${g}@${d}`}function CV(a){const l=jw(a),d=Kw(a);return d?`${l}.${d}`:l}function BV(a){const l=jw(a),d=Kw(a);return{basename:l,extension:d,filename:d?`${l}.${d}`:l}}function PV(a,l=Math.random){return a.replace(/\{(.+?)\}/g,(d,g)=>it(g.split("|"),l))}function xk(a){const l=/\{(.+?)\}/,d=a.match(l);if(!d||!d.index)return[a];const g=d[1].split(","),x=a.slice(0,d.index),L=a.slice(d.index+d[0].length);let Q=[];for(const lt of g){const at=xk(x+lt+L);Q=Q.concat(at)}return Q}function Gh(a){return a.split(`
3
- `).map(l=>l.trim().replace(/\s+/g," ")).filter(l=>l.length>0).join(`
4
- `)}function Bp(a){return a.charAt(0).toUpperCase()+a.slice(1)}function Rk(a){return a.charAt(0).toLowerCase()+a.slice(1)}function Sk(a){if(!a)return!1;const l=a.charCodeAt(0);return l>=65&&l<=90||l>=97&&l<=122}function Ik(a){if(!a)return!1;const l=a.charCodeAt(0);return l>=48&&l<=57}function Vh(a){return Sk(a)||Ik(a)}const MV=`
5
- \r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function LV(a){return MV.includes(a)}function UV(a){return Vh(a)||a==="."||a==="["||a==="]"||a==="_"}function DV(a,l,d,g,x){return a.slice(0,l)+g+a.slice(l,l+d)+x+a.slice(l+d)}function kk(a,l,d=0){const g=l.exec(a.slice(d));return g?{index:g.index,match:g[0]}:null}function Tk(a,l,d=!0){if(!d)return l.every(x=>x instanceof RegExp?x.test(a):a.indexOf(x,0)!==-1);let g=0;for(const x of l)if(x instanceof RegExp){const L=kk(a,x,g);if(!L)return!1;g=L.index+L.match.length}else{const L=a.indexOf(x,g);if(L===-1)return!1;g=L+x.length}return!0}function FV(a,l,d=!0){let g=0;for(const x of l){let L=!1;for(;!L&&g<a.length;)Tk(a[g],x,d)&&(L=!0),g++;if(!L)return!1}return!0}function $V(a){return a.match(/"|,/)?`"${a.replace(/"/g,'""')}"`:a}function Pl(a,l,d=0){let g=-1;for(const x of l){const L=a.indexOf(x,d);L!==-1&&(g===-1||L<g)&&(g=L)}return g}function HV(a,l=0){for(let d=l;d<a.length;d++)if(LV(a[d]))return d;return-1}function zV(a,l=0){for(let d=l;d<a.length;d++)if(a[d]==="#"&&Vh(a[d+1]))return d;return-1}function Ok(a,l,d=0){return a.slice(0,d).lastIndexOf(l)}function Nk(a,l=0,d="{",g="}"){let x=1;for(let L=l;L<a.length;L++)if(a.slice(L,L+g.length)===g){if(--x===0)return L}else a.slice(L,L+d.length)===d&&x++;return-1}function Ck(a,l){const d=l.wordBoundary?Pl(a,[`${l.opening} `,`${l.opening}
6
- `],l.start||0):a.indexOf(l.opening,l.start||0);if(d===-1)return null;const g=Nk(a,d+l.opening.length,l.opening,l.closing);return g===-1?null:l.exclusive?a.slice(d+l.opening.length,g):a.slice(d,g+l.closing.length)}function GV(a,l){const d=[];let g=l.wordBoundary?Pl(a,[`${l.opening} `,`${l.opening}
7
- `],l.start||0):a.indexOf(l.opening,l.start||0);for(;;){if(g===-1)return d;const x=Ck(a,{...l,start:g});if(!x)return d;d.push(x),g=l.wordBoundary?Pl(a,[`${l.opening} `,`${l.opening}
8
- `],g+x.length):a.indexOf(l.opening,g+x.length)}}function VV(a,l,d){let g=0;for(;;){const x=n.Strings.extractBlock(a,{...d,start:g});if(!x)return a;const L=l(x);g=a.indexOf(x,g)+L.length,a=a.replace(x,L)}}function KV(a,l){const d=[];let g=0;for(;g<a.length;){const x=a.indexOf(l,g);if(x===-1){d.push({string:a.slice(g),symbol:null});break}const L=a.indexOf(l,x+l.length);if(x>g&&L!==-1&&d.push({string:a.slice(g,x),symbol:null}),L===-1){d.push({string:a.slice(g),symbol:null});break}d.push({string:a.slice(x+l.length,L),symbol:l}),g=L+l.length}return d}function jV(a){const l=[];let d=0;for(;d<a.length;){const g=zV(a,d);if(g===-1){l.push({string:a.slice(d),symbol:null});break}const x=HV(a,g+1);if(x===-1){l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g+1),symbol:"#"});break}g>d&&l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g+1,x),symbol:"#"}),d=x}return l}function WV(a){const l=[];let d=0;for(;d<a.length;){const g=Pl(a,["http://","https://"],d);if(g===-1){l.push({string:a.slice(d),symbol:null});break}const x=Pl(a,[" ",`
9
- `],g);if(x===-1){g>d&&l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g),symbol:"http"});break}g>d&&l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g,x),symbol:"http"}),d=x}return l}const Bk="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pk="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function ZV(a){return Mk(a,Bk)}function qV(a){return Lk(a,Bk)}function QV(a){return Mk(a,Pk)}function YV(a){return Lk(a,Pk)}function Mk(a,l){const d="=",g=l.length;let x=0,L=0;const Q=[];for(let lt=0;lt<a.length;lt++){const at=a[lt];if(at===d)break;const Pt=l.indexOf(at);if(Pt===-1)throw new Error(`Invalid character: ${at}`);L=L<<Math.log2(g)|Pt,x+=Math.log2(g),x>=8&&(x-=8,Q.push(L>>x&255))}return new Uint8Array(Q)}function Lk(a,l){const d=l.length;let g=0,x=0,L="";for(let Q=0;Q<a.length;Q++)for(x=x<<8|a[Q],g+=8;g>=Math.log2(d);)g-=Math.log2(d),L+=l[x>>g&d-1];return g>0&&(L+=l[x<<Math.log2(d)-g&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function JV(a){a.startsWith("0x")&&(a=a.slice(2));const l=a.length/2,d=new Uint8Array(l);for(let g=0;g<l;g++){const x=parseInt(a.slice(g*2,g*2+2),16);d[g]=x}return d}function XV(a){return Array.from(a).map(l=>l.toString(16).padStart(2,"0")).join("")}function tK(a,l){const d=a.split("/").filter(L=>L),g=l.split("/").filter(L=>L);if(d.length!==g.length)return null;const x={};for(let L=0;L<d.length;L++){const Q=d[L];if(Q.startsWith(":"))x[Q.slice(1)]=g[L];else if(Q!==g[L])return null}return x}function Ww(a,l,d){const g=[];for(const x of d)x!==l&&g.push(a.replace(l,x));return g}function eK(a,l,d,g=Math.random){const x=n.Arrays.shuffle(l.map(Q=>({variants:n.Arrays.shuffle(Q.variants.map(lt=>lt),g),avoid:Q.avoid})),g),L=[];for(const Q of x){const lt=Q.variants.filter(Pt=>Pt!==Q.avoid),at=lt.find(Pt=>a.includes(Pt));if(at&&(na(L,Ww(a,at,lt)),L.length>=d))break}if(L.length<d)for(const Q of x){const lt=Q.variants.find(at=>a.includes(at));if(lt&&(na(L,Ww(a,lt,Q.variants)),L.length>=d))break}return L.slice(0,d)}function nK(a,l,d,g=!1){const x=new RegExp(g?`(?<=\\s|^)${l}(?=\\s|$)`:`\\b${l}\\b`,"g");return a.replace(x,d)}function rK(a,l){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return a.replace(d,g=>g.toUpperCase()===g?g:l(g))}function iK(a){return a.replace(/<[^>]*>/g,"")}function Uk(a){const l=a.lastIndexOf(" ");if(l===-1)return{line:a,rest:""};const d=a.slice(0,l),g=a.slice(l+1);return{line:d,rest:g}}function sK(a,l={}){return[...a].reduce((d,g)=>d+(l[g]||1),0)}function oK(a,l,d={}){const g=[];let x="",L=0;for(let Q=0;Q<a.length;Q++){const lt=a[Q],at=d[lt]||1;if(x+=lt,L+=at,L>l){const{line:Pt,rest:Le}=Uk(x);g.push(Pt),x=Le,L=Le.split("").map(Hn=>d[Hn]||1).reduce((Hn,Dl)=>Hn+Dl,0)}}return x&&g.push(x),g}function aK(a,l){const d=[];for(let g=0;g<=a.length;g++)d[g]=[g];for(let g=0;g<=l.length;g++)d[0][g]=g;for(let g=1;g<=a.length;g++)for(let x=1;x<=l.length;x++){const L=a[g-1]===l[x-1]?0:1;d[g][x]=Math.min(d[g-1][x]+1,d[g][x-1]+1,d[g-1][x-1]+L)}return d[a.length][l.length]}function Zw(a,l){return new RegExp(`\\b${l}\\b`).test(a)}function cK(a,l,d){return d==="any"?l.some(g=>Zw(a,g)):l.every(g=>Zw(a,g))}function uK(a){const l={},d=a.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const g of d){const[x,L]=Vw(g,"=");l[x]=L.slice(1,L.length-1)}return l}function Pp(a,l,d=[]){let g="";for(;l<a.length&&(Vh(a[l])||d.includes(a[l]));)g+=a[l++];return g}function lK(a,l,d="$",g=":"){for(const x in l)a=Dk(a,x,l[x],d,g);return a=Fk(a),a}function Dk(a,l,d,g="$",x=":"){if(d==="")return a;let L=a.indexOf(`${g}${l}`);for(;L!==-1;){if(a[L+l.length+1]===x)if(a[L+l.length+2]===x)a=a.replace(`${g}${l}${x}${x}`,d);else{const Q=Pp(a,L+l.length+2,["_"]);a=a.replace(`${g}${l}${x}${Q}`,d)}else a=a.replace(`${g}${l}`,d);L=a.indexOf(`${g}${l}`,L+d.length)}return a}function Fk(a,l="$",d=":"){let g=a.indexOf(l);for(;g!==-1;){const x=Pp(a,g+1);if(a[g+x.length+1]===d)if(a[g+x.length+2]===d)a=a.replace(`${l}${x}${d}${d}`,"");else{const L=Pp(a,g+x.length+2);a=a.replace(`${l}${x}${d}${L}`,L)}g=a.indexOf(l,g+1)}return a}function fK(a,l){let d=a.indexOf("](");for(;d!==-1;){const g=Ok(a,"[",d),x=a.indexOf(")",d);if(g!==-1&&x!==-1){const[L,Q]=a.slice(g+1,x).split("]("),lt=l(L,Q);a=a.slice(0,g)+lt+a.slice(x+1)}d=a.indexOf("](",d+1)}return a}function $k(a,l=!0){const d=Object.entries(a).filter(([g,x])=>x!=null).map(([g,x])=>`${g}=${encodeURIComponent(x)}`).join("&");return d?(l?"?":"")+d:""}function hK(a){const l={},d=a.split("&");for(const g of d){const[x,L]=g.split("=");x&&L&&(l[x]=decodeURIComponent(L))}return l}function dK(a,l){return Object.prototype.hasOwnProperty.call(a,l)}function pK(a,l){let d=null,g=-1/0;for(const[x,L]of Object.entries(a)){const Q=l(L);Q>g&&(g=Q,d=x)}return d?[d,a[d]]:null}function gK(a,l,d,g){const x=a.find(Q=>Q[l]===d),L=a.find(Q=>Q[l]===d+g);x&&L?(x[l]=d+g,L[l]=d):x&&(x[l]=d+g),a.sort((Q,lt)=>vc(Q[l])-vc(lt[l])),a.forEach((Q,lt)=>Q[l]=lt+1)}function yK(a){const l=Object.keys(a);if(l.length===1)return a[l[0]];throw new Error("Expected object to have a single key")}function mK(a,l=":"){return Object.fromEntries(a.map(d=>Vw(d,l)).map(d=>d[0]&&d[1]?[Gh(d[0]),Gh(d[1])]:null).filter(d=>d))}function wK(a,l,d){return Vk(a,l)+$k(d||{})}function bK(a,l=",",d='"'){const g=[];let x="",L=!1;const Q=a.split("");for(const lt of Q)lt===l&&!L?(g.push(x),x=""):lt===d&&(!x&&!L||L)?L=!L:x+=lt;return g.push(x),g}function _K(a){return`[${Math.floor(a.progress*100)}%] ${Mp(a.deltaMs)} out of ${Mp(a.totalTimeMs)} (${Mp(a.remainingTimeMs)} left) [${Math.round(a.baseTimeMs)} ms each]`}async function AK(a,l,d){for(let g=0;g<d;g++){try{if(await a())return!0}catch{}g<d-1&&await s(l)}return!1}function EK(a,l){const d=[];for(let g=a.length-1;g>=0;g--)l(a[g])&&d.push(a.splice(g,1)[0]);return d}function vK(a){return JSON.parse(JSON.stringify(a))}function xK(a){return Math.ceil((a||Date.now())/1e3)}function RK(a){return(a||new Date).toISOString().slice(0,10)}function SK(a){return(a||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function IK(a){const l=new Date(a);return new Date(l.getTime()-l.getTimezoneOffset()*6e4)}function kK(a){return new Date(a)}function ls(a){return String(Math.floor(a)).padStart(2,"0")}function TK(a){let[l,d]=a.split(":");he(parseInt(l,10))||(l="0"),he(parseInt(d,10))||(d="0");let g=Xw(Ye(l),0,23),x=Xw(Ye(d),0,59);return`${ls(g)}:${ls(x)}`}function Mp(a){const l=Math.floor(a/36e5);a=a%36e5;const d=Math.floor(a/6e4);a=a%6e4;const g=Math.floor(a/1e3);return l?`${ls(l)}:${ls(d)}:${ls(g)}`:`${ls(d)}:${ls(g)}`}function Rc(a){return Math.floor((sn(a)?a.getTime():a)/864e5)}const OK={today:(a,l)=>ls(a)+":"+ls(l),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:a=>`${a}w`};function NK(a,l){const d=new Date((l==null?void 0:l.now)||Date.now()),g=(l==null?void 0:l.labels)||OK,x=sn(a)?a:new Date(a);if(Rc(d)===Rc(x))return g.today(x.getUTCHours(),x.getUTCMinutes(),x.getUTCHours()>12);if(Rc(d)-Rc(x)===1)return g.yesterday();const L=Qw(x);return Rc(d)-Rc(x)<7?g[L.day]():g.weeks(Math.round((d.getTime()-x.getTime())/6048e5))}const Hk={now:()=>"A few seconds",seconds:a=>`${a} seconds`,minutes:a=>`${a} minutes`,hours:a=>`${a} hours`,days:a=>`${a} days`,weeks:a=>`${a} weeks`};function zk(a,l){const d=(l==null?void 0:l.now)??Date.now(),g=(l==null?void 0:l.labels)||Hk,x=n.Types.isDate(a)?a.getTime():a;let L=(d-x)/1e3;return L<10?g.now():L<120?g.seconds(Math.floor(L)):(L/=60,L<120?g.minutes(Math.floor(L)):(L/=60,L<48?g.hours(Math.floor(L)):(L/=24,L<14?g.days(Math.floor(L)):(L/=7,g.weeks(Math.floor(L))))))}function CK(a,l=Hk){return zk(0,{now:a*1e3,labels:l})}function BK(a,l,d){const g=((d==null?void 0:d.now)??Date.now())-a,x=Math.floor(g/l),L=l/((d==null?void 0:d.precision)??1)-Math.ceil(g%l/((d==null?void 0:d.precision)??1));return{cycles:x,remaining:L}}const qw={};function PK(a,l){return!qw[a]||Date.now()>qw[a]?(qw[a]=Date.now()+l,!0):!1}const MK={s:1e3,m:6e4,h:36e5,d:864e5};function LK(a,l,d){return l=sn(l)?l.getTime():l,d=d?sn(d)?d.getTime():d:Date.now(),(d-l)/MK[a]}function UK(a,l,d,g){g||(g=Date.now());const x=l/d,L=g-a,Q=L/l,lt=Q*d,at=lt-L;return{deltaMs:L,progress:x,baseTimeMs:Q,totalTimeMs:lt,remainingTimeMs:at}}const DK={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Gk(a){return{zeroBasedIndex:a,day:DK[a]}}function Qw(a){return Gk(a.getDay())}function FK(a){return Qw(new Date(a))}function $K(a){return a*1e3}function HK(a){return a*6e4}function zK(a){return a*36e5}function GK(a){return a*864e5}const VK={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function KK(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeDate got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=VK[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}const jK={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function WK(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeDate got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=jK[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}function ZK(a){return a.replace(/ +/g," ").replace(/^ /gm,"")}const Yw={};async function qK(a,l,d){const g=Date.now(),x=Yw[a];if(x&&x.validUntil>g)return x.value;const L=await d(),Q=g+l;return Yw[a]={value:L,validUntil:Q},L}function QK(a){delete Yw[a]}function Vk(...a){return a.filter(l=>l).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function YK(a,l,d,g,x=!0){const L=a.indexOf(l),Q=a.indexOf(d,L+l.length);if(L===-1||Q===-1)throw Error("Start or end not found");return x?a.substring(0,L+l.length)+g+a.substring(Q):a.substring(0,L)+g+a.substring(Q+d.length)}function JK(a){let l="p";a.startsWith("#")?(l="h1",a=a.slice(1).trim()):a.startsWith("-")&&(l="li",a=a.slice(1).trim());const d=a[0]===a[0].toUpperCase(),g=/[.?!]$/.test(a),x=/:$/.test(a);return{type:l,isCapitalized:d,hasPunctuation:g,endsWithColon:x}}function XK(a,l="(",d=")"){let g=0,x=0;for(;x<a.length;)if(a.startsWith(l,x)?(g++,x+=l.length):a.startsWith(d,x)?(g--,x+=d.length):x++,g<0)return!1;return l===d?g%2===0:g===0}function tj(a){a=a.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let l=a.length;for(;a=a.replace(/(\w+)[\s,']+\w+/g,"$1"),a.length!==l;)l=a.length;return a=a.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),a=a.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),a=a.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),a}function Kk(a){const l=Object.keys(a).sort((g,x)=>g.localeCompare(x)),d={};for(const g of l)d[g]=Sc(a[g]);return d}function jk(a){const l=[];return a.sort((d,g)=>JSON.stringify(Sc(d)).localeCompare(JSON.stringify(Sc(g)))).forEach(d=>l.push(Sc(d))),l}function Sc(a){return Array.isArray(a)?jk(a):rn(a)?Kk(a):a}function Wk(a,l){return JSON.stringify(Sc(a))===JSON.stringify(Sc(l))}function ej(...a){for(let l=1;l<a.length;l++)if(!Wk(a[l-1],a[l]))return!1;return!0}function nj(a){try{return JSON.parse(a)}catch{return null}}function rj(){let a=0;return{next:()=>a++}}function ij(a){let l=0;return{next:()=>a[l++%a.length]}}function sj(a){let l;return d=>{const g=d===a&&l!==a;return l=d,g}}function oj(a,l,d,g,x){const L={};for(const Q of Object.keys(l))L[Q]=[];L[g]=[],x&&(a=a.sort(x));for(const Q of a){const lt=Q[d],at=l[lt]?lt:g;L[at].length>=l[at]?L[g].push(Q):L[at].push(Q)}return L}function aj(a,l){const d=Object.keys(a),g=Object.keys(l);return{uniqueToA:d.filter(x=>!g.includes(x)),uniqueToB:g.filter(x=>!d.includes(x))}}function Zk(a){const l=Object.keys(a);return l[Math.floor(Math.random()*l.length)]}function cj(a,l){const d=Zk(a);return a[d]=l(a[d]),d}function uj(a){return a=a.replace(/\r\n/g,`
10
- `),a=a.replace(/(\w+)\((.+)\)/g,(l,d,g)=>`${d}(${g.replaceAll(",","&comma;")})`),a=a.replace(/(,)(\s+})/g,"$2"),a=a.replace(/\.\.\..+?,/g,""),a=a.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),a=a.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),a=a.replace(/:(.+)\?(.+):/g,(l,d,g)=>`: (${d.trim()} && ${g.trim()}) ||`),a=a.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),a=a.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(l,d,g,x)=>`"${d}":"${g.trim()}"${x}`),a=a.replace(/("'|'")/g,'"'),a=a.replaceAll("&comma;",","),JSON.parse(a)}const ra=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],lj=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],qk=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function fj(a,l,d){let g=a.length-l;if(g<=0)return"0."+"0".repeat(-g)+a+(d?" "+d:"");let x=a.substring(0,g),L=a.substring(g);return x===""&&(x="0"),x+"."+L+(d?" "+d:"")}function hj(a,l){const d=(l==null?void 0:l.longForm)??!1,g=l!=null&&l.unit?` ${l.unit}`:"",x=d?lj:qk,L=(l==null?void 0:l.precision)??1;if(a<ra[0])return`${a}${g}`;for(let Q=0;Q<ra.length-1;Q++)if(a<ra[Q+1])return`${(a/ra[Q]).toFixed(L)}${d?" ":""}${x[Q]}${g}`;return`${(a/ra[ra.length-1]).toFixed(L)}${d?" ":""}${x[ra.length-1]}${g}`}function Jw(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeNumber got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim(),g=qk.findIndex(x=>x.toLowerCase()===d.toLowerCase());return g===-1?l:l*ra[g]}function Xw(a,l,d){return a<l?l:a>d?d:a}function dj(a,l,d){const g=a+l;return g>d?d:g}function pj(a,l,d){const g=a-l;return g<d?d:g}function gj(a,l){return l(a),a}function yj(a,l){a&&l(a)}function mj(a,l){const d=Object.keys(l);for(const g of d)Array.isArray(l[g])&&Array.isArray(a[g])&&na(a[g],l[g])}function wj(a){return a.splice(0,a.length),a}function bj(a){for(const l of Object.keys(a))(Ue(a[l])||Array.isArray(a[l])&&a[l].every(d=>d==null))&&delete a[l];return a}function _j(a){for(const l of Object.entries(a))(l[1]===null||l[1]===void 0||In(l[1])&&Ee(l[1]))&&delete a[l[0]];return a}function Aj(a,l){const d={};for(const[g,x]of Object.entries(a))l(g)&&(d[g]=x);return d}function Ej(a,l){const d={};for(const[g,x]of Object.entries(a))l(x)&&(d[g]=x);return d}function vj(a,l){const d={};for(const g of Object.entries(a))d[g[0]]=l(g[1]);return d}function xj(a,l){const d=[];let g=0;for(const x of a)d.push(l(x,g++));return d}async function Rj(a,l){try{return await a()}catch{throw l}}function Sj(a,l,d){d!=null&&(a[l]=d)}function Ij(a,l,d,g){const x=N(d,g);x!=null&&M(a,l,x)}function kj(a){const l={};for(const[d,g]of Object.entries(a))l[g]=d;return l}function Tj(a){const l=Object.keys(a),d=l.map(lt=>a[lt].length),g=d.reduce((lt,at)=>lt*=at);let x=1;const L=[1];for(let lt=0;lt<d.length-1;lt++)x*=d[lt],L.push(x);const Q=[];for(let lt=0;lt<g;lt++){const at={};for(let Pt=0;Pt<l.length;Pt++){const Le=a[l[Pt]],Hn=Math.floor(lt/L[Pt])%Le.length;at[l[Pt]]=Le[Hn]}Q.push(at)}return Q}function Oj(a){return Object.values(a).filter(l=>l).length}function Nj(a,l,d){return a+(d?"["+l+"]":(a.length?".":"")+l)}function Lp(a,l,d,g,x){if(!rn(l))return l;for(const[L,Q]of Object.entries(l)){const lt=Nj(d,L,g);Array.isArray(Q)?x?Lp(a,Q,lt,!0,x):a[lt]=Q.map(at=>Lp(Array.isArray(at)?[]:{},at,"",!1,x)):rn(Q)?Lp(a,Q,lt,!1,x):a[lt]=Q}return a}function Cj(a,l=!1,d){return Lp({},a,d||"",!1,l)}function Qk(a){if(!rn(a))return a;const l=Array.isArray(a)?[]:{};for(const[d,g]of Object.entries(a))Array.isArray(g)?M(l,d,g.map(x=>Qk(x))):M(l,d,g);return l}function Bj(a,l,d){return l[a]?l[a]:d}function Yk(a,l){const d={};for(const g of a){const x=l(g);d[x]=g}return d}function Pj(a,l){const d={};for(const g of a){const x=l(g);d[x]||(d[x]=[]),d[x].push(g)}return d}function Mj(a,l){const d=[];for(let g=0;g<a.length;g+=l)d.push(a.slice(g,g+l));return d}function Jk(a,l){const d=Math.ceil(a.length/l),g=[];for(let x=0;x<a.length;x+=d)g.push(a.slice(x,x+d));return g}function Xk(a,l){const d=[],g=Math.ceil(a.length/l);for(let x=0;x<g;x++)d.push(a.slice(x*l,x*l+l));return d}function Lj(a,l){const d=Math.ceil(a.length/l);return Xk(a,d)}function Uj(a,l){return Object.values(Yk(a,l))}function Dj(a,l,d,g,x){const L=l?a.map(l):a,Q={};for(const at of L)Q[at]=(Q[at]||0)+1;const lt=g?tT(Q,x?(at,Pt)=>at[1]-Pt[1]:(at,Pt)=>Pt[1]-at[1]):Q;return d?Object.keys(lt):lt}function tT(a,l){return Object.fromEntries(Object.entries(a).sort(l))}function Fj(a){const l=[],d=Object.keys(a),g=a[d[0]].length;for(let x=0;x<g;x++){const L={};for(const Q of d)L[Q]=a[Q][x];l.push(L)}return l}function $j(a,l,d=1){for(const g of a)g[l]+=d}function Hj(a,l,d){for(const g of a)g[l]=d}function t1(a,l){const d=[];let g=[];return a.forEach((x,L)=>{(L===0||!l(x,a[L-1]))&&(g=[],d.push(g)),g.push(x)}),d}function zj(){return{map:new Map,keys:[]}}function Gj(){return{map:new Map,keys:[]}}function eT(a,l,d,g=100){if(a.map.has(l)){const x=a.keys.indexOf(l);a.keys.splice(x,1)}if(a.map.set(l,d),a.keys.push(l),a.keys.length>g){const x=a.keys.shift();x&&a.map.delete(x)}}function Vj(a,l,d,g=100){if(a.map.has(l)){const x=a.keys.indexOf(l);a.keys.splice(x,1)}if(a.map.set(l,d),a.keys.unshift(l),a.keys.length>g){const x=a.keys.shift();x&&a.map.delete(x)}}function Kj(a,l,d,g,x=100){eT(a,l,{validUntil:Date.now()+g,data:d},x)}function jj(a,l){const d=a.map.get(l);return d&&d.validUntil>Date.now()?d.data:null}class ia{constructor(l){this.value=l}static of(l){return new ia(l)}static empty(){return new ia(null)}map(l){return new ia(this.value!==null&&this.value!==void 0?l(this.value):null)}mapAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(d=>ia.of(d)):Promise.resolve(ia.empty())}ifPresent(l){return this.value!==null&&this.value!==void 0&&l(this.value),this}ifPresentAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(l){return(this.value===null||this.value===void 0)&&l(),this}ifAbsentAsync(l){return this.value===null||this.value===void 0?l().then(()=>this):Promise.resolve(this)}getOrFallback(l){return this.value??l()}getOrFallbackAsync(l){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):l()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}n.Optional=ia;class Wj{constructor(l){this.supplier=l,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}n.Lazy=Wj;class Zj{constructor(l){this.supplier=l,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}n.AsyncLazy=Zj;function qj(a){return()=>a.forEach(l=>l())}function Qj(a,l){return a.reduce((d,g)=>l(d)>l(g)?d:g)}function Yj(a,l){const d=a.find(g=>g instanceof l);return ia.of(d)}function Jj(a,l){return a.filter(d=>d instanceof l)}function Xj(a,l){const d=[],g=Math.max(a.length,l.length);for(let x=0;x<g;x++)a[x]&&d.push(a[x]),l[x]&&d.push(l[x]);return d}function tW(a,l){return a.includes(l)?a.filter(d=>d!==l):[...a,l]}class eW{constructor(l){this.value=l,this.children=[]}}function nW(a,l,d,g,x=!1){const L=new Map,Q=[];a.forEach(at=>{const Pt=new eW(at);L.set(at[l],Pt)}),a.forEach(at=>{const Pt=L.get(at[l]);if(!Pt)return;const Le=at[d];if(Le){const Hn=L.get(Le);Hn&&Hn.children.push(Pt)}else Q.push(Pt)});const lt=at=>{at.children.sort((Pt,Le)=>{const Hn=Pt.value[g],Dl=Le.value[g];return x?Dl-Hn:Hn-Dl}),at.children.forEach(lt)};return Q.forEach(lt),Q}function nT(a,l){if(Math.log2(a.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...a];for(;d.length>1;){const g=[];for(let x=0;x<d.length;x+=2){const L=d[x+1];g.push(l(d[x],L))}d=g}return d[0]}function Ml(...a){const l=a.reduce((x,L)=>x+L.length,0),d=new Uint8Array(l);let g=0;return a.forEach(x=>{d.set(x,g),g+=x.length}),d}function rT(a){return a[0]===137&&a[1]===80&&a[2]===78&&a[3]===71}function iT(a){return a[0]===255&&a[1]===216}function sT(a){return a[8]===87&&a[9]===69&&a[10]===66&&a[11]===80}function rW(a){return rT(a)||iT(a)||sT(a)}function iW(a){return new Uint8Array([a])}function sW(a){return a[0]}function oW(a,l){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,a,l==="LE"),new Uint8Array(d)}function aW(a,l){return new DataView(a.buffer).getUint16(a.byteOffset,l==="LE")}function cW(a,l){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,a,l==="LE"),new Uint8Array(d)}function uW(a,l){return new DataView(a.buffer).getUint32(a.byteOffset,l==="LE")}function e1(a,l){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(a),l==="LE"),new Uint8Array(d)}function lW(a,l){return new DataView(a.buffer).getBigUint64(a.byteOffset,l==="LE")}function Ll(a,l){const d=new Uint8Array(32);let g=a;if(l==="LE"){for(let x=0;x<32;x++)d[x]=Number(g&0xffn),g>>=8n;return d}for(let x=31;x>=0;x--)d[x]=Number(g&0xffn),g>>=8n;return d}function Ul(a,l){let d=0n;if(l==="LE"){for(let g=31;g>=0;g--)d=d<<8n|BigInt(a[g]);return d}for(let g=0;g<32;g++)d=d<<8n|BigInt(a[g]);return d}function fW(a,l){const d=[];let g=0;for(const x of l)d.push(a.subarray(g,g+x)),g+=x;return d}function n1(a,l){const d=[];for(let g=0;g<a.length;g+=l)d.push(a.subarray(g,g+l));return d}const oT=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function hW(a){for(let l=0;l<24;l++){const d=a[0]^a[10]^a[20]^a[30]^a[40],g=a[1]^a[11]^a[21]^a[31]^a[41],x=a[2]^a[12]^a[22]^a[32]^a[42],L=a[3]^a[13]^a[23]^a[33]^a[43],Q=a[4]^a[14]^a[24]^a[34]^a[44],lt=a[5]^a[15]^a[25]^a[35]^a[45],at=a[6]^a[16]^a[26]^a[36]^a[46],Pt=a[7]^a[17]^a[27]^a[37]^a[47],Le=a[8]^a[18]^a[28]^a[38]^a[48],Hn=a[9]^a[19]^a[29]^a[39]^a[49],Dl=x<<1|L>>>31,ZW=L<<1|x>>>31,Wh=Le^Dl,Zh=Hn^ZW,qW=Q<<1|lt>>>31,QW=lt<<1|Q>>>31,qh=d^qW,Qh=g^QW,YW=at<<1|Pt>>>31,JW=Pt<<1|at>>>31,Yh=x^YW,Jh=L^JW,XW=Le<<1|Hn>>>31,tZ=Hn<<1|Le>>>31,Xh=Q^XW,td=lt^tZ,eZ=d<<1|g>>>31,nZ=g<<1|d>>>31,ed=at^eZ,nd=Pt^nZ;a[0]^=Wh,a[1]^=Zh,a[2]^=qh,a[3]^=Qh,a[4]^=Yh,a[5]^=Jh,a[6]^=Xh,a[7]^=td,a[8]^=ed,a[9]^=nd,a[10]^=Wh,a[11]^=Zh,a[12]^=qh,a[13]^=Qh,a[14]^=Yh,a[15]^=Jh,a[16]^=Xh,a[17]^=td,a[18]^=ed,a[19]^=nd,a[20]^=Wh,a[21]^=Zh,a[22]^=qh,a[23]^=Qh,a[24]^=Yh,a[25]^=Jh,a[26]^=Xh,a[27]^=td,a[28]^=ed,a[29]^=nd,a[30]^=Wh,a[31]^=Zh,a[32]^=qh,a[33]^=Qh,a[34]^=Yh,a[35]^=Jh,a[36]^=Xh,a[37]^=td,a[38]^=ed,a[39]^=nd,a[40]^=Wh,a[41]^=Zh,a[42]^=qh,a[43]^=Qh,a[44]^=Yh,a[45]^=Jh,a[46]^=Xh,a[47]^=td,a[48]^=ed,a[49]^=nd;const c1=a[0],u1=a[1],l1=a[2]<<1|a[3]>>>31,f1=a[3]<<1|a[2]>>>31,h1=a[5]<<30|a[4]>>>2,d1=a[4]<<30|a[5]>>>2,p1=a[6]<<28|a[7]>>>4,g1=a[7]<<28|a[6]>>>4,y1=a[8]<<27|a[9]>>>5,m1=a[9]<<27|a[8]>>>5,w1=a[11]<<4|a[10]>>>28,b1=a[10]<<4|a[11]>>>28,_1=a[13]<<12|a[12]>>>20,A1=a[12]<<12|a[13]>>>20,E1=a[14]<<6|a[15]>>>26,v1=a[15]<<6|a[14]>>>26,x1=a[17]<<23|a[16]>>>9,R1=a[16]<<23|a[17]>>>9,S1=a[18]<<20|a[19]>>>12,I1=a[19]<<20|a[18]>>>12,k1=a[20]<<3|a[21]>>>29,T1=a[21]<<3|a[20]>>>29,O1=a[22]<<10|a[23]>>>22,N1=a[23]<<10|a[22]>>>22,C1=a[25]<<11|a[24]>>>21,B1=a[24]<<11|a[25]>>>21,P1=a[26]<<25|a[27]>>>7,M1=a[27]<<25|a[26]>>>7,L1=a[29]<<7|a[28]>>>25,U1=a[28]<<7|a[29]>>>25,D1=a[31]<<9|a[30]>>>23,F1=a[30]<<9|a[31]>>>23,$1=a[33]<<13|a[32]>>>19,H1=a[32]<<13|a[33]>>>19,z1=a[34]<<15|a[35]>>>17,G1=a[35]<<15|a[34]>>>17,V1=a[36]<<21|a[37]>>>11,K1=a[37]<<21|a[36]>>>11,j1=a[38]<<8|a[39]>>>24,W1=a[39]<<8|a[38]>>>24,Z1=a[40]<<18|a[41]>>>14,q1=a[41]<<18|a[40]>>>14,Q1=a[42]<<2|a[43]>>>30,Y1=a[43]<<2|a[42]>>>30,J1=a[45]<<29|a[44]>>>3,X1=a[44]<<29|a[45]>>>3,tb=a[47]<<24|a[46]>>>8,eb=a[46]<<24|a[47]>>>8,nb=a[48]<<14|a[49]>>>18,rb=a[49]<<14|a[48]>>>18;a[0]=c1^~_1&C1,a[1]=u1^~A1&B1,a[2]=_1^~C1&V1,a[3]=A1^~B1&K1,a[4]=C1^~V1&nb,a[5]=B1^~K1&rb,a[6]=V1^~nb&c1,a[7]=K1^~rb&u1,a[8]=nb^~c1&_1,a[9]=rb^~u1&A1,a[10]=p1^~S1&k1,a[11]=g1^~I1&T1,a[12]=S1^~k1&$1,a[13]=I1^~T1&H1,a[14]=k1^~$1&J1,a[15]=T1^~H1&X1,a[16]=$1^~J1&p1,a[17]=H1^~X1&g1,a[18]=J1^~p1&S1,a[19]=X1^~g1&I1,a[20]=l1^~E1&P1,a[21]=f1^~v1&M1,a[22]=E1^~P1&j1,a[23]=v1^~M1&W1,a[24]=P1^~j1&Z1,a[25]=M1^~W1&q1,a[26]=j1^~Z1&l1,a[27]=W1^~q1&f1,a[28]=Z1^~l1&E1,a[29]=q1^~f1&v1,a[30]=y1^~w1&O1,a[31]=m1^~b1&N1,a[32]=w1^~O1&z1,a[33]=b1^~N1&G1,a[34]=O1^~z1&tb,a[35]=N1^~G1&eb,a[36]=z1^~tb&y1,a[37]=G1^~eb&m1,a[38]=tb^~y1&w1,a[39]=eb^~m1&b1,a[40]=h1^~x1&L1,a[41]=d1^~R1&U1,a[42]=x1^~L1&D1,a[43]=R1^~U1&F1,a[44]=L1^~D1&Q1,a[45]=U1^~F1&Y1,a[46]=D1^~Q1&h1,a[47]=F1^~Y1&d1,a[48]=Q1^~h1&x1,a[49]=Y1^~d1&R1,a[0]^=oT[l*2],a[1]^=oT[l*2+1]}}function aT(a){const l=[];for(let d=0;d<a.length;d+=4)l.push(a[d]|a[d+1]<<8|a[d+2]<<16|a[d+3]<<24);return l}function cT(a,l){if(!a.length){const x=new Uint8Array(136);return x[0]=l,x[135]=128,[aT(x)]}const d=n1(a,136),g=d[d.length-1];if(g.length<136){const x=new Uint8Array(136);x.set(g),x[g.length]=l,x[135]|=128,d[d.length-1]=x}if(g.length===136){const x=new Uint8Array(136);x[0]=l,x[135]=128,d.push(x)}return d.map(aT)}function uT(a,l){for(const d of l){for(let g=0;g<34;g+=2)a[g]^=d[g+1],a[g+1]^=d[g];hW(a)}return a}function lT(a){return new Uint8Array([a[1],a[1]>>-24,a[1]>>-16,a[1]>>-8,a[0],a[0]>>8,a[0]>>16,a[0]>>24,a[3],a[3]>>-24,a[3]>>-16,a[3]>>-8,a[2],a[2]>>8,a[2]>>16,a[2]>>24,a[5],a[5]>>-24,a[5]>>-16,a[5]>>-8,a[4],a[4]>>8,a[4]>>16,a[4]>>24,a[7],a[7]>>-24,a[7]>>-16,a[7]>>-8,a[6],a[6]>>8,a[6]>>16,a[6]>>24])}function to(a){return lT(uT(new Array(50).fill(0),cT(a,1)))}function dW(a){return lT(uT(new Array(50).fill(0),cT(a,6)))}function pW(a,l,d){const g=Math.min(a.length,l.length,d/8+1);for(let x=0;x<g;x++){const L=a[x]^l[x];for(let Q=0;Q<8;Q++)if(L>>7-Q&1)return x*8+Q}return d}function gW(a,l){const d=Math.min(a.length,l.length);for(let g=0;g<d;g++)if(a[g]!==l[g])return a.subarray(0,g);return a.subarray(0,d)}function yW(a,l,d,g){const x=Math.floor(l/8),L=l%8;d===1?a[x]|=1<<(g==="BE"?7-L:L):a[x]&=~(1<<(g==="BE"?7-L:L))}function mW(a,l,d){const g=Math.floor(l/8),x=l%8;return a[g]>>(d==="BE"?7-x:x)&1}function wW(a,l,d=0){for(let g=d;g<a.length;g++)for(let x=0;x<l.length&&a[g+x]===l[x];x++)if(x===l.length-1)return g;return-1}function fT(a,l,d=0){if(a.length>=l)return a;const g=new Uint8Array(l);return g.fill(d),g.set(a,l-a.length),g}function bW(a,l,d=0){const g=a.length%l;return g===0?a:fT(a,a.length+l-g,d)}function hT(a,l,d=0){if(a.length>=l)return a;const g=new Uint8Array(l);return g.fill(d),g.set(a,0),g}function _W(a,l,d=0){const g=a.length%l;return g===0?a:hT(a,a.length+l-g,d)}function AW(a,l){const d=new Uint8Array(a.length);for(let g=0;g<a.length;g++)d[g]=a[g]^l[g%l.length];return d}function EW(a,l){if(a.length!==l.length)return!1;for(let d=0;d<a.length;d++)if(a[d]!==l[d])return!1;return!0}function Ge(a,l){return(a%l+l)%l}function Kh(a,l){a=Ge(a,l);let[d,g]=[0n,1n],[x,L]=[l,a];for(;L!==0n;){const Q=x/L;[d,g]=[g,d-Q*g],[x,L]=[L,x-Q*L]}if(x>1n)throw new Error("a is not invertible");return d<0n&&(d+=l),d}function vW(a,l,d){let g=1n;for(a=Ge(a,d);l>0;)l%2n===1n&&(g=Ge(g*a,d)),a=Ge(a*a,d),l=l/2n;return g}function dT(a,l){return Ge(a,l)===0n?0n:l%4n===3n?vW(a,(l+1n)/4n,l):null}const ur=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,$n=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Up=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Dp=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function r1(a,l,d){if(l===0n)return[0n,0n];const g=Ge(3n*a*a*Kh(2n*l,d),d),x=Ge(g*g-2n*a,d),L=Ge(g*(a-x)-l,d);return[x,L]}function Fp(a,l,d,g,x){if(a===0n&&l===0n)return[d,g];if(d===0n&&g===0n)return[a,l];if(a===d&&l===Ge(-g,x))return[0n,0n];if(a===d&&l===g)return r1(a,l,x);const L=Ge((g-l)*Kh(d-a,x),x),Q=Ge(L*L-a-d,x),lt=Ge(L*(a-Q)-l,x);return[Q,lt]}function xW(a){if(a<=0n||a>=$n)throw new Error("Invalid private key");return Ic(Up,Dp,a,ur)}function RW(a){const l=a[1]%2n===0n?2:3;return new Uint8Array([l,...Ll(a[0],"BE")])}function SW(a){if(a.length!==33||a[0]!==2&&a[0]!==3)throw new Error("Invalid compressed public key");const l=Ul(a.slice(1),"BE"),d=dT(Ge(l**3n+7n,ur),ur);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const g=Ge(-d,ur),x=d%2n===0n;return[l,a[0]===2?x?d:g:x?g:d]}function IW(a){const l=new Uint8Array(20),d=to(Ml(Ll(a[0],"BE"),Ll(a[1],"BE")));return l.set(d.subarray(12)),l}function kW(a){const l=n.Binary.uint8ArrayToHex(a),d=n.Binary.uint8ArrayToHex(n.Binary.keccak256(new Uint8Array([...l].map(x=>x.charCodeAt(0)))));let g="0x";for(let x=0;x<l.length;x++)parseInt(d[x],16)>7?g+=l[x].toUpperCase():g+=l[x];return g}function Ic(a,l,d,g){let x=[0n,0n],L=[a,l];const Q=d.toString(2);for(const lt of Q)lt==="0"?(L=Fp(x[0],x[1],L[0],L[1],g),x=r1(x[0],x[1],g)):(x=Fp(x[0],x[1],L[0],L[1],g),L=r1(L[0],L[1],g));return x}function TW(a,l,d){return pT(Ul(to(a),"BE"),l,d)}function pT(a,l,d){if(l<=0n||l>=$n)throw new Error("Invalid private key");if(d||(d=Ge(Ul(to(Ml(to(Ll(l,"BE")),Ll(a,"BE"))),"BE"),$n)),d<=0n||d>=$n)throw new Error("Invalid nonce");const g=Ge(a,$n),x=Ic(Up,Dp,d,ur),L=Ge(x[0],$n);let Q=Ge((g+Ge(L,$n)*l)*Kh(d,$n),$n);if(L===0n||Q===0n)throw new Error("Invalid r or s value");let lt=x[1]%2n===0n?27n:28n;return Q>$n/2n&&(Q=$n-Q,lt=lt===27n?28n:27n),[L,Q,lt]}function OW(a,l,d,g){const x=dT(Ge(l**3n+7n,ur),ur);if(!x)throw new Error("Invalid r: does not correspond to a valid curve point");const L=g===27n?0n:1n,Q=x%2n===L?x:ur-x,lt=Ge(Ul(to(a),"BE"),$n),at=Ic(l,Q,d,ur),Pt=Ic(Up,Dp,lt,ur),Le=Fp(at[0],at[1],Pt[0],Ge(-Pt[1],ur),ur);return Ic(Le[0],Le[1],Kh(l,$n),ur)}function NW(a,l,d,g){const x=Ge(Ul(to(a),"BE"),$n),L=Kh(g,$n),Q=Ge(x*L,$n),lt=Ge(d*L,$n),at=Ic(Up,Dp,Q,ur),Pt=Ic(l[0],l[1],lt,ur),Le=Fp(at[0],at[1],Pt[0],Pt[1],ur);return d===Ge(Le[0],$n)}class gT{constructor(l){this.cursor=0,this.buffer=l}read(l){const d=this.buffer.subarray(this.cursor,this.cursor+l);return this.cursor+=l,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayReader=gT;class yT{constructor(l){this.buffer=l,this.cursor=0}write(l){const d=Math.min(this.max(),l.max());return this.buffer.set(l.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayWriter=yT;class $p{constructor(l,d=0n){this.span=d,this.writer=new yT(new Uint8Array(l))}build(){return Ml(e1(this.span,"LE"),this.writer.buffer)}hash(){const l=nT(n1(this.writer.buffer,32),(d,g)=>to(Ml(d,g)));return to(Ml(e1(this.span,"LE"),l))}}n.Chunk=$p;class i1{constructor(l,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new $p(d)],this.onChunk=l}static async root(l,d=4096){const g=new t(t.NOOP,d);return await g.append(l),g.finalize()}async append(l,d=0,g=0n){const x=new gT(l);for(;x.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(x);g?this.chunks[d].span+=g:this.chunks[0].span+=BigInt(L)}}async elevate(l){this.counters[l]=++this.counters[l]%(this.capacity/32),this.chunks[l+1]||(this.chunks.push(new $p(this.capacity)),this.counters.push(1)),await this.append(this.chunks[l].hash(),l+1,this.chunks[l].span),await this.onChunk(this.chunks[l]),this.chunks[l]=new $p(this.capacity)}async finalize(l=0){return this.chunks[l+1]?this.counters[l]===1?(await this.elevate(l+1),this.chunks[l+1]=this.chunks[l],this.finalize(l+1)):(await this.elevate(l),this.finalize(l+1)):(await this.onChunk(this.chunks[l]),this.chunks[l])}}n.MerkleTree=i1,t=i1,i1.NOOP=async a=>{};class fs{constructor(l,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(l),this.scale=d}static fromDecimalString(l,d){let[g,x]=l.split(".");return x=(x||"").padEnd(d,"0").slice(0,d),new fs(BigInt(g+x),d)}add(l){return this.assertSameScale(l),new fs(this.value+l.value,this.scale)}subtract(l){return this.assertSameScale(l),new fs(this.value-l.value,this.scale)}multiply(l){return new fs(this.value*l,this.scale)}divmod(l){if(l===0n)throw new Error("Division by zero is not allowed");const d=this.value/l,g=this.value%l;return[new fs(d,this.scale),new fs(g,this.scale)]}exchange(l,d,g){if(l==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new fs(L,g)}this.assertSameScale(d);const x=this.value*10n**BigInt(g)/d.value;return new fs(x,g)}compare(l){return this.assertSameScale(l),this.value>l.value?1:this.value<l.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const l=this.value.toString(),d=l.slice(0,-this.scale)||"0",g=l.slice(-this.scale).padStart(this.scale,"0");return`${d}.${g}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(l){if(this.scale!==l.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${l.scale}`)}}n.FixedPointNumber=fs;function CW(a){if(a.length===0)return null;const l=a[0];return l.ttlMax?--l.ttl<=0&&a.shift():l.ttlMax=l.ttl,{progress:(l.ttlMax-l.ttl)/l.ttlMax,data:l.data}}function Hp(a,l,d,g){const x=a.findIndex(lt=>lt===`--${l}`||lt.startsWith(`--${l}=`)),L=a[x];if(!L)return(d||{})[g||l||""]||null;if(L.includes("="))return L.split("=")[1];const Q=a[x+1];return Q&&!Q.startsWith("-")?Q:(d||{})[g||l||""]||null}function BW(a,l,d,g){const x=Hp(a,l,d,g);if(!x)return null;try{return Jw(x)}catch{throw new Error(`Invalid number argument ${l}: ${x}`)}}function PW(a,l,d,g){const x=a.some(at=>at.endsWith("-"+l)),L=Hp(a,l,d,g);if(!L&&x)return!0;if(!L&&!x)return null;const Q=["true","1","yes","y","on"],lt=["false","0","no","n","off"];if(Q.includes(L.toLowerCase()))return!0;if(lt.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${l}: ${L}`)}function mT(a,l,d,g){const x=Hp(a,l,d,g);if(!x)throw new Error(`Missing argument ${l}`);return x}function MW(a,l,d,g){const x=mT(a,l,d,g);try{return Jw(x)}catch{throw new Error(`Invalid argument ${l}: ${x}`)}}function wT(a,l){const d=a[l];a.splice(l,1),a.unshift(d)}function LW(a,l){const d=[...a];return wT(d,l),d}function bT(a,l){return{x:a.x+l.x,y:a.y+l.y}}function UW(a,l){return{x:a.x-l.x,y:a.y-l.y}}function s1(a,l){return{x:a.x*l,y:a.y*l}}function DW(a){const l=Math.sqrt(a.x*a.x+a.y*a.y);return{x:a.x/l,y:a.y/l}}function _T(a,l,d){return{x:a.x+Math.cos(l)*d,y:a.y+Math.sin(l)*d}}function AT(a,l){return Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2)}function jh(a,l,d="row-first"){const g=[];if(d==="column-first")for(let x=0;x<a.length;x++)for(let L=0;L<a[0].length;L++)l(x,L)&&g.push({x,y:L});else for(let x=0;x<a[0].length;x++)for(let L=0;L<a.length;L++)l(L,x)&&g.push({x:L,y:x});return g}function FW(a,l,d){var g,x;return((g=a[l+1])==null?void 0:g[d])&&((x=a[l-1])==null?void 0:x[d])&&!a[l][d-1]&&!a[l][d+1]}function $W(a,l,d){var g,x;return a[l][d+1]&&a[l][d-1]&&!((g=a[l-1])!=null&&g[d])&&!((x=a[l+1])!=null&&x[d])}function ET(a,l,d){var g;return!((g=a[l-1])!=null&&g[d])}function vT(a,l,d){var g;return!((g=a[l+1])!=null&&g[d])}function xT(a,l,d){return!a[l][d-1]}function RT(a,l,d){return!a[l][d+1]}function HW(a,l,d){var x,L,Q,lt,at,Pt,Le,Hn;const g=[];return a[l][d]?FW(a,l,d)||$W(a,l,d)?[]:(!((x=a[l-1])!=null&&x[d-1])&&ET(a,l,d)&&xT(a,l,d)&&g.push({x:l,y:d}),!((L=a[l+1])!=null&&L[d-1])&&vT(a,l,d)&&xT(a,l,d)&&g.push({x:l+1,y:d}),!((Q=a[l-1])!=null&&Q[d+1])&&ET(a,l,d)&&RT(a,l,d)&&g.push({x:l,y:d+1}),!((lt=a[l+1])!=null&&lt[d+1])&&vT(a,l,d)&&RT(a,l,d)&&g.push({x:l+1,y:d+1}),g):((at=a[l-1])!=null&&at[d]&&a[l][d-1]&&g.push({x:l,y:d}),(Pt=a[l+1])!=null&&Pt[d]&&a[l][d-1]&&g.push({x:l+1,y:d}),(Le=a[l-1])!=null&&Le[d]&&a[l][d+1]&&g.push({x:l,y:d+1}),(Hn=a[l+1])!=null&&Hn[d]&&a[l][d+1]&&g.push({x:l+1,y:d+1}),g)}function zW(a,l,d,g){const x=[{x:0,y:0},{x:d,y:0},{x:0,y:g},{x:d,y:g}];for(let L=0;L<a.length;L++)for(let Q=0;Q<a[0].length;Q++){const lt=HW(a,L,Q);for(const at of lt)x.some(Pt=>Pt.x===at.x&&Pt.y===at.y)||x.push(at)}return x.map(L=>({x:L.x*l,y:L.y*l}))}function GW(a,l){const d=jh(a,(at,Pt)=>a[at][Pt]===0&&a[at][Pt+1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),g=jh(a,(at,Pt)=>a[at][Pt]===0&&a[at][Pt-1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),x=jh(a,(at,Pt)=>{var Le;return a[at][Pt]===0&&((Le=a[at-1])==null?void 0:Le[Pt])!==0},"column-first").map(at=>({...at,dx:0,dy:1})),L=jh(a,(at,Pt)=>{var Le;return a[at][Pt]===0&&((Le=a[at+1])==null?void 0:Le[Pt])!==0},"column-first").map(at=>({...at,dx:0,dy:1}));d.forEach(at=>at.y++),L.forEach(at=>at.x++);const Q=t1([...x,...L],(at,Pt)=>at.x===Pt.x&&at.y-1===Pt.y),lt=t1([...g,...d],(at,Pt)=>at.y===Pt.y&&at.x-1===Pt.x);return[...Q,...lt].map(at=>({start:at[0],end:C(at)})).map(at=>({start:s1(at.start,l),end:s1(bT(at.end,{x:at.start.dx,y:at.start.dy}),l)}))}function VW(a,l){return Math.atan2(l.y-a.y,l.x-a.x)}function KW(a,l){return l.map(d=>VW(a,d)).sort((d,g)=>d-g)}function ST(a,l,d,g){const x=(g.y-d.y)*(l.x-a.x)-(g.x-d.x)*(l.y-a.y);if(x===0)return null;let L=a.y-d.y,Q=a.x-d.x;const lt=(g.x-d.x)*L-(g.y-d.y)*Q,at=(l.x-a.x)*L-(l.y-a.y)*Q;return L=lt/x,Q=at/x,L>0&&L<1&&Q>0&&Q<1?{x:a.x+L*(l.x-a.x),y:a.y+L*(l.y-a.y)}:null}function o1(a,l,d){const g=[],x=_T(a,d,1e4);for(const L of l){const Q=ST(a,x,L.start,L.end);Q&&g.push(Q)}return g.length?g.reduce((L,Q)=>{const lt=AT(a,Q),at=AT(a,L);return lt<at?Q:L}):null}function jW(a,l,d){const g=KW(a,d),x=[];for(const L of g){const Q=o1(a,l,L-.001),lt=o1(a,l,L+.001);Q&&x.push(Q),lt&&x.push(lt)}return x}class a1{constructor(){this.subscribers=[]}subscribe(l){return this.subscribers.push(l),()=>{this.subscribers=this.subscribers.filter(d=>d!==l)}}publish(l){this.subscribers.forEach(d=>d(l))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}n.PubSubChannel=a1;class WW{constructor(l,d){this.queue=[],this.running=0,this.onProcessed=new a1,this.onDrained=new a1,this.concurrency=l,this.capacity=d}process(){if(this.running>=this.concurrency)return;const l=this.queue.shift();l&&(this.running++,l().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(l){if(this.queue.length<this.capacity)return this.queue.push(l),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(l),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(l=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),l()})})}}n.AsyncQueue=WW,n.Binary={hexToUint8Array:JV,uint8ArrayToHex:XV,base64ToUint8Array:ZV,uint8ArrayToBase64:qV,base32ToUint8Array:QV,uint8ArrayToBase32:YV,log2Reduce:nT,partition:n1,concatBytes:Ml,numberToUint8:iW,uint8ToNumber:sW,numberToUint16:oW,uint16ToNumber:aW,numberToUint32:cW,uint32ToNumber:uW,numberToUint64:e1,uint64ToNumber:lW,numberToUint256:Ll,uint256ToNumber:Ul,sliceBytes:fW,keccak256:to,sha3_256:dW,proximity:pW,commonPrefix:gW,setBit:yW,getBit:mW,indexOf:wW,equals:EW,padStart:fT,padStartToMultiple:bW,padEnd:hT,padEndToMultiple:_W,xorCypher:AW},n.Elliptic={privateKeyToPublicKey:xW,compressPublicKey:RW,publicKeyFromCompressed:SW,publicKeyToAddress:IW,signMessage:TW,signHash:pT,verifySignature:NW,recoverPublicKey:OW,checksumEncode:kW},n.Random={intBetween:H,floatBetween:U,chance:Y,signed:G,makeSeededRng:B,point:J,procs:j},n.Arrays={countUnique:Dj,makeUnique:Uj,splitBySize:Mj,splitByCount:Jk,index:Yk,indexCollection:Pj,onlyOrThrow:c,onlyOrNull:u,firstOrThrow:h,firstOrNull:f,shuffle:o,initialize:y,initialize2D:b,rotate2D:A,containsShape:R,glue:rV,pluck:S,pick:it,pickMany:ut,pickManyUnique:rt,pickWeighted:v,pickRandomIndices:k,pickGuaranteed:ot,last:C,pipe:p,makePipe:m,sortWeighted:I,pushAll:na,unshiftAll:eV,filterAndRemove:EK,merge:mj,empty:wj,pushToBucket:$h,unshiftAndLimit:Hh,atRolling:zh,group:t1,createOscillator:ij,organiseWithLimits:oj,tickPlaybook:CW,getArgument:Hp,getBooleanArgument:PW,getNumberArgument:BW,requireStringArgument:mT,requireNumberArgument:MW,bringToFront:LW,bringToFrontInPlace:wT,findInstance:Yj,filterInstances:Jj,interleave:Xj,toggle:tW,createHierarchy:nW,multicall:qj,maxBy:Qj},n.System={sleepMillis:s,forever:dt,scheduleMany:lV,waitFor:AK,expandError:Lh,runAndSetInterval:mt},n.Numbers={make:Jw,sum:hV,average:dV,median:pV,getDistanceFromMidpoint:gV,clamp:Xw,range:_k,interpolate:fV,createSequence:rj,increment:dj,decrement:pj,format:hj,fromDecimals:fj,makeStorage:WK,asMegabytes:Gt,convertBytes:Ut,hexToRgb:Lt,rgbToHex:xe,haversineDistanceToMeters:Kt,roundToNearest:Ft,formatDistance:ke,triangularNumber:re,searchFloat:oe},n.Promises={raceFulfilled:r,invert:e,runInParallelBatches:i},n.Dates={getTimestamp:NK,getTimeDelta:zk,secondsToHumanTime:CK,countCycles:BK,isoDate:RK,throttle:PK,timeSince:LK,dateTimeSlug:SK,unixTimestamp:xK,fromUtcString:IK,fromMillis:kK,getProgress:UK,humanizeTime:Mp,humanizeProgress:_K,createTimeDigits:ls,mapDayNumber:Gk,getDayInfoFromDate:Qw,getDayInfoFromDateTimeString:FK,seconds:$K,minutes:HK,hours:zK,days:GK,make:KK,normalizeTime:TK,absoluteDays:Rc},n.Objects={safeParse:nj,deleteDeep:_,getDeep:N,setDeep:M,incrementDeep:z,ensureDeep:P,replaceDeep:F,getFirstDeep:ct,deepMergeInPlace:Ti,deepMerge2:Uh,deepMerge3:Dh,mapAllAsync:nV,cloneWithJson:vK,sortObject:Kk,sortArray:jk,sortAny:Sc,deepEquals:Wk,deepEqualsEvery:ej,runOn:gj,ifPresent:yj,zip:Bl,zipSum:Fh,removeEmptyArrays:bj,removeEmptyValues:_j,flatten:Cj,unflatten:Qk,match:Bj,sort:tT,map:vj,mapIterable:xj,filterKeys:Aj,filterValues:Ej,rethrow:Rj,setSomeOnObject:Sj,setSomeDeep:Ij,flip:kj,getAllPermutations:Tj,countTruthyValues:Oj,transformToArray:Fj,setMulti:Hj,incrementMulti:$j,createBidirectionalMap:zj,createTemporalBidirectionalMap:Gj,pushToBidirectionalMap:eT,unshiftToBidirectionalMap:Vj,addToTemporalBidirectionalMap:Kj,getFromTemporalBidirectionalMap:jj,createStatefulToggle:sj,diffKeys:aj,pickRandomKey:Zk,mapRandomKey:cj,fromObjectString:uj,toQueryString:$k,parseQueryString:hK,hasKey:dK,selectMax:pK,reposition:gK,unwrapSingleKey:yK,parseKeyValues:mK},n.Types={isFunction:Ce,isObject:rn,isStrictlyObject:fe,isEmptyArray:Ue,isEmptyObject:ea,isUndefined:Re,isString:In,isNumber:he,isBoolean:Se,isDate:sn,isBlank:Ee,isId:Be,isIntegerString:cr,isHexString:De,isUrl:Nl,isNullable:Ch,asString:on,asHexString:dn,asSafeString:Tp,asIntegerString:kp,asNumber:vc,asFunction:pn,asInteger:Ye,asBoolean:gn,asDate:Op,asNullableString:yn,asEmptiableString:mn,asId:Np,asTime:wn,asArray:bn,asObject:xc,asNullableObject:_n,asStringMap:An,asNumericDictionary:Oh,asUrl:Nh,asNullable:Bh,asOptional:Ph,enforceObjectShape:Cl,enforceArrayShape:Mh,isPng:rT,isJpg:iT,isWebp:sT,isImage:rW},n.Strings={tokenizeByCount:Lj,tokenizeByLength:Xk,searchHex:Ip,searchSubstring:fn,randomHex:hn,randomLetter:jt,randomAlphanumeric:Fe,randomRichAscii:Ht,randomUnicode:ln,includesAny:yV,slugify:Hw,normalForm:wV,enumify:xV,escapeHtml:SV,decodeHtmlEntities:kV,after:zw,afterLast:Ek,before:Ak,beforeLast:Gw,betweenWide:TV,betweenNarrow:OV,getPreLine:ZK,containsWord:Zw,containsWords:cK,joinUrl:Vk,getFuzzyMatchScore:Cp,sortByFuzzyScore:RV,splitOnce:Vw,splitAll:vk,randomize:PV,expand:xk,shrinkTrim:Gh,capitalize:Bp,decapitalize:Rk,csvEscape:$V,parseCsv:bK,surroundInOut:vV,getExtension:Kw,getBasename:jw,normalizeEmail:NV,normalizeFilename:CV,parseFilename:BV,camelToTitle:bV,slugToTitle:_V,slugToCamel:AV,joinHumanly:EV,findWeightedPair:Nk,extractBlock:Ck,extractAllBlocks:GV,replaceBlocks:VV,indexOfEarliest:Pl,lastIndexOfBefore:Ok,parseHtmlAttributes:uK,readNextWord:Pp,resolveVariables:lK,resolveVariableWithDefaultSyntax:Dk,resolveRemainingVariablesWithDefaults:Fk,isLetter:Sk,isDigit:Ik,isLetterOrDigit:Vh,isValidObjectPathCharacter:UV,insert:DV,indexOfRegex:kk,lineMatches:Tk,linesMatchInOrder:FV,represent:Xs,resolveMarkdownLinks:fK,buildUrl:wK,isChinese:mV,replaceBetweenStrings:YK,describeMarkdown:JK,isBalanced:XK,textToFormat:tj,splitFormatting:KV,splitHashtags:jV,splitUrls:WV,route:tK,explodeReplace:Ww,generateVariants:eK,replaceWord:nK,replacePascalCaseWords:rK,stripHtml:iK,breakLine:Uk,measureTextWidth:sK,toLines:oK,levenshteinDistance:aK},n.Assertions={asEqual:iV,asTrue:sV,asTruthy:oV,asFalse:aV,asFalsy:cV,asEither:uV},n.Cache={get:qK,invalidate:QK},n.Vector={addPoint:bT,subtractPoint:UW,multiplyPoint:s1,normalizePoint:DW,pushPoint:_T,filterCoordinates:jh,findCorners:zW,findLines:GW,raycast:o1,raycastCircle:jW,getLineIntersectionPoint:ST}})(n_);const Ke=Br(n_);Ke.Arrays,Ke.Assertions;const Jn=Ke.Binary;Ke.Cache,Ke.Dates,Ke.Elliptic,Ke.Numbers,Ke.Objects,Ke.Pagination,Ke.Promises,Ke.Random,Ke.Strings,Ke.System,Ke.Types,Ke.Optional,Ke.Vector,Ke.PubSubChannel,Ke.Chunk;const d8=Ke.MerkleTree;Ke.FixedPointNumber,Ke.Lazy,Ke.AsyncLazy,Ke.AsyncQueue,Ke.Uint8ArrayReader,Ke.Uint8ArrayWriter;var de;(function(n){n.assertEqual=i=>i;function t(i){}n.assertIs=t;function e(i){throw new Error}n.assertNever=e,n.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},n.getValidEnumValues=i=>{const s=n.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},n.find=(i,s)=>{for(const o of i)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(de||(de={}));var cg;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(cg||(cg={}));const St=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ds=n=>{switch(typeof n){case"undefined":return St.undefined;case"string":return St.string;case"number":return isNaN(n)?St.nan:St.number;case"boolean":return St.boolean;case"function":return St.function;case"bigint":return St.bigint;case"symbol":return St.symbol;case"object":return Array.isArray(n)?St.array:n===null?St.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?St.promise:typeof Map<"u"&&n instanceof Map?St.map:typeof Set<"u"&&n instanceof Set?St.set:typeof Date<"u"&&n instanceof Date?St.date:St.object;default:return St.unknown}},gt=de.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),p8=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class Pr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let c=r,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(c[f]=c[f]||{_errors:[]},c[f]._errors.push(e(o))):c[f]=c[f]||{_errors:[]},c=c[f],u++}}};return i(this),r}static assert(t){if(!(t instanceof Pr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}Pr.create=n=>new Pr(n);const Mc=(n,t)=>{let e;switch(n.code){case gt.invalid_type:n.received===St.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case gt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,de.jsonStringifyReplacer)}`;break;case gt.unrecognized_keys:e=`Unrecognized key(s) in object: ${de.joinValues(n.keys,", ")}`;break;case gt.invalid_union:e="Invalid input";break;case gt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${de.joinValues(n.options)}`;break;case gt.invalid_enum_value:e=`Invalid enum value. Expected ${de.joinValues(n.options)}, received '${n.received}'`;break;case gt.invalid_arguments:e="Invalid function arguments";break;case gt.invalid_return_type:e="Invalid function return type";break;case gt.invalid_date:e="Invalid date";break;case gt.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:de.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case gt.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case gt.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case gt.custom:e="Invalid input";break;case gt.invalid_intersection_types:e="Intersection results could not be merged";break;case gt.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case gt.not_finite:e="Number must be finite";break;default:e=t.defaultError,de.assertNever(n)}return{message:e}};let r_=Mc;function g8(n){r_=n}function wd(){return r_}const bd=n=>{const{data:t,path:e,errorMaps:r,issueData:i}=n,s=[...e,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=r.filter(f=>!!f).slice().reverse();for(const f of u)c=f(o,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},y8=[];function At(n,t){const e=wd(),r=bd({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Mc?void 0:Mc].filter(i=>!!i)});n.common.issues.push(r)}class Xn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const i of e){if(i.status==="aborted")return Vt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const i of e){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Xn.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const i of e){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Vt;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Vt=Object.freeze({status:"aborted"}),Lc=n=>({status:"dirty",value:n}),lr=n=>({status:"valid",value:n}),ug=n=>n.status==="aborted",lg=n=>n.status==="dirty",oa=n=>n.status==="valid",Gl=n=>typeof Promise<"u"&&n instanceof Promise;function _d(n,t,e,r){if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(n)}function i_(n,t,e,r,i){if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,e),e}typeof SuppressedError=="function"&&SuppressedError;var Bt;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Bt||(Bt={}));var Vl,Kl;class Ni{constructor(t,e,r,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const s_=(n,t)=>{if(oa(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new Pr(n.common.issues);return this._error=e,this._error}}};function Qt(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:i}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,c)=>{var u,f;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??c.defaultError}:typeof c.data>"u"?{message:(u=h??r)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(f=h??e)!==null&&f!==void 0?f:c.defaultError}},description:i}}class Jt{get description(){return this._def.description}_getType(t){return ds(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:ds(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Xn,ctx:{common:t.parent.common,data:t.data,parsedType:ds(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Gl(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;const i={common:{issues:[],async:(r=e==null?void 0:e.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ds(t)},s=this._parseSync({data:t,path:i.path,parent:i});return s_(i,s)}"~validate"(t){var e,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ds(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:i});return oa(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((r=(e=s==null?void 0:s.message)===null||e===void 0?void 0:e.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>oa(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ds(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Gl(i)?i:Promise.resolve(i));return s_(r,s)}refine(t,e){const r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,s)=>{const o=t(i),c=()=>s.addIssue({code:gt.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(t,e){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(t){return new hi({schema:this,typeName:zt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Bi.create(this,this._def)}nullable(){return io.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fi.create(this)}promise(){return $c.create(this,this._def)}or(t){return ql.create([this,t],this._def)}and(t){return Ql.create(this,t,this._def)}transform(t){return new hi({...Qt(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new ef({...Qt(this._def),innerType:this,defaultValue:e,typeName:zt.ZodDefault})}brand(){return new dg({typeName:zt.ZodBranded,type:this,...Qt(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new nf({...Qt(this._def),innerType:this,catchValue:e,typeName:zt.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return rf.create(this,t)}readonly(){return sf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const m8=/^c[^\s-]{8,}$/i,w8=/^[0-9a-z]+$/,b8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_8=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,A8=/^[a-z0-9_-]{21}$/i,E8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v8=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,x8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,R8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let fg;const S8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,I8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,k8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,T8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,O8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,N8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,o_="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",C8=new RegExp(`^${o_}$`);function a_(n){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`),t}function B8(n){return new RegExp(`^${a_(n)}$`)}function c_(n){let t=`${o_}T${a_(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function P8(n,t){return!!((t==="v4"||!t)&&S8.test(n)||(t==="v6"||!t)&&k8.test(n))}function M8(n,t){if(!E8.test(n))return!1;try{const[e]=n.split("."),r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function L8(n,t){return!!((t==="v4"||!t)&&I8.test(n)||(t==="v6"||!t)&&T8.test(n))}class li extends Jt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==St.string){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:St.string,received:s.parsedType}),Vt}const r=new Xn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,c=t.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(t,i),o?At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")x8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"email",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")fg||(fg=new RegExp(R8,"u")),fg.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"emoji",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")_8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"uuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")A8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"nanoid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")m8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")w8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid2",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")b8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ulid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),At(i,{validation:"url",code:gt.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"regex",code:gt.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?c_(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?C8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?B8(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?v8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"duration",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?P8(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ip",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?M8(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"jwt",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?L8(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cidr",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?O8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?N8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64url",code:gt.invalid_string,message:s.message}),r.dirty()):de.assertNever(s);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(i=>t.test(i),{validation:e,code:gt.invalid_string,...Bt.errToObj(r)})}_addCheck(t){return new li({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Bt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Bt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Bt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Bt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Bt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Bt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Bt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Bt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Bt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Bt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Bt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Bt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Bt.errToObj(t)})}datetime(t){var e,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(e=t==null?void 0:t.offset)!==null&&e!==void 0?e:!1,local:(r=t==null?void 0:t.local)!==null&&r!==void 0?r:!1,...Bt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Bt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Bt.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Bt.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Bt.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Bt.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Bt.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Bt.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Bt.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Bt.errToObj(e)})}nonempty(t){return this.min(1,Bt.errToObj(t))}trim(){return new li({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new li({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new li({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}li.create=n=>{var t;return new li({checks:[],typeName:zt.ZodString,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Qt(n)})};function U8(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=e>r?e:r,s=parseInt(n.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class eo extends Jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==St.number){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:St.number,received:s.parsedType}),Vt}let r;const i=new Xn;for(const s of this._def.checks)s.kind==="int"?de.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?U8(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_finite,message:s.message}),i.dirty()):de.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new eo({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new eo({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Bt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Bt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Bt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Bt.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&de.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}eo.create=n=>new eo({checks:[],typeName:zt.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Qt(n)});class no extends Jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==St.bigint)return this._getInvalidInput(t);let r;const i=new Xn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):de.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:St.bigint,received:e.parsedType}),Vt}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new no({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new no({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}no.create=n=>{var t;return new no({checks:[],typeName:zt.ZodBigInt,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Qt(n)})};class jl extends Jt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==St.boolean){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.boolean,received:r.parsedType}),Vt}return lr(t.data)}}jl.create=n=>new jl({typeName:zt.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Qt(n)});class aa extends Jt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==St.date){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:St.date,received:s.parsedType}),Vt}if(isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_date}),Vt}const r=new Xn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):de.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new aa({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Bt.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Bt.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}aa.create=n=>new aa({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:zt.ZodDate,...Qt(n)});class Ad extends Jt{_parse(t){if(this._getType(t)!==St.symbol){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.symbol,received:r.parsedType}),Vt}return lr(t.data)}}Ad.create=n=>new Ad({typeName:zt.ZodSymbol,...Qt(n)});class Wl extends Jt{_parse(t){if(this._getType(t)!==St.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.undefined,received:r.parsedType}),Vt}return lr(t.data)}}Wl.create=n=>new Wl({typeName:zt.ZodUndefined,...Qt(n)});class Zl extends Jt{_parse(t){if(this._getType(t)!==St.null){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.null,received:r.parsedType}),Vt}return lr(t.data)}}Zl.create=n=>new Zl({typeName:zt.ZodNull,...Qt(n)});class Uc extends Jt{constructor(){super(...arguments),this._any=!0}_parse(t){return lr(t.data)}}Uc.create=n=>new Uc({typeName:zt.ZodAny,...Qt(n)});class ca extends Jt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return lr(t.data)}}ca.create=n=>new ca({typeName:zt.ZodUnknown,...Qt(n)});class ps extends Jt{_parse(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:St.never,received:e.parsedType}),Vt}}ps.create=n=>new ps({typeName:zt.ZodNever,...Qt(n)});class Ed extends Jt{_parse(t){if(this._getType(t)!==St.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.void,received:r.parsedType}),Vt}return lr(t.data)}}Ed.create=n=>new Ed({typeName:zt.ZodVoid,...Qt(n)});class fi extends Jt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),i=this._def;if(e.parsedType!==St.array)return At(e,{code:gt.invalid_type,expected:St.array,received:e.parsedType}),Vt;if(i.exactLength!==null){const o=e.data.length>i.exactLength.value,c=e.data.length<i.exactLength.value;(o||c)&&(At(e,{code:o?gt.too_big:gt.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&e.data.length<i.minLength.value&&(At(e,{code:gt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&e.data.length>i.maxLength.value&&(At(e,{code:gt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,c)=>i.type._parseAsync(new Ni(e,o,e.path,c)))).then(o=>Xn.mergeArray(r,o));const s=[...e.data].map((o,c)=>i.type._parseSync(new Ni(e,o,e.path,c)));return Xn.mergeArray(r,s)}get element(){return this._def.type}min(t,e){return new fi({...this._def,minLength:{value:t,message:Bt.toString(e)}})}max(t,e){return new fi({...this._def,maxLength:{value:t,message:Bt.toString(e)}})}length(t,e){return new fi({...this._def,exactLength:{value:t,message:Bt.toString(e)}})}nonempty(t){return this.min(1,t)}}fi.create=(n,t)=>new fi({type:n,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Qt(t)});function Dc(n){if(n instanceof Je){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Bi.create(Dc(r))}return new Je({...n._def,shape:()=>t})}else return n instanceof fi?new fi({...n._def,type:Dc(n.element)}):n instanceof Bi?Bi.create(Dc(n.unwrap())):n instanceof io?io.create(Dc(n.unwrap())):n instanceof Ci?Ci.create(n.items.map(t=>Dc(t))):n}class Je extends Jt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=de.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==St.object){const f=this._getOrReturnCtx(t);return At(f,{code:gt.invalid_type,expected:St.object,received:f.parsedType}),Vt}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof ps&&this._def.unknownKeys==="strip"))for(const f in i.data)o.includes(f)||c.push(f);const u=[];for(const f of o){const h=s[f],y=i.data[f];u.push({key:{status:"valid",value:f},value:h._parse(new Ni(i,y,i.path,f)),alwaysSet:f in i.data})}if(this._def.catchall instanceof ps){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of c)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(f==="strict")c.length>0&&(At(i,{code:gt.unrecognized_keys,keys:c}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of c){const y=i.data[h];u.push({key:{status:"valid",value:h},value:f._parse(new Ni(i,y,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of u){const y=await h.key,A=await h.value;f.push({key:y,value:A,alwaysSet:h.alwaysSet})}return f}).then(f=>Xn.mergeObjectSync(r,f)):Xn.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Bt.errToObj,new Je({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(c=Bt.errToObj(t).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(t){return new Je({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Je({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Je({...this._def,catchall:t})}pick(t){const e={};return de.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new Je({...this._def,shape:()=>e})}omit(t){const e={};return de.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new Je({...this._def,shape:()=>e})}deepPartial(){return Dc(this)}partial(t){const e={};return de.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?e[r]=i:e[r]=i.optional()}),new Je({...this._def,shape:()=>e})}required(t){const e={};return de.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Bi;)s=s._def.innerType;e[r]=s}}),new Je({...this._def,shape:()=>e})}keyof(){return u_(de.objectKeys(this.shape))}}Je.create=(n,t)=>new Je({shape:()=>n,unknownKeys:"strip",catchall:ps.create(),typeName:zt.ZodObject,...Qt(t)}),Je.strictCreate=(n,t)=>new Je({shape:()=>n,unknownKeys:"strict",catchall:ps.create(),typeName:zt.ZodObject,...Qt(t)}),Je.lazycreate=(n,t)=>new Je({shape:n,unknownKeys:"strip",catchall:ps.create(),typeName:zt.ZodObject,...Qt(t)});class ql extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return e.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new Pr(c.ctx.common.issues));return At(e,{code:gt.invalid_union,unionErrors:o}),Vt}if(e.common.async)return Promise.all(r.map(async s=>{const o={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of r){const f={...e,common:{...e.common,issues:[]},parent:null},h=u._parseSync({data:e.data,path:e.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new Pr(u));return At(e,{code:gt.invalid_union,unionErrors:c}),Vt}}get options(){return this._def.options}}ql.create=(n,t)=>new ql({options:n,typeName:zt.ZodUnion,...Qt(t)});const gs=n=>n instanceof Jl?gs(n.schema):n instanceof hi?gs(n.innerType()):n instanceof Xl?[n.value]:n instanceof ro?n.options:n instanceof tf?de.objectValues(n.enum):n instanceof ef?gs(n._def.innerType):n instanceof Wl?[void 0]:n instanceof Zl?[null]:n instanceof Bi?[void 0,...gs(n.unwrap())]:n instanceof io?[null,...gs(n.unwrap())]:n instanceof dg||n instanceof sf?gs(n.unwrap()):n instanceof nf?gs(n._def.innerType):[];class vd extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==St.object)return At(e,{code:gt.invalid_type,expected:St.object,received:e.parsedType}),Vt;const r=this.discriminator,i=e.data[r],s=this.optionsMap.get(i);return s?e.common.async?s._parseAsync({data:e.data,path:e.path,parent:e}):s._parseSync({data:e.data,path:e.path,parent:e}):(At(e,{code:gt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){const i=new Map;for(const s of e){const o=gs(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new vd({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:i,...Qt(r)})}}function hg(n,t){const e=ds(n),r=ds(t);if(n===t)return{valid:!0,data:n};if(e===St.object&&r===St.object){const i=de.objectKeys(t),s=de.objectKeys(n).filter(c=>i.indexOf(c)!==-1),o={...n,...t};for(const c of s){const u=hg(n[c],t[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(e===St.array&&r===St.array){if(n.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<n.length;s++){const o=n[s],c=t[s],u=hg(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return e===St.date&&r===St.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Ql extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(ug(s)||ug(o))return Vt;const c=hg(s.value,o.value);return c.valid?((lg(s)||lg(o))&&e.dirty(),{status:e.value,value:c.data}):(At(r,{code:gt.invalid_intersection_types}),Vt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ql.create=(n,t,e)=>new Ql({left:n,right:t,typeName:zt.ZodIntersection,...Qt(e)});class Ci extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==St.array)return At(r,{code:gt.invalid_type,expected:St.array,received:r.parsedType}),Vt;if(r.data.length<this._def.items.length)return At(r,{code:gt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Vt;!this._def.rest&&r.data.length>this._def.items.length&&(At(r,{code:gt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const s=[...r.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new Ni(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Xn.mergeArray(e,o)):Xn.mergeArray(e,s)}get items(){return this._def.items}rest(t){return new Ci({...this._def,rest:t})}}Ci.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ci({items:n,typeName:zt.ZodTuple,rest:null,...Qt(t)})};class Yl extends Jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==St.object)return At(r,{code:gt.invalid_type,expected:St.object,received:r.parsedType}),Vt;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in r.data)i.push({key:s._parse(new Ni(r,c,r.path,c)),value:o._parse(new Ni(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?Xn.mergeObjectAsync(e,i):Xn.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof Jt?new Yl({keyType:t,valueType:e,typeName:zt.ZodRecord,...Qt(r)}):new Yl({keyType:li.create(),valueType:t,typeName:zt.ZodRecord,...Qt(e)})}}class xd extends Jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==St.map)return At(r,{code:gt.invalid_type,expected:St.map,received:r.parsedType}),Vt;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,u],f)=>({key:i._parse(new Ni(r,c,r.path,[f,"key"])),value:s._parse(new Ni(r,u,r.path,[f,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const f=await u.key,h=await u.value;if(f.status==="aborted"||h.status==="aborted")return Vt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),c.set(f.value,h.value)}return{status:e.value,value:c}})}else{const c=new Map;for(const u of o){const f=u.key,h=u.value;if(f.status==="aborted"||h.status==="aborted")return Vt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),c.set(f.value,h.value)}return{status:e.value,value:c}}}}xd.create=(n,t,e)=>new xd({valueType:t,keyType:n,typeName:zt.ZodMap,...Qt(e)});class ua extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==St.set)return At(r,{code:gt.invalid_type,expected:St.set,received:r.parsedType}),Vt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(At(r,{code:gt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(At(r,{code:gt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());const s=this._def.valueType;function o(u){const f=new Set;for(const h of u){if(h.status==="aborted")return Vt;h.status==="dirty"&&e.dirty(),f.add(h.value)}return{status:e.value,value:f}}const c=[...r.data.values()].map((u,f)=>s._parse(new Ni(r,u,r.path,f)));return r.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(t,e){return new ua({...this._def,minSize:{value:t,message:Bt.toString(e)}})}max(t,e){return new ua({...this._def,maxSize:{value:t,message:Bt.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}ua.create=(n,t)=>new ua({valueType:n,minSize:null,maxSize:null,typeName:zt.ZodSet,...Qt(t)});class Fc extends Jt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==St.function)return At(e,{code:gt.invalid_type,expected:St.function,received:e.parsedType}),Vt;function r(c,u){return bd({data:c,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,wd(),Mc].filter(f=>!!f),issueData:{code:gt.invalid_arguments,argumentsError:u}})}function i(c,u){return bd({data:c,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,wd(),Mc].filter(f=>!!f),issueData:{code:gt.invalid_return_type,returnTypeError:u}})}const s={errorMap:e.common.contextualErrorMap},o=e.data;if(this._def.returns instanceof $c){const c=this;return lr(async function(...u){const f=new Pr([]),h=await c._def.args.parseAsync(u,s).catch(b=>{throw f.addIssue(r(u,b)),f}),y=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(y,s).catch(b=>{throw f.addIssue(i(y,b)),f})})}else{const c=this;return lr(function(...u){const f=c._def.args.safeParse(u,s);if(!f.success)throw new Pr([r(u,f.error)]);const h=Reflect.apply(o,this,f.data),y=c._def.returns.safeParse(h,s);if(!y.success)throw new Pr([i(h,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Fc({...this._def,args:Ci.create(t).rest(ca.create())})}returns(t){return new Fc({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new Fc({args:t||Ci.create([]).rest(ca.create()),returns:e||ca.create(),typeName:zt.ZodFunction,...Qt(r)})}}class Jl extends Jt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Jl.create=(n,t)=>new Jl({getter:n,typeName:zt.ZodLazy,...Qt(t)});class Xl extends Jt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return At(e,{received:e.data,code:gt.invalid_literal,expected:this._def.value}),Vt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Xl.create=(n,t)=>new Xl({value:n,typeName:zt.ZodLiteral,...Qt(t)});function u_(n,t){return new ro({values:n,typeName:zt.ZodEnum,...Qt(t)})}class ro extends Jt{constructor(){super(...arguments),Vl.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{expected:de.joinValues(r),received:e.parsedType,code:gt.invalid_type}),Vt}if(_d(this,Vl)||i_(this,Vl,new Set(this._def.values)),!_d(this,Vl).has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{received:e.data,code:gt.invalid_enum_value,options:r}),Vt}return lr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return ro.create(t,{...this._def,...e})}exclude(t,e=this._def){return ro.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Vl=new WeakMap,ro.create=u_;class tf extends Jt{constructor(){super(...arguments),Kl.set(this,void 0)}_parse(t){const e=de.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==St.string&&r.parsedType!==St.number){const i=de.objectValues(e);return At(r,{expected:de.joinValues(i),received:r.parsedType,code:gt.invalid_type}),Vt}if(_d(this,Kl)||i_(this,Kl,new Set(de.getValidEnumValues(this._def.values))),!_d(this,Kl).has(t.data)){const i=de.objectValues(e);return At(r,{received:r.data,code:gt.invalid_enum_value,options:i}),Vt}return lr(t.data)}get enum(){return this._def.values}}Kl=new WeakMap,tf.create=(n,t)=>new tf({values:n,typeName:zt.ZodNativeEnum,...Qt(t)});class $c extends Jt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==St.promise&&e.common.async===!1)return At(e,{code:gt.invalid_type,expected:St.promise,received:e.parsedType}),Vt;const r=e.parsedType===St.promise?e.data:Promise.resolve(e.data);return lr(r.then(i=>this._def.type.parseAsync(i,{path:e.path,errorMap:e.common.contextualErrorMap})))}}$c.create=(n,t)=>new $c({type:n,typeName:zt.ZodPromise,...Qt(t)});class hi extends Jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{At(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(e.value==="aborted")return Vt;const u=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return u.status==="aborted"?Vt:u.status==="dirty"||e.value==="dirty"?Lc(u.value):u});{if(e.value==="aborted")return Vt;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?Vt:c.status==="dirty"||e.value==="dirty"?Lc(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?Vt:(c.status==="dirty"&&e.dirty(),o(c.value),{status:e.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?Vt:(c.status==="dirty"&&e.dirty(),o(c.value).then(()=>({status:e.value,value:c.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!oa(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>oa(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:e.value,value:c})):o);de.assertNever(i)}}hi.create=(n,t,e)=>new hi({schema:n,typeName:zt.ZodEffects,effect:t,...Qt(e)}),hi.createWithPreprocess=(n,t,e)=>new hi({schema:t,effect:{type:"preprocess",transform:n},typeName:zt.ZodEffects,...Qt(e)});class Bi extends Jt{_parse(t){return this._getType(t)===St.undefined?lr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Bi.create=(n,t)=>new Bi({innerType:n,typeName:zt.ZodOptional,...Qt(t)});class io extends Jt{_parse(t){return this._getType(t)===St.null?lr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}io.create=(n,t)=>new io({innerType:n,typeName:zt.ZodNullable,...Qt(t)});class ef extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===St.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}ef.create=(n,t)=>new ef({innerType:n,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Qt(t)});class nf extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Gl(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pr(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}nf.create=(n,t)=>new nf({innerType:n,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Qt(t)});class Rd extends Jt{_parse(t){if(this._getType(t)!==St.nan){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:St.nan,received:r.parsedType}),Vt}return{status:"valid",value:t.data}}}Rd.create=n=>new Rd({typeName:zt.ZodNaN,...Qt(n)});const D8=Symbol("zod_brand");class dg extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class rf extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Vt:s.status==="dirty"?(e.dirty(),Lc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Vt:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,e){return new rf({in:t,out:e,typeName:zt.ZodPipeline})}}class sf extends Jt{_parse(t){const e=this._def.innerType._parse(t),r=i=>(oa(i)&&(i.value=Object.freeze(i.value)),i);return Gl(e)?e.then(i=>r(i)):r(e)}unwrap(){return this._def.innerType}}sf.create=(n,t)=>new sf({innerType:n,typeName:zt.ZodReadonly,...Qt(t)});function l_(n,t={},e){return n?Uc.create().superRefine((r,i)=>{var s,o;if(!n(r)){const c=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(o=(s=c.fatal)!==null&&s!==void 0?s:e)!==null&&o!==void 0?o:!0,f=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...f,fatal:u})}}):Uc.create()}const F8={object:Je.lazycreate};var zt;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(zt||(zt={}));const $8=(n,t={message:`Input not instance of ${n.name}`})=>l_(e=>e instanceof n,t),f_=li.create,h_=eo.create,H8=Rd.create,z8=no.create,d_=jl.create,G8=aa.create,V8=Ad.create,K8=Wl.create,j8=Zl.create,W8=Uc.create,Z8=ca.create,q8=ps.create,Q8=Ed.create,Y8=fi.create,J8=Je.create,X8=Je.strictCreate,t5=ql.create,e5=vd.create,n5=Ql.create,r5=Ci.create,i5=Yl.create,s5=xd.create,o5=ua.create,a5=Fc.create,c5=Jl.create,u5=Xl.create,l5=ro.create,f5=tf.create,h5=$c.create,p_=hi.create,d5=Bi.create,p5=io.create,g5=hi.createWithPreprocess,y5=rf.create;var so=Object.freeze({__proto__:null,defaultErrorMap:Mc,setErrorMap:g8,getErrorMap:wd,makeIssue:bd,EMPTY_PATH:y8,addIssueToContext:At,ParseStatus:Xn,INVALID:Vt,DIRTY:Lc,OK:lr,isAborted:ug,isDirty:lg,isValid:oa,isAsync:Gl,get util(){return de},get objectUtil(){return cg},ZodParsedType:St,getParsedType:ds,ZodType:Jt,datetimeRegex:c_,ZodString:li,ZodNumber:eo,ZodBigInt:no,ZodBoolean:jl,ZodDate:aa,ZodSymbol:Ad,ZodUndefined:Wl,ZodNull:Zl,ZodAny:Uc,ZodUnknown:ca,ZodNever:ps,ZodVoid:Ed,ZodArray:fi,ZodObject:Je,ZodUnion:ql,ZodDiscriminatedUnion:vd,ZodIntersection:Ql,ZodTuple:Ci,ZodRecord:Yl,ZodMap:xd,ZodSet:ua,ZodFunction:Fc,ZodLazy:Jl,ZodLiteral:Xl,ZodEnum:ro,ZodNativeEnum:tf,ZodPromise:$c,ZodEffects:hi,ZodTransformer:hi,ZodOptional:Bi,ZodNullable:io,ZodDefault:ef,ZodCatch:nf,ZodNaN:Rd,BRAND:D8,ZodBranded:dg,ZodPipeline:rf,ZodReadonly:sf,custom:l_,Schema:Jt,ZodSchema:Jt,late:F8,get ZodFirstPartyTypeKind(){return zt},coerce:{string:n=>li.create({...n,coerce:!0}),number:n=>eo.create({...n,coerce:!0}),boolean:n=>jl.create({...n,coerce:!0}),bigint:n=>no.create({...n,coerce:!0}),date:n=>aa.create({...n,coerce:!0})},any:W8,array:Y8,bigint:z8,boolean:d_,date:G8,discriminatedUnion:e5,effect:p_,enum:l5,function:a5,instanceof:$8,intersection:n5,lazy:c5,literal:u5,map:s5,nan:H8,nativeEnum:f5,never:q8,null:j8,nullable:p5,number:h_,object:J8,oboolean:()=>d_().optional(),onumber:()=>h_().optional(),optional:d5,ostring:()=>f_().optional(),pipeline:y5,preprocess:g5,promise:h5,record:i5,set:o5,strictObject:X8,string:f_,symbol:V8,transformer:p_,tuple:r5,undefined:K8,union:t5,unknown:Z8,void:Q8,NEVER:Vt,ZodIssueCode:gt,quotelessJson:p8,ZodError:Pr});const pg=Oi.getInstance(),g_=so.object({username:so.string(),address:so.string(),timestamp:so.number(),index:so.number(),signature:so.string()}),m5=so.object({topic:so.string(),messageSender:g_});function w5(n){const t=m5.safeParse(n);return t.success?n.messageSender&&!b5(n.messageSender)?(console.warn("Invalid messageSender"),!1):!0:(pg.warn(t.error.format()),!1)}function b5(n){const t=g_.safeParse(n);return t.success?_5(n):(pg.warn(t.error.format()),!1)}function _5(n){try{const t={username:n.username,address:n.address,timestamp:n.timestamp},e=new TextEncoder,r=Jn.concatBytes(e.encode(`Ethereum Signed Message:
11
- 32`),Jn.keccak256(e.encode(JSON.stringify(t))));if(new xt.Signature(n.signature).isValid(r,n.address))throw new Error("Signature verification failed!");return!0}catch(t){return pg.warn("Error in validateUserSignature",t),!1}}async function A5(n){const{condition:t,broadcast:e,maxRetries:r=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=n;return new Promise((c,u)=>{let f=0;const h=async()=>{await ag(i);for(let y=0;y<o;y++){if(await Promise.resolve(t()))return c();await ag(s)}if(++f>=r)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${f} of ${r}`),await e(),h()};console.log("Starting broadcast..."),e().then(()=>h()).catch(u)})}const Mr={LOADING_INIT:"loadingInit",LOADING_PREVIOUS_MESSAGES:"loadingPreviousMessages",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_INITIATED:"messageRequestInitiated",MESSAGE_REQUEST_UPLOADED:"messageRequestUploaded",MESSAGE_REQUEST_ERROR:"messageRequestError",CRITICAL_ERROR:"criticalError"},E5=1e3;class v5{constructor(t,e){this.utils=t,this.emitter=e,this.logger=Oi.getInstance(),this.errorHandler=new md,this.historyIndex=null}async init(){try{const t=await this.utils.fetchLatestChatMessage();this.historyIndex=t.index,await this.fetchPreviousMessages()}catch(t){this.errorHandler.handleError(t,"SwarmHistory.init")}}async fetchPreviousMessages(t=10){try{if(!this.historyIndex){this.logger.warn("History index is not set. Cannot fetch previous messages.");return}if(this.historyIndex.toBigInt()===0n){this.logger.warn("No previous messages to fetch.");return}const e=this.historyIndex.toBigInt(),r=e>BigInt(t)?e-BigInt(t):0n;for(let i=e-1n;i>=r;i--){const s=await this.utils.fetchChatMessage(xt.FeedIndex.fromBigInt(i));if(this.emitter.emit(Mr.MESSAGE_RECEIVED,s),this.historyIndex=xt.FeedIndex.fromBigInt(i),i===0n)break}}catch(e){this.errorHandler.handleError(e,"SwarmHistory.fetchPreviousMessages")}}}const Hc=globalThis||void 0||self;var gg={},Sd={};Sd.byteLength=S5,Sd.toByteArray=k5,Sd.fromByteArray=N5;for(var Pi=[],qr=[],x5=typeof Uint8Array<"u"?Uint8Array:Array,yg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zc=0,R5=yg.length;zc<R5;++zc)Pi[zc]=yg[zc],qr[yg.charCodeAt(zc)]=zc;qr[45]=62,qr[95]=63;function y_(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function S5(n){var t=y_(n),e=t[0],r=t[1];return(e+r)*3/4-r}function I5(n,t,e){return(t+e)*3/4-e}function k5(n){var t,e=y_(n),r=e[0],i=e[1],s=new x5(I5(n,r,i)),o=0,c=i>0?r-4:r,u;for(u=0;u<c;u+=4)t=qr[n.charCodeAt(u)]<<18|qr[n.charCodeAt(u+1)]<<12|qr[n.charCodeAt(u+2)]<<6|qr[n.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=qr[n.charCodeAt(u)]<<2|qr[n.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=qr[n.charCodeAt(u)]<<10|qr[n.charCodeAt(u+1)]<<4|qr[n.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function T5(n){return Pi[n>>18&63]+Pi[n>>12&63]+Pi[n>>6&63]+Pi[n&63]}function O5(n,t,e){for(var r,i=[],s=t;s<e;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(T5(r));return i.join("")}function N5(n){for(var t,e=n.length,r=e%3,i=[],s=16383,o=0,c=e-r;o<c;o+=s)i.push(O5(n,o,o+s>c?c:o+s));return r===1?(t=n[e-1],i.push(Pi[t>>2]+Pi[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(Pi[t>>10]+Pi[t>>4&63]+Pi[t<<2&63]+"=")),i.join("")}var mg={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */mg.read=function(n,t,e,r,i){var s,o,c=i*8-r-1,u=(1<<c)-1,f=u>>1,h=-7,y=e?i-1:0,A=e?-1:1,b=n[t+y];for(y+=A,s=b&(1<<-h)-1,b>>=-h,h+=c;h>0;s=s*256+n[t+y],y+=A,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=o*256+n[t+y],y+=A,h-=8);if(s===0)s=1-f;else{if(s===u)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-f}return(b?-1:1)*o*Math.pow(2,s-r)},mg.write=function(n,t,e,r,i,s){var o,c,u,f=s*8-i-1,h=(1<<f)-1,y=h>>1,A=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=r?0:s-1,R=r?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+y>=1?t+=A/u:t+=A*Math.pow(2,1-y),t*u>=2&&(o++,u/=2),o+y>=h?(c=0,o=h):o+y>=1?(c=(t*u-1)*Math.pow(2,i),o=o+y):(c=t*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;n[e+b]=c&255,b+=R,c/=256,i-=8);for(o=o<<i|c,f+=i;f>0;n[e+b]=o&255,b+=R,o/=256,f-=8);n[e+b-R]|=k*128};/*!
12
- * The buffer module from node.js, for the browser.
13
- *
14
- * @author Feross Aboukhadijeh <https://feross.org>
15
- * @license MIT
16
- */(function(n){const t=Sd,e=mg,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=h,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:c}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const O=new s(1),w={foo:function(){return 42}};return Object.setPrototypeOf(w,s.prototype),Object.setPrototypeOf(O,w),O.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function f(O){if(O>i)throw new RangeError('The value "'+O+'" is invalid for option "size"');const w=new s(O);return Object.setPrototypeOf(w,h.prototype),w}function h(O,w,E){if(typeof O=="number"){if(typeof w=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(O)}return y(O,w,E)}h.poolSize=8192;function y(O,w,E){if(typeof O=="string")return k(O,w);if(o.isView(O))return B(O);if(O==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O);if(sn(O,o)||O&&sn(O.buffer,o)||typeof c<"u"&&(sn(O,c)||O&&sn(O.buffer,c)))return H(O,w,E);if(typeof O=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=O.valueOf&&O.valueOf();if(D!=null&&D!==O)return h.from(D,w,E);const V=U(O);if(V)return V;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof O[Symbol.toPrimitive]=="function")return h.from(O[Symbol.toPrimitive]("string"),w,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O)}h.from=function(O,w,E){return y(O,w,E)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function A(O){if(typeof O!="number")throw new TypeError('"size" argument must be of type number');if(O<0)throw new RangeError('The value "'+O+'" is invalid for option "size"')}function b(O,w,E){return A(O),O<=0?f(O):w!==void 0?typeof E=="string"?f(O).fill(w,E):f(O).fill(w):f(O)}h.alloc=function(O,w,E){return b(O,w,E)};function R(O){return A(O),f(O<0?0:G(O)|0)}h.allocUnsafe=function(O){return R(O)},h.allocUnsafeSlow=function(O){return R(O)};function k(O,w){if((typeof w!="string"||w==="")&&(w="utf8"),!h.isEncoding(w))throw new TypeError("Unknown encoding: "+w);const E=J(O,w)|0;let D=f(E);const V=D.write(O,w);return V!==E&&(D=D.slice(0,V)),D}function S(O){const w=O.length<0?0:G(O.length)|0,E=f(w);for(let D=0;D<w;D+=1)E[D]=O[D]&255;return E}function B(O){if(sn(O,s)){const w=new s(O);return H(w.buffer,w.byteOffset,w.byteLength)}return S(O)}function H(O,w,E){if(w<0||O.byteLength<w)throw new RangeError('"offset" is outside of buffer bounds');if(O.byteLength<w+(E||0))throw new RangeError('"length" is outside of buffer bounds');let D;return w===void 0&&E===void 0?D=new s(O):E===void 0?D=new s(O,w):D=new s(O,w,E),Object.setPrototypeOf(D,h.prototype),D}function U(O){if(h.isBuffer(O)){const w=G(O.length)|0,E=f(w);return E.length===0||O.copy(E,0,0,w),E}if(O.length!==void 0)return typeof O.length!="number"||Ee(O.length)?f(0):S(O);if(O.type==="Buffer"&&Array.isArray(O.data))return S(O.data)}function G(O){if(O>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return O|0}function W(O){return+O!=O&&(O=0),h.alloc(+O)}h.isBuffer=function(w){return w!=null&&w._isBuffer===!0&&w!==h.prototype},h.compare=function(w,E){if(sn(w,s)&&(w=h.from(w,w.offset,w.byteLength)),sn(E,s)&&(E=h.from(E,E.offset,E.byteLength)),!h.isBuffer(w)||!h.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(w===E)return 0;let D=w.length,V=E.length;for(let q=0,st=Math.min(D,V);q<st;++q)if(w[q]!==E[q]){D=w[q],V=E[q];break}return D<V?-1:V<D?1:0},h.isEncoding=function(w){switch(String(w).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(w,E){if(!Array.isArray(w))throw new TypeError('"list" argument must be an Array of Buffers');if(w.length===0)return h.alloc(0);let D;if(E===void 0)for(E=0,D=0;D<w.length;++D)E+=w[D].length;const V=h.allocUnsafe(E);let q=0;for(D=0;D<w.length;++D){let st=w[D];if(sn(st,s))q+st.length>V.length?(h.isBuffer(st)||(st=h.from(st)),st.copy(V,q)):s.prototype.set.call(V,st,q);else if(h.isBuffer(st))st.copy(V,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=st.length}return V};function J(O,w){if(h.isBuffer(O))return O.length;if(o.isView(O)||sn(O,o))return O.byteLength;if(typeof O!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof O);const E=O.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&E===0)return 0;let V=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return Re(O).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return he(O).length;default:if(V)return D?-1:Re(O).length;w=(""+w).toLowerCase(),V=!0}}h.byteLength=J;function j(O,w,E){let D=!1;if((w===void 0||w<0)&&(w=0),w>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,w>>>=0,E<=w))return"";for(O||(O="utf8");;)switch(O){case"hex":return _(this,w,E);case"utf8":case"utf-8":return I(this,w,E);case"ascii":return z(this,w,E);case"latin1":case"binary":return P(this,w,E);case"base64":return v(this,w,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,w,E);default:if(D)throw new TypeError("Unknown encoding: "+O);O=(O+"").toLowerCase(),D=!0}}h.prototype._isBuffer=!0;function Y(O,w,E){const D=O[w];O[w]=O[E],O[E]=D}h.prototype.swap16=function(){const w=this.length;if(w%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<w;E+=2)Y(this,E,E+1);return this},h.prototype.swap32=function(){const w=this.length;if(w%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<w;E+=4)Y(this,E,E+3),Y(this,E+1,E+2);return this},h.prototype.swap64=function(){const w=this.length;if(w%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<w;E+=8)Y(this,E,E+7),Y(this,E+1,E+6),Y(this,E+2,E+5),Y(this,E+3,E+4);return this},h.prototype.toString=function(){const w=this.length;return w===0?"":arguments.length===0?I(this,0,w):j.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(w){if(!h.isBuffer(w))throw new TypeError("Argument must be a Buffer");return this===w?!0:h.compare(this,w)===0},h.prototype.inspect=function(){let w="";const E=n.INSPECT_MAX_BYTES;return w=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(w+=" ... "),"<Buffer "+w+">"},r&&(h.prototype[r]=h.prototype.inspect),h.prototype.compare=function(w,E,D,V,q){if(sn(w,s)&&(w=h.from(w,w.offset,w.byteLength)),!h.isBuffer(w))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof w);if(E===void 0&&(E=0),D===void 0&&(D=w?w.length:0),V===void 0&&(V=0),q===void 0&&(q=this.length),E<0||D>w.length||V<0||q>this.length)throw new RangeError("out of range index");if(V>=q&&E>=D)return 0;if(V>=q)return-1;if(E>=D)return 1;if(E>>>=0,D>>>=0,V>>>=0,q>>>=0,this===w)return 0;let st=q-V,qt=D-E;const Wt=Math.min(st,qt),jt=this.slice(V,q),Fe=w.slice(E,D);for(let Ht=0;Ht<Wt;++Ht)if(jt[Ht]!==Fe[Ht]){st=jt[Ht],qt=Fe[Ht];break}return st<qt?-1:qt<st?1:0};function it(O,w,E,D,V){if(O.length===0)return-1;if(typeof E=="string"?(D=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,Ee(E)&&(E=V?0:O.length-1),E<0&&(E=O.length+E),E>=O.length){if(V)return-1;E=O.length-1}else if(E<0)if(V)E=0;else return-1;if(typeof w=="string"&&(w=h.from(w,D)),h.isBuffer(w))return w.length===0?-1:ut(O,w,E,D,V);if(typeof w=="number")return w=w&255,typeof s.prototype.indexOf=="function"?V?s.prototype.indexOf.call(O,w,E):s.prototype.lastIndexOf.call(O,w,E):ut(O,[w],E,D,V);throw new TypeError("val must be string, number or Buffer")}function ut(O,w,E,D,V){let q=1,st=O.length,qt=w.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(O.length<2||w.length<2)return-1;q=2,st/=2,qt/=2,E/=2}function Wt(Fe,Ht){return q===1?Fe[Ht]:Fe.readUInt16BE(Ht*q)}let jt;if(V){let Fe=-1;for(jt=E;jt<st;jt++)if(Wt(O,jt)===Wt(w,Fe===-1?0:jt-Fe)){if(Fe===-1&&(Fe=jt),jt-Fe+1===qt)return Fe*q}else Fe!==-1&&(jt-=jt-Fe),Fe=-1}else for(E+qt>st&&(E=st-qt),jt=E;jt>=0;jt--){let Fe=!0;for(let Ht=0;Ht<qt;Ht++)if(Wt(O,jt+Ht)!==Wt(w,Ht)){Fe=!1;break}if(Fe)return jt}return-1}h.prototype.includes=function(w,E,D){return this.indexOf(w,E,D)!==-1},h.prototype.indexOf=function(w,E,D){return it(this,w,E,D,!0)},h.prototype.lastIndexOf=function(w,E,D){return it(this,w,E,D,!1)};function rt(O,w,E,D){E=Number(E)||0;const V=O.length-E;D?(D=Number(D),D>V&&(D=V)):D=V;const q=w.length;D>q/2&&(D=q/2);let st;for(st=0;st<D;++st){const qt=parseInt(w.substr(st*2,2),16);if(Ee(qt))return st;O[E+st]=qt}return st}function ot(O,w,E,D){return Se(Re(w,O.length-E),O,E,D)}function C(O,w,E,D){return Se(Ce(w),O,E,D)}function p(O,w,E,D){return Se(he(w),O,E,D)}function m(O,w,E,D){return Se(In(w,O.length-E),O,E,D)}h.prototype.write=function(w,E,D,V){if(E===void 0)V="utf8",D=this.length,E=0;else if(D===void 0&&typeof E=="string")V=E,D=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(D)?(D=D>>>0,V===void 0&&(V="utf8")):(V=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-E;if((D===void 0||D>q)&&(D=q),w.length>0&&(D<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let st=!1;for(;;)switch(V){case"hex":return rt(this,w,E,D);case"utf8":case"utf-8":return ot(this,w,E,D);case"ascii":case"latin1":case"binary":return C(this,w,E,D);case"base64":return p(this,w,E,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,w,E,D);default:if(st)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),st=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(O,w,E){return w===0&&E===O.length?t.fromByteArray(O):t.fromByteArray(O.slice(w,E))}function I(O,w,E){E=Math.min(O.length,E);const D=[];let V=w;for(;V<E;){const q=O[V];let st=null,qt=q>239?4:q>223?3:q>191?2:1;if(V+qt<=E){let Wt,jt,Fe,Ht;switch(qt){case 1:q<128&&(st=q);break;case 2:Wt=O[V+1],(Wt&192)===128&&(Ht=(q&31)<<6|Wt&63,Ht>127&&(st=Ht));break;case 3:Wt=O[V+1],jt=O[V+2],(Wt&192)===128&&(jt&192)===128&&(Ht=(q&15)<<12|(Wt&63)<<6|jt&63,Ht>2047&&(Ht<55296||Ht>57343)&&(st=Ht));break;case 4:Wt=O[V+1],jt=O[V+2],Fe=O[V+3],(Wt&192)===128&&(jt&192)===128&&(Fe&192)===128&&(Ht=(q&15)<<18|(Wt&63)<<12|(jt&63)<<6|Fe&63,Ht>65535&&Ht<1114112&&(st=Ht))}}st===null?(st=65533,qt=1):st>65535&&(st-=65536,D.push(st>>>10&1023|55296),st=56320|st&1023),D.push(st),V+=qt}return M(D)}const N=4096;function M(O){const w=O.length;if(w<=N)return String.fromCharCode.apply(String,O);let E="",D=0;for(;D<w;)E+=String.fromCharCode.apply(String,O.slice(D,D+=N));return E}function z(O,w,E){let D="";E=Math.min(O.length,E);for(let V=w;V<E;++V)D+=String.fromCharCode(O[V]&127);return D}function P(O,w,E){let D="";E=Math.min(O.length,E);for(let V=w;V<E;++V)D+=String.fromCharCode(O[V]);return D}function _(O,w,E){const D=O.length;(!w||w<0)&&(w=0),(!E||E<0||E>D)&&(E=D);let V="";for(let q=w;q<E;++q)V+=Be[O[q]];return V}function F(O,w,E){const D=O.slice(w,E);let V="";for(let q=0;q<D.length-1;q+=2)V+=String.fromCharCode(D[q]+D[q+1]*256);return V}h.prototype.slice=function(w,E){const D=this.length;w=~~w,E=E===void 0?D:~~E,w<0?(w+=D,w<0&&(w=0)):w>D&&(w=D),E<0?(E+=D,E<0&&(E=0)):E>D&&(E=D),E<w&&(E=w);const V=this.subarray(w,E);return Object.setPrototypeOf(V,h.prototype),V};function ct(O,w,E){if(O%1!==0||O<0)throw new RangeError("offset is not uint");if(O+w>E)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[w+st]*q;return V},h.prototype.readUintBE=h.prototype.readUIntBE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w+--E],q=1;for(;E>0&&(q*=256);)V+=this[w+--E]*q;return V},h.prototype.readUint8=h.prototype.readUInt8=function(w,E){return w=w>>>0,E||ct(w,1,this.length),this[w]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(w,E){return w=w>>>0,E||ct(w,2,this.length),this[w]|this[w+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(w,E){return w=w>>>0,E||ct(w,2,this.length),this[w]<<8|this[w+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),(this[w]|this[w+1]<<8|this[w+2]<<16)+this[w+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]*16777216+(this[w+1]<<16|this[w+2]<<8|this[w+3])},h.prototype.readBigUInt64LE=cr(function(w){w=w>>>0,rn(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&fe(w,this.length-8);const V=E+this[++w]*2**8+this[++w]*2**16+this[++w]*2**24,q=this[++w]+this[++w]*2**8+this[++w]*2**16+D*2**24;return BigInt(V)+(BigInt(q)<<BigInt(32))}),h.prototype.readBigUInt64BE=cr(function(w){w=w>>>0,rn(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&fe(w,this.length-8);const V=E*2**24+this[++w]*2**16+this[++w]*2**8+this[++w],q=this[++w]*2**24+this[++w]*2**16+this[++w]*2**8+D;return(BigInt(V)<<BigInt(32))+BigInt(q)}),h.prototype.readIntLE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[w+st]*q;return q*=128,V>=q&&(V-=Math.pow(2,8*E)),V},h.prototype.readIntBE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=E,q=1,st=this[w+--V];for(;V>0&&(q*=256);)st+=this[w+--V]*q;return q*=128,st>=q&&(st-=Math.pow(2,8*E)),st},h.prototype.readInt8=function(w,E){return w=w>>>0,E||ct(w,1,this.length),this[w]&128?(255-this[w]+1)*-1:this[w]},h.prototype.readInt16LE=function(w,E){w=w>>>0,E||ct(w,2,this.length);const D=this[w]|this[w+1]<<8;return D&32768?D|4294901760:D},h.prototype.readInt16BE=function(w,E){w=w>>>0,E||ct(w,2,this.length);const D=this[w+1]|this[w]<<8;return D&32768?D|4294901760:D},h.prototype.readInt32LE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]|this[w+1]<<8|this[w+2]<<16|this[w+3]<<24},h.prototype.readInt32BE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]<<24|this[w+1]<<16|this[w+2]<<8|this[w+3]},h.prototype.readBigInt64LE=cr(function(w){w=w>>>0,rn(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&fe(w,this.length-8);const V=this[w+4]+this[w+5]*2**8+this[w+6]*2**16+(D<<24);return(BigInt(V)<<BigInt(32))+BigInt(E+this[++w]*2**8+this[++w]*2**16+this[++w]*2**24)}),h.prototype.readBigInt64BE=cr(function(w){w=w>>>0,rn(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&fe(w,this.length-8);const V=(E<<24)+this[++w]*2**16+this[++w]*2**8+this[++w];return(BigInt(V)<<BigInt(32))+BigInt(this[++w]*2**24+this[++w]*2**16+this[++w]*2**8+D)}),h.prototype.readFloatLE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),e.read(this,w,!0,23,4)},h.prototype.readFloatBE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),e.read(this,w,!1,23,4)},h.prototype.readDoubleLE=function(w,E){return w=w>>>0,E||ct(w,8,this.length),e.read(this,w,!0,52,8)},h.prototype.readDoubleBE=function(w,E){return w=w>>>0,E||ct(w,8,this.length),e.read(this,w,!1,52,8)};function dt(O,w,E,D,V,q){if(!h.isBuffer(O))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>V||w<q)throw new RangeError('"value" argument is out of bounds');if(E+D>O.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(w,E,D,V){if(w=+w,E=E>>>0,D=D>>>0,!V){const qt=Math.pow(2,8*D)-1;dt(this,w,E,D,qt,0)}let q=1,st=0;for(this[E]=w&255;++st<D&&(q*=256);)this[E+st]=w/q&255;return E+D},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(w,E,D,V){if(w=+w,E=E>>>0,D=D>>>0,!V){const qt=Math.pow(2,8*D)-1;dt(this,w,E,D,qt,0)}let q=D-1,st=1;for(this[E+q]=w&255;--q>=0&&(st*=256);)this[E+q]=w/st&255;return E+D},h.prototype.writeUint8=h.prototype.writeUInt8=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,1,255,0),this[E]=w&255,E+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,2,65535,0),this[E]=w&255,this[E+1]=w>>>8,E+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,2,65535,0),this[E]=w>>>8,this[E+1]=w&255,E+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,4,4294967295,0),this[E+3]=w>>>24,this[E+2]=w>>>16,this[E+1]=w>>>8,this[E]=w&255,E+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,4,4294967295,0),this[E]=w>>>24,this[E+1]=w>>>16,this[E+2]=w>>>8,this[E+3]=w&255,E+4};function mt(O,w,E,D,V){oe(w,D,V,O,E,7);let q=Number(w&BigInt(4294967295));O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q;let st=Number(w>>BigInt(32)&BigInt(4294967295));return O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,E}function Gt(O,w,E,D,V){oe(w,D,V,O,E,7);let q=Number(w&BigInt(4294967295));O[E+7]=q,q=q>>8,O[E+6]=q,q=q>>8,O[E+5]=q,q=q>>8,O[E+4]=q;let st=Number(w>>BigInt(32)&BigInt(4294967295));return O[E+3]=st,st=st>>8,O[E+2]=st,st=st>>8,O[E+1]=st,st=st>>8,O[E]=st,E+8}h.prototype.writeBigUInt64LE=cr(function(w,E=0){return mt(this,w,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=cr(function(w,E=0){return Gt(this,w,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(w,E,D,V){if(w=+w,E=E>>>0,!V){const Wt=Math.pow(2,8*D-1);dt(this,w,E,D,Wt-1,-Wt)}let q=0,st=1,qt=0;for(this[E]=w&255;++q<D&&(st*=256);)w<0&&qt===0&&this[E+q-1]!==0&&(qt=1),this[E+q]=(w/st>>0)-qt&255;return E+D},h.prototype.writeIntBE=function(w,E,D,V){if(w=+w,E=E>>>0,!V){const Wt=Math.pow(2,8*D-1);dt(this,w,E,D,Wt-1,-Wt)}let q=D-1,st=1,qt=0;for(this[E+q]=w&255;--q>=0&&(st*=256);)w<0&&qt===0&&this[E+q+1]!==0&&(qt=1),this[E+q]=(w/st>>0)-qt&255;return E+D},h.prototype.writeInt8=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,1,127,-128),w<0&&(w=255+w+1),this[E]=w&255,E+1},h.prototype.writeInt16LE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,2,32767,-32768),this[E]=w&255,this[E+1]=w>>>8,E+2},h.prototype.writeInt16BE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,2,32767,-32768),this[E]=w>>>8,this[E+1]=w&255,E+2},h.prototype.writeInt32LE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,4,2147483647,-2147483648),this[E]=w&255,this[E+1]=w>>>8,this[E+2]=w>>>16,this[E+3]=w>>>24,E+4},h.prototype.writeInt32BE=function(w,E,D){return w=+w,E=E>>>0,D||dt(this,w,E,4,2147483647,-2147483648),w<0&&(w=4294967295+w+1),this[E]=w>>>24,this[E+1]=w>>>16,this[E+2]=w>>>8,this[E+3]=w&255,E+4},h.prototype.writeBigInt64LE=cr(function(w,E=0){return mt(this,w,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=cr(function(w,E=0){return Gt(this,w,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ut(O,w,E,D,V,q){if(E+D>O.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function Lt(O,w,E,D,V){return w=+w,E=E>>>0,V||Ut(O,w,E,4),e.write(O,w,E,D,23,4),E+4}h.prototype.writeFloatLE=function(w,E,D){return Lt(this,w,E,!0,D)},h.prototype.writeFloatBE=function(w,E,D){return Lt(this,w,E,!1,D)};function xe(O,w,E,D,V){return w=+w,E=E>>>0,V||Ut(O,w,E,8),e.write(O,w,E,D,52,8),E+8}h.prototype.writeDoubleLE=function(w,E,D){return xe(this,w,E,!0,D)},h.prototype.writeDoubleBE=function(w,E,D){return xe(this,w,E,!1,D)},h.prototype.copy=function(w,E,D,V){if(!h.isBuffer(w))throw new TypeError("argument should be a Buffer");if(D||(D=0),!V&&V!==0&&(V=this.length),E>=w.length&&(E=w.length),E||(E=0),V>0&&V<D&&(V=D),V===D||w.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(D<0||D>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),w.length-E<V-D&&(V=w.length-E+D);const q=V-D;return this===w&&typeof s.prototype.copyWithin=="function"?this.copyWithin(E,D,V):s.prototype.set.call(w,this.subarray(D,V),E),q},h.prototype.fill=function(w,E,D,V){if(typeof w=="string"){if(typeof E=="string"?(V=E,E=0,D=this.length):typeof D=="string"&&(V=D,D=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!h.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(w.length===1){const st=w.charCodeAt(0);(V==="utf8"&&st<128||V==="latin1")&&(w=st)}}else typeof w=="number"?w=w&255:typeof w=="boolean"&&(w=Number(w));if(E<0||this.length<E||this.length<D)throw new RangeError("Out of range index");if(D<=E)return this;E=E>>>0,D=D===void 0?this.length:D>>>0,w||(w=0);let q;if(typeof w=="number")for(q=E;q<D;++q)this[q]=w;else{const st=h.isBuffer(w)?w:h.from(w,V),qt=st.length;if(qt===0)throw new TypeError('The value "'+w+'" is invalid for argument "value"');for(q=0;q<D-E;++q)this[q+E]=st[q%qt]}return this};const Kt={};function Ft(O,w,E){Kt[O]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:w.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${O}]`,this.stack,delete this.name}get code(){return O}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${O}]: ${this.message}`}}}Ft("ERR_BUFFER_OUT_OF_BOUNDS",function(O){return O?`${O} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ft("ERR_INVALID_ARG_TYPE",function(O,w){return`The "${O}" argument must be of type number. Received type ${typeof w}`},TypeError),Ft("ERR_OUT_OF_RANGE",function(O,w,E){let D=`The value of "${O}" is out of range.`,V=E;return Number.isInteger(E)&&Math.abs(E)>2**32?V=ke(String(E)):typeof E=="bigint"&&(V=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(V=ke(V)),V+="n"),D+=` It must be ${w}. Received ${V}`,D},RangeError);function ke(O){let w="",E=O.length;const D=O[0]==="-"?1:0;for(;E>=D+4;E-=3)w=`_${O.slice(E-3,E)}${w}`;return`${O.slice(0,E)}${w}`}function re(O,w,E){rn(w,"offset"),(O[w]===void 0||O[w+E]===void 0)&&fe(w,O.length-(E+1))}function oe(O,w,E,D,V,q){if(O>E||O<w){const st=typeof w=="bigint"?"n":"";let qt;throw w===0||w===BigInt(0)?qt=`>= 0${st} and < 2${st} ** ${(q+1)*8}${st}`:qt=`>= -(2${st} ** ${(q+1)*8-1}${st}) and < 2 ** ${(q+1)*8-1}${st}`,new Kt.ERR_OUT_OF_RANGE("value",qt,O)}re(D,V,q)}function rn(O,w){if(typeof O!="number")throw new Kt.ERR_INVALID_ARG_TYPE(w,"number",O)}function fe(O,w,E){throw Math.floor(O)!==O?(rn(O,E),new Kt.ERR_OUT_OF_RANGE("offset","an integer",O)):w<0?new Kt.ERR_BUFFER_OUT_OF_BOUNDS:new Kt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${w}`,O)}const Ue=/[^+/0-9A-Za-z-_]/g;function ea(O){if(O=O.split("=")[0],O=O.trim().replace(Ue,""),O.length<2)return"";for(;O.length%4!==0;)O=O+"=";return O}function Re(O,w){w=w||1/0;let E;const D=O.length;let V=null;const q=[];for(let st=0;st<D;++st){if(E=O.charCodeAt(st),E>55295&&E<57344){if(!V){if(E>56319){(w-=3)>-1&&q.push(239,191,189);continue}else if(st+1===D){(w-=3)>-1&&q.push(239,191,189);continue}V=E;continue}if(E<56320){(w-=3)>-1&&q.push(239,191,189),V=E;continue}E=(V-55296<<10|E-56320)+65536}else V&&(w-=3)>-1&&q.push(239,191,189);if(V=null,E<128){if((w-=1)<0)break;q.push(E)}else if(E<2048){if((w-=2)<0)break;q.push(E>>6|192,E&63|128)}else if(E<65536){if((w-=3)<0)break;q.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((w-=4)<0)break;q.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return q}function Ce(O){const w=[];for(let E=0;E<O.length;++E)w.push(O.charCodeAt(E)&255);return w}function In(O,w){let E,D,V;const q=[];for(let st=0;st<O.length&&!((w-=2)<0);++st)E=O.charCodeAt(st),D=E>>8,V=E%256,q.push(V),q.push(D);return q}function he(O){return t.toByteArray(ea(O))}function Se(O,w,E,D){let V;for(V=0;V<D&&!(V+E>=w.length||V>=O.length);++V)w[V+E]=O[V];return V}function sn(O,w){return O instanceof w||O!=null&&O.constructor!=null&&O.constructor.name!=null&&O.constructor.name===w.name}function Ee(O){return O!==O}const Be=function(){const O="0123456789abcdef",w=new Array(256);for(let E=0;E<16;++E){const D=E*16;for(let V=0;V<16;++V)w[D+V]=O[E]+O[V]}return w}();function cr(O){return typeof BigInt>"u"?De:O}function De(){throw new Error("BigInt not supported")}})(gg);const Zt=gg.Buffer,kt=gg.Buffer,C5=Object.freeze(Object.defineProperty({__proto__:null,Buffer:kt,default:Zt},Symbol.toStringTag,{value:"Module"}));var wg={exports:{}};const bg=kc(C5);wg.exports,function(n){(function(t,e){function r(C,p){if(!C)throw new Error(p||"Assertion failed")}function i(C,p){C.super_=p;var m=function(){};m.prototype=p.prototype,C.prototype=new m,C.prototype.constructor=C}function s(C,p,m){if(s.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(C||0,p||10,m||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=bg.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,v){if(typeof p=="number")return this._initNumber(p,m,v);if(typeof p=="object")return this._initArray(p,m,v);m==="hex"&&(m=16),r(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var I=0;p[0]==="-"&&(I++,this.negative=1),I<p.length&&(m===16?this._parseHex(p,I,v):(this._parseBase(p,m,I),v==="le"&&this._initArray(this.toArray(),m,v)))},s.prototype._initNumber=function(p,m,v){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(r(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),m,v)},s.prototype._initArray=function(p,m,v){if(r(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N,M,z=0;if(v==="be")for(I=p.length-1,N=0;I>=0;I-=3)M=p[I]|p[I-1]<<8|p[I-2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);else if(v==="le")for(I=0,N=0;I<p.length;I+=3)M=p[I]|p[I+1]<<8|p[I+2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);return this._strip()};function c(C,p){var m=C.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;r(!1,"Invalid character in "+C)}function u(C,p,m){var v=c(C,m);return m-1>=p&&(v|=c(C,m-1)<<4),v}s.prototype._parseHex=function(p,m,v){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N=0,M=0,z;if(v==="be")for(I=p.length-1;I>=m;I-=2)z=u(p,m,I)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8;else{var P=p.length-m;for(I=P%2===0?m+1:m;I<p.length;I+=2)z=u(p,m,I)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8}this._strip()};function f(C,p,m,v){for(var I=0,N=0,M=Math.min(C.length,m),z=p;z<M;z++){var P=C.charCodeAt(z)-48;I*=v,P>=49?N=P-49+10:P>=17?N=P-17+10:N=P,r(P>=0&&N<v,"Invalid character"),I+=N}return I}s.prototype._parseBase=function(p,m,v){this.words=[0],this.length=1;for(var I=0,N=1;N<=67108863;N*=m)I++;I--,N=N/m|0;for(var M=p.length-v,z=M%I,P=Math.min(M,M-z)+v,_=0,F=v;F<P;F+=I)_=f(p,F,F+I,m),this.imuln(N),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_);if(z!==0){var ct=1;for(_=f(p,F,p.length,m),F=0;F<z;F++)ct*=m;this.imuln(ct),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var m=0;m<this.length;m++)p.words[m]=this.words[m];p.length=this.length,p.negative=this.negative,p.red=this.red};function h(C,p){C.words=p.words,C.length=p.length,C.negative=p.negative,C.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var A=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],R=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var v;if(p===16||p==="hex"){v="";for(var I=0,N=0,M=0;M<this.length;M++){var z=this.words[M],P=((z<<I|N)&16777215).toString(16);N=z>>>24-I&16777215,I+=2,I>=26&&(I-=26,M--),N!==0||M!==this.length-1?v=A[6-P.length]+P+v:v=P+v}for(N!==0&&(v=N.toString(16)+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(p===(p|0)&&p>=2&&p<=36){var _=b[p],F=R[p];v="";var ct=this.clone();for(ct.negative=0;!ct.isZero();){var dt=ct.modrn(F).toString(p);ct=ct.idivn(F),ct.isZero()?v=dt+v:v=A[_-dt.length]+dt+v}for(this.isZero()&&(v="0"+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var k=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,v){this._strip();var I=this.byteLength(),N=v||Math.max(1,I);r(I<=N,"byte array longer than desired length"),r(N>0,"Requested array length <= 0");var M=k(p,N),z=m==="le"?"LE":"BE";return this["_toArrayLike"+z](M,I),M},s.prototype._toArrayLikeLE=function(p,m){for(var v=0,I=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|I;p[v++]=z&255,v<p.length&&(p[v++]=z>>8&255),v<p.length&&(p[v++]=z>>16&255),M===6?(v<p.length&&(p[v++]=z>>24&255),I=0,M=0):(I=z>>>24,M+=2)}if(v<p.length)for(p[v++]=I;v<p.length;)p[v++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var v=p.length-1,I=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|I;p[v--]=z&255,v>=0&&(p[v--]=z>>8&255),v>=0&&(p[v--]=z>>16&255),M===6?(v>=0&&(p[v--]=z>>24&255),I=0,M=0):(I=z>>>24,M+=2)}if(v>=0)for(p[v--]=I;v>=0;)p[v--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,v=0;return m>=4096&&(v+=13,m>>>=13),m>=64&&(v+=7,m>>>=7),m>=8&&(v+=4,m>>>=4),m>=2&&(v+=2,m>>>=2),v+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,v=0;return m&8191||(v+=13,m>>>=13),m&127||(v+=7,m>>>=7),m&15||(v+=4,m>>>=4),m&3||(v+=2,m>>>=2),m&1||v++,v},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function S(C){for(var p=new Array(C.bitLength()),m=0;m<p.length;m++){var v=m/26|0,I=m%26;p[m]=C.words[v]>>>I&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var v=this._zeroBits(this.words[m]);if(p+=v,v!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return r((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var v=0;v<m.length;v++)this.words[v]=this.words[v]&p.words[v];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return r((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,v;this.length>p.length?(m=this,v=p):(m=p,v=this);for(var I=0;I<v.length;I++)this.words[I]=m.words[I]^v.words[I];if(this!==m)for(;I<m.length;I++)this.words[I]=m.words[I];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return r((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){r(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,v=p%26;this._expand(m),v>0&&m--;for(var I=0;I<m;I++)this.words[I]=~this.words[I]&67108863;return v>0&&(this.words[I]=~this.words[I]&67108863>>26-v),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){r(typeof p=="number"&&p>=0);var v=p/26|0,I=p%26;return this._expand(v+1),m?this.words[v]=this.words[v]|1<<I:this.words[v]=this.words[v]&~(1<<I),this._strip()},s.prototype.iadd=function(p){var m;if(this.negative!==0&&p.negative===0)return this.negative=0,m=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,m=this.isub(p),p.negative=1,m._normSign();var v,I;this.length>p.length?(v=this,I=p):(v=p,I=this);for(var N=0,M=0;M<I.length;M++)m=(v.words[M]|0)+(I.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;for(;N!==0&&M<v.length;M++)m=(v.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;if(this.length=v.length,N!==0)this.words[this.length]=N,this.length++;else if(v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var v=this.cmp(p);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var I,N;v>0?(I=this,N=p):(I=p,N=this);for(var M=0,z=0;z<N.length;z++)m=(I.words[z]|0)-(N.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;for(;M!==0&&z<I.length;z++)m=(I.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;if(M===0&&z<I.length&&I!==this)for(;z<I.length;z++)this.words[z]=I.words[z];return this.length=Math.max(this.length,z),I!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function B(C,p,m){m.negative=p.negative^C.negative;var v=C.length+p.length|0;m.length=v,v=v-1|0;var I=C.words[0]|0,N=p.words[0]|0,M=I*N,z=M&67108863,P=M/67108864|0;m.words[0]=z;for(var _=1;_<v;_++){for(var F=P>>>26,ct=P&67108863,dt=Math.min(_,p.length-1),mt=Math.max(0,_-C.length+1);mt<=dt;mt++){var Gt=_-mt|0;I=C.words[Gt]|0,N=p.words[mt]|0,M=I*N+ct,F+=M/67108864|0,ct=M&67108863}m.words[_]=ct|0,P=F|0}return P!==0?m.words[_]=P|0:m.length--,m._strip()}var H=function(p,m,v){var I=p.words,N=m.words,M=v.words,z=0,P,_,F,ct=I[0]|0,dt=ct&8191,mt=ct>>>13,Gt=I[1]|0,Ut=Gt&8191,Lt=Gt>>>13,xe=I[2]|0,Kt=xe&8191,Ft=xe>>>13,ke=I[3]|0,re=ke&8191,oe=ke>>>13,rn=I[4]|0,fe=rn&8191,Ue=rn>>>13,ea=I[5]|0,Re=ea&8191,Ce=ea>>>13,In=I[6]|0,he=In&8191,Se=In>>>13,sn=I[7]|0,Ee=sn&8191,Be=sn>>>13,cr=I[8]|0,De=cr&8191,O=cr>>>13,w=I[9]|0,E=w&8191,D=w>>>13,V=N[0]|0,q=V&8191,st=V>>>13,qt=N[1]|0,Wt=qt&8191,jt=qt>>>13,Fe=N[2]|0,Ht=Fe&8191,ln=Fe>>>13,Ip=N[3]|0,fn=Ip&8191,hn=Ip>>>13,kp=N[4]|0,on=kp&8191,dn=kp>>>13,Tp=N[5]|0,an=Tp&8191,pn=Tp>>>13,vc=N[6]|0,Ye=vc&8191,gn=vc>>>13,Op=N[7]|0,yn=Op&8191,mn=Op>>>13,Np=N[8]|0,wn=Np&8191,bn=Np>>>13,xc=N[9]|0,_n=xc&8191,An=xc>>>13;v.negative=p.negative^m.negative,v.length=19,P=Math.imul(dt,q),_=Math.imul(dt,st),_=_+Math.imul(mt,q)|0,F=Math.imul(mt,st);var Oh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Oh>>>26)|0,Oh&=67108863,P=Math.imul(Ut,q),_=Math.imul(Ut,st),_=_+Math.imul(Lt,q)|0,F=Math.imul(Lt,st),P=P+Math.imul(dt,Wt)|0,_=_+Math.imul(dt,jt)|0,_=_+Math.imul(mt,Wt)|0,F=F+Math.imul(mt,jt)|0;var Nl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Nl>>>26)|0,Nl&=67108863,P=Math.imul(Kt,q),_=Math.imul(Kt,st),_=_+Math.imul(Ft,q)|0,F=Math.imul(Ft,st),P=P+Math.imul(Ut,Wt)|0,_=_+Math.imul(Ut,jt)|0,_=_+Math.imul(Lt,Wt)|0,F=F+Math.imul(Lt,jt)|0,P=P+Math.imul(dt,Ht)|0,_=_+Math.imul(dt,ln)|0,_=_+Math.imul(mt,Ht)|0,F=F+Math.imul(mt,ln)|0;var Nh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Nh>>>26)|0,Nh&=67108863,P=Math.imul(re,q),_=Math.imul(re,st),_=_+Math.imul(oe,q)|0,F=Math.imul(oe,st),P=P+Math.imul(Kt,Wt)|0,_=_+Math.imul(Kt,jt)|0,_=_+Math.imul(Ft,Wt)|0,F=F+Math.imul(Ft,jt)|0,P=P+Math.imul(Ut,Ht)|0,_=_+Math.imul(Ut,ln)|0,_=_+Math.imul(Lt,Ht)|0,F=F+Math.imul(Lt,ln)|0,P=P+Math.imul(dt,fn)|0,_=_+Math.imul(dt,hn)|0,_=_+Math.imul(mt,fn)|0,F=F+Math.imul(mt,hn)|0;var Ch=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Ch>>>26)|0,Ch&=67108863,P=Math.imul(fe,q),_=Math.imul(fe,st),_=_+Math.imul(Ue,q)|0,F=Math.imul(Ue,st),P=P+Math.imul(re,Wt)|0,_=_+Math.imul(re,jt)|0,_=_+Math.imul(oe,Wt)|0,F=F+Math.imul(oe,jt)|0,P=P+Math.imul(Kt,Ht)|0,_=_+Math.imul(Kt,ln)|0,_=_+Math.imul(Ft,Ht)|0,F=F+Math.imul(Ft,ln)|0,P=P+Math.imul(Ut,fn)|0,_=_+Math.imul(Ut,hn)|0,_=_+Math.imul(Lt,fn)|0,F=F+Math.imul(Lt,hn)|0,P=P+Math.imul(dt,on)|0,_=_+Math.imul(dt,dn)|0,_=_+Math.imul(mt,on)|0,F=F+Math.imul(mt,dn)|0;var Bh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Bh>>>26)|0,Bh&=67108863,P=Math.imul(Re,q),_=Math.imul(Re,st),_=_+Math.imul(Ce,q)|0,F=Math.imul(Ce,st),P=P+Math.imul(fe,Wt)|0,_=_+Math.imul(fe,jt)|0,_=_+Math.imul(Ue,Wt)|0,F=F+Math.imul(Ue,jt)|0,P=P+Math.imul(re,Ht)|0,_=_+Math.imul(re,ln)|0,_=_+Math.imul(oe,Ht)|0,F=F+Math.imul(oe,ln)|0,P=P+Math.imul(Kt,fn)|0,_=_+Math.imul(Kt,hn)|0,_=_+Math.imul(Ft,fn)|0,F=F+Math.imul(Ft,hn)|0,P=P+Math.imul(Ut,on)|0,_=_+Math.imul(Ut,dn)|0,_=_+Math.imul(Lt,on)|0,F=F+Math.imul(Lt,dn)|0,P=P+Math.imul(dt,an)|0,_=_+Math.imul(dt,pn)|0,_=_+Math.imul(mt,an)|0,F=F+Math.imul(mt,pn)|0;var Ph=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Ph>>>26)|0,Ph&=67108863,P=Math.imul(he,q),_=Math.imul(he,st),_=_+Math.imul(Se,q)|0,F=Math.imul(Se,st),P=P+Math.imul(Re,Wt)|0,_=_+Math.imul(Re,jt)|0,_=_+Math.imul(Ce,Wt)|0,F=F+Math.imul(Ce,jt)|0,P=P+Math.imul(fe,Ht)|0,_=_+Math.imul(fe,ln)|0,_=_+Math.imul(Ue,Ht)|0,F=F+Math.imul(Ue,ln)|0,P=P+Math.imul(re,fn)|0,_=_+Math.imul(re,hn)|0,_=_+Math.imul(oe,fn)|0,F=F+Math.imul(oe,hn)|0,P=P+Math.imul(Kt,on)|0,_=_+Math.imul(Kt,dn)|0,_=_+Math.imul(Ft,on)|0,F=F+Math.imul(Ft,dn)|0,P=P+Math.imul(Ut,an)|0,_=_+Math.imul(Ut,pn)|0,_=_+Math.imul(Lt,an)|0,F=F+Math.imul(Lt,pn)|0,P=P+Math.imul(dt,Ye)|0,_=_+Math.imul(dt,gn)|0,_=_+Math.imul(mt,Ye)|0,F=F+Math.imul(mt,gn)|0;var Cl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Cl>>>26)|0,Cl&=67108863,P=Math.imul(Ee,q),_=Math.imul(Ee,st),_=_+Math.imul(Be,q)|0,F=Math.imul(Be,st),P=P+Math.imul(he,Wt)|0,_=_+Math.imul(he,jt)|0,_=_+Math.imul(Se,Wt)|0,F=F+Math.imul(Se,jt)|0,P=P+Math.imul(Re,Ht)|0,_=_+Math.imul(Re,ln)|0,_=_+Math.imul(Ce,Ht)|0,F=F+Math.imul(Ce,ln)|0,P=P+Math.imul(fe,fn)|0,_=_+Math.imul(fe,hn)|0,_=_+Math.imul(Ue,fn)|0,F=F+Math.imul(Ue,hn)|0,P=P+Math.imul(re,on)|0,_=_+Math.imul(re,dn)|0,_=_+Math.imul(oe,on)|0,F=F+Math.imul(oe,dn)|0,P=P+Math.imul(Kt,an)|0,_=_+Math.imul(Kt,pn)|0,_=_+Math.imul(Ft,an)|0,F=F+Math.imul(Ft,pn)|0,P=P+Math.imul(Ut,Ye)|0,_=_+Math.imul(Ut,gn)|0,_=_+Math.imul(Lt,Ye)|0,F=F+Math.imul(Lt,gn)|0,P=P+Math.imul(dt,yn)|0,_=_+Math.imul(dt,mn)|0,_=_+Math.imul(mt,yn)|0,F=F+Math.imul(mt,mn)|0;var Mh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Mh>>>26)|0,Mh&=67108863,P=Math.imul(De,q),_=Math.imul(De,st),_=_+Math.imul(O,q)|0,F=Math.imul(O,st),P=P+Math.imul(Ee,Wt)|0,_=_+Math.imul(Ee,jt)|0,_=_+Math.imul(Be,Wt)|0,F=F+Math.imul(Be,jt)|0,P=P+Math.imul(he,Ht)|0,_=_+Math.imul(he,ln)|0,_=_+Math.imul(Se,Ht)|0,F=F+Math.imul(Se,ln)|0,P=P+Math.imul(Re,fn)|0,_=_+Math.imul(Re,hn)|0,_=_+Math.imul(Ce,fn)|0,F=F+Math.imul(Ce,hn)|0,P=P+Math.imul(fe,on)|0,_=_+Math.imul(fe,dn)|0,_=_+Math.imul(Ue,on)|0,F=F+Math.imul(Ue,dn)|0,P=P+Math.imul(re,an)|0,_=_+Math.imul(re,pn)|0,_=_+Math.imul(oe,an)|0,F=F+Math.imul(oe,pn)|0,P=P+Math.imul(Kt,Ye)|0,_=_+Math.imul(Kt,gn)|0,_=_+Math.imul(Ft,Ye)|0,F=F+Math.imul(Ft,gn)|0,P=P+Math.imul(Ut,yn)|0,_=_+Math.imul(Ut,mn)|0,_=_+Math.imul(Lt,yn)|0,F=F+Math.imul(Lt,mn)|0,P=P+Math.imul(dt,wn)|0,_=_+Math.imul(dt,bn)|0,_=_+Math.imul(mt,wn)|0,F=F+Math.imul(mt,bn)|0;var Xs=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Xs>>>26)|0,Xs&=67108863,P=Math.imul(E,q),_=Math.imul(E,st),_=_+Math.imul(D,q)|0,F=Math.imul(D,st),P=P+Math.imul(De,Wt)|0,_=_+Math.imul(De,jt)|0,_=_+Math.imul(O,Wt)|0,F=F+Math.imul(O,jt)|0,P=P+Math.imul(Ee,Ht)|0,_=_+Math.imul(Ee,ln)|0,_=_+Math.imul(Be,Ht)|0,F=F+Math.imul(Be,ln)|0,P=P+Math.imul(he,fn)|0,_=_+Math.imul(he,hn)|0,_=_+Math.imul(Se,fn)|0,F=F+Math.imul(Se,hn)|0,P=P+Math.imul(Re,on)|0,_=_+Math.imul(Re,dn)|0,_=_+Math.imul(Ce,on)|0,F=F+Math.imul(Ce,dn)|0,P=P+Math.imul(fe,an)|0,_=_+Math.imul(fe,pn)|0,_=_+Math.imul(Ue,an)|0,F=F+Math.imul(Ue,pn)|0,P=P+Math.imul(re,Ye)|0,_=_+Math.imul(re,gn)|0,_=_+Math.imul(oe,Ye)|0,F=F+Math.imul(oe,gn)|0,P=P+Math.imul(Kt,yn)|0,_=_+Math.imul(Kt,mn)|0,_=_+Math.imul(Ft,yn)|0,F=F+Math.imul(Ft,mn)|0,P=P+Math.imul(Ut,wn)|0,_=_+Math.imul(Ut,bn)|0,_=_+Math.imul(Lt,wn)|0,F=F+Math.imul(Lt,bn)|0,P=P+Math.imul(dt,_n)|0,_=_+Math.imul(dt,An)|0,_=_+Math.imul(mt,_n)|0,F=F+Math.imul(mt,An)|0;var Lh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Lh>>>26)|0,Lh&=67108863,P=Math.imul(E,Wt),_=Math.imul(E,jt),_=_+Math.imul(D,Wt)|0,F=Math.imul(D,jt),P=P+Math.imul(De,Ht)|0,_=_+Math.imul(De,ln)|0,_=_+Math.imul(O,Ht)|0,F=F+Math.imul(O,ln)|0,P=P+Math.imul(Ee,fn)|0,_=_+Math.imul(Ee,hn)|0,_=_+Math.imul(Be,fn)|0,F=F+Math.imul(Be,hn)|0,P=P+Math.imul(he,on)|0,_=_+Math.imul(he,dn)|0,_=_+Math.imul(Se,on)|0,F=F+Math.imul(Se,dn)|0,P=P+Math.imul(Re,an)|0,_=_+Math.imul(Re,pn)|0,_=_+Math.imul(Ce,an)|0,F=F+Math.imul(Ce,pn)|0,P=P+Math.imul(fe,Ye)|0,_=_+Math.imul(fe,gn)|0,_=_+Math.imul(Ue,Ye)|0,F=F+Math.imul(Ue,gn)|0,P=P+Math.imul(re,yn)|0,_=_+Math.imul(re,mn)|0,_=_+Math.imul(oe,yn)|0,F=F+Math.imul(oe,mn)|0,P=P+Math.imul(Kt,wn)|0,_=_+Math.imul(Kt,bn)|0,_=_+Math.imul(Ft,wn)|0,F=F+Math.imul(Ft,bn)|0,P=P+Math.imul(Ut,_n)|0,_=_+Math.imul(Ut,An)|0,_=_+Math.imul(Lt,_n)|0,F=F+Math.imul(Lt,An)|0;var Ti=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Ti>>>26)|0,Ti&=67108863,P=Math.imul(E,Ht),_=Math.imul(E,ln),_=_+Math.imul(D,Ht)|0,F=Math.imul(D,ln),P=P+Math.imul(De,fn)|0,_=_+Math.imul(De,hn)|0,_=_+Math.imul(O,fn)|0,F=F+Math.imul(O,hn)|0,P=P+Math.imul(Ee,on)|0,_=_+Math.imul(Ee,dn)|0,_=_+Math.imul(Be,on)|0,F=F+Math.imul(Be,dn)|0,P=P+Math.imul(he,an)|0,_=_+Math.imul(he,pn)|0,_=_+Math.imul(Se,an)|0,F=F+Math.imul(Se,pn)|0,P=P+Math.imul(Re,Ye)|0,_=_+Math.imul(Re,gn)|0,_=_+Math.imul(Ce,Ye)|0,F=F+Math.imul(Ce,gn)|0,P=P+Math.imul(fe,yn)|0,_=_+Math.imul(fe,mn)|0,_=_+Math.imul(Ue,yn)|0,F=F+Math.imul(Ue,mn)|0,P=P+Math.imul(re,wn)|0,_=_+Math.imul(re,bn)|0,_=_+Math.imul(oe,wn)|0,F=F+Math.imul(oe,bn)|0,P=P+Math.imul(Kt,_n)|0,_=_+Math.imul(Kt,An)|0,_=_+Math.imul(Ft,_n)|0,F=F+Math.imul(Ft,An)|0;var Uh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Uh>>>26)|0,Uh&=67108863,P=Math.imul(E,fn),_=Math.imul(E,hn),_=_+Math.imul(D,fn)|0,F=Math.imul(D,hn),P=P+Math.imul(De,on)|0,_=_+Math.imul(De,dn)|0,_=_+Math.imul(O,on)|0,F=F+Math.imul(O,dn)|0,P=P+Math.imul(Ee,an)|0,_=_+Math.imul(Ee,pn)|0,_=_+Math.imul(Be,an)|0,F=F+Math.imul(Be,pn)|0,P=P+Math.imul(he,Ye)|0,_=_+Math.imul(he,gn)|0,_=_+Math.imul(Se,Ye)|0,F=F+Math.imul(Se,gn)|0,P=P+Math.imul(Re,yn)|0,_=_+Math.imul(Re,mn)|0,_=_+Math.imul(Ce,yn)|0,F=F+Math.imul(Ce,mn)|0,P=P+Math.imul(fe,wn)|0,_=_+Math.imul(fe,bn)|0,_=_+Math.imul(Ue,wn)|0,F=F+Math.imul(Ue,bn)|0,P=P+Math.imul(re,_n)|0,_=_+Math.imul(re,An)|0,_=_+Math.imul(oe,_n)|0,F=F+Math.imul(oe,An)|0;var Dh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Dh>>>26)|0,Dh&=67108863,P=Math.imul(E,on),_=Math.imul(E,dn),_=_+Math.imul(D,on)|0,F=Math.imul(D,dn),P=P+Math.imul(De,an)|0,_=_+Math.imul(De,pn)|0,_=_+Math.imul(O,an)|0,F=F+Math.imul(O,pn)|0,P=P+Math.imul(Ee,Ye)|0,_=_+Math.imul(Ee,gn)|0,_=_+Math.imul(Be,Ye)|0,F=F+Math.imul(Be,gn)|0,P=P+Math.imul(he,yn)|0,_=_+Math.imul(he,mn)|0,_=_+Math.imul(Se,yn)|0,F=F+Math.imul(Se,mn)|0,P=P+Math.imul(Re,wn)|0,_=_+Math.imul(Re,bn)|0,_=_+Math.imul(Ce,wn)|0,F=F+Math.imul(Ce,bn)|0,P=P+Math.imul(fe,_n)|0,_=_+Math.imul(fe,An)|0,_=_+Math.imul(Ue,_n)|0,F=F+Math.imul(Ue,An)|0;var Bl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Bl>>>26)|0,Bl&=67108863,P=Math.imul(E,an),_=Math.imul(E,pn),_=_+Math.imul(D,an)|0,F=Math.imul(D,pn),P=P+Math.imul(De,Ye)|0,_=_+Math.imul(De,gn)|0,_=_+Math.imul(O,Ye)|0,F=F+Math.imul(O,gn)|0,P=P+Math.imul(Ee,yn)|0,_=_+Math.imul(Ee,mn)|0,_=_+Math.imul(Be,yn)|0,F=F+Math.imul(Be,mn)|0,P=P+Math.imul(he,wn)|0,_=_+Math.imul(he,bn)|0,_=_+Math.imul(Se,wn)|0,F=F+Math.imul(Se,bn)|0,P=P+Math.imul(Re,_n)|0,_=_+Math.imul(Re,An)|0,_=_+Math.imul(Ce,_n)|0,F=F+Math.imul(Ce,An)|0;var Fh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Fh>>>26)|0,Fh&=67108863,P=Math.imul(E,Ye),_=Math.imul(E,gn),_=_+Math.imul(D,Ye)|0,F=Math.imul(D,gn),P=P+Math.imul(De,yn)|0,_=_+Math.imul(De,mn)|0,_=_+Math.imul(O,yn)|0,F=F+Math.imul(O,mn)|0,P=P+Math.imul(Ee,wn)|0,_=_+Math.imul(Ee,bn)|0,_=_+Math.imul(Be,wn)|0,F=F+Math.imul(Be,bn)|0,P=P+Math.imul(he,_n)|0,_=_+Math.imul(he,An)|0,_=_+Math.imul(Se,_n)|0,F=F+Math.imul(Se,An)|0;var $h=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+($h>>>26)|0,$h&=67108863,P=Math.imul(E,yn),_=Math.imul(E,mn),_=_+Math.imul(D,yn)|0,F=Math.imul(D,mn),P=P+Math.imul(De,wn)|0,_=_+Math.imul(De,bn)|0,_=_+Math.imul(O,wn)|0,F=F+Math.imul(O,bn)|0,P=P+Math.imul(Ee,_n)|0,_=_+Math.imul(Ee,An)|0,_=_+Math.imul(Be,_n)|0,F=F+Math.imul(Be,An)|0;var Hh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Hh>>>26)|0,Hh&=67108863,P=Math.imul(E,wn),_=Math.imul(E,bn),_=_+Math.imul(D,wn)|0,F=Math.imul(D,bn),P=P+Math.imul(De,_n)|0,_=_+Math.imul(De,An)|0,_=_+Math.imul(O,_n)|0,F=F+Math.imul(O,An)|0;var zh=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(zh>>>26)|0,zh&=67108863,P=Math.imul(E,_n),_=Math.imul(E,An),_=_+Math.imul(D,_n)|0,F=Math.imul(D,An);var na=(z+P|0)+((_&8191)<<13)|0;return z=(F+(_>>>13)|0)+(na>>>26)|0,na&=67108863,M[0]=Oh,M[1]=Nl,M[2]=Nh,M[3]=Ch,M[4]=Bh,M[5]=Ph,M[6]=Cl,M[7]=Mh,M[8]=Xs,M[9]=Lh,M[10]=Ti,M[11]=Uh,M[12]=Dh,M[13]=Bl,M[14]=Fh,M[15]=$h,M[16]=Hh,M[17]=zh,M[18]=na,z!==0&&(M[19]=z,v.length++),v};Math.imul||(H=B);function U(C,p,m){m.negative=p.negative^C.negative,m.length=C.length+p.length;for(var v=0,I=0,N=0;N<m.length-1;N++){var M=I;I=0;for(var z=v&67108863,P=Math.min(N,p.length-1),_=Math.max(0,N-C.length+1);_<=P;_++){var F=N-_,ct=C.words[F]|0,dt=p.words[_]|0,mt=ct*dt,Gt=mt&67108863;M=M+(mt/67108864|0)|0,Gt=Gt+z|0,z=Gt&67108863,M=M+(Gt>>>26)|0,I+=M>>>26,M&=67108863}m.words[N]=z,v=M,M=I}return v!==0?m.words[N]=v:m.length--,m._strip()}function G(C,p,m){return U(C,p,m)}s.prototype.mulTo=function(p,m){var v,I=this.length+p.length;return this.length===10&&p.length===10?v=H(this,p,m):I<63?v=B(this,p,m):I<1024?v=U(this,p,m):v=G(this,p,m),v},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),G(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),r(typeof p=="number"),r(p<67108864);for(var v=0,I=0;I<this.length;I++){var N=(this.words[I]|0)*p,M=(N&67108863)+(v&67108863);v>>=26,v+=N/67108864|0,v+=M>>>26,this.words[I]=M&67108863}return v!==0&&(this.words[I]=v,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=S(p);if(m.length===0)return new s(1);for(var v=this,I=0;I<m.length&&m[I]===0;I++,v=v.sqr());if(++I<m.length)for(var N=v.sqr();I<m.length;I++,N=N.sqr())m[I]!==0&&(v=v.mul(N));return v},s.prototype.iushln=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,I=67108863>>>26-m<<26-m,N;if(m!==0){var M=0;for(N=0;N<this.length;N++){var z=this.words[N]&I,P=(this.words[N]|0)-z<<m;this.words[N]=P|M,M=z>>>26-m}M&&(this.words[N]=M,this.length++)}if(v!==0){for(N=this.length-1;N>=0;N--)this.words[N+v]=this.words[N];for(N=0;N<v;N++)this.words[N]=0;this.length+=v}return this._strip()},s.prototype.ishln=function(p){return r(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,v){r(typeof p=="number"&&p>=0);var I;m?I=(m-m%26)/26:I=0;var N=p%26,M=Math.min((p-N)/26,this.length),z=67108863^67108863>>>N<<N,P=v;if(I-=M,I=Math.max(0,I),P){for(var _=0;_<M;_++)P.words[_]=this.words[_];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,_=0;_<this.length;_++)this.words[_]=this.words[_+M];else this.words[0]=0,this.length=1;var F=0;for(_=this.length-1;_>=0&&(F!==0||_>=I);_--){var ct=this.words[_]|0;this.words[_]=F<<26-N|ct>>>N,F=ct&z}return P&&F!==0&&(P.words[P.length++]=F),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,v){return r(this.negative===0),this.iushrn(p,m,v)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,I=1<<m;if(this.length<=v)return!1;var N=this.words[v];return!!(N&I)},s.prototype.imaskn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(m!==0&&v++,this.length=Math.min(v,this.length),m!==0){var I=67108863^67108863>>>m<<m;this.words[this.length-1]&=I}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return r(typeof p=="number"),r(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(r(typeof p=="number"),r(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,v){var I=p.length+v,N;this._expand(I);var M,z=0;for(N=0;N<p.length;N++){M=(this.words[N+v]|0)+z;var P=(p.words[N]|0)*m;M-=P&67108863,z=(M>>26)-(P/67108864|0),this.words[N+v]=M&67108863}for(;N<this.length-v;N++)M=(this.words[N+v]|0)+z,z=M>>26,this.words[N+v]=M&67108863;if(z===0)return this._strip();for(r(z===-1),z=0,N=0;N<this.length;N++)M=-(this.words[N]|0)+z,z=M>>26,this.words[N]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var v=this.length-p.length,I=this.clone(),N=p,M=N.words[N.length-1]|0,z=this._countBits(M);v=26-z,v!==0&&(N=N.ushln(v),I.iushln(v),M=N.words[N.length-1]|0);var P=I.length-N.length,_;if(m!=="mod"){_=new s(null),_.length=P+1,_.words=new Array(_.length);for(var F=0;F<_.length;F++)_.words[F]=0}var ct=I.clone()._ishlnsubmul(N,1,P);ct.negative===0&&(I=ct,_&&(_.words[P]=1));for(var dt=P-1;dt>=0;dt--){var mt=(I.words[N.length+dt]|0)*67108864+(I.words[N.length+dt-1]|0);for(mt=Math.min(mt/M|0,67108863),I._ishlnsubmul(N,mt,dt);I.negative!==0;)mt--,I.negative=0,I._ishlnsubmul(N,1,dt),I.isZero()||(I.negative^=1);_&&(_.words[dt]=mt)}return _&&_._strip(),I._strip(),m!=="div"&&v!==0&&I.iushrn(v),{div:_||null,mod:I}},s.prototype.divmod=function(p,m,v){if(r(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var I,N,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(I=M.div.neg()),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.iadd(p)),{div:I,mod:N}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(I=M.div.neg()),{div:I,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.isub(p)),{div:M.div,mod:N}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var v=m.div.negative!==0?m.mod.isub(p):m.mod,I=p.ushrn(1),N=p.andln(1),M=v.cmp(I);return M<0||N===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=(1<<26)%p,I=0,N=this.length-1;N>=0;N--)I=(v*I+(this.words[N]|0))%p;return m?-I:I},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=0,I=this.length-1;I>=0;I--){var N=(this.words[I]|0)+v*67108864;this.words[I]=N/p|0,v=N%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var I=new s(1),N=new s(0),M=new s(0),z=new s(1),P=0;m.isEven()&&v.isEven();)m.iushrn(1),v.iushrn(1),++P;for(var _=v.clone(),F=m.clone();!m.isZero();){for(var ct=0,dt=1;!(m.words[0]&dt)&&ct<26;++ct,dt<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(I.isOdd()||N.isOdd())&&(I.iadd(_),N.isub(F)),I.iushrn(1),N.iushrn(1);for(var mt=0,Gt=1;!(v.words[0]&Gt)&&mt<26;++mt,Gt<<=1);if(mt>0)for(v.iushrn(mt);mt-- >0;)(M.isOdd()||z.isOdd())&&(M.iadd(_),z.isub(F)),M.iushrn(1),z.iushrn(1);m.cmp(v)>=0?(m.isub(v),I.isub(M),N.isub(z)):(v.isub(m),M.isub(I),z.isub(N))}return{a:M,b:z,gcd:v.iushln(P)}},s.prototype._invmp=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var I=new s(1),N=new s(0),M=v.clone();m.cmpn(1)>0&&v.cmpn(1)>0;){for(var z=0,P=1;!(m.words[0]&P)&&z<26;++z,P<<=1);if(z>0)for(m.iushrn(z);z-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);for(var _=0,F=1;!(v.words[0]&F)&&_<26;++_,F<<=1);if(_>0)for(v.iushrn(_);_-- >0;)N.isOdd()&&N.iadd(M),N.iushrn(1);m.cmp(v)>=0?(m.isub(v),I.isub(N)):(v.isub(m),N.isub(I))}var ct;return m.cmpn(1)===0?ct=I:ct=N,ct.cmpn(0)<0&&ct.iadd(p),ct},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),v=p.clone();m.negative=0,v.negative=0;for(var I=0;m.isEven()&&v.isEven();I++)m.iushrn(1),v.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;v.isEven();)v.iushrn(1);var N=m.cmp(v);if(N<0){var M=m;m=v,v=M}else if(N===0||v.cmpn(1)===0)break;m.isub(v)}while(!0);return v.iushln(I)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){r(typeof p=="number");var m=p%26,v=(p-m)/26,I=1<<m;if(this.length<=v)return this._expand(v+1),this.words[v]|=I,this;for(var N=I,M=v;N!==0&&M<this.length;M++){var z=this.words[M]|0;z+=N,N=z>>>26,z&=67108863,this.words[M]=z}return N!==0&&(this.words[M]=N,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var v;if(this.length>1)v=1;else{m&&(p=-p),r(p<=67108863,"Number is too big");var I=this.words[0]|0;v=I===p?0:I<p?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,v=this.length-1;v>=0;v--){var I=this.words[v]|0,N=p.words[v]|0;if(I!==N){I<N?m=-1:I>N&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new rt(p)},s.prototype.toRed=function(p){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return r(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return r(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var W={k256:null,p224:null,p192:null,p25519:null};function J(C,p){this.name=C,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},J.prototype.ireduce=function(p){var m=p,v;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),v=m.bitLength();while(v>this.n);var I=v<this.n?-1:m.ucmp(this.p);return I===0?(m.words[0]=0,m.length=1):I>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},J.prototype.split=function(p,m){p.iushrn(this.n,0,m)},J.prototype.imulK=function(p){return p.imul(this.k)};function j(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,J),j.prototype.split=function(p,m){for(var v=4194303,I=Math.min(p.length,9),N=0;N<I;N++)m.words[N]=p.words[N];if(m.length=I,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&v,N=10;N<p.length;N++){var z=p.words[N]|0;p.words[N-10]=(z&v)<<4|M>>>22,M=z}M>>>=22,p.words[N-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},j.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,v=0;v<p.length;v++){var I=p.words[v]|0;m+=I*977,p.words[v]=m&67108863,m=I*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function Y(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(Y,J);function it(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(it,J);function ut(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ut,J),ut.prototype.imulK=function(p){for(var m=0,v=0;v<p.length;v++){var I=(p.words[v]|0)*19+m,N=I&67108863;I>>>=26,p.words[v]=N,m=I}return m!==0&&(p.words[p.length++]=m),p},s._prime=function(p){if(W[p])return W[p];var m;if(p==="k256")m=new j;else if(p==="p224")m=new Y;else if(p==="p192")m=new it;else if(p==="p25519")m=new ut;else throw new Error("Unknown prime "+p);return W[p]=m,m};function rt(C){if(typeof C=="string"){var p=s._prime(C);this.m=p.p,this.prime=p}else r(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}rt.prototype._verify1=function(p){r(p.negative===0,"red works only with positives"),r(p.red,"red works only with red numbers")},rt.prototype._verify2=function(p,m){r((p.negative|m.negative)===0,"red works only with positives"),r(p.red&&p.red===m.red,"red works only with red numbers")},rt.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},rt.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},rt.prototype.add=function(p,m){this._verify2(p,m);var v=p.add(m);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},rt.prototype.iadd=function(p,m){this._verify2(p,m);var v=p.iadd(m);return v.cmp(this.m)>=0&&v.isub(this.m),v},rt.prototype.sub=function(p,m){this._verify2(p,m);var v=p.sub(m);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},rt.prototype.isub=function(p,m){this._verify2(p,m);var v=p.isub(m);return v.cmpn(0)<0&&v.iadd(this.m),v},rt.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},rt.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},rt.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},rt.prototype.isqr=function(p){return this.imul(p,p.clone())},rt.prototype.sqr=function(p){return this.mul(p,p)},rt.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(r(m%2===1),m===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(p,v)}for(var I=this.m.subn(1),N=0;!I.isZero()&&I.andln(1)===0;)N++,I.iushrn(1);r(!I.isZero());var M=new s(1).toRed(this),z=M.redNeg(),P=this.m.subn(1).iushrn(1),_=this.m.bitLength();for(_=new s(2*_*_).toRed(this);this.pow(_,P).cmp(z)!==0;)_.redIAdd(z);for(var F=this.pow(_,I),ct=this.pow(p,I.addn(1).iushrn(1)),dt=this.pow(p,I),mt=N;dt.cmp(M)!==0;){for(var Gt=dt,Ut=0;Gt.cmp(M)!==0;Ut++)Gt=Gt.redSqr();r(Ut<mt);var Lt=this.pow(F,new s(1).iushln(mt-Ut-1));ct=ct.redMul(Lt),F=Lt.redSqr(),dt=dt.redMul(F),mt=Ut}return ct},rt.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},rt.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var v=4,I=new Array(1<<v);I[0]=new s(1).toRed(this),I[1]=p;for(var N=2;N<I.length;N++)I[N]=this.mul(I[N-1],p);var M=I[0],z=0,P=0,_=m.bitLength()%26;for(_===0&&(_=26),N=m.length-1;N>=0;N--){for(var F=m.words[N],ct=_-1;ct>=0;ct--){var dt=F>>ct&1;if(M!==I[0]&&(M=this.sqr(M)),dt===0&&z===0){P=0;continue}z<<=1,z|=dt,P++,!(P!==v&&(N!==0||ct!==0))&&(M=this.mul(M,I[z]),P=0,z=0)}_=26}return M},rt.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},rt.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ot(p)};function ot(C){rt.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ot,rt),ot.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ot.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ot.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var v=p.imul(m),I=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(I).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var v=p.mul(m),I=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(I).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(n,ae)}(wg);var _g=wg.exports;const ys=Br(_g);function Id(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function B5(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function of(n,...t){if(!B5(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error("Uint8Array expected of length "+t+", got length="+n.length)}function P5(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Id(n.outputLen),Id(n.blockLen)}function Gc(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function m_(n,t){of(n);const e=t.outputLen;if(n.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}const Vc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function M5(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}function Ag(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Mi(n,t){return n<<32-t|n>>>t}const w_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function L5(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function b_(n){for(let t=0;t<n.length;t++)n[t]=L5(n[t])}function U5(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function kd(n){return typeof n=="string"&&(n=U5(n)),of(n),n}function D5(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];of(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}let Eg=class{clone(){return this._cloneInto()}};function vg(n){const t=r=>n().update(kd(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function __(n=32){if(Vc&&typeof Vc.getRandomValues=="function")return Vc.getRandomValues(new Uint8Array(n));if(Vc&&typeof Vc.randomBytes=="function")return Vc.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}function F5(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,c,r)}function $5(n,t,e){return n&t^~n&e}function H5(n,t,e){return n&t^n&e^t&e}class A_ extends Eg{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ag(this.buffer)}update(t){Gc(this);const{view:e,buffer:r,blockLen:i}=this;t=kd(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(i-this.pos,s-o);if(c===i){const u=Ag(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Gc(this),m_(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;F5(r,i-8,BigInt(this.length*8),s),this.process(r,0);const c=Ag(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)c.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const Td=BigInt(2**32-1),xg=BigInt(32);function E_(n,t=!1){return t?{h:Number(n&Td),l:Number(n>>xg&Td)}:{h:Number(n>>xg&Td)|0,l:Number(n&Td)|0}}function v_(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=E_(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const z5=(n,t)=>BigInt(n>>>0)<<xg|BigInt(t>>>0),G5=(n,t,e)=>n>>>e,V5=(n,t,e)=>n<<32-e|t>>>e,K5=(n,t,e)=>n>>>e|t<<32-e,j5=(n,t,e)=>n<<32-e|t>>>e,W5=(n,t,e)=>n<<64-e|t>>>e-32,Z5=(n,t,e)=>n>>>e-32|t<<64-e,q5=(n,t)=>t,Q5=(n,t)=>n,x_=(n,t,e)=>n<<e|t>>>32-e,R_=(n,t,e)=>t<<e|n>>>32-e,S_=(n,t,e)=>t<<e-32|n>>>64-e,I_=(n,t,e)=>n<<e-32|t>>>64-e;function Y5(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const Xt={fromBig:E_,split:v_,toBig:z5,shrSH:G5,shrSL:V5,rotrSH:K5,rotrSL:j5,rotrBH:W5,rotrBL:Z5,rotr32H:q5,rotr32L:Q5,rotlSH:x_,rotlSL:R_,rotlBH:S_,rotlBL:I_,add:Y5,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,add5H:(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,add5L:(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)},[J5,X5]=Xt.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))),oo=new Uint32Array(80),ao=new Uint32Array(80);let t4=class extends A_{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:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:f,El:h,Fh:y,Fl:A,Gh:b,Gl:R,Hh:k,Hl:S}=this;return[t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S]}set(t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=A|0,this.Gh=b|0,this.Gl=R|0,this.Hh=k|0,this.Hl=S|0}process(t,e){for(let U=0;U<16;U++,e+=4)oo[U]=t.getUint32(e),ao[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=oo[U-15]|0,W=ao[U-15]|0,J=Xt.rotrSH(G,W,1)^Xt.rotrSH(G,W,8)^Xt.shrSH(G,W,7),j=Xt.rotrSL(G,W,1)^Xt.rotrSL(G,W,8)^Xt.shrSL(G,W,7),Y=oo[U-2]|0,it=ao[U-2]|0,ut=Xt.rotrSH(Y,it,19)^Xt.rotrBH(Y,it,61)^Xt.shrSH(Y,it,6),rt=Xt.rotrSL(Y,it,19)^Xt.rotrBL(Y,it,61)^Xt.shrSL(Y,it,6),ot=Xt.add4L(j,rt,ao[U-7],ao[U-16]),C=Xt.add4H(ot,J,ut,oo[U-7],oo[U-16]);oo[U]=C|0,ao[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:f,Dl:h,Eh:y,El:A,Fh:b,Fl:R,Gh:k,Gl:S,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=Xt.rotrSH(y,A,14)^Xt.rotrSH(y,A,18)^Xt.rotrBH(y,A,41),W=Xt.rotrSL(y,A,14)^Xt.rotrSL(y,A,18)^Xt.rotrBL(y,A,41),J=y&b^~y&k,j=A&R^~A&S,Y=Xt.add5L(H,W,j,X5[U],ao[U]),it=Xt.add5H(Y,B,G,J,J5[U],oo[U]),ut=Y|0,rt=Xt.rotrSH(r,i,28)^Xt.rotrBH(r,i,34)^Xt.rotrBH(r,i,39),ot=Xt.rotrSL(r,i,28)^Xt.rotrBL(r,i,34)^Xt.rotrBL(r,i,39),C=r&s^r&c^s&c,p=i&o^i&u^o&u;B=k|0,H=S|0,k=b|0,S=R|0,b=y|0,R=A|0,{h:y,l:A}=Xt.add(f|0,h|0,it|0,ut|0),f=c|0,h=u|0,c=s|0,u=o|0,s=r|0,o=i|0;const m=Xt.add3L(ut,ot,p);r=Xt.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=Xt.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Xt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=Xt.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:f,l:h}=Xt.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:A}=Xt.add(this.Eh|0,this.El|0,y|0,A|0),{h:b,l:R}=Xt.add(this.Fh|0,this.Fl|0,b|0,R|0),{h:k,l:S}=Xt.add(this.Gh|0,this.Gl|0,k|0,S|0),{h:B,l:H}=Xt.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H)}roundClean(){oo.fill(0),ao.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 e4=vg(()=>new t4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Od=BigInt(0),Nd=BigInt(1),n4=BigInt(2);function la(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function af(n){if(!la(n))throw new Error("Uint8Array expected")}function ms(n,t){if(typeof t!="boolean")throw new Error(n+" boolean expected, got "+t)}const r4=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function fa(n){af(n);let t="";for(let e=0;e<n.length;e++)t+=r4[n[e]];return t}function Kc(n){const t=n.toString(16);return t.length&1?"0"+t:t}function Rg(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?Od:BigInt("0x"+n)}const ws={_0:48,_9:57,A:65,F:70,a:97,f:102};function k_(n){if(n>=ws._0&&n<=ws._9)return n-ws._0;if(n>=ws.A&&n<=ws.F)return n-(ws.A-10);if(n>=ws.a&&n<=ws.f)return n-(ws.a-10)}function jc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){const o=k_(n.charCodeAt(s)),c=k_(n.charCodeAt(s+1));if(o===void 0||c===void 0){const u=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}r[i]=o*16+c}return r}function ha(n){return Rg(fa(n))}function Wc(n){return af(n),Rg(fa(Uint8Array.from(n).reverse()))}function Zc(n,t){return jc(n.toString(16).padStart(t*2,"0"))}function cf(n,t){return Zc(n,t).reverse()}function i4(n){return jc(Kc(n))}function kn(n,t,e){let r;if(typeof t=="string")try{r=jc(t)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(la(t))r=Uint8Array.from(t);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(n+" of length "+e+" expected, got "+i);return r}function da(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];af(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}function s4(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function o4(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}const Sg=n=>typeof n=="bigint"&&Od<=n;function Cd(n,t,e){return Sg(n)&&Sg(t)&&Sg(e)&&t<=n&&n<e}function Qr(n,t,e,r){if(!Cd(t,e,r))throw new Error("expected valid "+n+": "+e+" <= n < "+r+", got "+t)}function T_(n){let t;for(t=0;n>Od;n>>=Nd,t+=1);return t}function a4(n,t){return n>>BigInt(t)&Nd}function c4(n,t,e){return n|(e?Nd:Od)<<BigInt(t)}const Ig=n=>(n4<<BigInt(n-1))-Nd,kg=n=>new Uint8Array(n),O_=n=>Uint8Array.from(n);function N_(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=kg(n),i=kg(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},c=(...y)=>e(i,r,...y),u=(y=kg())=>{i=c(O_([0]),y),r=c(),y.length!==0&&(i=c(O_([1]),y),r=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const A=[];for(;y<t;){r=c();const b=r.slice();A.push(b),y+=r.length}return da(...A)};return(y,A)=>{o(),u(y);let b;for(;!(b=A(f()));)u();return o(),b}}const u4={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"||la(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function qc(n,t,e={}){const r=(i,s,o)=>{const c=u4[s];if(typeof c!="function")throw new Error("invalid validator function");const u=n[i];if(!(o&&u===void 0)&&!c(u,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const l4=()=>{throw new Error("not implemented")};function uf(n){const t=new WeakMap;return(e,...r)=>{const i=t.get(e);if(i!==void 0)return i;const s=n(e,...r);return t.set(e,s),s}}const f4=Object.freeze(Object.defineProperty({__proto__:null,aInRange:Qr,abool:ms,abytes:af,bitGet:a4,bitLen:T_,bitMask:Ig,bitSet:c4,bytesToHex:fa,bytesToNumberBE:ha,bytesToNumberLE:Wc,concatBytes:da,createHmacDrbg:N_,ensureBytes:kn,equalBytes:s4,hexToBytes:jc,hexToNumber:Rg,inRange:Cd,isBytes:la,memoized:uf,notImplemented:l4,numberToBytesBE:Zc,numberToBytesLE:cf,numberToHexUnpadded:Kc,numberToVarBytesBE:i4,utf8ToBytes:o4,validateObject:qc},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bn=BigInt(0),Xe=BigInt(1),pa=BigInt(2),h4=BigInt(3),Tg=BigInt(4),C_=BigInt(5),B_=BigInt(8);function Ze(n,t){const e=n%t;return e>=Bn?e:t+e}function d4(n,t,e){if(t<Bn)throw new Error("invalid exponent, negatives unsupported");if(e<=Bn)throw new Error("invalid modulus");if(e===Xe)return Bn;let r=Xe;for(;t>Bn;)t&Xe&&(r=r*n%e),n=n*n%e,t>>=Xe;return r}function cn(n,t,e){let r=n;for(;t-- >Bn;)r*=r,r%=e;return r}function Og(n,t){if(n===Bn)throw new Error("invert: expected non-zero number");if(t<=Bn)throw new Error("invert: expected positive modulus, got "+t);let e=Ze(n,t),r=t,i=Bn,s=Xe;for(;e!==Bn;){const c=r/e,u=r%e,f=i-s*c;r=e,e=u,i=s,s=f}if(r!==Xe)throw new Error("invert: does not exist");return Ze(i,t)}function p4(n){const t=(n-Xe)/pa;let e,r,i;for(e=n-Xe,r=0;e%pa===Bn;e/=pa,r++);for(i=pa;i<n&&d4(i,t,n)!==n-Xe;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(n+Xe)/Tg;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+Xe)/pa;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=r,h=c.pow(c.mul(c.ONE,i),e),y=c.pow(u,s),A=c.pow(u,e);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let b=1;for(let k=c.sqr(A);b<f&&!c.eql(k,c.ONE);b++)k=c.sqr(k);const R=c.pow(h,Xe<<BigInt(f-b-1));h=c.sqr(R),y=c.mul(y,R),A=c.mul(A,h),f=b}return y}}function g4(n){if(n%Tg===h4){const t=(n+Xe)/Tg;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%B_===C_){const t=(n-C_)/B_;return function(r,i){const s=r.mul(i,pa),o=r.pow(s,t),c=r.mul(i,o),u=r.mul(r.mul(c,pa),o),f=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return p4(n)}const y4=(n,t)=>(Ze(n,t)&Xe)===Xe,m4=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function w4(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=m4.reduce((r,i)=>(r[i]="function",r),t);return qc(n,e)}function b4(n,t,e){if(e<Bn)throw new Error("invalid exponent, negatives unsupported");if(e===Bn)return n.ONE;if(e===Xe)return t;let r=n.ONE,i=t;for(;e>Bn;)e&Xe&&(r=n.mul(r,i)),i=n.sqr(i),e>>=Xe;return r}function _4(n,t){const e=new Array(t.length),r=t.reduce((s,o,c)=>n.is0(o)?s:(e[c]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,c)=>n.is0(o)?s:(e[c]=n.mul(s,e[c]),n.mul(s,o)),i),e}function P_(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Bd(n,t,e=!1,r={}){if(n<=Bn)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=P_(n,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const c=Object.freeze({ORDER:n,isLE:e,BITS:i,BYTES:s,MASK:Ig(i),ZERO:Bn,ONE:Xe,create:u=>Ze(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Bn<=u&&u<n},is0:u=>u===Bn,isOdd:u=>(u&Xe)===Xe,neg:u=>Ze(-u,n),eql:(u,f)=>u===f,sqr:u=>Ze(u*u,n),add:(u,f)=>Ze(u+f,n),sub:(u,f)=>Ze(u-f,n),mul:(u,f)=>Ze(u*f,n),pow:(u,f)=>b4(c,u,f),div:(u,f)=>Ze(u*Og(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Og(u,n),sqrt:r.sqrt||(u=>(o||(o=g4(n)),o(c,u))),invertBatch:u=>_4(c,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?cf(u,s):Zc(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return e?Wc(u):ha(u)}});return Object.freeze(c)}function M_(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function L_(n){const t=M_(n);return t+Math.ceil(t/2)}function A4(n,t,e=!1){const r=n.length,i=M_(t),s=L_(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=e?Wc(n):ha(n),c=Ze(o,t-Xe)+Xe;return e?cf(c,i):Zc(c,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const U_=BigInt(0),Pd=BigInt(1);function Ng(n,t){const e=t.negate();return n?e:t}function D_(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function Cg(n,t){D_(n,t);const e=Math.ceil(t/n)+1,r=2**(n-1);return{windows:e,windowSize:r}}function E4(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function v4(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const Bg=new WeakMap,F_=new WeakMap;function Pg(n){return F_.get(n)||1}function $_(n,t){return{constTimeNegate:Ng,hasPrecomputes(e){return Pg(e)!==1},unsafeLadder(e,r,i=n.ZERO){let s=e;for(;r>U_;)r&Pd&&(i=i.add(s)),s=s.double(),r>>=Pd;return i},precomputeWindow(e,r){const{windows:i,windowSize:s}=Cg(r,t),o=[];let c=e,u=c;for(let f=0;f<i;f++){u=c,o.push(u);for(let h=1;h<s;h++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(e,r,i){const{windows:s,windowSize:o}=Cg(e,t);let c=n.ZERO,u=n.BASE;const f=BigInt(2**e-1),h=2**e,y=BigInt(e);for(let A=0;A<s;A++){const b=A*o;let R=Number(i&f);i>>=y,R>o&&(R-=h,i+=Pd);const k=b,S=b+Math.abs(R)-1,B=A%2!==0,H=R<0;R===0?u=u.add(Ng(B,r[k])):c=c.add(Ng(H,r[S]))}return{p:c,f:u}},wNAFUnsafe(e,r,i,s=n.ZERO){const{windows:o,windowSize:c}=Cg(e,t),u=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let y=0;y<o;y++){const A=y*c;if(i===U_)break;let b=Number(i&u);if(i>>=h,b>c&&(b-=f,i+=Pd),b===0)continue;let R=r[A+Math.abs(b)-1];b<0&&(R=R.negate()),s=s.add(R)}return s},getPrecomputes(e,r,i){let s=Bg.get(r);return s||(s=this.precomputeWindow(r,e),e!==1&&Bg.set(r,i(s))),s},wNAFCached(e,r,i){const s=Pg(e);return this.wNAF(s,this.getPrecomputes(s,e,i),r)},wNAFCachedUnsafe(e,r,i,s){const o=Pg(e);return o===1?this.unsafeLadder(e,r,s):this.wNAFUnsafe(o,this.getPrecomputes(o,e,i),r,s)},setWindowSize(e,r){D_(r,t),F_.set(e,r),Bg.delete(e)}}}function H_(n,t,e,r){if(E4(e,n),v4(r,t),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=n.ZERO,s=T_(BigInt(e.length)),o=s>12?s-3:s>4?s-2:s?2:1,c=(1<<o)-1,u=new Array(c+1).fill(i),f=Math.floor((t.BITS-1)/o)*o;let h=i;for(let y=f;y>=0;y-=o){u.fill(i);for(let b=0;b<r.length;b++){const R=r[b],k=Number(R>>BigInt(y)&BigInt(c));u[k]=u[k].add(e[b])}let A=i;for(let b=u.length-1,R=i;b>0;b--)R=R.add(u[b]),A=A.add(R);if(h=h.add(A),y!==0)for(let b=0;b<o;b++)h=h.double()}return h}function Mg(n){return w4(n.Fp),qc(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...P_(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const di=BigInt(0),Ar=BigInt(1),Md=BigInt(2),x4=BigInt(8),R4={zip215:!0};function S4(n){const t=Mg(n);return qc(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function I4(n){const t=S4(n),{Fp:e,n:r,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,f=Md<<BigInt(c*8)-Ar,h=e.create,y=Bd(t.n,t.nBitLength),A=t.uvRatio||((v,I)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(I))}}catch{return{isValid:!1,value:di}}}),b=t.adjustScalarBytes||(v=>v),R=t.domain||((v,I,N)=>{if(ms("phflag",N),I.length||N)throw new Error("Contexts/pre-hash are not supported");return v});function k(v,I){Qr("coordinate "+v,I,di,f)}function S(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const B=uf((v,I)=>{const{ex:N,ey:M,ez:z}=v,P=v.is0();I==null&&(I=P?x4:e.inv(z));const _=h(N*I),F=h(M*I),ct=h(z*I);if(P)return{x:di,y:Ar};if(ct!==Ar)throw new Error("invZ was invalid");return{x:_,y:F}}),H=uf(v=>{const{a:I,d:N}=t;if(v.is0())throw new Error("bad point: ZERO");const{ex:M,ey:z,ez:P,et:_}=v,F=h(M*M),ct=h(z*z),dt=h(P*P),mt=h(dt*dt),Gt=h(F*I),Ut=h(dt*h(Gt+ct)),Lt=h(mt+h(N*h(F*ct)));if(Ut!==Lt)throw new Error("bad point: equation left != right (1)");const xe=h(M*z),Kt=h(P*_);if(xe!==Kt)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(I,N,M,z){this.ex=I,this.ey=N,this.ez=M,this.et=z,k("x",I),k("y",N),k("z",M),k("t",z),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof U)throw new Error("extended point not allowed");const{x:N,y:M}=I||{};return k("x",N),k("y",M),new U(N,M,Ar,h(N*M))}static normalizeZ(I){const N=e.invertBatch(I.map(M=>M.ez));return I.map((M,z)=>M.toAffine(N[z])).map(U.fromAffine)}static msm(I,N){return H_(U,y,I,N)}_setWindowSize(I){J.setWindowSize(this,I)}assertValidity(){H(this)}equals(I){S(I);const{ex:N,ey:M,ez:z}=this,{ex:P,ey:_,ez:F}=I,ct=h(N*F),dt=h(P*z),mt=h(M*F),Gt=h(_*z);return ct===dt&&mt===Gt}is0(){return this.equals(U.ZERO)}negate(){return new U(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:I}=t,{ex:N,ey:M,ez:z}=this,P=h(N*N),_=h(M*M),F=h(Md*h(z*z)),ct=h(I*P),dt=N+M,mt=h(h(dt*dt)-P-_),Gt=ct+_,Ut=Gt-F,Lt=ct-_,xe=h(mt*Ut),Kt=h(Gt*Lt),Ft=h(mt*Lt),ke=h(Ut*Gt);return new U(xe,Kt,ke,Ft)}add(I){S(I);const{a:N,d:M}=t,{ex:z,ey:P,ez:_,et:F}=this,{ex:ct,ey:dt,ez:mt,et:Gt}=I;if(N===BigInt(-1)){const Re=h((P-z)*(dt+ct)),Ce=h((P+z)*(dt-ct)),In=h(Ce-Re);if(In===di)return this.double();const he=h(_*Md*Gt),Se=h(F*Md*mt),sn=Se+he,Ee=Ce+Re,Be=Se-he,cr=h(sn*In),De=h(Ee*Be),O=h(sn*Be),w=h(In*Ee);return new U(cr,De,w,O)}const Ut=h(z*ct),Lt=h(P*dt),xe=h(F*M*Gt),Kt=h(_*mt),Ft=h((z+P)*(ct+dt)-Ut-Lt),ke=Kt-xe,re=Kt+xe,oe=h(Lt-N*Ut),rn=h(Ft*ke),fe=h(re*oe),Ue=h(Ft*oe),ea=h(ke*re);return new U(rn,fe,ea,Ue)}subtract(I){return this.add(I.negate())}wNAF(I){return J.wNAFCached(this,I,U.normalizeZ)}multiply(I){const N=I;Qr("scalar",N,Ar,r);const{p:M,f:z}=this.wNAF(N);return U.normalizeZ([M,z])[0]}multiplyUnsafe(I,N=U.ZERO){const M=I;return Qr("scalar",M,di,r),M===di?W:this.is0()||M===Ar?this:J.wNAFCachedUnsafe(this,M,U.normalizeZ,N)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return J.unsafeLadder(this,r).is0()}toAffine(I){return B(this,I)}clearCofactor(){const{h:I}=t;return I===Ar?this:this.multiplyUnsafe(I)}static fromHex(I,N=!1){const{d:M,a:z}=t,P=e.BYTES;I=kn("pointHex",I,P),ms("zip215",N);const _=I.slice(),F=I[P-1];_[P-1]=F&-129;const ct=Wc(_),dt=N?f:e.ORDER;Qr("pointHex.y",ct,di,dt);const mt=h(ct*ct),Gt=h(mt-Ar),Ut=h(M*mt-z);let{isValid:Lt,value:xe}=A(Gt,Ut);if(!Lt)throw new Error("Point.fromHex: invalid y coordinate");const Kt=(xe&Ar)===Ar,Ft=(F&128)!==0;if(!N&&xe===di&&Ft)throw new Error("Point.fromHex: x=0 and x_0=1");return Ft!==Kt&&(xe=h(-xe)),U.fromAffine({x:xe,y:ct})}static fromPrivateKey(I){return it(I).point}toRawBytes(){const{x:I,y:N}=this.toAffine(),M=cf(N,e.BYTES);return M[M.length-1]|=I&Ar?128:0,M}toHex(){return fa(this.toRawBytes())}}U.BASE=new U(t.Gx,t.Gy,Ar,h(t.Gx*t.Gy)),U.ZERO=new U(di,Ar,Ar,di);const{BASE:G,ZERO:W}=U,J=$_(U,c*8);function j(v){return Ze(v,r)}function Y(v){return j(Wc(v))}function it(v){const I=e.BYTES;v=kn("private key",v,I);const N=kn("hashed private key",s(v),2*I),M=b(N.slice(0,I)),z=N.slice(I,2*I),P=Y(M),_=G.multiply(P),F=_.toRawBytes();return{head:M,prefix:z,scalar:P,point:_,pointBytes:F}}function ut(v){return it(v).pointBytes}function rt(v=new Uint8Array,...I){const N=da(...I);return Y(s(R(N,kn("context",v),!!i)))}function ot(v,I,N={}){v=kn("message",v),i&&(v=i(v));const{prefix:M,scalar:z,pointBytes:P}=it(I),_=rt(N.context,M,v),F=G.multiply(_).toRawBytes(),ct=rt(N.context,F,P,v),dt=j(_+ct*z);Qr("signature.s",dt,di,r);const mt=da(F,cf(dt,e.BYTES));return kn("result",mt,e.BYTES*2)}const C=R4;function p(v,I,N,M=C){const{context:z,zip215:P}=M,_=e.BYTES;v=kn("signature",v,2*_),I=kn("message",I),N=kn("publicKey",N,_),P!==void 0&&ms("zip215",P),i&&(I=i(I));const F=Wc(v.slice(_,2*_));let ct,dt,mt;try{ct=U.fromHex(N,P),dt=U.fromHex(v.slice(0,_),P),mt=G.multiplyUnsafe(F)}catch{return!1}if(!P&&ct.isSmallOrder())return!1;const Gt=rt(z,dt.toRawBytes(),ct.toRawBytes(),I);return dt.add(ct.multiplyUnsafe(Gt)).subtract(mt).clearCofactor().equals(U.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:ut,sign:ot,verify:p,ExtendedPoint:U,utils:{getExtendedPublicKey:it,randomPrivateKey:()=>o(e.BYTES),precompute(v=8,I=U.BASE){return I._setWindowSize(v),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Lg=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),z_=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const k4=BigInt(1),G_=BigInt(2);BigInt(3);const T4=BigInt(5),O4=BigInt(8);function N4(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),i=BigInt(80),s=Lg,c=n*n%s*n%s,u=cn(c,G_,s)*c%s,f=cn(u,k4,s)*n%s,h=cn(f,T4,s)*f%s,y=cn(h,t,s)*h%s,A=cn(y,e,s)*y%s,b=cn(A,r,s)*A%s,R=cn(b,i,s)*b%s,k=cn(R,i,s)*b%s,S=cn(k,t,s)*h%s;return{pow_p_5_8:cn(S,G_,s)*n%s,b2:c}}function C4(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function B4(n,t){const e=Lg,r=Ze(t*t*t,e),i=Ze(r*r*t,e),s=N4(n*i).pow_p_5_8;let o=Ze(n*r*s,e);const c=Ze(t*o*o,e),u=o,f=Ze(o*z_,e),h=c===n,y=c===Ze(-n,e),A=c===Ze(-n*z_,e);return h&&(o=u),(y||A)&&(o=f),y4(o,e)&&(o=Ze(-o,e)),{isValid:h||y,value:o}}const P4=Bd(Lg,void 0,!0),M4={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:P4,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:O4,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:e4,randomBytes:__,adjustScalarBytes:C4,uvRatio:B4},Qc=I4(M4);var Ug={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=bg,r=e.Buffer;function i(o,c){for(var u in o)c[u]=o[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(i(e,t),t.Buffer=s);function s(o,c,u){return r(o,c,u)}s.prototype=Object.create(r.prototype),i(r,s),s.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,c,u)},s.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=r(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(Ug,Ug.exports);var L4=Ug.exports,Ld=L4.Buffer;function U4(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=r}var o=n.length,c=n.charAt(0),u=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function h(b){if((Array.isArray(b)||b instanceof Uint8Array)&&(b=Ld.from(b)),!Ld.isBuffer(b))throw new TypeError("Expected Buffer");if(b.length===0)return"";for(var R=0,k=0,S=0,B=b.length;S!==B&&b[S]===0;)S++,R++;for(var H=(B-S)*f+1>>>0,U=new Uint8Array(H);S!==B;){for(var G=b[S],W=0,J=H-1;(G!==0||W<k)&&J!==-1;J--,W++)G+=256*U[J]>>>0,U[J]=G%o>>>0,G=G/o>>>0;if(G!==0)throw new Error("Non-zero carry");k=W,S++}for(var j=H-k;j!==H&&U[j]===0;)j++;for(var Y=c.repeat(R);j<H;++j)Y+=n.charAt(U[j]);return Y}function y(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return Ld.alloc(0);for(var R=0,k=0,S=0;b[R]===c;)k++,R++;for(var B=(b.length-R)*u+1>>>0,H=new Uint8Array(B);R<b.length;){var U=b.charCodeAt(R);if(U>255)return;var G=t[U];if(G===255)return;for(var W=0,J=B-1;(G!==0||W<S)&&J!==-1;J--,W++)G+=o*H[J]>>>0,H[J]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");S=W,R++}for(var j=B-S;j!==B&&H[j]===0;)j++;var Y=Ld.allocUnsafe(k+(B-j));Y.fill(0,0,k);for(var it=k;j!==B;)Y[it++]=H[j++];return Y}function A(b){var R=y(b);if(R)return R;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:y,decode:A}}var D4=U4,F4=D4,$4="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",V_=F4($4);const Tn=Br(V_),H4=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]),co=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),uo=new Uint32Array(64);let z4=class extends A_{constructor(){super(64,32,8,!1),this.A=co[0]|0,this.B=co[1]|0,this.C=co[2]|0,this.D=co[3]|0,this.E=co[4]|0,this.F=co[5]|0,this.G=co[6]|0,this.H=co[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,r,i,s,o,c,u]}set(t,e,r,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)uo[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const A=uo[y-15],b=uo[y-2],R=Mi(A,7)^Mi(A,18)^A>>>3,k=Mi(b,17)^Mi(b,19)^b>>>10;uo[y]=k+uo[y-7]+R+uo[y-16]|0}let{A:r,B:i,C:s,D:o,E:c,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const A=Mi(c,6)^Mi(c,11)^Mi(c,25),b=h+A+$5(c,u,f)+H4[y]+uo[y]|0,k=(Mi(r,2)^Mi(r,13)^Mi(r,22))+H5(r,i,s)|0;h=f,f=u,u=c,c=o+b|0,o=s,s=i,i=r,r=b+k|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,c,u,f,h)}roundClean(){uo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Dg=vg(()=>new z4);var Gn={};function bs(n,t,e){return t<=n&&n<=e}function Ud(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function G4(n){for(var t=String(n),e=t.length,r=0,i=[];r<e;){var s=t.charCodeAt(r);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(r===e-1)i.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var c=s&1023,u=o&1023;i.push(65536+(c<<10)+u),r+=1}else i.push(65533)}r+=1}return i}function V4(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var Dd=-1;function Fg(n){this.tokens=[].slice.call(n)}Fg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Dd},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var Yc=-1;function $g(n,t){if(n)throw TypeError("Decoder error");return t||65533}var Fd="utf-8";function $d(n,t){if(!(this instanceof $d))return new $d(n,t);if(n=n!==void 0?String(n).toLowerCase():Fd,n!==Fd)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ud(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}$d.prototype={decode:function(t,e){var r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=Ud(e),this._streaming||(this._decoder=new K4({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var i=new Fg(r),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==Yc);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===Yc)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),V4(s)}};function Hd(n,t){if(!(this instanceof Hd))return new Hd(n,t);if(n=n!==void 0?String(n).toLowerCase():Fd,n!==Fd)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ud(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Hd.prototype={encode:function(t,e){t=t?String(t):"",e=Ud(e),this._streaming||(this._encoder=new j4(this._options)),this._streaming=!!e.stream;for(var r=[],i=new Fg(G4(t)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==Yc);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==Yc;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)}};function K4(n){var t=n.fatal,e=0,r=0,i=0,s=128,o=191;this.handler=function(c,u){if(u===Dd&&i!==0)return i=0,$g(t);if(u===Dd)return Yc;if(i===0){if(bs(u,0,127))return u;if(bs(u,194,223))i=1,e=u-192;else if(bs(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,e=u-224;else if(bs(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,e=u-240;else return $g(t);return e=e<<6*i,null}if(!bs(u,s,o))return e=i=r=0,s=128,o=191,c.prepend(u),$g(t);if(s=128,o=191,r+=1,e+=u-128<<6*(i-r),r!==i)return null;var f=e;return e=i=r=0,f}}function j4(n){n.fatal,this.handler=function(t,e){if(e===Dd)return Yc;if(bs(e,0,127))return e;var r,i;bs(e,128,2047)?(r=1,i=192):bs(e,2048,65535)?(r=2,i=224):bs(e,65536,1114111)&&(r=3,i=240);for(var s=[(e>>6*r)+i];r>0;){var o=e>>6*(r-1);s.push(128|o&63),r-=1}return s}}const W4=kc(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:$d,TextEncoder:Hd},Symbol.toStringTag,{value:"Module"})));var Z4=ae&&ae.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),q4=ae&&ae.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),Li=ae&&ae.__decorate||function(n,t,e,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},Q4=ae&&ae.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&Z4(t,n,e);return q4(t,n),t},K_=ae&&ae.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Gn,"__esModule",{value:!0});var j_=Gn.deserializeUnchecked=J_=Gn.deserialize=Y_=Gn.serialize=Gn.BinaryReader=Gn.BinaryWriter=Gn.BorshError=Gn.baseDecode=Gn.baseEncode=void 0;const lo=K_(_g),W_=K_(V_),Y4=Q4(W4),J4=typeof TextDecoder!="function"?Y4.TextDecoder:TextDecoder,X4=new J4("utf-8",{fatal:!0});function tP(n){return typeof n=="string"&&(n=Zt.from(n,"utf8")),W_.default.encode(Zt.from(n))}Gn.baseEncode=tP;function eP(n){return Zt.from(W_.default.decode(n))}Gn.baseDecode=eP;const Hg=1024;class fr extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Gn.BorshError=fr;class Z_{constructor(){this.buf=Zt.alloc(Hg),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Zt.concat([this.buf,Zt.alloc(Hg)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Zt.from(new lo.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Zt.from(new lo.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Zt.from(new lo.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Zt.from(new lo.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Zt.concat([Zt.from(this.buf.subarray(0,this.length)),t,Zt.alloc(Hg)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Zt.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Zt.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}Gn.BinaryWriter=Z_;function Ui(n,t,e){const r=e.value;e.value=function(...i){try{return r.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new fr("Reached the end of buffer when deserializing")}throw s}}}class Lr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new lo.default(t,"le")}readU128(){const t=this.readBuffer(16);return new lo.default(t,"le")}readU256(){const t=this.readBuffer(32);return new lo.default(t,"le")}readU512(){const t=this.readBuffer(64);return new lo.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new fr(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return X4.decode(e)}catch(r){throw new fr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let i=0;i<e;++i)r.push(t());return r}}Li([Ui],Lr.prototype,"readU8",null),Li([Ui],Lr.prototype,"readU16",null),Li([Ui],Lr.prototype,"readU32",null),Li([Ui],Lr.prototype,"readU64",null),Li([Ui],Lr.prototype,"readU128",null),Li([Ui],Lr.prototype,"readU256",null),Li([Ui],Lr.prototype,"readU512",null),Li([Ui],Lr.prototype,"readString",null),Li([Ui],Lr.prototype,"readFixedArray",null),Li([Ui],Lr.prototype,"readArray",null),Gn.BinaryReader=Lr;function q_(n){return n.charAt(0).toUpperCase()+n.slice(1)}function ga(n,t,e,r,i){try{if(typeof r=="string")i[`write${q_(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new fr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);i.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new fr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let s=0;s<r[1];s++)ga(n,null,e[s],r[0],i)}else i.writeArray(e,s=>{ga(n,t,s,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?i.writeU8(0):(i.writeU8(1),ga(n,t,e,r.type,i));break}case"map":{i.writeU32(e.size),e.forEach((s,o)=>{ga(n,t,o,r.key,i),ga(n,t,s,r.value,i)});break}default:throw new fr(`FieldType ${r} unrecognized`)}else Q_(n,e,i)}catch(s){throw s instanceof fr&&s.addToFieldPath(t),s}}function Q_(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new fr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([i,s])=>{ga(n,i,t[i],s,e)});else if(r.kind==="enum"){const i=t[r.field];for(let s=0;s<r.values.length;++s){const[o,c]=r.values[s];if(o===i){e.writeU8(s),ga(n,o,t[o],c,e);break}}}else throw new fr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function nP(n,t,e=Z_){const r=new e;return Q_(n,t,r),r.toArray()}var Y_=Gn.serialize=nP;function ya(n,t,e,r){try{if(typeof e=="string")return r[`read${q_(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const i=[];for(let s=0;s<e[1];s++)i.push(ya(n,null,e[0],r));return i}else return r.readArray(()=>ya(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?ya(n,t,e.type,r):void 0;if(e.kind==="map"){let i=new Map;const s=r.readU32();for(let o=0;o<s;o++){const c=ya(n,t,e.key,r),u=ya(n,t,e.value,r);i.set(c,u)}return i}return zg(n,e,r)}catch(i){throw i instanceof fr&&i.addToFieldPath(t),i}}function zg(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new fr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const i={};for(const[s,o]of n.get(t).fields)i[s]=ya(n,s,o,e);return new t(i)}if(r.kind==="enum"){const i=e.readU8();if(i>=r.values.length)throw new fr(`Enum index: ${i} is out of range`);const[s,o]=r.values[i],c=ya(n,s,o,e);return new t({[s]:c})}throw new fr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function rP(n,t,e,r=Lr){const i=new r(e),s=zg(n,t,i);if(i.offset<e.length)throw new fr(`Unexpected ${e.length-i.offset} bytes after deserialized data`);return s}var J_=Gn.deserialize=rP;function iP(n,t,e,r=Lr){const i=new r(e);return zg(n,t,i)}j_=Gn.deserializeUnchecked=iP;var et={};Object.defineProperty(et,"__esModule",{value:!0}),et.s16=et.s8=et.nu64be=et.u48be=et.u40be=et.u32be=et.u24be=et.u16be=Vn=et.nu64=et.u48=et.u40=Ot=et.u32=et.u24=Jr=et.u16=me=et.u8=fo=et.offset=et.greedy=et.Constant=et.UTF8=et.CString=et.Blob=et.Boolean=et.BitField=et.BitStructure=et.VariantLayout=et.Union=et.UnionLayoutDiscriminator=et.UnionDiscriminator=et.Structure=et.Sequence=et.DoubleBE=et.Double=et.FloatBE=et.Float=et.NearInt64BE=et.NearInt64=et.NearUInt64BE=et.NearUInt64=et.IntBE=et.Int=et.UIntBE=et.UInt=et.OffsetLayout=et.GreedyCount=et.ExternalLayout=et.bindConstructorLayout=et.nameWithProperty=et.Layout=et.uint8ArrayToBuffer=et.checkUint8Array=void 0,et.constant=et.utf8=et.cstr=je=et.blob=et.unionLayoutDiscriminator=et.union=Kn=et.seq=et.bits=Nt=et.struct=et.f64be=et.f64=et.f32be=et.f32=et.ns64be=et.s48be=et.s40be=et.s32be=et.s24be=et.s16be=Ur=et.ns64=et.s48=et.s40=et.s32=et.s24=void 0;const Gg=bg;function Jc(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}et.checkUint8Array=Jc;function be(n){return Jc(n),Gg.Buffer.from(n.buffer,n.byteOffset,n.length)}et.uint8ArrayToBuffer=be;let Te=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};et.Layout=Te;function Vg(n,t){return t.property?n+"["+t.property+"]":n}et.nameWithProperty=Vg;function sP(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Te))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}et.bindConstructorLayout=sP;let Er=class extends Te{isCount(){throw new Error("ExternalLayout is abstract")}};et.ExternalLayout=Er;let X_=class extends Er{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Jc(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}};et.GreedyCount=X_;let Kg=class extends Er{constructor(t,e=0,r){if(!(t instanceof Te))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Yr||this.layout instanceof pi}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}};et.OffsetLayout=Kg;let Yr=class extends Te{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntLE(t,r,this.span),this.span}};et.UInt=Yr;let pi=class extends Te{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntBE(t,r,this.span),this.span}};et.UIntBE=pi;let ma=class extends Te{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeIntLE(t,r,this.span),this.span}};et.Int=ma;let Xc=class extends Te{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeIntBE(t,r,this.span),this.span}};et.IntBE=Xc;const jg=Math.pow(2,32);function zd(n){const t=Math.floor(n/jg),e=n-t*jg;return{hi32:t,lo32:e}}function Gd(n,t){return n*jg+t}let tA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32LE(e),s=r.readUInt32LE(e+4);return Gd(s,i)}encode(t,e,r=0){const i=zd(t),s=be(e);return s.writeUInt32LE(i.lo32,r),s.writeUInt32LE(i.hi32,r+4),8}};et.NearUInt64=tA;let eA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32BE(e),s=r.readUInt32BE(e+4);return Gd(i,s)}encode(t,e,r=0){const i=zd(t),s=be(e);return s.writeUInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};et.NearUInt64BE=eA;let nA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32LE(e),s=r.readInt32LE(e+4);return Gd(s,i)}encode(t,e,r=0){const i=zd(t),s=be(e);return s.writeUInt32LE(i.lo32,r),s.writeInt32LE(i.hi32,r+4),8}};et.NearInt64=nA;let rA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readInt32BE(e),s=r.readUInt32BE(e+4);return Gd(i,s)}encode(t,e,r=0){const i=zd(t),s=be(e);return s.writeInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};et.NearInt64BE=rA;let iA=class extends Te{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatLE(e)}encode(t,e,r=0){return be(e).writeFloatLE(t,r),4}};et.Float=iA;let sA=class extends Te{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatBE(e)}encode(t,e,r=0){return be(e).writeFloatBE(t,r),4}};et.FloatBE=sA;let oA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleLE(e)}encode(t,e,r=0){return be(e).writeDoubleLE(t,r),8}};et.Double=oA;let aA=class extends Te{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleBE(e)}encode(t,e,r=0){return be(e).writeDoubleBE(t,r),8}};et.DoubleBE=aA;let cA=class extends Te{constructor(t,e,r){if(!(t instanceof Te))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Er&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Er)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,i=this.count;if(i instanceof Er&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e=0){const r=[];let i=0,s=this.count;for(s instanceof Er&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r=0){const i=this.elementLayout,s=t.reduce((o,c)=>o+i.encode(c,e,r+o),0);return this.count instanceof Er&&this.count.encode(t.length,e,r),s}};et.Sequence=cA;let uA=class extends Te{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Te,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){Jc(t);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}};et.Structure=uA;let Wg=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}};et.UnionDiscriminator=Wg;let Vd=class extends Wg{constructor(t,e){if(!(t instanceof Er&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}};et.UnionLayoutDiscriminator=Vd;let Zg=class extends Te{constructor(t,e,r){let i;if(t instanceof Yr||t instanceof pi)i=new Vd(new Kg(t));else if(t instanceof Er&&t.isCount())i=new Vd(t);else if(t instanceof Wg)i=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Te))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof Yr||t instanceof pi)&&(s+=i.layout.span)),super(s,r),this.discriminator=i,this.usesPrefixDiscriminator=t instanceof Yr||t instanceof pi,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const i=this.discriminator,s=i.decode(t,e),o=this.registry[s];if(o===void 0){const c=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[c.property]=c.decode(t,e+u)}else r=o.decode(t,e);return r}encode(t,e,r=0){const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new lA(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}};et.Union=Zg;let lA=class extends Te{constructor(t,e,r,i){if(!(t instanceof Zg))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Te))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(t,e+r)),r+i}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};et.VariantLayout=lA;function tu(n){return 0>n&&(n+=4294967296),n}let qg=class extends Te{constructor(t,e,r){if(!(t instanceof Yr||t instanceof pi))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=tu(s),this},this._packedGetValue=function(){return i}}decode(t,e=0){const r=this.makeDestinationObject(),i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(t));return r}encode(t,e,r=0){const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Qg(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new fA(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}};et.BitStructure=qg;let Qg=class{constructor(t,e,r){if(!(t instanceof qg))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,c)=>o+c.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=tu(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return tu(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==tu(t&this.valueMask))throw new TypeError(Vg("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=tu(t<<this.start);this.container._packedSetValue(tu(e&~this.wordMask)|r)}};et.BitField=Qg;let fA=class extends Qg{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};et.Boolean=fA;let hA=class extends Te{constructor(t,e){if(!(t instanceof Er&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Er||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),be(t).slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Er&&(i=t.length),!(t instanceof Uint8Array&&i===t.length))throw new TypeError(Vg("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(r+i>e.length)throw new RangeError("encoding overruns Uint8Array");const s=be(t);return be(e).write(s.toString("hex"),r,i,"hex"),this.length instanceof Er&&this.length.encode(i,e,r),i}};et.Blob=hA;let dA=class extends Te{constructor(t){super(-1,t)}getSpan(t,e=0){Jc(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return be(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=Gg.Buffer.from(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");const o=be(e);return i.copy(o,r),o[r+s]=0,s+1}};et.CString=dA;let pA=class extends Te{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Jc(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return be(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=Gg.Buffer.from(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(be(e),r),s}};et.UTF8=pA;let gA=class extends Te{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}};et.Constant=gA,et.greedy=(n,t)=>new X_(n,t);var fo=et.offset=(n,t,e)=>new Kg(n,t,e),me=et.u8=n=>new Yr(1,n),Jr=et.u16=n=>new Yr(2,n);et.u24=n=>new Yr(3,n);var Ot=et.u32=n=>new Yr(4,n);et.u40=n=>new Yr(5,n),et.u48=n=>new Yr(6,n);var Vn=et.nu64=n=>new tA(n);et.u16be=n=>new pi(2,n),et.u24be=n=>new pi(3,n),et.u32be=n=>new pi(4,n),et.u40be=n=>new pi(5,n),et.u48be=n=>new pi(6,n),et.nu64be=n=>new eA(n),et.s8=n=>new ma(1,n),et.s16=n=>new ma(2,n),et.s24=n=>new ma(3,n),et.s32=n=>new ma(4,n),et.s40=n=>new ma(5,n),et.s48=n=>new ma(6,n);var Ur=et.ns64=n=>new nA(n);et.s16be=n=>new Xc(2,n),et.s24be=n=>new Xc(3,n),et.s32be=n=>new Xc(4,n),et.s40be=n=>new Xc(5,n),et.s48be=n=>new Xc(6,n),et.ns64be=n=>new rA(n),et.f32=n=>new iA(n),et.f32be=n=>new sA(n),et.f64=n=>new oA(n),et.f64be=n=>new aA(n);var Nt=et.struct=(n,t,e)=>new uA(n,t,e);et.bits=(n,t,e)=>new qg(n,t,e);var Kn=et.seq=(n,t,e)=>new cA(n,t,e);et.union=(n,t,e)=>new Zg(n,t,e),et.unionLayoutDiscriminator=(n,t)=>new Vd(n,t);var je=et.blob=(n,t)=>new hA(n,t);et.cstr=n=>new dA(n),et.utf8=(n,t)=>new pA(n,t),et.constant=(n,t)=>new gA(n,t);var lf={};Object.defineProperty(lf,"__esModule",{value:!0});function oP(n){{const t=Zt.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var aP=lf.toBigIntLE=oP;function cP(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}lf.toBigIntBE=cP;function uP(n,t){{const e=n.toString(16),r=Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var yA=lf.toBufferLE=uP;function lP(n,t){{const e=n.toString(16);return Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}lf.toBufferBE=lP;let fP=class extends TypeError{constructor(t,e){let r;const{message:i,explanation:s,...o}=t,{path:c}=t,u=c.length===0?i:`At path: ${c.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}};function hP(n){return ff(n)&&typeof n[Symbol.iterator]=="function"}function ff(n){return typeof n=="object"&&n!=null}function Kd(n){return ff(n)&&!Array.isArray(n)}function gi(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function dP(n){const{done:t,value:e}=n.next();return t?void 0:e}function pP(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:c,message:u=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${gi(r)}\``}=n;return{value:r,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*mA(n,t,e,r){hP(n)||(n=[n]);for(const i of n){const s=pP(i,t,e,r);s&&(yield s)}}function*Yg(n,t,e={}){const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,c={path:r,branch:i,mask:o};s&&(n=t.coercer(n,c));let u="valid";for(const f of t.validator(n,c))f.explanation=e.message,u="not_valid",yield[f,void 0];for(let[f,h,y]of t.entries(n,c)){const A=Yg(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o,message:e.message});for(const b of A)b[0]?(u=b[0].refinement!=null?"not_refined":"not_valid",yield[b[0],void 0]):s&&(h=b[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):ff(n)&&(h!==void 0||f in n)&&(n[f]=h))}if(u!=="not_valid")for(const f of t.refiner(n,c))f.explanation=e.message,u="not_refined",yield[f,void 0];u==="valid"&&(yield[void 0,n])}let Di=class{constructor(t){const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=t;this.type=e,this.schema=r,this.entries=c,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return mA(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return mA(h,f,this,u)}:this.refiner=()=>[]}assert(t,e){return wA(t,this,e)}create(t,e){return wt(t,this,e)}is(t){return bA(t,this)}mask(t,e){return gP(t,this,e)}validate(t,e={}){return hf(t,this,e)}};function wA(n,t,e){const r=hf(n,t,{message:e});if(r[0])throw r[0]}function wt(n,t,e){const r=hf(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function gP(n,t,e){const r=hf(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function bA(n,t){return!hf(n,t)[0]}function hf(n,t,e={}){const r=Yg(n,t,e),i=dP(r);return i[0]?[new fP(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function wa(n,t){return new Di({type:n,schema:null,validator:t})}function yP(){return wa("any",()=>!0)}function Et(n){return new Di({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${gi(t)}`}})}function Fi(){return wa("boolean",n=>typeof n=="boolean")}function Jg(n){return wa("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${gi(t)}`)}function tn(n){const t=gi(n),e=typeof n;return new Di({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${gi(r)}`}})}function mP(){return wa("never",()=>!1)}function vt(n){return new Di({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function X(){return wa("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${gi(n)}`)}function Dt(n){return new Di({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function _A(n,t){return new Di({type:"record",schema:null,*entries(e){if(ff(e))for(const r in e){const i=e[r];yield[r,r,n],yield[r,i,t]}},validator(e){return Kd(e)||`Expected an object, but received: ${gi(e)}`},coercer(e){return Kd(e)?{...e}:e}})}function yt(){return wa("string",n=>typeof n=="string"||`Expected a string, but received: ${gi(n)}`)}function Xg(n){const t=mP();return new Di({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let i=0;i<r;i++)yield[i,e[i],n[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${gi(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ft(n){const t=Object.keys(n);return new Di({type:"type",schema:n,*entries(e){if(ff(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return Kd(e)||`Expected an object, but received: ${gi(e)}`},coercer(e){return Kd(e)?{...e}:e}})}function hr(n){const t=n.map(e=>e.type).join(" | ");return new Di({type:"union",schema:null,coercer(e,r){for(const i of n){const[s,o]=i.validate(e,{coerce:!0,mask:r.mask});if(!s)return o}return e},validator(e,r){const i=[];for(const s of n){const[...o]=Yg(e,s,r),[c]=o;if(c[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${gi(e)}`,...i]}})}function eu(){return wa("unknown",()=>!0)}function df(n,t,e){return new Di({...n,coercer:(r,i)=>bA(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}var jd,wP=new Uint8Array(16);function AA(){if(!jd&&(jd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!jd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jd(wP)}const bP=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Wd(n){return typeof n=="string"&&bP.test(n)}for(var jn=[],ty=0;ty<256;++ty)jn.push((ty+256).toString(16).substr(1));function Zd(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(jn[n[t+0]]+jn[n[t+1]]+jn[n[t+2]]+jn[n[t+3]]+"-"+jn[n[t+4]]+jn[n[t+5]]+"-"+jn[n[t+6]]+jn[n[t+7]]+"-"+jn[n[t+8]]+jn[n[t+9]]+"-"+jn[n[t+10]]+jn[n[t+11]]+jn[n[t+12]]+jn[n[t+13]]+jn[n[t+14]]+jn[n[t+15]]).toLowerCase();if(!Wd(e))throw TypeError("Stringified UUID is invalid");return e}var EA,ey,ny=0,ry=0;function _P(n,t,e){var r=t&&e||0,i=t||new Array(16);n=n||{};var s=n.node||EA,o=n.clockseq!==void 0?n.clockseq:ey;if(s==null||o==null){var c=n.random||(n.rng||AA)();s==null&&(s=EA=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=ey=(c[6]<<8|c[7])&16383)}var u=n.msecs!==void 0?n.msecs:Date.now(),f=n.nsecs!==void 0?n.nsecs:ry+1,h=u-ny+(f-ry)/1e4;if(h<0&&n.clockseq===void 0&&(o=o+1&16383),(h<0||u>ny)&&n.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ny=u,ry=f,ey=o,u+=122192928e5;var y=((u&268435455)*1e4+f)%4294967296;i[r++]=y>>>24&255,i[r++]=y>>>16&255,i[r++]=y>>>8&255,i[r++]=y&255;var A=u/4294967296*1e4&268435455;i[r++]=A>>>8&255,i[r++]=A&255,i[r++]=A>>>24&15|16,i[r++]=A>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var b=0;b<6;++b)i[r+b]=s[b];return t||Zd(i)}function vA(n){if(!Wd(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function AP(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var EP="6ba7b810-9dad-11d1-80b4-00c04fd430c8",vP="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function xA(n,t,e){function r(i,s,o,c){if(typeof i=="string"&&(i=AP(i)),typeof s=="string"&&(s=vA(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){c=c||0;for(var f=0;f<16;++f)o[c+f]=u[f];return o}return Zd(u)}try{r.name=n}catch{}return r.DNS=EP,r.URL=vP,r}function xP(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return RP(SP(IP(n),n.length*8))}function RP(n){for(var t=[],e=n.length*32,r="0123456789abcdef",i=0;i<e;i+=8){var s=n[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);t.push(o)}return t}function RA(n){return(n+64>>>9<<4)+14+1}function SP(n,t){n[t>>5]|=128<<t%32,n[RA(t)-1]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var c=e,u=r,f=i,h=s;e=tr(e,r,i,s,n[o],7,-680876936),s=tr(s,e,r,i,n[o+1],12,-389564586),i=tr(i,s,e,r,n[o+2],17,606105819),r=tr(r,i,s,e,n[o+3],22,-1044525330),e=tr(e,r,i,s,n[o+4],7,-176418897),s=tr(s,e,r,i,n[o+5],12,1200080426),i=tr(i,s,e,r,n[o+6],17,-1473231341),r=tr(r,i,s,e,n[o+7],22,-45705983),e=tr(e,r,i,s,n[o+8],7,1770035416),s=tr(s,e,r,i,n[o+9],12,-1958414417),i=tr(i,s,e,r,n[o+10],17,-42063),r=tr(r,i,s,e,n[o+11],22,-1990404162),e=tr(e,r,i,s,n[o+12],7,1804603682),s=tr(s,e,r,i,n[o+13],12,-40341101),i=tr(i,s,e,r,n[o+14],17,-1502002290),r=tr(r,i,s,e,n[o+15],22,1236535329),e=er(e,r,i,s,n[o+1],5,-165796510),s=er(s,e,r,i,n[o+6],9,-1069501632),i=er(i,s,e,r,n[o+11],14,643717713),r=er(r,i,s,e,n[o],20,-373897302),e=er(e,r,i,s,n[o+5],5,-701558691),s=er(s,e,r,i,n[o+10],9,38016083),i=er(i,s,e,r,n[o+15],14,-660478335),r=er(r,i,s,e,n[o+4],20,-405537848),e=er(e,r,i,s,n[o+9],5,568446438),s=er(s,e,r,i,n[o+14],9,-1019803690),i=er(i,s,e,r,n[o+3],14,-187363961),r=er(r,i,s,e,n[o+8],20,1163531501),e=er(e,r,i,s,n[o+13],5,-1444681467),s=er(s,e,r,i,n[o+2],9,-51403784),i=er(i,s,e,r,n[o+7],14,1735328473),r=er(r,i,s,e,n[o+12],20,-1926607734),e=nr(e,r,i,s,n[o+5],4,-378558),s=nr(s,e,r,i,n[o+8],11,-2022574463),i=nr(i,s,e,r,n[o+11],16,1839030562),r=nr(r,i,s,e,n[o+14],23,-35309556),e=nr(e,r,i,s,n[o+1],4,-1530992060),s=nr(s,e,r,i,n[o+4],11,1272893353),i=nr(i,s,e,r,n[o+7],16,-155497632),r=nr(r,i,s,e,n[o+10],23,-1094730640),e=nr(e,r,i,s,n[o+13],4,681279174),s=nr(s,e,r,i,n[o],11,-358537222),i=nr(i,s,e,r,n[o+3],16,-722521979),r=nr(r,i,s,e,n[o+6],23,76029189),e=nr(e,r,i,s,n[o+9],4,-640364487),s=nr(s,e,r,i,n[o+12],11,-421815835),i=nr(i,s,e,r,n[o+15],16,530742520),r=nr(r,i,s,e,n[o+2],23,-995338651),e=rr(e,r,i,s,n[o],6,-198630844),s=rr(s,e,r,i,n[o+7],10,1126891415),i=rr(i,s,e,r,n[o+14],15,-1416354905),r=rr(r,i,s,e,n[o+5],21,-57434055),e=rr(e,r,i,s,n[o+12],6,1700485571),s=rr(s,e,r,i,n[o+3],10,-1894986606),i=rr(i,s,e,r,n[o+10],15,-1051523),r=rr(r,i,s,e,n[o+1],21,-2054922799),e=rr(e,r,i,s,n[o+8],6,1873313359),s=rr(s,e,r,i,n[o+15],10,-30611744),i=rr(i,s,e,r,n[o+6],15,-1560198380),r=rr(r,i,s,e,n[o+13],21,1309151649),e=rr(e,r,i,s,n[o+4],6,-145523070),s=rr(s,e,r,i,n[o+11],10,-1120210379),i=rr(i,s,e,r,n[o+2],15,718787259),r=rr(r,i,s,e,n[o+9],21,-343485551),e=ho(e,c),r=ho(r,u),i=ho(i,f),s=ho(s,h)}return[e,r,i,s]}function IP(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(RA(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function ho(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function kP(n,t){return n<<t|n>>>32-t}function qd(n,t,e,r,i,s){return ho(kP(ho(ho(t,n),ho(r,s)),i),e)}function tr(n,t,e,r,i,s,o){return qd(t&e|~t&r,n,t,i,s,o)}function er(n,t,e,r,i,s,o){return qd(t&r|e&~r,n,t,i,s,o)}function nr(n,t,e,r,i,s,o){return qd(t^e^r,n,t,i,s,o)}function rr(n,t,e,r,i,s,o){return qd(e^(t|~r),n,t,i,s,o)}var TP=xA("v3",48,xP);function OP(n,t,e){n=n||{};var r=n.random||(n.rng||AA)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var i=0;i<16;++i)t[e+i]=r[i];return t}return Zd(r)}function NP(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function iy(n,t){return n<<t|n>>>32-t}function CP(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var i=0;i<r.length;++i)n.push(r.charCodeAt(i))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var s=n.length/4+2,o=Math.ceil(s/16),c=new Array(o),u=0;u<o;++u){for(var f=new Uint32Array(16),h=0;h<16;++h)f[h]=n[u*64+h*4]<<24|n[u*64+h*4+1]<<16|n[u*64+h*4+2]<<8|n[u*64+h*4+3];c[u]=f}c[o-1][14]=(n.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(n.length-1)*8&4294967295;for(var y=0;y<o;++y){for(var A=new Uint32Array(80),b=0;b<16;++b)A[b]=c[y][b];for(var R=16;R<80;++R)A[R]=iy(A[R-3]^A[R-8]^A[R-14]^A[R-16],1);for(var k=e[0],S=e[1],B=e[2],H=e[3],U=e[4],G=0;G<80;++G){var W=Math.floor(G/20),J=iy(k,5)+NP(W,S,B,H)+U+t[W]+A[G]>>>0;U=H,H=B,B=iy(S,30)>>>0,S=k,k=J}e[0]=e[0]+k>>>0,e[1]=e[1]+S>>>0,e[2]=e[2]+B>>>0,e[3]=e[3]+H>>>0,e[4]=e[4]+U>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var BP=xA("v5",80,CP);const PP="00000000-0000-0000-0000-000000000000";function MP(n){if(!Wd(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const SA=kc(Object.freeze(Object.defineProperty({__proto__:null,NIL:PP,parse:vA,stringify:Zd,v1:_P,v3:TP,v4:OP,v5:BP,validate:Wd,version:MP},Symbol.toStringTag,{value:"Module"}))),LP=SA.v4;var UP=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:n};if(i===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return LP()};s.id=o(s,r)}else i===2&&e===null?r.notificationIdNull&&(s.id=null):s.id=e;return s};const DP=SA.v4,FP=UP,pf=function(n,t){if(!(this instanceof pf))return new pf(n,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return DP()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var $P=pf;pf.prototype.request=function(n,t,e,r){const i=this;let s=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,s=n;else{typeof e=="function"&&(r=e,e=void 0);const f=typeof r=="function";try{s=FP(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(f)return r(h);throw h}if(!f)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(f){return r(f)}return this.callServer(u,function(f,h){i._parseResponse(f,h,r)}),s},pf.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(i){return e(i)}if(e.length===3)if(Array.isArray(r)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return e(null,r.filter(i),r.filter(s))}else return e(null,r.error,r.result);e(null,r)};const HP=Br($P);var IA={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,A){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new i(h,y||u,A),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],b]:u._events[R].push(b):(u._events[R]=b,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},c.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var A=0,b=y.length,R=new Array(b);A<b;A++)R[A]=y[A].fn;return R},c.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},c.prototype.emit=function(f,h,y,A,b,R){var k=e?e+f:f;if(!this._events[k])return!1;var S=this._events[k],B=arguments.length,H,U;if(S.fn){switch(S.once&&this.removeListener(f,S.fn,void 0,!0),B){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,y),!0;case 4:return S.fn.call(S.context,h,y,A),!0;case 5:return S.fn.call(S.context,h,y,A,b),!0;case 6:return S.fn.call(S.context,h,y,A,b,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];S.fn.apply(S.context,H)}else{var G=S.length,W;for(U=0;U<G;U++)switch(S[U].once&&this.removeListener(f,S[U].fn,void 0,!0),B){case 1:S[U].fn.call(S[U].context);break;case 2:S[U].fn.call(S[U].context,h);break;case 3:S[U].fn.call(S[U].context,h,y);break;case 4:S[U].fn.call(S[U].context,h,y,A);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];S[U].fn.apply(S[U].context,H)}}return!0},c.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},c.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},c.prototype.removeListener=function(f,h,y,A){var b=e?e+f:f;if(!this._events[b])return this;if(!h)return o(this,b),this;var R=this._events[b];if(R.fn)R.fn===h&&(!A||R.once)&&(!y||R.context===y)&&o(this,b);else{for(var k=0,S=[],B=R.length;k<B;k++)(R[k].fn!==h||A&&!R[k].once||y&&R[k].context!==y)&&S.push(R[k]);S.length?this._events[b]=S.length===1?S[0]:S:o(this,b)}return this},c.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,n.exports=c})(IA);var zP=IA.exports;const kA=Br(zP);var GP=class extends kA{constructor(t,e,r){super();Z(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(t,e,r){const i=r||e;try{this.socket.send(t),i()}catch(s){i(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function VP(n,t){return new GP(n,t)}var KP=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},jP=class extends kA{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...c}={},u,f){super();Z(this,"address");Z(this,"rpc_id");Z(this,"queue");Z(this,"options");Z(this,"autoconnect");Z(this,"ready");Z(this,"reconnect");Z(this,"reconnect_timer_id");Z(this,"reconnect_interval");Z(this,"max_reconnects");Z(this,"rest_options");Z(this,"current_reconnects");Z(this,"generate_request_id");Z(this,"socket");Z(this,"webSocketFactory");Z(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=c,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),f?this.dataPack=f:this.dataPack=new KP,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,r,i){return!i&&typeof r=="object"&&(i=r,r=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const c=this.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||void 0,id:c};this.socket.send(this.dataPack.encode(u),i,f=>{if(f)return o(f);this.queue[c]={promise:[s,o]},r&&(this.queue[c].timeout=setTimeout(()=>{delete this.queue[c],o(new Error("reply timeout"))},r))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((r,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);r()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=kt.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const i=[r.notification];if(r.params.constructor===Object)i.push(r.params);else for(let s=0;s<r.params.length;s++)i.push(r.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",r,i),0),this.ready=!1,this.socket=void 0,r!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const TA=[],OA=[],NA=[],WP=BigInt(0),gf=BigInt(1),ZP=BigInt(2),qP=BigInt(7),QP=BigInt(256),YP=BigInt(113);for(let n=0,t=gf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],TA.push(2*(5*r+e)),OA.push((n+1)*(n+2)/2%64);let i=WP;for(let s=0;s<7;s++)t=(t<<gf^(t>>qP)*YP)%QP,t&ZP&&(i^=gf<<(gf<<BigInt(s))-gf);NA.push(i)}const[JP,XP]=v_(NA,!0),CA=(n,t,e)=>e>32?S_(n,t,e):x_(n,t,e),BA=(n,t,e)=>e>32?I_(n,t,e):R_(n,t,e);function tM(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=CA(f,h,1)^e[c],A=BA(f,h,1)^e[c+1];for(let b=0;b<50;b+=10)n[o+b]^=y,n[o+b+1]^=A}let i=n[2],s=n[3];for(let o=0;o<24;o++){const c=OA[o],u=CA(i,s,c),f=BA(i,s,c),h=TA[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)e[c]=n[o+c];for(let c=0;c<10;c++)n[o+c]^=~e[(c+2)%10]&e[(c+4)%10]}n[0]^=JP[r],n[1]^=XP[r]}e.fill(0)}let eM=class kT extends Eg{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Id(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=M5(this.state)}keccak(){w_||b_(this.state32),tM(this.state32,this.rounds),w_||b_(this.state32),this.posOut=0,this.pos=0}update(t){Gc(this);const{blockLen:e,state:r}=this;t=kd(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Gc(this,!1),of(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Id(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(m_(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new kT(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const PA=((n,t,e)=>vg(()=>new eM(t,n,e)))(1,136,256/8);let MA=class extends Eg{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,P5(t);const r=kd(e);if(this.iHash=t.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 i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return Gc(this),this.iHash.update(t),this}digestInto(t){Gc(this),of(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const LA=(n,t,e)=>new MA(n,t).update(e).digest();LA.create=(n,t)=>new MA(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function UA(n){n.lowS!==void 0&&ms("lowS",n.lowS),n.prehash!==void 0&&ms("prehash",n.prehash)}function nM(n){const t=Mg(n);qc(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:rM,hexToBytes:iM}=f4;class sM extends Error{constructor(t=""){super(t)}}const _s={Err:sM,_tlv:{encode:(n,t)=>{const{Err:e}=_s;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const r=t.length/2,i=Kc(r);if(i.length/2&128)throw new e("tlv.encode: long form length too big");const s=r>127?Kc(i.length/2|128):"";return Kc(n)+s+i+t},decode(n,t){const{Err:e}=_s;let r=0;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[r++]!==n)throw new e("tlv.decode: wrong tlv");const i=t[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new e("tlv.decode(long): indefinite length not supported");if(u>4)throw new e("tlv.decode(long): byte length is too big");const f=t.subarray(r,r+u);if(f.length!==u)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const h of f)o=o<<8|h;if(r+=u,o<128)throw new e("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+o);if(c.length!==o)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+o)}}},_int:{encode(n){const{Err:t}=_s;if(n<As)throw new t("integer: negative integers are not allowed");let e=Kc(n);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(n){const{Err:t}=_s;if(n[0]&128)throw new t("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return rM(n)}},toSig(n){const{Err:t,_int:e,_tlv:r}=_s,i=typeof n=="string"?iM(n):n;af(i);const{v:s,l:o}=r.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:u}=r.decode(2,s),{v:f,l:h}=r.decode(2,u);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(n){const{_tlv:t,_int:e}=_s,r=t.encode(2,e.encode(n.r)),i=t.encode(2,e.encode(n.s)),s=r+i;return t.encode(48,s)}},As=BigInt(0),Pn=BigInt(1);BigInt(2);const DA=BigInt(3);BigInt(4);function oM(n){const t=nM(n),{Fp:e}=t,r=Bd(t.n,t.nBitLength),i=t.toBytes||((k,S,B)=>{const H=S.toAffine();return da(Uint8Array.from([4]),e.toBytes(H.x),e.toBytes(H.y))}),s=t.fromBytes||(k=>{const S=k.subarray(1),B=e.fromBytes(S.subarray(0,e.BYTES)),H=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:B,y:H}});function o(k){const{a:S,b:B}=t,H=e.sqr(k),U=e.mul(H,k);return e.add(e.add(U,e.mul(k,S)),B)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function c(k){return Cd(k,Pn,t.n)}function u(k){const{allowedPrivateKeyLengths:S,nByteLength:B,wrapPrivateKey:H,n:U}=t;if(S&&typeof k!="bigint"){if(la(k)&&(k=fa(k)),typeof k!="string"||!S.includes(k.length))throw new Error("invalid private key");k=k.padStart(B*2,"0")}let G;try{G=typeof k=="bigint"?k:ha(kn("private key",k,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof k)}return H&&(G=Ze(G,U)),Qr("private key",G,Pn,U),G}function f(k){if(!(k instanceof A))throw new Error("ProjectivePoint expected")}const h=uf((k,S)=>{const{px:B,py:H,pz:U}=k;if(e.eql(U,e.ONE))return{x:B,y:H};const G=k.is0();S==null&&(S=G?e.ONE:e.inv(U));const W=e.mul(B,S),J=e.mul(H,S),j=e.mul(U,S);if(G)return{x:e.ZERO,y:e.ZERO};if(!e.eql(j,e.ONE))throw new Error("invZ was invalid");return{x:W,y:J}}),y=uf(k=>{if(k.is0()){if(t.allowInfinityPoint&&!e.is0(k.py))return;throw new Error("bad point: ZERO")}const{x:S,y:B}=k.toAffine();if(!e.isValid(S)||!e.isValid(B))throw new Error("bad point: x or y not FE");const H=e.sqr(B),U=o(S);if(!e.eql(H,U))throw new Error("bad point: equation left != right");if(!k.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class A{constructor(S,B,H){if(this.px=S,this.py=B,this.pz=H,S==null||!e.isValid(S))throw new Error("x required");if(B==null||!e.isValid(B))throw new Error("y required");if(H==null||!e.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(S){const{x:B,y:H}=S||{};if(!S||!e.isValid(B)||!e.isValid(H))throw new Error("invalid affine point");if(S instanceof A)throw new Error("projective point not allowed");const U=G=>e.eql(G,e.ZERO);return U(B)&&U(H)?A.ZERO:new A(B,H,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const B=e.invertBatch(S.map(H=>H.pz));return S.map((H,U)=>H.toAffine(B[U])).map(A.fromAffine)}static fromHex(S){const B=A.fromAffine(s(kn("pointHex",S)));return B.assertValidity(),B}static fromPrivateKey(S){return A.BASE.multiply(u(S))}static msm(S,B){return H_(A,r,S,B)}_setWindowSize(S){R.setWindowSize(this,S)}assertValidity(){y(this)}hasEvenY(){const{y:S}=this.toAffine();if(e.isOdd)return!e.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){f(S);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:J}=S,j=e.eql(e.mul(B,J),e.mul(G,U)),Y=e.eql(e.mul(H,J),e.mul(W,U));return j&&Y}negate(){return new A(this.px,e.neg(this.py),this.pz)}double(){const{a:S,b:B}=t,H=e.mul(B,DA),{px:U,py:G,pz:W}=this;let J=e.ZERO,j=e.ZERO,Y=e.ZERO,it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(W,W),ot=e.mul(U,G);return ot=e.add(ot,ot),Y=e.mul(U,W),Y=e.add(Y,Y),J=e.mul(S,Y),j=e.mul(H,rt),j=e.add(J,j),J=e.sub(ut,j),j=e.add(ut,j),j=e.mul(J,j),J=e.mul(ot,J),Y=e.mul(H,Y),rt=e.mul(S,rt),ot=e.sub(it,rt),ot=e.mul(S,ot),ot=e.add(ot,Y),Y=e.add(it,it),it=e.add(Y,it),it=e.add(it,rt),it=e.mul(it,ot),j=e.add(j,it),rt=e.mul(G,W),rt=e.add(rt,rt),it=e.mul(rt,ot),J=e.sub(J,it),Y=e.mul(rt,ut),Y=e.add(Y,Y),Y=e.add(Y,Y),new A(J,j,Y)}add(S){f(S);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:J}=S;let j=e.ZERO,Y=e.ZERO,it=e.ZERO;const ut=t.a,rt=e.mul(t.b,DA);let ot=e.mul(B,G),C=e.mul(H,W),p=e.mul(U,J),m=e.add(B,H),v=e.add(G,W);m=e.mul(m,v),v=e.add(ot,C),m=e.sub(m,v),v=e.add(B,U);let I=e.add(G,J);return v=e.mul(v,I),I=e.add(ot,p),v=e.sub(v,I),I=e.add(H,U),j=e.add(W,J),I=e.mul(I,j),j=e.add(C,p),I=e.sub(I,j),it=e.mul(ut,v),j=e.mul(rt,p),it=e.add(j,it),j=e.sub(C,it),it=e.add(C,it),Y=e.mul(j,it),C=e.add(ot,ot),C=e.add(C,ot),p=e.mul(ut,p),v=e.mul(rt,v),C=e.add(C,p),p=e.sub(ot,p),p=e.mul(ut,p),v=e.add(v,p),ot=e.mul(C,v),Y=e.add(Y,ot),ot=e.mul(I,v),j=e.mul(m,j),j=e.sub(j,ot),ot=e.mul(m,C),it=e.mul(I,it),it=e.add(it,ot),new A(j,Y,it)}subtract(S){return this.add(S.negate())}is0(){return this.equals(A.ZERO)}wNAF(S){return R.wNAFCached(this,S,A.normalizeZ)}multiplyUnsafe(S){const{endo:B,n:H}=t;Qr("scalar",S,As,H);const U=A.ZERO;if(S===As)return U;if(this.is0()||S===Pn)return this;if(!B||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,S,A.normalizeZ);let{k1neg:G,k1:W,k2neg:J,k2:j}=B.splitScalar(S),Y=U,it=U,ut=this;for(;W>As||j>As;)W&Pn&&(Y=Y.add(ut)),j&Pn&&(it=it.add(ut)),ut=ut.double(),W>>=Pn,j>>=Pn;return G&&(Y=Y.negate()),J&&(it=it.negate()),it=new A(e.mul(it.px,B.beta),it.py,it.pz),Y.add(it)}multiply(S){const{endo:B,n:H}=t;Qr("scalar",S,Pn,H);let U,G;if(B){const{k1neg:W,k1:J,k2neg:j,k2:Y}=B.splitScalar(S);let{p:it,f:ut}=this.wNAF(J),{p:rt,f:ot}=this.wNAF(Y);it=R.constTimeNegate(W,it),rt=R.constTimeNegate(j,rt),rt=new A(e.mul(rt.px,B.beta),rt.py,rt.pz),U=it.add(rt),G=ut.add(ot)}else{const{p:W,f:J}=this.wNAF(S);U=W,G=J}return A.normalizeZ([U,G])[0]}multiplyAndAddUnsafe(S,B,H){const U=A.BASE,G=(J,j)=>j===As||j===Pn||!J.equals(U)?J.multiplyUnsafe(j):J.multiply(j),W=G(this,B).add(G(S,H));return W.is0()?void 0:W}toAffine(S){return h(this,S)}isTorsionFree(){const{h:S,isTorsionFree:B}=t;if(S===Pn)return!0;if(B)return B(A,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:B}=t;return S===Pn?this:B?B(A,this):this.multiplyUnsafe(t.h)}toRawBytes(S=!0){return ms("isCompressed",S),this.assertValidity(),i(A,this,S)}toHex(S=!0){return ms("isCompressed",S),fa(this.toRawBytes(S))}}A.BASE=new A(t.Gx,t.Gy,e.ONE),A.ZERO=new A(e.ZERO,e.ONE,e.ZERO);const b=t.nBitLength,R=$_(A,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:A,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function aM(n){const t=Mg(n);return qc(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function cM(n){const t=aM(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(p){return Ze(p,r)}function c(p){return Og(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:y}=oM({...t,toBytes(p,m,v){const I=m.toAffine(),N=e.toBytes(I.x),M=da;return ms("isCompressed",v),v?M(Uint8Array.from([m.hasEvenY()?2:3]),N):M(Uint8Array.from([4]),N,e.toBytes(I.y))},fromBytes(p){const m=p.length,v=p[0],I=p.subarray(1);if(m===i&&(v===2||v===3)){const N=ha(I);if(!Cd(N,Pn,e.ORDER))throw new Error("Point is not on curve");const M=h(N);let z;try{z=e.sqrt(M)}catch(F){const ct=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+ct)}const P=(z&Pn)===Pn;return(v&1)===1!==P&&(z=e.neg(z)),{x:N,y:z}}else if(m===s&&v===4){const N=e.fromBytes(I.subarray(0,e.BYTES)),M=e.fromBytes(I.subarray(e.BYTES,2*e.BYTES));return{x:N,y:M}}else{const N=i,M=s;throw new Error("invalid Point, expected length of "+N+", or uncompressed "+M+", got "+m)}}}),A=p=>fa(Zc(p,t.nByteLength));function b(p){const m=r>>Pn;return p>m}function R(p){return b(p)?o(-p):p}const k=(p,m,v)=>ha(p.slice(m,v));class S{constructor(m,v,I){this.r=m,this.s=v,this.recovery=I,this.assertValidity()}static fromCompact(m){const v=t.nByteLength;return m=kn("compactSignature",m,v*2),new S(k(m,0,v),k(m,v,2*v))}static fromDER(m){const{r:v,s:I}=_s.toSig(kn("DER",m));return new S(v,I)}assertValidity(){Qr("r",this.r,Pn,r),Qr("s",this.s,Pn,r)}addRecoveryBit(m){return new S(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:I,recovery:N}=this,M=J(kn("msgHash",m));if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");const z=N===2||N===3?v+t.n:v;if(z>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=N&1?"03":"02",_=u.fromHex(P+A(z)),F=c(z),ct=o(-M*F),dt=o(I*F),mt=u.BASE.multiplyAndAddUnsafe(_,ct,dt);if(!mt)throw new Error("point at infinify");return mt.assertValidity(),mt}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return jc(this.toDERHex())}toDERHex(){return _s.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return jc(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}const B={isValidPrivateKey(p){try{return f(p),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const p=L_(t.n);return A4(t.randomBytes(p),t.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function U(p){const m=la(p),v=typeof p=="string",I=(m||v)&&p.length;return m?I===i||I===s:v?I===2*i||I===2*s:p instanceof u}function G(p,m,v=!0){if(U(p))throw new Error("first arg must be private key");if(!U(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(f(p)).toRawBytes(v)}const W=t.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=ha(p),v=p.length*8-t.nBitLength;return v>0?m>>BigInt(v):m},J=t.bits2int_modN||function(p){return o(W(p))},j=Ig(t.nBitLength);function Y(p){return Qr("num < 2^"+t.nBitLength,p,As,j),Zc(p,t.nByteLength)}function it(p,m,v=ut){if(["recovered","canonical"].some(Ut=>Ut in v))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:N}=t;let{lowS:M,prehash:z,extraEntropy:P}=v;M==null&&(M=!0),p=kn("msgHash",p),UA(v),z&&(p=kn("prehashed msgHash",I(p)));const _=J(p),F=f(m),ct=[Y(F),Y(_)];if(P!=null&&P!==!1){const Ut=P===!0?N(e.BYTES):P;ct.push(kn("extraEntropy",Ut))}const dt=da(...ct),mt=_;function Gt(Ut){const Lt=W(Ut);if(!y(Lt))return;const xe=c(Lt),Kt=u.BASE.multiply(Lt).toAffine(),Ft=o(Kt.x);if(Ft===As)return;const ke=o(xe*o(mt+Ft*F));if(ke===As)return;let re=(Kt.x===Ft?0:2)|Number(Kt.y&Pn),oe=ke;return M&&b(ke)&&(oe=R(ke),re^=1),new S(Ft,oe,re)}return{seed:dt,k2sig:Gt}}const ut={lowS:t.lowS,prehash:!1},rt={lowS:t.lowS,prehash:!1};function ot(p,m,v=ut){const{seed:I,k2sig:N}=it(p,m,v),M=t;return N_(M.hash.outputLen,M.nByteLength,M.hmac)(I,N)}u.BASE._setWindowSize(8);function C(p,m,v,I=rt){var re;const N=p;m=kn("msgHash",m),v=kn("publicKey",v);const{lowS:M,prehash:z,format:P}=I;if(UA(I),"strict"in I)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");const _=typeof N=="string"||la(N),F=!_&&!P&&typeof N=="object"&&N!==null&&typeof N.r=="bigint"&&typeof N.s=="bigint";if(!_&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let ct,dt;try{if(F&&(ct=new S(N.r,N.s)),_){try{P!=="compact"&&(ct=S.fromDER(N))}catch(oe){if(!(oe instanceof _s.Err))throw oe}!ct&&P!=="der"&&(ct=S.fromCompact(N))}dt=u.fromHex(v)}catch{return!1}if(!ct||M&&ct.hasHighS())return!1;z&&(m=t.hash(m));const{r:mt,s:Gt}=ct,Ut=J(m),Lt=c(Gt),xe=o(Ut*Lt),Kt=o(mt*Lt),Ft=(re=u.BASE.multiplyAndAddUnsafe(dt,xe,Kt))==null?void 0:re.toAffine();return Ft?o(Ft.x)===mt:!1}return{CURVE:t,getPublicKey:H,getSharedSecret:G,sign:ot,verify:C,ProjectivePoint:u,Signature:S,utils:B}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function uM(n){return{hash:n,hmac:(t,...e)=>LA(n,t,D5(...e)),randomBytes:__}}function lM(n,t){const e=r=>cM({...n,...uM(r)});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const FA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$A=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),fM=BigInt(1),sy=BigInt(2),HA=(n,t)=>(n+t/sy)/t;function hM(n){const t=FA,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=cn(h,e,t)*h%t,A=cn(y,e,t)*h%t,b=cn(A,sy,t)*f%t,R=cn(b,i,t)*b%t,k=cn(R,s,t)*R%t,S=cn(k,c,t)*k%t,B=cn(S,u,t)*S%t,H=cn(B,c,t)*k%t,U=cn(H,e,t)*h%t,G=cn(U,o,t)*R%t,W=cn(G,r,t)*f%t,J=cn(W,sy,t);if(!oy.eql(oy.sqr(J),n))throw new Error("Cannot find square root");return J}const oy=Bd(FA,void 0,void 0,{sqrt:hM}),Qd=lM({a:BigInt(0),b:BigInt(7),Fp:oy,n:$A,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=$A,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-fM*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),c=HA(s*n,t),u=HA(-r*n,t);let f=Ze(n-c*e-u*i,t),h=Ze(-c*r-u*s,t);const y=f>o,A=h>o;if(y&&(f=t-f),A&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:A,k2:h}}}},Dg);BigInt(0),Qd.ProjectivePoint;const dM=Qc.utils.randomPrivateKey,zA=()=>{const n=Qc.utils.randomPrivateKey(),t=Yd(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},Yd=Qc.getPublicKey;function GA(n){try{return Qc.ExtendedPoint.fromHex(n),!0}catch{return!1}}const ay=(n,t)=>Qc.sign(n,t.slice(0,32)),pM=Qc.verify,te=n=>kt.isBuffer(n)?n:n instanceof Uint8Array?kt.from(n.buffer,n.byteOffset,n.byteLength):kt.from(n);let cy=class{constructor(t){Object.assign(this,t)}encode(){return kt.from(Y_(yf,this))}static decode(t){return J_(yf,this,t)}static decodeUnchecked(t){return j_(yf,this,t)}};class gM extends cy{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const yf=new Map;var VA;const KA=32,$i=32;function yM(n){return n._bn!==void 0}let jA=1;class pt extends cy{constructor(t){if(super({}),this._bn=void 0,yM(t))this._bn=t._bn;else{if(typeof t=="string"){const e=Tn.decode(t);if(e.length!=$i)throw new Error("Invalid public key input");this._bn=new ys(e)}else this._bn=new ys(t);if(this._bn.byteLength()>$i)throw new Error("Invalid public key input")}}static unique(){const t=new pt(jA);return jA+=1,new pt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return Tn.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(kt);if(t.length===$i)return t;const e=kt.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=kt.concat([t.toBuffer(),kt.from(e),r.toBuffer()]),s=Dg(i);return new pt(s)}static createProgramAddressSync(t,e){let r=kt.alloc(0);t.forEach(function(s){if(s.length>KA)throw new TypeError("Max seed length exceeded");r=kt.concat([r,te(s)])}),r=kt.concat([r,e.toBuffer(),kt.from("ProgramDerivedAddress")]);const i=Dg(r);if(GA(i))throw new Error("Invalid seeds, address must fall off the curve");return new pt(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,i;for(;r!=0;){try{const s=t.concat(kt.from([r]));i=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new pt(t);return GA(e.toBytes())}}VA=pt,pt.default=new VA("11111111111111111111111111111111"),yf.set(pt,{kind:"struct",fields:[["_bn","u256"]]});class mM{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=te(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=te(dM()),this._publicKey=te(Yd(this._secretKey))}get publicKey(){return new pt(this._publicKey)}get secretKey(){return kt.concat([this._secretKey,this._publicKey],64)}}const wM=new pt("BPFLoader1111111111111111111111111111111111"),po=1232,Jd=127,mf=64;class uy extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(uy.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class ly extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ly.prototype,"name",{value:"TransactionExpiredTimeoutError"});class nu extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(nu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class wf{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((s,o)=>{r.set(s.toBase58(),o)});const i=s=>{const o=r.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const ce=(n="publicKey")=>je(32,n),bM=(n="signature")=>je(64,n),ba=(n="string")=>{const t=Nt([Ot("length"),Ot("lengthPadding"),je(fo(Ot(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(s,o)=>e(s,o).chars.toString(),i.encode=(s,o,c)=>{const u={chars:kt.from(s,"utf8")};return r(u,o,c)},i.alloc=s=>Ot().span+Ot().span+kt.from(s,"utf8").length,i},_M=(n="authorized")=>Nt([ce("staker"),ce("withdrawer")],n),AM=(n="lockup")=>Nt([Ur("unixTimestamp"),Ur("epoch"),ce("custodian")],n),EM=(n="voteInit")=>Nt([ce("nodePubkey"),ce("authorizedVoter"),ce("authorizedWithdrawer"),me("commission")],n),vM=(n="voteAuthorizeWithSeedArgs")=>Nt([Ot("voteAuthorizationType"),ce("currentAuthorityDerivedKeyOwnerPubkey"),ba("currentAuthorityDerivedKeySeed"),ce("newAuthorized")],n);function WA(n,t){const e=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(t[i.property]);if("count"in i&&"elementLayout"in i){const s=t[i.property];if(Array.isArray(s))return s.length*e(i.elementLayout)}else if("fields"in i)return WA({layout:i},t[i.property]);return 0};let r=0;return n.layout.fields.forEach(i=>{r+=e(i)}),r}function vr(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function Dr(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function _e(n,t){if(!n)throw new Error(t||"Assertion failed")}class Xd{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,i=o=>{const c=o.toBase58();let u=r.get(c);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(c,u)),u},s=i(e);s.isSigner=!0,s.isWritable=!0;for(const o of t){i(o.programId).isInvoked=!0;for(const c of o.keys){const u=i(c.pubkey);u.isSigner||(u.isSigner=c.isSigner),u.isWritable||(u.isWritable=c.isWritable)}}return new Xd(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];_e(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),r=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),s=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{_e(e.length>0,"Expected at least one writable signer key");const[u]=e[0];_e(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const c=[...e.map(([u])=>new pt(u)),...r.map(([u])=>new pt(u)),...i.map(([u])=>new pt(u)),...s.map(([u])=>new pt(u))];return[o,c]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(t,e){const r=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(e(o)){const c=new pt(s),u=t.findIndex(f=>f.equals(c));u>=0&&(_e(u<256,"Max lookup table index exceeded"),r.push(u),i.push(c),this.keyMetaMap.delete(s))}return[r,i]}}const ZA="Reached end of buffer unexpectedly";function Hi(n){if(n.length===0)throw new Error(ZA);return n.shift()}function xr(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(ZA);return n.splice(...t)}class yi{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new pt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Tn.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new wf(this.staticAccountKeys)}static compile(t){const e=Xd.compile(t.instructions,t.payerKey),[r,i]=e.getMessageComponents(),o=new wf(i).compileInstructions(t.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:Tn.encode(c.data)}));return new yi({header:r,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<s}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];Dr(e,t);const r=this.instructions.map(y=>{const{accounts:A,programIdIndex:b}=y,R=Array.from(Tn.decode(y.data));let k=[];Dr(k,A.length);let S=[];return Dr(S,R.length),{programIdIndex:b,keyIndicesCount:kt.from(k),keyIndices:A,dataLength:kt.from(S),data:R}});let i=[];Dr(i,r.length);let s=kt.alloc(po);kt.from(i).copy(s);let o=i.length;r.forEach(y=>{const b=Nt([me("programIdIndex"),je(y.keyIndicesCount.length,"keyIndicesCount"),Kn(me("keyIndex"),y.keyIndices.length,"keyIndices"),je(y.dataLength.length,"dataLength"),Kn(me("userdatum"),y.data.length,"data")]).encode(y,s,o);o+=b}),s=s.slice(0,o);const c=Nt([je(1,"numRequiredSignatures"),je(1,"numReadonlySignedAccounts"),je(1,"numReadonlyUnsignedAccounts"),je(e.length,"keyCount"),Kn(ce("key"),t,"keys"),ce("recentBlockhash")]),u={numRequiredSignatures:kt.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:kt.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:kt.from([this.header.numReadonlyUnsignedAccounts]),keyCount:kt.from(e),keys:this.accountKeys.map(y=>te(y.toBytes())),recentBlockhash:Tn.decode(this.recentBlockhash)};let f=kt.alloc(2048);const h=c.encode(u,f);return s.copy(f,h),f.slice(0,h+s.length)}static from(t){let e=[...t];const r=Hi(e);if(r!==(r&Jd))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=Hi(e),s=Hi(e),o=vr(e);let c=[];for(let A=0;A<o;A++){const b=xr(e,0,$i);c.push(new pt(kt.from(b)))}const u=xr(e,0,$i),f=vr(e);let h=[];for(let A=0;A<f;A++){const b=Hi(e),R=vr(e),k=xr(e,0,R),S=vr(e),B=xr(e,0,S),H=Tn.encode(kt.from(B));h.push({programIdIndex:b,accounts:k,data:H})}const y={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:Tn.encode(kt.from(u)),accountKeys:c,instructions:h};return new yi(y)}}class _a{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new wf(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const i=t-r,s=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return i<s}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=t.find(s=>s.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const s of r.writableIndexes)if(s<i.state.addresses.length)e.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(const s of r.readonlyIndexes)if(s<i.state.addresses.length)e.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=Xd.compile(t.instructions,t.payerKey),r=new Array,i={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const h of s){const y=e.extractTableLookup(h);if(y!==void 0){const[A,{writable:b,readonly:R}]=y;r.push(A),i.writable.push(...b),i.readonly.push(...R)}}const[o,c]=e.getMessageComponents(),f=new wf(c,i).compileInstructions(t.instructions);return new _a({header:o,staticAccountKeys:c,recentBlockhash:t.recentBlockhash,compiledInstructions:f,addressTableLookups:r})}serialize(){const t=Array();Dr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Dr(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();Dr(s,this.addressTableLookups.length);const o=Nt([me("prefix"),Nt([me("numRequiredSignatures"),me("numReadonlySignedAccounts"),me("numReadonlyUnsignedAccounts")],"header"),je(t.length,"staticAccountKeysLength"),Kn(ce(),this.staticAccountKeys.length,"staticAccountKeys"),ce("recentBlockhash"),je(r.length,"instructionsLength"),je(e.length,"serializedInstructions"),je(s.length,"addressTableLookupsLength"),je(i.length,"serializedAddressTableLookups")]),c=new Uint8Array(po),f=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:Tn.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},c);return c.slice(0,f)}serializeInstructions(){let t=0;const e=new Uint8Array(po);for(const r of this.compiledInstructions){const i=Array();Dr(i,r.accountKeyIndexes.length);const s=Array();Dr(s,r.data.length);const o=Nt([me("programIdIndex"),je(i.length,"encodedAccountKeyIndexesLength"),Kn(me(),r.accountKeyIndexes.length,"accountKeyIndexes"),je(s.length,"encodedDataLength"),je(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(po);for(const r of this.addressTableLookups){const i=Array();Dr(i,r.writableIndexes.length);const s=Array();Dr(s,r.readonlyIndexes.length);const o=Nt([ce("accountKey"),je(i.length,"encodedWritableIndexesLength"),Kn(me(),r.writableIndexes.length,"writableIndexes"),je(s.length,"encodedReadonlyIndexesLength"),Kn(me(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=Hi(e),i=r&Jd;_e(r!==i,"Expected versioned message but received legacy message");const s=i;_e(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:Hi(e),numReadonlySignedAccounts:Hi(e),numReadonlyUnsignedAccounts:Hi(e)},c=[],u=vr(e);for(let R=0;R<u;R++)c.push(new pt(xr(e,0,$i)));const f=Tn.encode(xr(e,0,$i)),h=vr(e),y=[];for(let R=0;R<h;R++){const k=Hi(e),S=vr(e),B=xr(e,0,S),H=vr(e),U=new Uint8Array(xr(e,0,H));y.push({programIdIndex:k,accountKeyIndexes:B,data:U})}const A=vr(e),b=[];for(let R=0;R<A;R++){const k=new pt(xr(e,0,$i)),S=vr(e),B=xr(e,0,S),H=vr(e),U=xr(e,0,H);b.push({accountKey:k,writableIndexes:B,readonlyIndexes:U})}return new _a({header:o,staticAccountKeys:c,recentBlockhash:f,compiledInstructions:y,addressTableLookups:b})}}const fy={deserializeMessageVersion(n){const t=n[0],e=t&Jd;return e===t?"legacy":e},deserialize:n=>{const t=fy.deserializeMessageVersion(n);if(t==="legacy")return yi.from(n);if(t===0)return _a.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let Es=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const xM=kt.alloc(mf).fill(0);class Pe{constructor(t){this.keys=void 0,this.programId=void 0,this.data=kt.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}let Oe=class sb{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Pe(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<e.length;k++)if(e[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const i=[],s=[];e.forEach(k=>{k.keys.forEach(B=>{s.push({...B})});const S=k.programId.toString();i.includes(S)||i.push(S)}),i.forEach(k=>{s.push({pubkey:new pt(k),isSigner:!1,isWritable:!1})});const o=[];s.forEach(k=>{const S=k.pubkey.toString(),B=o.findIndex(H=>H.pubkey.toString()===S);B>-1?(o[B].isWritable=o[B].isWritable||k.isWritable,o[B].isSigner=o[B].isSigner||k.isSigner):o.push(k)}),o.sort(function(k,S){if(k.isSigner!==S.isSigner)return k.isSigner?-1:1;if(k.isWritable!==S.isWritable)return k.isWritable?-1:1;const B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(S.pubkey.toBase58(),"en",B)});const c=o.findIndex(k=>k.pubkey.equals(r));if(c>-1){const[k]=o.splice(c,1);k.isSigner=!0,k.isWritable=!0,o.unshift(k)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const k of this.signatures){const S=o.findIndex(B=>B.pubkey.equals(k.publicKey));if(S>-1)o[S].isSigner||(o[S].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let u=0,f=0,h=0;const y=[],A=[];o.forEach(({pubkey:k,isSigner:S,isWritable:B})=>{S?(y.push(k.toString()),u+=1,B||(f+=1)):(A.push(k.toString()),B||(h+=1))});const b=y.concat(A),R=e.map(k=>{const{data:S,programId:B}=k;return{programIdIndex:b.indexOf(B.toString()),accounts:k.keys.map(H=>b.indexOf(H.pubkey.toString())),data:Tn.encode(S)}});return R.forEach(k=>{_e(k.programIdIndex>=0),k.accounts.forEach(S=>_e(S>=0))}),new yi({header:{numRequiredSignatures:u,numReadonlySignedAccounts:f,numReadonlyUnsignedAccounts:h},accountKeys:b,recentBlockhash:t,instructions:R})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,s)=>e[s].equals(i.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(r=>{const i=r.toString();return e.has(i)?!1:(e.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}const i=this._compile();this._partialSign(i,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(i=>{const s=ay(r,i.secretKey);this._addSignature(i.publicKey,te(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){_e(e.length===64);const r=this.signatures.findIndex(i=>t.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=kt.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:i,publicKey:s}of this.signatures)i===null?e&&(r.missing||(r.missing=[])).push(s):pM(i,t,s.toBytes())||(r.invalid||(r.invalid=[])).push(s);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(r){const s=this._getMessageSignednessErrors(i,e);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
17
- Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(c=>c.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
18
- Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(t){const{signatures:e}=this,r=[];Dr(r,e.length);const i=r.length+e.length*64+t.length,s=kt.alloc(i);return _e(e.length<256),kt.from(r).copy(s,0),e.forEach(({signature:o},c)=>{o!==null&&(_e(o.length===64,"signature has invalid length"),kt.from(o).copy(s,r.length+c*64))}),t.copy(s,r.length+e.length*64),_e(s.length<=po,`Transaction too large: ${s.length} > ${po}`),s}get keys(){return _e(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return _e(this.instructions.length===1),this.instructions[0].programId}get data(){return _e(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=vr(e);let i=[];for(let s=0;s<r;s++){const o=xr(e,0,mf);i.push(Tn.encode(kt.from(o)))}return sb.populate(yi.from(e),i)}static populate(t,e=[]){const r=new sb;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((i,s)=>{const o={signature:i==Tn.encode(xM)?null:Tn.decode(i),publicKey:t.accountKeys[s]};r.signatures.push(o)}),t.instructions.forEach(i=>{const s=i.accounts.map(o=>{const c=t.accountKeys[o];return{pubkey:c,isSigner:r.signatures.some(u=>u.publicKey.toString()===c.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Pe({keys:s,programId:t.accountKeys[i.programIdIndex],data:Tn.decode(i.data)}))}),r._message=t,r._json=r.toJSON(),r}};class hy{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:r,compiledInstructions:i,recentBlockhash:s}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u}=r,f=o-c;_e(f>0,"Message header is invalid");const h=t.staticAccountKeys.length-o-u;_e(h>=0,"Message header is invalid");const y=t.getAccountKeys(e),A=y.get(0);if(A===void 0)throw new Error("Failed to decompile message because no account keys were found");const b=[];for(const R of i){const k=[];for(const B of R.accountKeyIndexes){const H=y.get(B);if(H===void 0)throw new Error(`Failed to find key for account key index ${B}`);const U=B<o;let G;U?G=B<f:B<y.staticAccountKeys.length?G=B-o<h:G=B-y.staticAccountKeys.length<y.accountKeysFromLookups.writable.length,k.push({pubkey:H,isSigner:B<r.numRequiredSignatures,isWritable:G})}const S=y.get(R.programIdIndex);if(S===void 0)throw new Error(`Failed to find program id for program id index ${R.programIdIndex}`);b.push(new Pe({programId:S,data:te(R.data),keys:k}))}return new hy({payerKey:A,instructions:b,recentBlockhash:s})}compileToLegacyMessage(){return yi.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return _a.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class dy{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)_e(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const r=[];for(let i=0;i<t.header.numRequiredSignatures;i++)r.push(new Uint8Array(mf));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Dr(e,this.signatures.length);const r=Nt([je(e.length,"encodedSignaturesLength"),Kn(bM(),this.signatures.length,"signatures"),je(t.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},i);return i.slice(0,s)}static deserialize(t){let e=[...t];const r=[],i=vr(e);for(let o=0;o<i;o++)r.push(new Uint8Array(xr(e,0,mf)));const s=fy.deserialize(new Uint8Array(e));return new dy(s,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of t){const s=r.findIndex(o=>o.equals(i.publicKey));_e(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=ay(e,i.secretKey)}}addSignature(t,e){_e(e.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(t));_e(i>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=e}}const qA=1e3/(160/64),zi=new pt("SysvarC1ock11111111111111111111111111111111"),RM=new pt("SysvarEpochSchedu1e111111111111111111111111"),SM=new pt("Sysvar1nstructions1111111111111111111111111"),t0=new pt("SysvarRecentB1ockHashes11111111111111111111"),ru=new pt("SysvarRent111111111111111111111111111111111"),IM=new pt("SysvarRewards111111111111111111111111111111"),kM=new pt("SysvarS1otHashes111111111111111111111111111"),TM=new pt("SysvarS1otHistory11111111111111111111111111"),e0=new pt("SysvarStakeHistory1111111111111111111111111");class go extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:i}){const s=i?`Logs:
19
- ${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let c;switch(t){case"send":c=`Transaction ${e} resulted in an error.
20
- ${r}. `+s+o;break;case"simulate":c=`Simulation failed.
21
- Message: ${r}.
22
- `+s+o;break;default:c=`Unknown action '${(u=>u)(t)}'`}super(c),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,r)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,e(s)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const OM={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Mt extends Error{constructor({code:t,message:e,data:r},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function py(n,t,e,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await n.sendTransaction(t,e,i);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:c}=t.nonceInfo,u=c.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:t.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else(r==null?void 0:r.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await n.confirmTransaction(s,r&&r.commitment)).value;if(o.err)throw s!=null?new go({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function Aa(n){return new Promise(t=>setTimeout(t,n))}function pe(n,t){const e=n.layout.span>=0?n.layout.span:WA(n,t),r=kt.alloc(e),i=Object.assign({instruction:n.index},t);return n.layout.encode(i,r),r}function Ie(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const QA=Vn("lamportsPerSignature"),YA=Nt([Ot("version"),Ot("state"),ce("authorizedPubkey"),ce("nonce"),Nt([QA],"feeCalculator")]),gy=YA.span;class n0{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=YA.decode(te(t),0);return new n0({authorizedPubkey:new pt(e.authorizedPubkey),nonce:new pt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const NM=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},iu=(n=>t=>{const e=je(n,t),{encode:r,decode:i}=NM(e),s=e;return s.decode=(o,c)=>{const u=i(o,c);return aP(kt.from(u))},s.encode=(o,c,u)=>{const f=yA(o,n);return r(f,c,u)},s})(8);class CM{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries($e))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:i}=Ie($e.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new pt(i)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ie($e.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:i}=Ie($e.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new pt(i)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ie($e.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:i,programId:s}=Ie($e.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,space:i,programId:new pt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ie($e.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new pt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:i}=Ie($e.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,programId:new pt(i)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:i,space:s,programId:o}=Ie($e.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new pt(e),seed:r,lamports:i,space:s,programId:new pt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ie($e.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new pt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ie($e.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ie($e.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Ie($e.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new pt(e)}}static checkProgramId(t){if(!t.equals(Nn.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const $e=Object.freeze({Create:{index:0,layout:Nt([Ot("instruction"),Ur("lamports"),Ur("space"),ce("programId")])},Assign:{index:1,layout:Nt([Ot("instruction"),ce("programId")])},Transfer:{index:2,layout:Nt([Ot("instruction"),iu("lamports")])},CreateWithSeed:{index:3,layout:Nt([Ot("instruction"),ce("base"),ba("seed"),Ur("lamports"),Ur("space"),ce("programId")])},AdvanceNonceAccount:{index:4,layout:Nt([Ot("instruction")])},WithdrawNonceAccount:{index:5,layout:Nt([Ot("instruction"),Ur("lamports")])},InitializeNonceAccount:{index:6,layout:Nt([Ot("instruction"),ce("authorized")])},AuthorizeNonceAccount:{index:7,layout:Nt([Ot("instruction"),ce("authorized")])},Allocate:{index:8,layout:Nt([Ot("instruction"),Ur("space")])},AllocateWithSeed:{index:9,layout:Nt([Ot("instruction"),ce("base"),ba("seed"),Ur("space"),ce("programId")])},AssignWithSeed:{index:10,layout:Nt([Ot("instruction"),ce("base"),ba("seed"),ce("programId")])},TransferWithSeed:{index:11,layout:Nt([Ot("instruction"),iu("lamports"),ba("seed"),ce("programId")])},UpgradeNonceAccount:{index:12,layout:Nt([Ot("instruction")])}});class Nn{constructor(){}static createAccount(t){const e=$e.Create,r=pe(e,{lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});return new Pe({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const i=$e.TransferWithSeed;e=pe(i,{lamports:BigInt(t.lamports),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=$e.Transfer;e=pe(i,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const i=$e.AssignWithSeed;e=pe(i,{base:te(t.basePubkey.toBuffer()),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=$e.Assign;e=pe(i,{programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=$e.CreateWithSeed,r=pe(e,{base:te(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});let i=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||i.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Pe({keys:i,programId:this.programId,data:r})}static createNonceAccount(t){const e=new Oe;"basePubkey"in t&&"seed"in t?e.add(Nn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:gy,programId:this.programId})):e.add(Nn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:gy,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=$e.InitializeNonceAccount,r=pe(e,{authorized:te(t.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t0,isSigner:!1,isWritable:!1},{pubkey:ru,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Pe(i)}static nonceAdvance(t){const e=$e.AdvanceNonceAccount,r=pe(e),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t0,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Pe(i)}static nonceWithdraw(t){const e=$e.WithdrawNonceAccount,r=pe(e,{lamports:t.lamports});return new Pe({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:t0,isSigner:!1,isWritable:!1},{pubkey:ru,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=$e.AuthorizeNonceAccount,r=pe(e,{authorized:te(t.newAuthorizedPubkey.toBuffer())});return new Pe({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const i=$e.AllocateWithSeed;e=pe(i,{base:te(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=$e.Allocate;e=pe(i,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}}Nn.programId=new pt("11111111111111111111111111111111");const BM=po-300;class Ea{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Ea.chunkSize)+1+1)}static async load(t,e,r,i,s){{const y=await t.getMinimumBalanceForRentExemption(s.length),A=await t.getAccountInfo(r.publicKey,"confirmed");let b=null;if(A!==null){if(A.executable)return console.error("Program load failed, account is already executable"),!1;A.data.length!==s.length&&(b=b||new Oe,b.add(Nn.allocate({accountPubkey:r.publicKey,space:s.length}))),A.owner.equals(i)||(b=b||new Oe,b.add(Nn.assign({accountPubkey:r.publicKey,programId:i}))),A.lamports<y&&(b=b||new Oe,b.add(Nn.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:y-A.lamports})))}else b=new Oe().add(Nn.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:y>0?y:1,space:s.length,programId:i}));b!==null&&await py(t,b,[e,r],{commitment:"confirmed"})}const o=Nt([Ot("instruction"),Ot("offset"),Ot("bytesLength"),Ot("bytesLengthPadding"),Kn(me("byte"),fo(Ot(),-8),"bytes")]),c=Ea.chunkSize;let u=0,f=s,h=[];for(;f.length>0;){const y=f.slice(0,c),A=kt.alloc(c+16);o.encode({instruction:0,offset:u,bytes:y,bytesLength:0,bytesLengthPadding:0},A);const b=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:A});h.push(py(t,b,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Aa(1e3/4),u+=c,f=f.slice(c)}await Promise.all(h);{const y=Nt([Ot("instruction")]),A=kt.alloc(y.span);y.encode({instruction:1},A);const b=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ru,isSigner:!1,isWritable:!1}],programId:i,data:A}),R="processed",k=await t.sendTransaction(b,[e,r],{preflightCommitment:R}),{context:S,value:B}=await t.confirmTransaction({signature:k,lastValidBlockHeight:b.lastValidBlockHeight,blockhash:b.recentBlockhash},R);if(B.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(B)})`);for(;;){try{if(await t.getSlot({commitment:R})>S.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(qA/2)))}}return!0}}Ea.chunkSize=BM;const PM=new pt("BPFLoader2111111111111111111111111111111111");class MM{static getMinNumSignatures(t){return Ea.getMinNumSignatures(t)}static load(t,e,r,i,s){return Ea.load(t,e,r,s,i)}}function LM(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var yy,JA;function UM(){if(JA)return yy;JA=1;var n=Object.prototype.toString,t=Object.keys||function(r){var i=[];for(var s in r)i.push(s);return i};function e(r,i){var s,o,c,u,f,h,y;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return e(r.toJSON(),i);if(y=n.call(r),y==="[object Array]"){for(c="[",o=r.length-1,s=0;s<o;s++)c+=e(r[s],!0)+",";return o>-1&&(c+=e(r[s],!0)),c+"]"}else if(y==="[object Object]"){for(u=t(r).sort(),o=u.length,c="",s=0;s<o;)f=u[s],h=e(r[f],!1),h!==void 0&&(c&&(c+=","),c+=JSON.stringify(f)+":"+h),s++;return"{"+c+"}"}else return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return yy=function(r){var i=e(r,!1);if(i!==void 0)return""+i},yy}var DM=UM(),XA=LM(DM);const bf=32;function my(n){let t=0;for(;n>1;)n/=2,t++;return t}function FM(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class tE{constructor(t,e,r,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=my(FM(t+bf+1))-my(bf)-1,r=this.getSlotsInEpoch(e),i=t-(r-bf);return[e,i]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+r,s=e%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*bf:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+my(bf)):this.slotsPerEpoch}}var $M=globalThis.fetch;class HM extends jP{constructor(t,e,r){const i=s=>{const o=VP(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function zM(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const eE=56;class wy{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=zM(GM,t),r=t.length-eE;_e(r>=0,"lookup table is invalid"),_e(r%32===0,"lookup table is invalid");const i=r/32,{addresses:s}=Nt([Kn(ce(),i,"addresses")]).decode(t.slice(eE));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new pt(e.authority[0]):void 0,addresses:s.map(o=>new pt(o))}}}const GM={index:1,layout:Nt([Ot("typeIndex"),iu("deactivationSlot"),Vn("lastExtendedSlot"),me("lastExtendedStartIndex"),me(),Kn(ce(),fo(me(),-1),"authority")])},VM=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function KM(n){const t=n.match(VM);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,i,s]=t,o=n.startsWith("https:")?"wss:":"ws:",c=i==null?null:parseInt(i.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${r}${u}${s}`}const en=df(Jg(pt),yt(),n=>new pt(n)),nE=Xg([yt(),tn("base64")]),by=df(Jg(kt),nE,n=>kt.from(n[0],"base64")),rE=30*1e3;function jM(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function He(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...i}=n;t=r,e=i}return{commitment:t,config:e}}function iE(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function sE(n){return hr([ft({jsonrpc:tn("2.0"),id:yt(),result:n}),ft({jsonrpc:tn("2.0"),id:yt(),error:ft({code:eu(),message:yt(),data:Dt(yP())})})])}const WM=sE(eu());function ee(n){return df(sE(n),WM,t=>"error"in t?t:{...t,result:wt(t.result,n)})}function En(n){return ee(ft({context:ft({slot:X()}),value:n}))}function r0(n){return ft({context:ft({slot:X()}),value:n})}function _y(n,t){return n===0?new _a({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new pt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Tn.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new yi(t)}const ZM=ft({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),qM=ee(Et(vt(ft({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:Dt(vt(X()))})))),QM=Et(ft({slot:X(),prioritizationFee:X()})),YM=ft({total:X(),validator:X(),foundation:X(),epoch:X()}),JM=ft({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:Dt(X()),transactionCount:Dt(X())}),XM=ft({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:Fi(),firstNormalEpoch:X(),firstNormalSlot:X()}),tL=_A(yt(),Et(X())),va=vt(hr([ft({}),yt()])),eL=ft({err:va}),nL=tn("receivedSignature"),rL=ft({"solana-core":yt(),"feature-set":Dt(X())}),iL=ft({program:yt(),programId:en,parsed:eu()}),sL=ft({programId:en,accounts:Et(en),data:yt()}),oE=En(ft({err:vt(hr([ft({}),yt()])),logs:vt(Et(yt())),accounts:Dt(vt(Et(vt(ft({executable:Fi(),owner:yt(),lamports:X(),data:Et(yt()),rentEpoch:Dt(X())}))))),unitsConsumed:Dt(X()),returnData:Dt(vt(ft({programId:yt(),data:Xg([yt(),tn("base64")])}))),innerInstructions:Dt(vt(Et(ft({index:X(),instructions:Et(hr([iL,sL]))}))))})),oL=En(ft({byIdentity:_A(yt(),Et(X())),range:ft({firstSlot:X(),lastSlot:X()})}));function aL(n,t,e,r,i,s){const o=e||$M;let c;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return r&&(u=async(h,y)=>{const A=await new Promise((b,R)=>{try{r(h,y,(k,S)=>b([k,S]))}catch(k){R(k)}});return await o(...A)}),new HP(async(h,y)=>{const A={method:"POST",body:h,agent:c,headers:Object.assign({"Content-Type":"application/json"},t||{},aU)};try{let b=5,R,k=500;for(;u?R=await u(n,A):R=await o(n,A),!(R.status!==429||i===!0||(b-=1,b===0));)console.error(`Server responded with ${R.status} ${R.statusText}. Retrying after ${k}ms delay...`),await Aa(k),k*=2;const S=await R.text();R.ok?y(null,S):y(new Error(`${R.status} ${R.statusText}: ${S}`))}catch(b){b instanceof Error&&y(b)}},{})}function cL(n){return(t,e)=>new Promise((r,i)=>{n.request(t,e,(s,o)=>{if(s){i(s);return}r(o)})})}function uL(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const i=t.map(s=>n.request(s.methodName,s.args));n.request(i,(s,o)=>{if(s){r(s);return}e(o)})})}const lL=ee(ZM),fL=ee(YM),hL=ee(QM),dL=ee(JM),pL=ee(XM),gL=ee(tL),yL=ee(X()),mL=En(ft({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Et(en)})),Ay=ft({amount:yt(),uiAmount:vt(X()),decimals:X(),uiAmountString:Dt(yt())}),wL=En(Et(ft({address:en,amount:yt(),uiAmount:vt(X()),decimals:X(),uiAmountString:Dt(yt())}))),bL=En(Et(ft({pubkey:en,account:ft({executable:Fi(),owner:en,lamports:X(),data:by,rentEpoch:X()})}))),Ey=ft({program:yt(),parsed:eu(),space:X()}),_L=En(Et(ft({pubkey:en,account:ft({executable:Fi(),owner:en,lamports:X(),data:Ey,rentEpoch:X()})}))),AL=En(Et(ft({lamports:X(),address:en}))),_f=ft({executable:Fi(),owner:en,lamports:X(),data:by,rentEpoch:X()}),EL=ft({pubkey:en,account:_f}),vL=df(hr([Jg(kt),Ey]),hr([nE,Ey]),n=>Array.isArray(n)?wt(n,by):n),vy=ft({executable:Fi(),owner:en,lamports:X(),data:vL,rentEpoch:X()}),xL=ft({pubkey:en,account:vy}),RL=ft({state:hr([tn("active"),tn("inactive"),tn("activating"),tn("deactivating")]),active:X(),inactive:X()}),SL=ee(Et(ft({signature:yt(),slot:X(),err:va,memo:vt(yt()),blockTime:Dt(vt(X()))}))),IL=ee(Et(ft({signature:yt(),slot:X(),err:va,memo:vt(yt()),blockTime:Dt(vt(X()))}))),kL=ft({subscription:X(),result:r0(_f)}),TL=ft({pubkey:en,account:_f}),OL=ft({subscription:X(),result:r0(TL)}),NL=ft({parent:X(),slot:X(),root:X()}),CL=ft({subscription:X(),result:NL}),BL=hr([ft({type:hr([tn("firstShredReceived"),tn("completed"),tn("optimisticConfirmation"),tn("root")]),slot:X(),timestamp:X()}),ft({type:tn("createdBank"),parent:X(),slot:X(),timestamp:X()}),ft({type:tn("frozen"),slot:X(),timestamp:X(),stats:ft({numTransactionEntries:X(),numSuccessfulTransactions:X(),numFailedTransactions:X(),maxTransactionsPerEntry:X()})}),ft({type:tn("dead"),slot:X(),timestamp:X(),err:yt()})]),PL=ft({subscription:X(),result:BL}),ML=ft({subscription:X(),result:r0(hr([eL,nL]))}),LL=ft({subscription:X(),result:X()}),UL=ft({pubkey:yt(),gossip:vt(yt()),tpu:vt(yt()),rpc:vt(yt()),version:vt(yt())}),aE=ft({votePubkey:yt(),nodePubkey:yt(),activatedStake:X(),epochVoteAccount:Fi(),epochCredits:Et(Xg([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:vt(X())}),DL=ee(ft({current:Et(aE),delinquent:Et(aE)})),FL=hr([tn("processed"),tn("confirmed"),tn("finalized")]),$L=ft({slot:X(),confirmations:vt(X()),err:va,confirmationStatus:Dt(FL)}),HL=En(Et(vt($L))),zL=ee(X()),cE=ft({accountKey:en,writableIndexes:Et(X()),readonlyIndexes:Et(X())}),xy=ft({signatures:Et(yt()),message:ft({accountKeys:Et(yt()),header:ft({numRequiredSignatures:X(),numReadonlySignedAccounts:X(),numReadonlyUnsignedAccounts:X()}),instructions:Et(ft({accounts:Et(X()),data:yt(),programIdIndex:X()})),recentBlockhash:yt(),addressTableLookups:Dt(Et(cE))})}),uE=ft({pubkey:en,signer:Fi(),writable:Fi(),source:Dt(hr([tn("transaction"),tn("lookupTable")]))}),lE=ft({accountKeys:Et(uE),signatures:Et(yt())}),fE=ft({parsed:eu(),program:yt(),programId:en}),hE=ft({accounts:Et(en),data:yt(),programId:en}),GL=hr([hE,fE]),VL=hr([ft({parsed:eu(),program:yt(),programId:yt()}),ft({accounts:Et(yt()),data:yt(),programId:yt()})]),dE=df(GL,VL,n=>"accounts"in n?wt(n,hE):wt(n,fE)),pE=ft({signatures:Et(yt()),message:ft({accountKeys:Et(uE),instructions:Et(dE),recentBlockhash:yt(),addressTableLookups:Dt(vt(Et(cE)))})}),i0=ft({accountIndex:X(),mint:yt(),owner:Dt(yt()),programId:Dt(yt()),uiTokenAmount:Ay}),gE=ft({writable:Et(en),readonly:Et(en)}),s0=ft({err:va,fee:X(),innerInstructions:Dt(vt(Et(ft({index:X(),instructions:Et(ft({accounts:Et(X()),data:yt(),programIdIndex:X()}))})))),preBalances:Et(X()),postBalances:Et(X()),logMessages:Dt(vt(Et(yt()))),preTokenBalances:Dt(vt(Et(i0))),postTokenBalances:Dt(vt(Et(i0))),loadedAddresses:Dt(gE),computeUnitsConsumed:Dt(X())}),Ry=ft({err:va,fee:X(),innerInstructions:Dt(vt(Et(ft({index:X(),instructions:Et(dE)})))),preBalances:Et(X()),postBalances:Et(X()),logMessages:Dt(vt(Et(yt()))),preTokenBalances:Dt(vt(Et(i0))),postTokenBalances:Dt(vt(Et(i0))),loadedAddresses:Dt(gE),computeUnitsConsumed:Dt(X())}),su=hr([tn(0),tn("legacy")]),xa=ft({pubkey:yt(),lamports:X(),postBalance:vt(X()),rewardType:vt(yt()),commission:Dt(vt(X()))}),KL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(ft({transaction:xy,meta:vt(s0),version:Dt(su)})),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),jL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),WL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(ft({transaction:lE,meta:vt(s0),version:Dt(su)})),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),ZL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(ft({transaction:pE,meta:vt(Ry),version:Dt(su)})),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),qL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(ft({transaction:lE,meta:vt(Ry),version:Dt(su)})),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),QL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),rewards:Dt(Et(xa)),blockTime:vt(X()),blockHeight:vt(X())}))),YL=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(ft({transaction:xy,meta:vt(s0)})),rewards:Dt(Et(xa)),blockTime:vt(X())}))),yE=ee(vt(ft({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),signatures:Et(yt()),blockTime:vt(X())}))),Sy=ee(vt(ft({slot:X(),meta:vt(s0),blockTime:Dt(vt(X())),transaction:xy,version:Dt(su)}))),o0=ee(vt(ft({slot:X(),transaction:pE,meta:vt(Ry),blockTime:Dt(vt(X())),version:Dt(su)}))),JL=En(ft({blockhash:yt(),lastValidBlockHeight:X()})),XL=En(Fi()),tU=ft({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),eU=ee(Et(tU)),nU=En(vt(ft({feeCalculator:ft({lamportsPerSignature:X()})}))),rU=ee(yt()),iU=ee(yt()),sU=ft({err:va,logs:Et(yt()),signature:yt()}),oU=ft({result:r0(sU),subscription:X()}),aU={"solana-client":"js/1.0.0-maintenance"};class mE{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const f={};return async h=>{const{commitment:y,config:A}=He(h),b=this._buildArgs([],y,void 0,A),R=XA(b);return f[R]=f[R]??(async()=>{try{const k=await this._rpcRequest("getBlockHeight",b),S=wt(k,ee(X()));if("error"in S)throw new Mt(S.error,"failed to get block height information");return S.result}finally{delete f[R]}})(),await f[R]}})();let r,i,s,o,c,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,i=e.httpHeaders,s=e.fetch,o=e.fetchMiddleware,c=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=jM(t),this._rpcWsEndpoint=r||KM(t),this._rpcClient=aL(t,i,s,o,c,u),this._rpcRequest=cL(this._rpcClient),this._rpcBatchRequest=uL(this._rpcClient),this._rpcWebSocket=new HM(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgs([t.toBase58()],r,void 0,i),o=await this._rpcRequest("getBalance",s),c=wt(o,En(X()));if("error"in c)throw new Mt(c.error,`failed to get balance for ${t.toBase58()}`);return c.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=wt(e,ee(vt(X())));if("error"in r)throw new Mt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=wt(t,ee(X()));if("error"in e)throw new Mt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=wt(t,yL);if("error"in e)throw new Mt(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[e]),i=wt(r,mL);if("error"in i)throw new Mt(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",r),s=wt(i,En(Ay));if("error"in s)throw new Mt(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",r),s=wt(i,En(Ay));if("error"in s)throw new Mt(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,r){const{commitment:i,config:s}=He(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const c=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",c),f=wt(u,bL);if("error"in f)throw new Mt(f.error,`failed to get token accounts owned by account ${t.toBase58()}`);return f.result}async getParsedTokenAccountsByOwner(t,e,r){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const s=this._buildArgs(i,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),c=wt(o,_L);if("error"in c)throw new Mt(c.error,`failed to get token accounts owned by account ${t.toBase58()}`);return c.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",r),s=wt(i,AL);if("error"in s)throw new Mt(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",r),s=wt(i,wL);if("error"in s)throw new Mt(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgs([t.toBase58()],r,"base64",i),o=await this._rpcRequest("getAccountInfo",s),c=wt(o,En(vt(_f)));if("error"in c)throw new Mt(c.error,`failed to get info about account ${t.toBase58()}`);return c.result}async getParsedAccountInfo(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),c=wt(o,En(vt(vy)));if("error"in c)throw new Mt(c.error,`failed to get info about account ${t.toBase58()}`);return c.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:i}=He(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"jsonParsed",i),c=await this._rpcRequest("getMultipleAccounts",o),u=wt(c,En(Et(vt(vy))));if("error"in u)throw new Mt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:i}=He(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"base64",i),c=await this._rpcRequest("getMultipleAccounts",o),u=wt(c,En(Et(vt(_f))));if("error"in u)throw new Mt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:i,config:s}=He(e),o=this._buildArgs([t.toBase58()],i,void 0,{...s,epoch:r??(s==null?void 0:s.epoch)}),c=await this._rpcRequest("getStakeActivation",o),u=wt(c,ee(RL));if("error"in u)throw new Mt(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:r,config:i}=He(e),{encoding:s,...o}=i||{},c=this._buildArgs([t.toBase58()],r,s||"base64",{...o,...o.filters?{filters:iE(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),f=Et(EL),h=o.withContext===!0?wt(u,En(f)):wt(u,ee(f));if("error"in h)throw new Mt(h.error,`failed to get accounts owned by program ${t.toBase58()}`);return h.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),c=wt(o,ee(Et(xL)));if("error"in c)throw new Mt(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result}async confirmTransaction(t,e){var s;let r;if(typeof t=="string")r=t;else{const o=t;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let i;try{i=Tn.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return _e(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,i,s=!1;const o=new Promise((u,f)=>{try{r=this.onSignature(e,(y,A)=>{r=void 0;const b={context:A,value:y};u({__type:Es.PROCESSED,response:b})},t);const h=new Promise(y=>{r==null?y():i=this._onSubscriptionStateChange(r,A=>{A==="subscribed"&&y()})});(async()=>{if(await h,s)return;const y=await this.getSignatureStatus(e);if(s||y==null)return;const{context:A,value:b}=y;if(b!=null)if(b!=null&&b.err)f(b.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(b.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(b.confirmationStatus==="processed"||b.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:Es.PROCESSED,response:{context:A,value:b}})}})()}catch(h){f(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:i}}){let s=!1;const o=new Promise(y=>{const A=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let b=await A();if(!s){for(;b<=r;)if(await Aa(1e3),s||(b=await A(),s))return;y({__type:Es.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),f=this.getCancellationPromise(e);let h;try{const y=await Promise.race([f,u,o]);if(y.__type===Es.PROCESSED)h=y.response;else throw new uy(i)}finally{s=!0,c()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let c=!1;const u=new Promise(b=>{let R=s,k=null;const S=async()=>{try{const{context:B,value:H}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:r});return k=B.slot,H==null?void 0:H.nonce}catch{return R}};(async()=>{if(R=await S(),!c)for(;;){if(s!==R){b({__type:Es.NONCE_INVALID,slotInWhichNonceDidAdvance:k});return}if(await Aa(2e3),c||(R=await S(),c))return}})()}),{abortConfirmation:f,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),y=this.getCancellationPromise(e);let A;try{const b=await Promise.race([y,h,u]);if(b.__type===Es.PROCESSED)A=b.response;else{let R;for(;;){const k=await this.getSignatureStatus(o);if(k==null)break;if(k.context.slot<(b.slotInWhichNonceDidAdvance??r)){await Aa(400);continue}R=k;break}if(R!=null&&R.value){const k=t||"finalized",{confirmationStatus:S}=R.value;switch(k){case"processed":case"recent":if(S!=="processed"&&S!=="confirmed"&&S!=="finalized")throw new nu(o);break;case"confirmed":case"single":case"singleGossip":if(S!=="confirmed"&&S!=="finalized")throw new nu(o);break;case"finalized":case"max":case"root":if(S!=="finalized")throw new nu(o);break;default:}A={context:R.context,value:{err:R.value.err}}}else throw new nu(o)}}finally{c=!0,f()}return A}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const i=new Promise(u=>{let f=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{f=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>u({__type:Es.TIMED_OUT,timeoutMs:f}),f)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let c;try{const u=await Promise.race([o,i]);if(u.__type===Es.PROCESSED)c=u.response;else throw new ly(e,u.timeoutMs/1e3)}finally{clearTimeout(r),s()}return c}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=wt(t,ee(Et(UL)));if("error"in e)throw new Mt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),i=wt(r,DL);if("error"in i)throw new Mt(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlot",i),o=wt(s,ee(X()));if("error"in o)throw new Mt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlotLeader",i),o=wt(s,ee(yt()));if("error"in o)throw new Mt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],i=await this._rpcRequest("getSlotLeaders",r),s=wt(i,ee(Et(en)));if("error"in s)throw new Mt(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:r,value:i}=await this.getSignatureStatuses([t],e);_e(i.length===1);const s=i[0];return{context:r,value:s}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const i=await this._rpcRequest("getSignatureStatuses",r),s=wt(i,HL);if("error"in s)throw new Mt(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getTransactionCount",i),o=wt(s,ee(X()));if("error"in o)throw new Mt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),i=wt(r,lL);if("error"in i)throw new Mt(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,r){const{commitment:i,config:s}=He(r),o=this._buildArgs([t.map(f=>f.toBase58())],i,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),c=await this._rpcRequest("getInflationReward",o),u=wt(c,qM);if("error"in u)throw new Mt(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=wt(t,fL);if("error"in e)throw new Mt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getEpochInfo",i),o=wt(s,dL);if("error"in o)throw new Mt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=wt(t,pL);if("error"in e)throw new Mt(e.error,"failed to get epoch schedule");const r=e.result;return new tE(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=wt(t,gL);if("error"in e)throw new Mt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=wt(i,zL);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=wt(e,eU);if("error"in r)throw new Mt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=wt(i,nU);if("error"in s)throw new Mt(s.error,"failed to get fee calculator");const{context:o,value:c}=s.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(t,e){const r=te(t.serialize()).toString("base64"),i=this._buildArgs([r],e),s=await this._rpcRequest("getFeeForMessage",i),o=wt(s,En(vt(X())));if("error"in o)throw new Mt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(c=>c.toBase58()),r=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=wt(i,hL);if("error"in s)throw new Mt(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),o=wt(s,JL);if("error"in o)throw new Mt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgs([t],r,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),c=wt(o,XL);if("error"in c)throw new Mt(c.error,"failed to determine if the blockhash `"+t+"`is valid");return c.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=wt(t,ee(rL));if("error"in e)throw new Mt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=wt(t,ee(yt()));if("error"in e)throw new Mt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const c=wt(o,WL);if("error"in c)throw c.error;return c.result}case"none":{const c=wt(o,jL);if("error"in c)throw c.error;return c.result}default:{const c=wt(o,KL);if("error"in c)throw c.error;const{result:u}=c;return u?{...u,transactions:u.transactions.map(({transaction:f,meta:h,version:y})=>({meta:h,transaction:{...f,message:_y(y,f.message)},version:y}))}:null}}}catch(c){throw new Mt(c,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const c=wt(o,qL);if("error"in c)throw c.error;return c.result}case"none":{const c=wt(o,QL);if("error"in c)throw c.error;return c.result}default:{const c=wt(o,ZL);if("error"in c)throw c.error;return c.result}}}catch(c){throw new Mt(c,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:c,...u}=t;r=c,e=u}const i=this._buildArgs([],r,"base64",e),s=await this._rpcRequest("getBlockProduction",i),o=wt(s,oL);if("error"in o)throw new Mt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getTransaction",s),c=wt(o,Sy);if("error"in c)throw new Mt(c.error,"failed to get transaction");const u=c.result;return u&&{...u,transaction:{...u.transaction,message:_y(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:i}=He(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),c=wt(o,o0);if("error"in c)throw new Mt(c.error,"failed to get transaction");return c.result}async getParsedTransactions(t,e){const{commitment:r,config:i}=He(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=wt(u,o0);if("error"in f)throw new Mt(f.error,"failed to get transactions");return f.result})}async getTransactions(t,e){const{commitment:r,config:i}=He(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=wt(u,Sy);if("error"in f)throw new Mt(f.error,"failed to get transactions");const h=f.result;return h&&{...h,transaction:{...h.transaction,message:_y(h.version,h.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",r),s=wt(i,YL);if("error"in s)throw new Mt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");const c={...o,transactions:o.transactions.map(({transaction:u,meta:f})=>{const h=new yi(u.message);return{meta:f,transaction:{...u,message:h}}})};return{...c,transactions:c.transactions.map(({transaction:u,meta:f})=>({meta:f,transaction:Oe.populate(u.message,u.signatures)}))}}async getBlocks(t,e,r){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),s=await this._rpcRequest("getBlocks",i),o=wt(s,ee(Et(X())));if("error"in o)throw new Mt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=wt(i,yE);if("error"in s)throw new Mt(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=wt(i,yE);if("error"in s)throw new Mt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",r),s=wt(i,Sy);if("error"in s)throw new Mt(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const c=new yi(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Oe.populate(c,u)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=wt(i,o0);if("error"in s)throw new Mt(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const c=wt(o,o0);if("error"in c)throw new Mt(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(t,e,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<s));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(r++,!(r>o));)try{const u=await this.getConfirmedBlockSignatures(r);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=wt(s,SL);if("error"in o)throw new Mt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",i),o=wt(s,IL);if("error"in o)throw new Mt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=new wy({key:t,state:wy.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=n0.fromAccountData(i.data)),{context:r,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=wt(r,rU);if("error"in i)throw new Mt(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Aa(100);const r=Date.now()-this._blockhashInfo.lastFetch>=rE;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(r!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Aa(qA/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=He(t),i=this._buildArgs([],e,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=wt(s,En(X()));if("error"in o)throw new Mt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const k=t.serialize(),S=kt.from(k).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const B=e||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(B.innerInstructions=e.innerInstructions);const H=[S,B],U=await this._rpcRequest("simulateTransaction",H),G=wt(U,oE);if("error"in G)throw new Error("failed to simulate transaction: "+G.error.message);return G.result}let i;if(t instanceof Oe){let R=t;i=new Oe,i.feePayer=R.feePayer,i.instructions=t.instructions,i.nonceInfo=R.nonceInfo,i.signatures=R.signatures}else i=Oe.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(i.nonceInfo&&s)i.sign(...s);else{let R=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(R);if(i.lastValidBlockHeight=k.lastValidBlockHeight,i.recentBlockhash=k.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const S=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(S)&&!this._blockhashInfo.transactionSignatures.includes(S)){this._blockhashInfo.simulatedSignatures.push(S);break}else R=!0}}const o=i._compile(),c=o.serialize(),f=i._serialize(c).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(r){const R=(Array.isArray(r)?r:o.nonProgramIds()).map(k=>k.toBase58());h.accounts={encoding:"base64",addresses:R}}s&&(h.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(h.innerInstructions=e.innerInstructions);const y=[f,h],A=await this._rpcRequest("simulateTransaction",y),b=wt(A,oE);if("error"in b){let R;if("data"in b.error&&(R=b.error.data.logs,R&&Array.isArray(R))){const k=`
23
- `,S=k+R.join(k);console.error(b.error.message,S)}throw new go({action:"simulate",signature:"",transactionMessage:b.error.message,logs:R})}return b.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const c=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=c.lastValidBlockHeight,t.recentBlockhash=c.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=t.serialize();return await this.sendRawTransaction(s,r)}async sendRawTransaction(t,e){const r=te(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},i=e&&e.skipPreflight,s=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),i&&(r.skipPreflight=i),s&&(r.preflightCommitment=s);const o=[t,r],c=await this._rpcRequest("sendTransaction",o),u=wt(c,iU);if("error"in u){let f;throw"data"in u.error&&(f=u.error.data.logs),new go({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:f})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var i;const r=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[r]||(s[r]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const c=await this._rpcWebSocket.call(o,s);this._setSubscription(r,{...i,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=i.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:c}),!e())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!e())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(i=>{try{i(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=wt(t,kL);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,i=XA([t.method,e]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[i];_e(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:i,config:s}=He(r),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=wt(t,OL);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,i){const{commitment:s,config:o}=He(r),c=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:iE(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=wt(t,oU);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=wt(t,CL);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=wt(t,PL);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,i){const s=e||this._commitment;if(s||r||i){let o={};r&&(o.encoding=r),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,i){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,i)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=wt(t,ML);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const i=this._buildArgs([t],r||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){e(o.result,c);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(t,e,r){const{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,s),c=this._makeSubscription({callback:(u,f)=>{e(u,f);try{this.removeSignatureListener(c)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=wt(t,LL);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Ra{constructor(t){this._keypair=void 0,this._keypair=t??zA()}static generate(){return new Ra(zA())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const i=t.slice(0,32),s=Yd(i);for(let o=0;o<32;o++)if(r[o]!==s[o])throw new Error("provided secretKey is invalid")}return new Ra({publicKey:r,secretKey:t})}static fromSeed(t){const e=Yd(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Ra({publicKey:e,secretKey:r})}get publicKey(){return new pt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const vs=Object.freeze({CreateLookupTable:{index:0,layout:Nt([Ot("instruction"),iu("recentSlot"),me("bumpSeed")])},FreezeLookupTable:{index:1,layout:Nt([Ot("instruction")])},ExtendLookupTable:{index:2,layout:Nt([Ot("instruction"),iu(),Kn(ce(),fo(Ot(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Nt([Ot("instruction")])},CloseLookupTable:{index:4,layout:Nt([Ot("instruction")])}});class cU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(vs))if(o.index==r){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ie(vs.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Ie(vs.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(r=>new pt(r))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Iy.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class Iy{constructor(){}static createLookupTable(t){const[e,r]=pt.findProgramAddressSync([t.authority.toBuffer(),yA(BigInt(t.recentSlot),8)],this.programId),i=vs.CreateLookupTable,s=pe(i,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Nn.programId,isSigner:!1,isWritable:!1}];return[new Pe({programId:this.programId,keys:o,data:s}),e]}static freezeLookupTable(t){const e=vs.FreezeLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pe({programId:this.programId,keys:i,data:r})}static extendLookupTable(t){const e=vs.ExtendLookupTable,r=pe(e,{addresses:t.addresses.map(s=>s.toBytes())}),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&i.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Nn.programId,isSigner:!1,isWritable:!1}),new Pe({programId:this.programId,keys:i,data:r})}static deactivateLookupTable(t){const e=vs.DeactivateLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pe({programId:this.programId,keys:i,data:r})}static closeLookupTable(t){const e=vs.CloseLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Pe({programId:this.programId,keys:i,data:r})}}Iy.programId=new pt("AddressLookupTab1e1111111111111111111111111");class uU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=me("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Gi))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ie(Gi.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ie(Gi.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ie(Gi.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ie(Gi.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(ky.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Gi=Object.freeze({RequestUnits:{index:0,layout:Nt([me("instruction"),Ot("units"),Ot("additionalFee")])},RequestHeapFrame:{index:1,layout:Nt([me("instruction"),Ot("bytes")])},SetComputeUnitLimit:{index:2,layout:Nt([me("instruction"),Ot("units")])},SetComputeUnitPrice:{index:3,layout:Nt([me("instruction"),iu("microLamports")])}});class ky{constructor(){}static requestUnits(t){const e=Gi.RequestUnits,r=pe(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Gi.RequestHeapFrame,r=pe(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Gi.SetComputeUnitLimit,r=pe(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Gi.SetComputeUnitPrice,r=pe(e,{microLamports:BigInt(t.microLamports)});return new Pe({keys:[],programId:this.programId,data:r})}}ky.programId=new pt("ComputeBudget111111111111111111111111111111");const wE=64,bE=32,_E=64,AE=Nt([me("numSignatures"),me("padding"),Jr("signatureOffset"),Jr("signatureInstructionIndex"),Jr("publicKeyOffset"),Jr("publicKeyInstructionIndex"),Jr("messageDataOffset"),Jr("messageDataSize"),Jr("messageInstructionIndex")]);class a0{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:s}=t;_e(e.length===bE,`Public Key must be ${bE} bytes but received ${e.length} bytes`),_e(i.length===_E,`Signature must be ${_E} bytes but received ${i.length} bytes`);const o=AE.span,c=o+e.length,u=c+i.length,f=1,h=kt.alloc(u+r.length),y=s??65535;return AE.encode({numSignatures:f,padding:0,signatureOffset:c,signatureInstructionIndex:y,publicKeyOffset:o,publicKeyInstructionIndex:y,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:y},h),h.fill(e,o),h.fill(i,c),h.fill(r,u),new Pe({keys:[],programId:a0.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;_e(e.length===wE,`Private key must be ${wE} bytes but received ${e.length} bytes`);try{const s=Ra.fromSecretKey(e),o=s.publicKey.toBytes(),c=ay(r,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:c,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}a0.programId=new pt("Ed25519SigVerify111111111111111111111111111");const lU=(n,t)=>{const e=Qd.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};Qd.utils.isValidPrivateKey;const fU=Qd.getPublicKey,EE=32,Ty=20,vE=64,hU=11,Oy=Nt([me("numSignatures"),Jr("signatureOffset"),me("signatureInstructionIndex"),Jr("ethAddressOffset"),me("ethAddressInstructionIndex"),Jr("messageDataOffset"),Jr("messageDataSize"),me("messageInstructionIndex"),je(20,"ethAddress"),je(64,"signature"),me("recoveryId")]);class ou{constructor(){}static publicKeyToEthAddress(t){_e(t.length===vE,`Public key must be ${vE} bytes but received ${t.length} bytes`);try{return kt.from(PA(te(t))).slice(-Ty)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,recoveryId:s,instructionIndex:o}=t;return ou.createInstructionWithEthAddress({ethAddress:ou.publicKeyToEthAddress(e),message:r,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:s,instructionIndex:o=0}=t;let c;typeof e=="string"?e.startsWith("0x")?c=kt.from(e.substr(2),"hex"):c=kt.from(e,"hex"):c=e,_e(c.length===Ty,`Address must be ${Ty} bytes but received ${c.length} bytes`);const u=1+hU,f=u,h=u+c.length,y=h+i.length+1,A=1,b=kt.alloc(Oy.span+r.length);return Oy.encode({numSignatures:A,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:f,ethAddressInstructionIndex:o,messageDataOffset:y,messageDataSize:r.length,messageInstructionIndex:o,signature:te(i),ethAddress:te(c),recoveryId:s},b),b.fill(te(r),Oy.span),new Pe({keys:[],programId:ou.programId,data:b})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;_e(e.length===EE,`Private key must be ${EE} bytes but received ${e.length} bytes`);try{const s=te(e),o=fU(s,!1).slice(1),c=kt.from(PA(te(r))),[u,f]=lU(c,s);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,recoveryId:f,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ou.programId=new pt("KeccakSecp256k11111111111111111111111111111");var xE;const RE=new pt("StakeConfig11111111111111111111111111111111");class SE{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Af{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}xE=Af,Af.default=new xE(0,0,pt.default);class dU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Mn))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ie(Mn.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new SE(new pt(e.staker),new pt(e.withdrawer)),lockup:new Af(r.unixTimestamp,r.epoch,new pt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ie(Mn.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=Ie(Mn.Authorize,t.data),i={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(i.custodianPubkey=t.keys[3].pubkey),i}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:i,authorityOwner:s}=Ie(Mn.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:i,authorityOwner:new pt(s),newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ie(Mn.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ie(Mn.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ie(Mn.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ie(Mn.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(c0.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Mn=Object.freeze({Initialize:{index:0,layout:Nt([Ot("instruction"),_M(),AM()])},Authorize:{index:1,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("stakeAuthorizationType")])},Delegate:{index:2,layout:Nt([Ot("instruction")])},Split:{index:3,layout:Nt([Ot("instruction"),Ur("lamports")])},Withdraw:{index:4,layout:Nt([Ot("instruction"),Ur("lamports")])},Deactivate:{index:5,layout:Nt([Ot("instruction")])},Merge:{index:7,layout:Nt([Ot("instruction")])},AuthorizeWithSeed:{index:8,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("stakeAuthorizationType"),ba("authoritySeed"),ce("authorityOwner")])}}),pU=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class c0{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:i}=t,s=i||Af.default,o=Mn.Initialize,c=pe(o,{authorized:{staker:te(r.staker.toBuffer()),withdrawer:te(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:te(s.custodian.toBuffer())}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ru,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Pe(u)}static createAccountWithSeed(t){const e=new Oe;e.add(Nn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(t){const e=new Oe;e.add(Nn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:i}=t,s=Mn.Delegate,o=pe(s);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:e0,isSigner:!1,isWritable:!1},{pubkey:RE,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=t,c=Mn.Authorize,u=pe(c,{newAuthorized:te(i.toBuffer()),stakeAuthorizationType:s.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=t,f=Mn.AuthorizeWithSeed,h=pe(f,{newAuthorized:te(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:i,authorityOwner:te(s.toBuffer())}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1}];return u&&y.push({pubkey:u,isSigner:!0,isWritable:!1}),new Oe().add({keys:y,programId:this.programId,data:h})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=t,o=Mn.Split,c=pe(o,{lamports:s});return new Pe({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:c})}static split(t,e){const r=new Oe;return r.add(Nn.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:c,lamports:u}=t,f=new Oe;return f.add(Nn.allocate({accountPubkey:s,basePubkey:o,seed:c,space:this.space,programId:this.programId})),e&&e>0&&f.add(Nn.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),f.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:i}=t,s=Mn.Merge,o=pe(s);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:e0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:o}=t,c=Mn.Withdraw,u=pe(c,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:e0,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:f,programId:this.programId,data:u})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,i=Mn.Deactivate,s=pe(i);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}c0.programId=new pt("Stake11111111111111111111111111111111111111"),c0.space=200;class IE{constructor(t,e,r,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=i}}class gU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Vi))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ie(Vi.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new IE(new pt(e.nodePubkey),new pt(e.authorizedVoter),new pt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ie(Vi.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:i,voteAuthorizationType:s}}=Ie(Vi.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new pt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new pt(i),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ie(Vi.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(au.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Vi=Object.freeze({InitializeAccount:{index:0,layout:Nt([Ot("instruction"),EM()])},Authorize:{index:1,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("voteAuthorizationType")])},Withdraw:{index:3,layout:Nt([Ot("instruction"),Ur("lamports")])},UpdateValidatorIdentity:{index:4,layout:Nt([Ot("instruction")])},AuthorizeWithSeed:{index:10,layout:Nt([Ot("instruction"),vM()])}}),yU=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class au{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:i}=t,s=Vi.InitializeAccount,o=pe(s,{voteInit:{nodePubkey:te(i.nodePubkey.toBuffer()),authorizedVoter:te(i.authorizedVoter.toBuffer()),authorizedWithdrawer:te(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),c={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ru,isSigner:!1,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pe(c)}static createAccount(t){const e=new Oe;return e.add(Nn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:s}=t,o=Vi.Authorize,c=pe(o,{newAuthorized:te(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:u,programId:this.programId,data:c})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:c}=t,u=Vi.AuthorizeWithSeed,f=pe(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:te(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:te(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Oe().add({keys:h,programId:this.programId,data:f})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=t,o=Vi.Withdraw,c=pe(o,{lamports:i}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:u,programId:this.programId,data:c})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return au.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:i}=t,s=Vi.UpdateValidatorIdentity,o=pe(s),c=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:c,programId:this.programId,data:o})}}au.programId=new pt("Vote111111111111111111111111111111111111111"),au.space=3762;const kE=new pt("Va1idator1nfo111111111111111111111111111111"),mU=ft({name:yt(),website:Dt(yt()),details:Dt(yt()),iconUrl:Dt(yt()),keybaseUsername:Dt(yt())});class Ny{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(vr(e)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new pt(xr(e,0,$i)),c=Hi(e)===1;i.push({publicKey:o,isSigner:c})}if(i[0].publicKey.equals(kE)&&i[1].isSigner){const s=ba().decode(kt.from(e)),o=JSON.parse(s);return wA(o,mU),new Ny(i[1].publicKey,o)}return null}}const wU=new pt("Vote111111111111111111111111111111111111111"),bU=Nt([ce("nodePubkey"),ce("authorizedWithdrawer"),me("commission"),Vn(),Kn(Nt([Vn("slot"),Ot("confirmationCount")]),fo(Ot(),-8),"votes"),me("rootSlotValid"),Vn("rootSlot"),Vn(),Kn(Nt([Vn("epoch"),ce("authorizedVoter")]),fo(Ot(),-8),"authorizedVoters"),Nt([Kn(Nt([ce("authorizedPubkey"),Vn("epochOfLastAuthorizedSwitch"),Vn("targetEpoch")]),32,"buf"),Vn("idx"),me("isEmpty")],"priorVoters"),Vn(),Kn(Nt([Vn("epoch"),Vn("credits"),Vn("prevCredits")]),fo(Ot(),-8),"epochCredits"),Nt([Vn("slot"),Vn("timestamp")],"lastTimestamp")]);class Cy{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const r=bU.decode(te(t),4);let i=r.rootSlot;return r.rootSlotValid||(i=null),new Cy({nodePubkey:new pt(r.nodePubkey),authorizedWithdrawer:new pt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:i,authorizedVoters:r.authorizedVoters.map(_U),priorVoters:AU(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function _U({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new pt(n)}}function TE({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new pt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function AU({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(TE),...n.slice(0,t).map(TE)]}const OE={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function EU(n,t){const e=t===!1?"http":"https";if(!n)return OE[e].devnet;const r=OE[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function vU(n,t,e,r){let i,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(i=e,s=r):s=e;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},c=await n.sendRawTransaction(t,o),u=s&&s.commitment,h=(await(i?n.confirmTransaction(i,u):n.confirmTransaction(c,u))).value;if(h.err)throw c!=null?new go({action:o!=null&&o.skipPreflight?"send":"simulate",signature:c,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${c} failed (${JSON.stringify(h)})`);return c}const xU=Object.freeze(Object.defineProperty({__proto__:null,Account:mM,AddressLookupTableAccount:wy,AddressLookupTableInstruction:cU,AddressLookupTableProgram:Iy,Authorized:SE,BLOCKHASH_CACHE_TIMEOUT_MS:rE,BPF_LOADER_DEPRECATED_PROGRAM_ID:wM,BPF_LOADER_PROGRAM_ID:PM,BpfLoader:MM,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Gi,ComputeBudgetInstruction:uU,ComputeBudgetProgram:ky,Connection:mE,Ed25519Program:a0,Enum:gM,EpochSchedule:tE,FeeCalculatorLayout:QA,Keypair:Ra,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:vs,Loader:Ea,Lockup:Af,MAX_SEED_LENGTH:KA,Message:yi,MessageAccountKeys:wf,MessageV0:_a,NONCE_ACCOUNT_LENGTH:gy,NonceAccount:n0,PACKET_DATA_SIZE:po,PUBLIC_KEY_LENGTH:$i,PublicKey:pt,SIGNATURE_LENGTH_IN_BYTES:mf,SOLANA_SCHEMA:yf,STAKE_CONFIG_ID:RE,STAKE_INSTRUCTION_LAYOUTS:Mn,SYSTEM_INSTRUCTION_LAYOUTS:$e,SYSVAR_CLOCK_PUBKEY:zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:RM,SYSVAR_INSTRUCTIONS_PUBKEY:SM,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:t0,SYSVAR_RENT_PUBKEY:ru,SYSVAR_REWARDS_PUBKEY:IM,SYSVAR_SLOT_HASHES_PUBKEY:kM,SYSVAR_SLOT_HISTORY_PUBKEY:TM,SYSVAR_STAKE_HISTORY_PUBKEY:e0,Secp256k1Program:ou,SendTransactionError:go,SolanaJSONRPCError:Mt,SolanaJSONRPCErrorCode:OM,StakeAuthorizationLayout:pU,StakeInstruction:dU,StakeProgram:c0,Struct:cy,SystemInstruction:CM,SystemProgram:Nn,Transaction:Oe,TransactionExpiredBlockheightExceededError:uy,TransactionExpiredNonceInvalidError:nu,TransactionExpiredTimeoutError:ly,TransactionInstruction:Pe,TransactionMessage:hy,TransactionStatus:Es,VALIDATOR_INFO_KEY:kE,VERSION_PREFIX_MASK:Jd,VOTE_PROGRAM_ID:wU,ValidatorInfo:Ny,VersionedMessage:fy,VersionedTransaction:dy,VoteAccount:Cy,VoteAuthorizationLayout:yU,VoteInit:IE,VoteInstruction:gU,VoteProgram:au,clusterApiUrl:EU,sendAndConfirmRawTransaction:vU,sendAndConfirmTransaction:py},Symbol.toStringTag,{value:"Module"}));var By={exports:{}};const RU=/[\p{Lu}]/u,SU=/[\p{Ll}]/u,NE=/^[\p{Lu}](?![\p{Lu}])/gu,CE=/([\p{Alpha}\p{N}_]|$)/u,BE=/[_.\- ]+/,IU=new RegExp("^"+BE.source),PE=new RegExp(BE.source+CE.source,"gu"),ME=new RegExp("\\d+"+CE.source,"gu"),kU=(n,t,e)=>{let r=!1,i=!1,s=!1;for(let o=0;o<n.length;o++){const c=n[o];r&&RU.test(c)?(n=n.slice(0,o)+"-"+n.slice(o),r=!1,s=i,i=!0,o++):i&&s&&SU.test(c)?(n=n.slice(0,o-1)+"-"+n.slice(o-1),s=i,i=!1,r=!0):(r=t(c)===c&&e(c)!==c,s=i,i=e(c)===c&&t(c)!==c)}return n},TU=(n,t)=>(NE.lastIndex=0,n.replace(NE,e=>t(e))),OU=(n,t)=>(PE.lastIndex=0,ME.lastIndex=0,n.replace(PE,(e,r)=>t(r)).replace(ME,e=>t(e))),LE=(n,t)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";const e=t.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(t.locale),r=t.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(t.locale);return n.length===1?t.pascalCase?r(n):e(n):(n!==e(n)&&(n=kU(n,e,r)),n=n.replace(IU,""),t.preserveConsecutiveUppercase?n=TU(n,e):n=e(n),t.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),OU(n,r))};By.exports=LE,By.exports.default=LE;var NU=By.exports;const CU=Br(NU);var Yt={},Rt={};let Ne=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};Rt.Layout=Ne;function Py(n,t){return t.property?n+"["+t.property+"]":n}Rt.nameWithProperty=Py;function BU(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(n.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Ne))throw new TypeError("layout must be a Layout");if(t.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value:function(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value:function(e,r){return t.decode(e,r)},writable:!0})}Rt.bindConstructorLayout=BU;let Rr=class extends Ne{isCount(){throw new Error("ExternalLayout is abstract")}};class UE extends Rr{constructor(t,e){if(t===void 0&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){e===void 0&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}let My=class extends Rr{constructor(t,e,r){if(!(t instanceof Ne))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Ki||this.layout instanceof xs}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}},Ki=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}},xs=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}};class Sa extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class cu extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Ly=Math.pow(2,32);function u0(n){const t=Math.floor(n/Ly),e=n-t*Ly;return{hi32:t,lo32:e}}function l0(n,t){return n*Ly+t}let PU=class extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return l0(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=u0(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}};class MU extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return l0(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=u0(t);return e.writeUInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}let LU=class extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return l0(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=u0(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}};class UU extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readInt32BE(e),i=t.readUInt32BE(e+4);return l0(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=u0(t);return e.writeInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}class DE extends Ne{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatLE(t,r),4}}class FE extends Ne{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatBE(t,r),4}}class $E extends Ne{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleLE(t,r),8}}class HE extends Ne{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleBE(t,r),8}}class zE extends Ne{constructor(t,e,r){if(!(t instanceof Ne))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Rr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Rr)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0,i=this.count;if(i instanceof Rr&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e){e===void 0&&(e=0);const r=[];let i=0,s=this.count;for(s instanceof Rr&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r){r===void 0&&(r=0);const i=this.elementLayout,s=t.reduce((o,c)=>o+i.encode(c,e,r+o),0);return this.count instanceof Rr&&this.count.encode(t.length,e,r),s}}let GE=class extends Ne{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ne,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}},Uy=class{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},f0=class extends Uy{constructor(t,e){if(!(t instanceof Rr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}},Dy=class extends Ne{constructor(t,e,r){const i=t instanceof Ki||t instanceof xs;if(i)t=new f0(new My(t));else if(t instanceof Rr&&t.isCount())t=new f0(t);else if(!(t instanceof Uy))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ne))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let c=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(c=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+c)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new VE(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}},VE=class extends Ne{constructor(t,e,r,i){if(!(t instanceof Dy))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ne))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};function uu(n){return 0>n&&(n+=4294967296),n}class Fy extends Ne{constructor(t,e,r){if(!(t instanceof Ki||t instanceof xs))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=uu(s),this},this._packedGetValue=function(){return i}}decode(t,e){const r=this.makeDestinationObject();e===void 0&&(e=0);const i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(i));return r}encode(t,e,r){r===void 0&&(r=0);const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Ef(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new KE(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class Ef{constructor(t,e,r){if(!(t instanceof Fy))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,c)=>o+c.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=uu(this.valueMask<<this.start),this.property=r}decode(){const t=this.container._packedGetValue();return uu(t&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==uu(t&this.valueMask))throw new TypeError(Py("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=uu(t<<this.start);this.container._packedSetValue(uu(e&~this.wordMask)|r)}}let KE=class extends Ef{constructor(t,e){super(t,1,e)}decode(t,e){return!!Ef.prototype.decode.call(this,t,e)}encode(t){return typeof t=="boolean"&&(t=+t),Ef.prototype.encode.call(this,t)}},jE=class extends Ne{constructor(t,e){if(!(t instanceof Rr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Rr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Rr&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(Py("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Rr&&this.length.encode(i,e,r),i}};class WE extends Ne{constructor(t){super(-1,t)}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");e===void 0&&(e=0);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);return t.slice(e,e+i-1).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),e[r+s]=0,s+1}}class ZE extends Ne{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");return e===void 0&&(e=0),t.length-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+i).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),s}}class qE extends Ne{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}Rt.ExternalLayout=Rr,Rt.GreedyCount=UE,Rt.OffsetLayout=My,Rt.UInt=Ki,Rt.UIntBE=xs,Rt.Int=Sa,Rt.IntBE=cu,Rt.Float=DE,Rt.FloatBE=FE,Rt.Double=$E,Rt.DoubleBE=HE,Rt.Sequence=zE,Rt.Structure=GE,Rt.UnionDiscriminator=Uy,Rt.UnionLayoutDiscriminator=f0,Rt.Union=Dy,Rt.VariantLayout=VE,Rt.BitStructure=Fy,Rt.BitField=Ef,Rt.Boolean=KE,Rt.Blob=jE,Rt.CString=WE,Rt.UTF8=ZE,Rt.Constant=qE,Rt.greedy=(n,t)=>new UE(n,t),Rt.offset=(n,t,e)=>new My(n,t,e),Rt.u8=n=>new Ki(1,n),Rt.u16=n=>new Ki(2,n),Rt.u24=n=>new Ki(3,n),Rt.u32=n=>new Ki(4,n),Rt.u40=n=>new Ki(5,n),Rt.u48=n=>new Ki(6,n),Rt.nu64=n=>new PU(n),Rt.u16be=n=>new xs(2,n),Rt.u24be=n=>new xs(3,n),Rt.u32be=n=>new xs(4,n),Rt.u40be=n=>new xs(5,n),Rt.u48be=n=>new xs(6,n),Rt.nu64be=n=>new MU(n),Rt.s8=n=>new Sa(1,n),Rt.s16=n=>new Sa(2,n),Rt.s24=n=>new Sa(3,n),Rt.s32=n=>new Sa(4,n),Rt.s40=n=>new Sa(5,n),Rt.s48=n=>new Sa(6,n),Rt.ns64=n=>new LU(n),Rt.s16be=n=>new cu(2,n),Rt.s24be=n=>new cu(3,n),Rt.s32be=n=>new cu(4,n),Rt.s40be=n=>new cu(5,n),Rt.s48be=n=>new cu(6,n),Rt.ns64be=n=>new UU(n),Rt.f32=n=>new DE(n),Rt.f32be=n=>new FE(n),Rt.f64=n=>new $E(n),Rt.f64be=n=>new HE(n),Rt.struct=(n,t,e)=>new GE(n,t,e),Rt.bits=(n,t,e)=>new Fy(n,t,e),Rt.seq=(n,t,e)=>new zE(n,t,e),Rt.union=(n,t,e)=>new Dy(n,t,e),Rt.unionLayoutDiscriminator=(n,t)=>new f0(n,t),Rt.blob=(n,t)=>new jE(n,t),Rt.cstr=n=>new WE(n),Rt.utf8=(n,t)=>new ZE(n,t),Rt.const=(n,t)=>new qE(n,t);const DU=kc(xU);(function(n){var t=ae&&ae.__importDefault||function(ot){return ot&&ot.__esModule?ot:{default:ot}};Object.defineProperty(n,"__esModule",{value:!0}),n.struct=n.f64=n.f32=n.i32=n.u32=n.i16=n.u16=n.i8=n.u8=void 0,n.u64=c,n.i64=u,n.u128=f,n.i128=h,n.u256=y,n.i256=A,n.publicKey=R,n.option=S,n.bool=B,n.vec=G,n.tagged=W,n.vecU8=J,n.str=j,n.rustEnum=Y,n.array=it,n.map=rt;const e=Rt,r=DU,i=t(_g);var s=Rt;Object.defineProperty(n,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(n,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(n,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(n,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(n,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(n,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(n,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(n,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(n,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends e.Layout{constructor(C,p,m){super(C,m),this.blob=(0,e.blob)(C),this.signed=p}decode(C,p=0){const m=new i.default(this.blob.decode(C,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(C,p,m=0){return this.signed&&(C=C.toTwos(this.span*8)),this.blob.encode(C.toArrayLike(Zt,"le",this.span),p,m)}}function c(ot){return new o(8,!1,ot)}function u(ot){return new o(8,!0,ot)}function f(ot){return new o(16,!1,ot)}function h(ot){return new o(16,!0,ot)}function y(ot){return new o(32,!1,ot)}function A(ot){return new o(32,!0,ot)}class b extends e.Layout{constructor(C,p,m,v){super(C.span,v),this.layout=C,this.decoder=p,this.encoder=m}decode(C,p){return this.decoder(this.layout.decode(C,p))}encode(C,p,m){return this.layout.encode(this.encoder(C),p,m)}getSpan(C,p){return this.layout.getSpan(C,p)}}function R(ot){return new b((0,e.blob)(32),C=>new r.PublicKey(C),C=>C.toBuffer(),ot)}class k extends e.Layout{constructor(C,p){super(-1,p),this.layout=C,this.discriminator=(0,e.u8)()}encode(C,p,m=0){return C==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(C,p,m+1)+1)}decode(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return null;if(m===1)return this.layout.decode(C,p+1);throw new Error("Invalid option "+this.property)}getSpan(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(C,p+1)+1;throw new Error("Invalid option "+this.property)}}function S(ot,C){return new k(ot,C)}function B(ot){return new b((0,e.u8)(),H,U,ot)}function H(ot){if(ot===0)return!1;if(ot===1)return!0;throw new Error("Invalid bool: "+ot)}function U(ot){return ot?1:0}function G(ot,C){const p=(0,e.u32)("length"),m=(0,e.struct)([p,(0,e.seq)(ot,(0,e.offset)(p,-p.span),"values")]);return new b(m,({values:v})=>v,v=>({values:v}),C)}function W(ot,C,p){const m=(0,e.struct)([c("tag"),C.replicate("data")]);function v({tag:I,data:N}){if(!I.eq(ot))throw new Error("Invalid tag, expected: "+ot.toString("hex")+", got: "+I.toString("hex"));return N}return new b(m,v,I=>({tag:ot,data:I}),p)}function J(ot){const C=(0,e.u32)("length"),p=(0,e.struct)([C,(0,e.blob)((0,e.offset)(C,-C.span),"data")]);return new b(p,({data:m})=>m,m=>({data:m}),ot)}function j(ot){return new b(J(),C=>C.toString("utf-8"),C=>Zt.from(C,"utf-8"),ot)}function Y(ot,C,p){const m=(0,e.union)(p??(0,e.u8)(),C);return ot.forEach((v,I)=>m.addVariant(I,v,v.property)),m}function it(ot,C,p){const m=(0,e.struct)([(0,e.seq)(ot,C,"values")]);return new b(m,({values:v})=>v,v=>({values:v}),p)}class ut extends e.Layout{constructor(C,p,m){super(C.span+p.span,m),this.keyLayout=C,this.valueLayout=p}decode(C,p){p=p||0;const m=this.keyLayout.decode(C,p),v=this.valueLayout.decode(C,p+this.keyLayout.getSpan(C,p));return[m,v]}encode(C,p,m){m=m||0;const v=this.keyLayout.encode(C[0],p,m),I=this.valueLayout.encode(C[1],p,m+v);return v+I}getSpan(C,p){return this.keyLayout.getSpan(C,p)+this.valueLayout.getSpan(C,p)}}function rt(ot,C,p){const m=(0,e.u32)("length"),v=(0,e.struct)([m,(0,e.seq)(new ut(ot,C),(0,e.offset)(m,-m.span),"values")]);return new b(v,({values:I})=>new Map(I),I=>({values:Array.from(I.entries())}),p)}})(Yt);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const FU=4,QE=0,YE=1,$U=2;function lu(n){let t=n.length;for(;--t>=0;)n[t]=0}const HU=0,JE=1,zU=2,GU=3,VU=258,$y=29,vf=256,xf=vf+1+$y,fu=30,Hy=19,XE=2*xf+1,Ia=15,zy=16,KU=7,Gy=256,tv=16,ev=17,nv=18,Vy=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),h0=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),jU=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),rv=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),WU=512,Rs=new Array((xf+2)*2);lu(Rs);const Rf=new Array(fu*2);lu(Rf);const Sf=new Array(WU);lu(Sf);const If=new Array(VU-GU+1);lu(If);const Ky=new Array($y);lu(Ky);const d0=new Array(fu);lu(d0);function jy(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let iv,sv,ov;function Wy(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const av=n=>n<256?Sf[n]:Sf[256+(n>>>7)],kf=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},Sr=(n,t,e)=>{n.bi_valid>zy-e?(n.bi_buf|=t<<n.bi_valid&65535,kf(n,n.bi_buf),n.bi_buf=t>>zy-n.bi_valid,n.bi_valid+=e-zy):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},ji=(n,t,e)=>{Sr(n,e[t*2],e[t*2+1])},cv=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},ZU=n=>{n.bi_valid===16?(kf(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},qU=(n,t)=>{const e=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,u=t.stat_desc.max_length;let f,h,y,A,b,R,k=0;for(A=0;A<=Ia;A++)n.bl_count[A]=0;for(e[n.heap[n.heap_max]*2+1]=0,f=n.heap_max+1;f<XE;f++)h=n.heap[f],A=e[e[h*2+1]*2+1]+1,A>u&&(A=u,k++),e[h*2+1]=A,!(h>r)&&(n.bl_count[A]++,b=0,h>=c&&(b=o[h-c]),R=e[h*2],n.opt_len+=R*(A+b),s&&(n.static_len+=R*(i[h*2+1]+b)));if(k!==0){do{for(A=u-1;n.bl_count[A]===0;)A--;n.bl_count[A]--,n.bl_count[A+1]+=2,n.bl_count[u]--,k-=2}while(k>0);for(A=u;A!==0;A--)for(h=n.bl_count[A];h!==0;)y=n.heap[--f],!(y>r)&&(e[y*2+1]!==A&&(n.opt_len+=(A-e[y*2+1])*e[y*2],e[y*2+1]=A),h--)}},uv=(n,t,e)=>{const r=new Array(Ia+1);let i=0,s,o;for(s=1;s<=Ia;s++)i=i+e[s-1]<<1,r[s]=i;for(o=0;o<=t;o++){let c=n[o*2+1];c!==0&&(n[o*2]=cv(r[c]++,c))}},QU=()=>{let n,t,e,r,i;const s=new Array(Ia+1);for(e=0,r=0;r<$y-1;r++)for(Ky[r]=e,n=0;n<1<<Vy[r];n++)If[e++]=r;for(If[e-1]=r,i=0,r=0;r<16;r++)for(d0[r]=i,n=0;n<1<<h0[r];n++)Sf[i++]=r;for(i>>=7;r<fu;r++)for(d0[r]=i<<7,n=0;n<1<<h0[r]-7;n++)Sf[256+i++]=r;for(t=0;t<=Ia;t++)s[t]=0;for(n=0;n<=143;)Rs[n*2+1]=8,n++,s[8]++;for(;n<=255;)Rs[n*2+1]=9,n++,s[9]++;for(;n<=279;)Rs[n*2+1]=7,n++,s[7]++;for(;n<=287;)Rs[n*2+1]=8,n++,s[8]++;for(uv(Rs,xf+1,s),n=0;n<fu;n++)Rf[n*2+1]=5,Rf[n*2]=cv(n,5);iv=new jy(Rs,Vy,vf+1,xf,Ia),sv=new jy(Rf,h0,0,fu,Ia),ov=new jy(new Array(0),jU,0,Hy,KU)},lv=n=>{let t;for(t=0;t<xf;t++)n.dyn_ltree[t*2]=0;for(t=0;t<fu;t++)n.dyn_dtree[t*2]=0;for(t=0;t<Hy;t++)n.bl_tree[t*2]=0;n.dyn_ltree[Gy*2]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},fv=n=>{n.bi_valid>8?kf(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},hv=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]<n[s]||n[i]===n[s]&&r[t]<=r[e]},Zy=(n,t,e)=>{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i<n.heap_len&&hv(t,n.heap[i+1],n.heap[i],n.depth)&&i++,!hv(t,r,n.heap[i],n.depth));)n.heap[e]=n.heap[i],e=i,i<<=1;n.heap[e]=r},dv=(n,t,e)=>{let r,i,s=0,o,c;if(n.sym_next!==0)do r=n.pending_buf[n.sym_buf+s++]&255,r+=(n.pending_buf[n.sym_buf+s++]&255)<<8,i=n.pending_buf[n.sym_buf+s++],r===0?ji(n,i,t):(o=If[i],ji(n,o+vf+1,t),c=Vy[o],c!==0&&(i-=Ky[o],Sr(n,i,c)),r--,o=av(r),ji(n,o,e),c=h0[o],c!==0&&(r-=d0[o],Sr(n,r,c)));while(s<n.sym_next);ji(n,Gy,t)},qy=(n,t)=>{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,c,u=-1,f;for(n.heap_len=0,n.heap_max=XE,o=0;o<s;o++)e[o*2]!==0?(n.heap[++n.heap_len]=u=o,n.depth[o]=0):e[o*2+1]=0;for(;n.heap_len<2;)f=n.heap[++n.heap_len]=u<2?++u:0,e[f*2]=1,n.depth[f]=0,n.opt_len--,i&&(n.static_len-=r[f*2+1]);for(t.max_code=u,o=n.heap_len>>1;o>=1;o--)Zy(n,e,o);f=s;do o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],Zy(n,e,1),c=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=c,e[f*2]=e[o*2]+e[c*2],n.depth[f]=(n.depth[o]>=n.depth[c]?n.depth[o]:n.depth[c])+1,e[o*2+1]=e[c*2+1]=f,n.heap[1]=f++,Zy(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],qU(n,t),uv(e,u,n.bl_count)},pv=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],c=0,u=7,f=4;for(o===0&&(u=138,f=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=o,o=t[(r+1)*2+1],!(++c<u&&s===o)&&(c<f?n.bl_tree[s*2]+=c:s!==0?(s!==i&&n.bl_tree[s*2]++,n.bl_tree[tv*2]++):c<=10?n.bl_tree[ev*2]++:n.bl_tree[nv*2]++,c=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4))},gv=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],c=0,u=7,f=4;for(o===0&&(u=138,f=3),r=0;r<=e;r++)if(s=o,o=t[(r+1)*2+1],!(++c<u&&s===o)){if(c<f)do ji(n,s,n.bl_tree);while(--c!==0);else s!==0?(s!==i&&(ji(n,s,n.bl_tree),c--),ji(n,tv,n.bl_tree),Sr(n,c-3,2)):c<=10?(ji(n,ev,n.bl_tree),Sr(n,c-3,3)):(ji(n,nv,n.bl_tree),Sr(n,c-11,7));c=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4)}},YU=n=>{let t;for(pv(n,n.dyn_ltree,n.l_desc.max_code),pv(n,n.dyn_dtree,n.d_desc.max_code),qy(n,n.bl_desc),t=Hy-1;t>=3&&n.bl_tree[rv[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},JU=(n,t,e,r)=>{let i;for(Sr(n,t-257,5),Sr(n,e-1,5),Sr(n,r-4,4),i=0;i<r;i++)Sr(n,n.bl_tree[rv[i]*2+1],3);gv(n,n.dyn_ltree,t-1),gv(n,n.dyn_dtree,e-1)},XU=n=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return QE;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return YE;for(e=32;e<vf;e++)if(n.dyn_ltree[e*2]!==0)return YE;return QE};let yv=!1;const tD=n=>{yv||(QU(),yv=!0),n.l_desc=new Wy(n.dyn_ltree,iv),n.d_desc=new Wy(n.dyn_dtree,sv),n.bl_desc=new Wy(n.bl_tree,ov),n.bi_buf=0,n.bi_valid=0,lv(n)},mv=(n,t,e,r)=>{Sr(n,(HU<<1)+(r?1:0),3),fv(n),kf(n,e),kf(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},eD=n=>{Sr(n,JE<<1,3),ji(n,Gy,Rs),ZU(n)},nD=(n,t,e,r)=>{let i,s,o=0;n.level>0?(n.strm.data_type===$U&&(n.strm.data_type=XU(n)),qy(n,n.l_desc),qy(n,n.d_desc),o=YU(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?mv(n,t,e,r):n.strategy===FU||s===i?(Sr(n,(JE<<1)+(r?1:0),3),dv(n,Rs,Rf)):(Sr(n,(zU<<1)+(r?1:0),3),JU(n,n.l_desc.max_code+1,n.d_desc.max_code+1,o+1),dv(n,n.dyn_ltree,n.dyn_dtree)),lv(n),r&&fv(n)},rD=(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(If[e]+vf+1)*2]++,n.dyn_dtree[av(t)*2]++),n.sym_next===n.sym_end);var iD=tD,sD=mv,oD=nD,aD=rD,cD=eD,uD={_tr_init:iD,_tr_stored_block:sD,_tr_flush_block:oD,_tr_tally:aD,_tr_align:cD},Tf=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,o=0;for(;e!==0;){o=e>2e3?2e3:e,e-=o;do i=i+t[r++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};const lD=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},fD=new Uint32Array(lD());var Ln=(n,t,e,r)=>{const i=fD,s=r+e;n^=-1;for(let o=r;o<s;o++)n=n>>>8^i[(n^t[o])&255];return n^-1},hu={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Of={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:hD,_tr_stored_block:Qy,_tr_flush_block:dD,_tr_tally:yo,_tr_align:pD}=uD,{Z_NO_FLUSH:mo,Z_PARTIAL_FLUSH:gD,Z_FULL_FLUSH:yD,Z_FINISH:Xr,Z_BLOCK:wv,Z_OK:Wn,Z_STREAM_END:bv,Z_STREAM_ERROR:Wi,Z_DATA_ERROR:mD,Z_BUF_ERROR:Yy,Z_DEFAULT_COMPRESSION:wD,Z_FILTERED:bD,Z_HUFFMAN_ONLY:p0,Z_RLE:_D,Z_FIXED:AD,Z_DEFAULT_STRATEGY:ED,Z_UNKNOWN:vD,Z_DEFLATED:g0}=Of,xD=9,RD=15,SD=8,Jy=256+1+29,ID=30,kD=19,TD=2*Jy+1,OD=15,le=3,wo=258,Zi=wo+le+1,ND=32,du=42,Xy=57,tm=69,em=73,nm=91,rm=103,ka=113,Nf=666,dr=1,pu=2,Ta=3,gu=4,CD=3,Oa=(n,t)=>(n.msg=hu[t],t),_v=n=>n*2-(n>4?9:0),bo=n=>{let t=n.length;for(;--t>=0;)n[t]=0},BD=n=>{let t,e,r,i=n.w_size;t=n.hash_size,r=t;do e=n.head[--r],n.head[r]=e>=i?e-i:0;while(--t);t=i,r=t;do e=n.prev[--r],n.prev[r]=e>=i?e-i:0;while(--t)};let _o=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask;const Fr=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},$r=(n,t)=>{dD(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Fr(n.strm)},ve=(n,t)=>{n.pending_buf[n.pending++]=t},Cf=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},im=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=Tf(n.adler,t,i,e):n.state.wrap===2&&(n.adler=Ln(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},Av=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,o=n.prev_length,c=n.nice_match;const u=n.strstart>n.w_size-Zi?n.strstart-(n.w_size-Zi):0,f=n.window,h=n.w_mask,y=n.prev,A=n.strstart+wo;let b=f[r+o-1],R=f[r+o];n.prev_length>=n.good_match&&(e>>=2),c>n.lookahead&&(c=n.lookahead);do if(i=t,!(f[i+o]!==R||f[i+o-1]!==b||f[i]!==f[r]||f[++i]!==f[r+1])){r+=2,i++;do;while(f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&r<A);if(s=wo-(A-r),r=A-wo,s>o){if(n.match_start=t,o=s,s>=c)break;b=f[r+o-1],R=f[r+o]}}while((t=y[t&h])>u&&--e!==0);return o<=n.lookahead?o:n.lookahead},yu=n=>{const t=n.w_size;let e,r,i;do{if(r=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-Zi)&&(n.window.set(n.window.subarray(t,t+t-r),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),BD(n),r+=t),n.strm.avail_in===0)break;if(e=im(n.strm,n.window,n.strstart+n.lookahead,r),n.lookahead+=e,n.lookahead+n.insert>=le)for(i=n.strstart-n.insert,n.ins_h=n.window[i],n.ins_h=_o(n,n.ins_h,n.window[i+1]);n.insert&&(n.ins_h=_o(n,n.ins_h,n.window[i+le-1]),n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,n.insert--,!(n.lookahead+n.insert<le)););}while(n.lookahead<Zi&&n.strm.avail_in!==0)},Ev=(n,t)=>{let e=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,r,i,s,o=0,c=n.strm.avail_in;do{if(r=65535,s=n.bi_valid+42>>3,n.strm.avail_out<s||(s=n.strm.avail_out-s,i=n.strstart-n.block_start,r>i+n.strm.avail_in&&(r=i+n.strm.avail_in),r>s&&(r=s),r<e&&(r===0&&t!==Xr||t===mo||r!==i+n.strm.avail_in)))break;o=t===Xr&&r===i+n.strm.avail_in?1:0,Qy(n,0,0,o),n.pending_buf[n.pending-4]=r,n.pending_buf[n.pending-3]=r>>8,n.pending_buf[n.pending-2]=~r,n.pending_buf[n.pending-1]=~r>>8,Fr(n.strm),i&&(i>r&&(i=r),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+i),n.strm.next_out),n.strm.next_out+=i,n.strm.avail_out-=i,n.strm.total_out+=i,n.block_start+=i,r-=i),r&&(im(n.strm,n.strm.output,n.strm.next_out,r),n.strm.next_out+=r,n.strm.avail_out-=r,n.strm.total_out+=r)}while(o===0);return c-=n.strm.avail_in,c&&(c>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=c&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-c,n.strm.next_in),n.strstart),n.strstart+=c,n.insert+=c>n.w_size-n.insert?n.w_size-n.insert:c),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),o?gu:t!==mo&&t!==Xr&&n.strm.avail_in===0&&n.strstart===n.block_start?pu:(s=n.window_size-n.strstart,n.strm.avail_in>s&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,s+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),s>n.strm.avail_in&&(s=n.strm.avail_in),s&&(im(n.strm,n.window,n.strstart,s),n.strstart+=s,n.insert+=s>n.w_size-n.insert?n.w_size-n.insert:s),n.high_water<n.strstart&&(n.high_water=n.strstart),s=n.bi_valid+42>>3,s=n.pending_buf_size-s>65535?65535:n.pending_buf_size-s,e=s>n.w_size?n.w_size:s,i=n.strstart-n.block_start,(i>=e||(i||t===Xr)&&t!==mo&&n.strm.avail_in===0&&i<=s)&&(r=i>s?s:i,o=t===Xr&&n.strm.avail_in===0&&r===i?1:0,Qy(n,n.block_start,r,o),n.block_start+=r,Fr(n.strm)),o?Ta:dr)},sm=(n,t)=>{let e,r;for(;;){if(n.lookahead<Zi){if(yu(n),n.lookahead<Zi&&t===mo)return dr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=_o(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-Zi&&(n.match_length=Av(n,e)),n.match_length>=le)if(r=yo(n,n.strstart-n.match_start,n.match_length-le),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=le){n.match_length--;do n.strstart++,n.ins_h=_o(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=_o(n,n.ins_h,n.window[n.strstart+1]);else r=yo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&($r(n,!1),n.strm.avail_out===0))return dr}return n.insert=n.strstart<le-1?n.strstart:le-1,t===Xr?($r(n,!0),n.strm.avail_out===0?Ta:gu):n.sym_next&&($r(n,!1),n.strm.avail_out===0)?dr:pu},mu=(n,t)=>{let e,r,i;for(;;){if(n.lookahead<Zi){if(yu(n),n.lookahead<Zi&&t===mo)return dr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=_o(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=le-1,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-Zi&&(n.match_length=Av(n,e),n.match_length<=5&&(n.strategy===bD||n.match_length===le&&n.strstart-n.match_start>4096)&&(n.match_length=le-1)),n.prev_length>=le&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-le,r=yo(n,n.strstart-1-n.prev_match,n.prev_length-le),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=_o(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=le-1,n.strstart++,r&&($r(n,!1),n.strm.avail_out===0))return dr}else if(n.match_available){if(r=yo(n,0,n.window[n.strstart-1]),r&&$r(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return dr}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=yo(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<le-1?n.strstart:le-1,t===Xr?($r(n,!0),n.strm.avail_out===0?Ta:gu):n.sym_next&&($r(n,!1),n.strm.avail_out===0)?dr:pu},PD=(n,t)=>{let e,r,i,s;const o=n.window;for(;;){if(n.lookahead<=wo){if(yu(n),n.lookahead<=wo&&t===mo)return dr;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=le&&n.strstart>0&&(i=n.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){s=n.strstart+wo;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<s);n.match_length=wo-(s-i),n.match_length>n.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=le?(e=yo(n,1,n.match_length-le),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=yo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&($r(n,!1),n.strm.avail_out===0))return dr}return n.insert=0,t===Xr?($r(n,!0),n.strm.avail_out===0?Ta:gu):n.sym_next&&($r(n,!1),n.strm.avail_out===0)?dr:pu},MD=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(yu(n),n.lookahead===0)){if(t===mo)return dr;break}if(n.match_length=0,e=yo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&($r(n,!1),n.strm.avail_out===0))return dr}return n.insert=0,t===Xr?($r(n,!0),n.strm.avail_out===0?Ta:gu):n.sym_next&&($r(n,!1),n.strm.avail_out===0)?dr:pu};function qi(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const Bf=[new qi(0,0,0,0,Ev),new qi(4,4,8,4,sm),new qi(4,5,16,8,sm),new qi(4,6,32,32,sm),new qi(4,4,16,16,mu),new qi(8,16,32,32,mu),new qi(8,16,128,128,mu),new qi(8,32,128,256,mu),new qi(32,128,258,1024,mu),new qi(32,258,258,4096,mu)],LD=n=>{n.window_size=2*n.w_size,bo(n.head),n.max_lazy_match=Bf[n.level].max_lazy,n.good_match=Bf[n.level].good_length,n.nice_match=Bf[n.level].nice_length,n.max_chain_length=Bf[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=le-1,n.match_available=0,n.ins_h=0};function UD(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g0,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(TD*2),this.dyn_dtree=new Uint16Array((2*ID+1)*2),this.bl_tree=new Uint16Array((2*kD+1)*2),bo(this.dyn_ltree),bo(this.dyn_dtree),bo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(OD+1),this.heap=new Uint16Array(2*Jy+1),bo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Jy+1),bo(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Pf=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==du&&t.status!==Xy&&t.status!==tm&&t.status!==em&&t.status!==nm&&t.status!==rm&&t.status!==ka&&t.status!==Nf?1:0},vv=n=>{if(Pf(n))return Oa(n,Wi);n.total_in=n.total_out=0,n.data_type=vD;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Xy:t.wrap?du:ka,n.adler=t.wrap===2?0:1,t.last_flush=-2,hD(t),Wn},xv=n=>{const t=vv(n);return t===Wn&&LD(n.state),t},DD=(n,t)=>Pf(n)||n.state.wrap!==2?Wi:(n.state.gzhead=t,Wn),Rv=(n,t,e,r,i,s)=>{if(!n)return Wi;let o=1;if(t===wD&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>xD||e!==g0||r<8||r>15||t<0||t>9||s<0||s>AD||r===8&&o!==1)return Oa(n,Wi);r===8&&(r=9);const c=new UD;return n.state=c,c.strm=n,c.status=du,c.wrap=o,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=i+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+le-1)/le),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=t,c.strategy=s,c.method=e,xv(n)},FD=(n,t)=>Rv(n,t,g0,RD,SD,ED),$D=(n,t)=>{if(Pf(n)||t>wv||t<0)return n?Oa(n,Wi):Wi;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===Nf&&t!==Xr)return Oa(n,n.avail_out===0?Yy:Wi);const r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Fr(n),n.avail_out===0)return e.last_flush=-1,Wn}else if(n.avail_in===0&&_v(t)<=_v(r)&&t!==Xr)return Oa(n,Yy);if(e.status===Nf&&n.avail_in!==0)return Oa(n,Yy);if(e.status===du&&e.wrap===0&&(e.status=ka),e.status===du){let i=g0+(e.w_bits-8<<4)<<8,s=-1;if(e.strategy>=p0||e.level<2?s=0:e.level<6?s=1:e.level===6?s=2:s=3,i|=s<<6,e.strstart!==0&&(i|=ND),i+=31-i%31,Cf(e,i),e.strstart!==0&&(Cf(e,n.adler>>>16),Cf(e,n.adler&65535)),n.adler=1,e.status=ka,Fr(n),e.pending!==0)return e.last_flush=-1,Wn}if(e.status===Xy){if(n.adler=0,ve(e,31),ve(e,139),ve(e,8),e.gzhead)ve(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),ve(e,e.gzhead.time&255),ve(e,e.gzhead.time>>8&255),ve(e,e.gzhead.time>>16&255),ve(e,e.gzhead.time>>24&255),ve(e,e.level===9?2:e.strategy>=p0||e.level<2?4:0),ve(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(ve(e,e.gzhead.extra.length&255),ve(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=Ln(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=tm;else if(ve(e,0),ve(e,0),ve(e,0),ve(e,0),ve(e,0),ve(e,e.level===9?2:e.strategy>=p0||e.level<2?4:0),ve(e,CD),e.status=ka,Fr(n),e.pending!==0)return e.last_flush=-1,Wn}if(e.status===tm){if(e.gzhead.extra){let i=e.pending,s=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let c=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+c),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex+=c,Fr(n),e.pending!==0)return e.last_flush=-1,Wn;i=0,s-=c}let o=new Uint8Array(e.gzhead.extra);e.pending_buf.set(o.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=em}if(e.status===em){if(e.gzhead.name){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),Fr(n),e.pending!==0)return e.last_flush=-1,Wn;i=0}e.gzindex<e.gzhead.name.length?s=e.gzhead.name.charCodeAt(e.gzindex++)&255:s=0,ve(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=nm}if(e.status===nm){if(e.gzhead.comment){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),Fr(n),e.pending!==0)return e.last_flush=-1,Wn;i=0}e.gzindex<e.gzhead.comment.length?s=e.gzhead.comment.charCodeAt(e.gzindex++)&255:s=0,ve(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i))}e.status=rm}if(e.status===rm){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Fr(n),e.pending!==0))return e.last_flush=-1,Wn;ve(e,n.adler&255),ve(e,n.adler>>8&255),n.adler=0}if(e.status=ka,Fr(n),e.pending!==0)return e.last_flush=-1,Wn}if(n.avail_in!==0||e.lookahead!==0||t!==mo&&e.status!==Nf){let i=e.level===0?Ev(e,t):e.strategy===p0?MD(e,t):e.strategy===_D?PD(e,t):Bf[e.level].func(e,t);if((i===Ta||i===gu)&&(e.status=Nf),i===dr||i===Ta)return n.avail_out===0&&(e.last_flush=-1),Wn;if(i===pu&&(t===gD?pD(e):t!==wv&&(Qy(e,0,0,!1),t===yD&&(bo(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Fr(n),n.avail_out===0))return e.last_flush=-1,Wn}return t!==Xr?Wn:e.wrap<=0?bv:(e.wrap===2?(ve(e,n.adler&255),ve(e,n.adler>>8&255),ve(e,n.adler>>16&255),ve(e,n.adler>>24&255),ve(e,n.total_in&255),ve(e,n.total_in>>8&255),ve(e,n.total_in>>16&255),ve(e,n.total_in>>24&255)):(Cf(e,n.adler>>>16),Cf(e,n.adler&65535)),Fr(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Wn:bv)},HD=n=>{if(Pf(n))return Wi;const t=n.state.status;return n.state=null,t===ka?Oa(n,mD):Wn},zD=(n,t)=>{let e=t.length;if(Pf(n))return Wi;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==du||r.lookahead)return Wi;if(i===1&&(n.adler=Tf(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(bo(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(t.subarray(e-r.w_size,e),0),t=u,e=r.w_size}const s=n.avail_in,o=n.next_in,c=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,yu(r);r.lookahead>=le;){let u=r.strstart,f=r.lookahead-(le-1);do r.ins_h=_o(r,r.ins_h,r.window[u+le-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--f);r.strstart=u,r.lookahead=le-1,yu(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=le-1,r.match_available=0,n.next_in=o,n.input=c,n.avail_in=s,r.wrap=i,Wn};var GD=FD,VD=Rv,KD=xv,jD=vv,WD=DD,ZD=$D,qD=HD,QD=zD,YD="pako deflate (from Nodeca project)",Mf={deflateInit:GD,deflateInit2:VD,deflateReset:KD,deflateResetKeep:jD,deflateSetHeader:WD,deflate:ZD,deflateEnd:qD,deflateSetDictionary:QD,deflateInfo:YD};const JD=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var XD=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)JD(e,r)&&(n[r]=e[r])}}return n},t9=n=>{let t=0;for(let r=0,i=n.length;r<i;r++)t+=n[r].length;const e=new Uint8Array(t);for(let r=0,i=0,s=n.length;r<s;r++){let o=n[r];e.set(o,i),i+=o.length}return e},y0={assign:XD,flattenChunks:t9};let Sv=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Sv=!1}const Lf=new Uint8Array(256);for(let n=0;n<256;n++)Lf[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;Lf[254]=Lf[254]=1;var e9=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,o=n.length,c=0;for(i=0;i<o;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),c+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(c),s=0,i=0;s<c;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const n9=(n,t)=>{if(t<65534&&n.subarray&&Sv)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(n[r]);return e};var r9=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*2);for(i=0,r=0;r<e;){let o=n[r++];if(o<128){s[i++]=o;continue}let c=Lf[o];if(c>4){s[i++]=65533,r+=c-1;continue}for(o&=c===2?31:c===3?15:7;c>1&&r<e;)o=o<<6|n[r++]&63,c--;if(c>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return n9(s,i)},i9=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+Lf[n[e]]>t?e:t},Uf={string2buf:e9,buf2string:r9,utf8border:i9};function s9(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Iv=s9;const kv=Object.prototype.toString,{Z_NO_FLUSH:o9,Z_SYNC_FLUSH:a9,Z_FULL_FLUSH:c9,Z_FINISH:u9,Z_OK:m0,Z_STREAM_END:l9,Z_DEFAULT_COMPRESSION:f9,Z_DEFAULT_STRATEGY:h9,Z_DEFLATED:d9}=Of;function om(n){this.options=y0.assign({level:f9,method:d9,chunkSize:16384,windowBits:15,memLevel:8,strategy:h9},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Iv,this.strm.avail_out=0;let e=Mf.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==m0)throw new Error(hu[e]);if(t.header&&Mf.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=Uf.string2buf(t.dictionary):kv.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=Mf.deflateSetDictionary(this.strm,r),e!==m0)throw new Error(hu[e]);this._dict_set=!0}}om.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?u9:o9,typeof n=="string"?e.input=Uf.string2buf(n):kv.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===a9||s===c9)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=Mf.deflate(e,s),i===l9)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=Mf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===m0;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0},om.prototype.onData=function(n){this.chunks.push(n)},om.prototype.onEnd=function(n){n===m0&&(this.result=y0.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};const w0=16209,p9=16191;var g9=function(t,e){let r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H,U,G,W,J,j,Y,it,ut;const rt=t.state;r=t.next_in,it=t.input,i=r+(t.avail_in-5),s=t.next_out,ut=t.output,o=s-(e-t.avail_out),c=s+(t.avail_out-257),u=rt.dmax,f=rt.wsize,h=rt.whave,y=rt.wnext,A=rt.window,b=rt.hold,R=rt.bits,k=rt.lencode,S=rt.distcode,B=(1<<rt.lenbits)-1,H=(1<<rt.distbits)-1;t:do{R<15&&(b+=it[r++]<<R,R+=8,b+=it[r++]<<R,R+=8),U=k[b&B];e:for(;;){if(G=U>>>24,b>>>=G,R-=G,G=U>>>16&255,G===0)ut[s++]=U&65535;else if(G&16){W=U&65535,G&=15,G&&(R<G&&(b+=it[r++]<<R,R+=8),W+=b&(1<<G)-1,b>>>=G,R-=G),R<15&&(b+=it[r++]<<R,R+=8,b+=it[r++]<<R,R+=8),U=S[b&H];n:for(;;){if(G=U>>>24,b>>>=G,R-=G,G=U>>>16&255,G&16){if(J=U&65535,G&=15,R<G&&(b+=it[r++]<<R,R+=8,R<G&&(b+=it[r++]<<R,R+=8)),J+=b&(1<<G)-1,J>u){t.msg="invalid distance too far back",rt.mode=w0;break t}if(b>>>=G,R-=G,G=s-o,J>G){if(G=J-G,G>h&&rt.sane){t.msg="invalid distance too far back",rt.mode=w0;break t}if(j=0,Y=A,y===0){if(j+=f-G,G<W){W-=G;do ut[s++]=A[j++];while(--G);j=s-J,Y=ut}}else if(y<G){if(j+=f+y-G,G-=y,G<W){W-=G;do ut[s++]=A[j++];while(--G);if(j=0,y<W){G=y,W-=G;do ut[s++]=A[j++];while(--G);j=s-J,Y=ut}}}else if(j+=y-G,G<W){W-=G;do ut[s++]=A[j++];while(--G);j=s-J,Y=ut}for(;W>2;)ut[s++]=Y[j++],ut[s++]=Y[j++],ut[s++]=Y[j++],W-=3;W&&(ut[s++]=Y[j++],W>1&&(ut[s++]=Y[j++]))}else{j=s-J;do ut[s++]=ut[j++],ut[s++]=ut[j++],ut[s++]=ut[j++],W-=3;while(W>2);W&&(ut[s++]=ut[j++],W>1&&(ut[s++]=ut[j++]))}}else if(G&64){t.msg="invalid distance code",rt.mode=w0;break t}else{U=S[(U&65535)+(b&(1<<G)-1)];continue n}break}}else if(G&64)if(G&32){rt.mode=p9;break t}else{t.msg="invalid literal/length code",rt.mode=w0;break t}else{U=k[(U&65535)+(b&(1<<G)-1)];continue e}break}}while(r<i&&s<c);W=R>>3,r-=W,R-=W<<3,b&=(1<<R)-1,t.next_in=r,t.next_out=s,t.avail_in=r<i?5+(i-r):5-(r-i),t.avail_out=s<c?257+(c-s):257-(s-c),rt.hold=b,rt.bits=R};const wu=15,Tv=852,Ov=592,Nv=0,am=1,Cv=2,y9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),m9=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),w9=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),b9=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Df=(n,t,e,r,i,s,o,c)=>{const u=c.bits;let f=0,h=0,y=0,A=0,b=0,R=0,k=0,S=0,B=0,H=0,U,G,W,J,j,Y=null,it;const ut=new Uint16Array(wu+1),rt=new Uint16Array(wu+1);let ot=null,C,p,m;for(f=0;f<=wu;f++)ut[f]=0;for(h=0;h<r;h++)ut[t[e+h]]++;for(b=u,A=wu;A>=1&&ut[A]===0;A--);if(b>A&&(b=A),A===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,c.bits=1,0;for(y=1;y<A&&ut[y]===0;y++);for(b<y&&(b=y),S=1,f=1;f<=wu;f++)if(S<<=1,S-=ut[f],S<0)return-1;if(S>0&&(n===Nv||A!==1))return-1;for(rt[1]=0,f=1;f<wu;f++)rt[f+1]=rt[f]+ut[f];for(h=0;h<r;h++)t[e+h]!==0&&(o[rt[t[e+h]]++]=h);if(n===Nv?(Y=ot=o,it=20):n===am?(Y=y9,ot=m9,it=257):(Y=w9,ot=b9,it=0),H=0,h=0,f=y,j=s,R=b,k=0,W=-1,B=1<<b,J=B-1,n===am&&B>Tv||n===Cv&&B>Ov)return 1;for(;;){C=f-k,o[h]+1<it?(p=0,m=o[h]):o[h]>=it?(p=ot[o[h]-it],m=Y[o[h]-it]):(p=96,m=0),U=1<<f-k,G=1<<R,y=G;do G-=U,i[j+(H>>k)+G]=C<<24|p<<16|m|0;while(G!==0);for(U=1<<f-1;H&U;)U>>=1;if(U!==0?(H&=U-1,H+=U):H=0,h++,--ut[f]===0){if(f===A)break;f=t[e+o[h]]}if(f>b&&(H&J)!==W){for(k===0&&(k=b),j+=y,R=f-k,S=1<<R;R+k<A&&(S-=ut[R+k],!(S<=0));)R++,S<<=1;if(B+=1<<R,n===am&&B>Tv||n===Cv&&B>Ov)return 1;W=H&J,i[W]=b<<24|R<<16|j-s|0}}return H!==0&&(i[j+H]=f-k<<24|64<<16|0),c.bits=b,0};const _9=0,Bv=1,Pv=2,{Z_FINISH:Mv,Z_BLOCK:A9,Z_TREES:b0,Z_OK:Na,Z_STREAM_END:E9,Z_NEED_DICT:v9,Z_STREAM_ERROR:ti,Z_DATA_ERROR:Lv,Z_MEM_ERROR:Uv,Z_BUF_ERROR:x9,Z_DEFLATED:Dv}=Of,_0=16180,Fv=16181,$v=16182,Hv=16183,zv=16184,Gv=16185,Vv=16186,Kv=16187,jv=16188,Wv=16189,A0=16190,Ss=16191,cm=16192,Zv=16193,um=16194,qv=16195,Qv=16196,Yv=16197,Jv=16198,E0=16199,v0=16200,Xv=16201,tx=16202,ex=16203,nx=16204,rx=16205,lm=16206,ix=16207,sx=16208,qe=16209,ox=16210,ax=16211,R9=852,S9=592,I9=15,cx=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function k9(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ca=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<_0||t.mode>ax?1:0},ux=n=>{if(Ca(n))return ti;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=_0,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(R9),t.distcode=t.distdyn=new Int32Array(S9),t.sane=1,t.back=-1,Na},lx=n=>{if(Ca(n))return ti;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,ux(n)},fx=(n,t)=>{let e;if(Ca(n))return ti;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ti:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,lx(n))},hx=(n,t)=>{if(!n)return ti;const e=new k9;n.state=e,e.strm=n,e.window=null,e.mode=_0;const r=fx(n,t);return r!==Na&&(n.state=null),r},T9=n=>hx(n,I9);let dx=!0,fm,hm;const O9=n=>{if(dx){fm=new Int32Array(512),hm=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Df(Bv,n.lens,0,288,fm,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Df(Pv,n.lens,0,32,hm,0,n.work,{bits:5}),dx=!1}n.lencode=fm,n.lenbits=9,n.distcode=hm,n.distbits=5},px=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},N9=(n,t)=>{let e,r,i,s,o,c,u,f,h,y,A,b,R,k,S=0,B,H,U,G,W,J,j,Y;const it=new Uint8Array(4);let ut,rt;const ot=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ca(n)||!n.output||!n.input&&n.avail_in!==0)return ti;e=n.state,e.mode===Ss&&(e.mode=cm),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,c=n.avail_in,f=e.hold,h=e.bits,y=c,A=u,Y=Na;t:for(;;)switch(e.mode){case _0:if(e.wrap===0){e.mode=cm;break}for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&2&&f===35615){e.wbits===0&&(e.wbits=15),e.check=0,it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0),f=0,h=0,e.mode=Fv;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((f&255)<<8)+(f>>8))%31){n.msg="incorrect header check",e.mode=qe;break}if((f&15)!==Dv){n.msg="unknown compression method",e.mode=qe;break}if(f>>>=4,h-=4,j=(f&15)+8,e.wbits===0&&(e.wbits=j),j>15||j>e.wbits){n.msg="invalid window size",e.mode=qe;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=f&512?Wv:Ss,f=0,h=0;break;case Fv:for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.flags=f,(e.flags&255)!==Dv){n.msg="unknown compression method",e.mode=qe;break}if(e.flags&57344){n.msg="unknown header flags set",e.mode=qe;break}e.head&&(e.head.text=f>>8&1),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0,e.mode=$v;case $v:for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.head&&(e.head.time=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,it[2]=f>>>16&255,it[3]=f>>>24&255,e.check=Ln(e.check,it,4,0)),f=0,h=0,e.mode=Hv;case Hv:for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.head&&(e.head.xflags=f&255,e.head.os=f>>8),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0,e.mode=zv;case zv:if(e.flags&1024){for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.length=f,e.head&&(e.head.extra_len=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0}else e.head&&(e.head.extra=null);e.mode=Gv;case Gv:if(e.flags&1024&&(b=e.length,b>c&&(b=c),b&&(e.head&&(j=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+b),j)),e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,b,s)),c-=b,s+=b,e.length-=b),e.length))break t;e.length=0,e.mode=Vv;case Vv:if(e.flags&2048){if(c===0)break t;b=0;do j=r[s+b++],e.head&&j&&e.length<65536&&(e.head.name+=String.fromCharCode(j));while(j&&b<c);if(e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,b,s)),c-=b,s+=b,j)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=Kv;case Kv:if(e.flags&4096){if(c===0)break t;b=0;do j=r[s+b++],e.head&&j&&e.length<65536&&(e.head.comment+=String.fromCharCode(j));while(j&&b<c);if(e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,b,s)),c-=b,s+=b,j)break t}else e.head&&(e.head.comment=null);e.mode=jv;case jv:if(e.flags&512){for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.check&65535)){n.msg="header crc mismatch",e.mode=qe;break}f=0,h=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=Ss;break;case Wv:for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}n.adler=e.check=cx(f),f=0,h=0,e.mode=A0;case A0:if(e.havedict===0)return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,v9;n.adler=e.check=1,e.mode=Ss;case Ss:if(t===A9||t===b0)break t;case cm:if(e.last){f>>>=h&7,h-=h&7,e.mode=lm;break}for(;h<3;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}switch(e.last=f&1,f>>>=1,h-=1,f&3){case 0:e.mode=Zv;break;case 1:if(O9(e),e.mode=E0,t===b0){f>>>=2,h-=2;break t}break;case 2:e.mode=Qv;break;case 3:n.msg="invalid block type",e.mode=qe}f>>>=2,h-=2;break;case Zv:for(f>>>=h&7,h-=h&7;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if((f&65535)!==(f>>>16^65535)){n.msg="invalid stored block lengths",e.mode=qe;break}if(e.length=f&65535,f=0,h=0,e.mode=um,t===b0)break t;case um:e.mode=qv;case qv:if(b=e.length,b){if(b>c&&(b=c),b>u&&(b=u),b===0)break t;i.set(r.subarray(s,s+b),o),c-=b,s+=b,u-=b,o+=b,e.length-=b;break}e.mode=Ss;break;case Qv:for(;h<14;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.nlen=(f&31)+257,f>>>=5,h-=5,e.ndist=(f&31)+1,f>>>=5,h-=5,e.ncode=(f&15)+4,f>>>=4,h-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=qe;break}e.have=0,e.mode=Yv;case Yv:for(;e.have<e.ncode;){for(;h<3;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.lens[ot[e.have++]]=f&7,f>>>=3,h-=3}for(;e.have<19;)e.lens[ot[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,ut={bits:e.lenbits},Y=Df(_9,e.lens,0,19,e.lencode,0,e.work,ut),e.lenbits=ut.bits,Y){n.msg="invalid code lengths set",e.mode=qe;break}e.have=0,e.mode=Jv;case Jv:for(;e.have<e.nlen+e.ndist;){for(;S=e.lencode[f&(1<<e.lenbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(U<16)f>>>=B,h-=B,e.lens[e.have++]=U;else{if(U===16){for(rt=B+2;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(f>>>=B,h-=B,e.have===0){n.msg="invalid bit length repeat",e.mode=qe;break}j=e.lens[e.have-1],b=3+(f&3),f>>>=2,h-=2}else if(U===17){for(rt=B+3;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,b=3+(f&7),f>>>=3,h-=3}else{for(rt=B+7;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,b=11+(f&127),f>>>=7,h-=7}if(e.have+b>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=qe;break}for(;b--;)e.lens[e.have++]=j}}if(e.mode===qe)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=qe;break}if(e.lenbits=9,ut={bits:e.lenbits},Y=Df(Bv,e.lens,0,e.nlen,e.lencode,0,e.work,ut),e.lenbits=ut.bits,Y){n.msg="invalid literal/lengths set",e.mode=qe;break}if(e.distbits=6,e.distcode=e.distdyn,ut={bits:e.distbits},Y=Df(Pv,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,ut),e.distbits=ut.bits,Y){n.msg="invalid distances set",e.mode=qe;break}if(e.mode=E0,t===b0)break t;case E0:e.mode=v0;case v0:if(c>=6&&u>=258){n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,g9(n,A),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,c=n.avail_in,f=e.hold,h=e.bits,e.mode===Ss&&(e.back=-1);break}for(e.back=0;S=e.lencode[f&(1<<e.lenbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(H&&!(H&240)){for(G=B,W=H,J=U;S=e.lencode[J+((f&(1<<G+W)-1)>>G)],B=S>>>24,H=S>>>16&255,U=S&65535,!(G+B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,e.length=U,H===0){e.mode=rx;break}if(H&32){e.back=-1,e.mode=Ss;break}if(H&64){n.msg="invalid literal/length code",e.mode=qe;break}e.extra=H&15,e.mode=Xv;case Xv:if(e.extra){for(rt=e.extra;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.length+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=tx;case tx:for(;S=e.distcode[f&(1<<e.distbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(!(H&240)){for(G=B,W=H,J=U;S=e.distcode[J+((f&(1<<G+W)-1)>>G)],B=S>>>24,H=S>>>16&255,U=S&65535,!(G+B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,H&64){n.msg="invalid distance code",e.mode=qe;break}e.offset=U,e.extra=H&15,e.mode=ex;case ex:if(e.extra){for(rt=e.extra;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.offset+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=qe;break}e.mode=nx;case nx:if(u===0)break t;if(b=A-u,e.offset>b){if(b=e.offset-b,b>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=qe;break}b>e.wnext?(b-=e.wnext,R=e.wsize-b):R=e.wnext-b,b>e.length&&(b=e.length),k=e.window}else k=i,R=o-e.offset,b=e.length;b>u&&(b=u),u-=b,e.length-=b;do i[o++]=k[R++];while(--b);e.length===0&&(e.mode=v0);break;case rx:if(u===0)break t;i[o++]=e.length,u--,e.mode=v0;break;case lm:if(e.wrap){for(;h<32;){if(c===0)break t;c--,f|=r[s++]<<h,h+=8}if(A-=u,n.total_out+=A,e.total+=A,e.wrap&4&&A&&(n.adler=e.check=e.flags?Ln(e.check,i,A,o-A):Tf(e.check,i,A,o-A)),A=u,e.wrap&4&&(e.flags?f:cx(f))!==e.check){n.msg="incorrect data check",e.mode=qe;break}f=0,h=0}e.mode=ix;case ix:if(e.wrap&&e.flags){for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.total&4294967295)){n.msg="incorrect length check",e.mode=qe;break}f=0,h=0}e.mode=sx;case sx:Y=E9;break t;case qe:Y=Lv;break t;case ox:return Uv;case ax:default:return ti}return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,(e.wsize||A!==n.avail_out&&e.mode<qe&&(e.mode<lm||t!==Mv))&&px(n,n.output,n.next_out,A-n.avail_out),y-=n.avail_in,A-=n.avail_out,n.total_in+=y,n.total_out+=A,e.total+=A,e.wrap&4&&A&&(n.adler=e.check=e.flags?Ln(e.check,i,A,n.next_out-A):Tf(e.check,i,A,n.next_out-A)),n.data_type=e.bits+(e.last?64:0)+(e.mode===Ss?128:0)+(e.mode===E0||e.mode===um?256:0),(y===0&&A===0||t===Mv)&&Y===Na&&(Y=x9),Y},C9=n=>{if(Ca(n))return ti;let t=n.state;return t.window&&(t.window=null),n.state=null,Na},B9=(n,t)=>{if(Ca(n))return ti;const e=n.state;return e.wrap&2?(e.head=t,t.done=!1,Na):ti},P9=(n,t)=>{const e=t.length;let r,i,s;return Ca(n)||(r=n.state,r.wrap!==0&&r.mode!==A0)?ti:r.mode===A0&&(i=1,i=Tf(i,t,e,0),i!==r.check)?Lv:(s=px(n,t,e,e),s?(r.mode=ox,Uv):(r.havedict=1,Na))};var M9=lx,L9=fx,U9=ux,D9=T9,F9=hx,$9=N9,H9=C9,z9=B9,G9=P9,V9="pako inflate (from Nodeca project)",Is={inflateReset:M9,inflateReset2:L9,inflateResetKeep:U9,inflateInit:D9,inflateInit2:F9,inflate:$9,inflateEnd:H9,inflateGetHeader:z9,inflateSetDictionary:G9,inflateInfo:V9};function K9(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var j9=K9;const gx=Object.prototype.toString,{Z_NO_FLUSH:W9,Z_FINISH:Z9,Z_OK:Ff,Z_STREAM_END:dm,Z_NEED_DICT:pm,Z_STREAM_ERROR:q9,Z_DATA_ERROR:yx,Z_MEM_ERROR:Q9}=Of;function $f(n){this.options=y0.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Iv,this.strm.avail_out=0;let e=Is.inflateInit2(this.strm,t.windowBits);if(e!==Ff)throw new Error(hu[e]);if(this.header=new j9,Is.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Uf.string2buf(t.dictionary):gx.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Is.inflateSetDictionary(this.strm,t.dictionary),e!==Ff)))throw new Error(hu[e])}$f.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,o,c;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?Z9:W9,gx.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=Is.inflate(e,o),s===pm&&i&&(s=Is.inflateSetDictionary(e,i),s===Ff?s=Is.inflate(e,o):s===yx&&(s=pm));e.avail_in>0&&s===dm&&e.state.wrap>0&&n[e.next_in]!==0;)Is.inflateReset(e),s=Is.inflate(e,o);switch(s){case q9:case yx:case pm:case Q9:return this.onEnd(s),this.ended=!0,!1}if(c=e.avail_out,e.next_out&&(e.avail_out===0||s===dm))if(this.options.to==="string"){let u=Uf.utf8border(e.output,e.next_out),f=e.next_out-u,h=Uf.buf2string(e.output,u);e.next_out=f,e.avail_out=r-f,f&&e.output.set(e.output.subarray(u,u+f),0),this.onData(h)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===Ff&&c===0)){if(s===dm)return s=Is.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0},$f.prototype.onData=function(n){this.chunks.push(n)},$f.prototype.onEnd=function(n){n===Ff&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=y0.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function gm(n,t){const e=new $f(t);if(e.push(n),e.err)throw e.msg||hu[e.err];return e.result}function Y9(n,t){return t=t||{},t.raw=!0,gm(n,t)}var J9=$f,X9=gm,tF=Y9,eF=gm,nF=Of,rF={Inflate:J9,inflate:X9,inflateRaw:tF,ungzip:eF,constants:nF};const{Inflate:BZ,inflate:iF,inflateRaw:PZ,ungzip:MZ}=rF;var sF=iF,mx={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,A){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new i(h,y||u,A),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],b]:u._events[R].push(b):(u._events[R]=b,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},c.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var A=0,b=y.length,R=new Array(b);A<b;A++)R[A]=y[A].fn;return R},c.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},c.prototype.emit=function(f,h,y,A,b,R){var k=e?e+f:f;if(!this._events[k])return!1;var S=this._events[k],B=arguments.length,H,U;if(S.fn){switch(S.once&&this.removeListener(f,S.fn,void 0,!0),B){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,y),!0;case 4:return S.fn.call(S.context,h,y,A),!0;case 5:return S.fn.call(S.context,h,y,A,b),!0;case 6:return S.fn.call(S.context,h,y,A,b,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];S.fn.apply(S.context,H)}else{var G=S.length,W;for(U=0;U<G;U++)switch(S[U].once&&this.removeListener(f,S[U].fn,void 0,!0),B){case 1:S[U].fn.call(S[U].context);break;case 2:S[U].fn.call(S[U].context,h);break;case 3:S[U].fn.call(S[U].context,h,y);break;case 4:S[U].fn.call(S[U].context,h,y,A);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];S[U].fn.apply(S[U].context,H)}}return!0},c.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},c.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},c.prototype.removeListener=function(f,h,y,A){var b=e?e+f:f;if(!this._events[b])return this;if(!h)return o(this,b),this;var R=this._events[b];if(R.fn)R.fn===h&&(!A||R.once)&&(!y||R.context===y)&&o(this,b);else{for(var k=0,S=[],B=R.length;k<B;k++)(R[k].fn!==h||A&&!R[k].once||y&&R[k].context!==y)&&S.push(R[k]);S.length?this._events[b]=S.length===1?S[0]:S:o(this,b)}return this},c.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,n.exports=c})(mx);var oF=mx.exports;const aF=Br(oF);function cF(n,t){return Array.apply(0,new Array(Math.ceil(n.length/t))).map((e,r)=>n.slice(r*t,(r+1)*t))}const Ba=n=>"version"in n;function uF(n){return new TextDecoder("utf-8").decode(n)}function wx(n){return Tn.encode(n)}function bx(n){return kt.from(n,"base64")}function Ao(n){return"accounts"in n}async function lF(n){const t=(await pt.findProgramAddress([],n))[0];return await pt.createWithSeed(t,fF(),n)}function fF(){return"anchor:idl"}const hF=Yt.struct([Yt.publicKey("authority"),Yt.vecU8("data")]);function dF(n){return hF.decode(n)}function pF(n){const t=["name","path","account","relations","generic"],e=s=>s.split(".").map(CU).join("."),r=s=>{for(const o in s){const c=s[o];t.includes(o)?s[o]=Array.isArray(c)?c.map(e):e(c):typeof c=="object"&&r(c)}},i=structuredClone(n);return r(i),i}function bu(n,t,e,r){return n!=null&&n.length?n[0].name?e(n):r(n):t()}function gF(n){const t=new Map;return n.errors&&n.errors.forEach(e=>{var r;let i=(r=e.msg)!==null&&r!==void 0?r:e.name;t.set(e.code,i)}),t}function yF(n,...t){if(n.args.length!=t.length)throw new Error("Invalid argument length");const e={};let r=0;return n.args.forEach(i=>{e[i.name]=t[r],r+=1}),e}function _x(n,t={}){n.forEach(e=>{if(Ao(e))_x(e.accounts,t[e.name]);else if(!t[e.name])throw new Error(`Account \`${e.name}\` not provided.`)})}function mi(n){return n instanceof pt?n:new pt(n)}class mF extends TypeError{constructor(t,e){let r;const{message:i,...s}=t,{path:o}=t,c=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(c),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var u;return(u=r)!=null?u:r=[t,...e()]}}}function wF(n){return _u(n)&&typeof n[Symbol.iterator]=="function"}function _u(n){return typeof n=="object"&&n!=null}function Eo(n){return typeof n=="string"?JSON.stringify(n):""+n}function bF(n){const{done:t,value:e}=n.next();return t?void 0:e}function _F(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:c,message:u="Expected a value of type `"+o+"`"+(c?" with refinement `"+c+"`":"")+", but received: `"+Eo(r)+"`"}=n;return{value:r,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*Ax(n,t,e,r){wF(n)||(n=[n]);for(const i of n){const s=_F(i,t,e,r);s&&(yield s)}}function*ym(n,t,e){e===void 0&&(e={});const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,c={path:r,branch:i};if(s&&(n=t.coercer(n,c),o&&t.type!=="type"&&_u(t.schema)&&_u(n)&&!Array.isArray(n)))for(const f in n)t.schema[f]===void 0&&delete n[f];let u=!0;for(const f of t.validator(n,c))u=!1,yield[f,void 0];for(let[f,h,y]of t.entries(n,c)){const A=ym(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o});for(const b of A)b[0]?(u=!1,yield[b[0],void 0]):s&&(h=b[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):_u(n)&&(n[f]=h))}if(u)for(const f of t.refiner(n,c))u=!1,yield[f,void 0];u&&(yield[void 0,n])}class vo{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=t;this.type=e,this.schema=r,this.entries=c,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return Ax(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return Ax(h,f,this,u)}:this.refiner=()=>[]}assert(t){return AF(t,this)}create(t){return mm(t,this)}is(t){return Ex(t,this)}mask(t){return EF(t,this)}validate(t,e){return e===void 0&&(e={}),Hf(t,this,e)}}function AF(n,t){const e=Hf(n,t);if(e[0])throw e[0]}function mm(n,t){const e=Hf(n,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function EF(n,t){const e=Hf(n,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function Ex(n,t){return!Hf(n,t)[0]}function Hf(n,t,e){e===void 0&&(e={});const r=ym(n,t,e),i=bF(r);return i[0]?[new mF(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function zf(n,t){return new vo({type:n,schema:null,validator:t})}function vF(){return zf("any",()=>!0)}function wm(n){return new vo({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+Eo(t)}})}function xF(){return zf("boolean",n=>typeof n=="boolean")}function vx(n){const t=Eo(n);return new vo({type:"literal",schema:n,validator(e){return e===n||"Expected the literal `"+t+"`, but received: "+Eo(e)}})}function x0(n){return new vo({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function R0(){return zf("number",n=>typeof n=="number"&&!isNaN(n)||"Expected a number, but received: "+Eo(n))}function S0(n){return new vo({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function Pa(){return zf("string",n=>typeof n=="string"||"Expected a string, but received: "+Eo(n))}function xo(n){const t=Object.keys(n);return new vo({type:"type",schema:n,*entries(e){if(_u(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return _u(e)||"Expected an object, but received: "+Eo(e)}})}function xx(n){const t=n.map(e=>e.type).join(" | ");return new vo({type:"union",schema:null,coercer(e,r){return(n.find(s=>{const[o]=s.validate(e,{coerce:!0});return!o})||bm()).coercer(e,r)},validator(e,r){const i=[];for(const s of n){const[...o]=ym(e,s,r),[c]=o;if(c[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+Eo(e),...i]}})}function bm(){return zf("unknown",()=>!0)}function RF(n,t,e){return new vo({...n,coercer:(r,i)=>Ex(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}const Rx=99;async function SF(n,t,e){if(t.length<=Rx)return await Sx(n,t,e);{const r=cF(t,Rx);return(await Promise.all(r.map(s=>Sx(n,s,e)))).flat()}}async function Sx(n,t,e){const r=e??n.commitment,{value:i,context:s}=await n.getMultipleAccountsInfoAndContext(t,r);return i.map((c,u)=>c===null?null:{publicKey:t[u],account:c,context:s})}async function IF(n,t,e,r,i){var s;e&&e.length>0&&t.sign(...e);const o=t._compile(),c=o.serialize(),f=t._serialize(c).toString("base64"),h={encoding:"base64",commitment:r??n.commitment};if(i){const R=(Array.isArray(i)?i:o.nonProgramIds()).map(k=>k.toBase58());h.accounts={encoding:"base64",addresses:R}}e&&e.length>0&&(h.sigVerify=!0);const y=[f,h],A=await n._rpcRequest("simulateTransaction",y),b=mm(A,NF);if("error"in b){let R;if("data"in b.error&&(R=(s=b.error.data)===null||s===void 0?void 0:s.logs,R&&Array.isArray(R))){const k=`
24
- `,S=k+R.join(k);console.error(b.error.message,S)}throw new go("failed to simulate transaction: "+b.error.message,R)}return b.result}function kF(n){return RF(Ix(n),TF,t=>"error"in t?t:{...t,result:mm(t.result,n)})}const TF=Ix(bm());function Ix(n){return xx([xo({jsonrpc:vx("2.0"),id:Pa(),result:n}),xo({jsonrpc:vx("2.0"),id:Pa(),error:xo({code:bm(),message:Pa(),data:S0(vF())})})])}function OF(n){return kF(xo({context:xo({slot:R0()}),value:n}))}const NF=OF(xo({err:x0(xx([xo({}),Pa()])),logs:x0(wm(Pa())),accounts:S0(x0(wm(x0(xo({executable:xF(),owner:Pa(),lamports:R0(),data:wm(Pa()),rentEpoch:S0(R0())}))))),unitsConsumed:S0(R0())}));class Gf{constructor(t,e,r=Gf.defaultOptions()){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=e==null?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e=Gf.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var i,s,o,c;if(r===void 0&&(r=this.opts),Ba(t))e&&t.sign(e);else if(t.feePayer=(i=t.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const f of e)t.partialSign(f);t=await this.wallet.signTransaction(t);const u=t.serialize();try{return await kx(this.connection,u,r)}catch(f){if(f instanceof _m){const h=wx(Ba(t)?((s=t.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=t.signature)!==null&&o!==void 0?o:new Uint8Array),y=Ba(t)?0:void 0,A=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:y});if(A){const b=(c=A.meta)===null||c===void 0?void 0:c.logMessages;throw b?new go(f.message,b):f}else throw f}else throw f}}async sendAll(t,e){var r,i,s;e===void 0&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let c=t.map(h=>{var y,A;if(Ba(h.tx)){let b=h.tx;return h.signers&&b.sign(h.signers),b}else{let b=h.tx,R=(y=h.signers)!==null&&y!==void 0?y:[];return b.feePayer=(A=b.feePayer)!==null&&A!==void 0?A:this.wallet.publicKey,b.recentBlockhash=o,R.forEach(k=>{b.partialSign(k)}),b}});const u=await this.wallet.signAllTransactions(c),f=[];for(let h=0;h<c.length;h+=1){const y=u[h],A=y.serialize();try{f.push(await kx(this.connection,A,e))}catch(b){if(b instanceof _m){const R=wx(Ba(y)?((r=y.signatures)===null||r===void 0?void 0:r[0])||new Uint8Array:(i=y.signature)!==null&&i!==void 0?i:new Uint8Array),k=Ba(y)?0:void 0,S=await this.connection.getTransaction(R,{commitment:"confirmed",maxSupportedTransactionVersion:k});if(S){const B=(s=S.meta)===null||s===void 0?void 0:s.logMessages;throw B?new go(b.message,B):b}else throw b}else throw b}}return f}async simulate(t,e,r,i){let s=(await this.connection.getLatestBlockhash(r??this.connection.commitment)).blockhash,o;if(Ba(t)?(e&&e.length>0&&(t.sign(e),t=await this.wallet.signTransaction(t)),o=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=s,e&&e.length>0&&(t=await this.wallet.signTransaction(t)),o=await IF(this.connection,t,e,r,i)),o.value.err)throw new CF(o.value);return o.value}}class CF extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function kx(n,t,e){const r=e?{skipPreflight:e.skipPreflight,preflightCommitment:e.preflightCommitment||e.commitment,maxRetries:e.maxRetries,minContextSlot:e.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await n.sendRawTransaction(t,r);if(e!=null&&e.blockhash)if(r.maxRetries===0){const c=AbortSignal.timeout(15e3);i=(await n.confirmTransaction({abortSignal:c,signature:o,...e.blockhash},e&&e.commitment)).value}else i=(await n.confirmTransaction({signature:o,...e.blockhash},e&&e.commitment)).value;else i=(await n.confirmTransaction(o,e&&e.commitment)).value;if(i.err)throw new _m(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class _m extends Error{constructor(t){super(t)}}function Am(){return Gf.local()}var BF=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Hc<"u"?Hc:typeof self<"u"?self:{},tt={};Object.defineProperty(tt,"__esModule",{value:!0});var Tx=tt.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=R2=tt.ANCHOR_ERROR__REQUIRE_VIOLATED=x2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=v2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=E2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=A2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=_2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=b2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=w2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=m2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=y2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=g2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=p2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=d2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=h2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=f2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=l2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=u2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=c2=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=a2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=o2=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=s2=tt.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=i2=tt.ANCHOR_ERROR__CONSTRAINT_SPACE=r2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=n2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=e2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=t2=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=Xx=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=Jx=tt.ANCHOR_ERROR__CONSTRAINT_ZERO=Yx=tt.ANCHOR_ERROR__CONSTRAINT_ADDRESS=Qx=tt.ANCHOR_ERROR__CONSTRAINT_CLOSE=qx=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=Zx=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=Wx=tt.ANCHOR_ERROR__CONSTRAINT_STATE=jx=tt.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=Kx=tt.ANCHOR_ERROR__CONSTRAINT_SEEDS=Vx=tt.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=Gx=tt.ANCHOR_ERROR__CONSTRAINT_OWNER=zx=tt.ANCHOR_ERROR__CONSTRAINT_RAW=Hx=tt.ANCHOR_ERROR__CONSTRAINT_SIGNER=$x=tt.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=Fx=tt.ANCHOR_ERROR__CONSTRAINT_MUT=Dx=tt.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=Ux=tt.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=Lx=tt.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=Mx=tt.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=Px=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=Bx=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=Cx=tt.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=Nx=tt.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,Ox=tt.ANCHOR_ERROR__DEPRECATED=Y2=tt.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=Q2=tt.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=q2=tt.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=Z2=tt.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=W2=tt.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=j2=tt.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=K2=tt.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=V2=tt.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=G2=tt.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=z2=tt.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=H2=tt.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=$2=tt.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=F2=tt.ANCHOR_ERROR__INVALID_PROGRAM_ID=D2=tt.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=U2=tt.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=L2=tt.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=M2=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=P2=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=B2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=C2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=N2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=O2=tt.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=T2=tt.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=k2=tt.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=I2=tt.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=S2=tt.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,Nx=tt.ANCHOR_ERROR__INSTRUCTION_MISSING=100,Cx=tt.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,Bx=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,Px=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,Mx=tt.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,Lx=tt.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,Ux=tt.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,Dx=tt.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,Fx=tt.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,$x=tt.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,Hx=tt.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,zx=tt.ANCHOR_ERROR__CONSTRAINT_RAW=2003,Gx=tt.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,Vx=tt.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,Kx=tt.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,jx=tt.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,Wx=tt.ANCHOR_ERROR__CONSTRAINT_STATE=2008,Zx=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,qx=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,Qx=tt.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,Yx=tt.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,Jx=tt.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,Xx=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,t2=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,e2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,n2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,r2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,i2=tt.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,s2=tt.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,o2=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,a2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,c2=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,u2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,l2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,f2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,h2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,d2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,p2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,g2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,y2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,m2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,w2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,b2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,_2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,A2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,E2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,v2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,x2=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,R2=tt.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;Tx=tt.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var S2=tt.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,I2=tt.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,k2=tt.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,T2=tt.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,O2=tt.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,N2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,C2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,B2=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,P2=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,M2=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,L2=tt.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,U2=tt.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,D2=tt.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,F2=tt.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,$2=tt.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,H2=tt.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,z2=tt.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,G2=tt.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,V2=tt.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,K2=tt.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,j2=tt.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,W2=tt.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,Z2=tt.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,q2=tt.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,Q2=tt.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,Y2=tt.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;Ox=tt.ANCHOR_ERROR__DEPRECATED=5e3;const PF=new Map;function J2(n){return PF.get(n)!==void 0}class Ro extends Error{constructor(t){super(t),this.name="IdlError"}}class Vf{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<t.length;o++){if(i.exec(t[o])){s.pop();continue}const c=(e=r.exec(t[o]))===null||e===void 0?void 0:e[1];c&&s.push(new pt(c))}return new Vf(s)}}class Kf extends Error{constructor(t,e,r,i,s,o){super(r.join(`
25
- `).replace("Program log: ","")),this.errorLogs=r,this.logs=i,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:s},this._programErrorStack=Vf.parse(i)}static parse(t){if(!t)return null;const e=t.findIndex(A=>A.startsWith("Program log: AnchorError"));if(e===-1)return null;const r=t[e],i=[r];let s;if(e+1<t.length){if(t[e+1]==="Program log: Left:"){const A=/^Program log: (.*)$/,b=A.exec(t[e+2])[1],R=A.exec(t[e+4])[1];s=[new pt(b),new pt(R)],i.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const A=/^Program log: (Left|Right): (.*)$/,b=A.exec(t[e+1])[2],R=A.exec(t[e+2])[2];i.push(...t.slice(e+1,e+3)),s=[b,R]}}const c=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),f=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),y=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(c){const[A,b,R]=c.slice(1,4),k={code:A,number:parseInt(b)};return new Kf(k,R,i,t,void 0,s)}else if(f){const[A,b,R,k,S]=f.slice(1,6),B={code:R,number:parseInt(k)},H={file:A,line:parseInt(b)};return new Kf(B,S,i,t,H,s)}else if(y){const[A,b,R,k]=y.slice(1,5),S=A,B={code:b,number:parseInt(R)};return new Kf(B,k,i,t,S,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class I0 extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=Vf.parse(r))}static parse(t,e){const r=t.toString();let i;if(r.includes("custom program error:")){let c=r.split("custom program error: ");if(c.length!==2)return null;i=c[1]}else{const c=r.match(/"Custom":([0-9]+)}/g);if(!c||c.length>1)return null;i=c[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=e.get(s);return o!==void 0?new I0(s,o,t.logs):(o=MF.get(s),o!==void 0?new I0(s,o,t.logs):null)}get program(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack}toString(){return this.msg}}function X2(n,t){J2("debug-logs")&&console.log("Translating error:",n);const e=Kf.parse(n.logs);if(e)return e;const r=I0.parse(n,t);if(r)return r;if(n.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[n.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return n.programErrorStack=Vf.parse(n.logs),new Proxy(n,i)}return n}const bt={InstructionMissing:Nx,InstructionFallbackNotFound:Cx,InstructionDidNotDeserialize:Bx,InstructionDidNotSerialize:Px,IdlInstructionStub:Mx,IdlInstructionInvalidProgram:Lx,IdlAccountNotEmpty:Ux,EventInstructionStub:Dx,ConstraintMut:Fx,ConstraintHasOne:$x,ConstraintSigner:Hx,ConstraintRaw:zx,ConstraintOwner:Gx,ConstraintRentExempt:Vx,ConstraintSeeds:Kx,ConstraintExecutable:jx,ConstraintState:Wx,ConstraintAssociated:Zx,ConstraintAssociatedInit:qx,ConstraintClose:Qx,ConstraintAddress:Yx,ConstraintZero:Jx,ConstraintTokenMint:Xx,ConstraintTokenOwner:t2,ConstraintMintMintAuthority:e2,ConstraintMintFreezeAuthority:n2,ConstraintMintDecimals:r2,ConstraintSpace:i2,ConstraintAccountIsNone:s2,ConstraintTokenTokenProgram:o2,ConstraintMintTokenProgram:a2,ConstraintAssociatedTokenTokenProgram:c2,ConstraintMintGroupPointerExtension:u2,ConstraintMintGroupPointerExtensionAuthority:l2,ConstraintMintGroupPointerExtensionGroupAddress:f2,ConstraintMintGroupMemberPointerExtension:h2,ConstraintMintGroupMemberPointerExtensionAuthority:d2,ConstraintMintGroupMemberPointerExtensionMemberAddress:p2,ConstraintMintMetadataPointerExtension:g2,ConstraintMintMetadataPointerExtensionAuthority:y2,ConstraintMintMetadataPointerExtensionMetadataAddress:m2,ConstraintMintCloseAuthorityExtension:w2,ConstraintMintCloseAuthorityExtensionAuthority:b2,ConstraintMintPermanentDelegateExtension:_2,ConstraintMintPermanentDelegateExtensionDelegate:A2,ConstraintMintTransferHookExtension:E2,ConstraintMintTransferHookExtensionAuthority:v2,ConstraintMintTransferHookExtensionProgramId:x2,RequireViolated:R2,RequireEqViolated:Tx,RequireKeysEqViolated:S2,RequireNeqViolated:I2,RequireKeysNeqViolated:k2,RequireGtViolated:T2,RequireGteViolated:O2,AccountDiscriminatorAlreadySet:N2,AccountDiscriminatorNotFound:C2,AccountDiscriminatorMismatch:B2,AccountDidNotDeserialize:P2,AccountDidNotSerialize:M2,AccountNotEnoughKeys:L2,AccountNotMutable:U2,AccountOwnedByWrongProgram:D2,InvalidProgramId:F2,InvalidProgramExecutable:$2,AccountNotSigner:H2,AccountNotSystemOwned:z2,AccountNotInitialized:G2,AccountNotProgramData:V2,AccountNotAssociatedTokenAccount:K2,AccountSysvarMismatch:j2,AccountReallocExceedsLimit:W2,AccountDuplicateReallocs:Z2,DeclaredProgramIdMismatch:q2,TryingToInitPayerAsProgramAccount:Q2,InvalidNumericConversion:Y2,Deprecated:Ox},MF=new Map([[bt.InstructionMissing,"Instruction discriminator not provided"],[bt.InstructionFallbackNotFound,"Fallback functions are not supported"],[bt.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[bt.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[bt.IdlInstructionStub,"The program was compiled without idl instructions"],[bt.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[bt.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[bt.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[bt.ConstraintMut,"A mut constraint was violated"],[bt.ConstraintHasOne,"A has one constraint was violated"],[bt.ConstraintSigner,"A signer constraint was violated"],[bt.ConstraintRaw,"A raw constraint was violated"],[bt.ConstraintOwner,"An owner constraint was violated"],[bt.ConstraintRentExempt,"A rent exemption constraint was violated"],[bt.ConstraintSeeds,"A seeds constraint was violated"],[bt.ConstraintExecutable,"An executable constraint was violated"],[bt.ConstraintState,"Deprecated Error, feel free to replace with something else"],[bt.ConstraintAssociated,"An associated constraint was violated"],[bt.ConstraintAssociatedInit,"An associated init constraint was violated"],[bt.ConstraintClose,"A close constraint was violated"],[bt.ConstraintAddress,"An address constraint was violated"],[bt.ConstraintZero,"Expected zero account discriminant"],[bt.ConstraintTokenMint,"A token mint constraint was violated"],[bt.ConstraintTokenOwner,"A token owner constraint was violated"],[bt.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[bt.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[bt.ConstraintMintDecimals,"A mint decimals constraint was violated"],[bt.ConstraintSpace,"A space constraint was violated"],[bt.ConstraintAccountIsNone,"A required account for the constraint is None"],[bt.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[bt.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[bt.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[bt.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[bt.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[bt.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[bt.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[bt.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[bt.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[bt.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[bt.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[bt.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[bt.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[bt.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[bt.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[bt.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[bt.RequireViolated,"A require expression was violated"],[bt.RequireEqViolated,"A require_eq expression was violated"],[bt.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[bt.RequireNeqViolated,"A require_neq expression was violated"],[bt.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[bt.RequireGtViolated,"A require_gt expression was violated"],[bt.RequireGteViolated,"A require_gte expression was violated"],[bt.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[bt.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[bt.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[bt.AccountDidNotDeserialize,"Failed to deserialize the account"],[bt.AccountDidNotSerialize,"Failed to serialize the account"],[bt.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[bt.AccountNotMutable,"The given account is not mutable"],[bt.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[bt.InvalidProgramId,"Program ID was not as expected"],[bt.InvalidProgramExecutable,"Program account is not executable"],[bt.AccountNotSigner,"The given account did not sign"],[bt.AccountNotSystemOwned,"The given account is not owned by the system program"],[bt.AccountNotInitialized,"The program expected this account to be already initialized"],[bt.AccountNotProgramData,"The given account is not a program data account"],[bt.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[bt.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[bt.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[bt.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[bt.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[bt.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[bt.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[bt.Deprecated,"The API being used is deprecated and should no longer be used"]]);class ge{static fieldLayout(t,e=[],r){const i=t.name;switch(t.type){case"bool":return Yt.bool(i);case"u8":return Yt.u8(i);case"i8":return Yt.i8(i);case"u16":return Yt.u16(i);case"i16":return Yt.i16(i);case"u32":return Yt.u32(i);case"i32":return Yt.i32(i);case"f32":return Yt.f32(i);case"u64":return Yt.u64(i);case"i64":return Yt.i64(i);case"f64":return Yt.f64(i);case"u128":return Yt.u128(i);case"i128":return Yt.i128(i);case"u256":return Yt.u256(i);case"i256":return Yt.i256(i);case"bytes":return Yt.vecU8(i);case"string":return Yt.str(i);case"pubkey":return Yt.publicKey(i);default:{if("option"in t.type)return Yt.option(ge.fieldLayout({type:t.type.option},e,r),i);if("vec"in t.type)return Yt.vec(ge.fieldLayout({type:t.type.vec},e,r),i);if("array"in t.type){let[s,o]=t.type.array;return o=ge.resolveArrayLen(o,r),Yt.array(ge.fieldLayout({type:s},e,r),o,i)}if("defined"in t.type){if(!e)throw new Ro("User defined types not provided");const s=t.type.defined.name,o=e.find(c=>c.name===s);if(!o)throw new Ro(`Type not found: ${t.name}`);return ge.typeDefLayout({typeDef:o,types:e,genericArgs:r??t.type.defined.generics,name:i})}if("generic"in t.type){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new Ro(`Invalid generic field: ${t.name}`);return ge.fieldLayout({...t,type:s.type},e)}throw new Ro(`Not yet implemented: ${JSON.stringify(t.type)}`)}}}static typeDefLayout({typeDef:t,types:e,name:r,genericArgs:i}){switch(t.type.kind){case"struct":{const s=bu(t.type.fields,()=>[],o=>o.map(c=>{const u=i&&ge.resolveGenericArgs({type:c.type,typeDef:t,genericArgs:i});return ge.fieldLayout(c,e,u)}),o=>o.map((c,u)=>{const f=i&&ge.resolveGenericArgs({type:c,typeDef:t,genericArgs:i});return ge.fieldLayout({name:u.toString(),type:c},e,f)}));return Yt.struct(s,r)}case"enum":{const s=t.type.variants.map(o=>{const c=bu(o.fields,()=>[],u=>u.map(f=>{const h=i&&ge.resolveGenericArgs({type:f.type,typeDef:t,genericArgs:i});return ge.fieldLayout(f,e,h)}),u=>u.map((f,h)=>{const y=i&&ge.resolveGenericArgs({type:f,typeDef:t,genericArgs:i});return ge.fieldLayout({name:h.toString(),type:f},e,y)}));return Yt.struct(c,o.name)});return r!==void 0?Yt.rustEnum(s).replicate(r):Yt.rustEnum(s,r)}case"type":return ge.fieldLayout({type:t.type.alias,name:r},e)}}static typeSize(t,e,r){var i;switch(t){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in t)return 1+ge.typeSize(t.option,e,r);if("coption"in t)return 4+ge.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[s,o]=t.array;return o=ge.resolveArrayLen(o,r),ge.typeSize(s,e,r)*o}if("defined"in t){const s=(i=e.types)===null||i===void 0?void 0:i.find(c=>c.name===t.defined.name);if(!s)throw new Ro(`Type not found: ${JSON.stringify(t)}`);const o=c=>{const u=r??t.defined.generics,f=u&&ge.resolveGenericArgs({type:c,typeDef:s,genericArgs:u});return ge.typeSize(c,e,f)};switch(s.type.kind){case"struct":return bu(s.type.fields,()=>[0],c=>c.map(u=>o(u.type)),c=>c.map(u=>o(u))).reduce((c,u)=>c+u,0);case"enum":{const c=s.type.variants.map(u=>bu(u.fields,()=>[0],f=>f.map(h=>o(h.type)),f=>f.map(h=>o(h))).reduce((f,h)=>f+h,0));return Math.max(...c)+1}case"type":return ge.typeSize(s.type.alias,e,r)}}if("generic"in t){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new Ro(`Invalid generic: ${t.generic}`);return ge.typeSize(s.type,e,r)}throw new Error(`Invalid type ${JSON.stringify(t)}`)}}static resolveArrayLen(t,e){if(typeof t=="number")return t;if(e){const r=e.find(i=>i.kind==="const");(r==null?void 0:r.kind)==="const"&&(t=+r.value)}if(typeof t!="number")throw new Ro("Generic array length did not resolve");return t}static resolveGenericArgs({type:t,typeDef:e,genericArgs:r,isDefined:i}){if(typeof t!="object")return null;for(const s in e.generics){const o=e.generics[s];if("generic"in t&&o.name===t.generic)return[r[s]];if("option"in t){const c=ge.resolveGenericArgs({type:t.option,typeDef:e,genericArgs:r,isDefined:i});if(!c||!i)return c;if(c[0].kind==="type")return[{kind:"type",type:{option:c[0].type}}]}if("vec"in t){const c=ge.resolveGenericArgs({type:t.vec,typeDef:e,genericArgs:r,isDefined:i});if(!c||!i)return c;if(c[0].kind==="type")return[{kind:"type",type:{vec:c[0].type}}]}if("array"in t){const[c,u]=t.array,f=typeof u=="object",h=ge.resolveGenericArgs({type:c,typeDef:e,genericArgs:r,isDefined:i});if(h){for(const y in e.generics.slice(+s)){const A=+s+ +y;f&&e.generics[A].name===u.generic&&h.push(r[A])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(f&&o.name===u.generic){const y=r[s];return i?[{kind:"type",type:{array:[c,+y.value]}}]:[y]}return null}if("defined"in t)return t.defined.generics?t.defined.generics.flatMap(c=>{switch(c.kind){case"type":return ge.resolveGenericArgs({type:c.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[c]}}).filter(c=>c!==null):null}return null}}class LF{constructor(t){this.idl=t;const e=t.instructions.map(r=>{const i=r.name,s=r.args.map(c=>ge.fieldLayout(c,t.types)),o=Yt.struct(s,i);return[i,{discriminator:r.discriminator,layout:o}]});this.ixLayouts=new Map(e)}encode(t,e){const r=kt.alloc(1e3),i=this.ixLayouts.get(t);if(!i)throw new Error(`Unknown method: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s);return kt.concat([kt.from(i.discriminator),o])}decode(t,e="hex"){typeof t=="string"&&(t=e==="hex"?kt.from(t,"hex"):Tn.decode(t));for(const[r,i]of this.ixLayouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(kt.from(i.discriminator)))return{name:r,data:i.layout.decode(t.subarray(s.length))}}return null}format(t,e){return Hr.format(t,e,this.idl)}}class Hr{static format(t,e,r){const i=r.instructions.find(u=>t.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Hr.formatIdlType(u.type),data:Hr.formatIdlData(u,t.data[u.name],r.types)})),o=Hr.flattenIdlAccounts(i.accounts),c=e.map((u,f)=>f<o.length?{name:o[f].name,...u}:{name:void 0,...u});return{args:s,accounts:c}}static formatIdlType(t){if(typeof t=="string")return t;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("coption"in t)return`COption<${this.formatIdlType(t.coption)}>`;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;if("defined"in t){const e=t.defined.name;if(t.defined.generics){const r=t.defined.generics.map(i=>{switch(i.kind){case"type":return Hr.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${e}<${r}>`}return e}throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if(typeof t.type=="string")return e.toString();if("vec"in t.type)return"["+e.map(i=>this.formatIdlData({name:"",type:t.type.vec},i,r)).join(", ")+"]";if("option"in t.type)return e===null?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if("defined"in t.type){if(!r)throw new Error("User defined types not provided");const i=t.type.defined.name,s=r.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Hr.formatIdlDataDefined(s,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+bu(t.type.fields,()=>"",i=>Object.entries(e).map(([s,o])=>{const c=i.find(u=>u.name===s);if(!c)throw new Error(`Field not found: ${s}`);return s+": "+Hr.formatIdlData(c,o,r)}).join(", "),i=>Object.entries(e).map(([s,o])=>s+": "+Hr.formatIdlData({name:"",type:i[s]},o,r)).join(", "))+" }";case"enum":{const i=Object.keys(e)[0],s=t.type.variants.find(c=>c.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=e[i];return bu(s.fields,()=>i,c=>{const u=Object.keys(o).map(f=>{const h=o[f],y=c.find(A=>A.name===f);if(!y)throw new Error(`Field not found: ${f}`);return f+": "+Hr.formatIdlData(y,h,r)}).join(", ");return`${i} { ${u} }`},c=>{const u=Object.entries(o).map(([f,h])=>f+": "+Hr.formatIdlData({name:"",type:c[f]},h,r)).join(", ");return`${i} { ${u} }`})}case"type":return Hr.formatIdlType(t.type.alias)}}static flattenIdlAccounts(t,e){return t.map(r=>{const i=UF(r.name);if(r.hasOwnProperty("accounts")){const s=e?`${e} > ${i}`:i;return Hr.flattenIdlAccounts(r.accounts,s)}else return{...r,name:e?`${e} > ${i}`:i}}).flat()}}function UF(n){const t=n.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}class DF{constructor(t){if(this.idl=t,!t.accounts){this.accountLayouts=new Map;return}const e=t.types;if(!e)throw new Error("Accounts require `idl.types`");const r=t.accounts.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:ge.typeDefLayout({typeDef:s,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){const r=kt.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s),c=this.accountDiscriminator(t);return kt.concat([c,o])}decode(t,e){const r=this.accountDiscriminator(t);if(r.compare(e.slice(0,r.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){for(const[e,r]of this.accountLayouts)if(t.subarray(0,r.discriminator.length).equals(kt.from(r.discriminator)))return this.decodeUnchecked(e,t);throw new Error("Account not found")}decodeUnchecked(t,e){const r=this.accountDiscriminator(t),i=e.subarray(r.length),s=this.accountLayouts.get(t);if(!s)throw new Error(`Unknown account: ${t}`);return s.layout.decode(i)}memcmp(t,e){const r=this.accountDiscriminator(t);return{offset:0,bytes:Tn.encode(e?kt.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+ge.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;const r=(e=this.idl.accounts)===null||e===void 0?void 0:e.find(i=>i.name===t);if(!r)throw new Error(`Account not found: ${t}`);return kt.from(r.discriminator)}}class FF{constructor(t){if(!t.events){this.layouts=new Map;return}const e=t.types;if(!e)throw new Error("Events require `idl.types`");const r=t.events.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:ge.typeDefLayout({typeDef:s,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=bx(t)}catch{return null}for(const[r,i]of this.layouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(kt.from(i.discriminator)))return{name:r,data:i.layout.decode(e.subarray(s.length))}}return null}}class $F{constructor(t){const e=t.types;if(!e){this.typeLayouts=new Map;return}const r=e.filter(i=>!i.generics).map(i=>[i.name,ge.typeDefLayout({typeDef:i,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){const r=kt.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const s=i.encode(e,r);return r.slice(0,s)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class tR{constructor(t){this.instruction=new LF(t),this.accounts=new DF(t),this.events=new FF(t),this.types=new $F(t)}}class Ir{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var k0=Ir;function HF(n,t){return t.property?n+"["+t.property+"]":n}class Ma extends Ir{isCount(){throw new Error("ExternalLayout is abstract")}}class eR extends Ma{constructor(t,e,r){if(!(t instanceof Ir))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof T0||this.layout instanceof nR}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}}class T0 extends Ir{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class nR extends Ir{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const Em=Math.pow(2,32);function rR(n){const t=Math.floor(n/Em),e=n-t*Em;return{hi32:t,lo32:e}}function iR(n,t){return n*Em+t}class zF extends Ir{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return iR(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=rR(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}}class GF extends Ir{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return iR(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=rR(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}}class VF extends Ir{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ir,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class sR{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class oR extends sR{constructor(t,e){if(!(t instanceof Ma&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class aR extends Ir{constructor(t,e,r){const i=t instanceof T0||t instanceof nR;if(i)t=new oR(new eR(t));else if(t instanceof Ma&&t.isCount())t=new oR(t);else if(!(t instanceof sR))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ir))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let c=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(c=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+c)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new KF(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class KF extends Ir{constructor(t,e,r,i){if(!(t instanceof aR))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ir))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class jF extends Ir{constructor(t,e){if(!(t instanceof Ma&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ma||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Ma&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(HF("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Ma&&this.length.encode(i,e,r),i}}var WF=(n,t,e)=>new eR(n,t,e),ZF=n=>new T0(1,n),ks=n=>new T0(4,n),qF=n=>new zF(n),Ts=n=>new GF(n),Cn=(n,t,e)=>new VF(n,t,e),cR=(n,t,e)=>new aR(n,t,e),jf=(n,t)=>new jF(n,t);class QF extends k0{constructor(t){super(-1,t),this.property=t,this.layout=Cn([ks("length"),ks("lengthPadding"),jf(WF(ks(),-8),"chars")],this.property)}encode(t,e,r=0){if(t==null)return this.layout.span;const i={chars:Zt.from(t,"utf8")};return this.layout.encode(i,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return ks().span+ks().span+new ys(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function O0(n){return new QF(n)}function ei(n){return jf(32,n)}const zr=cR(ks("instruction"));zr.addVariant(0,Cn([Ts("lamports"),Ts("space"),ei("owner")]),"createAccount"),zr.addVariant(1,Cn([ei("owner")]),"assign"),zr.addVariant(2,Cn([Ts("lamports")]),"transfer"),zr.addVariant(3,Cn([ei("base"),O0("seed"),Ts("lamports"),Ts("space"),ei("owner")]),"createAccountWithSeed"),zr.addVariant(4,Cn([ei("authorized")]),"advanceNonceAccount"),zr.addVariant(5,Cn([Ts("lamports")]),"withdrawNonceAccount"),zr.addVariant(6,Cn([ei("authorized")]),"initializeNonceAccount"),zr.addVariant(7,Cn([ei("authorized")]),"authorizeNonceAccount"),zr.addVariant(8,Cn([Ts("space")]),"allocate"),zr.addVariant(9,Cn([ei("base"),O0("seed"),Ts("space"),ei("owner")]),"allocateWithSeed"),zr.addVariant(10,Cn([ei("base"),O0("seed"),ei("owner")]),"assignWithSeed"),zr.addVariant(11,Cn([Ts("lamports"),O0("seed"),ei("owner")]),"transferWithSeed"),Math.max(...Object.values(zr.registry).map(n=>n.span));class YF extends k0{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function uR(n){return new YF(jf(32),t=>new pt(t),t=>t.toBuffer(),n)}Cn([ks("version"),ks("state"),uR("authorizedPubkey"),uR("nonce"),Cn([qF("lamportsPerSignature")],"feeCalculator")]),new pt("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new pt("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var lR={exports:{}};(function(n,t){var e=typeof self<"u"?self:BF,r=function(){function s(){this.fetch=!1,this.DOMException=e.DOMException}return s.prototype=e,new s}();(function(s){(function(o){var c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(p){return p&&DataView.prototype.isPrototypeOf(p)}if(c.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&f.indexOf(Object.prototype.toString.call(p))>-1};function y(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function A(p){return typeof p!="string"&&(p=String(p)),p}function b(p){var m={next:function(){var v=p.shift();return{done:v===void 0,value:v}}};return c.iterable&&(m[Symbol.iterator]=function(){return m}),m}function R(p){this.map={},p instanceof R?p.forEach(function(m,v){this.append(v,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}R.prototype.append=function(p,m){p=y(p),m=A(m);var v=this.map[p];this.map[p]=v?v+", "+m:m},R.prototype.delete=function(p){delete this.map[y(p)]},R.prototype.get=function(p){return p=y(p),this.has(p)?this.map[p]:null},R.prototype.has=function(p){return this.map.hasOwnProperty(y(p))},R.prototype.set=function(p,m){this.map[y(p)]=A(m)},R.prototype.forEach=function(p,m){for(var v in this.map)this.map.hasOwnProperty(v)&&p.call(m,this.map[v],v,this)},R.prototype.keys=function(){var p=[];return this.forEach(function(m,v){p.push(v)}),b(p)},R.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),b(p)},R.prototype.entries=function(){var p=[];return this.forEach(function(m,v){p.push([v,m])}),b(p)},c.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function k(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function S(p){return new Promise(function(m,v){p.onload=function(){m(p.result)},p.onerror=function(){v(p.error)}})}function B(p){var m=new FileReader,v=S(m);return m.readAsArrayBuffer(p),v}function H(p){var m=new FileReader,v=S(m);return m.readAsText(p),v}function U(p){for(var m=new Uint8Array(p),v=new Array(m.length),I=0;I<m.length;I++)v[I]=String.fromCharCode(m[I]);return v.join("")}function G(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function W(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p:c.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:c.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():c.arrayBuffer&&c.blob&&u(p)?(this._bodyArrayBuffer=G(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=G(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var p=k(this);if(p)return p;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?k(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var p=k(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(U(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(it)}),this.json=function(){return this.text().then(JSON.parse)},this}var J=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(p){var m=p.toUpperCase();return J.indexOf(m)>-1?m:p}function Y(p,m){m=m||{};var v=m.body;if(p instanceof Y){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new R(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!v&&p._bodyInit!=null&&(v=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new R(m.headers)),this.method=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&v)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(v)}Y.prototype.clone=function(){return new Y(this,{body:this._bodyInit})};function it(p){var m=new FormData;return p.trim().split("&").forEach(function(v){if(v){var I=v.split("="),N=I.shift().replace(/\+/g," "),M=I.join("=").replace(/\+/g," ");m.append(decodeURIComponent(N),decodeURIComponent(M))}}),m}function ut(p){var m=new R,v=p.replace(/\r?\n[\t ]+/g," ");return v.split(/\r?\n/).forEach(function(I){var N=I.split(":"),M=N.shift().trim();if(M){var z=N.join(":").trim();m.append(M,z)}}),m}W.call(Y.prototype);function rt(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new R(m.headers),this.url=m.url||"",this._initBody(p)}W.call(rt.prototype),rt.prototype.clone=function(){return new rt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},rt.error=function(){var p=new rt(null,{status:0,statusText:""});return p.type="error",p};var ot=[301,302,303,307,308];rt.redirect=function(p,m){if(ot.indexOf(m)===-1)throw new RangeError("Invalid status code");return new rt(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,v){this.message=m,this.name=v;var I=Error(m);this.stack=I.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function C(p,m){return new Promise(function(v,I){var N=new Y(p,m);if(N.signal&&N.signal.aborted)return I(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function z(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ut(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var _="response"in M?M.response:M.responseText;v(new rt(_,P))},M.onerror=function(){I(new TypeError("Network request failed"))},M.ontimeout=function(){I(new TypeError("Network request failed"))},M.onabort=function(){I(new o.DOMException("Aborted","AbortError"))},M.open(N.method,N.url,!0),N.credentials==="include"?M.withCredentials=!0:N.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&c.blob&&(M.responseType="blob"),N.headers.forEach(function(P,_){M.setRequestHeader(_,P)}),N.signal&&(N.signal.addEventListener("abort",z),M.onreadystatechange=function(){M.readyState===4&&N.signal.removeEventListener("abort",z)}),M.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return C.polyfill=!0,s.fetch||(s.fetch=C,s.Headers=R,s.Request=Y,s.Response=rt),o.Headers=R,o.Request=Y,o.Response=rt,o.fetch=C,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,n.exports=t})(lR,lR.exports),Yt.rustEnum([Yt.struct([],"uninitialized"),Yt.struct([Yt.option(Yt.publicKey(),"authorityAddress")],"buffer"),Yt.struct([Yt.publicKey("programdataAddress")],"program"),Yt.struct([Yt.u64("slot"),Yt.option(Yt.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,Yt.u32());const vm="Program log: ",fR="Program data: ",JF=vm.length,XF=fR.length;class t7{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new hR(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e,r){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,((i=this._eventListeners.get(t))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[t,e]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,c)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const f=this._eventListeners.get(u.name);f&&f.forEach(h=>{const y=this._eventCallbacks.get(h);if(y){const[,A]=y;A(u.data,c.slot,o.signature)}})}},r)),s}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let i=this._eventListeners.get(r);if(!i)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),i=i.filter(s=>s!==t),this._eventListeners.set(r,i),i.length===0&&this._eventListeners.delete(r),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class hR{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new n7(t),i=new e7;let s=r.next();for(;s!==null;){let[o,c,u]=this.handleLog(i,s,e);o&&(yield o),c&&i.push(c),u&&i.pop(),s=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(vm)||t.startsWith(fR)){const r=t.startsWith(vm)?t.slice(JF):t.slice(XF),i=this.coder.events.decode(r);if(e&&i===null)throw new Error(`Unable to decode event ${r}`);return[i,null,!1]}else return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return e.match(/^Program (.*) success/g)!==null?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class e7{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class n7{constructor(t){this.logs=t}next(){if(this.logs.length===0)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}function N0(n,t){var e,r;let i={};const s=n.args?n.args.length:0;if(t.length>s){if(t.length!==s+1)throw new Error(`provided too many arguments ${t} to instruction ${n==null?void 0:n.name} expecting: ${(r=(e=n.args)===null||e===void 0?void 0:e.map(o=>o.name))!==null&&r!==void 0?r:[]}`);i=t.pop()}return[t,i]}class C0{static build(t,e,r){if(t.name==="_inner")throw new Ro("the _inner name is reserved");const i=(...s)=>{const[o,c]=N0(t,[...s]);_x(t.accounts,c.accounts),r7(t,...s);const u=i.accounts(c.accounts);return c.remainingAccounts!==void 0&&u.push(...c.remainingAccounts),J2("debug-logs")&&console.log("Outgoing account metas:",u),new Pe({keys:u,programId:r,data:e(t.name,yF(t,...o))})};return i.accounts=s=>C0.accountsArray(s,t.accounts,r,t.name),i}static accountsArray(t,e,r,i){return t?e.map(s=>{if(Ao(s)){const h=t[s.name];return C0.accountsArray(h,s.accounts,r,i).flat()}let o;try{o=mi(t[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const c=s.optional&&o.equals(r),u=!!(s.writable&&!c),f=!!(s.signer&&!c);return{pubkey:o,isWritable:u,isSigner:f}}).flat():[]}}function r7(n,...t){}class i7{static build(t,e){return(...i)=>{var s,o,c;const[,u]=N0(t,[...i]),f=new Oe;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>f.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>f.add(h)),f.add(e(...i)),(c=u.postInstructions)===null||c===void 0||c.forEach(h=>f.add(h)),f}}}class s7{static build(t,e,r,i){return async(...o)=>{var c;const u=e(...o),[,f]=N0(t,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(c=f.signers)!==null&&c!==void 0?c:[],f.options)}catch(h){throw X2(h,r)}}}}class o7{static build(t,e,r,i){var s;return((s=t.accounts)!==null&&s!==void 0?s:[]).reduce((o,c)=>(o[c.name]=new a7(t,c,r,i,e),o),{})}}class a7{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(t,e,r,i,s){this._idlAccount=e,this._programId=r,this._provider=i??Am(),this._coder=s??new tR(t),this._size=this._coder.accounts.size(e.name)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:i,context:s}=r;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:i}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:i}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(i=>i?i.data:null)}async fetchMultipleAndContext(t,e){return(await SF(this._provider.connection,t.map(i=>mi(i)),e)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Zt?t:void 0),r=[];return(e==null?void 0:e.offset)!=null&&(e==null?void 0:e.bytes)!=null&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(e==null?void 0:e.dataSize)!=null&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(t,e){const r=Wf.get(t.toString());if(r)return r.ee;const i=new aF;t=mi(t);const s=this._provider.connection.onAccountChange(t,o=>{const c=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",c)},e);return Wf.set(t.toString(),{ee:i,listener:s}),i}async unsubscribe(t){let e=Wf.get(t.toString());if(!e){console.warn("Address is not subscribed");return}Wf&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{Wf.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){const r=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Nn.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:e??r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(e??r),programId:this._programId})}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(mi(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(mi(t),e)}}const Wf=new Map;class c7{static build(t,e,r,i,s,o,c){return async(...f)=>{var h;const y=e(...f),[,A]=N0(t,[...f]);let b;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{b=await i.simulate(y,A.signers,(h=A.options)===null||h===void 0?void 0:h.commitment)}catch(S){throw X2(S,r)}if(b===void 0)throw new Error("Unable to simulate transaction");const R=b.logs;if(!R)throw new Error("Simulated logs not found");const k=[];if(c.events){let S=new hR(o,s);for(const B of S.parseLogs(R))k.push(B)}return{events:k,raw:R}}}}function xm(n){return new dR(jf(8),t=>l7.fromBuffer(t),t=>t.toBuffer(),n)}function B0(n){return new dR(jf(32),t=>new pt(t),t=>t.toBuffer(),n)}function Rm(n,t){return new u7(n,t)}class dR extends k0{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class u7 extends k0{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=ks()}encode(t,e,r=0){return t==null?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(r===0)return null;if(r===1)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}let l7=class TT extends ys{toBuffer(){const t=super.toArray().reverse(),e=Zt.from(t);if(e.length===8)return e;if(e.length>=8)throw new Error("u64 too large");const r=Zt.alloc(8);return e.copy(r),r}static fromBuffer(t){if(t.length!==8)throw new Error(`Invalid buffer length: ${t.length}`);return new TT([...t].reverse().map(e=>`00${e.toString(16)}`.slice(-2)).join(""),16)}};const f7=Cn([B0("mint"),B0("owner"),xm("amount"),Rm(B0(),"delegate"),(n=>{const t=cR(ZF("discriminator"),null,n);return t.addVariant(0,Cn([]),"uninitialized"),t.addVariant(1,Cn([]),"initialized"),t.addVariant(2,Cn([]),"frozen"),t})("state"),Rm(xm(),"isNative"),xm("delegatedAmount"),Rm(B0(),"closeAuthority")]);function h7(n){return f7.decode(n)}class d7{constructor(t,e,r,i,s,o,c,u){this._args=t,this._accounts=e,this._provider=r,this._programId=i,this._idlIx=s,this._idlTypes=c,this._customResolver=u,this._accountStore=new p7(r,o,i)}args(t){this._args=t}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let t=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(t++,t===16){const e=o=>Ao(o)?o.accounts.some(e):!!(o.address||o.pda||o.relations),r=(o,c=[],u=[])=>{for(const f of o)Ao(f)?u.push(...r(f.accounts,[...c,f.name])):u.push([...c,f.name]);return u},i=this._idlIx.accounts.filter(e),s=r(i).filter(o=>!this.get(o)).map(o=>o.reduce((c,u)=>c+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce((r,i)=>r&&r[i],this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach((i,s)=>{var o;s===t.length-1&&(r[i]=e),r[i]=(o=r[i])!==null&&o!==void 0?o:{},r=r[i]})}resolveOptionalsHelper(t,e){const r={};for(const i of e){const s=i.name,o=t[s];o!==void 0&&(pR(o)?Ao(i)?r[s]=this.resolveOptionalsHelper(o,i.accounts):r[s]=gR(o):o!==null?r[s]=mi(o):i.optional&&(r[s]=this._programId))}return r}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveEventCpi(t,e=[]){for(const r in t){const i=t[r];Ao(i)&&this.resolveEventCpi(i.accounts,[...e,i.name]);const s=+r+1;if(s===t.length)return;const o=t[r].name,c=t[s].name;if(o==="eventAuthority"&&c==="program"){const u=[...e,o],f=[...e,c];this.get(u)||this.set(u,pt.findProgramAddressSync([Zt.from("__event_authority")],this._programId)[0]),this.get(f)||this.set(f,this._programId);return}}}resolveConst(t,e=[]){for(const r of t){const i=r.name;if(Ao(r))this.resolveConst(r.accounts,[...e,i]);else{const s=r;if((s.signer||s.address)&&!this.get([...e,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...e,i],this._provider.wallet.publicKey)}s.address&&this.set([...e,i],mi(s.address))}}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(const i of t){const s=i.name;if(Ao(i))r+=await this.resolvePdasAndRelations(i.accounts,[...e,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...e,s])){r++;try{if(o.pda){const c=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,e)));if(c.some(h=>!h))continue;const u=await this.parseProgramId(o,e),[f]=pt.findProgramAddressSync(c,u);this.set([...e,s],f)}}catch{}try{if(o.relations){const c=this.get([...e,o.relations[0]]);if(c){const u=await this._accountStore.fetchAccount({publicKey:c});this.set([...e,s],u[s])}}}catch{}}}}return r}async parseProgramId(t,e=[]){var r;if(!(!((r=t.pda)===null||r===void 0)&&r.program))return this._programId;const i=await this.toBuffer(t.pda.program,e);if(!i)throw new Error(`Program seed not resolved: ${t.name}`);return new pt(i)}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed: ${t}`)}}toBufferConst(t){return this.toBufferValue("bytes",t.value)}async toBufferArg(t){const[e,...r]=t.path.split("."),i=this._idlIx.args.findIndex(c=>c.name===e);if(i===-1)throw new Error(`Unable to find argument for seed: ${e}`);const s=r.reduce((c,u)=>(c??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,r);return this.toBufferValue(o,s)}async toBufferAccount(t,e=[]){const[r,...i]=t.path.split("."),s=this.get([...e,r]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!t.account)throw new Error(`Seed account is required in order to resolve type: ${t.path}`);let c=await this._accountStore.fetchAccount({publicKey:s,name:t.account}),u=i;for(;u.length>0;)c=c[u[0]],u=u.slice(1);if(c===void 0)return;const f=this.getType({defined:{name:t.account}},i);return this.toBufferValue(f,c)}toBufferValue(t,e){switch(t){case"u8":case"i8":return Zt.from([e]);case"u16":case"i16":return new ys(e).toArrayLike(Zt,"le",2);case"u32":case"i32":return new ys(e).toArrayLike(Zt,"le",4);case"u64":case"i64":return new ys(e).toArrayLike(Zt,"le",8);case"u128":case"i128":return new ys(e).toArrayLike(Zt,"le",16);case"u256":case"i256":return new ys(e).toArrayLike(Zt,"le",32);case"string":return Zt.from(e);case"pubkey":return e.toBuffer();case"bytes":return Zt.from(e);default:if(t!=null&&t.array)return Zt.from(e);throw new Error(`Unexpected seed type: ${t}`)}}getType(t,e=[]){var r;const i=(r=t==null?void 0:t.defined)===null||r===void 0?void 0:r.name;if(i){if(i==="tokenAccount")switch(e.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${e}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...c]=e,f=s.type.fields.find(h=>h.name===o);if(!f)throw new Error(`Field not found: ${o}`);return this.getType(f.type,c)}return t}}class p7{constructor(t,e,r){this._provider=t,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async fetchAccount({publicKey:t,name:e}){const r=t.toBase58();if(!this._cache.has(r)){const i=await this._provider.connection.getAccountInfo(t);if(i===null)throw new Error(`Account not found: ${r}`);if(e==="tokenAccount"){const s=h7(i.data);this._cache.set(r,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const c=o.coder.accounts.decodeAny(i.data);this._cache.set(r,c)}}}}return this._cache.get(r)}async getAccountsNs(t){const e=t.toBase58();if(!this._idls[e]){const r=await Au.fetchIdl(t,this._provider);if(r){const i=new Au(r,this._provider);this._idls[e]=i.account}}return this._idls[e]}}class g7{static build(t,e,r,i,s,o,c,u,f,h,y){return(...A)=>new y7(A,i,s,o,c,u,t,e,r,f,h,y)}}function pR(n){return typeof n=="object"&&n!==null&&!("_bn"in n)}function gR(n,t){const e={};for(const r in n){const i=n[r];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");e[r]=pR(i)?gR(i):mi(i)}return e}class y7{constructor(t,e,r,i,s,o,c,u,f,h,y,A){this._args=t,this._ixFn=e,this._txFn=r,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new d7(t,this._accounts,c,u,f,h,y,A)}args(t){this._args=t,this._accountsResolver.args(t)}accounts(t){return this.accountsPartial(t)}accountsPartial(t){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t,e=!1){return e?this._preInstructions=t.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async view(t){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpc(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{signature:await this.rpc(t),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class m7{static build(t,e,r,i){const s=e.accounts.find(u=>u.writable),o=!!e.returns;return s||!o?void 0:async(...u)=>{let f=await r(...u);const h=`Program return: ${t} `;let y=f.raw.find(k=>k.startsWith(h));if(!y)throw new Error("View expected return log");let A=bx(y.slice(h.length)),b=e.returns;if(!b)throw new Error("View expected return type");return ge.fieldLayout({type:b},i.types).decode(A)}}}class w7{static build(t,e,r,i,s){const o={},c={},u={},f={},h={},y={},A=gF(t),b=t.accounts?o7.build(t,e,r,i):{};return t.instructions.forEach(R=>{const k=C0.build(R,(J,j)=>e.instruction.encode(J,j),r),S=i7.build(R,k),B=s7.build(R,S,A,i),H=c7.build(R,S,A,i,e,r,t),U=m7.build(r,R,H,t),G=g7.build(i,r,R,k,S,B,H,U,b,t.types||[],s==null?void 0:s(R)),W=R.name;c[W]=k,u[W]=S,o[W]=B,f[W]=H,h[W]=G,U&&(y[W]=U)}),[o,c,u,b,f,h,y]}}class Au{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e=Am(),r,i){this._idl=pF(t),this._rawIdl=t,this._provider=e,this._programId=mi(t.address),this._coder=r??new tR(this._idl),this._events=new t7(this._programId,e,this._coder);const[s,o,c,u,f,h,y]=w7.build(this._idl,this._coder,this._programId,e,i);this.rpc=s,this.instruction=o,this.transaction=c,this.account=u,this.simulate=f,this.methods=h,this.views=y}static async at(t,e){const r=mi(t),i=await Au.fetchIdl(r,e);if(!i)throw new Error(`IDL not found for program: ${t.toString()}`);return new Au(i,e)}static async fetchIdl(t,e){e=e??Am();const r=mi(t),i=await lF(r),s=await e.connection.getAccountInfo(i);if(!s)return null;let o=dF(s.data.slice(8));const c=sF(o.data);return JSON.parse(uF(c))}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new pt("11111111111111111111111111111111");const b7="6.13.5";function _7(n,t,e){const r=t.split("|").map(s=>s.trim());for(let s=0;s<r.length;s++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===t)return}const i=new Error(`invalid value for type ${t}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${e}`,i.value=n,i}async function pr(n){const t=Object.keys(n);return(await Promise.all(t.map(r=>Promise.resolve(n[r])))).reduce((r,i,s)=>(r[t[s]]=i,r),{})}function $t(n,t,e){for(let r in t){let i=t[r];const s=e?e[r]:null;s&&_7(i,s,r),Object.defineProperty(n,r,{enumerable:!0,value:i,writable:!1})}}function Eu(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Eu).join(", ")+" ]";if(n instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let r=0;r<n.length;r++)e+=t[n[r]>>4],e+=t[n[r]&15];return e}if(typeof n=="object"&&typeof n.toJSON=="function")return Eu(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 t=Object.keys(n);return t.sort(),"{ "+t.map(e=>`${Eu(e)}: ${Eu(n[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Zn(n,t){return n&&n.code===t}function Sm(n){return Zn(n,"CALL_EXCEPTION")}function Qe(n,t,e){let r=n;{const s=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${Eu(e)}`);for(const o in e){if(o==="shortMessage")continue;const c=e[o];s.push(o+"="+Eu(c))}}s.push(`code=${t}`),s.push(`version=${b7}`),s.length&&(n+=" ("+s.join(", ")+")")}let i;switch(t){case"INVALID_ARGUMENT":i=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(n);break;default:i=new Error(n)}return $t(i,{code:t}),e&&Object.assign(i,e),i.shortMessage==null&&$t(i,{shortMessage:r}),i}function ht(n,t,e,r){if(!n)throw Qe(t,e,r)}function K(n,t,e,r){ht(n,t,"INVALID_ARGUMENT",{argument:e,value:r})}function yR(n,t,e){e==null&&(e=""),e&&(e=": "+e),ht(n>=t,"missing argument"+e,"MISSING_ARGUMENT",{count:n,expectedCount:t}),ht(n<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((n,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(t)}catch{}return n},[]);function P0(n,t,e){if(e==null&&(e=""),n!==t){let r=e,i="new";e&&(r+=".",i+=" "+e),ht(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function mR(n,t,e){if(n instanceof Uint8Array)return e?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 i=2;for(let s=0;s<r.length;s++)r[s]=parseInt(n.substring(i,i+2),16),i+=2;return r}K(!1,"invalid BytesLike value",t||"value",n)}function we(n,t){return mR(n,t,!1)}function gr(n,t){return mR(n,t,!0)}function ze(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&n.length!==2+2*t||t===!0&&n.length%2!==0)}function Im(n){return ze(n,!0)||n instanceof Uint8Array}const wR="0123456789abcdef";function Tt(n){const t=we(n);let e="0x";for(let r=0;r<t.length;r++){const i=t[r];e+=wR[(i&240)>>4]+wR[i&15]}return e}function vn(n){return"0x"+n.map(t=>Tt(t).substring(2)).join("")}function vu(n){return ze(n,!0)?(n.length-2)/2:we(n).length}function un(n,t,e){const r=we(n);return e!=null&&e>r.length&&ht(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:e}),Tt(r.slice(t??0,e??r.length))}function bR(n,t,e){const r=we(n);ht(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),e?i.set(r,t-r.length):i.set(r,0),Tt(i)}function La(n,t){return bR(n,t,!0)}function A7(n,t){return bR(n,t,!1)}const M0=BigInt(0),wi=BigInt(1),xu=9007199254740991;function E7(n,t){const e=L0(n,"value"),r=BigInt(ie(t,"width"));if(ht(e>>r===M0,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),e>>r-wi){const i=(wi<<r)-wi;return-((~e&i)+wi)}return e}function _R(n,t){let e=Ct(n,"value");const r=BigInt(ie(t,"width")),i=wi<<r-wi;if(e<M0){e=-e,ht(e<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const s=(wi<<r)-wi;return(~e&s)+wi}else ht(e<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return e}function Zf(n,t){const e=L0(n,"value"),r=BigInt(ie(t,"bits"));return e&(wi<<r)-wi}function Ct(n,t){switch(typeof n){case"bigint":return n;case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-xu&&n<=xu,"overflow",t||"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(e){K(!1,`invalid BigNumberish string: ${e.message}`,t||"value",n)}}K(!1,"invalid BigNumberish value",t||"value",n)}function L0(n,t){const e=Ct(n,t);return ht(e>=M0,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),e}const AR="0123456789abcdef";function km(n){if(n instanceof Uint8Array){let t="0x0";for(const e of n)t+=AR[e>>4],t+=AR[e&15];return BigInt(t)}return Ct(n)}function ie(n,t){switch(typeof n){case"bigint":return K(n>=-xu&&n<=xu,"overflow",t||"value",n),Number(n);case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-xu&&n<=xu,"overflow",t||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return ie(BigInt(n),t)}catch(e){K(!1,`invalid numeric string: ${e.message}`,t||"value",n)}}K(!1,"invalid numeric value",t||"value",n)}function v7(n){return ie(km(n))}function So(n,t){let r=L0(n,"value").toString(16);if(t==null)r.length%2&&(r="0"+r);else{const i=ie(t,"width");for(ht(i*2>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<i*2;)r="0"+r}return"0x"+r}function yr(n){const t=L0(n,"value");if(t===M0)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const r=new Uint8Array(e.length/2);for(let i=0;i<r.length;i++){const s=i*2;r[i]=parseInt(e.substring(s,s+2),16)}return r}function Ru(n){let t=Tt(Im(n)?n:yr(n)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}const ER="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const vR=BigInt(58);function x7(n){const t=we(n);let e=km(t),r="";for(;e;)r=ER[Number(e%vR)]+r,e/=vR;for(let i=0;i<t.length&&!t[i];i++)r=ER[0]+r;return r}function R7(n){n=atob(n);const t=new Uint8Array(n.length);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return we(t)}function S7(n){const t=we(n);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}class xR{constructor(t,e,r){Z(this,"filter");Z(this,"emitter");nt(this,zu);$(this,zu,e),$t(this,{emitter:t,filter:r})}async removeListener(){T(this,zu)!=null&&await this.emitter.off(this.filter,T(this,zu))}}zu=new WeakMap;function I7(n,t,e,r,i){K(!1,`invalid codepoint at offset ${t}; ${n}`,"bytes",e)}function RR(n,t,e,r,i){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let s=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)s++;return s}return n==="OVERRUN"?e.length-t-1:0}function k7(n,t,e,r,i){return n==="OVERLONG"?(K(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),RR(n,t,e))}const T7=Object.freeze({error:I7,ignore:RR,replace:k7});function O7(n,t){t==null&&(t=T7.error);const e=we(n,"bytes"),r=[];let i=0;for(;i<e.length;){const s=e[i++];if(!(s>>7)){r.push(s);continue}let o=null,c=null;if((s&224)===192)o=1,c=127;else if((s&240)===224)o=2,c=2047;else if((s&248)===240)o=3,c=65535;else{(s&192)===128?i+=t("UNEXPECTED_CONTINUE",i-1,e,r):i+=t("BAD_PREFIX",i-1,e,r);continue}if(i-1+o>=e.length){i+=t("OVERRUN",i-1,e,r);continue}let u=s&(1<<8-o-1)-1;for(let f=0;f<o;f++){let h=e[i];if((h&192)!=128){i+=t("MISSING_CONTINUE",i,e,r),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=t("OUT_OF_RANGE",i-1-o,e,r,u);continue}if(u>=55296&&u<=57343){i+=t("UTF16_SURROGATE",i-1-o,e,r,u);continue}if(u<=c){i+=t("OVERLONG",i-1-o,e,r,u);continue}r.push(u)}}return r}function Os(n,t){K(typeof n=="string","invalid string value","str",n);let e=[];for(let r=0;r<n.length;r++){const i=n.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);K(r<n.length&&(s&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((i&1023)<<10)+(s&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return new Uint8Array(e)}function N7(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function U0(n,t){return N7(O7(n,t))}function SR(n){async function t(e,r){ht(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const i=e.url.split(":")[0].toLowerCase();ht(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ht(i==="https"||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,c=setTimeout(()=>{s=Qe("request timeout","TIMEOUT"),o.abort()},e.timeout);r&&r.addListener(()=>{s=Qe("request cancelled","CANCELLED"),o.abort()});const u={method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:o.signal};let f;try{f=await fetch(e.url,u)}catch(b){throw clearTimeout(c),s||b}clearTimeout(c);const h={};f.headers.forEach((b,R)=>{h[R.toLowerCase()]=b});const y=await f.arrayBuffer(),A=y==null?null:new Uint8Array(y);return{statusCode:f.status,statusMessage:f.statusText,headers:h,body:A}}return t}const C7=12,B7=250;let IR=SR();const P7=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),M7=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Tm=!1;async function kR(n,t){try{const e=n.match(P7);if(!e)throw new Error("invalid data");return new Io(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?R7(e[3]):U7(e[3]))}catch{return new Io(599,"BAD REQUEST (invalid data: URI)",{},null,new Ns(n))}}function TR(n){async function t(e,r){try{const i=e.match(M7);if(!i)throw new Error("invalid link");return new Ns(`${n}${i[2]}`)}catch{return new Io(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ns(e))}}return t}const D0={data:kR,ipfs:TR("https://gateway.ipfs.io/ipfs/")},OR=new WeakMap;class L7{constructor(t){nt(this,Ya);nt(this,Po);$(this,Ya,[]),$(this,Po,!1),OR.set(t,()=>{if(!T(this,Po)){$(this,Po,!0);for(const e of T(this,Ya))setTimeout(()=>{e()},0);$(this,Ya,[])}})}addListener(t){ht(!T(this,Po),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,Ya).push(t)}get cancelled(){return T(this,Po)}checkSignal(){ht(!this.cancelled,"cancelled","CANCELLED",{})}}Ya=new WeakMap,Po=new WeakMap;function F0(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const _p=class _p{constructor(t){nt(this,ec);nt(this,Gu);nt(this,Vu);nt(this,vi);nt(this,Fs);nt(this,Ku);nt(this,ju);nt(this,Fn);nt(this,Vr);nt(this,$s);nt(this,Ja);nt(this,Xa);nt(this,tc);nt(this,ts);nt(this,xi);nt(this,Mo);$(this,ju,String(t)),$(this,Gu,!1),$(this,Vu,!0),$(this,vi,{}),$(this,Fs,""),$(this,Ku,3e5),$(this,xi,{slotInterval:B7,maxAttempts:C7}),$(this,Mo,null)}get url(){return T(this,ju)}set url(t){$(this,ju,String(t))}get body(){return T(this,Fn)==null?null:new Uint8Array(T(this,Fn))}set body(t){if(t==null)$(this,Fn,void 0),$(this,Vr,void 0);else if(typeof t=="string")$(this,Fn,Os(t)),$(this,Vr,"text/plain");else if(t instanceof Uint8Array)$(this,Fn,t),$(this,Vr,"application/octet-stream");else if(typeof t=="object")$(this,Fn,Os(JSON.stringify(t))),$(this,Vr,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Fn)!=null}get method(){return T(this,Fs)?T(this,Fs):this.hasBody()?"POST":"GET"}set method(t){t==null&&(t=""),$(this,Fs,String(t).toUpperCase())}get headers(){const t=Object.assign({},T(this,vi));return T(this,$s)&&(t.authorization=`Basic ${S7(Os(T(this,$s)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),t["content-type"]==null&&T(this,Vr)&&(t["content-type"]=T(this,Vr)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){T(this,vi)[String(t).toLowerCase()]=String(e)}clearHeaders(){$(this,vi,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,$s)||null}setCredentials(t,e){K(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),$(this,$s,`${t}:${e}`)}get allowGzip(){return T(this,Vu)}set allowGzip(t){$(this,Vu,!!t)}get allowInsecureAuthentication(){return!!T(this,Gu)}set allowInsecureAuthentication(t){$(this,Gu,!!t)}get timeout(){return T(this,Ku)}set timeout(t){K(t>=0,"timeout must be non-zero","timeout",t),$(this,Ku,t)}get preflightFunc(){return T(this,Ja)||null}set preflightFunc(t){$(this,Ja,t)}get processFunc(){return T(this,Xa)||null}set processFunc(t){$(this,Xa,t)}get retryFunc(){return T(this,tc)||null}set retryFunc(t){$(this,tc,t)}get getUrlFunc(){return T(this,Mo)||IR}set getUrlFunc(t){$(this,Mo,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,Fn)?Tt(T(this,Fn)):"null"}>`}setThrottleParams(t){t.slotInterval!=null&&(T(this,xi).slotInterval=t.slotInterval),t.maxAttempts!=null&&(T(this,xi).maxAttempts=t.maxAttempts)}send(){return ht(T(this,ts)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),$(this,ts,new L7(this)),_t(this,ec,id).call(this,0,NR()+this.timeout,0,this,new Io(0,"",{},null,this))}cancel(){ht(T(this,ts)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=OR.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();ht(this.method==="GET"&&(e!=="https"||r!=="http")&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new _p(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,$(i,vi,Object.assign({},T(this,vi))),T(this,Fn)&&$(i,Fn,new Uint8Array(T(this,Fn))),$(i,Vr,T(this,Vr)),i}clone(){const t=new _p(this.url);return $(t,Fs,T(this,Fs)),T(this,Fn)&&$(t,Fn,T(this,Fn)),$(t,Vr,T(this,Vr)),$(t,vi,Object.assign({},T(this,vi))),$(t,$s,T(this,$s)),this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),$(t,Ja,T(this,Ja)),$(t,Xa,T(this,Xa)),$(t,tc,T(this,tc)),$(t,xi,Object.assign({},T(this,xi))),$(t,Mo,T(this,Mo)),t}static lockConfig(){Tm=!0}static getGateway(t){return D0[t.toLowerCase()]||null}static registerGateway(t,e){if(t=t.toLowerCase(),t==="http"||t==="https")throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(Tm)throw new Error("gateways locked");D0[t]=e}static registerGetUrl(t){if(Tm)throw new Error("gateways locked");IR=t}static createGetUrlFunc(t){return SR()}static createDataGateway(){return kR}static createIpfsGatewayFunc(t){return TR(t)}};Gu=new WeakMap,Vu=new WeakMap,vi=new WeakMap,Fs=new WeakMap,Ku=new WeakMap,ju=new WeakMap,Fn=new WeakMap,Vr=new WeakMap,$s=new WeakMap,Ja=new WeakMap,Xa=new WeakMap,tc=new WeakMap,ts=new WeakMap,xi=new WeakMap,Mo=new WeakMap,ec=new WeakSet,id=async function(t,e,r,i,s){var h,y,A;if(t>=T(this,xi).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ht(NR()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),r>0&&await D7(r);let o=this.clone();const c=(o.url.split(":")[0]||"").toLowerCase();if(c in D0){const b=await D0[c](o.url,F0(T(i,ts)));if(b instanceof Io){let R=b;if(this.processFunc){F0(T(i,ts));try{R=await this.processFunc(o,R)}catch(k){(k.throttle==null||typeof k.stall!="number")&&R.makeServerError("error in post-processing function",k).assertOk()}}return R}o=b}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,F0(T(i,ts)));let f=new Io(u.statusCode,u.statusMessage,u.headers,u.body,i);if(f.statusCode===301||f.statusCode===302){try{const b=f.headers.location||"";return _t(h=o.redirect(b),ec,id).call(h,t+1,e,0,i,f)}catch{}return f}else if(f.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,f,t))){const b=f.headers["retry-after"];let R=T(this,xi).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return typeof b=="string"&&b.match(/^[1-9][0-9]*$/)&&(R=parseInt(b)),_t(y=o.clone(),ec,id).call(y,t+1,e,R,i,f)}if(this.processFunc){F0(T(i,ts));try{f=await this.processFunc(o,f)}catch(b){(b.throttle==null||typeof b.stall!="number")&&f.makeServerError("error in post-processing function",b).assertOk();let R=T(this,xi).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return b.stall>=0&&(R=b.stall),_t(A=o.clone(),ec,id).call(A,t+1,e,R,i,f)}}return f};let Ns=_p;const Dw=class Dw{constructor(t,e,r,i,s){nt(this,gh);nt(this,yh);nt(this,mh);nt(this,Kr);nt(this,Wu);nt(this,nc);$(this,gh,t),$(this,yh,e),$(this,mh,Object.keys(r).reduce((o,c)=>(o[c.toLowerCase()]=String(r[c]),o),{})),$(this,Kr,i==null?null:new Uint8Array(i)),$(this,Wu,s||null),$(this,nc,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,Kr)?Tt(T(this,Kr)):"null"}>`}get statusCode(){return T(this,gh)}get statusMessage(){return T(this,yh)}get headers(){return Object.assign({},T(this,mh))}get body(){return T(this,Kr)==null?null:new Uint8Array(T(this,Kr))}get bodyText(){try{return T(this,Kr)==null?"":U0(T(this,Kr))}catch{ht(!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{ht(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(t,e){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);const i=new Dw(599,r,this.headers,this.body,T(this,Wu)||void 0);return $(i,nc,{message:t,error:e}),i}throwThrottleError(t,e){e==null?e=-1:K(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $t(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return T(this,Kr)!=null}get request(){return T(this,Wu)}ok(){return T(this,nc).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=T(this,nc);t===""&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let i=null;try{T(this,Kr)&&(i=U0(T(this,Kr)))}catch{}ht(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};gh=new WeakMap,yh=new WeakMap,mh=new WeakMap,Kr=new WeakMap,Wu=new WeakMap,nc=new WeakMap;let Io=Dw;function NR(){return new Date().getTime()}function U7(n){return Os(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function D7(n){return new Promise(t=>setTimeout(t,n))}function F7(n){let t=n.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function CR(n,t,e){let r=0;for(let i=0;i<e;i++)r=r*256+n[t+i];return r}function BR(n,t,e,r){const i=[];for(;e<t+1+r;){const s=PR(n,e);i.push(s.result),e+=s.consumed,ht(e<=t+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:t})}return{consumed:1+r,result:i}}function PR(n,t){ht(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const e=r=>{ht(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[t]>=248){const r=n[t]-247;e(t+1+r);const i=CR(n,t+1,r);return e(t+1+r+i),BR(n,t,t+1+r,r+i)}else if(n[t]>=192){const r=n[t]-192;return e(t+1+r),BR(n,t,t+1,r)}else if(n[t]>=184){const r=n[t]-183;e(t+1+r);const i=CR(n,t+1,r);e(t+1+r+i);const s=Tt(n.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:s}}else if(n[t]>=128){const r=n[t]-128;e(t+1+r);const i=Tt(n.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:F7(n[t])}}function $0(n){const t=we(n,"data"),e=PR(t,0);return K(e.consumed===t.length,"unexpected junk after rlp payload","data",n),e.result}function MR(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function LR(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(s){r=r.concat(LR(s))}),r.length<=55)return r.unshift(192+r.length),r;const i=MR(r.length);return i.unshift(247+i.length),i.concat(r)}const t=Array.prototype.slice.call(we(n,"object"));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const e=MR(t.length);return e.unshift(183+e.length),e.concat(t)}const UR="0123456789abcdef";function Ua(n){let t="0x";for(const e of LR(n))t+=UR[e>>4],t+=UR[e&15];return t}const mr=32,Om=new Uint8Array(mr),$7=["then"],H0={},DR=new WeakMap;function Da(n){return DR.get(n)}function FR(n,t){DR.set(n,t)}function qf(n,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw e.error=t,e}function Nm(n,t,e){return n.indexOf(null)>=0?t.map((r,i)=>r instanceof Su?Nm(Da(r),r,e):r):n.reduce((r,i,s)=>{let o=t.getValue(i);return i in r||(e&&o instanceof Su&&(o=Nm(Da(o),o,e)),r[i]=o),r},{})}const qu=class qu extends Array{constructor(...e){const r=e[0];let i=e[1],s=(e[2]||[]).slice(),o=!0;r!==H0&&(i=e,s=[],o=!1);super(i.length);nt(this,Zu);i.forEach((f,h)=>{this[h]=f});const c=s.reduce((f,h)=>(typeof h=="string"&&f.set(h,(f.get(h)||0)+1),f),new Map);if(FR(this,Object.freeze(i.map((f,h)=>{const y=s[h];return y!=null&&c.get(y)===1?y:null}))),$(this,Zu,[]),T(this,Zu)==null&&T(this,Zu),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(f,h,y)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const b=ie(h,"%index");if(b<0||b>=this.length)throw new RangeError("out of result range");const R=f[b];return R instanceof Error&&qf(`index ${b}`,R),R}if($7.indexOf(h)>=0)return Reflect.get(f,h,y);const A=f[h];if(A instanceof Function)return function(...b){return A.apply(this===y?f:this,b)};if(!(h in f))return f.getValue.apply(this===y?f:this,[h])}return Reflect.get(f,h,y)}});return FR(u,Da(this)),u}toArray(e){const r=[];return this.forEach((i,s)=>{i instanceof Error&&qf(`index ${s}`,i),e&&i instanceof qu&&(i=i.toArray(e)),r.push(i)}),r}toObject(e){const r=Da(this);return r.reduce((i,s,o)=>(ht(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Nm(r,this,e)),{})}slice(e,r){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const i=Da(this),s=[],o=[];for(let c=e;c<r;c++)s.push(this[c]),o.push(i[c]);return new qu(H0,s,o)}filter(e,r){const i=Da(this),s=[],o=[];for(let c=0;c<this.length;c++){const u=this[c];u instanceof Error&&qf(`index ${c}`,u),e.call(r,u,c,this)&&(s.push(u),o.push(i[c]))}return new qu(H0,s,o)}map(e,r){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&qf(`index ${s}`,o),i.push(e.call(r,o,s,this))}return i}getValue(e){const r=Da(this).indexOf(e);if(r===-1)return;const i=this[r];return i instanceof Error&&qf(`property ${JSON.stringify(e)}`,i.error),i}static fromItems(e,r){return new qu(H0,e,r)}};Zu=new WeakMap;let Su=qu;function $R(n){let t=yr(n);return ht(t.length<=mr,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:mr,offset:t.length}),t.length!==mr&&(t=gr(vn([Om.slice(t.length%mr),t]))),t}class Cs{constructor(t,e,r,i){Z(this,"name");Z(this,"type");Z(this,"localName");Z(this,"dynamic");$t(this,{name:t,type:e,localName:r,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){K(!1,t,this.localName,e)}}class Cm{constructor(){nt(this,Qu);nt(this,Hs);nt(this,rc);$(this,Hs,[]),$(this,rc,0)}get data(){return vn(T(this,Hs))}get length(){return T(this,rc)}appendWriter(t){return _t(this,Qu,zp).call(this,gr(t.data))}writeBytes(t){let e=gr(t);const r=e.length%mr;return r&&(e=gr(vn([e,Om.slice(r)]))),_t(this,Qu,zp).call(this,e)}writeValue(t){return _t(this,Qu,zp).call(this,$R(t))}writeUpdatableValue(){const t=T(this,Hs).length;return T(this,Hs).push(Om),$(this,rc,T(this,rc)+mr),e=>{T(this,Hs)[t]=$R(e)}}}Hs=new WeakMap,rc=new WeakMap,Qu=new WeakSet,zp=function(t){return T(this,Hs).push(t),$(this,rc,T(this,rc)+t.length),t.length};const Fw=class Fw{constructor(t,e,r){nt(this,oc);Z(this,"allowLoose");nt(this,Nr);nt(this,jr);nt(this,ic);nt(this,sc);nt(this,Lo);$t(this,{allowLoose:!!e}),$(this,Nr,gr(t)),$(this,ic,0),$(this,sc,null),$(this,Lo,r??1024),$(this,jr,0)}get data(){return Tt(T(this,Nr))}get dataLength(){return T(this,Nr).length}get consumed(){return T(this,jr)}get bytes(){return new Uint8Array(T(this,Nr))}subReader(t){const e=new Fw(T(this,Nr).slice(T(this,jr)+t),this.allowLoose,T(this,Lo));return $(e,sc,this),e}readBytes(t,e){let r=_t(this,oc,OT).call(this,0,t,!!e);return _t(this,oc,ob).call(this,t),$(this,jr,T(this,jr)+r.length),r.slice(0,t)}readValue(){return km(this.readBytes(mr))}readIndex(){return v7(this.readBytes(mr))}};Nr=new WeakMap,jr=new WeakMap,ic=new WeakMap,sc=new WeakMap,Lo=new WeakMap,oc=new WeakSet,ob=function(t){var e;if(T(this,sc))return _t(e=T(this,sc),oc,ob).call(e,t);$(this,ic,T(this,ic)+t),ht(T(this,Lo)<1||T(this,ic)<=T(this,Lo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Lo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:gr(T(this,Nr)),offset:T(this,jr),length:t,info:{bytesRead:T(this,ic),dataLength:this.dataLength}})},OT=function(t,e,r){let i=Math.ceil(e/mr)*mr;return T(this,jr)+i>T(this,Nr).length&&(this.allowLoose&&r&&T(this,jr)+e<=T(this,Nr).length?i=e:ht(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:gr(T(this,Nr)),length:T(this,Nr).length,offset:T(this,jr)+i})),T(this,Nr).slice(T(this,jr),T(this,jr)+i)};let Bm=Fw;function z0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Pm(n,...t){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(n.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${n.length}`)}function H7(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");z0(n.outputLen),z0(n.blockLen)}function Iu(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function HR(n,t){Pm(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const Mm=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zR=n=>n instanceof Uint8Array,z7=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Lm=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Qi=(n,t)=>n<<32-t|n>>>t;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function G7(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function G0(n){if(typeof n=="string"&&(n=G7(n)),!zR(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function V7(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!zR(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}class Um{clone(){return this._cloneInto()}}function Dm(n){const t=r=>n().update(G0(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function K7(n=32){if(Mm&&typeof Mm.getRandomValues=="function")return Mm.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class GR extends Um{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,H7(t);const r=G0(e);if(this.iHash=t.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 i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return Iu(this),this.iHash.update(t),this}digestInto(t){Iu(this),Pm(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const VR=(n,t,e)=>new GR(n,t).update(e).digest();VR.create=(n,t)=>new GR(n,t);function j7(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,c,r)}class KR extends Um{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Lm(this.buffer)}update(t){Iu(this);const{view:e,buffer:r,blockLen:i}=this;t=G0(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(i-this.pos,s-o);if(c===i){const u=Lm(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Iu(this),HR(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;j7(r,i-8,BigInt(this.length*8),s),this.process(r,0);const c=Lm(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)c.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const W7=(n,t,e)=>n&t^~n&e,Z7=(n,t,e)=>n&t^n&e^t&e,q7=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]),ko=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),To=new Uint32Array(64);class Q7 extends KR{constructor(){super(64,32,8,!1),this.A=ko[0]|0,this.B=ko[1]|0,this.C=ko[2]|0,this.D=ko[3]|0,this.E=ko[4]|0,this.F=ko[5]|0,this.G=ko[6]|0,this.H=ko[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,r,i,s,o,c,u]}set(t,e,r,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)To[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const A=To[y-15],b=To[y-2],R=Qi(A,7)^Qi(A,18)^A>>>3,k=Qi(b,17)^Qi(b,19)^b>>>10;To[y]=k+To[y-7]+R+To[y-16]|0}let{A:r,B:i,C:s,D:o,E:c,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const A=Qi(c,6)^Qi(c,11)^Qi(c,25),b=h+A+W7(c,u,f)+q7[y]+To[y]|0,k=(Qi(r,2)^Qi(r,13)^Qi(r,22))+Z7(r,i,s)|0;h=f,f=u,u=c,c=o+b|0,o=s,s=i,i=r,r=b+k|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,c,u,f,h)}roundClean(){To.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const jR=Dm(()=>new Q7),V0=BigInt(2**32-1),Fm=BigInt(32);function WR(n,t=!1){return t?{h:Number(n&V0),l:Number(n>>Fm&V0)}:{h:Number(n>>Fm&V0)|0,l:Number(n&V0)|0}}function ZR(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=WR(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const Y7=(n,t)=>BigInt(n>>>0)<<Fm|BigInt(t>>>0),J7=(n,t,e)=>n>>>e,X7=(n,t,e)=>n<<32-e|t>>>e,t$=(n,t,e)=>n>>>e|t<<32-e,e$=(n,t,e)=>n<<32-e|t>>>e,n$=(n,t,e)=>n<<64-e|t>>>e-32,r$=(n,t,e)=>n>>>e-32|t<<64-e,i$=(n,t)=>t,s$=(n,t)=>n,qR=(n,t,e)=>n<<e|t>>>32-e,QR=(n,t,e)=>t<<e|n>>>32-e,YR=(n,t,e)=>t<<e-32|n>>>64-e,JR=(n,t,e)=>n<<e-32|t>>>64-e;function o$(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const ne={fromBig:WR,split:ZR,toBig:Y7,shrSH:J7,shrSL:X7,rotrSH:t$,rotrSL:e$,rotrBH:n$,rotrBL:r$,rotr32H:i$,rotr32L:s$,rotlSH:qR,rotlSL:QR,rotlBH:YR,rotlBL:JR,add:o$,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,add5H:(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,add5L:(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)},[a$,c$]=ne.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))),Oo=new Uint32Array(80),No=new Uint32Array(80);class u$ extends KR{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:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:f,El:h,Fh:y,Fl:A,Gh:b,Gl:R,Hh:k,Hl:S}=this;return[t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S]}set(t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=A|0,this.Gh=b|0,this.Gl=R|0,this.Hh=k|0,this.Hl=S|0}process(t,e){for(let U=0;U<16;U++,e+=4)Oo[U]=t.getUint32(e),No[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=Oo[U-15]|0,W=No[U-15]|0,J=ne.rotrSH(G,W,1)^ne.rotrSH(G,W,8)^ne.shrSH(G,W,7),j=ne.rotrSL(G,W,1)^ne.rotrSL(G,W,8)^ne.shrSL(G,W,7),Y=Oo[U-2]|0,it=No[U-2]|0,ut=ne.rotrSH(Y,it,19)^ne.rotrBH(Y,it,61)^ne.shrSH(Y,it,6),rt=ne.rotrSL(Y,it,19)^ne.rotrBL(Y,it,61)^ne.shrSL(Y,it,6),ot=ne.add4L(j,rt,No[U-7],No[U-16]),C=ne.add4H(ot,J,ut,Oo[U-7],Oo[U-16]);Oo[U]=C|0,No[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:f,Dl:h,Eh:y,El:A,Fh:b,Fl:R,Gh:k,Gl:S,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=ne.rotrSH(y,A,14)^ne.rotrSH(y,A,18)^ne.rotrBH(y,A,41),W=ne.rotrSL(y,A,14)^ne.rotrSL(y,A,18)^ne.rotrBL(y,A,41),J=y&b^~y&k,j=A&R^~A&S,Y=ne.add5L(H,W,j,c$[U],No[U]),it=ne.add5H(Y,B,G,J,a$[U],Oo[U]),ut=Y|0,rt=ne.rotrSH(r,i,28)^ne.rotrBH(r,i,34)^ne.rotrBH(r,i,39),ot=ne.rotrSL(r,i,28)^ne.rotrBL(r,i,34)^ne.rotrBL(r,i,39),C=r&s^r&c^s&c,p=i&o^i&u^o&u;B=k|0,H=S|0,k=b|0,S=R|0,b=y|0,R=A|0,{h:y,l:A}=ne.add(f|0,h|0,it|0,ut|0),f=c|0,h=u|0,c=s|0,u=o|0,s=r|0,o=i|0;const m=ne.add3L(ut,ot,p);r=ne.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=ne.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=ne.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=ne.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:f,l:h}=ne.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:A}=ne.add(this.Eh|0,this.El|0,y|0,A|0),{h:b,l:R}=ne.add(this.Fh|0,this.Fl|0,b|0,R|0),{h:k,l:S}=ne.add(this.Gh|0,this.Gl|0,k|0,S|0),{h:B,l:H}=ne.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H)}roundClean(){Oo.fill(0),No.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 l$=Dm(()=>new u$);function f$(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Hc<"u")return Hc;throw new Error("unable to locate global object")}const XR=f$();XR.crypto||XR.msCrypto;function h$(n){switch(n){case"sha256":return jR.create();case"sha512":return l$.create()}K(!1,"invalid hashing algorithm name","algorithm",n)}const[tS,eS,nS]=[[],[],[]],d$=BigInt(0),Qf=BigInt(1),p$=BigInt(2),g$=BigInt(7),y$=BigInt(256),m$=BigInt(113);for(let n=0,t=Qf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],tS.push(2*(5*r+e)),eS.push((n+1)*(n+2)/2%64);let i=d$;for(let s=0;s<7;s++)t=(t<<Qf^(t>>g$)*m$)%y$,t&p$&&(i^=Qf<<(Qf<<BigInt(s))-Qf);nS.push(i)}const[w$,b$]=ZR(nS,!0),rS=(n,t,e)=>e>32?YR(n,t,e):qR(n,t,e),iS=(n,t,e)=>e>32?JR(n,t,e):QR(n,t,e);function _$(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=rS(f,h,1)^e[c],A=iS(f,h,1)^e[c+1];for(let b=0;b<50;b+=10)n[o+b]^=y,n[o+b+1]^=A}let i=n[2],s=n[3];for(let o=0;o<24;o++){const c=eS[o],u=rS(i,s,c),f=iS(i,s,c),h=tS[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)e[c]=n[o+c];for(let c=0;c<10;c++)n[o+c]^=~e[(c+2)%10]&e[(c+4)%10]}n[0]^=w$[r],n[1]^=b$[r]}e.fill(0)}class $m extends Um{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,z0(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=z7(this.state)}keccak(){_$(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Iu(this);const{blockLen:e,state:r}=this;t=G0(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Iu(this,!1),Pm(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return z0(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(HR(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new $m(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const A$=((n,t,e)=>Dm(()=>new $m(t,n,e)))(1,136,256/8);let sS=!1;const oS=function(n){return A$(n)};let aS=oS;function On(n){const t=we(n,"data");return Tt(aS(t))}On._=oS,On.lock=function(){sS=!0},On.register=function(n){if(sS)throw new TypeError("keccak256 is locked");aS=n},Object.freeze(On);const cS=function(n){return h$("sha256").update(n).digest()};let uS=cS,lS=!1;function ku(n){const t=we(n,"data");return Tt(uS(t))}ku._=cS,ku.lock=function(){lS=!0},ku.register=function(n){if(lS)throw new Error("sha256 is locked");uS=n},Object.freeze(ku),Object.freeze(ku);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fS=BigInt(0),K0=BigInt(1),E$=BigInt(2),j0=n=>n instanceof Uint8Array,v$=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function Tu(n){if(!j0(n))throw new Error("Uint8Array expected");let t="";for(let e=0;e<n.length;e++)t+=v$[n[e]];return t}function hS(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function Hm(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Ou(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const e=new Uint8Array(t/2);for(let r=0;r<e.length;r++){const i=r*2,s=n.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function Fa(n){return Hm(Tu(n))}function zm(n){if(!j0(n))throw new Error("Uint8Array expected");return Hm(Tu(Uint8Array.from(n).reverse()))}function Nu(n,t){return Ou(n.toString(16).padStart(t*2,"0"))}function Gm(n,t){return Nu(n,t).reverse()}function x$(n){return Ou(hS(n))}function bi(n,t,e){let r;if(typeof t=="string")try{r=Ou(t)}catch(s){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${s}`)}else if(j0(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(`${n} expected ${e} bytes, got ${i}`);return r}function Yf(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!j0(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}function R$(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}function S$(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function I$(n){let t;for(t=0;n>fS;n>>=K0,t+=1);return t}function k$(n,t){return n>>BigInt(t)&K0}const T$=(n,t,e)=>n|(e?K0:fS)<<BigInt(t),Vm=n=>(E$<<BigInt(n-1))-K0,Km=n=>new Uint8Array(n),dS=n=>Uint8Array.from(n);function pS(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=Km(n),i=Km(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},c=(...y)=>e(i,r,...y),u=(y=Km())=>{i=c(dS([0]),y),r=c(),y.length!==0&&(i=c(dS([1]),y),r=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const A=[];for(;y<t;){r=c();const b=r.slice();A.push(b),y+=r.length}return Yf(...A)};return(y,A)=>{o(),u(y);let b;for(;!(b=A(f()));)u();return o(),b}}const O$={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,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Jf(n,t,e={}){const r=(i,s,o)=>{const c=O$[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=n[i];if(!(o&&u===void 0)&&!c(u,n))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const N$=Object.freeze(Object.defineProperty({__proto__:null,bitGet:k$,bitLen:I$,bitMask:Vm,bitSet:T$,bytesToHex:Tu,bytesToNumberBE:Fa,bytesToNumberLE:zm,concatBytes:Yf,createHmacDrbg:pS,ensureBytes:bi,equalBytes:R$,hexToBytes:Ou,hexToNumber:Hm,numberToBytesBE:Nu,numberToBytesLE:Gm,numberToHexUnpadded:hS,numberToVarBytesBE:x$,utf8ToBytes:S$,validateObject:Jf},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Un=BigInt(0),xn=BigInt(1),$a=BigInt(2),C$=BigInt(3),jm=BigInt(4),gS=BigInt(5),yS=BigInt(8);BigInt(9),BigInt(16);function kr(n,t){const e=n%t;return e>=Un?e:t+e}function B$(n,t,e){if(e<=Un||t<Un)throw new Error("Expected power/modulo > 0");if(e===xn)return Un;let r=xn;for(;t>Un;)t&xn&&(r=r*n%e),n=n*n%e,t>>=xn;return r}function ni(n,t,e){let r=n;for(;t-- >Un;)r*=r,r%=e;return r}function Wm(n,t){if(n===Un||t<=Un)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=kr(n,t),r=t,i=Un,s=xn;for(;e!==Un;){const c=r/e,u=r%e,f=i-s*c;r=e,e=u,i=s,s=f}if(r!==xn)throw new Error("invert: does not exist");return kr(i,t)}function P$(n){const t=(n-xn)/$a;let e,r,i;for(e=n-xn,r=0;e%$a===Un;e/=$a,r++);for(i=$a;i<n&&B$(i,t,n)!==n-xn;i++);if(r===1){const o=(n+xn)/jm;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+xn)/$a;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=r,h=c.pow(c.mul(c.ONE,i),e),y=c.pow(u,s),A=c.pow(u,e);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let b=1;for(let k=c.sqr(A);b<f&&!c.eql(k,c.ONE);b++)k=c.sqr(k);const R=c.pow(h,xn<<BigInt(f-b-1));h=c.sqr(R),y=c.mul(y,R),A=c.mul(A,h),f=b}return y}}function M$(n){if(n%jm===C$){const t=(n+xn)/jm;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%yS===gS){const t=(n-gS)/yS;return function(r,i){const s=r.mul(i,$a),o=r.pow(s,t),c=r.mul(i,o),u=r.mul(r.mul(c,$a),o),f=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return P$(n)}const L$=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function U$(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=L$.reduce((r,i)=>(r[i]="function",r),t);return Jf(n,e)}function D$(n,t,e){if(e<Un)throw new Error("Expected power > 0");if(e===Un)return n.ONE;if(e===xn)return t;let r=n.ONE,i=t;for(;e>Un;)e&xn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=xn;return r}function F$(n,t){const e=new Array(t.length),r=t.reduce((s,o,c)=>n.is0(o)?s:(e[c]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,c)=>n.is0(o)?s:(e[c]=n.mul(s,e[c]),n.mul(s,o)),i),e}function mS(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function $$(n,t,e=!1,r={}){if(n<=Un)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:i,nByteLength:s}=mS(n,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=M$(n),c=Object.freeze({ORDER:n,BITS:i,BYTES:s,MASK:Vm(i),ZERO:Un,ONE:xn,create:u=>kr(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Un<=u&&u<n},is0:u=>u===Un,isOdd:u=>(u&xn)===xn,neg:u=>kr(-u,n),eql:(u,f)=>u===f,sqr:u=>kr(u*u,n),add:(u,f)=>kr(u+f,n),sub:(u,f)=>kr(u-f,n),mul:(u,f)=>kr(u*f,n),pow:(u,f)=>D$(c,u,f),div:(u,f)=>kr(u*Wm(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Wm(u,n),sqrt:r.sqrt||(u=>o(c,u)),invertBatch:u=>F$(c,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?Gm(u,s):Nu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?zm(u):Fa(u)}});return Object.freeze(c)}function wS(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function bS(n){const t=wS(n);return t+Math.ceil(t/2)}function H$(n,t,e=!1){const r=n.length,i=wS(t),s=bS(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=e?Fa(n):zm(n),c=kr(o,t-xn)+xn;return e?Gm(c,i):Nu(c,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const z$=BigInt(0),Zm=BigInt(1);function G$(n,t){const e=(i,s)=>{const o=s.negate();return i?o:s},r=i=>{const s=Math.ceil(t/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:e,unsafeLadder(i,s){let o=n.ZERO,c=i;for(;s>z$;)s&Zm&&(o=o.add(c)),c=c.double(),s>>=Zm;return o},precomputeWindow(i,s){const{windows:o,windowSize:c}=r(s),u=[];let f=i,h=f;for(let y=0;y<o;y++){h=f,u.push(h);for(let A=1;A<c;A++)h=h.add(f),u.push(h);f=h.double()}return u},wNAF(i,s,o){const{windows:c,windowSize:u}=r(i);let f=n.ZERO,h=n.BASE;const y=BigInt(2**i-1),A=2**i,b=BigInt(i);for(let R=0;R<c;R++){const k=R*u;let S=Number(o&y);o>>=b,S>u&&(S-=A,o+=Zm);const B=k,H=k+Math.abs(S)-1,U=R%2!==0,G=S<0;S===0?h=h.add(e(U,s[B])):f=f.add(e(G,s[H]))}return{p:f,f:h}},wNAFCached(i,s,o,c){const u=i._WINDOW_SIZE||1;let f=s.get(i);return f||(f=this.precomputeWindow(i,u),u!==1&&s.set(i,c(f))),this.wNAF(u,f,o)}}}function _S(n){return U$(n.Fp),Jf(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...mS(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function V$(n){const t=_S(n);Jf(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:K$,hexToBytes:j$}=N$,Ha={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Ha;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:K$(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Ha,e=typeof n=="string"?j$(n):n;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=Ha._parseInt(e.subarray(2)),{d:o,l:c}=Ha._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(n){const t=f=>Number.parseInt(f[0],16)&8?"00"+f:f,e=f=>{const h=f.toString(16);return h.length&1?`0${h}`:h},r=t(e(n.s)),i=t(e(n.r)),s=r.length/2,o=i.length/2,c=e(s),u=e(o);return`30${e(o+s+4)}02${u}${i}02${c}${r}`}},Bs=BigInt(0),ri=BigInt(1);BigInt(2);const AS=BigInt(3);BigInt(4);function W$(n){const t=V$(n),{Fp:e}=t,r=t.toBytes||((R,k,S)=>{const B=k.toAffine();return Yf(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(R=>{const k=R.subarray(1),S=e.fromBytes(k.subarray(0,e.BYTES)),B=e.fromBytes(k.subarray(e.BYTES,2*e.BYTES));return{x:S,y:B}});function s(R){const{a:k,b:S}=t,B=e.sqr(R),H=e.mul(B,R);return e.add(e.add(H,e.mul(R,k)),S)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(R){return typeof R=="bigint"&&Bs<R&&R<t.n}function c(R){if(!o(R))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(R){const{allowedPrivateKeyLengths:k,nByteLength:S,wrapPrivateKey:B,n:H}=t;if(k&&typeof R!="bigint"){if(R instanceof Uint8Array&&(R=Tu(R)),typeof R!="string"||!k.includes(R.length))throw new Error("Invalid key");R=R.padStart(S*2,"0")}let U;try{U=typeof R=="bigint"?R:Fa(bi("private key",R,S))}catch{throw new Error(`private key must be ${S} bytes, hex or bigint, not ${typeof R}`)}return B&&(U=kr(U,H)),c(U),U}const f=new Map;function h(R){if(!(R instanceof y))throw new Error("ProjectivePoint expected")}class y{constructor(k,S,B){if(this.px=k,this.py=S,this.pz=B,k==null||!e.isValid(k))throw new Error("x required");if(S==null||!e.isValid(S))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required")}static fromAffine(k){const{x:S,y:B}=k||{};if(!k||!e.isValid(S)||!e.isValid(B))throw new Error("invalid affine point");if(k instanceof y)throw new Error("projective point not allowed");const H=U=>e.eql(U,e.ZERO);return H(S)&&H(B)?y.ZERO:new y(S,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const S=e.invertBatch(k.map(B=>B.pz));return k.map((B,H)=>B.toAffine(S[H])).map(y.fromAffine)}static fromHex(k){const S=y.fromAffine(i(bi("pointHex",k)));return S.assertValidity(),S}static fromPrivateKey(k){return y.BASE.multiply(u(k))}_setWindowSize(k){this._WINDOW_SIZE=k,f.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:S}=this.toAffine();if(!e.isValid(k)||!e.isValid(S))throw new Error("bad point: x or y not FE");const B=e.sqr(S),H=s(k);if(!e.eql(B,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:k}=this.toAffine();if(e.isOdd)return!e.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){h(k);const{px:S,py:B,pz:H}=this,{px:U,py:G,pz:W}=k,J=e.eql(e.mul(S,W),e.mul(U,H)),j=e.eql(e.mul(B,W),e.mul(G,H));return J&&j}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){const{a:k,b:S}=t,B=e.mul(S,AS),{px:H,py:U,pz:G}=this;let W=e.ZERO,J=e.ZERO,j=e.ZERO,Y=e.mul(H,H),it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(H,U);return rt=e.add(rt,rt),j=e.mul(H,G),j=e.add(j,j),W=e.mul(k,j),J=e.mul(B,ut),J=e.add(W,J),W=e.sub(it,J),J=e.add(it,J),J=e.mul(W,J),W=e.mul(rt,W),j=e.mul(B,j),ut=e.mul(k,ut),rt=e.sub(Y,ut),rt=e.mul(k,rt),rt=e.add(rt,j),j=e.add(Y,Y),Y=e.add(j,Y),Y=e.add(Y,ut),Y=e.mul(Y,rt),J=e.add(J,Y),ut=e.mul(U,G),ut=e.add(ut,ut),Y=e.mul(ut,rt),W=e.sub(W,Y),j=e.mul(ut,it),j=e.add(j,j),j=e.add(j,j),new y(W,J,j)}add(k){h(k);const{px:S,py:B,pz:H}=this,{px:U,py:G,pz:W}=k;let J=e.ZERO,j=e.ZERO,Y=e.ZERO;const it=t.a,ut=e.mul(t.b,AS);let rt=e.mul(S,U),ot=e.mul(B,G),C=e.mul(H,W),p=e.add(S,B),m=e.add(U,G);p=e.mul(p,m),m=e.add(rt,ot),p=e.sub(p,m),m=e.add(S,H);let v=e.add(U,W);return m=e.mul(m,v),v=e.add(rt,C),m=e.sub(m,v),v=e.add(B,H),J=e.add(G,W),v=e.mul(v,J),J=e.add(ot,C),v=e.sub(v,J),Y=e.mul(it,m),J=e.mul(ut,C),Y=e.add(J,Y),J=e.sub(ot,Y),Y=e.add(ot,Y),j=e.mul(J,Y),ot=e.add(rt,rt),ot=e.add(ot,rt),C=e.mul(it,C),m=e.mul(ut,m),ot=e.add(ot,C),C=e.sub(rt,C),C=e.mul(it,C),m=e.add(m,C),rt=e.mul(ot,m),j=e.add(j,rt),rt=e.mul(v,m),J=e.mul(p,J),J=e.sub(J,rt),rt=e.mul(p,ot),Y=e.mul(v,Y),Y=e.add(Y,rt),new y(J,j,Y)}subtract(k){return this.add(k.negate())}is0(){return this.equals(y.ZERO)}wNAF(k){return b.wNAFCached(this,f,k,S=>{const B=e.invertBatch(S.map(H=>H.pz));return S.map((H,U)=>H.toAffine(B[U])).map(y.fromAffine)})}multiplyUnsafe(k){const S=y.ZERO;if(k===Bs)return S;if(c(k),k===ri)return this;const{endo:B}=t;if(!B)return b.unsafeLadder(this,k);let{k1neg:H,k1:U,k2neg:G,k2:W}=B.splitScalar(k),J=S,j=S,Y=this;for(;U>Bs||W>Bs;)U&ri&&(J=J.add(Y)),W&ri&&(j=j.add(Y)),Y=Y.double(),U>>=ri,W>>=ri;return H&&(J=J.negate()),G&&(j=j.negate()),j=new y(e.mul(j.px,B.beta),j.py,j.pz),J.add(j)}multiply(k){c(k);let S=k,B,H;const{endo:U}=t;if(U){const{k1neg:G,k1:W,k2neg:J,k2:j}=U.splitScalar(S);let{p:Y,f:it}=this.wNAF(W),{p:ut,f:rt}=this.wNAF(j);Y=b.constTimeNegate(G,Y),ut=b.constTimeNegate(J,ut),ut=new y(e.mul(ut.px,U.beta),ut.py,ut.pz),B=Y.add(ut),H=it.add(rt)}else{const{p:G,f:W}=this.wNAF(S);B=G,H=W}return y.normalizeZ([B,H])[0]}multiplyAndAddUnsafe(k,S,B){const H=y.BASE,U=(W,J)=>J===Bs||J===ri||!W.equals(H)?W.multiplyUnsafe(J):W.multiply(J),G=U(this,S).add(U(k,B));return G.is0()?void 0:G}toAffine(k){const{px:S,py:B,pz:H}=this,U=this.is0();k==null&&(k=U?e.ONE:e.inv(H));const G=e.mul(S,k),W=e.mul(B,k),J=e.mul(H,k);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(J,e.ONE))throw new Error("invZ was invalid");return{x:G,y:W}}isTorsionFree(){const{h:k,isTorsionFree:S}=t;if(k===ri)return!0;if(S)return S(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:S}=t;return k===ri?this:S?S(y,this):this.multiplyUnsafe(t.h)}toRawBytes(k=!0){return this.assertValidity(),r(y,this,k)}toHex(k=!0){return Tu(this.toRawBytes(k))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);const A=t.nBitLength,b=G$(y,t.endo?Math.ceil(A/2):A);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function Z$(n){const t=_S(n);return Jf(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function q$(n){const t=Z$(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(m){return Bs<m&&m<e.ORDER}function c(m){return kr(m,r)}function u(m){return Wm(m,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:h,weierstrassEquation:y,isWithinCurveOrder:A}=W$({...t,toBytes(m,v,I){const N=v.toAffine(),M=e.toBytes(N.x),z=Yf;return I?z(Uint8Array.from([v.hasEvenY()?2:3]),M):z(Uint8Array.from([4]),M,e.toBytes(N.y))},fromBytes(m){const v=m.length,I=m[0],N=m.subarray(1);if(v===i&&(I===2||I===3)){const M=Fa(N);if(!o(M))throw new Error("Point is not on curve");const z=y(M);let P=e.sqrt(z);const _=(P&ri)===ri;return(I&1)===1!==_&&(P=e.neg(P)),{x:M,y:P}}else if(v===s&&I===4){const M=e.fromBytes(N.subarray(0,e.BYTES)),z=e.fromBytes(N.subarray(e.BYTES,2*e.BYTES));return{x:M,y:z}}else throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),b=m=>Tu(Nu(m,t.nByteLength));function R(m){const v=r>>ri;return m>v}function k(m){return R(m)?c(-m):m}const S=(m,v,I)=>Fa(m.slice(v,I));class B{constructor(v,I,N){this.r=v,this.s=I,this.recovery=N,this.assertValidity()}static fromCompact(v){const I=t.nByteLength;return v=bi("compactSignature",v,I*2),new B(S(v,0,I),S(v,I,2*I))}static fromDER(v){const{r:I,s:N}=Ha.toSig(bi("DER",v));return new B(I,N)}assertValidity(){if(!A(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!A(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(v){return new B(this.r,this.s,v)}recoverPublicKey(v){const{r:I,s:N,recovery:M}=this,z=j(bi("msgHash",v));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?I+t.n:I;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const _=M&1?"03":"02",F=f.fromHex(_+b(P)),ct=u(P),dt=c(-z*ct),mt=c(N*ct),Gt=f.BASE.multiplyAndAddUnsafe(F,dt,mt);if(!Gt)throw new Error("point at infinify");return Gt.assertValidity(),Gt}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Ou(this.toDERHex())}toDERHex(){return Ha.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ou(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=bS(t.n);return H$(t.randomBytes(m),t.n)},precompute(m=8,v=f.BASE){return v._setWindowSize(m),v.multiply(BigInt(3)),v}};function U(m,v=!0){return f.fromPrivateKey(m).toRawBytes(v)}function G(m){const v=m instanceof Uint8Array,I=typeof m=="string",N=(v||I)&&m.length;return v?N===i||N===s:I?N===2*i||N===2*s:m instanceof f}function W(m,v,I=!0){if(G(m))throw new Error("first arg must be private key");if(!G(v))throw new Error("second arg must be public key");return f.fromHex(v).multiply(h(m)).toRawBytes(I)}const J=t.bits2int||function(m){const v=Fa(m),I=m.length*8-t.nBitLength;return I>0?v>>BigInt(I):v},j=t.bits2int_modN||function(m){return c(J(m))},Y=Vm(t.nBitLength);function it(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(Bs<=m&&m<Y))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Nu(m,t.nByteLength)}function ut(m,v,I=rt){if(["recovered","canonical"].some(Lt=>Lt in I))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:M}=t;let{lowS:z,prehash:P,extraEntropy:_}=I;z==null&&(z=!0),m=bi("msgHash",m),P&&(m=bi("prehashed msgHash",N(m)));const F=j(m),ct=h(v),dt=[it(ct),it(F)];if(_!=null){const Lt=_===!0?M(e.BYTES):_;dt.push(bi("extraEntropy",Lt))}const mt=Yf(...dt),Gt=F;function Ut(Lt){const xe=J(Lt);if(!A(xe))return;const Kt=u(xe),Ft=f.BASE.multiply(xe).toAffine(),ke=c(Ft.x);if(ke===Bs)return;const re=c(Kt*c(Gt+ke*ct));if(re===Bs)return;let oe=(Ft.x===ke?0:2)|Number(Ft.y&ri),rn=re;return z&&R(re)&&(rn=k(re),oe^=1),new B(ke,rn,oe)}return{seed:mt,k2sig:Ut}}const rt={lowS:t.lowS,prehash:!1},ot={lowS:t.lowS,prehash:!1};function C(m,v,I=rt){const{seed:N,k2sig:M}=ut(m,v,I),z=t;return pS(z.hash.outputLen,z.nByteLength,z.hmac)(N,M)}f.BASE._setWindowSize(8);function p(m,v,I,N=ot){var Ft;const M=m;if(v=bi("msgHash",v),I=bi("publicKey",I),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:P}=N;let _,F;try{if(typeof M=="string"||M instanceof Uint8Array)try{_=B.fromDER(M)}catch(ke){if(!(ke instanceof Ha.Err))throw ke;_=B.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:ke,s:re}=M;_=new B(ke,re)}else throw new Error("PARSE");F=f.fromHex(I)}catch(ke){if(ke.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&_.hasHighS())return!1;P&&(v=t.hash(v));const{r:ct,s:dt}=_,mt=j(v),Gt=u(dt),Ut=c(mt*Gt),Lt=c(ct*Gt),xe=(Ft=f.BASE.multiplyAndAddUnsafe(F,Ut,Lt))==null?void 0:Ft.toAffine();return xe?c(xe.x)===ct:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:W,sign:C,verify:p,ProjectivePoint:f,Signature:B,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Q$(n){return{hash:n,hmac:(t,...e)=>VR(n,t,V7(...e)),randomBytes:K7}}function Y$(n,t){const e=r=>q$({...n,...Q$(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ES=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),vS=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),J$=BigInt(1),qm=BigInt(2),xS=(n,t)=>(n+t/qm)/t;function X$(n){const t=ES,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=ni(h,e,t)*h%t,A=ni(y,e,t)*h%t,b=ni(A,qm,t)*f%t,R=ni(b,i,t)*b%t,k=ni(R,s,t)*R%t,S=ni(k,c,t)*k%t,B=ni(S,u,t)*S%t,H=ni(B,c,t)*k%t,U=ni(H,e,t)*h%t,G=ni(U,o,t)*R%t,W=ni(G,r,t)*f%t,J=ni(W,qm,t);if(!Qm.eql(Qm.sqr(J),n))throw new Error("Cannot find square root");return J}const Qm=$$(ES,void 0,void 0,{sqrt:X$}),Co=Y$({a:BigInt(0),b:BigInt(7),Fp:Qm,n:vS,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=vS,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-J$*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),c=xS(s*n,t),u=xS(-r*n,t);let f=kr(n-c*e-u*i,t),h=kr(-c*r-u*s,t);const y=f>o,A=h>o;if(y&&(f=t-f),A&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:A,k2:h}}}},jR);BigInt(0),Co.ProjectivePoint;const Xf="0x0000000000000000000000000000000000000000",RS="0x0000000000000000000000000000000000000000000000000000000000000000",SS=BigInt(0),IS=BigInt(1),kS=BigInt(2),TS=BigInt(27),OS=BigInt(28),W0=BigInt(35),Cu={};function NS(n){return La(yr(n),32)}const Ri=class Ri{constructor(t,e,r,i){nt(this,Yu);nt(this,Ju);nt(this,Xu);nt(this,ac);P0(t,Cu,"Signature"),$(this,Yu,e),$(this,Ju,r),$(this,Xu,i),$(this,ac,null)}get r(){return T(this,Yu)}set r(t){K(vu(t)===32,"invalid r","value",t),$(this,Yu,Tt(t))}get s(){return T(this,Ju)}set s(t){K(vu(t)===32,"invalid s","value",t);const e=Tt(t);K(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),$(this,Ju,e)}get v(){return T(this,Xu)}set v(t){const e=ie(t,"value");K(e===27||e===28,"invalid v","v",t),$(this,Xu,e)}get networkV(){return T(this,ac)}get legacyChainId(){const t=this.networkV;return t==null?null:Ri.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){const t=we(this.s);return this.yParity&&(t[0]|=128),Tt(t)}get compactSerialized(){return vn([this.r,this.yParityAndS])}get serialized(){return vn([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 t=new Ri(Cu,this.r,this.s,this.v);return this.networkV&&$(t,ac,this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:t!=null?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Ct(t,"v");return e==TS||e==OS?SS:(K(e>=W0,"invalid EIP-155 v","v",t),(e-W0)/kS)}static getChainIdV(t,e){return Ct(t)*kS+BigInt(35+e-27)}static getNormalizedV(t){const e=Ct(t);return e===SS||e===TS?27:e===IS||e===OS?28:(K(e>=W0,"invalid v","v",t),e&IS?27:28)}static from(t){function e(f,h){K(f,h,"signature",t)}if(t==null)return new Ri(Cu,RS,RS,27);if(typeof t=="string"){const f=we(t,"signature");if(f.length===64){const h=Tt(f.slice(0,32)),y=f.slice(32,64),A=y[0]&128?28:27;return y[0]&=127,new Ri(Cu,h,Tt(y),A)}if(f.length===65){const h=Tt(f.slice(0,32)),y=f.slice(32,64);e((y[0]&128)===0,"non-canonical s");const A=Ri.getNormalizedV(f[64]);return new Ri(Cu,h,Tt(y),A)}e(!1,"invalid raw signature length")}if(t instanceof Ri)return t.clone();const r=t.r;e(r!=null,"missing r");const i=NS(r),s=function(f,h){if(f!=null)return NS(f);if(h!=null){e(ze(h,32),"invalid yParityAndS");const y=we(h);return y[0]&=127,Tt(y)}e(!1,"missing s")}(t.s,t.yParityAndS);e((we(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:c}=function(f,h,y){if(f!=null){const A=Ct(f);return{networkV:A>=W0?A:void 0,v:Ri.getNormalizedV(A)}}if(h!=null)return e(ze(h,32),"invalid yParityAndS"),{v:we(h)[0]&128?28:27};if(y!=null){switch(ie(y,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),u=new Ri(Cu,i,s,c);return o&&$(u,ac,o),e(t.yParity==null||ie(t.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),e(t.yParityAndS==null||t.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};Yu=new WeakMap,Ju=new WeakMap,Xu=new WeakMap,ac=new WeakMap;let _i=Ri;const cc=class cc{constructor(t){nt(this,zs);K(vu(t)===32,"invalid private key","privateKey","[REDACTED]"),$(this,zs,Tt(t))}get privateKey(){return T(this,zs)}get publicKey(){return cc.computePublicKey(T(this,zs))}get compressedPublicKey(){return cc.computePublicKey(T(this,zs),!0)}sign(t){K(vu(t)===32,"invalid digest length","digest",t);const e=Co.sign(gr(t),gr(T(this,zs)),{lowS:!0});return _i.from({r:So(e.r,32),s:So(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=cc.computePublicKey(t);return Tt(Co.getSharedSecret(gr(T(this,zs)),we(e),!1))}static computePublicKey(t,e){let r=we(t,"key");if(r.length===32){const s=Co.getPublicKey(r,!!e);return Tt(s)}if(r.length===64){const s=new Uint8Array(65);s[0]=4,s.set(r,1),r=s}const i=Co.ProjectivePoint.fromHex(r);return Tt(i.toRawBytes(e))}static recoverPublicKey(t,e){K(vu(t)===32,"invalid digest length","digest",t);const r=_i.from(e);let i=Co.Signature.fromCompact(gr(vn([r.r,r.s])));i=i.addRecoveryBit(r.yParity);const s=i.recoverPublicKey(gr(t));return K(s!=null,"invalid signautre for digest","signature",e),"0x"+s.toHex(!1)}static addPoints(t,e,r){const i=Co.ProjectivePoint.fromHex(cc.computePublicKey(t).substring(2)),s=Co.ProjectivePoint.fromHex(cc.computePublicKey(e).substring(2));return"0x"+i.add(s).toHex(!!r)}};zs=new WeakMap;let th=cc;const tH=BigInt(0),eH=BigInt(36);function CS(n){n=n.toLowerCase();const t=n.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const r=we(On(e));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(r[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const Ym={};for(let n=0;n<10;n++)Ym[String(n)]=String(n);for(let n=0;n<26;n++)Ym[String.fromCharCode(65+n)]=String(10+n);const BS=15;function nH(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(r=>Ym[r]).join("");for(;t.length>=BS;){let r=t.substring(0,BS);t=parseInt(r,10)%97+t.substring(r.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const rH=function(){const n={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];n[e]=BigInt(t)}return n}();function iH(n){n=n.toLowerCase();let t=tH;for(let e=0;e<n.length;e++)t=t*eH+rH[n[e]];return t}function Me(n){if(K(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const t=CS(n);return K(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===n,"bad address checksum","address",n),t}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){K(n.substring(2,4)===nH(n),"bad icap checksum","address",n);let t=iH(n.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return CS("0x"+t)}K(!1,"invalid address","address",n)}function sH(n){const t=Me(n.from);let r=Ct(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,Me(un(On(Ua([t,r])),12))}function PS(n){return n&&typeof n.getAddress=="function"}async function Jm(n,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(ht(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),K(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),Me(e)}function wr(n,t){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?Me(n):(ht(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Jm(n,t.resolveName(n)));if(PS(n))return Jm(n,n.getAddress());if(n&&typeof n.then=="function")return Jm(n,n);K(!1,"unsupported addressable value","target",n)}const Ps={};function It(n,t){let e=!1;return t<0&&(e=!0,t*=-1),new ir(Ps,`${e?"":"u"}int${t}`,n,{signed:e,width:t})}function Ae(n,t){return new ir(Ps,`bytes${t||""}`,n,{size:t})}const MS=Symbol.for("_ethers_typed"),Gs=class Gs{constructor(t,e,r,i){Z(this,"type");Z(this,"value");nt(this,uc);Z(this,"_typedSymbol");i==null&&(i=null),P0(Ps,t,"Typed"),$t(this,{_typedSymbol:MS,type:e,value:r}),$(this,uc,i),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(t=>t.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,uc)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,uc)===!0?-1:T(this,uc)===!1?this.value.length:null}static from(t,e){return new Gs(Ps,t,e)}static uint8(t){return It(t,8)}static uint16(t){return It(t,16)}static uint24(t){return It(t,24)}static uint32(t){return It(t,32)}static uint40(t){return It(t,40)}static uint48(t){return It(t,48)}static uint56(t){return It(t,56)}static uint64(t){return It(t,64)}static uint72(t){return It(t,72)}static uint80(t){return It(t,80)}static uint88(t){return It(t,88)}static uint96(t){return It(t,96)}static uint104(t){return It(t,104)}static uint112(t){return It(t,112)}static uint120(t){return It(t,120)}static uint128(t){return It(t,128)}static uint136(t){return It(t,136)}static uint144(t){return It(t,144)}static uint152(t){return It(t,152)}static uint160(t){return It(t,160)}static uint168(t){return It(t,168)}static uint176(t){return It(t,176)}static uint184(t){return It(t,184)}static uint192(t){return It(t,192)}static uint200(t){return It(t,200)}static uint208(t){return It(t,208)}static uint216(t){return It(t,216)}static uint224(t){return It(t,224)}static uint232(t){return It(t,232)}static uint240(t){return It(t,240)}static uint248(t){return It(t,248)}static uint256(t){return It(t,256)}static uint(t){return It(t,256)}static int8(t){return It(t,-8)}static int16(t){return It(t,-16)}static int24(t){return It(t,-24)}static int32(t){return It(t,-32)}static int40(t){return It(t,-40)}static int48(t){return It(t,-48)}static int56(t){return It(t,-56)}static int64(t){return It(t,-64)}static int72(t){return It(t,-72)}static int80(t){return It(t,-80)}static int88(t){return It(t,-88)}static int96(t){return It(t,-96)}static int104(t){return It(t,-104)}static int112(t){return It(t,-112)}static int120(t){return It(t,-120)}static int128(t){return It(t,-128)}static int136(t){return It(t,-136)}static int144(t){return It(t,-144)}static int152(t){return It(t,-152)}static int160(t){return It(t,-160)}static int168(t){return It(t,-168)}static int176(t){return It(t,-176)}static int184(t){return It(t,-184)}static int192(t){return It(t,-192)}static int200(t){return It(t,-200)}static int208(t){return It(t,-208)}static int216(t){return It(t,-216)}static int224(t){return It(t,-224)}static int232(t){return It(t,-232)}static int240(t){return It(t,-240)}static int248(t){return It(t,-248)}static int256(t){return It(t,-256)}static int(t){return It(t,-256)}static bytes1(t){return Ae(t,1)}static bytes2(t){return Ae(t,2)}static bytes3(t){return Ae(t,3)}static bytes4(t){return Ae(t,4)}static bytes5(t){return Ae(t,5)}static bytes6(t){return Ae(t,6)}static bytes7(t){return Ae(t,7)}static bytes8(t){return Ae(t,8)}static bytes9(t){return Ae(t,9)}static bytes10(t){return Ae(t,10)}static bytes11(t){return Ae(t,11)}static bytes12(t){return Ae(t,12)}static bytes13(t){return Ae(t,13)}static bytes14(t){return Ae(t,14)}static bytes15(t){return Ae(t,15)}static bytes16(t){return Ae(t,16)}static bytes17(t){return Ae(t,17)}static bytes18(t){return Ae(t,18)}static bytes19(t){return Ae(t,19)}static bytes20(t){return Ae(t,20)}static bytes21(t){return Ae(t,21)}static bytes22(t){return Ae(t,22)}static bytes23(t){return Ae(t,23)}static bytes24(t){return Ae(t,24)}static bytes25(t){return Ae(t,25)}static bytes26(t){return Ae(t,26)}static bytes27(t){return Ae(t,27)}static bytes28(t){return Ae(t,28)}static bytes29(t){return Ae(t,29)}static bytes30(t){return Ae(t,30)}static bytes31(t){return Ae(t,31)}static bytes32(t){return Ae(t,32)}static address(t){return new Gs(Ps,"address",t)}static bool(t){return new Gs(Ps,"bool",!!t)}static bytes(t){return new Gs(Ps,"bytes",t)}static string(t){return new Gs(Ps,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new Gs(Ps,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===MS}static dereference(t,e){if(Gs.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};uc=new WeakMap;let ir=Gs;class oH extends Cs{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=ir.dereference(e,"string");try{r=Me(r)}catch(i){return this._throwError(i.message,e)}return t.writeValue(r)}decode(t){return Me(So(t.readValue(),20))}}class aH extends Cs{constructor(e){super(e.name,e.type,"_",e.dynamic);Z(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}function LS(n,t,e){let r=[];if(Array.isArray(e))r=e;else if(e&&typeof e=="object"){let u={};r=t.map(f=>{const h=f.localName;return ht(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),ht(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),u[h]=!0,e[h]})}else K(!1,"invalid tuple value","tuple",e);K(t.length===r.length,"types/value length mismatch","tuple",e);let i=new Cm,s=new Cm,o=[];t.forEach((u,f)=>{let h=r[f];if(u.dynamic){let y=s.length;u.encode(s,h);let A=i.writeUpdatableValue();o.push(b=>{A(b+y)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let c=n.appendWriter(i);return c+=n.appendWriter(s),c}function US(n,t){let e=[],r=[],i=n.subReader(0);return t.forEach(s=>{let o=null;if(s.dynamic){let c=n.readIndex(),u=i.subReader(c);try{o=s.decode(u)}catch(f){if(Zn(f,"BUFFER_OVERRUN"))throw f;o=f,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(n)}catch(c){if(Zn(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");e.push(o),r.push(s.localName||null)}),Su.fromItems(e,r)}class cH extends Cs{constructor(e,r,i){const s=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",s,i,o);Z(this,"coder");Z(this,"length");$t(this,{coder:e,length:r})}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){const i=ir.dereference(r,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,e.writeValue(i.length)),yR(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let c=0;c<i.length;c++)o.push(this.coder);return LS(e,o,i)}decode(e){let r=this.length;r===-1&&(r=e.readIndex(),ht(r*mr<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:r*mr,length:e.dataLength}));let i=[];for(let s=0;s<r;s++)i.push(new aH(this.coder));return US(e,i)}}class uH extends Cs{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=ir.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class DS extends Cs{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=gr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class lH extends DS{constructor(t){super("bytes",t)}decode(t){return Tt(super.decode(t))}}class fH extends Cs{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1);Z(this,"size");$t(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=gr(ir.dereference(r,this.type));return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return Tt(e.readBytes(this.size))}}const hH=new Uint8Array([]);class dH extends Cs{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(hH)}decode(t){return t.readBytes(0),null}}const pH=BigInt(0),gH=BigInt(1),yH=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class mH extends Cs{constructor(e,r,i){const s=(r?"int":"uint")+e*8;super(s,s,i,!1);Z(this,"size");Z(this,"signed");$t(this,{size:e,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,r){let i=Ct(ir.dereference(r,this.type)),s=Zf(yH,mr*8);if(this.signed){let o=Zf(s,this.size*8-1);(i>o||i<-(o+gH))&&this._throwError("value out-of-bounds",r),i=_R(i,8*mr)}else(i<pH||i>Zf(s,this.size*8))&&this._throwError("value out-of-bounds",r);return e.writeValue(i)}decode(e){let r=Zf(e.readValue(),this.size*8);return this.signed&&(r=E7(r,this.size*8)),r}}class wH extends DS{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Os(ir.dereference(e,"string")))}decode(t){return U0(super.decode(t))}}class Z0 extends Cs{constructor(e,r){let i=!1;const s=[];e.forEach(c=>{c.dynamic&&(i=!0),s.push(c.type)});const o="tuple("+s.join(",")+")";super("tuple",o,r,i);Z(this,"coders");$t(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(i=>{e.push(i.defaultValue())});const r=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[s]))}),Object.freeze(e)}encode(e,r){const i=ir.dereference(r,"tuple");return LS(e,this.coders,i)}decode(e){return US(e,this.coders)}}function za(n){return On(Os(n))}var bH="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const FS=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),$S=4;function _H(n){let t=0;function e(){return n[t++]<<8|n[t++]}let r=e(),i=1,s=[0,1];for(let W=1;W<r;W++)s.push(i+=e());let o=e(),c=t;t+=o;let u=0,f=0;function h(){return u==0&&(f=f<<8|n[t++],u=8),f>>--u&1}const y=31,A=2**y,b=A>>>1,R=b>>1,k=A-1;let S=0;for(let W=0;W<y;W++)S=S<<1|h();let B=[],H=0,U=A;for(;;){let W=Math.floor(((S-H+1)*i-1)/U),J=0,j=r;for(;j-J>1;){let ut=J+j>>>1;W<s[ut]?j=ut:J=ut}if(J==0)break;B.push(J);let Y=H+Math.floor(U*s[J]/i),it=H+Math.floor(U*s[J+1]/i)-1;for(;!((Y^it)&b);)S=S<<1&k|h(),Y=Y<<1&k,it=it<<1&k|1;for(;Y&~it&R;)S=S&b|S<<1&k>>>1|h(),Y=Y<<1^b,it=(it^b)<<1|b|1;H=Y,U=1+it-Y}let G=r-4;return B.map(W=>{switch(W-G){case 3:return G+65792+(n[c++]<<16|n[c++]<<8|n[c++]);case 2:return G+256+(n[c++]<<8|n[c++]);case 1:return G+n[c++];default:return W-1}})}function AH(n){let t=0;return()=>n[t++]}function HS(n){return AH(_H(EH(n)))}function EH(n){let t=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>t[i.charCodeAt(0)]=s);let e=n.length,r=new Uint8Array(6*e>>3);for(let i=0,s=0,o=0,c=0;i<e;i++)c=c<<6|t[n.charCodeAt(i)],o+=6,o>=8&&(r[s++]=c>>(o-=8));return r}function vH(n){return n&1?~n>>1:n>>1}function xH(n,t){let e=Array(n);for(let r=0,i=0;r<n;r++)e[r]=i+=vH(t());return e}function eh(n,t=0){let e=[];for(;;){let r=n(),i=n();if(!i)break;t+=r;for(let s=0;s<i;s++)e.push(t+s);t+=i+1}return e}function zS(n){return nh(()=>{let t=eh(n);if(t.length)return t})}function GS(n){let t=[];for(;;){let e=n();if(e==0)break;t.push(RH(e,n))}for(;;){let e=n()-1;if(e<0)break;t.push(SH(e,n))}return t.flat()}function nh(n){let t=[];for(;;){let e=n(t.length);if(!e)break;t.push(e)}return t}function VS(n,t,e){let r=Array(n).fill().map(()=>[]);for(let i=0;i<t;i++)xH(n,e).forEach((s,o)=>r[o].push(s));return r}function RH(n,t){let e=1+t(),r=t(),i=nh(t);return VS(i.length,1+n,t).flatMap((o,c)=>{let[u,...f]=o;return Array(i[c]).fill().map((h,y)=>{let A=y*r;return[u+y*e,f.map(b=>b+A)]})})}function SH(n,t){let e=1+t();return VS(e,1+n,t).map(i=>[i[0],i.slice(1)])}function IH(n){let t=[],e=eh(n);return i(r([]),[]),t;function r(s){let o=n(),c=nh(()=>{let u=eh(n).map(f=>e[f]);if(u.length)return r(u)});return{S:o,B:c,Q:s}}function i({S:s,B:o},c,u){if(!(s&4&&u===c[c.length-1])){s&2&&(u=c[c.length-1]),s&1&&t.push(c);for(let f of o)for(let h of f.Q)i(f,[...c,h],u)}}}function kH(n){return n.toString(16).toUpperCase().padStart(2,"0")}function KS(n){return`{${kH(n)}}`}function TH(n){let t=[];for(let e=0,r=n.length;e<r;){let i=n.codePointAt(e);e+=i<65536?1:2,t.push(i)}return t}function Bu(n){let e=n.length;if(e<4096)return String.fromCodePoint(...n);let r=[];for(let i=0;i<e;)r.push(String.fromCodePoint(...n.slice(i,i+=4096)));return r.join("")}function OH(n,t){let e=n.length,r=e-t.length;for(let i=0;r==0&&i<e;i++)r=n[i]-t[i];return r}var NH="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+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 rh=44032,q0=4352,Q0=4449,Y0=4519,jS=19,WS=21,Pu=28,J0=WS*Pu,CH=jS*J0,BH=rh+CH,PH=q0+jS,MH=Q0+WS,LH=Y0+Pu;function ih(n){return n>>24&255}function ZS(n){return n&16777215}let Xm,qS,tw,X0;function UH(){let n=HS(NH);Xm=new Map(zS(n).flatMap((t,e)=>t.map(r=>[r,e+1<<24]))),qS=new Set(eh(n)),tw=new Map,X0=new Map;for(let[t,e]of GS(n)){if(!qS.has(t)&&e.length==2){let[r,i]=e,s=X0.get(r);s||(s=new Map,X0.set(r,s)),s.set(i,t)}tw.set(t,e.reverse())}}function QS(n){return n>=rh&&n<BH}function DH(n,t){if(n>=q0&&n<PH&&t>=Q0&&t<MH)return rh+(n-q0)*J0+(t-Q0)*Pu;if(QS(n)&&t>Y0&&t<LH&&(n-rh)%Pu==0)return n+(t-Y0);{let e=X0.get(n);return e&&(e=e.get(t),e)?e:-1}}function YS(n){Xm||UH();let t=[],e=[],r=!1;function i(s){let o=Xm.get(s);o&&(r=!0,s|=o),t.push(s)}for(let s of n)for(;;){if(s<128)t.push(s);else if(QS(s)){let o=s-rh,c=o/J0|0,u=o%J0/Pu|0,f=o%Pu;i(q0+c),i(Q0+u),f>0&&i(Y0+f)}else{let o=tw.get(s);o?e.push(...o):i(s)}if(!e.length)break;s=e.pop()}if(r&&t.length>1){let s=ih(t[0]);for(let o=1;o<t.length;o++){let c=ih(t[o]);if(c==0||s<=c){s=c;continue}let u=o-1;for(;;){let f=t[u+1];if(t[u+1]=t[u],t[u]=f,!u||(s=ih(t[--u]),s<=c))break}s=ih(t[o])}}return t}function FH(n){let t=[],e=[],r=-1,i=0;for(let s of n){let o=ih(s),c=ZS(s);if(r==-1)o==0?r=c:t.push(c);else if(i>0&&i>=o)o==0?(t.push(r,...e),e.length=0,r=c):e.push(c),i=o;else{let u=DH(r,c);u>=0?r=u:i==0&&o==0?(t.push(r),r=c):(e.push(c),i=o)}}return r>=0&&t.push(r,...e),t}function JS(n){return YS(n).map(ZS)}function $H(n){return FH(YS(n))}const XS=45,tI=".",eI=65039,nI=1,tp=n=>Array.from(n);function sh(n,t){return n.P.has(t)||n.Q.has(t)}class HH extends Array{get is_emoji(){return!0}}let ew,rI,Ga,nw,iI,Mu,rw,Lu,Va,sI,iw;function sw(){if(ew)return;let n=HS(bH);const t=()=>eh(n),e=()=>new Set(t()),r=(h,y)=>y.forEach(A=>h.add(A));ew=new Map(GS(n)),rI=e(),Ga=t(),nw=new Set(t().map(h=>Ga[h])),Ga=new Set(Ga),iI=e(),e();let i=zS(n),s=n();const o=()=>{let h=new Set;return t().forEach(y=>r(h,i[y])),r(h,t()),h};Mu=nh(h=>{let y=nh(n).map(A=>A+96);if(y.length){let A=h>=s;y[0]-=32,y=Bu(y),A&&(y=`Restricted[${y}]`);let b=o(),R=o(),k=!n();return{N:y,P:b,Q:R,M:k,R:A}}}),rw=e(),Lu=new Map;let c=t().concat(tp(rw)).sort((h,y)=>h-y);c.forEach((h,y)=>{let A=n(),b=c[y]=A?c[y-A]:{V:[],M:new Map};b.V.push(h),rw.has(h)||Lu.set(h,b)});for(let{V:h,M:y}of new Set(Lu.values())){let A=[];for(let R of h){let k=Mu.filter(B=>sh(B,R)),S=A.find(({G:B})=>k.some(H=>B.has(H)));S||(S={G:new Set,V:[]},A.push(S)),S.V.push(R),r(S.G,k)}let b=A.flatMap(R=>tp(R.G));for(let{G:R,V:k}of A){let S=new Set(b.filter(B=>!R.has(B)));for(let B of k)y.set(B,S)}}Va=new Set;let u=new Set;const f=h=>Va.has(h)?u.add(h):Va.add(h);for(let h of Mu){for(let y of h.P)f(y);for(let y of h.Q)f(y)}for(let h of Va)!Lu.has(h)&&!u.has(h)&&Lu.set(h,nI);r(Va,JS(Va)),sI=IH(n).map(h=>HH.from(h)).sort(OH),iw=new Map;for(let h of sI){let y=[iw];for(let A of h){let b=y.map(R=>{let k=R.get(A);return k||(k=new Map,R.set(A,k)),k});A===eI?y.push(...b):y=b}for(let A of y)A.V=h}}function ow(n){return(oI(n)?"":`${aw(ep([n]))} `)+KS(n)}function aw(n){return`"${n}"‎`}function zH(n){if(n.length>=4&&n[2]==XS&&n[3]==XS)throw new Error(`invalid label extension: "${Bu(n.slice(0,4))}"`)}function GH(n){for(let e=n.lastIndexOf(95);e>0;)if(n[--e]!==95)throw new Error("underscore allowed only at start")}function VH(n){let t=n[0],e=FS.get(t);if(e)throw oh(`leading ${e}`);let r=n.length,i=-1;for(let s=1;s<r;s++){t=n[s];let o=FS.get(t);if(o){if(i==s)throw oh(`${e} + ${o}`);i=s+1,e=o}}if(i==r)throw oh(`trailing ${e}`)}function ep(n,t=1/0,e=KS){let r=[];KH(n[0])&&r.push("◌"),n.length>t&&(t>>=1,n=[...n.slice(0,t),8230,...n.slice(-t)]);let i=0,s=n.length;for(let o=0;o<s;o++){let c=n[o];oI(c)&&(r.push(Bu(n.slice(i,o))),r.push(e(c)),i=o+1)}return r.push(Bu(n.slice(i,s))),r.join("")}function KH(n){return sw(),Ga.has(n)}function oI(n){return sw(),iI.has(n)}function jH(n){return QH(WH(n,$H,XH))}function WH(n,t,e){if(!n)return[];sw();let r=0;return n.split(tI).map(i=>{let s=TH(i),o={input:s,offset:r};r+=s.length+1;try{let c=o.tokens=JH(s,t,e),u=c.length,f;if(!u)throw new Error("empty label");let h=o.output=c.flat();if(GH(h),!(o.emoji=u>1||c[0].is_emoji)&&h.every(A=>A<128))zH(h),f="ASCII";else{let A=c.flatMap(b=>b.is_emoji?[]:b);if(!A.length)f="Emoji";else{if(Ga.has(h[0]))throw oh("leading combining mark");for(let k=1;k<u;k++){let S=c[k];if(!S.is_emoji&&Ga.has(S[0]))throw oh(`emoji + combining mark: "${Bu(c[k-1])} + ${ep([S[0]])}"`)}VH(h);let b=tp(new Set(A)),[R]=qH(b);YH(R,A),ZH(R,b),f=R.N}}o.type=f}catch(c){o.error=c}return o})}function ZH(n,t){let e,r=[];for(let i of t){let s=Lu.get(i);if(s===nI)return;if(s){let o=s.M.get(i);if(e=e?e.filter(c=>o.has(c)):tp(o),!e.length)return}else r.push(i)}if(e){for(let i of e)if(r.every(s=>sh(i,s)))throw new Error(`whole-script confusable: ${n.N}/${i.N}`)}}function qH(n){let t=Mu;for(let e of n){let r=t.filter(i=>sh(i,e));if(!r.length)throw Mu.some(i=>sh(i,e))?cI(t[0],e):aI(e);if(t=r,r.length==1)break}return t}function QH(n){return n.map(({input:t,error:e,output:r})=>{if(e){let i=e.message;throw new Error(n.length==1?i:`Invalid label ${aw(ep(t,63))}: ${i}`)}return Bu(r)}).join(tI)}function aI(n){return new Error(`disallowed character: ${ow(n)}`)}function cI(n,t){let e=ow(t),r=Mu.find(i=>i.P.has(t));return r&&(e=`${r.N} ${e}`),new Error(`illegal mixture: ${n.N} + ${e}`)}function oh(n){return new Error(`illegal placement: ${n}`)}function YH(n,t){for(let e of t)if(!sh(n,e))throw cI(n,e);if(n.M){let e=JS(t);for(let r=1,i=e.length;r<i;r++)if(nw.has(e[r])){let s=r+1;for(let o;s<i&&nw.has(o=e[s]);s++)for(let c=r;c<s;c++)if(e[c]==o)throw new Error(`duplicate non-spacing marks: ${ow(o)}`);if(s-r>$S)throw new Error(`excessive non-spacing marks: ${aw(ep(e.slice(r-1,s)))} (${s-r}/${$S})`);r=s}}}function JH(n,t,e){let r=[],i=[];for(n=n.slice().reverse();n.length;){let s=tz(n);if(s)i.length&&(r.push(t(i)),i=[]),r.push(e(s));else{let o=n.pop();if(Va.has(o))i.push(o);else{let c=ew.get(o);if(c)i.push(...c);else if(!rI.has(o))throw aI(o)}}}return i.length&&r.push(t(i)),r}function XH(n){return n.filter(t=>t!=eI)}function tz(n,t){let e=iw,r,i=n.length;for(;i&&(e=e.get(n[--i]),!!e);){let{V:s}=e;s&&(r=s,n.length=i)}return r}const uI=new Uint8Array(32);uI.fill(0);function lI(n){return K(n.length!==0,"invalid ENS name; empty component","comp",n),n}function fI(n){const t=Os(ez(n)),e=[];if(n.length===0)return e;let r=0;for(let i=0;i<t.length;i++)t[i]===46&&(e.push(lI(t.slice(r,i))),r=i+1);return K(r<t.length,"invalid ENS name; empty component","name",n),e.push(lI(t.slice(r))),e}function ez(n){try{if(n.length===0)throw new Error("empty label");return jH(n)}catch(t){K(!1,`invalid ENS name (${t.message})`,"name",n)}}function cw(n){K(typeof n=="string","invalid ENS name; not a string","name",n),K(n.length,"invalid ENS name (empty label)","name",n);let t=uI;const e=fI(n);for(;e.length;)t=On(vn([t,On(e.pop())]));return Tt(t)}function nz(n,t){const e=t;return K(e<=255,"DNS encoded label cannot exceed 255","length",e),Tt(vn(fI(n).map(r=>{K(r.length<=e,`label ${JSON.stringify(n)} exceeds ${e} bytes`,"name",n);const i=new Uint8Array(r.length+1);return i.set(r,1),i[0]=i.length-1,i})))+"00"}function uw(n,t){return{address:Me(n),storageKeys:t.map((e,r)=>(K(ze(e,32),"invalid slot",`storageKeys[${r}]`,e),e.toLowerCase()))}}function Ka(n){if(Array.isArray(n))return n.map((e,r)=>Array.isArray(e)?(K(e.length===2,"invalid slot set",`value[${r}]`,e),uw(e[0],e[1])):(K(e!=null&&typeof e=="object","invalid address-slot set","value",n),uw(e.address,e.storageKeys)));K(n!=null&&typeof n=="object","invalid access list","value",n);const t=Object.keys(n).map(e=>{const r=n[e].reduce((i,s)=>(i[s]=!0,i),{});return uw(e,Object.keys(r).sort())});return t.sort((e,r)=>e.address.localeCompare(r.address)),t}function rz(n){let t;return typeof n=="string"?t=th.computePublicKey(n,!1):t=n.publicKey,Me(On("0x"+t.substring(4)).substring(26))}function iz(n,t){return rz(th.recoverPublicKey(n,t))}const Dn=BigInt(0),sz=BigInt(2),oz=BigInt(27),az=BigInt(28),cz=BigInt(35),uz=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),lw=4096*32;function hI(n,t){let e=n.toString(16);for(;e.length<2;)e="0"+e;return e+=ku(t).substring(4),"0x"+e}function np(n){return n==="0x"?null:Me(n)}function fw(n,t){try{return Ka(n)}catch(e){K(!1,e.message,t,n)}}function ah(n,t){return n==="0x"?0:ie(n,t)}function Rn(n,t){if(n==="0x")return Dn;const e=Ct(n,t);return K(e<=uz,"value exceeds uint size",t,e),e}function We(n,t){const e=Ct(n,"value"),r=yr(e);return K(r.length<=32,"value too large",`tx.${t}`,e),r}function hw(n){return Ka(n).map(t=>[t.address,t.storageKeys])}function lz(n,t){K(Array.isArray(n),`invalid ${t}`,"value",n);for(let e=0;e<n.length;e++)K(ze(n[e],32),"invalid ${ param } hash",`value[${e}]`,n[e]);return n}function fz(n){const t=$0(n);K(Array.isArray(t)&&(t.length===9||t.length===6),"invalid field count for legacy transaction","data",n);const e={type:0,nonce:ah(t[0],"nonce"),gasPrice:Rn(t[1],"gasPrice"),gasLimit:Rn(t[2],"gasLimit"),to:np(t[3]),value:Rn(t[4],"value"),data:Tt(t[5]),chainId:Dn};if(t.length===6)return e;const r=Rn(t[6],"v"),i=Rn(t[7],"r"),s=Rn(t[8],"s");if(i===Dn&&s===Dn)e.chainId=r;else{let o=(r-cz)/sz;o<Dn&&(o=Dn),e.chainId=o,K(o!==Dn||r===oz||r===az,"non-canonical legacy v","v",t[6]),e.signature=_i.from({r:La(t[7],32),s:La(t[8],32),v:r})}return e}function hz(n,t){const e=[We(n.nonce,"nonce"),We(n.gasPrice||0,"gasPrice"),We(n.gasLimit,"gasLimit"),n.to||"0x",We(n.value,"value"),n.data];let r=Dn;if(n.chainId!=Dn)r=Ct(n.chainId,"tx.chainId"),K(!t||t.networkV==null||t.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",t);else if(n.signature){const s=n.signature.legacyChainId;s!=null&&(r=s)}if(!t)return r!==Dn&&(e.push(yr(r)),e.push("0x"),e.push("0x")),Ua(e);let i=BigInt(27+t.yParity);return r!==Dn?i=_i.getChainIdV(r,t.v):BigInt(t.v)!==i&&K(!1,"tx.chainId/sig.v mismatch","sig",t),e.push(yr(i)),e.push(yr(t.r)),e.push(yr(t.s)),Ua(e)}function dw(n,t){let e;try{if(e=ah(t[0],"yParity"),e!==0&&e!==1)throw new Error("bad yParity")}catch{K(!1,"invalid yParity","yParity",t[0])}const r=La(t[1],32),i=La(t[2],32),s=_i.from({r,s:i,yParity:e});n.signature=s}function dz(n){const t=$0(we(n).slice(1));K(Array.isArray(t)&&(t.length===9||t.length===12),"invalid field count for transaction type: 2","data",Tt(n));const e={type:2,chainId:Rn(t[0],"chainId"),nonce:ah(t[1],"nonce"),maxPriorityFeePerGas:Rn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:Rn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rn(t[4],"gasLimit"),to:np(t[5]),value:Rn(t[6],"value"),data:Tt(t[7]),accessList:fw(t[8],"accessList")};return t.length===9||dw(e,t.slice(9)),e}function pz(n,t){const e=[We(n.chainId,"chainId"),We(n.nonce,"nonce"),We(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),We(n.maxFeePerGas||0,"maxFeePerGas"),We(n.gasLimit,"gasLimit"),n.to||"0x",We(n.value,"value"),n.data,hw(n.accessList||[])];return t&&(e.push(We(t.yParity,"yParity")),e.push(yr(t.r)),e.push(yr(t.s))),vn(["0x02",Ua(e)])}function gz(n){const t=$0(we(n).slice(1));K(Array.isArray(t)&&(t.length===8||t.length===11),"invalid field count for transaction type: 1","data",Tt(n));const e={type:1,chainId:Rn(t[0],"chainId"),nonce:ah(t[1],"nonce"),gasPrice:Rn(t[2],"gasPrice"),gasLimit:Rn(t[3],"gasLimit"),to:np(t[4]),value:Rn(t[5],"value"),data:Tt(t[6]),accessList:fw(t[7],"accessList")};return t.length===8||dw(e,t.slice(8)),e}function yz(n,t){const e=[We(n.chainId,"chainId"),We(n.nonce,"nonce"),We(n.gasPrice||0,"gasPrice"),We(n.gasLimit,"gasLimit"),n.to||"0x",We(n.value,"value"),n.data,hw(n.accessList||[])];return t&&(e.push(We(t.yParity,"recoveryParam")),e.push(yr(t.r)),e.push(yr(t.s))),vn(["0x01",Ua(e)])}function mz(n){let t=$0(we(n).slice(1)),e="3",r=null;if(t.length===4&&Array.isArray(t[0])){e="3 (network format)";const s=t[1],o=t[2],c=t[3];K(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),K(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),K(Array.isArray(c),"invalid network format: proofs not an array","fields[3]",c),K(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",t),K(s.length===c.length,"invalid network format: blobs/proofs length mismatch","fields",t),r=[];for(let u=0;u<t[1].length;u++)r.push({data:s[u],commitment:o[u],proof:c[u]});t=t[0]}K(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${e}`,"data",Tt(n));const i={type:3,chainId:Rn(t[0],"chainId"),nonce:ah(t[1],"nonce"),maxPriorityFeePerGas:Rn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:Rn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rn(t[4],"gasLimit"),to:np(t[5]),value:Rn(t[6],"value"),data:Tt(t[7]),accessList:fw(t[8],"accessList"),maxFeePerBlobGas:Rn(t[9],"maxFeePerBlobGas"),blobVersionedHashes:t[10]};r&&(i.blobs=r),K(i.to!=null,`invalid address for transaction type: ${e}`,"data",n),K(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let s=0;s<i.blobVersionedHashes.length;s++)K(ze(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",n);return t.length===11||dw(i,t.slice(11)),i}function wz(n,t,e){const r=[We(n.chainId,"chainId"),We(n.nonce,"nonce"),We(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),We(n.maxFeePerGas||0,"maxFeePerGas"),We(n.gasLimit,"gasLimit"),n.to||Xf,We(n.value,"value"),n.data,hw(n.accessList||[]),We(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),lz(n.blobVersionedHashes||[],"blobVersionedHashes")];return t&&(r.push(We(t.yParity,"yParity")),r.push(yr(t.r)),r.push(yr(t.s)),e)?vn(["0x03",Ua([r,e.map(i=>i.data),e.map(i=>i.commitment),e.map(i=>i.proof)])]):vn(["0x03",Ua(r)])}const Ks=class Ks{constructor(){nt(this,fl);nt(this,es);nt(this,tl);nt(this,el);nt(this,nl);nt(this,rl);nt(this,il);nt(this,sl);nt(this,ol);nt(this,al);nt(this,cl);nt(this,ul);nt(this,ll);nt(this,lc);nt(this,Uo);nt(this,Vs);nt(this,Do);$(this,es,null),$(this,tl,null),$(this,nl,0),$(this,rl,Dn),$(this,il,null),$(this,sl,null),$(this,ol,null),$(this,el,"0x"),$(this,al,Dn),$(this,cl,Dn),$(this,ul,null),$(this,ll,null),$(this,lc,null),$(this,Uo,null),$(this,Do,null),$(this,Vs,null)}get type(){return T(this,es)}set type(t){switch(t){case null:$(this,es,null);break;case 0:case"legacy":$(this,es,0);break;case 1:case"berlin":case"eip-2930":$(this,es,1);break;case 2:case"london":case"eip-1559":$(this,es,2);break;case 3:case"cancun":case"eip-4844":$(this,es,3);break;default:K(!1,"unsupported transaction type","type",t)}}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 t=T(this,tl);return t==null&&this.type===3?Xf:t}set to(t){$(this,tl,t==null?null:Me(t))}get nonce(){return T(this,nl)}set nonce(t){$(this,nl,ie(t,"value"))}get gasLimit(){return T(this,rl)}set gasLimit(t){$(this,rl,Ct(t))}get gasPrice(){const t=T(this,il);return t==null&&(this.type===0||this.type===1)?Dn:t}set gasPrice(t){$(this,il,t==null?null:Ct(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=T(this,sl);return t??(this.type===2||this.type===3?Dn:null)}set maxPriorityFeePerGas(t){$(this,sl,t==null?null:Ct(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=T(this,ol);return t??(this.type===2||this.type===3?Dn:null)}set maxFeePerGas(t){$(this,ol,t==null?null:Ct(t,"maxFeePerGas"))}get data(){return T(this,el)}set data(t){$(this,el,Tt(t))}get value(){return T(this,al)}set value(t){$(this,al,Ct(t,"value"))}get chainId(){return T(this,cl)}set chainId(t){$(this,cl,Ct(t))}get signature(){return T(this,ul)||null}set signature(t){$(this,ul,t==null?null:_i.from(t))}get accessList(){const t=T(this,ll)||null;return t??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(t){$(this,ll,t==null?null:Ka(t))}get maxFeePerBlobGas(){const t=T(this,lc);return t==null&&this.type===3?Dn:t}set maxFeePerBlobGas(t){$(this,lc,t==null?null:Ct(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=T(this,Uo);return t==null&&this.type===3?[]:t}set blobVersionedHashes(t){if(t!=null){K(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)K(ze(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}$(this,Uo,t)}get blobs(){return T(this,Do)==null?null:T(this,Do).map(t=>Object.assign({},t))}set blobs(t){if(t==null){$(this,Do,null);return}const e=[],r=[];for(let i=0;i<t.length;i++){const s=t[i];if(Im(s)){ht(T(this,Vs),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=we(s);if(K(o.length<=lw,"blob is too large",`blobs[${i}]`,s),o.length!==lw){const f=new Uint8Array(lw);f.set(o),o=f}const c=T(this,Vs).blobToKzgCommitment(o),u=Tt(T(this,Vs).computeBlobKzgProof(o,c));e.push({data:Tt(o),commitment:Tt(c),proof:u}),r.push(hI(1,c))}else{const o=Tt(s.commitment);e.push({data:Tt(s.data),commitment:o,proof:Tt(s.proof)}),r.push(hI(1,o))}}$(this,Do,e),$(this,Uo,r)}get kzg(){return T(this,Vs)}set kzg(t){$(this,Vs,t)}get hash(){return this.signature==null?null:On(_t(this,fl,Gp).call(this,!0,!1))}get unsignedHash(){return On(this.unsignedSerialized)}get from(){return this.signature==null?null:iz(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:th.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return _t(this,fl,Gp).call(this,!0,!0)}get unsignedSerialized(){return _t(this,fl,Gp).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=this.gasPrice!=null,e=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,i=T(this,lc)!=null||T(this,Uo);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ht(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ht(!e||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ht(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):e?s.push(2):t?(s.push(1),r||s.push(0)):r?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Ks.from(this)}toJSON(){const t=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new Ks;if(typeof t=="string"){const r=we(t);if(r[0]>=127)return Ks.from(fz(r));switch(r[0]){case 1:return Ks.from(gz(r));case 2:return Ks.from(dz(r));case 3:return Ks.from(mz(r))}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new Ks;return t.type!=null&&(e.type=t.type),t.to!=null&&(e.to=t.to),t.nonce!=null&&(e.nonce=t.nonce),t.gasLimit!=null&&(e.gasLimit=t.gasLimit),t.gasPrice!=null&&(e.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(e.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(e.data=t.data),t.value!=null&&(e.value=t.value),t.chainId!=null&&(e.chainId=t.chainId),t.signature!=null&&(e.signature=_i.from(t.signature)),t.accessList!=null&&(e.accessList=t.accessList),t.blobVersionedHashes!=null&&(e.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(e.kzg=t.kzg),t.blobs!=null&&(e.blobs=t.blobs),t.hash!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),K(e.hash===t.hash,"hash mismatch","tx",t)),t.from!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),K(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}};es=new WeakMap,tl=new WeakMap,el=new WeakMap,nl=new WeakMap,rl=new WeakMap,il=new WeakMap,sl=new WeakMap,ol=new WeakMap,al=new WeakMap,cl=new WeakMap,ul=new WeakMap,ll=new WeakMap,lc=new WeakMap,Uo=new WeakMap,Vs=new WeakMap,Do=new WeakMap,fl=new WeakSet,Gp=function(t,e){ht(!t||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return hz(this,r);case 1:return yz(this,r);case 2:return pz(this,r);case 3:return wz(this,r,e?this.blobs:null)}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let rp=Ks;const dI=new Uint8Array(32);dI.fill(0);const bz=BigInt(-1),pI=BigInt(0),gI=BigInt(1),_z=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Az(n){const t=we(n),e=t.length%32;return e?vn([t,dI.slice(e)]):Tt(t)}const Ez=So(gI,32),vz=So(pI,32),yI={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},pw=["name","version","chainId","verifyingContract","salt"];function mI(n){return function(t){return K(typeof t=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const xz={name:mI("name"),version:mI("version"),chainId:function(n){const t=Ct(n,"domain.chainId");return K(t>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(t)?Number(t):Ru(t)},verifyingContract:function(n){try{return Me(n).toLowerCase()}catch{}K(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const t=we(n,"domain.salt");return K(t.length===32,'invalid domain value "salt"',"domain.salt",n),Tt(t)}};function gw(n){{const t=n.match(/^(u?)int(\d+)$/);if(t){const e=t[1]==="",r=parseInt(t[2]);K(r%8===0&&r!==0&&r<=256&&t[2]===String(r),"invalid numeric width","type",n);const i=Zf(_z,e?r-1:r),s=e?(i+gI)*bz:pI;return function(o){const c=Ct(o,"value");return K(c>=s&&c<=i,`value out-of-bounds for ${n}`,"value",c),So(e?_R(c,256):c,32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return K(e!==0&&e<=32&&t[1]===String(e),"invalid bytes width","type",n),function(r){const i=we(r);return K(i.length===e,`invalid length for ${n}`,"value",r),Az(r)}}}switch(n){case"address":return function(t){return La(Me(t),32)};case"bool":return function(t){return t?Ez:vz};case"bytes":return function(t){return On(t)};case"string":return function(t){return za(t)}}return null}function wI(n,t){return`${n}(${t.map(({name:e,type:r})=>r+" "+e).join(",")})`}function ip(n){const t=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:n}}const ii=class ii{constructor(t){nt(this,Ap);Z(this,"primaryType");nt(this,wh);nt(this,js);nt(this,hl);$(this,js,new Map),$(this,hl,new Map);const e=new Map,r=new Map,i=new Map,s={};Object.keys(t).forEach(u=>{s[u]=t[u].map(({name:f,type:h})=>{let{base:y,index:A}=ip(h);return y==="int"&&!t.int&&(y="int256"),y==="uint"&&!t.uint&&(y="uint256"),{name:f,type:y+(A||"")}}),e.set(u,new Set),r.set(u,[]),i.set(u,new Set)}),$(this,wh,JSON.stringify(s));for(const u in s){const f=new Set;for(const h of s[u]){K(!f.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",t),f.add(h.name);const y=ip(h.type).base;K(y!==u,`circular type reference to ${JSON.stringify(y)}`,"types",t),!gw(y)&&(K(r.has(y),`unknown type ${JSON.stringify(y)}`,"types",t),r.get(y).push(u),e.get(u).add(y))}}const o=Array.from(r.keys()).filter(u=>r.get(u).length===0);K(o.length!==0,"missing primary type","types",t),K(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",t),$t(this,{primaryType:o[0]});function c(u,f){K(!f.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",t),f.add(u);for(const h of e.get(u))if(r.has(h)){c(h,f);for(const y of f)i.get(y).add(h)}f.delete(u)}c(this.primaryType,new Set);for(const[u,f]of i){const h=Array.from(f);h.sort(),T(this,js).set(u,wI(u,s[u])+h.map(y=>wI(y,s[y])).join(""))}}get types(){return JSON.parse(T(this,wh))}getEncoder(t){let e=T(this,hl).get(t);return e||(e=_t(this,Ap,NT).call(this,t),T(this,hl).set(t,e)),e}encodeType(t){const e=T(this,js).get(t);return K(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return On(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gw(t))return r(t,e);const i=ip(t).array;if(i)return K(i.count===-1||i.count===e.length,`array length mismatch; expected length ${i.count}`,"value",e),e.map(o=>this._visit(i.prefix,o,r));const s=this.types[t];if(s)return s.reduce((o,{name:c,type:u})=>(o[c]=this._visit(u,e[c],r),o),{});K(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new ii(t)}static getPrimaryType(t){return ii.from(t).primaryType}static hashStruct(t,e,r){return ii.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(t[r]==null)continue;const i=yI[r];K(i,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort((r,i)=>pw.indexOf(r.name)-pw.indexOf(i.name)),ii.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return vn(["0x1901",ii.hashDomain(t),ii.from(e).hash(r)])}static hash(t,e,r){return On(ii.encode(t,e,r))}static async resolveNames(t,e,r,i){t=Object.assign({},t);for(const c in t)t[c]==null&&delete t[c];const s={};t.verifyingContract&&!ze(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const o=ii.from(e);o.visit(r,(c,u)=>(c==="address"&&!ze(u,20)&&(s[u]="0x"),u));for(const c in s)s[c]=await i(c);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),r=o.visit(r,(c,u)=>c==="address"&&s[u]?s[u]:u),{domain:t,value:r}}static getPayload(t,e,r){ii.hashDomain(t);const i={},s=[];pw.forEach(u=>{const f=t[u];f!=null&&(i[u]=xz[u](f),s.push({name:u,type:yI[u]}))});const o=ii.from(e);e=o.types;const c=Object.assign({},e);return K(c.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",e),c.EIP712Domain=s,o.encode(r),{types:c,domain:i,primaryType:o.primaryType,message:o.visit(r,(u,f)=>{if(u.match(/^bytes(\d*)/))return Tt(we(f));if(u.match(/^u?int/))return Ct(f).toString();switch(u){case"address":return f.toLowerCase();case"bool":return!!f;case"string":return K(typeof f=="string","invalid string","value",f),f}K(!1,"unsupported type","type",u)})}}};wh=new WeakMap,js=new WeakMap,hl=new WeakMap,Ap=new WeakSet,NT=function(t){{const i=gw(t);if(i)return i}const e=ip(t).array;if(e){const i=e.prefix,s=this.getEncoder(i);return o=>{K(e.count===-1||e.count===o.length,`array length mismatch; expected length ${e.count}`,"value",o);let c=o.map(s);return T(this,js).has(i)&&(c=c.map(On)),On(vn(c))}}const r=this.types[t];if(r){const i=za(T(this,js).get(t));return s=>{const o=r.map(({name:c,type:u})=>{const f=this.getEncoder(u)(s[c]);return T(this,js).has(u)?On(f):f});return o.unshift(i),vn(o)}}K(!1,`unknown type: ${t}`,"type",t)};let sp=ii;function br(n){const t=new Set;return n.forEach(e=>t.add(e)),Object.freeze(t)}const Rz=br("external public payable override".split(" ")),bI="constant external internal payable private public pure view override",Sz=br(bI.split(" ")),_I="constructor error event fallback function receive struct",AI=br(_I.split(" ")),EI="calldata memory storage payable indexed",Iz=br(EI.split(" ")),kz=[_I,EI,"tuple returns",bI].join(" "),Tz=br(kz.split(" ")),Oz={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Nz=new RegExp("^(\\s*)"),Cz=new RegExp("^([0-9]+)"),Bz=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),vI=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),xI=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Ep=class Ep{constructor(t){nt(this,bh);nt(this,Yn);nt(this,Si);$(this,Yn,0),$(this,Si,t.slice())}get offset(){return T(this,Yn)}get length(){return T(this,Si).length-T(this,Yn)}clone(){return new Ep(T(this,Si))}reset(){$(this,Yn,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=_t(this,bh,ab).call(this,T(this,Yn)+1,t.match+1);return $(this,Yn,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;T(this,Yn)<t.match-1;){const r=this.peek().linkNext;e.push(_t(this,bh,ab).call(this,T(this,Yn)+1,r)),$(this,Yn,r)}return $(this,Yn,t.match+1),e}peek(){if(T(this,Yn)>=T(this,Si).length)throw new Error("out-of-bounds");return T(this,Si)[T(this,Yn)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return rd(this,Yn)._++,t}toString(){const t=[];for(let e=T(this,Yn);e<T(this,Si).length;e++){const r=T(this,Si)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Yn=new WeakMap,Si=new WeakMap,bh=new WeakSet,ab=function(t=0,e=0){return new Ep(T(this,Si).slice(t,e).map(r=>Object.freeze(Object.assign({},r,{match:r.match-t,linkBack:r.linkBack-t,linkNext:r.linkNext-t}))))};let Ai=Ep;function Bo(n){const t=[],e=o=>{const c=s<n.length?JSON.stringify(n[s]):"$EOI";throw new Error(`invalid token ${c} at ${s}: ${o}`)};let r=[],i=[],s=0;for(;s<n.length;){let o=n.substring(s),c=o.match(Nz);c&&(s+=c[1].length,o=n.substring(s));const u={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};t.push(u);let f=Oz[o[0]]||"";if(f){if(u.type=f,u.text=o[0],s++,f==="OPEN_PAREN")r.push(t.length-1),i.push(t.length-1);else if(f=="CLOSE_PAREN")r.length===0&&e("no matching open bracket"),u.match=r.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1;else if(f==="COMMA")u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(f==="OPEN_BRACKET")u.type="BRACKET";else if(f==="CLOSE_BRACKET"){let h=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const y=t.pop().text;h=y+h,t[t.length-1].value=ie(y)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=h}continue}if(c=o.match(Bz),c){if(u.text=c[1],s+=u.text.length,Tz.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(xI)){u.type="TYPE";continue}u.type="ID";continue}if(c=o.match(Cz),c){u.text=c[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new Ai(t.map(o=>Object.freeze(o)))}function RI(n,t){let e=[];for(const r in t.keys())n.has(r)&&e.push(r);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function op(n,t){if(t.peekKeyword(AI)){const e=t.pop().text;if(e!==n)throw new Error(`expected ${n}, got ${e}`)}return t.popType("ID")}function Ms(n,t){const e=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||t&&!t.has(r))break;if(n.pop(),e.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);e.add(r)}return Object.freeze(e)}function SI(n){let t=Ms(n,Sz);return RI(t,br("constant payable nonpayable".split(" "))),RI(t,br("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Ls(n,t){return n.popParams().map(e=>qn.from(e,t))}function II(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ct(n.pop().text);throw new Error("invalid gas")}return null}function ja(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const Pz=new RegExp(/^(.*)\[([0-9]*)\]$/);function kI(n){const t=n.match(xI);if(K(t,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(t[2]){const e=parseInt(t[2]);K(e!==0&&e<=32,"invalid bytes length","type",n)}else if(t[3]){const e=parseInt(t[3]);K(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",n)}return n}const nn={},Tr=Symbol.for("_ethers_internal"),TI="_ParamTypeInternal",OI="_ErrorInternal",NI="_EventInternal",CI="_ConstructorInternal",BI="_FallbackInternal",PI="_FunctionInternal",MI="_StructInternal",si=class si{constructor(t,e,r,i,s,o,c,u){nt(this,dl);Z(this,"name");Z(this,"type");Z(this,"baseType");Z(this,"indexed");Z(this,"components");Z(this,"arrayLength");Z(this,"arrayChildren");if(P0(t,nn,"ParamType"),Object.defineProperty(this,Tr,{value:TI}),o&&(o=Object.freeze(o.slice())),i==="array"){if(c==null||u==null)throw new Error("")}else if(c!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");$t(this,{name:e,type:r,baseType:i,indexed:s,components:o,arrayLength:c,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const r=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=r,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(t)))),JSON.stringify(i)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(r=>r.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){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 r=this;return t.map(i=>r.arrayChildren.walk(i,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map((i,s)=>r.components[s].walk(i,e))}return e(this.type,t)}async walkAsync(t,e){const r=[],i=[t];return _t(this,dl,Vp).call(this,r,t,e,s=>{i[0]=s}),r.length&&await Promise.all(r),i[0]}static from(t,e){if(si.isParamType(t))return t;if(typeof t=="string")try{return si.from(Bo(t),e)}catch{K(!1,"invalid param type","obj",t)}else if(t instanceof Ai){let c="",u="",f=null;Ms(t,br(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",f=t.popParams().map(k=>si.from(k)),c=`tuple(${f.map(k=>k.format()).join(",")})`):(c=kI(t.popType("TYPE")),u=c);let h=null,y=null;for(;t.length&&t.peekType("BRACKET");){const k=t.pop();h=new si(nn,"",c,u,null,f,y,h),y=k.value,c+=k.text,u="array",f=null}let A=null;if(Ms(t,Iz).has("indexed")){if(!e)throw new Error("");A=!0}const R=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new si(nn,R,c,u,A,f,y,h)}const r=t.name;K(!r||typeof r=="string"&&r.match(vI),"invalid name","obj.name",r);let i=t.indexed;i!=null&&(K(e,"parameter cannot be indexed","obj.indexed",t.indexed),i=!!i);let s=t.type,o=s.match(Pz);if(o){const c=parseInt(o[2]||"-1"),u=si.from({type:o[1],components:t.components});return new si(nn,r||"",s,"array",i,null,c,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const c=t.components!=null?t.components.map(f=>si.from(f)):null;return new si(nn,r||"",s,"tuple",i,c,null,null)}return s=kI(t.type),new si(nn,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Tr]===TI}};dl=new WeakSet,Vp=function(t,e,r,i){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 o=this.arrayChildren,c=e.slice();c.forEach((u,f)=>{var h;_t(h=o,dl,Vp).call(h,t,u,r,y=>{c[f]=y})}),i(c);return}if(this.isTuple()){const o=this.components;let c;if(Array.isArray(e))c=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");c=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(c.length!==this.components.length)throw new Error("array is wrong length");c.forEach((u,f)=>{var h;_t(h=o[f],dl,Vp).call(h,t,u,r,y=>{c[f]=y})}),i(c);return}const s=r(this.type,e);s.then?t.push(async function(){i(await s)}()):i(s)};let qn=si;class Wa{constructor(t,e,r){Z(this,"type");Z(this,"inputs");P0(t,nn,"Fragment"),r=Object.freeze(r.slice()),$t(this,{type:e,inputs:r})}static from(t){if(typeof t=="string"){try{Wa.from(JSON.parse(t))}catch{}return Wa.from(Bo(t))}if(t instanceof Ai)switch(t.peekKeyword(AI)){case"constructor":return Us.from(t);case"error":return Or.from(t);case"event":return Yi.from(t);case"fallback":case"receive":return Ds.from(t);case"function":return Ji.from(t);case"struct":return Za.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return Us.from(t);case"error":return Or.from(t);case"event":return Yi.from(t);case"fallback":case"receive":return Ds.from(t);case"function":return Ji.from(t);case"struct":return Za.from(t)}ht(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}K(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Us.isFragment(t)}static isError(t){return Or.isFragment(t)}static isEvent(t){return Yi.isFragment(t)}static isFunction(t){return Ji.isFragment(t)}static isStruct(t){return Za.isFragment(t)}}class ap extends Wa{constructor(e,r,i,s){super(e,r,s);Z(this,"name");K(typeof i=="string"&&i.match(vI),"invalid identifier","name",i),s=Object.freeze(s.slice()),$t(this,{name:i})}}function ch(n,t){return"("+t.map(e=>e.format(n)).join(n==="full"?", ":",")+")"}class Or extends ap{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Tr,{value:OI})}get selector(){return za(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+ch(t,this.inputs)),e.join(" ")}static from(t){if(Or.isFragment(t))return t;if(typeof t=="string")return Or.from(Bo(t));if(t instanceof Ai){const e=op("error",t),r=Ls(t);return ja(t),new Or(nn,e,r)}return new Or(nn,t.name,t.inputs?t.inputs.map(qn.from):[])}static isFragment(t){return t&&t[Tr]===OI}}class Yi extends ap{constructor(e,r,i,s){super(e,"event",r,i);Z(this,"anonymous");Object.defineProperty(this,Tr,{value:NI}),$t(this,{anonymous:s})}get topicHash(){return za(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("event"),r.push(this.name+ch(e,this.inputs)),e!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(e,r){return r=(r||[]).map(s=>qn.from(s)),new Yi(nn,e,r,!1).topicHash}static from(e){if(Yi.isFragment(e))return e;if(typeof e=="string")try{return Yi.from(Bo(e))}catch{K(!1,"invalid event fragment","obj",e)}else if(e instanceof Ai){const r=op("event",e),i=Ls(e,!0),s=!!Ms(e,br(["anonymous"])).has("anonymous");return ja(e),new Yi(nn,r,i,s)}return new Yi(nn,e.name,e.inputs?e.inputs.map(r=>qn.from(r,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[Tr]===NI}}class Us extends Wa{constructor(e,r,i,s,o){super(e,r,i);Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Tr,{value:CI}),$t(this,{payable:s,gas:o})}format(e){if(ht(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="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(i=>JSON.parse(i.format(e)))});const r=[`constructor${ch(e,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(e){if(Us.isFragment(e))return e;if(typeof e=="string")try{return Us.from(Bo(e))}catch{K(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof Ai){Ms(e,br(["constructor"]));const r=Ls(e),i=!!Ms(e,Rz).has("payable"),s=II(e);return ja(e),new Us(nn,"constructor",r,i,s)}return new Us(nn,"constructor",e.inputs?e.inputs.map(qn.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Tr]===CI}}class Ds extends Wa{constructor(e,r,i){super(e,"fallback",r);Z(this,"payable");Object.defineProperty(this,Tr,{value:BI}),$t(this,{payable:i})}format(e){const r=this.inputs.length===0?"receive":"fallback";if(e==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:i})}return`${r}()${this.payable?" payable":""}`}static from(e){if(Ds.isFragment(e))return e;if(typeof e=="string")try{return Ds.from(Bo(e))}catch{K(!1,"invalid fallback fragment","obj",e)}else if(e instanceof Ai){const r=e.toString(),i=e.peekKeyword(br(["fallback","receive"]));if(K(i,"type must be fallback or receive","obj",r),e.popKeyword(br(["fallback","receive"]))==="receive"){const u=Ls(e);return K(u.length===0,"receive cannot have arguments","obj.inputs",u),Ms(e,br(["payable"])),ja(e),new Ds(nn,[],!0)}let o=Ls(e);o.length?K(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[qn.from("bytes")];const c=SI(e);if(K(c==="nonpayable"||c==="payable","fallback cannot be constants","obj.stateMutability",c),Ms(e,br(["returns"])).has("returns")){const u=Ls(e);K(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(f=>f.format("minimal")).join(", "))}return ja(e),new Ds(nn,o,c==="payable")}if(e.type==="receive")return new Ds(nn,[],!0);if(e.type==="fallback"){const r=[qn.from("bytes")],i=e.stateMutability==="payable";return new Ds(nn,r,i)}K(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Tr]===BI}}class Ji extends ap{constructor(e,r,i,s,o,c){super(e,"function",r,s);Z(this,"constant");Z(this,"outputs");Z(this,"stateMutability");Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Tr,{value:PI}),o=Object.freeze(o.slice()),$t(this,{constant:i==="view"||i==="pure",gas:c,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return za(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="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(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("function"),r.push(this.name+ch(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(ch(e,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(e,r){return r=(r||[]).map(s=>qn.from(s)),new Ji(nn,e,"view",r,[],null).selector}static from(e){if(Ji.isFragment(e))return e;if(typeof e=="string")try{return Ji.from(Bo(e))}catch{K(!1,"invalid function fragment","obj",e)}else if(e instanceof Ai){const i=op("function",e),s=Ls(e),o=SI(e);let c=[];Ms(e,br(["returns"])).has("returns")&&(c=Ls(e));const u=II(e);return ja(e),new Ji(nn,i,o,s,c,u)}let r=e.stateMutability;return r==null&&(r="payable",typeof e.constant=="boolean"?(r="view",e.constant||(r="payable",typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable")),new Ji(nn,e.name,r,e.inputs?e.inputs.map(qn.from):[],e.outputs?e.outputs.map(qn.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Tr]===PI}}class Za extends ap{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Tr,{value:MI})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Za.from(Bo(t))}catch{K(!1,"invalid struct fragment","obj",t)}else if(t instanceof Ai){const e=op("struct",t),r=Ls(t);return ja(t),new Za(nn,e,r)}return new Za(nn,t.name,t.inputs?t.inputs.map(qn.from):[])}static isFragment(t){return t&&t[Tr]===MI}}const Ei=new Map;Ei.set(0,"GENERIC_PANIC"),Ei.set(1,"ASSERT_FALSE"),Ei.set(17,"OVERFLOW"),Ei.set(18,"DIVIDE_BY_ZERO"),Ei.set(33,"ENUM_RANGE_ERROR"),Ei.set(34,"BAD_STORAGE_DATA"),Ei.set(49,"STACK_UNDERFLOW"),Ei.set(50,"ARRAY_RANGE_ERROR"),Ei.set(65,"OUT_OF_MEMORY"),Ei.set(81,"UNINITIALIZED_FUNCTION_CALL");const Mz=new RegExp(/^bytes([0-9]*)$/),Lz=new RegExp(/^(u?int)([0-9]*)$/);let yw=null,LI=1024;function Uz(n,t,e,r){let i="missing revert data",s=null;const o=null;let c=null;if(e){i="execution reverted";const f=we(e);if(e=Tt(e),f.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(f.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(Tt(f.slice(0,4))==="0x08c379a0")try{s=r.decode(["string"],f.slice(4))[0],c={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(Tt(f.slice(0,4))==="0x4e487b71")try{const h=Number(r.decode(["uint256"],f.slice(4))[0]);c={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Ei.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:t.to?Me(t.to):null,data:t.data||"0x"};return t.from&&(u.from=Me(t.from)),Qe(i,"CALL_EXCEPTION",{action:n,data:e,reason:s,transaction:u,invocation:o,revert:c})}const vp=class vp{constructor(){nt(this,Fo)}getDefaultValue(t){const e=t.map(i=>_t(this,Fo,Fl).call(this,qn.from(i)));return new Z0(e,"_").defaultValue()}encode(t,e){yR(e.length,t.length,"types/values length mismatch");const r=t.map(o=>_t(this,Fo,Fl).call(this,qn.from(o))),i=new Z0(r,"_"),s=new Cm;return i.encode(s,e),s.data}decode(t,e,r){const i=t.map(o=>_t(this,Fo,Fl).call(this,qn.from(o)));return new Z0(i,"_").decode(new Bm(e,r,LI))}static _setDefaultMaxInflation(t){K(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),LI=t}static defaultAbiCoder(){return yw==null&&(yw=new vp),yw}static getBuiltinCallException(t,e,r){return Uz(t,e,r,vp.defaultAbiCoder())}};Fo=new WeakSet,Fl=function(t){if(t.isArray())return new cH(_t(this,Fo,Fl).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new Z0(t.components.map(r=>_t(this,Fo,Fl).call(this,r)),t.name);switch(t.baseType){case"address":return new oH(t.name);case"bool":return new uH(t.name);case"string":return new wH(t.name);case"bytes":return new lH(t.name);case"":return new dH(t.name)}let e=t.type.match(Lz);if(e){let r=parseInt(e[2]||"256");return K(r!==0&&r<=256&&r%8===0,"invalid "+e[1]+" bit length","param",t),new mH(r/8,e[1]==="int",t.name)}if(e=t.type.match(Mz),e){let r=parseInt(e[1]);return K(r!==0&&r<=32,"invalid bytes length","param",t),new fH(r,t.name)}K(!1,"invalid type","type",t.type)};let uh=vp;class Dz{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"signature");Z(this,"topic");Z(this,"args");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,signature:s,topic:e,args:r})}}class Fz{constructor(t,e,r,i){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");Z(this,"value");const s=t.name,o=t.format();$t(this,{fragment:t,name:s,args:r,signature:o,selector:e,value:i})}}class $z{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,args:r,signature:s,selector:e})}}class UI{constructor(t){Z(this,"hash");Z(this,"_isIndexed");$t(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const DI={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"},FI={"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 t="unknown panic code";return n>=0&&n<=255&&DI[n.toString()]&&(t=DI[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${t})`}}},fc=class fc{constructor(t){nt(this,ss);Z(this,"fragments");Z(this,"deploy");Z(this,"fallback");Z(this,"receive");nt(this,ns);nt(this,rs);nt(this,is);nt(this,sr);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,$(this,is,new Map),$(this,ns,new Map),$(this,rs,new Map);const r=[];for(const o of e)try{r.push(Wa.from(o))}catch(c){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,c.message)}$t(this,{fragments:Object.freeze(r)});let i=null,s=!1;$(this,sr,this.getAbiCoder()),this.fragments.forEach((o,c)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}$t(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(K(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${c}]`,o),i=o,s=i.payable);return;case"function":u=T(this,is);break;case"event":u=T(this,rs);break;case"error":u=T(this,ns);break;default:return}const f=o.format();u.has(f)||u.set(f,o)}),this.deploy||$t(this,{deploy:Us.from("constructor()")}),$t(this,{fallback:i,receive:s})}format(t){const e=t?"minimal":"full";return this.fragments.map(i=>i.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return uh.defaultAbiCoder()}getFunctionName(t){const e=_t(this,ss,Kp).call(this,t,null,!1);return K(e,"no matching function","key",t),e.name}hasFunction(t){return!!_t(this,ss,Kp).call(this,t,null,!1)}getFunction(t,e){return _t(this,ss,Kp).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(T(this,is).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,is).get(i),r)}}getEventName(t){const e=_t(this,ss,jp).call(this,t,null,!1);return K(e,"no matching event","key",t),e.name}hasEvent(t){return!!_t(this,ss,jp).call(this,t,null,!1)}getEvent(t,e){return _t(this,ss,jp).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(T(this,rs).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,rs).get(i),r)}}getError(t,e){if(ze(t)){const i=t.toLowerCase();if(FI[i])return Or.from(FI[i].signature);for(const s of T(this,ns).values())if(i===s.selector)return s;return null}if(t.indexOf("(")===-1){const i=[];for(const[s,o]of T(this,ns))s.split("(")[0]===t&&i.push(o);if(i.length===0)return t==="Error"?Or.from("error Error(string)"):t==="Panic"?Or.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");K(!1,`ambiguous error description (i.e. ${s})`,"name",t)}return i[0]}if(t=Or.from(t).format(),t==="Error(string)")return Or.from("error Error(string)");if(t==="Panic(uint256)")return Or.from("error Panic(uint256)");const r=T(this,ns).get(t);return r||null}forEachError(t){const e=Array.from(T(this,ns).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,ns).get(i),r)}}_decodeParams(t,e){return T(this,sr).decode(t,e)}_encodeParams(t,e){return T(this,sr).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return K(un(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,un(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return vn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return K(un(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,un(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return vn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const s=this.getFunction(t);K(s,"unknown function","fragment",t),t=s}let r="invalid length for result data";const i=gr(e);if(i.length%32===0)try{return T(this,sr).decode(t.outputs,i)}catch{r="could not decode result data"}ht(!1,r,"BAD_DATA",{value:Tt(i),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=we(t,"data"),i=uh.getBuiltinCallException("call",e,r);if(i.message.startsWith("execution reverted (unknown custom error)")){const c=Tt(r.slice(0,4)),u=this.getError(c);if(u)try{const f=T(this,sr).decode(u.inputs,r.slice(4));i.revert={name:u.name,signature:u.format(),args:f},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return Tt(T(this,sr).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const s=this.getEvent(t);K(s,"unknown event","eventFragment",t),t=s}ht(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const i=(s,o)=>s.type==="string"?za(o):s.type==="bytes"?On(Tt(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=So(o):s.type.match(/^bytes/)?o=A7(o,32):s.type==="address"&&T(this,sr).encode(["address"],[o]),La(Tt(o),32));for(e.forEach((s,o)=>{const c=t.inputs[o];if(!c.indexed){K(s==null,"cannot filter non-indexed parameters; must be null","contract."+c.name,s);return}s==null?r.push(null):c.baseType==="array"||c.baseType==="tuple"?K(!1,"filtering with tuples or arrays not supported","contract."+c.name,s):Array.isArray(s)?r.push(s.map(u=>i(c,u))):r.push(i(c,s))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);K(o,"unknown event","eventFragment",t),t=o}const r=[],i=[],s=[];return t.anonymous||r.push(t.topicHash),K(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,c)=>{const u=e[c];if(o.indexed)if(o.type==="string")r.push(za(u));else if(o.type==="bytes")r.push(On(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,sr).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:T(this,sr).encode(i,s),topics:r}}decodeEventLog(t,e,r){if(typeof t=="string"){const b=this.getEvent(t);K(b,"unknown event","eventFragment",t),t=b}if(r!=null&&!t.anonymous){const b=t.topicHash;K(ze(r[0],32)&&r[0].toLowerCase()===b,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const i=[],s=[],o=[];t.inputs.forEach((b,R)=>{b.indexed?b.type==="string"||b.type==="bytes"||b.baseType==="tuple"||b.baseType==="array"?(i.push(qn.from({type:"bytes32",name:b.name})),o.push(!0)):(i.push(b),o.push(!1)):(s.push(b),o.push(!1))});const c=r!=null?T(this,sr).decode(i,vn(r)):null,u=T(this,sr).decode(s,e,!0),f=[],h=[];let y=0,A=0;return t.inputs.forEach((b,R)=>{let k=null;if(b.indexed)if(c==null)k=new UI(null);else if(o[R])k=new UI(c[A++]);else try{k=c[A++]}catch(S){k=S}else try{k=u[y++]}catch(S){k=S}f.push(k),h.push(b.name||null)}),Su.fromItems(f,h)}parseTransaction(t){const e=we(t.data,"tx.data"),r=Ct(t.value!=null?t.value:0,"tx.value"),i=this.getFunction(Tt(e.slice(0,4)));if(!i)return null;const s=T(this,sr).decode(i.inputs,e.slice(4));return new Fz(i,i.selector,s,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Dz(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Tt(t),r=this.getError(un(e,0,4));if(!r)return null;const i=T(this,sr).decode(r.inputs,un(e,4));return new $z(r,r.selector,i)}static from(t){return t instanceof fc?t:typeof t=="string"?new fc(JSON.parse(t)):typeof t.formatJson=="function"?new fc(t.formatJson()):typeof t.format=="function"?new fc(t.format("json")):new fc(t)}};ns=new WeakMap,rs=new WeakMap,is=new WeakMap,sr=new WeakMap,ss=new WeakSet,Kp=function(t,e,r){if(ze(t)){const s=t.toLowerCase();for(const o of T(this,is).values())if(s===o.selector)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,c]of T(this,is))o.split("(")[0]===t&&s.push(c);if(e){const o=e.length>0?e[e.length-1]:null;let c=e.length,u=!0;ir.isTyped(o)&&o.type==="overrides"&&(u=!1,c--);for(let f=s.length-1;f>=0;f--){const h=s[f].inputs.length;h!==c&&(!u||h!==c-1)&&s.splice(f,1)}for(let f=s.length-1;f>=0;f--){const h=s[f].inputs;for(let y=0;y<e.length;y++)if(ir.isTyped(e[y])){if(y>=h.length){if(e[y].type==="overrides")continue;s.splice(f,1);break}if(e[y].type!==h[y].baseType){s.splice(f,1);break}}}}if(s.length===1&&e&&e.length!==s[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(c=>JSON.stringify(c.format())).join(", ");K(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return s[0]}const i=T(this,is).get(Ji.from(t).format());return i||null},jp=function(t,e,r){if(ze(t)){const s=t.toLowerCase();for(const o of T(this,rs).values())if(s===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,c]of T(this,rs))o.split("(")[0]===t&&s.push(c);if(e){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<e.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const c=s[o].inputs;for(let u=0;u<e.length;u++)if(ir.isTyped(e[u])&&e[u].type!==c[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(c=>JSON.stringify(c.format())).join(", ");K(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return s[0]}const i=T(this,rs).get(Yi.from(t).format());return i||null};let mw=fc;const $I=BigInt(0);function Uu(n){return n??null}function Sn(n){return n==null?null:n.toString()}class HI{constructor(t,e,r){Z(this,"gasPrice");Z(this,"maxFeePerGas");Z(this,"maxPriorityFeePerGas");$t(this,{gasPrice:Uu(t),maxFeePerGas:Uu(e),maxPriorityFeePerGas:Uu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Sn(t),maxFeePerGas:Sn(e),maxPriorityFeePerGas:Sn(r)}}}function cp(n){const t={};n.to&&(t.to=n.to),n.from&&(t.from=n.from),n.data&&(t.data=Tt(n.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of e)!(i in n)||n[i]==null||(t[i]=Ct(n[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)!(i in n)||n[i]==null||(t[i]=ie(n[i],`request.${i}`));return n.accessList&&(t.accessList=Ka(n.accessList)),"blockTag"in n&&(t.blockTag=n.blockTag),"enableCcipRead"in n&&(t.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(t.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(t.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(t.kzg=n.kzg),"blobs"in n&&n.blobs&&(t.blobs=n.blobs.map(i=>Im(i)?Tt(i):Object.assign({},i))),t}class Hz{constructor(t,e){Z(this,"provider");Z(this,"number");Z(this,"hash");Z(this,"timestamp");Z(this,"parentHash");Z(this,"parentBeaconBlockRoot");Z(this,"nonce");Z(this,"difficulty");Z(this,"gasLimit");Z(this,"gasUsed");Z(this,"stateRoot");Z(this,"receiptsRoot");Z(this,"blobGasUsed");Z(this,"excessBlobGas");Z(this,"miner");Z(this,"prevRandao");Z(this,"extraData");Z(this,"baseFeePerGas");nt(this,Ws);$(this,Ws,t.transactions.map(r=>typeof r!="string"?new fh(r,e):r)),$t(this,{provider:e,hash:Uu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:Uu(t.prevRandao),extraData:t.extraData,baseFeePerGas:Uu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return T(this,Ws).map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=T(this,Ws).slice();return t.length===0?[]:(ht(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:i,gasUsed:s,hash:o,miner:c,prevRandao:u,nonce:f,number:h,parentHash:y,parentBeaconBlockRoot:A,stateRoot:b,receiptsRoot:R,timestamp:k,transactions:S}=this;return{_type:"Block",baseFeePerGas:Sn(t),difficulty:Sn(e),extraData:r,gasLimit:Sn(i),gasUsed:Sn(s),blobGasUsed:Sn(this.blobGasUsed),excessBlobGas:Sn(this.excessBlobGas),hash:o,miner:c,prevRandao:u,nonce:f,number:h,parentHash:y,timestamp:k,parentBeaconBlockRoot:A,stateRoot:b,receiptsRoot:R,transactions:S}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Ws).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=T(this,Ws)[t];else{const r=t.toLowerCase();for(const i of T(this,Ws))if(typeof i=="string"){if(i!==r)continue;e=i;break}else{if(i.hash!==r)continue;e=i;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;K(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return zz(this)}}Ws=new WeakMap;class lh{constructor(t,e){Z(this,"provider");Z(this,"transactionHash");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"removed");Z(this,"address");Z(this,"data");Z(this,"topics");Z(this,"index");Z(this,"transactionIndex");this.provider=e;const r=Object.freeze(t.topics.slice());$t(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:c,transactionHash:u,transactionIndex:f}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:c,transactionHash:u,transactionIndex:f}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return ht(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return Gz(this)}}class zI{constructor(t,e){Z(this,"provider");Z(this,"to");Z(this,"from");Z(this,"contractAddress");Z(this,"hash");Z(this,"index");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"logsBloom");Z(this,"gasUsed");Z(this,"blobGasUsed");Z(this,"cumulativeGasUsed");Z(this,"gasPrice");Z(this,"blobGasPrice");Z(this,"type");Z(this,"status");Z(this,"root");nt(this,_h);$(this,_h,Object.freeze(t.logs.map(i=>new lh(i,e))));let r=$I;t.effectiveGasPrice!=null?r=t.effectiveGasPrice:t.gasPrice!=null&&(r=t.gasPrice),$t(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return T(this,_h)}toJSON(){const{to:t,from:e,contractAddress:r,hash:i,index:s,blockHash:o,blockNumber:c,logsBloom:u,logs:f,status:h,root:y}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:c,contractAddress:r,cumulativeGasUsed:Sn(this.cumulativeGasUsed),from:e,gasPrice:Sn(this.gasPrice),blobGasUsed:Sn(this.blobGasUsed),blobGasPrice:Sn(this.blobGasPrice),gasUsed:Sn(this.gasUsed),hash:i,index:s,logs:f,logsBloom:u,root:y,status:h,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return VI(this)}reorderedEvent(t){return ht(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),GI(this,t)}}_h=new WeakMap;const $w=class $w{constructor(t,e){Z(this,"provider");Z(this,"blockNumber");Z(this,"blockHash");Z(this,"index");Z(this,"hash");Z(this,"type");Z(this,"to");Z(this,"from");Z(this,"nonce");Z(this,"gasLimit");Z(this,"gasPrice");Z(this,"maxPriorityFeePerGas");Z(this,"maxFeePerGas");Z(this,"maxFeePerBlobGas");Z(this,"data");Z(this,"value");Z(this,"chainId");Z(this,"signature");Z(this,"accessList");Z(this,"blobVersionedHashes");nt(this,$o);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,$(this,$o,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:i,type:s,to:o,from:c,nonce:u,data:f,signature:h,accessList:y,blobVersionedHashes:A}=this;return{_type:"TransactionResponse",accessList:y,blockNumber:t,blockHash:e,blobVersionedHashes:A,chainId:Sn(this.chainId),data:f,from:c,gasLimit:Sn(this.gasLimit),gasPrice:Sn(this.gasPrice),hash:i,maxFeePerGas:Sn(this.maxFeePerGas),maxPriorityFeePerGas:Sn(this.maxPriorityFeePerGas),maxFeePerBlobGas:Sn(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:r,type:s,value:Sn(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const r=await this.getTransaction();r&&(t=r.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:r}=await pr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:r-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=t??1,i=e??0;let s=T(this,$o),o=-1,c=s===-1;const u=async()=>{if(c)return null;const{blockNumber:A,nonce:b}=await pr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(b<this.nonce){s=A;return}if(c)return null;const R=await this.getTransaction();if(!(R&&R.blockNumber!=null))for(o===-1&&(o=s-3,o<T(this,$o)&&(o=T(this,$o)));o<=A;){if(c)return null;const k=await this.provider.getBlock(o,!0);if(k==null)return;for(const S of k)if(S===this.hash)return;for(let S=0;S<k.length;S++){const B=await k.getTransaction(S);if(B.from===this.from&&B.nonce===this.nonce){if(c)return null;const H=await this.provider.getTransactionReceipt(B.hash);if(H==null||A-H.blockNumber+1<r)return;let U="replaced";B.data===this.data&&B.to===this.to&&B.value===this.value?U="repriced":B.data==="0x"&&B.from===B.to&&B.value===$I&&(U="cancelled"),ht(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:U==="replaced"||U==="cancelled",reason:U,replacement:B.replaceableTransaction(s),hash:B.hash,receipt:H})}}o++}},f=A=>{if(A==null||A.status!==0)return A;ht(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:A.to,from:A.from,data:""},receipt:A})},h=await this.provider.getTransactionReceipt(this.hash);if(r===0)return f(h);if(h){if(await h.confirmations()>=r)return f(h)}else if(await u(),r===0)return null;return await new Promise((A,b)=>{const R=[],k=()=>{R.forEach(B=>B())};if(R.push(()=>{c=!0}),i>0){const B=setTimeout(()=>{k(),b(Qe("wait for transaction timeout","TIMEOUT"))},i);R.push(()=>{clearTimeout(B)})}const S=async B=>{if(await B.confirmations()>=r){k();try{A(f(B))}catch(H){b(H)}}};if(R.push(()=>{this.provider.off(this.hash,S)}),this.provider.on(this.hash,S),s>=0){const B=async()=>{try{await u()}catch(H){if(Zn(H,"TRANSACTION_REPLACED")){k(),b(H);return}}c||this.provider.once("block",B)};R.push(()=>{this.provider.off("block",B)}),this.provider.once("block",B)}})}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 ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),VI(this)}reorderedEvent(t){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ht(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),GI(this,t)}replaceableTransaction(t){K(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new $w(this,this.provider);return $(e,$o,t),e}};$o=new WeakMap;let fh=$w;function zz(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function GI(n,t){return{orphan:"reorder-transaction",tx:n,other:t}}function VI(n){return{orphan:"drop-transaction",tx:n}}function Gz(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 ww extends lh{constructor(e,r,i){super(e,e.provider);Z(this,"interface");Z(this,"fragment");Z(this,"args");const s=r.decodeEventLog(i,e.data,e.topics);$t(this,{args:s,fragment:i,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class KI extends lh{constructor(e,r){super(e,e.provider);Z(this,"error");$t(this,{error:r})}}class Vz extends zI{constructor(e,r,i){super(i,r);nt(this,pl);$(this,pl,e)}get logs(){return super.logs.map(e=>{const r=e.topics.length?T(this,pl).getEvent(e.topics[0]):null;if(r)try{return new ww(e,T(this,pl),r)}catch(i){return new KI(e,i)}return e})}}pl=new WeakMap;class bw extends fh{constructor(e,r,i){super(i,r);nt(this,Ah);$(this,Ah,e)}async wait(e,r){const i=await super.wait(e,r);return i==null?null:new Vz(T(this,Ah),this.provider,i)}}Ah=new WeakMap;class jI extends xR{constructor(e,r,i,s){super(e,r,i);Z(this,"log");$t(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Kz extends jI{constructor(t,e,r,i,s){super(t,e,r,new ww(s,t.interface,i));const o=t.interface.decodeEventLog(i,this.log.data,this.log.topics);$t(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const WI=BigInt(0);function ZI(n){return n&&typeof n.call=="function"}function qI(n){return n&&typeof n.estimateGas=="function"}function up(n){return n&&typeof n.resolveName=="function"}function QI(n){return n&&typeof n.sendTransaction=="function"}function YI(n){if(n!=null){if(up(n))return n;if(n.provider)return n.provider}}class jz{constructor(t,e,r){nt(this,Eh);Z(this,"fragment");if($t(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const i=qa(t.runner,"resolveName"),s=up(i)?i:null;$(this,Eh,async function(){const o=await Promise.all(e.inputs.map((c,u)=>r[u]==null?null:c.walkAsync(r[u],(h,y)=>h==="address"?Array.isArray(y)?Promise.all(y.map(A=>wr(A,s))):wr(y,s):y)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return T(this,Eh)}}Eh=new WeakMap;function qa(n,t){return n==null?null:typeof n[t]=="function"?n:n.provider&&typeof n.provider[t]=="function"?n.provider:null}function Qa(n){return n==null?null:n.provider||null}async function JI(n,t){const e=ir.dereference(n,"overrides");K(typeof e=="object","invalid overrides parameter","overrides",n);const r=cp(e);return K(r.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),K(r.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function Wz(n,t,e){const r=qa(n,"resolveName"),i=up(r)?r:null;return await Promise.all(t.map((s,o)=>s.walkAsync(e[o],(c,u)=>(u=ir.dereference(u,c),c==="address"?wr(u,i):u))))}function Zz(n){const t=async function(o){const c=await JI(o,["data"]);c.to=await n.getAddress(),c.from&&(c.from=await wr(c.from,YI(n.runner)));const u=n.interface,f=Ct(c.value||WI,"overrides.value")===WI,h=(c.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!f&&K(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",c.data);const y=u.receive||u.fallback&&u.fallback.payable;return K(y||f,"cannot send value to non-payable fallback","overrides.value",c.value),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",c.data),c},e=async function(o){const c=qa(n.runner,"call");ht(ZI(c),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(o);try{return await c.call(u)}catch(f){throw Sm(f)&&f.data?n.interface.makeError(f.data,u):f}},r=async function(o){const c=n.runner;ht(QI(c),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await c.sendTransaction(await t(o)),f=Qa(n.runner);return new bw(n.interface,f,u)},i=async function(o){const c=qa(n.runner,"estimateGas");return ht(qI(c),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await c.estimateGas(await t(o))},s=async o=>await r(o);return $t(s,{_contract:n,estimateGas:i,populateTransaction:t,send:r,staticCall:e}),s}function qz(n,t){const e=function(...f){const h=n.interface.getFunction(t,f);return ht(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:f}}),h},r=async function(...f){const h=e(...f);let y={};if(h.inputs.length+1===f.length&&(y=await JI(f.pop()),y.from&&(y.from=await wr(y.from,YI(n.runner)))),h.inputs.length!==f.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const A=await Wz(n.runner,h.inputs,f);return Object.assign({},y,await pr({to:n.getAddress(),data:n.interface.encodeFunctionData(h,A)}))},i=async function(...f){const h=await c(...f);return h.length===1?h[0]:h},s=async function(...f){const h=n.runner;ht(QI(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const y=await h.sendTransaction(await r(...f)),A=Qa(n.runner);return new bw(n.interface,A,y)},o=async function(...f){const h=qa(n.runner,"estimateGas");return ht(qI(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await r(...f))},c=async function(...f){const h=qa(n.runner,"call");ht(ZI(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const y=await r(...f);let A="0x";try{A=await h.call(y)}catch(R){throw Sm(R)&&R.data?n.interface.makeError(R.data,y):R}const b=e(...f);return n.interface.decodeFunctionResult(b,A)},u=async(...f)=>e(...f).constant?await i(...f):await s(...f);return $t(u,{name:n.interface.getFunctionName(t),_contract:n,_key:t,getFragment:e,estimateGas:o,populateTransaction:r,send:s,staticCall:i,staticCallResult:c}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const f=n.interface.getFunction(t);return ht(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),f}}),u}function Qz(n,t){const e=function(...i){const s=n.interface.getEvent(t,i);return ht(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:i}}),s},r=function(...i){return new jz(n,e(...i),i)};return $t(r,{name:n.interface.getEventName(t),_contract:n,_key:t,getFragment:e}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=n.interface.getEvent(t);return ht(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),i}}),r}const lp=Symbol.for("_ethersInternal_contract"),XI=new WeakMap;function Yz(n,t){XI.set(n[lp],t)}function Gr(n){return XI.get(n[lp])}function Jz(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function _w(n,t){let e,r=null;if(Array.isArray(t)){const s=function(o){if(ze(o,32))return o;const c=n.interface.getEvent(o);return K(c,"unknown fragment","name",o),c.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else t==="*"?e=[null]:typeof t=="string"?ze(t,32)?e=[t]:(r=n.interface.getEvent(t),K(r,"unknown fragment","event",t),e=[r.topicHash]):Jz(t)?e=await t.getTopicFilter():"fragment"in t?(r=t.fragment,e=[r.topicHash]):K(!1,"unknown event name","event",t);e=e.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(c=>c.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=e.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:r,tag:i,topics:e}}async function hh(n,t){const{subs:e}=Gr(n);return e.get((await _w(n,t)).tag)||null}async function tk(n,t,e){const r=Qa(n.runner);ht(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:i,tag:s,topics:o}=await _w(n,e),{addr:c,subs:u}=Gr(n);let f=u.get(s);if(!f){const y={address:c||n,topics:o},A=S=>{let B=i;if(B==null)try{B=n.interface.getEvent(S.topics[0])}catch{}if(B){const H=B,U=i?n.interface.decodeEventLog(i,S.data,S.topics):[];Ew(n,e,U,G=>new Kz(n,G,e,H,S))}else Ew(n,e,[],H=>new jI(n,H,e,S))};let b=[];f={tag:s,listeners:[],start:()=>{b.length||b.push(r.on(y,A))},stop:async()=>{if(b.length==0)return;let S=b;b=[],await Promise.all(S),r.off(y,A)}},u.set(s,f)}return f}let Aw=Promise.resolve();async function Xz(n,t,e,r){await Aw;const i=await hh(n,t);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:c})=>{const u=Array.from(e);r&&u.push(r(c?null:o));try{o.call(n,...u)}catch{}return!c}),i.listeners.length===0&&(i.stop(),Gr(n).subs.delete(i.tag)),s>0}async function Ew(n,t,e,r){try{await Aw}catch{}const i=Xz(n,t,e,r);return Aw=i,await i}const fp=["then"];bk=lp;const vh=class vh{constructor(t,e,r,i){Z(this,"target");Z(this,"interface");Z(this,"runner");Z(this,"filters");Z(this,bk);Z(this,"fallback");K(typeof t=="string"||PS(t),"invalid value for Contract target","target",t),r==null&&(r=null);const s=mw.from(e);$t(this,{target:t,runner:r,interface:s}),Object.defineProperty(this,lp,{value:{}});let o,c=null,u=null;if(i){const y=Qa(r);u=new bw(this.interface,y,i)}let f=new Map;if(typeof t=="string")if(ze(t))c=t,o=Promise.resolve(t);else{const y=qa(r,"resolveName");if(!up(y))throw Qe("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=y.resolveName(t).then(A=>{if(A==null)throw Qe("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Gr(this).addr=A,A})}else o=t.getAddress().then(y=>{if(y==null)throw new Error("TODO");return Gr(this).addr=y,y});Yz(this,{addrPromise:o,addr:c,deployTx:u,subs:f});const h=new Proxy({},{get:(y,A,b)=>{if(typeof A=="symbol"||fp.indexOf(A)>=0)return Reflect.get(y,A,b);try{return this.getEvent(A)}catch(R){if(!Zn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,A)=>fp.indexOf(A)>=0?Reflect.has(y,A):Reflect.has(y,A)||this.interface.hasEvent(String(A))});return $t(this,{filters:h}),$t(this,{fallback:s.receive||s.fallback?Zz(this):null}),new Proxy(this,{get:(y,A,b)=>{if(typeof A=="symbol"||A in y||fp.indexOf(A)>=0)return Reflect.get(y,A,b);try{return y.getFunction(A)}catch(R){if(!Zn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,A)=>typeof A=="symbol"||A in y||fp.indexOf(A)>=0?Reflect.has(y,A):y.interface.hasFunction(A)})}connect(t){return new vh(this.target,this.interface,t)}attach(t){return new vh(t,this.interface,this.runner)}async getAddress(){return await Gr(this).addrPromise}async getDeployedCode(){const t=Qa(this.runner);ht(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Qa(this.runner);return ht(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);r.once("block",o)}catch(c){s(c)}};o()})}deploymentTransaction(){return Gr(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),qz(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),Qz(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){e==null&&(e=0),r==null&&(r="latest");const{addr:i,addrPromise:s}=Gr(this),o=i||await s,{fragment:c,topics:u}=await _w(this,t),f={address:o,topics:u,fromBlock:e,toBlock:r},h=Qa(this.runner);return ht(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(f)).map(y=>{let A=c;if(A==null)try{A=this.interface.getEvent(y.topics[0])}catch{}if(A)try{return new ww(y,this.interface,A)}catch(b){return new KI(y,b)}return new lh(y,h)})}async on(t,e){const r=await tk(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await tk(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await Ew(this,t,e,null)}async listenerCount(t){if(t){const i=await hh(this,t);return i?i.listeners.length:0}const{subs:e}=Gr(this);let r=0;for(const{listeners:i}of e.values())r+=i.length;return r}async listeners(t){if(t){const i=await hh(this,t);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:e}=Gr(this);let r=[];for(const{listeners:i}of e.values())r=r.concat(i.map(({listener:s})=>s));return r}async off(t,e){const r=await hh(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(e==null||r.listeners.length===0)&&(r.stop(),Gr(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await hh(this,t);if(!e)return this;e.stop(),Gr(this).subs.delete(e.tag)}else{const{subs:e}=Gr(this);for(const{tag:r,stop:i}of e.values())i(),e.delete(r)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends vh{constructor(i,s=null){super(i,t,s)}}return e}static from(t,e,r){return r==null&&(r=null),new this(t,e,r)}};let vw=vh;function tG(){return vw}class Du extends tG(){}function xw(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):K(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class eG{constructor(t){Z(this,"name");$t(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const ek=new RegExp("^(ipfs)://(.*)$","i"),nk=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),ek,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],gl=class gl{constructor(t,e,r){nt(this,zo);Z(this,"provider");Z(this,"address");Z(this,"name");nt(this,Ho);nt(this,hc);$t(this,{provider:t,address:e,name:r}),$(this,Ho,null),$(this,hc,new Du(e,["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)"],t))}async supportsWildcard(){return T(this,Ho)==null&&$(this,Ho,(async()=>{try{return await T(this,hc).supportsInterface("0x9061b923")}catch(t){if(Zn(t,"CALL_EXCEPTION"))return!1;throw $(this,Ho,null),t}})()),await T(this,Ho)}async getAddress(t){if(t==null&&(t=60),t===60)try{const s=await _t(this,zo,$l).call(this,"addr(bytes32)");return s==null||s===Xf?null:s}catch(s){if(Zn(s,"CALL_EXCEPTION"))return null;throw s}if(t>=0&&t<2147483648){let s=t+2147483648;const o=await _t(this,zo,$l).call(this,"addr(bytes32,uint)",[s]);if(ze(o,20))return Me(o)}let e=null;for(const s of this.provider.plugins)if(s instanceof eG&&s.supportsCoinType(t)){e=s;break}if(e==null)return null;const r=await _t(this,zo,$l).call(this,"addr(bytes32,uint)",[t]);if(r==null||r==="0x")return null;const i=await e.decodeAddress(t,r);if(i!=null)return i;ht(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await _t(this,zo,$l).call(this,"text(bytes32,string)",[t]);return e==null||e==="0x"?null:e}async getContentHash(){const t=await _t(this,zo,$l).call(this,"contenthash(bytes32)");if(t==null||t==="0x")return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const i=e[1]==="e3010170"?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===s*2)return`${i}://${x7("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ht(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(e==null)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<nk.length;r++){const i=e.match(nk[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const o=xw(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:o}),{linkage:t,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";t.push({type:s,value:e});const c=await this.getAddress();if(c==null)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const u=(i[2]||"").split("/");if(u.length!==2)return t.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:t};const f=u[1],h=new Du(u[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(s==="erc721"){const k=await h.ownerOf(f);if(c!==k)return t.push({type:"!owner",value:k}),{url:null,linkage:t};t.push({type:"owner",value:k})}else if(s==="erc1155"){const k=await h.balanceOf(c,f);if(!k)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:k.toString()})}let y=await h[o](f);if(y==null||y==="0x")return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:y}),s==="erc1155"&&(y=y.replace("{id}",So(f,32).substring(2)),t.push({type:"metadata-url-expanded",value:y})),y.match(/^ipfs:/i)&&(y=xw(y)),t.push({type:"metadata-url",value:y});let A={};const b=await new Ns(y).send();b.assertOk();try{A=b.bodyJson}catch{try{t.push({type:"!metadata",value:b.bodyText})}catch{const B=b.body;return B&&t.push({type:"!metadata",value:Tt(B)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!A)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(A)});let R=A.image;if(typeof R!="string")return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(!R.match(/^(https:\/\/|data:)/i)){if(R.match(ek)==null)return t.push({type:"!imageUrl-ipfs",value:R}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:R}),R=xw(R)}return t.push({type:"url",value:R}),{linkage:t,url:R}}}}}catch{}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return ht(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async fromName(t,e){var i;let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const s=await _t(i=gl,xp,CT).call(i,t,r);if(s!=null){const o=new gl(t,s,e);return r!==e&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Ho=new WeakMap,hc=new WeakMap,zo=new WeakSet,$l=async function(t,e){e=(e||[]).slice();const r=T(this,hc).interface;e.unshift(cw(this.name));let i=null;await this.supportsWildcard()&&(i=r.getFunction(t),ht(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[nz(this.name,255),r.encodeFunctionData(i,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const s=await T(this,hc)[t](...e);return i?r.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Zn(s,"CALL_EXCEPTION"))throw s}return null},xp=new WeakSet,CT=async function(t,e){const r=await gl.getEnsAddress(t);try{const s=await new Du(r,["function resolver(bytes32) view returns (address)"],t).resolver(cw(e),{enableCcipRead:!0});return s===Xf?null:s}catch(i){throw i}return null},nt(gl,xp);let hp=gl;const rk=BigInt(0);function ye(n,t){return function(e){return e==null?t:n(e)}}function dp(n,t){return e=>{if(t&&e==null)return null;if(!Array.isArray(e))throw new Error("not an array");return e.map(r=>n(r))}}function dh(n,t){return e=>{const r={};for(const i in n){let s=i;if(t&&i in t&&!(s in e)){for(const o of t[i])if(o in e){s=o;break}}try{const o=n[i](e[s]);o!==void 0&&(r[i]=o)}catch(o){const c=o instanceof Error?o.message:"not-an-error";ht(!1,`invalid value for value.${i} (${c})`,"BAD_DATA",{value:e})}}return r}}function nG(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}K(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Fu(n){return K(ze(n,!0),"invalid data","value",n),n}function Qn(n){return K(ze(n,32),"invalid hash","value",n),n}const rG=dh({address:Me,blockHash:Qn,blockNumber:ie,data:Fu,index:ie,removed:ye(nG,!1),topics:dp(Qn),transactionHash:Qn,transactionIndex:ie},{index:["logIndex"]});function iG(n){return rG(n)}const sG=dh({hash:ye(Qn),parentHash:Qn,parentBeaconBlockRoot:ye(Qn,null),number:ie,timestamp:ie,nonce:ye(Fu),difficulty:Ct,gasLimit:Ct,gasUsed:Ct,stateRoot:ye(Qn,null),receiptsRoot:ye(Qn,null),blobGasUsed:ye(Ct,null),excessBlobGas:ye(Ct,null),miner:ye(Me),prevRandao:ye(Qn,null),extraData:Fu,baseFeePerGas:ye(Ct)},{prevRandao:["mixHash"]});function oG(n){const t=sG(n);return t.transactions=n.transactions.map(e=>typeof e=="string"?e:ik(e)),t}const aG=dh({transactionIndex:ie,blockNumber:ie,transactionHash:Qn,address:Me,topics:dp(Qn),data:Fu,index:ie,blockHash:Qn},{index:["logIndex"]});function cG(n){return aG(n)}const uG=dh({to:ye(Me,null),from:ye(Me,null),contractAddress:ye(Me,null),index:ie,root:ye(Tt),gasUsed:Ct,blobGasUsed:ye(Ct,null),logsBloom:ye(Fu),blockHash:Qn,hash:Qn,logs:dp(cG),blockNumber:ie,cumulativeGasUsed:Ct,effectiveGasPrice:ye(Ct),blobGasPrice:ye(Ct,null),status:ye(ie),type:ye(ie,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function lG(n){return uG(n)}function ik(n){n.to&&Ct(n.to)===rk&&(n.to="0x0000000000000000000000000000000000000000");const t=dh({hash:Qn,index:ye(ie,void 0),type:e=>e==="0x"||e==null?0:ie(e),accessList:ye(Ka,null),blobVersionedHashes:ye(dp(Qn,!0),null),blockHash:ye(Qn,null),blockNumber:ye(ie,null),transactionIndex:ye(ie,null),from:Me,gasPrice:ye(Ct),maxPriorityFeePerGas:ye(Ct),maxFeePerGas:ye(Ct),maxFeePerBlobGas:ye(Ct,null),gasLimit:Ct,to:ye(Me,null),value:Ct,nonce:ie,data:Fu,creates:ye(Me,null),chainId:ye(Ct,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(t.to==null&&t.creates==null&&(t.creates=sH(t)),(n.type===1||n.type===2)&&n.accessList==null&&(t.accessList=[]),n.signature?t.signature=_i.from(n.signature):t.signature=_i.from(n),t.chainId==null){const e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&Ct(t.blockHash)===rk&&(t.blockHash=null),t}const fG="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class ph{constructor(t){Z(this,"name");$t(this,{name:t})}clone(){return new ph(this.name)}}class pp extends ph{constructor(e,r){e==null&&(e=0);super(`org.ethers.network.plugins.GasCost#${e||0}`);Z(this,"effectiveBlock");Z(this,"txBase");Z(this,"txCreate");Z(this,"txDataZero");Z(this,"txDataNonzero");Z(this,"txAccessListStorageKey");Z(this,"txAccessListAddress");const i={effectiveBlock:e};function s(o,c){let u=(r||{})[o];u==null&&(u=c),K(typeof u=="number",`invalud value for ${o}`,"costs",r),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),$t(this,i)}clone(){return new pp(this.effectiveBlock,this)}}class gp extends ph{constructor(e,r){super("org.ethers.plugins.network.Ens");Z(this,"address");Z(this,"targetNetwork");$t(this,{address:e||fG,targetNetwork:r??1})}clone(){return new gp(this.address,this.targetNetwork)}}class hG extends ph{constructor(e,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");nt(this,xh);nt(this,Rh);$(this,xh,e),$(this,Rh,r)}get url(){return T(this,xh)}get processFunc(){return T(this,Rh)}clone(){return this}}xh=new WeakMap,Rh=new WeakMap;const Rw=new Map,wl=class wl{constructor(t,e){nt(this,yl);nt(this,ml);nt(this,Go);$(this,yl,t),$(this,ml,Ct(e)),$(this,Go,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,yl)}set name(t){$(this,yl,t)}get chainId(){return T(this,ml)}set chainId(t){$(this,ml,Ct(t,"chainId"))}matches(t){if(t==null)return!1;if(typeof t=="string"){try{return this.chainId===Ct(t)}catch{}return this.name===t}if(typeof t=="number"||typeof t=="bigint"){try{return this.chainId===Ct(t)}catch{}return!1}if(typeof t=="object"){if(t.chainId!=null){try{return this.chainId===Ct(t.chainId)}catch{}return!1}return t.name!=null?this.name===t.name:!1}return!1}get plugins(){return Array.from(T(this,Go).values())}attachPlugin(t){if(T(this,Go).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return T(this,Go).set(t.name,t.clone()),this}getPlugin(t){return T(this,Go).get(t)||null}getPlugins(t){return this.plugins.filter(e=>e.name.split("#")[0]===t)}clone(){const t=new wl(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new pp;let r=e.txBase;if(t.to==null&&(r+=e.txCreate),t.data)for(let i=2;i<t.data.length;i+=2)t.data.substring(i,i+2)==="00"?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const i=Ka(t.accessList);for(const s in i)r+=e.txAccessListAddress+e.txAccessListStorageKey*i[s].storageKeys.length}return r}static from(t){if(dG(),t==null)return wl.from("mainnet");if(typeof t=="number"&&(t=BigInt(t)),typeof t=="string"||typeof t=="bigint"){const e=Rw.get(t);if(e)return e();if(typeof t=="bigint")return new wl("unknown",t);K(!1,"unknown network","network",t)}if(typeof t.clone=="function")return t.clone();if(typeof t=="object"){K(typeof t.name=="string"&&typeof t.chainId=="number","invalid network object name or chainId","network",t);const e=new wl(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&e.attachPlugin(new gp(t.ensAddress,t.ensNetwork)),e}K(!1,"invalid network","network",t)}static register(t,e){typeof t=="number"&&(t=BigInt(t));const r=Rw.get(t);r&&K(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Rw.set(t,e)}};yl=new WeakMap,ml=new WeakMap,Go=new WeakMap;let Xi=wl;function sk(n,t){const e=String(n);if(!e.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=e.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<t;)r[1]+="0";if(r[1].length>9){let i=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||i++,r[1]=i.toString()}return BigInt(r[0]+r[1])}function ok(n){return new hG(n,async(t,e,r)=>{r.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([r.send(),t()]);i=s;const c=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:sk(c.maxFee,9),maxPriorityFeePerGas:sk(c.maxPriorityFee,9)}}catch(s){ht(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:i,error:s})}})}let ak=!1;function dG(){if(ak)return;ak=!0;function n(t,e,r){const i=function(){const s=new Xi(t,e);return r.ensNetwork!=null&&s.attachPlugin(new gp(null,r.ensNetwork)),s.attachPlugin(new pp),(r.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};Xi.register(t,i),Xi.register(e,i),r.altNames&&r.altNames.forEach(s=>{Xi.register(s,i)})}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:[ok("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[ok("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 Sw(n){return JSON.parse(JSON.stringify(n))}class pG{constructor(t){nt(this,bl);nt(this,Zs);nt(this,oi);nt(this,Vo);nt(this,os);$(this,Zs,t),$(this,oi,null),$(this,Vo,4e3),$(this,os,-2)}get pollingInterval(){return T(this,Vo)}set pollingInterval(t){$(this,Vo,t)}start(){T(this,oi)||($(this,oi,T(this,Zs)._setTimeout(_t(this,bl,Wp).bind(this),T(this,Vo))),_t(this,bl,Wp).call(this))}stop(){T(this,oi)&&(T(this,Zs)._clearTimeout(T(this,oi)),$(this,oi,null))}pause(t){this.stop(),t&&$(this,os,-2)}resume(){this.start()}}Zs=new WeakMap,oi=new WeakMap,Vo=new WeakMap,os=new WeakMap,bl=new WeakSet,Wp=async function(){try{const t=await T(this,Zs).getBlockNumber();if(T(this,os)===-2){$(this,os,t);return}if(t!==T(this,os)){for(let e=T(this,os)+1;e<=t;e++){if(T(this,oi)==null)return;await T(this,Zs).emit("block",e)}$(this,os,t)}}catch{}T(this,oi)!=null&&$(this,oi,T(this,Zs)._setTimeout(_t(this,bl,Wp).bind(this),T(this,Vo)))};class Iw{constructor(t){nt(this,dc);nt(this,pc);nt(this,Ko);$(this,dc,t),$(this,Ko,!1),$(this,pc,e=>{this._poll(e,T(this,dc))})}async _poll(t,e){throw new Error("sub-classes must override this")}start(){T(this,Ko)||($(this,Ko,!0),T(this,pc).call(this,-2),T(this,dc).on("block",T(this,pc)))}stop(){T(this,Ko)&&($(this,Ko,!1),T(this,dc).off("block",T(this,pc)))}pause(t){this.stop()}resume(){this.start()}}dc=new WeakMap,pc=new WeakMap,Ko=new WeakMap;class gG extends Iw{constructor(e,r){super(e);nt(this,_l);nt(this,qs);$(this,_l,r),$(this,qs,-2)}pause(e){e&&$(this,qs,-2),super.pause(e)}async _poll(e,r){const i=await r.getBlock(T(this,_l));i!=null&&(T(this,qs)===-2?$(this,qs,i.number):i.number>T(this,qs)&&(r.emit(T(this,_l),i.number),$(this,qs,i.number)))}}_l=new WeakMap,qs=new WeakMap;class yG extends Iw{constructor(e,r){super(e);nt(this,Rp);$(this,Rp,Sw(r))}async _poll(e,r){throw new Error("@TODO")}}Rp=new WeakMap;class mG extends Iw{constructor(e,r){super(e);nt(this,Al);$(this,Al,r)}async _poll(e,r){const i=await r.getTransactionReceipt(T(this,Al));i&&r.emit(T(this,Al),i)}}Al=new WeakMap;class kw{constructor(t,e){nt(this,Sp);nt(this,Qs);nt(this,El);nt(this,vl);nt(this,jo);nt(this,ai);$(this,Qs,t),$(this,El,Sw(e)),$(this,vl,_t(this,Sp,BT).bind(this)),$(this,jo,!1),$(this,ai,-2)}start(){T(this,jo)||($(this,jo,!0),T(this,ai)===-2&&T(this,Qs).getBlockNumber().then(t=>{$(this,ai,t)}),T(this,Qs).on("block",T(this,vl)))}stop(){T(this,jo)&&($(this,jo,!1),T(this,Qs).off("block",T(this,vl)))}pause(t){this.stop(),t&&$(this,ai,-2)}resume(){this.start()}}Qs=new WeakMap,El=new WeakMap,vl=new WeakMap,jo=new WeakMap,ai=new WeakMap,Sp=new WeakSet,BT=async function(t){if(T(this,ai)===-2)return;const e=Sw(T(this,El));e.fromBlock=T(this,ai)+1,e.toBlock=t;const r=await T(this,Qs).getLogs(e);if(r.length===0){T(this,ai)<t-60&&$(this,ai,t-60);return}for(const i of r)T(this,Qs).emit(T(this,El),i),$(this,ai,i.blockNumber)};const wG=BigInt(2),bG=10;function yp(n){return n&&typeof n.then=="function"}function mp(n,t){return n+":"+JSON.stringify(t,(e,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 i=Object.keys(r);return i.sort(),i.reduce((s,o)=>(s[o]=r[o],s),{})}return r})}class wp{constructor(t){Z(this,"name");$t(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function _G(n){return JSON.parse(JSON.stringify(n))}function Tw(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function Ow(n,t){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(ze(n,32)){const e=n.toLowerCase();return{type:"transaction",tag:mp("tx",{hash:e}),hash:e}}if(n.orphan){const e=n;return{type:"orphan",tag:mp("orphan",e),filter:_G(e)}}if(n.address||n.topics){const e=n,r={topics:(e.topics||[]).map(i=>i==null?null:Array.isArray(i)?Tw(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(e.address){const i=[],s=[],o=c=>{ze(c)?i.push(c):s.push((async()=>{i.push(await wr(c,t))})())};Array.isArray(e.address)?e.address.forEach(o):o(e.address),s.length&&await Promise.all(s),r.address=Tw(i.map(c=>c.toLowerCase()))}return{filter:r,tag:mp("event",r),type:"event"}}K(!1,"unknown ProviderEvent","event",n)}function Nw(){return new Date().getTime()}const AG={cacheTimeout:250,pollingInterval:4e3};class EG{constructor(t,e){nt(this,se);nt(this,or);nt(this,Wo);nt(this,ar);nt(this,xl);nt(this,Wr);nt(this,gc);nt(this,Zo);nt(this,Ys);nt(this,Sh);nt(this,ci);nt(this,Rl);nt(this,Sl);if($(this,Sl,Object.assign({},AG,e||{})),t==="any")$(this,gc,!0),$(this,Wr,null);else if(t){const r=Xi.from(t);$(this,gc,!1),$(this,Wr,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else $(this,gc,!1),$(this,Wr,null);$(this,Ys,-1),$(this,Zo,new Map),$(this,or,new Map),$(this,Wo,new Map),$(this,ar,null),$(this,xl,!1),$(this,Sh,1),$(this,ci,new Map),$(this,Rl,!1)}get pollingInterval(){return T(this,Sl).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Wo).values())}attachPlugin(t){if(T(this,Wo).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return T(this,Wo).set(t.name,t.connect(this)),this}getPlugin(t){return T(this,Wo).get(t)||null}get disableCcipRead(){return T(this,Rl)}set disableCcipRead(t){$(this,Rl,!!t)}async ccipReadFetch(t,e,r){if(this.disableCcipRead||r.length===0||t.to==null)return null;const i=t.to.toLowerCase(),s=e.toLowerCase(),o=[];for(let c=0;c<r.length;c++){const u=r[c],f=u.replace("{sender}",i).replace("{data}",s),h=new Ns(f);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:c,urls:r});let y="unknown error",A;try{A=await h.send()}catch(b){o.push(b.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:b}});continue}try{const b=A.bodyJson;if(b.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:b}),b.data;b.message&&(y=b.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:b})}catch{}ht(A.statusCode<400||A.statusCode>=500,`response not found during CCIP fetch: ${y}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:u,errorMessage:y}}),o.push(y)}ht(!1,`error encountered during CCIP fetch: ${o.map(c=>JSON.stringify(c)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new Hz(oG(t),this)}_wrapLog(t,e){return new lh(iG(t),this)}_wrapTransactionReceipt(t,e){return new zI(lG(t),this)}_wrapTransactionResponse(t,e){return new fh(ik(t),this)}_detectNetwork(){ht(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){ht(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=ie(await _t(this,se,Zr).call(this,{method:"getBlockNumber"}),"%response");return T(this,Ys)>=0&&$(this,Ys,t),t}_getAddress(t){return wr(t,this)}_getBlockTag(t){if(t==null)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}if(ze(t))return ze(t,32)?t:Ru(t);if(typeof t=="bigint"&&(t=ie(t,"blockTag")),typeof t=="number")return t>=0?Ru(t):T(this,Ys)>=0?Ru(T(this,Ys)+t):this.getBlockNumber().then(e=>Ru(e+t));K(!1,"invalid blockTag","blockTag",t)}_getFilter(t){const e=(t.topics||[]).map(u=>u==null?null:Array.isArray(u)?Tw(u.map(f=>f.toLowerCase())):u.toLowerCase()),r="blockHash"in t?t.blockHash:void 0,i=(u,f,h)=>{let y;switch(u.length){case 0:break;case 1:y=u[0];break;default:u.sort(),y=u}if(r&&(f!=null||h!=null))throw new Error("invalid filter");const A={};return y&&(A.address=y),e.length&&(A.topics=e),f&&(A.fromBlock=f),h&&(A.toBlock=h),r&&(A.blockHash=r),A};let s=[];if(t.address)if(Array.isArray(t.address))for(const u of t.address)s.push(this._getAddress(u));else s.push(this._getAddress(t.address));let o;"fromBlock"in t&&(o=this._getBlockTag(t.fromBlock));let c;return"toBlock"in t&&(c=this._getBlockTag(t.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||c!=null&&typeof c!="string"?Promise.all([Promise.all(s),o,c]).then(u=>i(u[0],u[1],u[2])):i(s,o,c)}_getTransactionRequest(t){const e=cp(t),r=[];if(["to","from"].forEach(i=>{if(e[i]==null)return;const s=wr(e[i],this);yp(s)?r.push(async function(){e[i]=await s}()):e[i]=s}),e.blockTag!=null){const i=this._getBlockTag(e.blockTag);yp(i)?r.push(async function(){e.blockTag=await i}()):e.blockTag=i}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(T(this,Wr)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,Wr)===i&&$(this,Wr,null),s}})();return $(this,Wr,i),(await i).clone()}const t=T(this,Wr),[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(T(this,gc)?(this.emit("network",r,e),T(this,Wr)===t&&$(this,Wr,Promise.resolve(r))):ht(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await pr({_block:_t(this,se,lb).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await _t(this,se,Zr).call(this,{method:"getGasPrice"});return Ct(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await _t(this,se,Zr).call(this,{method:"getPriorityFee"});return Ct(h,"%response")}catch{}return null})()});let c=null,u=null;const f=this._wrapBlock(i,t);return f&&f.baseFeePerGas&&(u=o??BigInt("1000000000"),c=f.baseFeePerGas*wG+u),new HI(s,c,u)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const i=new Ns(r.url),s=await r.processFunc(e,this,i);return new HI(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return yp(e)&&(e=await e),Ct(await _t(this,se,Zr).call(this,{method:"estimateGas",transaction:e}),"%response")}async call(t){const{tx:e,blockTag:r}=await pr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await _t(this,se,ub).call(this,_t(this,se,cb).call(this,e,r,t.enableCcipRead?0:-1))}async getBalance(t,e){return Ct(await _t(this,se,sd).call(this,{method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return ie(await _t(this,se,sd).call(this,{method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return Tt(await _t(this,se,sd).call(this,{method:"getCode"},t,e))}async getStorage(t,e,r){const i=Ct(e,"position");return Tt(await _t(this,se,sd).call(this,{method:"getStorage",position:i},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:i}=await pr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),s=rp.from(t);if(s.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(e)}async getBlock(t,e){const{network:r,params:i}=await pr({network:this.getNetwork(),params:_t(this,se,lb).call(this,t,!!e)});return i==null?null:this._wrapBlock(i,r)}async getTransaction(t){const{network:e,params:r}=await pr({network:this.getNetwork(),params:_t(this,se,Zr).call(this,{method:"getTransaction",hash:t})});return r==null?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await pr({network:this.getNetwork(),params:_t(this,se,Zr).call(this,{method:"getTransactionReceipt",hash:t})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const i=await _t(this,se,Zr).call(this,{method:"getTransaction",hash:t});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await pr({network:this.getNetwork(),result:_t(this,se,Zr).call(this,{method:"getTransactionResult",hash:t})});return e==null?null:Tt(e)}async getLogs(t){let e=this._getFilter(t);yp(e)&&(e=await e);const{network:r,params:i}=await pr({network:this.getNetwork(),params:_t(this,se,Zr).call(this,{method:"getLogs",filter:e})});return i.map(s=>this._wrapLog(s,r))}_getProvider(t){ht(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await hp.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=Me(t);const e=cw(t.substring(2).toLowerCase()+".addr.reverse");try{const r=await hp.getEnsAddress(this),s=await new Du(r,["function resolver(bytes32) view returns (address)"],this).resolver(e);if(s==null||s===Xf)return null;const c=await new Du(s,["function name(bytes32) view returns (string)"],this).name(e);return await this.resolveName(c)!==t?null:c}catch(r){if(Zn(r,"BAD_DATA")&&r.value==="0x"||Zn(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(t,e,r){const i=e??1;return i===0?this.getTransactionReceipt(t):new Promise(async(s,o)=>{let c=null;const u=async f=>{try{const h=await this.getTransactionReceipt(t);if(h!=null&&f-h.blockNumber+1>=i){s(h),c&&(clearTimeout(c),c=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};r!=null&&(c=setTimeout(()=>{c!=null&&(c=null,this.off("block",u),o(Qe("timeout","TIMEOUT",{reason:"timeout"})))},r)),u(await this.getBlockNumber())})}async waitForBlock(t){ht(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=T(this,ci).get(t);e&&(e.timer&&clearTimeout(e.timer),T(this,ci).delete(t))}_setTimeout(t,e){e==null&&(e=0);const r=rd(this,Sh)._++,i=()=>{T(this,ci).delete(r),t()};if(this.paused)T(this,ci).set(r,{timer:null,func:i,time:e});else{const s=setTimeout(i,e);T(this,ci).set(r,{timer:s,func:i,time:Nw()})}return r}_forEachSubscriber(t){for(const e of T(this,or).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new wp(t.type);case"block":{const e=new pG(this);return e.pollingInterval=this.pollingInterval,e}case"safe":case"finalized":return new gG(this,t.type);case"event":return new kw(this,t.filter);case"transaction":return new mG(this,t.hash);case"orphan":return new yG(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of T(this,or).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),T(this,ar)!=null&&e.pause(T(this,ar));break}}async on(t,e){const r=await _t(this,se,Zp).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,ar)!=null&&r.subscriber.pause(T(this,ar))),this}async once(t,e){const r=await _t(this,se,Zp).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,ar)!=null&&r.subscriber.pause(T(this,ar))),this}async emit(t,...e){const r=await _t(this,se,od).call(this,t,e);if(!r||r.listeners.length===0)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:s,once:o})=>{const c=new xR(this,o?null:s,t);try{s.call(this,...e,c)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,or).delete(r.tag)),i>0}async listenerCount(t){if(t){const r=await _t(this,se,od).call(this,t);return r?r.listeners.length:0}let e=0;for(const{listeners:r}of T(this,or).values())e+=r.length;return e}async listeners(t){if(t){const r=await _t(this,se,od).call(this,t);return r?r.listeners.map(({listener:i})=>i):[]}let e=[];for(const{listeners:r}of T(this,or).values())e=e.concat(r.map(({listener:i})=>i));return e}async off(t,e){const r=await _t(this,se,od).call(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(!e||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,or).delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:i}=await _t(this,se,Zp).call(this,t);r&&i.stop(),T(this,or).delete(e)}else for(const[e,{started:r,subscriber:i}]of T(this,or))r&&i.stop(),T(this,or).delete(e);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return T(this,xl)}destroy(){this.removeAllListeners();for(const t of T(this,ci).keys())this._clearTimeout(t);$(this,xl,!0)}get paused(){return T(this,ar)!=null}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if($(this,Ys,-1),T(this,ar)!=null){if(T(this,ar)==!!t)return;ht(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(e=>e.pause(t)),$(this,ar,!!t);for(const e of T(this,ci).values())e.timer&&clearTimeout(e.timer),e.time=Nw()-e.time}resume(){if(T(this,ar)!=null){this._forEachSubscriber(t=>t.resume()),$(this,ar,null);for(const t of T(this,ci).values()){let e=t.time;e<0&&(e=0),t.time=Nw(),setTimeout(t.func,e)}}}}or=new WeakMap,Wo=new WeakMap,ar=new WeakMap,xl=new WeakMap,Wr=new WeakMap,gc=new WeakMap,Zo=new WeakMap,Ys=new WeakMap,Sh=new WeakMap,ci=new WeakMap,Rl=new WeakMap,Sl=new WeakMap,se=new WeakSet,Zr=async function(t){const e=T(this,Sl).cacheTimeout;if(e<0)return await this._perform(t);const r=mp(t.method,t);let i=T(this,Zo).get(r);return i||(i=this._perform(t),T(this,Zo).set(r,i),setTimeout(()=>{T(this,Zo).get(r)===i&&T(this,Zo).delete(r)},e)),await i},cb=async function(t,e,r){ht(r<bG,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const i=cp(t);try{return Tt(await this._perform({method:"call",transaction:i,blockTag:e}))}catch(s){if(!this.disableCcipRead&&Sm(s)&&s.data&&r>=0&&e==="latest"&&i.to!=null&&un(s.data,0,4)==="0x556f1830"){const o=s.data,c=await wr(i.to,this);let u;try{u=IG(un(s.data,4))}catch(y){ht(!1,y.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ht(u.sender.toLowerCase()===c.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const f=await this.ccipReadFetch(i,u.calldata,u.urls);ht(f!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:c,data:vn([u.selector,SG([f,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const y=await _t(this,se,cb).call(this,h,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:y}),y}catch(y){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:y}),y}}throw s}},ub=async function(t){const{value:e}=await pr({network:this.getNetwork(),value:t});return e},sd=async function(t,e,r){let i=this._getAddress(e),s=this._getBlockTag(r);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await _t(this,se,ub).call(this,_t(this,se,Zr).call(this,Object.assign(t,{address:i,blockTag:s})))},lb=async function(t,e){if(ze(t,32))return await _t(this,se,Zr).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return typeof r!="string"&&(r=await r),await _t(this,se,Zr).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})},od=async function(t,e){let r=await Ow(t,this);return r.type==="event"&&e&&e.length>0&&e[0].removed===!0&&(r=await Ow({orphan:"drop-log",log:e[0]},this)),T(this,or).get(r.tag)||null},Zp=async function(t){const e=await Ow(t,this),r=e.tag;let i=T(this,or).get(r);return i||(i={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,or).set(r,i)),i};function vG(n,t){try{const e=Cw(n,t);if(e)return U0(e)}catch{}return null}function Cw(n,t){if(n==="0x")return null;try{const e=ie(un(n,t,t+32)),r=ie(un(n,e,e+32));return un(n,e+32,e+32+r)}catch{}return null}function ck(n){const t=yr(n);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function xG(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}const RG=new Uint8Array([]);function SG(n){const t=[];let e=0;for(let r=0;r<n.length;r++)t.push(RG),e+=32;for(let r=0;r<n.length;r++){const i=we(n[r]);t[r]=ck(e),t.push(ck(i.length)),t.push(xG(i)),e+=32+Math.ceil(i.length/32)*32}return vn(t)}const uk="0x0000000000000000000000000000000000000000000000000000000000000000";function IG(n){const t={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ht(vu(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const e=un(n,0,32);ht(un(e,0,12)===un(uk,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),t.sender=un(e,12);try{const r=[],i=ie(un(n,32,64)),s=ie(un(n,i,i+32)),o=un(n,i+32);for(let c=0;c<s;c++){const u=vG(o,c*32);if(u==null)throw new Error("abort");r.push(u)}t.urls=r}catch{ht(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Cw(n,64);if(r==null)throw new Error("abort");t.calldata=r}catch{ht(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ht(un(n,100,128)===un(uk,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),t.selector=un(n,96,100);try{const r=Cw(n,128);if(r==null)throw new Error("abort");t.extraData=r}catch{ht(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return t.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>t[r]),t}function $u(n,t){if(n.provider)return n.provider;ht(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:t})}async function lk(n,t){let e=cp(t);if(e.to!=null&&(e.to=wr(e.to,n)),e.from!=null){const r=e.from;e.from=Promise.all([n.getAddress(),wr(r,n)]).then(([i,s])=>(K(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else e.from=n.getAddress();return await pr(e)}class kG{constructor(t){Z(this,"provider");$t(this,{provider:t||null})}async getNonce(t){return $u(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await lk(this,t)}async populateTransaction(t){const e=$u(this,"populateTransaction"),r=await lk(this,t);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const i=await this.provider.getNetwork();if(r.chainId!=null){const o=Ct(r.chainId);K(o===i.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=i.chainId;const s=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||s)?K(!1,"eip-1559 transaction do not support gasPrice","tx",t):(r.type===0||r.type===1)&&s&&K(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t),(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 e.getFeeData();ht(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await e.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const c=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=c,r.maxPriorityFeePerGas=c}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ht(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ht(!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 pr(r)}async estimateGas(t){return $u(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return $u(this,"call").call(await this.populateCall(t))}async resolveName(t){return await $u(this,"resolveName").resolveName(t)}async sendTransaction(t){const e=$u(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const i=rp.from(r);return await e.broadcastTransaction(await this.signTransaction(i))}}function TG(n){return JSON.parse(JSON.stringify(n))}class fk{constructor(t){nt(this,Qo);nt(this,_r);nt(this,as);nt(this,yc);nt(this,qo);nt(this,mc);nt(this,Il);$(this,_r,t),$(this,as,null),$(this,yc,_t(this,Qo,fb).bind(this)),$(this,qo,!1),$(this,mc,null),$(this,Il,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){T(this,qo)||($(this,qo,!0),_t(this,Qo,fb).call(this,-2))}stop(){T(this,qo)&&($(this,qo,!1),$(this,Il,!0),_t(this,Qo,hb).call(this),T(this,_r).off("block",T(this,yc)))}pause(t){t&&_t(this,Qo,hb).call(this),T(this,_r).off("block",T(this,yc))}resume(){this.start()}}_r=new WeakMap,as=new WeakMap,yc=new WeakMap,qo=new WeakMap,mc=new WeakMap,Il=new WeakMap,Qo=new WeakSet,fb=async function(t){try{T(this,as)==null&&$(this,as,this._subscribe(T(this,_r)));let e=null;try{e=await T(this,as)}catch(s){if(!Zn(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(e==null){$(this,as,null),T(this,_r)._recoverSubscriber(this,this._recover(T(this,_r)));return}const r=await T(this,_r).getNetwork();if(T(this,mc)||$(this,mc,r),T(this,mc).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,Il))return;const i=await T(this,_r).send("eth_getFilterChanges",[e]);await this._emitResults(T(this,_r),i)}catch(e){console.log("@TODO",e)}T(this,_r).once("block",T(this,yc))},hb=function(){const t=T(this,as);t&&($(this,as,null),t.then(e=>{T(this,_r).destroyed||T(this,_r).send("eth_uninstallFilter",[e])}))};class OG extends fk{constructor(e,r){super(e);nt(this,wc);$(this,wc,TG(r))}_recover(e){return new kw(e,T(this,wc))}async _subscribe(e){return await e.send("eth_newFilter",[T(this,wc)])}async _emitResults(e,r){for(const i of r)e.emit(T(this,wc),e._wrapLog(i,e._network))}}wc=new WeakMap;class NG extends fk{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const CG="bigint,boolean,function,number,string,symbol".split(/,/g);function bp(n){if(n==null||CG.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(bp);if(typeof n=="object")return Object.keys(n).reduce((t,e)=>(t[e]=n[e],t),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function BG(n){return new Promise(t=>{setTimeout(t,n)})}function Hu(n){return n&&n.toLowerCase()}function hk(n){return n&&typeof n.pollingInterval=="number"}const dk={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Bw extends kG{constructor(e,r){super(e);Z(this,"address");r=Me(r),$t(this,{address:r})}connect(e){ht(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const r=bp(e),i=[];if(r.from){const o=r.from;i.push((async()=>{const c=await wr(o,this.provider);K(c!=null&&c.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=c})())}else r.from=this.address;if(r.gasLimit==null&&i.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;i.push((async()=>{r.to=await wr(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const r=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(e);return await new Promise((s,o)=>{const c=[1e3,100];let u=0;const f=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(r));return}}catch(h){if(Zn(h,"CANCELLED")||Zn(h,"BAD_DATA")||Zn(h,"NETWORK_ERROR")||Zn(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Zn(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Qe("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{f()},c.pop()||4e3)};f()})}async signTransaction(e){const r=bp(e);if(r.from){const s=await wr(r.from,this.provider);K(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=s}else r.from=this.address;const i=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[i])}async signMessage(e){const r=typeof e=="string"?Os(e):e;return await this.provider.send("personal_sign",[Tt(r),this.address.toLowerCase()])}async signTypedData(e,r,i){const s=bp(i),o=await sp.resolveNames(e,r,s,async c=>{const u=await wr(c);return K(u!=null,"TypedData does not support null address","value",c),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(sp.getPayload(o.domain,r,o.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const r=typeof e=="string"?Os(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Tt(r)])}}class pk extends EG{constructor(e,r){super(e,r);nt(this,Ih);nt(this,bc);nt(this,kl);nt(this,Js);nt(this,cs);nt(this,Ii);nt(this,ui);nt(this,Cr);$(this,kl,1),$(this,bc,Object.assign({},dk,r||{})),$(this,Js,[]),$(this,cs,null),$(this,ui,null),$(this,Cr,null);{let s=null;const o=new Promise(c=>{s=c});$(this,Ii,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(K(!i||e!=="any","staticNetwork cannot be used on special network 'any'","options",r),i&&e!=null&&$(this,ui,Xi.from(e))):i&&(K(e==null||i.matches(e),"staticNetwork MUST match network object","options",r),$(this,ui,i))}_getOption(e){return T(this,bc)[e]}get _network(){return ht(T(this,ui),"network is not available yet","NETWORK_ERROR"),T(this,ui)}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let i=e.transaction;if(i&&i.type!=null&&Ct(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},i,{type:void 0})}))}}const r=this.getRpcRequest(e);return r!=null?await this.send(r.method,r.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(T(this,ui))return T(this,ui)}else return e;return T(this,Cr)?await T(this,Cr):this.ready?($(this,Cr,(async()=>{try{const r=Xi.from(Ct(await this.send("eth_chainId",[])));return $(this,Cr,null),r}catch(r){throw $(this,Cr,null),r}})()),await T(this,Cr)):($(this,Cr,(async()=>{const r={id:rd(this,kl)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let i;try{i=(await this._send(r))[0],$(this,Cr,null)}catch(s){throw $(this,Cr,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return Xi.from(Ct(i.result));throw this.getRpcError(r,i)})()),await T(this,Cr))}_start(){T(this,Ii)==null||T(this,Ii).resolve==null||(T(this,Ii).resolve(),$(this,Ii,null),(async()=>{for(;T(this,ui)==null&&!this.destroyed;)try{$(this,ui,await this._detectNetwork())}catch(e){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",Qe("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await BG(1e3)}_t(this,Ih,db).call(this)})())}async _waitUntilReady(){if(T(this,Ii)!=null)return await T(this,Ii).promise}_getSubscriber(e){return e.type==="pending"?new NG(this):e.type==="event"?this._getOption("polling")?new kw(this,e.filter):new OG(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new wp("orphan"):super._getSubscriber(e)}get ready(){return T(this,Ii)==null}getRpcTransaction(e){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(e[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),r[s]=Ru(Ct(e[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{e[i]!=null&&(r[i]=Tt(e[i]))}),e.accessList&&(r.accessList=Ka(e.accessList)),e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes.map(i=>i.toLowerCase())),r}getRpcRequest(e){switch(e.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:[Hu(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Hu(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[Hu(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Hu(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(Hu):e.filter.address=Hu(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,r){const{method:i}=e,{error:s}=r;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Qe("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=Pw(s),f=uh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",e.params[0],u?u.data:null);return f.info={error:s,payload:e},f}const o=JSON.stringify(LG(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Qe("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"}[i]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=e.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Qe("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Qe("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Qe("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Qe("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let c=!!o.match(/the method .* does not exist/i);return c||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(c=!0),c?Qe("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):Qe("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,r){if(this.destroyed)return Promise.reject(Qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const i=rd(this,kl)._++,s=new Promise((o,c)=>{T(this,Js).push({resolve:o,reject:c,payload:{method:e,params:r,id:i,jsonrpc:"2.0"}})});return _t(this,Ih,db).call(this),s}async getSigner(e){e==null&&(e=0);const r=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await r;if(e>=s.length)throw new Error("no such account");return new Bw(this,s[e])}const{accounts:i}=await pr({network:this.getNetwork(),accounts:r});e=Me(e);for(const s of i)if(Me(s)===e)return new Bw(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new Bw(this,r))}destroy(){T(this,cs)&&(clearTimeout(T(this,cs)),$(this,cs,null));for(const{payload:e,reject:r}of T(this,Js))r(Qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));$(this,Js,[]),super.destroy()}}bc=new WeakMap,kl=new WeakMap,Js=new WeakMap,cs=new WeakMap,Ii=new WeakMap,ui=new WeakMap,Cr=new WeakMap,Ih=new WeakSet,db=function(){if(T(this,cs))return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");$(this,cs,setTimeout(()=>{$(this,cs,null);const r=T(this,Js);for($(this,Js,[]);r.length;){const i=[r.shift()];for(;r.length&&i.length!==T(this,bc).batchMaxCount;)if(i.push(r.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,bc).batchMaxSize){r.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:c,reject:u,payload:f}of i){if(this.destroyed){u(Qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:f.method}));continue}const h=o.filter(y=>y.id===f.id)[0];if(h==null){const y=Qe("missing response for request","BAD_DATA",{value:o,info:{payload:f}});this.emit("error",y),u(y);continue}if("error"in h){u(this.getRpcError(f,h));continue}c(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:c}of i)c(o)}})()}},e))};class PG extends pk{constructor(e,r){super(e,r);nt(this,Yo);let i=this._getOption("pollingInterval");i==null&&(i=dk.pollingInterval),$(this,Yo,i)}_getSubscriber(e){const r=super._getSubscriber(e);return hk(r)&&(r.pollingInterval=T(this,Yo)),r}get pollingInterval(){return T(this,Yo)}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");$(this,Yo,e),this._forEachSubscriber(r=>{hk(r)&&(r.pollingInterval=T(this,Yo))})}}Yo=new WeakMap;class MG extends PG{constructor(e,r,i){e==null&&(e="http://localhost:8545");super(r,i);nt(this,Tl);typeof e=="string"?$(this,Tl,new Ns(e)):$(this,Tl,e.clone())}_getConnection(){return T(this,Tl).clone()}async send(e,r){return await this._start(),await super.send(e,r)}async _send(e){const r=this._getConnection();r.body=JSON.stringify(e),r.setHeader("content-type","application/json");const i=await r.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}Tl=new WeakMap;function Pw(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&ze(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const t in n){const e=Pw(n[t]);if(e)return e}return null}if(typeof n=="string")try{return Pw(JSON.parse(n))}catch{}return null}function Mw(n,t){if(n!=null){if(typeof n.message=="string"&&t.push(n.message),typeof n=="object")for(const e in n)Mw(n[e],t);if(typeof n=="string")try{return Mw(JSON.parse(n),t)}catch{}}}function LG(n){const t=[];return Mw(n,t),t}function UG(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Hc<"u")return Hc;throw new Error("unable to locate global object")}const DG=UG().WebSocket;class Lw{constructor(t,e){nt(this,us);nt(this,kh);nt(this,Jo);nt(this,_c);nt(this,Xo);$(this,us,t),$(this,kh,JSON.stringify(e)),$(this,Jo,null),$(this,_c,null),$(this,Xo,null)}get filter(){return JSON.parse(T(this,kh))}start(){$(this,Jo,T(this,us).send("eth_subscribe",this.filter).then(t=>(T(this,us)._register(t,this),t)))}stop(){T(this,Jo).then(t=>{T(this,us).destroyed||T(this,us).send("eth_unsubscribe",[t])}),$(this,Jo,null)}pause(t){ht(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),$(this,_c,!!t)}resume(){$(this,_c,null)}_handleMessage(t){if(T(this,Jo)!=null&&T(this,_c)===null){let e=T(this,Xo);e==null?e=this._emit(T(this,us),t):e=e.then(async()=>{await this._emit(T(this,us),t)}),$(this,Xo,e.then(()=>{T(this,Xo)===e&&$(this,Xo,null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}us=new WeakMap,kh=new WeakMap,Jo=new WeakMap,_c=new WeakMap,Xo=new WeakMap;class FG extends Lw{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class $G extends Lw{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}class HG extends Lw{constructor(e,r){super(e,["logs",r]);nt(this,Th);$(this,Th,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Th))}async _emit(e,r){e.emit(this.logFilter,e._wrapLog(r,e._network))}}Th=new WeakMap;class zG extends pk{constructor(e,r){const i=Object.assign({},r??{});K(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(e,i);nt(this,Ac);nt(this,Ol);nt(this,ta);$(this,Ac,new Map),$(this,Ol,new Map),$(this,ta,new Map)}_getSubscriber(e){switch(e.type){case"close":return new wp("close");case"block":return new FG(this);case"pending":return new $G(this);case"event":return new HG(this,e.filter);case"orphan":if(e.filter.orphan==="drop-log")return new wp("drop-log")}return super._getSubscriber(e)}_register(e,r){T(this,Ol).set(e,r);const i=T(this,ta).get(e);if(i){for(const s of i)r._handleMessage(s);T(this,ta).delete(e)}}async _send(e){K(!Array.isArray(e),"WebSocket does not support batch send","payload",e);const r=new Promise((i,s)=>{T(this,Ac).set(e.id,{payload:e,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(e)),[await r]}async _processMessage(e){const r=JSON.parse(e);if(r&&typeof r=="object"&&"id"in r){const i=T(this,Ac).get(r.id);if(i==null){this.emit("error",Qe("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,Ac).delete(r.id),i.resolve(r)}else if(r&&r.method==="eth_subscription"){const i=r.params.subscription,s=T(this,Ol).get(i);if(s)s._handleMessage(r.params.result);else{let o=T(this,ta).get(i);o==null&&(o=[],T(this,ta).set(i,o)),o.push(r.params.result)}}else{this.emit("error",Qe("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(e){throw new Error("sub-classes must override this")}}Ac=new WeakMap,Ol=new WeakMap,ta=new WeakMap;class GG extends zG{constructor(e,r,i){super(r,i);nt(this,Ec);nt(this,ki);typeof e=="string"?($(this,Ec,()=>new DG(e)),$(this,ki,T(this,Ec).call(this))):typeof e=="function"?($(this,Ec,e),$(this,ki,e())):($(this,Ec,null),$(this,ki,e)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(T(this,ki)==null)throw new Error("websocket closed");return T(this,ki)}async _write(e){this.websocket.send(e)}async destroy(){T(this,ki)!=null&&(T(this,ki).close(),$(this,ki,null)),super.destroy()}}Ec=new WeakMap,ki=new WeakMap;const VG={_format:"hh-sol-artifact-1",contractName:"SwarmEventEmitter",sourceName:"contracts/SwarmEventEmitter.sol",abi:[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"string",name:"message",type:"string"}],name:"MessageLogged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"RemovedFromWhitelist",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"message",type:"string"}],name:"emitMessage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"whitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}],bytecode:"0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a26107b08061013b6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",deployedBytecode:"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",linkReferences:{},deployedLinkReferences:{}},KG={address:"Eai8D93JKad51sYmft1r74fzLkBSwRGPQVAmwZoLoWDf",metadata:{name:"swarm_event_emitter",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},instructions:[{name:"add_to_whitelist",discriminator:[157,211,52,54,144,81,5,55],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]},{name:"emit_message",discriminator:[118,99,20,87,25,132,207,62],accounts:[{name:"state",writable:!0},{name:"user",signer:!0}],args:[{name:"message",type:"string"}]},{name:"initialize",discriminator:[175,175,109,31,13,152,155,237],accounts:[{name:"state",writable:!0,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"admin",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"remove_from_whitelist",discriminator:[7,144,216,239,243,236,193,235],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]}],accounts:[{name:"State",discriminator:[216,146,107,94,104,75,182,177]}],events:[{name:"MessageLogged",discriminator:[24,236,247,207,227,70,101,210]},{name:"RemovedFromWhitelist",discriminator:[107,247,94,185,182,200,82,172]},{name:"Whitelisted",discriminator:[235,202,86,232,226,75,139,182]}],errors:[{code:6e3,name:"NotAdmin",msg:"Only the admin can perform this action."},{code:6001,name:"NotWhitelisted",msg:"You are not whitelisted."}],types:[{name:"MessageLogged",type:{kind:"struct",fields:[{name:"sender",type:"pubkey"},{name:"message",type:"string"}]}},{name:"RemovedFromWhitelist",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}},{name:"State",type:{kind:"struct",fields:[{name:"admin",type:"pubkey"},{name:"whitelisted",type:{vec:"pubkey"}}]}},{name:"Whitelisted",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}}]};class jG{constructor(t){this.settings=t,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:t,contractAddress:e}=this.settings;if(!e)throw new Error("Contract address is required for EVM chain type");const r=t.startsWith("ws")?new GG(t):new MG(t),i=new Du(e,VG.abi,r);this.evm={provider:r,contract:i}}initSvm(){const t=new mE(this.settings.rpcUrl,"confirmed"),e=Ra.generate(),r={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:e.publicKey},i=new Gf(t,r,{}),s=new Au(KG,i);this.svm={provider:t,program:s}}async onMessageFrom(t,e){this.settings.chainType==="EVM"?this.listenToEvm(t,e):this.settings.chainType==="SVM"&&await this.listenToSvm(t,e)}listenToEvm(t,e){var r;(r=this.evm)==null||r.contract.on("MessageLogged",(i,s)=>{const[o,c]=s.split("_");zl(i.toLowerCase())===zl(this.settings.swarmEmitterAddress.toLowerCase())&&o===t&&e(i,s)})}async listenToSvm(t,e){var i;const r=(i=this.svm)==null?void 0:i.program.addEventListener("messageLogged",s=>{const{sender:o,message:c}=s,[u,f]=c.split("_");o.toBase58()===this.settings.swarmEmitterAddress&&u===t&&e(o.toBase58(),c)});this.svm&&r!==void 0&&(this.svm.listenerId=r)}async removeAllListeners(){var t,e;this.settings.chainType==="EVM"&&((t=this.evm)==null||t.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((e=this.svm)==null?void 0:e.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const WG=new TextEncoder,gk=1,yk=4096,Uw=4096,ZG=32;function qG(n,t){return t=typeof t=="number"?xt.FeedIndex.fromBigInt(BigInt(t)):t,new xt.Identifier(Jn.keccak256(Jn.concatBytes(n.toUint8Array(),t.toUint8Array())))}function QG(n){const t=n.slice(0,xt.Span.LENGTH),e=n.slice(xt.Span.LENGTH),r=YG(e),i=Jn.keccak256(Jn.concatBytes(t,r));return new xt.Reference(i)}function YG(n){if(n.length>Uw)throw new xt.BeeArgumentError(`payload size ${n.length} exceeds maximum chunk payload size ${Uw}`,n);const t=new Uint8Array(Uw);return t.set(n),Jn.log2Reduce(Jn.partition(t,ZG),(e,r)=>Jn.keccak256(Jn.concatBytes(e,r)))}function mk(n){if(n instanceof Uint8Array||(n=WG.encode(n)),n.length<gk||n.length>yk)throw new RangeError(`payload size ${n.length} exceeds limits [${gk}, ${yk}]`);const t=xt.Span.fromBigInt(BigInt(n.length)),e=Jn.concatBytes(t.toUint8Array(),n);return{data:e,span:t,payload:xt.Bytes.fromSlice(e,xt.Span.LENGTH),address:QG(e)}}function JG(n,t){return new xt.Reference(Jn.keccak256(Jn.concatBytes(n.toUint8Array(),t.toUint8Array())))}function wk(n,t,e){t=new xt.Identifier(t),e=new xt.PrivateKey(e);const r=JG(t,e.publicKey().address()),i=e.sign(Jn.concatBytes(t.toUint8Array(),n.address.toUint8Array())),s=Jn.concatBytes(t.toUint8Array(),i.toUint8Array(),n.data),o=xt.Span.fromSlice(n.data,0),c=xt.Bytes.fromSlice(n.data,xt.Span.LENGTH);return{data:s,identifier:t,signature:i,span:o,payload:c,address:r,owner:e.publicKey().address()}}class XG{constructor(t,e){this.userDetails=t,this.swarmSettings=e,this.depth=24,this.logger=Oi.getInstance(),this.errorHandler=new md,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(t,e){const{enveloped:r,stamp:i}=this.swarmSettings;if(!r)await this.writeOwnFeedDataByIndexOwned(t,e);else if(i)await this.writeOwnFeedDataByIndexEnvelope(t,e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:c}=this.userDetails,u=this.generateUserOwnedFeedId(s,c),f=xt.Topic.fromString(u);console.log("DEBUG: feedID write",f.toString(),c,t,u),await r.makeFeedWriter(f,new xt.PrivateKey(o)).uploadPayload(i,JSON.stringify(e),{index:t})}async writeOwnFeedDataByIndexEnvelope(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:c}=this.userDetails,u=new xt.PrivateKey(o),f=xt.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,c),y=xt.Topic.fromString(h),A=qG(y,t),b=mk(e),R=wk(b,A,u),k={hash:()=>R.address.toUint8Array()},S=f.stamp(k),{upload:B}=r.makeSOCWriter(u),H=xt.Bytes.fromUtf8(e);return(await B(S,A,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(t,e,r){const{bee:i,chatTopic:s}=this.swarmSettings,o=(r==null?void 0:r.timeout)??1500,c=this.generateUserOwnedFeedId(s,t),u=xt.Topic.fromString(c);return console.log("DEBUG: feedID read",u.toString(),t,e,c),(await i.makeFeedReader(u,t,{timeout:o}).downloadPayload({index:e})).payload.toJSON()}orderMessages(t){return t.sort((e,r)=>e.timestamp-r.timestamp)}async retryAwaitableAsync(t,e=3,r=250){return new Promise((i,s)=>{t().then(i).catch(o=>{e>0?(this.logger.info(`Retrying... Attempts left: ${e}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(t,e-1,r).then(i).catch(s)},r)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(e){if(r)return this.uploadObjectToBeeEnvelope(t);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(t)}async uploadObjectToBeeOwn(t){try{const{bee:e,stamp:r}=this.swarmSettings,i=await e.uploadData(r,JSON.stringify(t),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(t){try{const{bee:e,stamp:r}=this.swarmSettings,{privateKey:i}=this.userDetails,s=xt.Stamper.fromBlank(i,r,this.depth),o=xt.Bytes.fromUtf8(JSON.stringify(t)),c=new d8(async f=>{await e.uploadChunk(s.stamp(f),f.build())});await c.append(o.toUint8Array());const u=await c.finalize();return Jn.uint8ArrayToHex(u.hash())}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(t){try{const{bee:e}=this.swarmSettings;return(await e.downloadData(t)).toJSON()}catch(e){return this.errorHandler.handleError(e,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:t,chatTopic:e}=this.swarmSettings,{ownAddress:r}=this.userDetails,i=this.generateUserOwnedFeedId(e,r),s=xt.Topic.fromString(i),c=await t.makeFeedReader(s,r).downloadPayload(),u=Number(c.feedIndex.toBigInt()),f=u+1;return console.log("DEBUG: getLatestFeedIndex",u,f),{latestIndex:u,nextIndex:f}}catch(t){if(this.isNotFoundError(t))return{latestIndex:-1,nextIndex:0};throw t}}async fetchLatestChatMessage(){const{bee:t,chatTopic:e,chatAddress:r}=this.swarmSettings,s=await t.makeFeedReader(xt.Topic.fromString(e),zl(r)).downloadPayload();return{message:s.payload.toJSON(),index:s.feedIndex}}async fetchChatMessage(t){const{bee:e,chatTopic:r,chatAddress:i}=this.swarmSettings;return(await e.makeFeedReader(xt.Topic.fromString(r),zl(i)).downloadPayload({index:t})).payload.toJSON()}async sendMessageToGsoc(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(!e)await this.sendMessageToGsocOwn(t);else if(r)await this.sendMessageToGsocEnvelope(t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new xt.PrivateKey(s),c=xt.Identifier.fromString(i),u=xt.Bytes.fromUtf8(t),{upload:f}=e.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await f(r,c,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,c=xt.Stamper.fromBlank(o,r,this.depth),u=new xt.PrivateKey(s),f=xt.Identifier.fromString(i),h=xt.Bytes.fromUtf8(t),y=mk(h.toUint8Array()),A=wk(y,f,u),b={hash:()=>A.address.toUint8Array()},R=c.stamp(b),{upload:k}=e.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await k(R,f,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(t,e){return`${t}_EthercastChat_${e}`}isNotFoundError(t){return t.stack.includes("404")||t.message.includes("Not Found")||t.message.includes("404")}}class tV{constructor(t){var r,i,s;this.logger=Oi.getInstance(),this.errorHandler=new md,this.messagesQueue=new e_({clearWaitTime:200}),this.gsocListenerQueue=new e_({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const e=new xt.PrivateKey(zl(t.user.privateKey));this.userDetails={privateKey:t.user.privateKey,ownAddress:e.publicKey().address().toString(),nickname:t.user.nickname,ownIndex:-1},this.swarmSettings={bee:new xt.Bee(t.infra.swarm.beeUrl),stamp:t.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:t.infra.swarm.enveloped,customGsocCallback:t.infra.swarm.customGsocCallback,gsocTopic:t.infra.swarm.gsocTopic,gsocResourceId:t.infra.swarm.gsocResourceId,chatTopic:t.infra.swarm.chatTopic,chatAddress:t.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((r=t.options)==null?void 0:r.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=t.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=t.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new h8,this.utils=new XG(this.userDetails,this.swarmSettings),this.history=new v5(this.utils,this.emitter),this.swarmEventEmitterReader=new jG(t.infra.chain)}start(){this.init(),this.swarmSettings.customGsocCallback||this.subscribeToGSOCEvent(),this.startMessagesFetchProcess(),this.startIdleUserCleanup()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.unsubFromGSOCEvent(),this.emitter.cleanAll()}getEmitter(){return this.emitter}orderMessages(t){return this.utils.orderMessages(t)}async sendMessage(t,e){const r=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:e||f8(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:r,message:t};try{this.emitter.emit(Mr.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(r,JSON.stringify(i)),this.userDetails.ownIndex=r,this.emitter.emit(Mr.MESSAGE_REQUEST_UPLOADED,i),await this.broadcastUserMessage()}catch(s){this.emitter.emit(Mr.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Mr.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages()}finally{this.emitter.emit(Mr.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(t){this.sendMessage(t.message,t.id)}async retryBroadcastUserMessage(t){this.broadcastUserMessage()}async init(){try{this.emitter.emit(Mr.LOADING_INIT,!0);const[t,e]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(t.status==="rejected")throw t.reason;e.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${e.reason}`),this.emitter.emit(Mr.LOADING_INIT,!1)}catch(t){this.errorHandler.handleError(t,"Chat.initSelfState"),this.emitter.emit(Mr.CRITICAL_ERROR,t)}}async initOwnIndex(){const{latestIndex:r}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=r}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom(this.swarmSettings.chatTopic,(t,e)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(e)))}catch(t){this.errorHandler.handleError(t,"Chat.subscribeToGSOCEvent"),this.emitter.emit(Mr.CRITICAL_ERROR,t)}}callbackProcessGsocEvent(t){try{this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t))}catch(e){this.errorHandler.handleError(e,"Chat.callbackProcessGsocEvent"),this.emitter.emit(Mr.CRITICAL_ERROR,e)}}async processGsocEvent(t){try{console.log("processGsocMessage CALLED",t);const[e,r]=t.split("_"),i=xt.FeedIndex.fromBigInt(BigInt(`0x${r}`)),s=await this.utils.fetchChatMessage(i);if(console.log("DEBUG processGsocMessage",s),!w5(s)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",s),a8(this.latestMessage,s))return;this.updateActiveUsers(s.messageSender),this.latestMessage=s}catch(e){this.errorHandler.handleError(e,"Chat.processGsocMessage")}}async waitForMessageBroadcast(t){return A5({condition:()=>Object.values(this.activeUsers).some(e=>e.index===t),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const t=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",t),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({topic:this.swarmSettings.chatTopic,messageSender:t})))}catch(t){this.errorHandler.handleError(t,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:t,privateKey:e,nickname:r}=this.userDetails,i=new xt.EthAddress(t).toString(),s=new xt.PrivateKey(e);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const c=Date.now(),u=s.sign(JSON.stringify({username:r,address:i,timestamp:c}));return{address:i,timestamp:c,signature:u.toHex(),index:this.getOwnIndex(),username:r}}async readAllActiveUserMessage(){if(!await this.messagesQueue.waitForProcessing())for(const e of Object.values(this.activeUsers))this.messagesQueue.enqueue(()=>this.readMessage(e))}async readMessage(t){try{let e;const r=this.isUserIndexRead(t.address,t.index);if(r.isIndexRead)return;e=r.cachedIndex?r.cachedIndex+1:t.index;const i=await this.utils.fetchUserFeedDataByIndex(t.address,e);this.setUserIndexCache(t.address,e),this.emitter.emit(Mr.MESSAGE_RECEIVED,JSON.parse(i))}catch(e){this.errorHandler.handleError(e,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:t,FETCH_MESSAGE_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),e)}stopMessagesFetchProcess(){const{fetchMessageTimer:t}=this.options;t&&(clearInterval(t),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:t,IDLE_USER_CLEANUP_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),e)}stopIdleUserCleanup(){const{idleUserCleanupInterval:t}=this.options;t&&(clearInterval(t),this.options.idleUserCleanupInterval=null)}isUserIndexRead(t,e){const r=this.userIndexCache[t];return{cachedIndex:r,isIndexRead:r===e}}setUserIndexCache(t,e){this.userIndexCache[t]=e}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const t=Date.now();for(const e of Object.values(this.activeUsers))t-e.timestamp>300*E5&&delete this.activeUsers[e.address]}updateActiveUsers(t){this.activeUsers[t.address]=t}}ue.EVENTS=Mr,ue.SwarmChat=tV,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})});
1
+ (function(ce,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],S):(ce=typeof globalThis<"u"?globalThis:ce||self,S(ce.SwarmChatJs={},ce.BeeJs))})(this,function(ce,S){"use strict";const P=[];for(let a=0;a<256;++a)P.push((a+256).toString(16).slice(1));function pi(a,n=0){return(P[a[n+0]]+P[a[n+1]]+P[a[n+2]]+P[a[n+3]]+"-"+P[a[n+4]]+P[a[n+5]]+"-"+P[a[n+6]]+P[a[n+7]]+"-"+P[a[n+8]]+P[a[n+9]]+"-"+P[a[n+10]]+P[a[n+11]]+P[a[n+12]]+P[a[n+13]]+P[a[n+14]]+P[a[n+15]]).toLowerCase()}let Vt;const gi=new Uint8Array(16);function yi(){if(!Vt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Vt=crypto.getRandomValues.bind(crypto)}return Vt(gi)}const Sn={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function vi(a,n,i){if(Sn.randomUUID&&!n&&!a)return Sn.randomUUID();a=a||{};const c=a.random||(a.rng||yi)();return c[6]=c[6]&15|64,c[8]=c[8]&63|128,pi(c)}function wi(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var On={};(function(a){var n;Object.defineProperty(a,"__esModule",{value:!0}),a.Vector=a.Cache=a.Assertions=a.Strings=a.Types=a.Objects=a.Dates=a.Promises=a.Numbers=a.System=a.Arrays=a.Random=a.Elliptic=a.Binary=a.AsyncQueue=a.PubSubChannel=a.FixedPointNumber=a.MerkleTree=a.Chunk=a.Uint8ArrayWriter=a.Uint8ArrayReader=a.AsyncLazy=a.Lazy=a.Optional=void 0;async function i(e){return new Promise((t,r)=>e.then(r,t))}async function c(e){return i(Promise.all(e.map(i)))}async function u(e,t=1){const r=Bs(e,t),s=[],o=r.map(async d=>{for(const f of d)s.push(await f())});return await Promise.all(o),s}async function l(e){return new Promise(t=>setTimeout(()=>{t(!0)},e))}function h(e,t=Math.random){for(let r=e.length-1;r>0;r--){const s=Math.floor(t()*(r+1)),o=e[r];e[r]=e[s],e[s]=o}return e}function m(e){if(e.length===1)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)}function w(e){return e.length===1?e[0]:null}function v(e){return e.length>0?e[0]:null}function E(e){if(!e.length)throw Error("Received empty array");return e[0]}function D(e,t){const r=[];for(let s=0;s<e;s++)r.push(t(s));return r}function ie(e){const t=[];for(let r=0;r<e[0].length;r++){t.push([]);for(let s=0;s<e.length;s++)t[r].push(e[s][r])}return t}function ae(e,t,r){const s=[];for(let o=0;o<e;o++){s.push([]);for(let d=0;d<t;d++)s[o].push(r)}return s}function nt(e,t,r,s){if(r<0||s<0||s+t[0].length>e[0].length||r+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let d=0;d<t[o].length;d++)if(t[o][d]!==void 0&&e[r+o][s+d]!==t[o][d])return!1;return!0}function Ne(e,t,r=Math.random){return h(cs(0,e.length-1),r).slice(0,t)}function er(e,t){return e.map(r=>r[t])}function tr(e){let t=e,r=3405648695,s=3735928559;return function(){return t+=r,r^=t<<7,t*=s,s^=t<<13,t^=r^s,(t>>>0)/4294967296}}function st(e,t,r=Math.random){return Math.floor(r()*(t-e+1))+e}function qn(e,t,r=Math.random){return r()*(t-e)+e}function ja(){return Math.random()*2-1}function Ua(e,t,r){return t>=e.x&&t<e.x+e.width&&r>=e.y&&r<e.y+e.height}function Pa(e,t,r,s=Math.random){let o,d;do o=st(0,e-1,s),d=st(0,t-1,s);while(r&&Ua(r,o,d));return[o,d]}function Za(e,t=Math.random){const r=Math.floor(e),s=e-r;return Gn(s,t)?r+1:r}function Gn(e,t=Math.random){return t()<e}function rr(e,t=Math.random){return e[Math.floor(e.length*t())]}function Ba(e,t,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return Ne(e,t,r).map(s=>e[s])}function La(e,t,r,s=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const d=rr(e,s);o.some(f=>r(f,d))||o.push(d)}return o}function za(e,t,r,s,o,d=Math.random){const f=e.filter(p=>p!==t&&p!==r),g=[];for(t!==null&&g.push(t);f.length&&g.length<s;){const p=a.Random.intBetween(0,f.length-1,d);o(f[p],g)&&g.push(f[p]),f.splice(p,1)}return h(g,d),{values:g,indexOfGuaranteed:t!==null?g.indexOf(t):-1}}function it(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function Kn(e,t,r){return r(t.reduce((s,o)=>o(s),e))}function Fa(e,t){return r=>Kn(r,e,t)}function Va(e,t,r){if(r===void 0&&(r=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let s=t.reduce((d,f)=>d+f,0);const o=r*s;for(let d=0;d<e.length-1;d++)if(s-=t[d],o>=s)return e[d];return it(e)}function Wa(e,t,r=Math.random){const s=t.map(d=>r()*d),o=[];for(let d=0;d<e.length;d++)o.push([e[d],s[d]]);return o.sort((d,f)=>f[1]-d[1]).map(d=>d[0])}function be(e,t){if(e==null)return null;const r=t.split(".");let s=e;for(const o of r){if(s[o]===null||s[o]===void 0)return null;s=s[o]}return s}function xe(e,t,r){const s=t.split(/\.|\[/);let o=e;for(let d=0;d<s.length;d++){const f=s[d],g=d<s.length-1&&s[d+1].includes("]"),p=f.includes("]")?f.replace(/\[|\]/g,""):f;if(d===s.length-1)return o[p]=r,r;he(o[p])||(g?o[p]=[]:o[p]={}),o=o[p]}return r}function Ha(e,t,r=1){const s=be(e,t)||0;return xe(e,t,s+r),s}function qa(e,t,r){return be(e,t)||xe(e,t,r)}function Ga(e,t){const r=dr(t,"."),s=ls(t,".");if(!r||!s)return;const o=be(e,r);delete o[s]}function Ka(e,t,r){const s=be(e,t);if(!s)throw new Error("Key '"+t+"' does not exist.");return xe(e,t,r),s}function Ya(e,t,r){for(const s of t){const o=be(e,s);if(o)return o}if(r){const s=Object.values(e);if(s.length)return s[0]}return null}async function Qa(e,t,r){for(;;){try{await e()}catch(s){r&&r("Error in forever",s)}await l(t)}}function Xa(e,t){e();const r=setInterval(()=>{e()},t);return()=>clearInterval(r)}function Ja(e){return e/1024/1024}function eo(e){return e>=1024*1024*1024*1024?(e/1024/1024/1024/1024).toFixed(3)+" TB":e>=1024*1024*1024?(e/1024/1024/1024).toFixed(3)+" GB":e>=1024*1024?(e/1024/1024).toFixed(3)+" MB":e>=1024?(e/1024).toFixed(3)+" KB":e+" B"}function to(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}function ro(e){return"#"+e.map(t=>t.toString(16).padStart(2,"0")).join("")}function no(e,t,r,s){const o=e*Math.PI/180,d=r*Math.PI/180,f=(r-e)*Math.PI/180,g=(s-t)*Math.PI/180,p=Math.sin(f/2)*Math.sin(f/2)+Math.cos(o)*Math.cos(d)*Math.sin(g/2)*Math.sin(g/2);return 6371e3*(2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)))}function It(e,t){return Math.round(e/t)*t}function so(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?It(e,100)+" m":e>=100?It(e,50)+" m":It(e,10)+" m"}function io(e){return e*(e+1)/2}function ao(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])}function he(e,t=!0){return!e||t&&!nr(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||e.constructor.name=="Uint8Array"||e.constructor.name==="ArrayBuffer"||e.constructor.name==="ReadableStream")?!1:typeof e=="object"}function Re(e){return he(e)&&!Array.isArray(e)}function Yn(e){return Array.isArray(e)&&e.length===0}function oo(e){return Re(e)&&Object.keys(e).length===0}function nr(e){return e===void 0}function sr(e){return Object.prototype.toString.call(e)==="[object Function]"||Object.prototype.toString.call(e)==="[object AsyncFunction]"}function V(e){return Object.prototype.toString.call(e)==="[object String]"}function me(e){return typeof e=="number"&&isFinite(e)}function Qn(e){return e===!0||e===!1}function De(e){return Object.prototype.toString.call(e)==="[object Date]"}function Mt(e){return!V(e)||e.trim().length===0}function ir(e){return me(e)&&Number.isInteger(e)&&e>=1}function Xn(e){return V(e)&&e.match(/^-?\d+$/)!==null}function Jn(e){return V(e)&&e.match(/^(0x)?[0-9a-f]+$/i)!==null}const co="!@#$%^&*()_+-=[]{}|;:<>?,./",uo="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),ar="abcdefghijklmnopqrstuvwxyz",lo="ABCDEFGHIJKLMNOPQRSTUVWXYZ",fo="1234567890",or=ar+lo+fo,es=or+co,ts=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],rs="0123456789abcdef";function ho(e,t=Math.random){let r="";for(let s=0;s<e;s++)r+=ar[Math.floor(t()*ar.length)];return r}function mo(e,t=Math.random){let r="";for(let s=0;s<e;s++)r+=or[Math.floor(t()*or.length)];return r}function po(e,t=Math.random){let r="";for(let s=0;s<e;s++)r+=es[Math.floor(t()*es.length)];return r}function go(e,t=Math.random){let r="";for(let s=0;s<e;s++)r+=ts[Math.floor(t()*ts.length)];return r}function yo(e,t){const r=new RegExp(`[0-9a-f]{${t}}`,"i"),s=e.match(r);return s?s[0]:null}function vo(e,t,r=uo){const s=ds(e,r);for(const o of s)if(t(o))return o;return null}function wo(e,t=Math.random){let r="";for(let s=0;s<e;s++)r+=rs[Math.floor(t()*rs.length)];return r}function _o(e,t){if(!Xn(e))throw new TypeError(`Expected integer string${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);const r=BigInt(e);if(t&&(t.min&&r<t.min||t.max&&r>t.max))throw RangeError(`Expected integer string${t!=null&&t.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+r);return e}function ns(e,t){if(Mt(e))throw new TypeError(`Expected string${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);if(t&&(t.min!==void 0&&e.length<t.min||t.max!==void 0&&e.length>t.max))throw RangeError(`Expected string${t!=null&&t.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function bo(e,t){if(!Jn(e))throw new TypeError(`Expected hex string${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);const r=e.replace(/^0x/,"");if(t&&t.byteLength&&r.length!==t.byteLength*2)throw RangeError(`Expected hex string${t!=null&&t.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+r);return r}function xo(e,t){if(!ns(e,t).split("").every(r=>r==="_"||ct(r)))throw new TypeError(`Expected safe string${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function ss(e,t){if(t.min!==void 0&&e<t.min||t.max!==void 0&&e>t.max)throw RangeError(`Expected value${t!=null&&t.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function ko(e,t){if(!sr(e))throw new TypeError(`Expected function${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function $t(e,t){if(me(e))return t&&ss(e,t),e;if(!V(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);const r=parseFloat(e);return t&&ss(r,t),r}function cr(e,t){return $t(e,t)|0}function Eo(e,t){if(e==="true")return!0;if(e==="false")return!1;if(!Qn(e))throw new TypeError(`Expected boolean${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function To(e,t){if(!De(e))throw new TypeError(`Expected date${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function Ao(e){return Mt(e)?null:e}function So(e,t){if(!V(e))throw new TypeError(`Expected string${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function Oo(e,t){if(ir(e))return e;const r=parseInt(e,10);if(!ir(r))throw new TypeError(`Expected id${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return r}function Io(e,t){if(!V(e))throw new TypeError(`Expected time${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);const r=e.split(":");if(r.length!==2)throw new TypeError(`Expected time${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);const s=parseInt(r[0],10),o=parseInt(r[1],10);if(!me(s)||!me(o)||s<0||s>23||o<0||o>59)throw new TypeError(`Expected time, got${t!=null&&t.name?` for ${t.name}`:""}: `+e);return`${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function Mo(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function Ct(e,t){if(!Re(e))throw new TypeError(`Expected object${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function $o(e,t){return e===null?null:Ct(e,t)}function Co(e,t){const r=Ct(e,t);for(const s of Object.keys(r))if(!V(r[s]))throw new TypeError(`Expected string map${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return r}function No(e,t){const r=Ct(e),s=Object.keys(r),o=Object.values(r);if(!s.every(V)||!o.every(me))throw new TypeError(`Expected numeric dictionary${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return r}function is(e){return V(e)&&e.match(/^https?:\/\/.+/)!==null}function Ro(e,t){if(!is(e))throw new TypeError(`Expected url${t!=null&&t.name?` for ${t.name}`:""}, got: `+e);return e}function Do(e,t){return t==null?!0:e(t)}function jo(e,t){return t==null?null:e(t)}function Uo(e,t){return t==null?void 0:e(t)}function as(e,t){for(const[r,s]of Object.entries(t))if(!s(e[r]))throw TypeError(`${r} in value does not exist or match shape`);for(const r of Object.keys(e))if(!t[r])throw TypeError(`${r} exists in value but not in shape`);return!0}function Po(e,t){return e.every(r=>as(r,t))}function at(e,t="json",r=0){if(he(e,!1)){if(r>1)return"[object Object]";if(t==="json"){if(Array.isArray(e)){const o=e.map(d=>at(d,"json",r+1));return r===0?JSON.stringify(o):o}const s={};e.message&&(s.message=at(e.message,"json",r+1));for(const[o,d]of Object.entries(e))s[o]=at(d,"json",r+1);return r===0?JSON.stringify(s):s}else if(t==="key-value"){const s=Object.keys(e);return e.message&&!s.includes("message")&&s.unshift("message"),s.map(o=>`${o}=${JSON.stringify(at(e[o],"json",r+1))}`).join(" ")}}return nr(e)&&(e="undefined"),r===0?JSON.stringify(e):e}function Zo(e,t){if(V(e))return e;const r=Object.keys(e);e.message&&!r.includes("message")&&r.push("message");const s=r.map(o=>`${o}: ${e[o]}`).join("; ");return t&&e.stack?s+`
2
+ `+e.stack:s}function ke(e,t){if(Re(e)&&Re(t))for(const r in t)Re(t[r])?(e[r]||(e[r]={}),ke(e[r],t[r])):Array.isArray(t[r])?e[r]=[...t[r]]:(t[r]!==null&&t[r]!==void 0||e[r]===null||e[r]===void 0)&&(e[r]=t[r]);return e}function Bo(e,t){const r={};return ke(r,e),ke(r,t),r}function Lo(e,t,r){const s={};return ke(s,e),ke(s,t),ke(s,r),s}function os(e,t){const r={};for(const s of e)for(const o of Object.keys(s))r[o]?r[o]=t(r[o],s[o]):r[o]=s[o];return r}function zo(e){return os(e,(t,r)=>t+r)}function Fo(e,t,r){e[t]||(e[t]=[]),e[t].push(r)}function Vo(e,t,r){for(e.unshift(t);e.length>r;)e.pop()}function Wo(e,t){let r=t%e.length;return r<0&&(r+=e.length),e[r]}function Nt(e,t){Array.prototype.push.apply(e,t)}function Ho(e,t){Array.prototype.unshift.apply(e,t)}async function qo(e,t){const r=[];for(const s of e)r.push(await t(s));return r}function Go(e,t){const r=[];for(let s=0;s<e.length;s++)r.push(e[s]),s<e.length-1&&(sr(t)?r.push(t()):r.push(t));return r}function Ko(e,t){if(e!==t)throw Error(`Expected [${e}] to equal [${t}]`);return[e,t]}function Yo(e){if(e!==!0)throw Error(`Expected [true], got: [${e}]`);return e}function Qo(e){if(!e)throw Error(`Expected truthy value, got: [${e}]`);return e}function Xo(e){if(e!==!1)throw Error(`Expected [false], got: [${e}]`);return e}function Jo(e){if(e)throw Error(`Expected falsy value, got: [${e}]`);return e}function ec(e,t){if(!t.includes(e))throw Error(`Expected any of [${t.join(", ")}], got: [${e}]`);return e}function tc(e,t){for(let r=0;r<e.length;r++){const s=e[r],o=t[r],d=Math.max(0,o.getTime()-Date.now());setTimeout(s,d)}}function rc(e,t,r){return e+(t-e)*r}function nc(e){return e.reduce((t,r)=>t+r,0)}function sc(e){return e.reduce((t,r)=>t+r,0)/e.length}function ic(e){const t=[...e].sort((s,o)=>s-o),r=Math.floor(t.length/2);return t.length%2===0?(t[r]+t[r-1])/2:t[r]}function ac(e,t){return e-(t-1)/2}function cs(e,t){const r=[];for(let s=e;s<=t;s++)r.push(s);return r}function oc(e,t){return t.some(r=>e.includes(r))}function cc(e){return/^[\u4E00-\u9FA5]+$/.test(e)}function ur(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(r=>/[a-z0-9]/.test(r)||t(r)?r:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function uc(e){return ur(e).replaceAll("-","")}function lc(e){return Dt(e.replace(/([A-Z])/g," $1"))}function dc(e){return e.split("-").map(Dt).join(" ")}function fc(e){return hs(e.split("-").map(Dt).join(""))}function hc(e,t=", ",r=" and "){return!e||!e.length?"":e.length===1?e[0]:e.length===2?`${e[0]}${r}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${r}${e[e.length-1]}`}function mc(e,t){return t+e.split("").join(t)+t}function pc(e){return ur(e).replace(/-/g,"_").toUpperCase()}function Rt(e,t){if(t.length===0)return 0;const r=e.toLowerCase(),s=t.toLowerCase();return e===t?1e4:r.startsWith(s)?1e4-e.length:r.includes(s)?5e3-e.length:new RegExp(".*"+s.split("").join(".*")+".*").test(r)?1e3-e.length:0}function gc(e,t){return e.filter(r=>Rt(r,t)).sort((r,s)=>Rt(s,t)-Rt(r,t))}function yc(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const vc={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function wc(e){let t=e.replace(/&#(\d+);/g,(r,s)=>String.fromCharCode(s)).replace(/&#x(\d+);/g,(r,s)=>String.fromCharCode(parseInt(s,16)));for(const[r,s]of Object.entries(vc))t=t.replaceAll(r,s);return t}function us(e,t){const r=e.indexOf(t);return r===-1?null:e.slice(0,r)}function lr(e,t){const r=e.indexOf(t);return r===-1?null:e.slice(r+t.length)}function dr(e,t){const r=e.lastIndexOf(t);return r===-1?null:e.slice(0,r)}function ls(e,t){const r=e.lastIndexOf(t);return r===-1?null:e.slice(r+t.length)}function _c(e,t,r){const s=dr(e,r);return s?lr(s,t):null}function bc(e,t,r){const s=lr(e,t);return s?us(s,r):null}function fr(e,t,r=!1){const s=r?e.lastIndexOf(t):e.indexOf(t);return s===-1?r?[null,e]:[e,null]:[e.slice(0,s),e.slice(s+t.length)]}function ds(e,t){let r=[e];for(const s of t)r=r.flatMap(o=>o.split(s));return r.filter(s=>s)}function hr(e){const t=it(e.split(/\\|\//g)),r=t.lastIndexOf(".",t.length-1);return r<=0?"":t.slice(r+1)}function mr(e){const t=it(e.split(/\\|\//g)),r=t.lastIndexOf(".",t.length-1);return r<=0?t:t.slice(0,r)}function xc(e){let[t,r]=e.split("@");t=ot(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[s]=t.split("+");if(!s||!r||r.indexOf(".")===-1||r.indexOf(".")===r.length-1)throw new Error("Invalid email");return r=ot(r.toLowerCase()).replaceAll(" ",""),`${s}@${r}`}function kc(e){const t=mr(e),r=hr(e);return r?`${t}.${r}`:t}function Ec(e){const t=mr(e),r=hr(e);return{basename:t,extension:r,filename:r?`${t}.${r}`:t}}function Tc(e,t=Math.random){return e.replace(/\{(.+?)\}/g,(r,s)=>rr(s.split("|"),t))}function fs(e){const t=/\{(.+?)\}/,r=e.match(t);if(!r||!r.index)return[e];const s=r[1].split(","),o=e.slice(0,r.index),d=e.slice(r.index+r[0].length);let f=[];for(const g of s){const p=fs(o+g+d);f=f.concat(p)}return f}function ot(e){return e.split(`
3
+ `).map(t=>t.trim().replace(/\s+/g," ")).filter(t=>t.length>0).join(`
4
+ `)}function Dt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hs(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ms(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ps(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function ct(e){return ms(e)||ps(e)}const Ac=`
5
+ \r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function Sc(e){return Ac.includes(e)}function Oc(e){return ct(e)||e==="."||e==="["||e==="]"||e==="_"}function Ic(e,t,r,s,o){return e.slice(0,t)+s+e.slice(t,t+r)+o+e.slice(t+r)}function gs(e,t,r=0){const s=t.exec(e.slice(r));return s?{index:s.index,match:s[0]}:null}function ys(e,t,r=!0){if(!r)return t.every(o=>o instanceof RegExp?o.test(e):e.indexOf(o,0)!==-1);let s=0;for(const o of t)if(o instanceof RegExp){const d=gs(e,o,s);if(!d)return!1;s=d.index+d.match.length}else{const d=e.indexOf(o,s);if(d===-1)return!1;s=d+o.length}return!0}function Mc(e,t,r=!0){let s=0;for(const o of t){let d=!1;for(;!d&&s<e.length;)ys(e[s],o,r)&&(d=!0),s++;if(!d)return!1}return!0}function $c(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e}function je(e,t,r=0){let s=-1;for(const o of t){const d=e.indexOf(o,r);d!==-1&&(s===-1||d<s)&&(s=d)}return s}function Cc(e,t=0){for(let r=t;r<e.length;r++)if(Sc(e[r]))return r;return-1}function Nc(e,t=0){for(let r=t;r<e.length;r++)if(e[r]==="#"&&ct(e[r+1]))return r;return-1}function vs(e,t,r=0){return e.slice(0,r).lastIndexOf(t)}function ws(e,t=0,r="{",s="}"){let o=1;for(let d=t;d<e.length;d++)if(e.slice(d,d+s.length)===s){if(--o===0)return d}else e.slice(d,d+r.length)===r&&o++;return-1}function _s(e,t){const r=t.wordBoundary?je(e,[`${t.opening} `,`${t.opening}
6
+ `],t.start||0):e.indexOf(t.opening,t.start||0);if(r===-1)return null;const s=ws(e,r+t.opening.length,t.opening,t.closing);return s===-1?null:t.exclusive?e.slice(r+t.opening.length,s):e.slice(r,s+t.closing.length)}function Rc(e,t){const r=[];let s=t.wordBoundary?je(e,[`${t.opening} `,`${t.opening}
7
+ `],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(s===-1)return r;const o=_s(e,{...t,start:s});if(!o)return r;r.push(o),s=t.wordBoundary?je(e,[`${t.opening} `,`${t.opening}
8
+ `],s+o.length):e.indexOf(t.opening,s+o.length)}}function Dc(e,t,r){let s=0;for(;;){const o=a.Strings.extractBlock(e,{...r,start:s});if(!o)return e;const d=t(o);s=e.indexOf(o,s)+d.length,e=e.replace(o,d)}}function jc(e,t){const r=[];let s=0;for(;s<e.length;){const o=e.indexOf(t,s);if(o===-1){r.push({string:e.slice(s),symbol:null});break}const d=e.indexOf(t,o+t.length);if(o>s&&d!==-1&&r.push({string:e.slice(s,o),symbol:null}),d===-1){r.push({string:e.slice(s),symbol:null});break}r.push({string:e.slice(o+t.length,d),symbol:t}),s=d+t.length}return r}function Uc(e){const t=[];let r=0;for(;r<e.length;){const s=Nc(e,r);if(s===-1){t.push({string:e.slice(r),symbol:null});break}const o=Cc(e,s+1);if(o===-1){t.push({string:e.slice(r,s),symbol:null}),t.push({string:e.slice(s+1),symbol:"#"});break}s>r&&t.push({string:e.slice(r,s),symbol:null}),t.push({string:e.slice(s+1,o),symbol:"#"}),r=o}return t}function Pc(e){const t=[];let r=0;for(;r<e.length;){const s=je(e,["http://","https://"],r);if(s===-1){t.push({string:e.slice(r),symbol:null});break}const o=je(e,[" ",`
9
+ `],s);if(o===-1){s>r&&t.push({string:e.slice(r,s),symbol:null}),t.push({string:e.slice(s),symbol:"http"});break}s>r&&t.push({string:e.slice(r,s),symbol:null}),t.push({string:e.slice(s,o),symbol:"http"}),r=o}return t}const bs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xs="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Zc(e){return ks(e,bs)}function Bc(e){return Es(e,bs)}function Lc(e){return ks(e,xs)}function zc(e){return Es(e,xs)}function ks(e,t){const r="=",s=t.length;let o=0,d=0;const f=[];for(let g=0;g<e.length;g++){const p=e[g];if(p===r)break;const k=t.indexOf(p);if(k===-1)throw new Error(`Invalid character: ${p}`);d=d<<Math.log2(s)|k,o+=Math.log2(s),o>=8&&(o-=8,f.push(d>>o&255))}return new Uint8Array(f)}function Es(e,t){const r=t.length;let s=0,o=0,d="";for(let f=0;f<e.length;f++)for(o=o<<8|e[f],s+=8;s>=Math.log2(r);)s-=Math.log2(r),d+=t[o>>s&r-1];return s>0&&(d+=t[o<<Math.log2(r)-s&r-1]),d.length%4!==0&&(d+="=".repeat(4-d.length%4)),d}function Fc(e){e.startsWith("0x")&&(e=e.slice(2));const t=e.length/2,r=new Uint8Array(t);for(let s=0;s<t;s++){const o=parseInt(e.slice(s*2,s*2+2),16);r[s]=o}return r}function Vc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Wc(e,t){const r=e.split("/").filter(d=>d),s=t.split("/").filter(d=>d);if(r.length!==s.length)return null;const o={};for(let d=0;d<r.length;d++){const f=r[d];if(f.startsWith(":"))o[f.slice(1)]=s[d];else if(f!==s[d])return null}return o}function pr(e,t,r){const s=[];for(const o of r)o!==t&&s.push(e.replace(t,o));return s}function Hc(e,t,r,s=Math.random){const o=a.Arrays.shuffle(t.map(f=>({variants:a.Arrays.shuffle(f.variants.map(g=>g),s),avoid:f.avoid})),s),d=[];for(const f of o){const g=f.variants.filter(k=>k!==f.avoid),p=g.find(k=>e.includes(k));if(p&&(Nt(d,pr(e,p,g)),d.length>=r))break}if(d.length<r)for(const f of o){const g=f.variants.find(p=>e.includes(p));if(g&&(Nt(d,pr(e,g,f.variants)),d.length>=r))break}return d.slice(0,r)}function qc(e,t,r,s=!1){const o=new RegExp(s?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,r)}function Gc(e,t){const r=/\b[A-Z][a-zA-Z0-9]*\b/g;return e.replace(r,s=>s.toUpperCase()===s?s:t(s))}function Kc(e){return e.replace(/<[^>]*>/g,"")}function Ts(e){const t=e.lastIndexOf(" ");if(t===-1)return{line:e,rest:""};const r=e.slice(0,t),s=e.slice(t+1);return{line:r,rest:s}}function Yc(e,t={}){return[...e].reduce((r,s)=>r+(t[s]||1),0)}function Qc(e,t,r={}){const s=[];let o="",d=0;for(let f=0;f<e.length;f++){const g=e[f],p=r[g]||1;if(o+=g,d+=p,d>t){const{line:k,rest:$}=Ts(o);s.push(k),o=$,d=$.split("").map(U=>r[U]||1).reduce((U,Be)=>U+Be,0)}}return o&&s.push(o),s}function Xc(e,t){const r=[];for(let s=0;s<=e.length;s++)r[s]=[s];for(let s=0;s<=t.length;s++)r[0][s]=s;for(let s=1;s<=e.length;s++)for(let o=1;o<=t.length;o++){const d=e[s-1]===t[o-1]?0:1;r[s][o]=Math.min(r[s-1][o]+1,r[s][o-1]+1,r[s-1][o-1]+d)}return r[e.length][t.length]}function gr(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Jc(e,t,r){return r==="any"?t.some(s=>gr(e,s)):t.every(s=>gr(e,s))}function eu(e){const t={},r=e.match(/([a-z\-]+)="([^"]+)"/g);if(r)for(const s of r){const[o,d]=fr(s,"=");t[o]=d.slice(1,d.length-1)}return t}function jt(e,t,r=[]){let s="";for(;t<e.length&&(ct(e[t])||r.includes(e[t]));)s+=e[t++];return s}function tu(e,t,r="$",s=":"){for(const o in t)e=As(e,o,t[o],r,s);return e=Ss(e),e}function As(e,t,r,s="$",o=":"){if(r==="")return e;let d=e.indexOf(`${s}${t}`);for(;d!==-1;){if(e[d+t.length+1]===o)if(e[d+t.length+2]===o)e=e.replace(`${s}${t}${o}${o}`,r);else{const f=jt(e,d+t.length+2,["_"]);e=e.replace(`${s}${t}${o}${f}`,r)}else e=e.replace(`${s}${t}`,r);d=e.indexOf(`${s}${t}`,d+r.length)}return e}function Ss(e,t="$",r=":"){let s=e.indexOf(t);for(;s!==-1;){const o=jt(e,s+1);if(e[s+o.length+1]===r)if(e[s+o.length+2]===r)e=e.replace(`${t}${o}${r}${r}`,"");else{const d=jt(e,s+o.length+2);e=e.replace(`${t}${o}${r}${d}`,d)}s=e.indexOf(t,s+1)}return e}function ru(e,t){let r=e.indexOf("](");for(;r!==-1;){const s=vs(e,"[",r),o=e.indexOf(")",r);if(s!==-1&&o!==-1){const[d,f]=e.slice(s+1,o).split("]("),g=t(d,f);e=e.slice(0,s)+g+e.slice(o+1)}r=e.indexOf("](",r+1)}return e}function Os(e,t=!0){const r=Object.entries(e).filter(([s,o])=>o!=null).map(([s,o])=>`${s}=${encodeURIComponent(o)}`).join("&");return r?(t?"?":"")+r:""}function nu(e){const t={},r=e.split("&");for(const s of r){const[o,d]=s.split("=");o&&d&&(t[o]=decodeURIComponent(d))}return t}function su(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function iu(e,t){let r=null,s=-1/0;for(const[o,d]of Object.entries(e)){const f=t(d);f>s&&(s=f,r=o)}return r?[r,e[r]]:null}function au(e,t,r,s){const o=e.find(f=>f[t]===r),d=e.find(f=>f[t]===r+s);o&&d?(o[t]=r+s,d[t]=r):o&&(o[t]=r+s),e.sort((f,g)=>$t(f[t])-$t(g[t])),e.forEach((f,g)=>f[t]=g+1)}function ou(e){const t=Object.keys(e);if(t.length===1)return e[t[0]];throw new Error("Expected object to have a single key")}function cu(e,t=":"){return Object.fromEntries(e.map(r=>fr(r,t)).map(r=>r[0]&&r[1]?[ot(r[0]),ot(r[1])]:null).filter(r=>r))}function uu(e,t,r){return Cs(e,t)+Os(r||{})}function lu(e,t=",",r='"'){const s=[];let o="",d=!1;const f=e.split("");for(const g of f)g===t&&!d?(s.push(o),o=""):g===r&&(!o&&!d||d)?d=!d:o+=g;return s.push(o),s}function du(e){return`[${Math.floor(e.progress*100)}%] ${Ut(e.deltaMs)} out of ${Ut(e.totalTimeMs)} (${Ut(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`}async function fu(e,t,r){for(let s=0;s<r;s++){try{if(await e())return!0}catch{}s<r-1&&await l(t)}return!1}function hu(e,t){const r=[];for(let s=e.length-1;s>=0;s--)t(e[s])&&r.push(e.splice(s,1)[0]);return r}function mu(e){return JSON.parse(JSON.stringify(e))}function pu(e){return Math.ceil((e||Date.now())/1e3)}function gu(e){return(e||new Date).toISOString().slice(0,10)}function yu(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function vu(e){const t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4)}function wu(e){return new Date(e)}function ee(e){return String(Math.floor(e)).padStart(2,"0")}function _u(e){let[t,r]=e.split(":");me(parseInt(t,10))||(t="0"),me(parseInt(r,10))||(r="0");let s=br(cr(t),0,23),o=br(cr(r),0,59);return`${ee(s)}:${ee(o)}`}function Ut(e){const t=Math.floor(e/36e5);e=e%36e5;const r=Math.floor(e/6e4);e=e%6e4;const s=Math.floor(e/1e3);return t?`${ee(t)}:${ee(r)}:${ee(s)}`:`${ee(r)}:${ee(s)}`}function Ee(e){return Math.floor((De(e)?e.getTime():e)/864e5)}const bu={today:(e,t)=>ee(e)+":"+ee(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`};function xu(e,t){const r=new Date((t==null?void 0:t.now)||Date.now()),s=(t==null?void 0:t.labels)||bu,o=De(e)?e:new Date(e);if(Ee(r)===Ee(o))return s.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ee(r)-Ee(o)===1)return s.yesterday();const d=vr(o);return Ee(r)-Ee(o)<7?s[d.day]():s.weeks(Math.round((r.getTime()-o.getTime())/6048e5))}const Is={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ms(e,t){const r=(t==null?void 0:t.now)??Date.now(),s=(t==null?void 0:t.labels)||Is,o=a.Types.isDate(e)?e.getTime():e;let d=(r-o)/1e3;return d<10?s.now():d<120?s.seconds(Math.floor(d)):(d/=60,d<120?s.minutes(Math.floor(d)):(d/=60,d<48?s.hours(Math.floor(d)):(d/=24,d<14?s.days(Math.floor(d)):(d/=7,s.weeks(Math.floor(d))))))}function ku(e,t=Is){return Ms(0,{now:e*1e3,labels:t})}function Eu(e,t,r){const s=((r==null?void 0:r.now)??Date.now())-e,o=Math.floor(s/t),d=t/((r==null?void 0:r.precision)??1)-Math.ceil(s%t/((r==null?void 0:r.precision)??1));return{cycles:o,remaining:d}}const yr={};function Tu(e,t){return!yr[e]||Date.now()>yr[e]?(yr[e]=Date.now()+t,!0):!1}const Au={s:1e3,m:6e4,h:36e5,d:864e5};function Su(e,t,r){return t=De(t)?t.getTime():t,r=r?De(r)?r.getTime():r:Date.now(),(r-t)/Au[e]}function Ou(e,t,r,s){s||(s=Date.now());const o=t/r,d=s-e,f=d/t,g=f*r,p=g-d;return{deltaMs:d,progress:o,baseTimeMs:f,totalTimeMs:g,remainingTimeMs:p}}const Iu={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function $s(e){return{zeroBasedIndex:e,day:Iu[e]}}function vr(e){return $s(e.getDay())}function Mu(e){return vr(new Date(e))}function $u(e){return e*1e3}function Cu(e){return e*6e4}function Nu(e){return e*36e5}function Ru(e){return e*864e5}const Du={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function ju(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),s=Du[r];if(!s)throw Error(`Unknown unit: "${r}"`);return t*s}const Uu={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function Pu(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),s=Uu[r];if(!s)throw Error(`Unknown unit: "${r}"`);return t*s}function Zu(e){return e.replace(/ +/g," ").replace(/^ /gm,"")}const wr={};async function Bu(e,t,r){const s=Date.now(),o=wr[e];if(o&&o.validUntil>s)return o.value;const d=await r(),f=s+t;return wr[e]={value:d,validUntil:f},d}function Lu(e){delete wr[e]}function Cs(...e){return e.filter(t=>t).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function zu(e,t,r,s,o=!0){const d=e.indexOf(t),f=e.indexOf(r,d+t.length);if(d===-1||f===-1)throw Error("Start or end not found");return o?e.substring(0,d+t.length)+s+e.substring(f):e.substring(0,d)+s+e.substring(f+r.length)}function Fu(e){let t="p";e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim());const r=e[0]===e[0].toUpperCase(),s=/[.?!]$/.test(e),o=/:$/.test(e);return{type:t,isCapitalized:r,hasPunctuation:s,endsWithColon:o}}function Vu(e,t="(",r=")"){let s=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(s++,o+=t.length):e.startsWith(r,o)?(s--,o+=r.length):o++,s<0)return!1;return t===r?s%2===0:s===0}function Wu(e){e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let t=e.length;for(;e=e.replace(/(\w+)[\s,']+\w+/g,"$1"),e.length!==t;)t=e.length;return e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),e=e.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),e=e.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),e}function Ns(e){const t=Object.keys(e).sort((s,o)=>s.localeCompare(o)),r={};for(const s of t)r[s]=Te(e[s]);return r}function Rs(e){const t=[];return e.sort((r,s)=>JSON.stringify(Te(r)).localeCompare(JSON.stringify(Te(s)))).forEach(r=>t.push(Te(r))),t}function Te(e){return Array.isArray(e)?Rs(e):he(e)?Ns(e):e}function Ds(e,t){return JSON.stringify(Te(e))===JSON.stringify(Te(t))}function Hu(...e){for(let t=1;t<e.length;t++)if(!Ds(e[t-1],e[t]))return!1;return!0}function qu(e){try{return JSON.parse(e)}catch{return null}}function Gu(){let e=0;return{next:()=>e++}}function Ku(e){let t=0;return{next:()=>e[t++%e.length]}}function Yu(e){let t;return r=>{const s=r===e&&t!==e;return t=r,s}}function Qu(e,t,r,s,o){const d={};for(const f of Object.keys(t))d[f]=[];d[s]=[],o&&(e=e.sort(o));for(const f of e){const g=f[r],p=t[g]?g:s;d[p].length>=t[p]?d[s].push(f):d[p].push(f)}return d}function Xu(e,t){const r=Object.keys(e),s=Object.keys(t);return{uniqueToA:r.filter(o=>!s.includes(o)),uniqueToB:s.filter(o=>!r.includes(o))}}function js(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}function Ju(e,t){const r=js(e);return e[r]=t(e[r]),r}function el(e){return e=e.replace(/\r\n/g,`
10
+ `),e=e.replace(/(\w+)\((.+)\)/g,(t,r,s)=>`${r}(${s.replaceAll(",","&comma;")})`),e=e.replace(/(,)(\s+})/g,"$2"),e=e.replace(/\.\.\..+?,/g,""),e=e.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),e=e.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),e=e.replace(/:(.+)\?(.+):/g,(t,r,s)=>`: (${r.trim()} && ${s.trim()}) ||`),e=e.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),e=e.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(t,r,s,o)=>`"${r}":"${s.trim()}"${o}`),e=e.replace(/("'|'")/g,'"'),e=e.replaceAll("&comma;",","),JSON.parse(e)}const pe=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],tl=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],Us=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function rl(e,t,r){let s=e.length-t;if(s<=0)return"0."+"0".repeat(-s)+e+(r?" "+r:"");let o=e.substring(0,s),d=e.substring(s);return o===""&&(o="0"),o+"."+d+(r?" "+r:"")}function nl(e,t){const r=(t==null?void 0:t.longForm)??!1,s=t!=null&&t.unit?` ${t.unit}`:"",o=r?tl:Us,d=(t==null?void 0:t.precision)??1;if(e<pe[0])return`${e}${s}`;for(let f=0;f<pe.length-1;f++)if(e<pe[f+1])return`${(e/pe[f]).toFixed(d)}${r?" ":""}${o[f]}${s}`;return`${(e/pe[pe.length-1]).toFixed(d)}${r?" ":""}${o[pe.length-1]}${s}`}function _r(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim(),s=Us.findIndex(o=>o.toLowerCase()===r.toLowerCase());return s===-1?t:t*pe[s]}function br(e,t,r){return e<t?t:e>r?r:e}function sl(e,t,r){const s=e+t;return s>r?r:s}function il(e,t,r){const s=e-t;return s<r?r:s}function al(e,t){return t(e),e}function ol(e,t){e&&t(e)}function cl(e,t){const r=Object.keys(t);for(const s of r)Array.isArray(t[s])&&Array.isArray(e[s])&&Nt(e[s],t[s])}function ul(e){return e.splice(0,e.length),e}function ll(e){for(const t of Object.keys(e))(Yn(e[t])||Array.isArray(e[t])&&e[t].every(r=>r==null))&&delete e[t];return e}function dl(e){for(const t of Object.entries(e))(t[1]===null||t[1]===void 0||V(t[1])&&Mt(t[1]))&&delete e[t[0]];return e}function fl(e,t){const r={};for(const[s,o]of Object.entries(e))t(s)&&(r[s]=o);return r}function hl(e,t){const r={};for(const[s,o]of Object.entries(e))t(o)&&(r[s]=o);return r}function ml(e,t){const r={};for(const s of Object.entries(e))r[s[0]]=t(s[1]);return r}function pl(e,t){const r=[];let s=0;for(const o of e)r.push(t(o,s++));return r}async function gl(e,t){try{return await e()}catch{throw t}}function yl(e,t,r){r!=null&&(e[t]=r)}function vl(e,t,r,s){const o=be(r,s);o!=null&&xe(e,t,o)}function wl(e){const t={};for(const[r,s]of Object.entries(e))t[s]=r;return t}function _l(e){const t=Object.keys(e),r=t.map(g=>e[g].length),s=r.reduce((g,p)=>g*=p);let o=1;const d=[1];for(let g=0;g<r.length-1;g++)o*=r[g],d.push(o);const f=[];for(let g=0;g<s;g++){const p={};for(let k=0;k<t.length;k++){const $=e[t[k]],U=Math.floor(g/d[k])%$.length;p[t[k]]=$[U]}f.push(p)}return f}function bl(e){return Object.values(e).filter(t=>t).length}function xl(e,t,r){return e+(r?"["+t+"]":(e.length?".":"")+t)}function Pt(e,t,r,s,o){if(!he(t))return t;for(const[d,f]of Object.entries(t)){const g=xl(r,d,s);Array.isArray(f)?o?Pt(e,f,g,!0,o):e[g]=f.map(p=>Pt(Array.isArray(p)?[]:{},p,"",!1,o)):he(f)?Pt(e,f,g,!1,o):e[g]=f}return e}function kl(e,t=!1,r){return Pt({},e,r||"",!1,t)}function Ps(e){if(!he(e))return e;const t=Array.isArray(e)?[]:{};for(const[r,s]of Object.entries(e))Array.isArray(s)?xe(t,r,s.map(o=>Ps(o))):xe(t,r,s);return t}function El(e,t,r){return t[e]?t[e]:r}function Zs(e,t){const r={};for(const s of e){const o=t(s);r[o]=s}return r}function Tl(e,t){const r={};for(const s of e){const o=t(s);r[o]||(r[o]=[]),r[o].push(s)}return r}function Al(e,t){const r=[];for(let s=0;s<e.length;s+=t)r.push(e.slice(s,s+t));return r}function Bs(e,t){const r=Math.ceil(e.length/t),s=[];for(let o=0;o<e.length;o+=r)s.push(e.slice(o,o+r));return s}function Ls(e,t){const r=[],s=Math.ceil(e.length/t);for(let o=0;o<s;o++)r.push(e.slice(o*t,o*t+t));return r}function Sl(e,t){const r=Math.ceil(e.length/t);return Ls(e,r)}function Ol(e,t){return Object.values(Zs(e,t))}function Il(e,t,r,s,o){const d=t?e.map(t):e,f={};for(const p of d)f[p]=(f[p]||0)+1;const g=s?zs(f,o?(p,k)=>p[1]-k[1]:(p,k)=>k[1]-p[1]):f;return r?Object.keys(g):g}function zs(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function Ml(e){const t=[],r=Object.keys(e),s=e[r[0]].length;for(let o=0;o<s;o++){const d={};for(const f of r)d[f]=e[f][o];t.push(d)}return t}function $l(e,t,r=1){for(const s of e)s[t]+=r}function Cl(e,t,r){for(const s of e)s[t]=r}function xr(e,t){const r=[];let s=[];return e.forEach((o,d)=>{(d===0||!t(o,e[d-1]))&&(s=[],r.push(s)),s.push(o)}),r}function Nl(){return{map:new Map,keys:[]}}function Rl(){return{map:new Map,keys:[]}}function Fs(e,t,r,s=100){if(e.map.has(t)){const o=e.keys.indexOf(t);e.keys.splice(o,1)}if(e.map.set(t,r),e.keys.push(t),e.keys.length>s){const o=e.keys.shift();o&&e.map.delete(o)}}function Dl(e,t,r,s=100){if(e.map.has(t)){const o=e.keys.indexOf(t);e.keys.splice(o,1)}if(e.map.set(t,r),e.keys.unshift(t),e.keys.length>s){const o=e.keys.shift();o&&e.map.delete(o)}}function jl(e,t,r,s,o=100){Fs(e,t,{validUntil:Date.now()+s,data:r},o)}function Ul(e,t){const r=e.map.get(t);return r&&r.validUntil>Date.now()?r.data:null}class ge{constructor(t){this.value=t}static of(t){return new ge(t)}static empty(){return new ge(null)}map(t){return new ge(this.value!==null&&this.value!==void 0?t(this.value):null)}mapAsync(t){return this.value!==null&&this.value!==void 0?t(this.value).then(r=>ge.of(r)):Promise.resolve(ge.empty())}ifPresent(t){return this.value!==null&&this.value!==void 0&&t(this.value),this}ifPresentAsync(t){return this.value!==null&&this.value!==void 0?t(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(t){return(this.value===null||this.value===void 0)&&t(),this}ifAbsentAsync(t){return this.value===null||this.value===void 0?t().then(()=>this):Promise.resolve(this)}getOrFallback(t){return this.value??t()}getOrFallbackAsync(t){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):t()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}a.Optional=ge;class Pl{constructor(t){this.supplier=t,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}a.Lazy=Pl;class Zl{constructor(t){this.supplier=t,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}a.AsyncLazy=Zl;function Bl(e){return()=>e.forEach(t=>t())}function Ll(e,t){return e.reduce((r,s)=>t(r)>t(s)?r:s)}function zl(e,t){const r=e.find(s=>s instanceof t);return ge.of(r)}function Fl(e,t){return e.filter(r=>r instanceof t)}function Vl(e,t){const r=[],s=Math.max(e.length,t.length);for(let o=0;o<s;o++)e[o]&&r.push(e[o]),t[o]&&r.push(t[o]);return r}function Wl(e,t){return e.includes(t)?e.filter(r=>r!==t):[...e,t]}class Hl{constructor(t){this.value=t,this.children=[]}}function ql(e,t,r,s,o=!1){const d=new Map,f=[];e.forEach(p=>{const k=new Hl(p);d.set(p[t],k)}),e.forEach(p=>{const k=d.get(p[t]);if(!k)return;const $=p[r];if($){const U=d.get($);U&&U.children.push(k)}else f.push(k)});const g=p=>{p.children.sort((k,$)=>{const U=k.value[s],Be=$.value[s];return o?Be-U:U-Be}),p.children.forEach(g)};return f.forEach(g),f}function Vs(e,t){if(Math.log2(e.length)%1!==0)throw new Error("Array length must be a power of 2");let r=[...e];for(;r.length>1;){const s=[];for(let o=0;o<r.length;o+=2){const d=r[o+1];s.push(t(r[o],d))}r=s}return r[0]}function Ue(...e){const t=e.reduce((o,d)=>o+d.length,0),r=new Uint8Array(t);let s=0;return e.forEach(o=>{r.set(o,s),s+=o.length}),r}function Ws(e){return e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71}function Hs(e){return e[0]===255&&e[1]===216}function qs(e){return e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}function Gl(e){return Ws(e)||Hs(e)||qs(e)}function Kl(e){return new Uint8Array([e])}function Yl(e){return e[0]}function Ql(e,t){const r=new ArrayBuffer(2);return new DataView(r).setUint16(0,e,t==="LE"),new Uint8Array(r)}function Xl(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,t==="LE")}function Jl(e,t){const r=new ArrayBuffer(4);return new DataView(r).setUint32(0,e,t==="LE"),new Uint8Array(r)}function ed(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,t==="LE")}function kr(e,t){const r=new ArrayBuffer(8);return new DataView(r).setBigUint64(0,BigInt(e),t==="LE"),new Uint8Array(r)}function td(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,t==="LE")}function Pe(e,t){const r=new Uint8Array(32);let s=e;if(t==="LE"){for(let o=0;o<32;o++)r[o]=Number(s&0xffn),s>>=8n;return r}for(let o=31;o>=0;o--)r[o]=Number(s&0xffn),s>>=8n;return r}function Ze(e,t){let r=0n;if(t==="LE"){for(let s=31;s>=0;s--)r=r<<8n|BigInt(e[s]);return r}for(let s=0;s<32;s++)r=r<<8n|BigInt(e[s]);return r}function rd(e,t){const r=[];let s=0;for(const o of t)r.push(e.subarray(s,s+o)),s+=o;return r}function Er(e,t){const r=[];for(let s=0;s<e.length;s+=t)r.push(e.subarray(s,s+t));return r}const Gs=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function nd(e){for(let t=0;t<24;t++){const r=e[0]^e[10]^e[20]^e[30]^e[40],s=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],d=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],g=e[5]^e[15]^e[25]^e[35]^e[45],p=e[6]^e[16]^e[26]^e[36]^e[46],k=e[7]^e[17]^e[27]^e[37]^e[47],$=e[8]^e[18]^e[28]^e[38]^e[48],U=e[9]^e[19]^e[29]^e[39]^e[49],Be=o<<1|d>>>31,Zd=d<<1|o>>>31,dt=$^Be,ft=U^Zd,Bd=f<<1|g>>>31,Ld=g<<1|f>>>31,ht=r^Bd,mt=s^Ld,zd=p<<1|k>>>31,Fd=k<<1|p>>>31,pt=o^zd,gt=d^Fd,Vd=$<<1|U>>>31,Wd=U<<1|$>>>31,yt=f^Vd,vt=g^Wd,Hd=r<<1|s>>>31,qd=s<<1|r>>>31,wt=p^Hd,_t=k^qd;e[0]^=dt,e[1]^=ft,e[2]^=ht,e[3]^=mt,e[4]^=pt,e[5]^=gt,e[6]^=yt,e[7]^=vt,e[8]^=wt,e[9]^=_t,e[10]^=dt,e[11]^=ft,e[12]^=ht,e[13]^=mt,e[14]^=pt,e[15]^=gt,e[16]^=yt,e[17]^=vt,e[18]^=wt,e[19]^=_t,e[20]^=dt,e[21]^=ft,e[22]^=ht,e[23]^=mt,e[24]^=pt,e[25]^=gt,e[26]^=yt,e[27]^=vt,e[28]^=wt,e[29]^=_t,e[30]^=dt,e[31]^=ft,e[32]^=ht,e[33]^=mt,e[34]^=pt,e[35]^=gt,e[36]^=yt,e[37]^=vt,e[38]^=wt,e[39]^=_t,e[40]^=dt,e[41]^=ft,e[42]^=ht,e[43]^=mt,e[44]^=pt,e[45]^=gt,e[46]^=yt,e[47]^=vt,e[48]^=wt,e[49]^=_t;const Mr=e[0],$r=e[1],Cr=e[2]<<1|e[3]>>>31,Nr=e[3]<<1|e[2]>>>31,Rr=e[5]<<30|e[4]>>>2,Dr=e[4]<<30|e[5]>>>2,jr=e[6]<<28|e[7]>>>4,Ur=e[7]<<28|e[6]>>>4,Pr=e[8]<<27|e[9]>>>5,Zr=e[9]<<27|e[8]>>>5,Br=e[11]<<4|e[10]>>>28,Lr=e[10]<<4|e[11]>>>28,zr=e[13]<<12|e[12]>>>20,Fr=e[12]<<12|e[13]>>>20,Vr=e[14]<<6|e[15]>>>26,Wr=e[15]<<6|e[14]>>>26,Hr=e[17]<<23|e[16]>>>9,qr=e[16]<<23|e[17]>>>9,Gr=e[18]<<20|e[19]>>>12,Kr=e[19]<<20|e[18]>>>12,Yr=e[20]<<3|e[21]>>>29,Qr=e[21]<<3|e[20]>>>29,Xr=e[22]<<10|e[23]>>>22,Jr=e[23]<<10|e[22]>>>22,en=e[25]<<11|e[24]>>>21,tn=e[24]<<11|e[25]>>>21,rn=e[26]<<25|e[27]>>>7,nn=e[27]<<25|e[26]>>>7,sn=e[29]<<7|e[28]>>>25,an=e[28]<<7|e[29]>>>25,on=e[31]<<9|e[30]>>>23,cn=e[30]<<9|e[31]>>>23,un=e[33]<<13|e[32]>>>19,ln=e[32]<<13|e[33]>>>19,dn=e[34]<<15|e[35]>>>17,fn=e[35]<<15|e[34]>>>17,hn=e[36]<<21|e[37]>>>11,mn=e[37]<<21|e[36]>>>11,pn=e[38]<<8|e[39]>>>24,gn=e[39]<<8|e[38]>>>24,yn=e[40]<<18|e[41]>>>14,vn=e[41]<<18|e[40]>>>14,wn=e[42]<<2|e[43]>>>30,_n=e[43]<<2|e[42]>>>30,bn=e[45]<<29|e[44]>>>3,xn=e[44]<<29|e[45]>>>3,kn=e[47]<<24|e[46]>>>8,En=e[46]<<24|e[47]>>>8,Tn=e[48]<<14|e[49]>>>18,An=e[49]<<14|e[48]>>>18;e[0]=Mr^~zr&en,e[1]=$r^~Fr&tn,e[2]=zr^~en&hn,e[3]=Fr^~tn&mn,e[4]=en^~hn&Tn,e[5]=tn^~mn&An,e[6]=hn^~Tn&Mr,e[7]=mn^~An&$r,e[8]=Tn^~Mr&zr,e[9]=An^~$r&Fr,e[10]=jr^~Gr&Yr,e[11]=Ur^~Kr&Qr,e[12]=Gr^~Yr&un,e[13]=Kr^~Qr&ln,e[14]=Yr^~un&bn,e[15]=Qr^~ln&xn,e[16]=un^~bn&jr,e[17]=ln^~xn&Ur,e[18]=bn^~jr&Gr,e[19]=xn^~Ur&Kr,e[20]=Cr^~Vr&rn,e[21]=Nr^~Wr&nn,e[22]=Vr^~rn&pn,e[23]=Wr^~nn&gn,e[24]=rn^~pn&yn,e[25]=nn^~gn&vn,e[26]=pn^~yn&Cr,e[27]=gn^~vn&Nr,e[28]=yn^~Cr&Vr,e[29]=vn^~Nr&Wr,e[30]=Pr^~Br&Xr,e[31]=Zr^~Lr&Jr,e[32]=Br^~Xr&dn,e[33]=Lr^~Jr&fn,e[34]=Xr^~dn&kn,e[35]=Jr^~fn&En,e[36]=dn^~kn&Pr,e[37]=fn^~En&Zr,e[38]=kn^~Pr&Br,e[39]=En^~Zr&Lr,e[40]=Rr^~Hr&sn,e[41]=Dr^~qr&an,e[42]=Hr^~sn&on,e[43]=qr^~an&cn,e[44]=sn^~on&wn,e[45]=an^~cn&_n,e[46]=on^~wn&Rr,e[47]=cn^~_n&Dr,e[48]=wn^~Rr&Hr,e[49]=_n^~Dr&qr,e[0]^=Gs[t*2],e[1]^=Gs[t*2+1]}}function Ks(e){const t=[];for(let r=0;r<e.length;r+=4)t.push(e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24);return t}function Ys(e,t){if(!e.length){const o=new Uint8Array(136);return o[0]=t,o[135]=128,[Ks(o)]}const r=Er(e,136),s=r[r.length-1];if(s.length<136){const o=new Uint8Array(136);o.set(s),o[s.length]=t,o[135]|=128,r[r.length-1]=o}if(s.length===136){const o=new Uint8Array(136);o[0]=t,o[135]=128,r.push(o)}return r.map(Ks)}function Qs(e,t){for(const r of t){for(let s=0;s<34;s+=2)e[s]^=r[s+1],e[s+1]^=r[s];nd(e)}return e}function Xs(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function oe(e){return Xs(Qs(new Array(50).fill(0),Ys(e,1)))}function sd(e){return Xs(Qs(new Array(50).fill(0),Ys(e,6)))}function id(e,t,r){const s=Math.min(e.length,t.length,r/8+1);for(let o=0;o<s;o++){const d=e[o]^t[o];for(let f=0;f<8;f++)if(d>>7-f&1)return o*8+f}return r}function ad(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++)if(e[s]!==t[s])return e.subarray(0,s);return e.subarray(0,r)}function od(e,t,r,s){const o=Math.floor(t/8),d=t%8;r===1?e[o]|=1<<(s==="BE"?7-d:d):e[o]&=~(1<<(s==="BE"?7-d:d))}function cd(e,t,r){const s=Math.floor(t/8),o=t%8;return e[s]>>(r==="BE"?7-o:o)&1}function ud(e,t,r=0){for(let s=r;s<e.length;s++)for(let o=0;o<t.length&&e[s+o]===t[o];o++)if(o===t.length-1)return s;return-1}function Js(e,t,r=0){if(e.length>=t)return e;const s=new Uint8Array(t);return s.fill(r),s.set(e,t-e.length),s}function ld(e,t,r=0){const s=e.length%t;return s===0?e:Js(e,e.length+t-s,r)}function ei(e,t,r=0){if(e.length>=t)return e;const s=new Uint8Array(t);return s.fill(r),s.set(e,0),s}function dd(e,t,r=0){const s=e.length%t;return s===0?e:ei(e,e.length+t-s,r)}function fd(e,t){const r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e[s]^t[s%t.length];return r}function hd(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function C(e,t){return(e%t+t)%t}function ut(e,t){e=C(e,t);let[r,s]=[0n,1n],[o,d]=[t,e];for(;d!==0n;){const f=o/d;[r,s]=[s,r-f*s],[o,d]=[d,o-f*d]}if(o>1n)throw new Error("a is not invertible");return r<0n&&(r+=t),r}function md(e,t,r){let s=1n;for(e=C(e,r);t>0;)t%2n===1n&&(s=C(s*e,r)),e=C(e*e,r),t=t/2n;return s}function ti(e,t){return C(e,t)===0n?0n:t%4n===3n?md(e,(t+1n)/4n,t):null}const L=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,j=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Zt=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Bt=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Tr(e,t,r){if(t===0n)return[0n,0n];const s=C(3n*e*e*ut(2n*t,r),r),o=C(s*s-2n*e,r),d=C(s*(e-o)-t,r);return[o,d]}function Lt(e,t,r,s,o){if(e===0n&&t===0n)return[r,s];if(r===0n&&s===0n)return[e,t];if(e===r&&t===C(-s,o))return[0n,0n];if(e===r&&t===s)return Tr(e,t,o);const d=C((s-t)*ut(r-e,o),o),f=C(d*d-e-r,o),g=C(d*(e-f)-t,o);return[f,g]}function pd(e){if(e<=0n||e>=j)throw new Error("Invalid private key");return Ae(Zt,Bt,e,L)}function gd(e){const t=e[1]%2n===0n?2:3;return new Uint8Array([t,...Pe(e[0],"BE")])}function yd(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Invalid compressed public key");const t=Ze(e.slice(1),"BE"),r=ti(C(t**3n+7n,L),L);if(!r)throw Error("Invalid x: does not correspond to a valid curve point");const s=C(-r,L),o=r%2n===0n;return[t,e[0]===2?o?r:s:o?s:r]}function vd(e){const t=new Uint8Array(20),r=oe(Ue(Pe(e[0],"BE"),Pe(e[1],"BE")));return t.set(r.subarray(12)),t}function wd(e){const t=a.Binary.uint8ArrayToHex(e),r=a.Binary.uint8ArrayToHex(a.Binary.keccak256(new Uint8Array([...t].map(o=>o.charCodeAt(0)))));let s="0x";for(let o=0;o<t.length;o++)parseInt(r[o],16)>7?s+=t[o].toUpperCase():s+=t[o];return s}function Ae(e,t,r,s){let o=[0n,0n],d=[e,t];const f=r.toString(2);for(const g of f)g==="0"?(d=Lt(o[0],o[1],d[0],d[1],s),o=Tr(o[0],o[1],s)):(o=Lt(o[0],o[1],d[0],d[1],s),d=Tr(d[0],d[1],s));return o}function _d(e,t,r){return ri(Ze(oe(e),"BE"),t,r)}function ri(e,t,r){if(t<=0n||t>=j)throw new Error("Invalid private key");if(r||(r=C(Ze(oe(Ue(oe(Pe(t,"BE")),Pe(e,"BE"))),"BE"),j)),r<=0n||r>=j)throw new Error("Invalid nonce");const s=C(e,j),o=Ae(Zt,Bt,r,L),d=C(o[0],j);let f=C((s+C(d,j)*t)*ut(r,j),j);if(d===0n||f===0n)throw new Error("Invalid r or s value");let g=o[1]%2n===0n?27n:28n;return f>j/2n&&(f=j-f,g=g===27n?28n:27n),[d,f,g]}function bd(e,t,r,s){const o=ti(C(t**3n+7n,L),L);if(!o)throw new Error("Invalid r: does not correspond to a valid curve point");const d=s===27n?0n:1n,f=o%2n===d?o:L-o,g=C(Ze(oe(e),"BE"),j),p=Ae(t,f,r,L),k=Ae(Zt,Bt,g,L),$=Lt(p[0],p[1],k[0],C(-k[1],L),L);return Ae($[0],$[1],ut(t,j),L)}function xd(e,t,r,s){const o=C(Ze(oe(e),"BE"),j),d=ut(s,j),f=C(o*d,j),g=C(r*d,j),p=Ae(Zt,Bt,f,L),k=Ae(t[0],t[1],g,L),$=Lt(p[0],p[1],k[0],k[1],L);return r===C($[0],j)}class ni{constructor(t){this.cursor=0,this.buffer=t}read(t){const r=this.buffer.subarray(this.cursor,this.cursor+t);return this.cursor+=t,r}max(){return this.buffer.length-this.cursor}}a.Uint8ArrayReader=ni;class si{constructor(t){this.buffer=t,this.cursor=0}write(t){const r=Math.min(this.max(),t.max());return this.buffer.set(t.read(r),this.cursor),this.cursor+=r,r}max(){return this.buffer.length-this.cursor}}a.Uint8ArrayWriter=si;class zt{constructor(t,r=0n){this.span=r,this.writer=new si(new Uint8Array(t))}build(){return Ue(kr(this.span,"LE"),this.writer.buffer)}hash(){const t=Vs(Er(this.writer.buffer,32),(r,s)=>oe(Ue(r,s)));return oe(Ue(kr(this.span,"LE"),t))}}a.Chunk=zt;class Ar{constructor(t,r=4096){this.counters=[1],this.capacity=r,this.chunks=[new zt(r)],this.onChunk=t}static async root(t,r=4096){const s=new n(n.NOOP,r);return await s.append(t),s.finalize()}async append(t,r=0,s=0n){const o=new ni(t);for(;o.max()>0;){this.chunks[r].writer.max()===0&&await this.elevate(r);const d=this.chunks[r].writer.write(o);s?this.chunks[r].span+=s:this.chunks[0].span+=BigInt(d)}}async elevate(t){this.counters[t]=++this.counters[t]%(this.capacity/32),this.chunks[t+1]||(this.chunks.push(new zt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[t].hash(),t+1,this.chunks[t].span),await this.onChunk(this.chunks[t]),this.chunks[t]=new zt(this.capacity)}async finalize(t=0){return this.chunks[t+1]?this.counters[t]===1?(await this.elevate(t+1),this.chunks[t+1]=this.chunks[t],this.finalize(t+1)):(await this.elevate(t),this.finalize(t+1)):(await this.onChunk(this.chunks[t]),this.chunks[t])}}a.MerkleTree=Ar,n=Ar,Ar.NOOP=async e=>{};class te{constructor(t,r){if(r<0)throw Error("Scale must be non-negative");this.value=BigInt(t),this.scale=r}static fromDecimalString(t,r){let[s,o]=t.split(".");return o=(o||"").padEnd(r,"0").slice(0,r),new te(BigInt(s+o),r)}add(t){return this.assertSameScale(t),new te(this.value+t.value,this.scale)}subtract(t){return this.assertSameScale(t),new te(this.value-t.value,this.scale)}multiply(t){return new te(this.value*t,this.scale)}divmod(t){if(t===0n)throw new Error("Division by zero is not allowed");const r=this.value/t,s=this.value%t;return[new te(r,this.scale),new te(s,this.scale)]}exchange(t,r,s){if(t==="*"){const d=this.value*r.value/10n**BigInt(this.scale);return new te(d,s)}this.assertSameScale(r);const o=this.value*10n**BigInt(s)/r.value;return new te(o,s)}compare(t){return this.assertSameScale(t),this.value>t.value?1:this.value<t.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const t=this.value.toString(),r=t.slice(0,-this.scale)||"0",s=t.slice(-this.scale).padStart(this.scale,"0");return`${r}.${s}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(t){if(this.scale!==t.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${t.scale}`)}}a.FixedPointNumber=te;function kd(e){if(e.length===0)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}}function Ft(e,t,r,s){const o=e.findIndex(g=>g===`--${t}`||g.startsWith(`--${t}=`)),d=e[o];if(!d)return(r||{})[s||t||""]||null;if(d.includes("="))return d.split("=")[1];const f=e[o+1];return f&&!f.startsWith("-")?f:(r||{})[s||t||""]||null}function Ed(e,t,r,s){const o=Ft(e,t,r,s);if(!o)return null;try{return _r(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}}function Td(e,t,r,s){const o=e.some(p=>p.endsWith("-"+t)),d=Ft(e,t,r,s);if(!d&&o)return!0;if(!d&&!o)return null;const f=["true","1","yes","y","on"],g=["false","0","no","n","off"];if(f.includes(d.toLowerCase()))return!0;if(g.includes(d.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${d}`)}function ii(e,t,r,s){const o=Ft(e,t,r,s);if(!o)throw new Error(`Missing argument ${t}`);return o}function Ad(e,t,r,s){const o=ii(e,t,r,s);try{return _r(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}}function ai(e,t){const r=e[t];e.splice(t,1),e.unshift(r)}function Sd(e,t){const r=[...e];return ai(r,t),r}function oi(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Od(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Sr(e,t){return{x:e.x*t,y:e.y*t}}function Id(e){const t=Math.sqrt(e.x*e.x+e.y*e.y);return{x:e.x/t,y:e.y/t}}function ci(e,t,r){return{x:e.x+Math.cos(t)*r,y:e.y+Math.sin(t)*r}}function ui(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function lt(e,t,r="row-first"){const s=[];if(r==="column-first")for(let o=0;o<e.length;o++)for(let d=0;d<e[0].length;d++)t(o,d)&&s.push({x:o,y:d});else for(let o=0;o<e[0].length;o++)for(let d=0;d<e.length;d++)t(d,o)&&s.push({x:d,y:o});return s}function Md(e,t,r){var s,o;return((s=e[t+1])==null?void 0:s[r])&&((o=e[t-1])==null?void 0:o[r])&&!e[t][r-1]&&!e[t][r+1]}function $d(e,t,r){var s,o;return e[t][r+1]&&e[t][r-1]&&!((s=e[t-1])!=null&&s[r])&&!((o=e[t+1])!=null&&o[r])}function li(e,t,r){var s;return!((s=e[t-1])!=null&&s[r])}function di(e,t,r){var s;return!((s=e[t+1])!=null&&s[r])}function fi(e,t,r){return!e[t][r-1]}function hi(e,t,r){return!e[t][r+1]}function Cd(e,t,r){var o,d,f,g,p,k,$,U;const s=[];return e[t][r]?Md(e,t,r)||$d(e,t,r)?[]:(!((o=e[t-1])!=null&&o[r-1])&&li(e,t,r)&&fi(e,t,r)&&s.push({x:t,y:r}),!((d=e[t+1])!=null&&d[r-1])&&di(e,t,r)&&fi(e,t,r)&&s.push({x:t+1,y:r}),!((f=e[t-1])!=null&&f[r+1])&&li(e,t,r)&&hi(e,t,r)&&s.push({x:t,y:r+1}),!((g=e[t+1])!=null&&g[r+1])&&di(e,t,r)&&hi(e,t,r)&&s.push({x:t+1,y:r+1}),s):((p=e[t-1])!=null&&p[r]&&e[t][r-1]&&s.push({x:t,y:r}),(k=e[t+1])!=null&&k[r]&&e[t][r-1]&&s.push({x:t+1,y:r}),($=e[t-1])!=null&&$[r]&&e[t][r+1]&&s.push({x:t,y:r+1}),(U=e[t+1])!=null&&U[r]&&e[t][r+1]&&s.push({x:t+1,y:r+1}),s)}function Nd(e,t,r,s){const o=[{x:0,y:0},{x:r,y:0},{x:0,y:s},{x:r,y:s}];for(let d=0;d<e.length;d++)for(let f=0;f<e[0].length;f++){const g=Cd(e,d,f);for(const p of g)o.some(k=>k.x===p.x&&k.y===p.y)||o.push(p)}return o.map(d=>({x:d.x*t,y:d.y*t}))}function Rd(e,t){const r=lt(e,(p,k)=>e[p][k]===0&&e[p][k+1]!==0,"row-first").map(p=>({...p,dx:1,dy:0})),s=lt(e,(p,k)=>e[p][k]===0&&e[p][k-1]!==0,"row-first").map(p=>({...p,dx:1,dy:0})),o=lt(e,(p,k)=>{var $;return e[p][k]===0&&(($=e[p-1])==null?void 0:$[k])!==0},"column-first").map(p=>({...p,dx:0,dy:1})),d=lt(e,(p,k)=>{var $;return e[p][k]===0&&(($=e[p+1])==null?void 0:$[k])!==0},"column-first").map(p=>({...p,dx:0,dy:1}));r.forEach(p=>p.y++),d.forEach(p=>p.x++);const f=xr([...o,...d],(p,k)=>p.x===k.x&&p.y-1===k.y),g=xr([...s,...r],(p,k)=>p.y===k.y&&p.x-1===k.x);return[...f,...g].map(p=>({start:p[0],end:it(p)})).map(p=>({start:Sr(p.start,t),end:Sr(oi(p.end,{x:p.start.dx,y:p.start.dy}),t)}))}function Dd(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}function jd(e,t){return t.map(r=>Dd(e,r)).sort((r,s)=>r-s)}function mi(e,t,r,s){const o=(s.y-r.y)*(t.x-e.x)-(s.x-r.x)*(t.y-e.y);if(o===0)return null;let d=e.y-r.y,f=e.x-r.x;const g=(s.x-r.x)*d-(s.y-r.y)*f,p=(t.x-e.x)*d-(t.y-e.y)*f;return d=g/o,f=p/o,d>0&&d<1&&f>0&&f<1?{x:e.x+d*(t.x-e.x),y:e.y+d*(t.y-e.y)}:null}function Or(e,t,r){const s=[],o=ci(e,r,1e4);for(const d of t){const f=mi(e,o,d.start,d.end);f&&s.push(f)}return s.length?s.reduce((d,f)=>{const g=ui(e,f),p=ui(e,d);return g<p?f:d}):null}function Ud(e,t,r){const s=jd(e,r),o=[];for(const d of s){const f=Or(e,t,d-.001),g=Or(e,t,d+.001);f&&o.push(f),g&&o.push(g)}return o}class Ir{constructor(){this.subscribers=[]}subscribe(t){return this.subscribers.push(t),()=>{this.subscribers=this.subscribers.filter(r=>r!==t)}}publish(t){this.subscribers.forEach(r=>r(t))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}a.PubSubChannel=Ir;class Pd{constructor(t,r){this.queue=[],this.running=0,this.onProcessed=new Ir,this.onDrained=new Ir,this.concurrency=t,this.capacity=r}process(){if(this.running>=this.concurrency)return;const t=this.queue.shift();t&&(this.running++,t().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(t){if(this.queue.length<this.capacity)return this.queue.push(t),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(r=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(t),this.process(),this.onProcessed.clear(),r())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(t=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),t()})})}}a.AsyncQueue=Pd,a.Binary={hexToUint8Array:Fc,uint8ArrayToHex:Vc,base64ToUint8Array:Zc,uint8ArrayToBase64:Bc,base32ToUint8Array:Lc,uint8ArrayToBase32:zc,log2Reduce:Vs,partition:Er,concatBytes:Ue,numberToUint8:Kl,uint8ToNumber:Yl,numberToUint16:Ql,uint16ToNumber:Xl,numberToUint32:Jl,uint32ToNumber:ed,numberToUint64:kr,uint64ToNumber:td,numberToUint256:Pe,uint256ToNumber:Ze,sliceBytes:rd,keccak256:oe,sha3_256:sd,proximity:id,commonPrefix:ad,setBit:od,getBit:cd,indexOf:ud,equals:hd,padStart:Js,padStartToMultiple:ld,padEnd:ei,padEndToMultiple:dd,xorCypher:fd},a.Elliptic={privateKeyToPublicKey:pd,compressPublicKey:gd,publicKeyFromCompressed:yd,publicKeyToAddress:vd,signMessage:_d,signHash:ri,verifySignature:xd,recoverPublicKey:bd,checksumEncode:wd},a.Random={intBetween:st,floatBetween:qn,chance:Gn,signed:ja,makeSeededRng:tr,point:Pa,procs:Za},a.Arrays={countUnique:Il,makeUnique:Ol,splitBySize:Al,splitByCount:Bs,index:Zs,indexCollection:Tl,onlyOrThrow:m,onlyOrNull:w,firstOrThrow:E,firstOrNull:v,shuffle:h,initialize:D,initialize2D:ae,rotate2D:ie,containsShape:nt,glue:Go,pluck:er,pick:rr,pickMany:Ba,pickManyUnique:La,pickWeighted:Va,pickRandomIndices:Ne,pickGuaranteed:za,last:it,pipe:Kn,makePipe:Fa,sortWeighted:Wa,pushAll:Nt,unshiftAll:Ho,filterAndRemove:hu,merge:cl,empty:ul,pushToBucket:Fo,unshiftAndLimit:Vo,atRolling:Wo,group:xr,createOscillator:Ku,organiseWithLimits:Qu,tickPlaybook:kd,getArgument:Ft,getBooleanArgument:Td,getNumberArgument:Ed,requireStringArgument:ii,requireNumberArgument:Ad,bringToFront:Sd,bringToFrontInPlace:ai,findInstance:zl,filterInstances:Fl,interleave:Vl,toggle:Wl,createHierarchy:ql,multicall:Bl,maxBy:Ll},a.System={sleepMillis:l,forever:Qa,scheduleMany:tc,waitFor:fu,expandError:Zo,runAndSetInterval:Xa},a.Numbers={make:_r,sum:nc,average:sc,median:ic,getDistanceFromMidpoint:ac,clamp:br,range:cs,interpolate:rc,createSequence:Gu,increment:sl,decrement:il,format:nl,fromDecimals:rl,makeStorage:Pu,asMegabytes:Ja,convertBytes:eo,hexToRgb:to,rgbToHex:ro,haversineDistanceToMeters:no,roundToNearest:It,formatDistance:so,triangularNumber:io,searchFloat:ao},a.Promises={raceFulfilled:c,invert:i,runInParallelBatches:u},a.Dates={getTimestamp:xu,getTimeDelta:Ms,secondsToHumanTime:ku,countCycles:Eu,isoDate:gu,throttle:Tu,timeSince:Su,dateTimeSlug:yu,unixTimestamp:pu,fromUtcString:vu,fromMillis:wu,getProgress:Ou,humanizeTime:Ut,humanizeProgress:du,createTimeDigits:ee,mapDayNumber:$s,getDayInfoFromDate:vr,getDayInfoFromDateTimeString:Mu,seconds:$u,minutes:Cu,hours:Nu,days:Ru,make:ju,normalizeTime:_u,absoluteDays:Ee},a.Objects={safeParse:qu,deleteDeep:Ga,getDeep:be,setDeep:xe,incrementDeep:Ha,ensureDeep:qa,replaceDeep:Ka,getFirstDeep:Ya,deepMergeInPlace:ke,deepMerge2:Bo,deepMerge3:Lo,mapAllAsync:qo,cloneWithJson:mu,sortObject:Ns,sortArray:Rs,sortAny:Te,deepEquals:Ds,deepEqualsEvery:Hu,runOn:al,ifPresent:ol,zip:os,zipSum:zo,removeEmptyArrays:ll,removeEmptyValues:dl,flatten:kl,unflatten:Ps,match:El,sort:zs,map:ml,mapIterable:pl,filterKeys:fl,filterValues:hl,rethrow:gl,setSomeOnObject:yl,setSomeDeep:vl,flip:wl,getAllPermutations:_l,countTruthyValues:bl,transformToArray:Ml,setMulti:Cl,incrementMulti:$l,createBidirectionalMap:Nl,createTemporalBidirectionalMap:Rl,pushToBidirectionalMap:Fs,unshiftToBidirectionalMap:Dl,addToTemporalBidirectionalMap:jl,getFromTemporalBidirectionalMap:Ul,createStatefulToggle:Yu,diffKeys:Xu,pickRandomKey:js,mapRandomKey:Ju,fromObjectString:el,toQueryString:Os,parseQueryString:nu,hasKey:su,selectMax:iu,reposition:au,unwrapSingleKey:ou,parseKeyValues:cu},a.Types={isFunction:sr,isObject:he,isStrictlyObject:Re,isEmptyArray:Yn,isEmptyObject:oo,isUndefined:nr,isString:V,isNumber:me,isBoolean:Qn,isDate:De,isBlank:Mt,isId:ir,isIntegerString:Xn,isHexString:Jn,isUrl:is,isNullable:Do,asString:ns,asHexString:bo,asSafeString:xo,asIntegerString:_o,asNumber:$t,asFunction:ko,asInteger:cr,asBoolean:Eo,asDate:To,asNullableString:Ao,asEmptiableString:So,asId:Oo,asTime:Io,asArray:Mo,asObject:Ct,asNullableObject:$o,asStringMap:Co,asNumericDictionary:No,asUrl:Ro,asNullable:jo,asOptional:Uo,enforceObjectShape:as,enforceArrayShape:Po,isPng:Ws,isJpg:Hs,isWebp:qs,isImage:Gl},a.Strings={tokenizeByCount:Sl,tokenizeByLength:Ls,searchHex:yo,searchSubstring:vo,randomHex:wo,randomLetter:ho,randomAlphanumeric:mo,randomRichAscii:po,randomUnicode:go,includesAny:oc,slugify:ur,normalForm:uc,enumify:pc,escapeHtml:yc,decodeHtmlEntities:wc,after:lr,afterLast:ls,before:us,beforeLast:dr,betweenWide:_c,betweenNarrow:bc,getPreLine:Zu,containsWord:gr,containsWords:Jc,joinUrl:Cs,getFuzzyMatchScore:Rt,sortByFuzzyScore:gc,splitOnce:fr,splitAll:ds,randomize:Tc,expand:fs,shrinkTrim:ot,capitalize:Dt,decapitalize:hs,csvEscape:$c,parseCsv:lu,surroundInOut:mc,getExtension:hr,getBasename:mr,normalizeEmail:xc,normalizeFilename:kc,parseFilename:Ec,camelToTitle:lc,slugToTitle:dc,slugToCamel:fc,joinHumanly:hc,findWeightedPair:ws,extractBlock:_s,extractAllBlocks:Rc,replaceBlocks:Dc,indexOfEarliest:je,lastIndexOfBefore:vs,parseHtmlAttributes:eu,readNextWord:jt,resolveVariables:tu,resolveVariableWithDefaultSyntax:As,resolveRemainingVariablesWithDefaults:Ss,isLetter:ms,isDigit:ps,isLetterOrDigit:ct,isValidObjectPathCharacter:Oc,insert:Ic,indexOfRegex:gs,lineMatches:ys,linesMatchInOrder:Mc,represent:at,resolveMarkdownLinks:ru,buildUrl:uu,isChinese:cc,replaceBetweenStrings:zu,describeMarkdown:Fu,isBalanced:Vu,textToFormat:Wu,splitFormatting:jc,splitHashtags:Uc,splitUrls:Pc,route:Wc,explodeReplace:pr,generateVariants:Hc,replaceWord:qc,replacePascalCaseWords:Gc,stripHtml:Kc,breakLine:Ts,measureTextWidth:Yc,toLines:Qc,levenshteinDistance:Xc},a.Assertions={asEqual:Ko,asTrue:Yo,asTruthy:Qo,asFalse:Xo,asFalsy:Jo,asEither:ec},a.Cache={get:Bu,invalidate:Lu},a.Vector={addPoint:oi,subtractPoint:Od,multiplyPoint:Sr,normalizePoint:Id,pushPoint:ci,filterCoordinates:lt,findCorners:Nd,findLines:Rd,raycast:Or,raycastCircle:Ud,getLineIntersectionPoint:mi}})(On);const N=wi(On);N.Arrays,N.Assertions;const Z=N.Binary;N.Cache,N.Dates,N.Elliptic,N.Numbers,N.Objects,N.Pagination,N.Promises,N.Random,N.Strings,N.System,N.Types,N.Optional,N.Vector,N.PubSubChannel,N.Chunk;const _i=N.MerkleTree;N.FixedPointNumber,N.Lazy,N.AsyncLazy,N.AsyncQueue,N.Uint8ArrayReader,N.Uint8ArrayWriter;const bi=new TextEncoder,In=1,Mn=4096,Wt=4096,xi=32;function $n(a,n){return n=typeof n=="number"?S.FeedIndex.fromBigInt(BigInt(n)):n,new S.Identifier(Z.keccak256(Z.concatBytes(a.toUint8Array(),n.toUint8Array())))}function ki(a){const n=a.slice(0,S.Span.LENGTH),i=a.slice(S.Span.LENGTH),c=Ei(i),u=Z.keccak256(Z.concatBytes(n,c));return new S.Reference(u)}function Ei(a){if(a.length>Wt)throw new S.BeeArgumentError(`payload size ${a.length} exceeds maximum chunk payload size ${Wt}`,a);const n=new Uint8Array(Wt);return n.set(a),Z.log2Reduce(Z.partition(n,xi),(i,c)=>Z.keccak256(Z.concatBytes(i,c)))}function Cn(a){if(a instanceof Uint8Array||(a=bi.encode(a)),a.length<In||a.length>Mn)throw new RangeError(`payload size ${a.length} exceeds limits [${In}, ${Mn}]`);const n=S.Span.fromBigInt(BigInt(a.length)),i=Z.concatBytes(n.toUint8Array(),a);return{data:i,span:n,payload:S.Bytes.fromSlice(i,S.Span.LENGTH),address:ki(i)}}function Ti(a,n){return new S.Reference(Z.keccak256(Z.concatBytes(a.toUint8Array(),n.toUint8Array())))}function Nn(a,n,i){n=new S.Identifier(n),i=new S.PrivateKey(i);const c=Ti(n,i.publicKey().address()),u=i.sign(Z.concatBytes(n.toUint8Array(),a.address.toUint8Array())),l=Z.concatBytes(n.toUint8Array(),u.toUint8Array(),a.data),h=S.Span.fromSlice(a.data,0),m=S.Bytes.fromSlice(a.data,S.Span.LENGTH);return{data:l,identifier:n,signature:u,span:h,payload:m,address:c,owner:i.publicKey().address()}}function Ht(a){return(a.startsWith("0x")?a.slice(2):a).toLowerCase()}class K{constructor(){}static getInstance(){return K.instance||(K.instance=new K),K.instance}formatMessage(n,...i){return`[${new Date().toISOString()}] [${n.toUpperCase()}] - ${i.map(u=>typeof u=="object"?JSON.stringify(u):u).join(" ")}`}log(...n){console.log(this.formatMessage("log",...n))}info(...n){console.info(this.formatMessage("info",...n))}warn(...n){console.warn(this.formatMessage("warn",...n))}error(...n){console.error(this.formatMessage("error",...n))}debug(...n){console.debug(this.formatMessage("debug",...n))}}class qt{constructor(){this.logger=K.getInstance()}handleError(n,i){const c=n instanceof Error?n.message:"Unknown error occurred",u=n instanceof Error?n.stack:null;this.logger.error(`Error in ${i||"unknown context"}: ${c}`,{stack:u})}}class Ai{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(n,i){this.events[n]||(this.events[n]=[]),this.events[n].push(i)}off(n,i){if(!this.events[n])return;const c=this.events[n].indexOf(i);c>-1&&this.events[n].splice(c,1)}cleanAll(){this.events={}}emit(n,i){this.events[n]&&this.events[n].forEach(c=>c(i))}}var M;(function(a){a.assertEqual=u=>u;function n(u){}a.assertIs=n;function i(u){throw new Error}a.assertNever=i,a.arrayToEnum=u=>{const l={};for(const h of u)l[h]=h;return l},a.getValidEnumValues=u=>{const l=a.objectKeys(u).filter(m=>typeof u[u[m]]!="number"),h={};for(const m of l)h[m]=u[m];return a.objectValues(h)},a.objectValues=u=>a.objectKeys(u).map(function(l){return u[l]}),a.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{const l=[];for(const h in u)Object.prototype.hasOwnProperty.call(u,h)&&l.push(h);return l},a.find=(u,l)=>{for(const h of u)if(l(h))return h},a.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&isFinite(u)&&Math.floor(u)===u;function c(u,l=" | "){return u.map(h=>typeof h=="string"?`'${h}'`:h).join(l)}a.joinValues=c,a.jsonStringifyReplacer=(u,l)=>typeof l=="bigint"?l.toString():l})(M||(M={}));var Gt;(function(a){a.mergeShapes=(n,i)=>({...n,...i})})(Gt||(Gt={}));const b=M.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),re=a=>{switch(typeof a){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(a)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(a)?b.array:a===null?b.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?b.promise:typeof Map<"u"&&a instanceof Map?b.map:typeof Set<"u"&&a instanceof Set?b.set:typeof Date<"u"&&a instanceof Date?b.date:b.object;default:return b.unknown}},y=M.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Si=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:");class F extends Error{get errors(){return this.issues}constructor(n){super(),this.issues=[],this.addIssue=c=>{this.issues=[...this.issues,c]},this.addIssues=(c=[])=>{this.issues=[...this.issues,...c]};const i=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,i):this.__proto__=i,this.name="ZodError",this.issues=n}format(n){const i=n||function(l){return l.message},c={_errors:[]},u=l=>{for(const h of l.issues)if(h.code==="invalid_union")h.unionErrors.map(u);else if(h.code==="invalid_return_type")u(h.returnTypeError);else if(h.code==="invalid_arguments")u(h.argumentsError);else if(h.path.length===0)c._errors.push(i(h));else{let m=c,w=0;for(;w<h.path.length;){const v=h.path[w];w===h.path.length-1?(m[v]=m[v]||{_errors:[]},m[v]._errors.push(i(h))):m[v]=m[v]||{_errors:[]},m=m[v],w++}}};return u(this),c}static assert(n){if(!(n instanceof F))throw new Error(`Not a ZodError: ${n}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,M.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(n=i=>i.message){const i={},c=[];for(const u of this.issues)u.path.length>0?(i[u.path[0]]=i[u.path[0]]||[],i[u.path[0]].push(n(u))):c.push(n(u));return{formErrors:c,fieldErrors:i}}get formErrors(){return this.flatten()}}F.create=a=>new F(a);const Se=(a,n)=>{let i;switch(a.code){case y.invalid_type:a.received===b.undefined?i="Required":i=`Expected ${a.expected}, received ${a.received}`;break;case y.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(a.expected,M.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:i=`Unrecognized key(s) in object: ${M.joinValues(a.keys,", ")}`;break;case y.invalid_union:i="Invalid input";break;case y.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${M.joinValues(a.options)}`;break;case y.invalid_enum_value:i=`Invalid enum value. Expected ${M.joinValues(a.options)}, received '${a.received}'`;break;case y.invalid_arguments:i="Invalid function arguments";break;case y.invalid_return_type:i="Invalid function return type";break;case y.invalid_date:i="Invalid date";break;case y.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(i=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(i=`${i} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?i=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?i=`Invalid input: must end with "${a.validation.endsWith}"`:M.assertNever(a.validation):a.validation!=="regex"?i=`Invalid ${a.validation}`:i="Invalid";break;case y.too_small:a.type==="array"?i=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?i=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?i=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?i=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:i="Invalid input";break;case y.too_big:a.type==="array"?i=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?i=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?i=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?i=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?i=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:i="Invalid input";break;case y.custom:i="Invalid input";break;case y.invalid_intersection_types:i="Intersection results could not be merged";break;case y.not_multiple_of:i=`Number must be a multiple of ${a.multipleOf}`;break;case y.not_finite:i="Number must be finite";break;default:i=n.defaultError,M.assertNever(a)}return{message:i}};let Rn=Se;function Oi(a){Rn=a}function bt(){return Rn}const xt=a=>{const{data:n,path:i,errorMaps:c,issueData:u}=a,l=[...i,...u.path||[]],h={...u,path:l};if(u.message!==void 0)return{...u,path:l,message:u.message};let m="";const w=c.filter(v=>!!v).slice().reverse();for(const v of w)m=v(h,{data:n,defaultError:m}).message;return{...u,path:l,message:m}},Ii=[];function _(a,n){const i=bt(),c=xt({issueData:n,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,i,i===Se?void 0:Se].filter(u=>!!u)});a.common.issues.push(c)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(n,i){const c=[];for(const u of i){if(u.status==="aborted")return A;u.status==="dirty"&&n.dirty(),c.push(u.value)}return{status:n.value,value:c}}static async mergeObjectAsync(n,i){const c=[];for(const u of i){const l=await u.key,h=await u.value;c.push({key:l,value:h})}return B.mergeObjectSync(n,c)}static mergeObjectSync(n,i){const c={};for(const u of i){const{key:l,value:h}=u;if(l.status==="aborted"||h.status==="aborted")return A;l.status==="dirty"&&n.dirty(),h.status==="dirty"&&n.dirty(),l.value!=="__proto__"&&(typeof h.value<"u"||u.alwaysSet)&&(c[l.value]=h.value)}return{status:n.value,value:c}}}const A=Object.freeze({status:"aborted"}),Oe=a=>({status:"dirty",value:a}),z=a=>({status:"valid",value:a}),Kt=a=>a.status==="aborted",Yt=a=>a.status==="dirty",ye=a=>a.status==="valid",Le=a=>typeof Promise<"u"&&a instanceof Promise;function kt(a,n,i,c){if(typeof n=="function"?a!==n||!c:!n.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n.get(a)}function Dn(a,n,i,c,u){if(typeof n=="function"?a!==n||!u:!n.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n.set(a,i),i}typeof SuppressedError=="function"&&SuppressedError;var x;(function(a){a.errToObj=n=>typeof n=="string"?{message:n}:n||{},a.toString=n=>typeof n=="string"?n:n==null?void 0:n.message})(x||(x={}));var ze,Fe;class Y{constructor(n,i,c,u){this._cachedPath=[],this.parent=n,this.data=i,this._path=c,this._key=u}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const jn=(a,n)=>{if(ye(n))return{success:!0,data:n.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const i=new F(a.common.issues);return this._error=i,this._error}}};function O(a){if(!a)return{};const{errorMap:n,invalid_type_error:i,required_error:c,description:u}=a;if(n&&(i||c))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return n?{errorMap:n,description:u}:{errorMap:(h,m)=>{var w,v;const{message:E}=a;return h.code==="invalid_enum_value"?{message:E??m.defaultError}:typeof m.data>"u"?{message:(w=E??c)!==null&&w!==void 0?w:m.defaultError}:h.code!=="invalid_type"?{message:m.defaultError}:{message:(v=E??i)!==null&&v!==void 0?v:m.defaultError}},description:u}}class I{get description(){return this._def.description}_getType(n){return re(n.data)}_getOrReturnCtx(n,i){return i||{common:n.parent.common,data:n.data,parsedType:re(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}_processInputParams(n){return{status:new B,ctx:{common:n.parent.common,data:n.data,parsedType:re(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}}_parseSync(n){const i=this._parse(n);if(Le(i))throw new Error("Synchronous parse encountered promise.");return i}_parseAsync(n){const i=this._parse(n);return Promise.resolve(i)}parse(n,i){const c=this.safeParse(n,i);if(c.success)return c.data;throw c.error}safeParse(n,i){var c;const u={common:{issues:[],async:(c=i==null?void 0:i.async)!==null&&c!==void 0?c:!1,contextualErrorMap:i==null?void 0:i.errorMap},path:(i==null?void 0:i.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:re(n)},l=this._parseSync({data:n,path:u.path,parent:u});return jn(u,l)}"~validate"(n){var i,c;const u={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:re(n)};if(!this["~standard"].async)try{const l=this._parseSync({data:n,path:[],parent:u});return ye(l)?{value:l.value}:{issues:u.common.issues}}catch(l){!((c=(i=l==null?void 0:l.message)===null||i===void 0?void 0:i.toLowerCase())===null||c===void 0)&&c.includes("encountered")&&(this["~standard"].async=!0),u.common={issues:[],async:!0}}return this._parseAsync({data:n,path:[],parent:u}).then(l=>ye(l)?{value:l.value}:{issues:u.common.issues})}async parseAsync(n,i){const c=await this.safeParseAsync(n,i);if(c.success)return c.data;throw c.error}async safeParseAsync(n,i){const c={common:{issues:[],contextualErrorMap:i==null?void 0:i.errorMap,async:!0},path:(i==null?void 0:i.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:re(n)},u=this._parse({data:n,path:c.path,parent:c}),l=await(Le(u)?u:Promise.resolve(u));return jn(c,l)}refine(n,i){const c=u=>typeof i=="string"||typeof i>"u"?{message:i}:typeof i=="function"?i(u):i;return this._refinement((u,l)=>{const h=n(u),m=()=>l.addIssue({code:y.custom,...c(u)});return typeof Promise<"u"&&h instanceof Promise?h.then(w=>w?!0:(m(),!1)):h?!0:(m(),!1)})}refinement(n,i){return this._refinement((c,u)=>n(c)?!0:(u.addIssue(typeof i=="function"?i(c,u):i),!1))}_refinement(n){return new q({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:n}})}superRefine(n){return this._refinement(n)}constructor(n){this.spa=this.safeParseAsync,this._def=n,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:i=>this["~validate"](i)}}optional(){return X.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return Ce.create(this,this._def)}or(n){return qe.create([this,n],this._def)}and(n){return Ge.create(this,n,this._def)}transform(n){return new q({...O(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:n}})}default(n){const i=typeof n=="function"?n:()=>n;return new Je({...O(this._def),innerType:this,defaultValue:i,typeName:T.ZodDefault})}brand(){return new Jt({typeName:T.ZodBranded,type:this,...O(this._def)})}catch(n){const i=typeof n=="function"?n:()=>n;return new et({...O(this._def),innerType:this,catchValue:i,typeName:T.ZodCatch})}describe(n){const i=this.constructor;return new i({...this._def,description:n})}pipe(n){return tt.create(this,n)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Mi=/^c[^\s-]{8,}$/i,$i=/^[0-9a-z]+$/,Ci=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ni=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ri=/^[a-z0-9_-]{21}$/i,Di=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ji=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ui=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Qt;const Zi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Li=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,zi=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Un="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Wi=new RegExp(`^${Un}$`);function Pn(a){let n="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return a.precision?n=`${n}\\.\\d{${a.precision}}`:a.precision==null&&(n=`${n}(\\.\\d+)?`),n}function Hi(a){return new RegExp(`^${Pn(a)}$`)}function Zn(a){let n=`${Un}T${Pn(a)}`;const i=[];return i.push(a.local?"Z?":"Z"),a.offset&&i.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${i.join("|")})`,new RegExp(`^${n}$`)}function qi(a,n){return!!((n==="v4"||!n)&&Zi.test(a)||(n==="v6"||!n)&&Li.test(a))}function Gi(a,n){if(!Di.test(a))return!1;try{const[i]=a.split("."),c=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),u=JSON.parse(atob(c));return!(typeof u!="object"||u===null||!u.typ||!u.alg||n&&u.alg!==n)}catch{return!1}}function Ki(a,n){return!!((n==="v4"||!n)&&Bi.test(a)||(n==="v6"||!n)&&zi.test(a))}class W extends I{_parse(n){if(this._def.coerce&&(n.data=String(n.data)),this._getType(n)!==b.string){const l=this._getOrReturnCtx(n);return _(l,{code:y.invalid_type,expected:b.string,received:l.parsedType}),A}const c=new B;let u;for(const l of this._def.checks)if(l.kind==="min")n.data.length<l.value&&(u=this._getOrReturnCtx(n,u),_(u,{code:y.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),c.dirty());else if(l.kind==="max")n.data.length>l.value&&(u=this._getOrReturnCtx(n,u),_(u,{code:y.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),c.dirty());else if(l.kind==="length"){const h=n.data.length>l.value,m=n.data.length<l.value;(h||m)&&(u=this._getOrReturnCtx(n,u),h?_(u,{code:y.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):m&&_(u,{code:y.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),c.dirty())}else if(l.kind==="email")Ui.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"email",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="emoji")Qt||(Qt=new RegExp(Pi,"u")),Qt.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"emoji",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="uuid")Ni.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"uuid",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="nanoid")Ri.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"nanoid",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="cuid")Mi.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"cuid",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="cuid2")$i.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"cuid2",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="ulid")Ci.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"ulid",code:y.invalid_string,message:l.message}),c.dirty());else if(l.kind==="url")try{new URL(n.data)}catch{u=this._getOrReturnCtx(n,u),_(u,{validation:"url",code:y.invalid_string,message:l.message}),c.dirty()}else l.kind==="regex"?(l.regex.lastIndex=0,l.regex.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"regex",code:y.invalid_string,message:l.message}),c.dirty())):l.kind==="trim"?n.data=n.data.trim():l.kind==="includes"?n.data.includes(l.value,l.position)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),c.dirty()):l.kind==="toLowerCase"?n.data=n.data.toLowerCase():l.kind==="toUpperCase"?n.data=n.data.toUpperCase():l.kind==="startsWith"?n.data.startsWith(l.value)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:{startsWith:l.value},message:l.message}),c.dirty()):l.kind==="endsWith"?n.data.endsWith(l.value)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:{endsWith:l.value},message:l.message}),c.dirty()):l.kind==="datetime"?Zn(l).test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:"datetime",message:l.message}),c.dirty()):l.kind==="date"?Wi.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:"date",message:l.message}),c.dirty()):l.kind==="time"?Hi(l).test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{code:y.invalid_string,validation:"time",message:l.message}),c.dirty()):l.kind==="duration"?ji.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"duration",code:y.invalid_string,message:l.message}),c.dirty()):l.kind==="ip"?qi(n.data,l.version)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"ip",code:y.invalid_string,message:l.message}),c.dirty()):l.kind==="jwt"?Gi(n.data,l.alg)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"jwt",code:y.invalid_string,message:l.message}),c.dirty()):l.kind==="cidr"?Ki(n.data,l.version)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"cidr",code:y.invalid_string,message:l.message}),c.dirty()):l.kind==="base64"?Fi.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"base64",code:y.invalid_string,message:l.message}),c.dirty()):l.kind==="base64url"?Vi.test(n.data)||(u=this._getOrReturnCtx(n,u),_(u,{validation:"base64url",code:y.invalid_string,message:l.message}),c.dirty()):M.assertNever(l);return{status:c.value,value:n.data}}_regex(n,i,c){return this.refinement(u=>n.test(u),{validation:i,code:y.invalid_string,...x.errToObj(c)})}_addCheck(n){return new W({...this._def,checks:[...this._def.checks,n]})}email(n){return this._addCheck({kind:"email",...x.errToObj(n)})}url(n){return this._addCheck({kind:"url",...x.errToObj(n)})}emoji(n){return this._addCheck({kind:"emoji",...x.errToObj(n)})}uuid(n){return this._addCheck({kind:"uuid",...x.errToObj(n)})}nanoid(n){return this._addCheck({kind:"nanoid",...x.errToObj(n)})}cuid(n){return this._addCheck({kind:"cuid",...x.errToObj(n)})}cuid2(n){return this._addCheck({kind:"cuid2",...x.errToObj(n)})}ulid(n){return this._addCheck({kind:"ulid",...x.errToObj(n)})}base64(n){return this._addCheck({kind:"base64",...x.errToObj(n)})}base64url(n){return this._addCheck({kind:"base64url",...x.errToObj(n)})}jwt(n){return this._addCheck({kind:"jwt",...x.errToObj(n)})}ip(n){return this._addCheck({kind:"ip",...x.errToObj(n)})}cidr(n){return this._addCheck({kind:"cidr",...x.errToObj(n)})}datetime(n){var i,c;return typeof n=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:n}):this._addCheck({kind:"datetime",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,offset:(i=n==null?void 0:n.offset)!==null&&i!==void 0?i:!1,local:(c=n==null?void 0:n.local)!==null&&c!==void 0?c:!1,...x.errToObj(n==null?void 0:n.message)})}date(n){return this._addCheck({kind:"date",message:n})}time(n){return typeof n=="string"?this._addCheck({kind:"time",precision:null,message:n}):this._addCheck({kind:"time",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,...x.errToObj(n==null?void 0:n.message)})}duration(n){return this._addCheck({kind:"duration",...x.errToObj(n)})}regex(n,i){return this._addCheck({kind:"regex",regex:n,...x.errToObj(i)})}includes(n,i){return this._addCheck({kind:"includes",value:n,position:i==null?void 0:i.position,...x.errToObj(i==null?void 0:i.message)})}startsWith(n,i){return this._addCheck({kind:"startsWith",value:n,...x.errToObj(i)})}endsWith(n,i){return this._addCheck({kind:"endsWith",value:n,...x.errToObj(i)})}min(n,i){return this._addCheck({kind:"min",value:n,...x.errToObj(i)})}max(n,i){return this._addCheck({kind:"max",value:n,...x.errToObj(i)})}length(n,i){return this._addCheck({kind:"length",value:n,...x.errToObj(i)})}nonempty(n){return this.min(1,x.errToObj(n))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(n=>n.kind==="datetime")}get isDate(){return!!this._def.checks.find(n=>n.kind==="date")}get isTime(){return!!this._def.checks.find(n=>n.kind==="time")}get isDuration(){return!!this._def.checks.find(n=>n.kind==="duration")}get isEmail(){return!!this._def.checks.find(n=>n.kind==="email")}get isURL(){return!!this._def.checks.find(n=>n.kind==="url")}get isEmoji(){return!!this._def.checks.find(n=>n.kind==="emoji")}get isUUID(){return!!this._def.checks.find(n=>n.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(n=>n.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(n=>n.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(n=>n.kind==="cuid2")}get isULID(){return!!this._def.checks.find(n=>n.kind==="ulid")}get isIP(){return!!this._def.checks.find(n=>n.kind==="ip")}get isCIDR(){return!!this._def.checks.find(n=>n.kind==="cidr")}get isBase64(){return!!this._def.checks.find(n=>n.kind==="base64")}get isBase64url(){return!!this._def.checks.find(n=>n.kind==="base64url")}get minLength(){let n=null;for(const i of this._def.checks)i.kind==="min"&&(n===null||i.value>n)&&(n=i.value);return n}get maxLength(){let n=null;for(const i of this._def.checks)i.kind==="max"&&(n===null||i.value<n)&&(n=i.value);return n}}W.create=a=>{var n;return new W({checks:[],typeName:T.ZodString,coerce:(n=a==null?void 0:a.coerce)!==null&&n!==void 0?n:!1,...O(a)})};function Yi(a,n){const i=(a.toString().split(".")[1]||"").length,c=(n.toString().split(".")[1]||"").length,u=i>c?i:c,l=parseInt(a.toFixed(u).replace(".","")),h=parseInt(n.toFixed(u).replace(".",""));return l%h/Math.pow(10,u)}class ue extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(n){if(this._def.coerce&&(n.data=Number(n.data)),this._getType(n)!==b.number){const l=this._getOrReturnCtx(n);return _(l,{code:y.invalid_type,expected:b.number,received:l.parsedType}),A}let c;const u=new B;for(const l of this._def.checks)l.kind==="int"?M.isInteger(n.data)||(c=this._getOrReturnCtx(n,c),_(c,{code:y.invalid_type,expected:"integer",received:"float",message:l.message}),u.dirty()):l.kind==="min"?(l.inclusive?n.data<l.value:n.data<=l.value)&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),u.dirty()):l.kind==="max"?(l.inclusive?n.data>l.value:n.data>=l.value)&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),u.dirty()):l.kind==="multipleOf"?Yi(n.data,l.value)!==0&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.not_multiple_of,multipleOf:l.value,message:l.message}),u.dirty()):l.kind==="finite"?Number.isFinite(n.data)||(c=this._getOrReturnCtx(n,c),_(c,{code:y.not_finite,message:l.message}),u.dirty()):M.assertNever(l);return{status:u.value,value:n.data}}gte(n,i){return this.setLimit("min",n,!0,x.toString(i))}gt(n,i){return this.setLimit("min",n,!1,x.toString(i))}lte(n,i){return this.setLimit("max",n,!0,x.toString(i))}lt(n,i){return this.setLimit("max",n,!1,x.toString(i))}setLimit(n,i,c,u){return new ue({...this._def,checks:[...this._def.checks,{kind:n,value:i,inclusive:c,message:x.toString(u)}]})}_addCheck(n){return new ue({...this._def,checks:[...this._def.checks,n]})}int(n){return this._addCheck({kind:"int",message:x.toString(n)})}positive(n){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(n)})}negative(n){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(n)})}multipleOf(n,i){return this._addCheck({kind:"multipleOf",value:n,message:x.toString(i)})}finite(n){return this._addCheck({kind:"finite",message:x.toString(n)})}safe(n){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(n)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(n)})}get minValue(){let n=null;for(const i of this._def.checks)i.kind==="min"&&(n===null||i.value>n)&&(n=i.value);return n}get maxValue(){let n=null;for(const i of this._def.checks)i.kind==="max"&&(n===null||i.value<n)&&(n=i.value);return n}get isInt(){return!!this._def.checks.find(n=>n.kind==="int"||n.kind==="multipleOf"&&M.isInteger(n.value))}get isFinite(){let n=null,i=null;for(const c of this._def.checks){if(c.kind==="finite"||c.kind==="int"||c.kind==="multipleOf")return!0;c.kind==="min"?(i===null||c.value>i)&&(i=c.value):c.kind==="max"&&(n===null||c.value<n)&&(n=c.value)}return Number.isFinite(i)&&Number.isFinite(n)}}ue.create=a=>new ue({checks:[],typeName:T.ZodNumber,coerce:(a==null?void 0:a.coerce)||!1,...O(a)});class le extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(n){if(this._def.coerce)try{n.data=BigInt(n.data)}catch{return this._getInvalidInput(n)}if(this._getType(n)!==b.bigint)return this._getInvalidInput(n);let c;const u=new B;for(const l of this._def.checks)l.kind==="min"?(l.inclusive?n.data<l.value:n.data<=l.value)&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.too_small,type:"bigint",minimum:l.value,inclusive:l.inclusive,message:l.message}),u.dirty()):l.kind==="max"?(l.inclusive?n.data>l.value:n.data>=l.value)&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.too_big,type:"bigint",maximum:l.value,inclusive:l.inclusive,message:l.message}),u.dirty()):l.kind==="multipleOf"?n.data%l.value!==BigInt(0)&&(c=this._getOrReturnCtx(n,c),_(c,{code:y.not_multiple_of,multipleOf:l.value,message:l.message}),u.dirty()):M.assertNever(l);return{status:u.value,value:n.data}}_getInvalidInput(n){const i=this._getOrReturnCtx(n);return _(i,{code:y.invalid_type,expected:b.bigint,received:i.parsedType}),A}gte(n,i){return this.setLimit("min",n,!0,x.toString(i))}gt(n,i){return this.setLimit("min",n,!1,x.toString(i))}lte(n,i){return this.setLimit("max",n,!0,x.toString(i))}lt(n,i){return this.setLimit("max",n,!1,x.toString(i))}setLimit(n,i,c,u){return new le({...this._def,checks:[...this._def.checks,{kind:n,value:i,inclusive:c,message:x.toString(u)}]})}_addCheck(n){return new le({...this._def,checks:[...this._def.checks,n]})}positive(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(n)})}negative(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(n)})}multipleOf(n,i){return this._addCheck({kind:"multipleOf",value:n,message:x.toString(i)})}get minValue(){let n=null;for(const i of this._def.checks)i.kind==="min"&&(n===null||i.value>n)&&(n=i.value);return n}get maxValue(){let n=null;for(const i of this._def.checks)i.kind==="max"&&(n===null||i.value<n)&&(n=i.value);return n}}le.create=a=>{var n;return new le({checks:[],typeName:T.ZodBigInt,coerce:(n=a==null?void 0:a.coerce)!==null&&n!==void 0?n:!1,...O(a)})};class Ve extends I{_parse(n){if(this._def.coerce&&(n.data=!!n.data),this._getType(n)!==b.boolean){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.boolean,received:c.parsedType}),A}return z(n.data)}}Ve.create=a=>new Ve({typeName:T.ZodBoolean,coerce:(a==null?void 0:a.coerce)||!1,...O(a)});class ve extends I{_parse(n){if(this._def.coerce&&(n.data=new Date(n.data)),this._getType(n)!==b.date){const l=this._getOrReturnCtx(n);return _(l,{code:y.invalid_type,expected:b.date,received:l.parsedType}),A}if(isNaN(n.data.getTime())){const l=this._getOrReturnCtx(n);return _(l,{code:y.invalid_date}),A}const c=new B;let u;for(const l of this._def.checks)l.kind==="min"?n.data.getTime()<l.value&&(u=this._getOrReturnCtx(n,u),_(u,{code:y.too_small,message:l.message,inclusive:!0,exact:!1,minimum:l.value,type:"date"}),c.dirty()):l.kind==="max"?n.data.getTime()>l.value&&(u=this._getOrReturnCtx(n,u),_(u,{code:y.too_big,message:l.message,inclusive:!0,exact:!1,maximum:l.value,type:"date"}),c.dirty()):M.assertNever(l);return{status:c.value,value:new Date(n.data.getTime())}}_addCheck(n){return new ve({...this._def,checks:[...this._def.checks,n]})}min(n,i){return this._addCheck({kind:"min",value:n.getTime(),message:x.toString(i)})}max(n,i){return this._addCheck({kind:"max",value:n.getTime(),message:x.toString(i)})}get minDate(){let n=null;for(const i of this._def.checks)i.kind==="min"&&(n===null||i.value>n)&&(n=i.value);return n!=null?new Date(n):null}get maxDate(){let n=null;for(const i of this._def.checks)i.kind==="max"&&(n===null||i.value<n)&&(n=i.value);return n!=null?new Date(n):null}}ve.create=a=>new ve({checks:[],coerce:(a==null?void 0:a.coerce)||!1,typeName:T.ZodDate,...O(a)});class Et extends I{_parse(n){if(this._getType(n)!==b.symbol){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.symbol,received:c.parsedType}),A}return z(n.data)}}Et.create=a=>new Et({typeName:T.ZodSymbol,...O(a)});class We extends I{_parse(n){if(this._getType(n)!==b.undefined){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.undefined,received:c.parsedType}),A}return z(n.data)}}We.create=a=>new We({typeName:T.ZodUndefined,...O(a)});class He extends I{_parse(n){if(this._getType(n)!==b.null){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.null,received:c.parsedType}),A}return z(n.data)}}He.create=a=>new He({typeName:T.ZodNull,...O(a)});class Ie extends I{constructor(){super(...arguments),this._any=!0}_parse(n){return z(n.data)}}Ie.create=a=>new Ie({typeName:T.ZodAny,...O(a)});class we extends I{constructor(){super(...arguments),this._unknown=!0}_parse(n){return z(n.data)}}we.create=a=>new we({typeName:T.ZodUnknown,...O(a)});class ne extends I{_parse(n){const i=this._getOrReturnCtx(n);return _(i,{code:y.invalid_type,expected:b.never,received:i.parsedType}),A}}ne.create=a=>new ne({typeName:T.ZodNever,...O(a)});class Tt extends I{_parse(n){if(this._getType(n)!==b.undefined){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.void,received:c.parsedType}),A}return z(n.data)}}Tt.create=a=>new Tt({typeName:T.ZodVoid,...O(a)});class H extends I{_parse(n){const{ctx:i,status:c}=this._processInputParams(n),u=this._def;if(i.parsedType!==b.array)return _(i,{code:y.invalid_type,expected:b.array,received:i.parsedType}),A;if(u.exactLength!==null){const h=i.data.length>u.exactLength.value,m=i.data.length<u.exactLength.value;(h||m)&&(_(i,{code:h?y.too_big:y.too_small,minimum:m?u.exactLength.value:void 0,maximum:h?u.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:u.exactLength.message}),c.dirty())}if(u.minLength!==null&&i.data.length<u.minLength.value&&(_(i,{code:y.too_small,minimum:u.minLength.value,type:"array",inclusive:!0,exact:!1,message:u.minLength.message}),c.dirty()),u.maxLength!==null&&i.data.length>u.maxLength.value&&(_(i,{code:y.too_big,maximum:u.maxLength.value,type:"array",inclusive:!0,exact:!1,message:u.maxLength.message}),c.dirty()),i.common.async)return Promise.all([...i.data].map((h,m)=>u.type._parseAsync(new Y(i,h,i.path,m)))).then(h=>B.mergeArray(c,h));const l=[...i.data].map((h,m)=>u.type._parseSync(new Y(i,h,i.path,m)));return B.mergeArray(c,l)}get element(){return this._def.type}min(n,i){return new H({...this._def,minLength:{value:n,message:x.toString(i)}})}max(n,i){return new H({...this._def,maxLength:{value:n,message:x.toString(i)}})}length(n,i){return new H({...this._def,exactLength:{value:n,message:x.toString(i)}})}nonempty(n){return this.min(1,n)}}H.create=(a,n)=>new H({type:a,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...O(n)});function Me(a){if(a instanceof R){const n={};for(const i in a.shape){const c=a.shape[i];n[i]=X.create(Me(c))}return new R({...a._def,shape:()=>n})}else return a instanceof H?new H({...a._def,type:Me(a.element)}):a instanceof X?X.create(Me(a.unwrap())):a instanceof fe?fe.create(Me(a.unwrap())):a instanceof Q?Q.create(a.items.map(n=>Me(n))):a}class R extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const n=this._def.shape(),i=M.objectKeys(n);return this._cached={shape:n,keys:i}}_parse(n){if(this._getType(n)!==b.object){const v=this._getOrReturnCtx(n);return _(v,{code:y.invalid_type,expected:b.object,received:v.parsedType}),A}const{status:c,ctx:u}=this._processInputParams(n),{shape:l,keys:h}=this._getCached(),m=[];if(!(this._def.catchall instanceof ne&&this._def.unknownKeys==="strip"))for(const v in u.data)h.includes(v)||m.push(v);const w=[];for(const v of h){const E=l[v],D=u.data[v];w.push({key:{status:"valid",value:v},value:E._parse(new Y(u,D,u.path,v)),alwaysSet:v in u.data})}if(this._def.catchall instanceof ne){const v=this._def.unknownKeys;if(v==="passthrough")for(const E of m)w.push({key:{status:"valid",value:E},value:{status:"valid",value:u.data[E]}});else if(v==="strict")m.length>0&&(_(u,{code:y.unrecognized_keys,keys:m}),c.dirty());else if(v!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const v=this._def.catchall;for(const E of m){const D=u.data[E];w.push({key:{status:"valid",value:E},value:v._parse(new Y(u,D,u.path,E)),alwaysSet:E in u.data})}}return u.common.async?Promise.resolve().then(async()=>{const v=[];for(const E of w){const D=await E.key,ie=await E.value;v.push({key:D,value:ie,alwaysSet:E.alwaysSet})}return v}).then(v=>B.mergeObjectSync(c,v)):B.mergeObjectSync(c,w)}get shape(){return this._def.shape()}strict(n){return x.errToObj,new R({...this._def,unknownKeys:"strict",...n!==void 0?{errorMap:(i,c)=>{var u,l,h,m;const w=(h=(l=(u=this._def).errorMap)===null||l===void 0?void 0:l.call(u,i,c).message)!==null&&h!==void 0?h:c.defaultError;return i.code==="unrecognized_keys"?{message:(m=x.errToObj(n).message)!==null&&m!==void 0?m:w}:{message:w}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(n){return new R({...this._def,shape:()=>({...this._def.shape(),...n})})}merge(n){return new R({unknownKeys:n._def.unknownKeys,catchall:n._def.catchall,shape:()=>({...this._def.shape(),...n._def.shape()}),typeName:T.ZodObject})}setKey(n,i){return this.augment({[n]:i})}catchall(n){return new R({...this._def,catchall:n})}pick(n){const i={};return M.objectKeys(n).forEach(c=>{n[c]&&this.shape[c]&&(i[c]=this.shape[c])}),new R({...this._def,shape:()=>i})}omit(n){const i={};return M.objectKeys(this.shape).forEach(c=>{n[c]||(i[c]=this.shape[c])}),new R({...this._def,shape:()=>i})}deepPartial(){return Me(this)}partial(n){const i={};return M.objectKeys(this.shape).forEach(c=>{const u=this.shape[c];n&&!n[c]?i[c]=u:i[c]=u.optional()}),new R({...this._def,shape:()=>i})}required(n){const i={};return M.objectKeys(this.shape).forEach(c=>{if(n&&!n[c])i[c]=this.shape[c];else{let l=this.shape[c];for(;l instanceof X;)l=l._def.innerType;i[c]=l}}),new R({...this._def,shape:()=>i})}keyof(){return Bn(M.objectKeys(this.shape))}}R.create=(a,n)=>new R({shape:()=>a,unknownKeys:"strip",catchall:ne.create(),typeName:T.ZodObject,...O(n)}),R.strictCreate=(a,n)=>new R({shape:()=>a,unknownKeys:"strict",catchall:ne.create(),typeName:T.ZodObject,...O(n)}),R.lazycreate=(a,n)=>new R({shape:a,unknownKeys:"strip",catchall:ne.create(),typeName:T.ZodObject,...O(n)});class qe extends I{_parse(n){const{ctx:i}=this._processInputParams(n),c=this._def.options;function u(l){for(const m of l)if(m.result.status==="valid")return m.result;for(const m of l)if(m.result.status==="dirty")return i.common.issues.push(...m.ctx.common.issues),m.result;const h=l.map(m=>new F(m.ctx.common.issues));return _(i,{code:y.invalid_union,unionErrors:h}),A}if(i.common.async)return Promise.all(c.map(async l=>{const h={...i,common:{...i.common,issues:[]},parent:null};return{result:await l._parseAsync({data:i.data,path:i.path,parent:h}),ctx:h}})).then(u);{let l;const h=[];for(const w of c){const v={...i,common:{...i.common,issues:[]},parent:null},E=w._parseSync({data:i.data,path:i.path,parent:v});if(E.status==="valid")return E;E.status==="dirty"&&!l&&(l={result:E,ctx:v}),v.common.issues.length&&h.push(v.common.issues)}if(l)return i.common.issues.push(...l.ctx.common.issues),l.result;const m=h.map(w=>new F(w));return _(i,{code:y.invalid_union,unionErrors:m}),A}}get options(){return this._def.options}}qe.create=(a,n)=>new qe({options:a,typeName:T.ZodUnion,...O(n)});const se=a=>a instanceof Ye?se(a.schema):a instanceof q?se(a.innerType()):a instanceof Qe?[a.value]:a instanceof de?a.options:a instanceof Xe?M.objectValues(a.enum):a instanceof Je?se(a._def.innerType):a instanceof We?[void 0]:a instanceof He?[null]:a instanceof X?[void 0,...se(a.unwrap())]:a instanceof fe?[null,...se(a.unwrap())]:a instanceof Jt||a instanceof rt?se(a.unwrap()):a instanceof et?se(a._def.innerType):[];class At extends I{_parse(n){const{ctx:i}=this._processInputParams(n);if(i.parsedType!==b.object)return _(i,{code:y.invalid_type,expected:b.object,received:i.parsedType}),A;const c=this.discriminator,u=i.data[c],l=this.optionsMap.get(u);return l?i.common.async?l._parseAsync({data:i.data,path:i.path,parent:i}):l._parseSync({data:i.data,path:i.path,parent:i}):(_(i,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[c]}),A)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(n,i,c){const u=new Map;for(const l of i){const h=se(l.shape[n]);if(!h.length)throw new Error(`A discriminator value for key \`${n}\` could not be extracted from all schema options`);for(const m of h){if(u.has(m))throw new Error(`Discriminator property ${String(n)} has duplicate value ${String(m)}`);u.set(m,l)}}return new At({typeName:T.ZodDiscriminatedUnion,discriminator:n,options:i,optionsMap:u,...O(c)})}}function Xt(a,n){const i=re(a),c=re(n);if(a===n)return{valid:!0,data:a};if(i===b.object&&c===b.object){const u=M.objectKeys(n),l=M.objectKeys(a).filter(m=>u.indexOf(m)!==-1),h={...a,...n};for(const m of l){const w=Xt(a[m],n[m]);if(!w.valid)return{valid:!1};h[m]=w.data}return{valid:!0,data:h}}else if(i===b.array&&c===b.array){if(a.length!==n.length)return{valid:!1};const u=[];for(let l=0;l<a.length;l++){const h=a[l],m=n[l],w=Xt(h,m);if(!w.valid)return{valid:!1};u.push(w.data)}return{valid:!0,data:u}}else return i===b.date&&c===b.date&&+a==+n?{valid:!0,data:a}:{valid:!1}}class Ge extends I{_parse(n){const{status:i,ctx:c}=this._processInputParams(n),u=(l,h)=>{if(Kt(l)||Kt(h))return A;const m=Xt(l.value,h.value);return m.valid?((Yt(l)||Yt(h))&&i.dirty(),{status:i.value,value:m.data}):(_(c,{code:y.invalid_intersection_types}),A)};return c.common.async?Promise.all([this._def.left._parseAsync({data:c.data,path:c.path,parent:c}),this._def.right._parseAsync({data:c.data,path:c.path,parent:c})]).then(([l,h])=>u(l,h)):u(this._def.left._parseSync({data:c.data,path:c.path,parent:c}),this._def.right._parseSync({data:c.data,path:c.path,parent:c}))}}Ge.create=(a,n,i)=>new Ge({left:a,right:n,typeName:T.ZodIntersection,...O(i)});class Q extends I{_parse(n){const{status:i,ctx:c}=this._processInputParams(n);if(c.parsedType!==b.array)return _(c,{code:y.invalid_type,expected:b.array,received:c.parsedType}),A;if(c.data.length<this._def.items.length)return _(c,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;!this._def.rest&&c.data.length>this._def.items.length&&(_(c,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),i.dirty());const l=[...c.data].map((h,m)=>{const w=this._def.items[m]||this._def.rest;return w?w._parse(new Y(c,h,c.path,m)):null}).filter(h=>!!h);return c.common.async?Promise.all(l).then(h=>B.mergeArray(i,h)):B.mergeArray(i,l)}get items(){return this._def.items}rest(n){return new Q({...this._def,rest:n})}}Q.create=(a,n)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:a,typeName:T.ZodTuple,rest:null,...O(n)})};class Ke extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){const{status:i,ctx:c}=this._processInputParams(n);if(c.parsedType!==b.object)return _(c,{code:y.invalid_type,expected:b.object,received:c.parsedType}),A;const u=[],l=this._def.keyType,h=this._def.valueType;for(const m in c.data)u.push({key:l._parse(new Y(c,m,c.path,m)),value:h._parse(new Y(c,c.data[m],c.path,m)),alwaysSet:m in c.data});return c.common.async?B.mergeObjectAsync(i,u):B.mergeObjectSync(i,u)}get element(){return this._def.valueType}static create(n,i,c){return i instanceof I?new Ke({keyType:n,valueType:i,typeName:T.ZodRecord,...O(c)}):new Ke({keyType:W.create(),valueType:n,typeName:T.ZodRecord,...O(i)})}}class St extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){const{status:i,ctx:c}=this._processInputParams(n);if(c.parsedType!==b.map)return _(c,{code:y.invalid_type,expected:b.map,received:c.parsedType}),A;const u=this._def.keyType,l=this._def.valueType,h=[...c.data.entries()].map(([m,w],v)=>({key:u._parse(new Y(c,m,c.path,[v,"key"])),value:l._parse(new Y(c,w,c.path,[v,"value"]))}));if(c.common.async){const m=new Map;return Promise.resolve().then(async()=>{for(const w of h){const v=await w.key,E=await w.value;if(v.status==="aborted"||E.status==="aborted")return A;(v.status==="dirty"||E.status==="dirty")&&i.dirty(),m.set(v.value,E.value)}return{status:i.value,value:m}})}else{const m=new Map;for(const w of h){const v=w.key,E=w.value;if(v.status==="aborted"||E.status==="aborted")return A;(v.status==="dirty"||E.status==="dirty")&&i.dirty(),m.set(v.value,E.value)}return{status:i.value,value:m}}}}St.create=(a,n,i)=>new St({valueType:n,keyType:a,typeName:T.ZodMap,...O(i)});class _e extends I{_parse(n){const{status:i,ctx:c}=this._processInputParams(n);if(c.parsedType!==b.set)return _(c,{code:y.invalid_type,expected:b.set,received:c.parsedType}),A;const u=this._def;u.minSize!==null&&c.data.size<u.minSize.value&&(_(c,{code:y.too_small,minimum:u.minSize.value,type:"set",inclusive:!0,exact:!1,message:u.minSize.message}),i.dirty()),u.maxSize!==null&&c.data.size>u.maxSize.value&&(_(c,{code:y.too_big,maximum:u.maxSize.value,type:"set",inclusive:!0,exact:!1,message:u.maxSize.message}),i.dirty());const l=this._def.valueType;function h(w){const v=new Set;for(const E of w){if(E.status==="aborted")return A;E.status==="dirty"&&i.dirty(),v.add(E.value)}return{status:i.value,value:v}}const m=[...c.data.values()].map((w,v)=>l._parse(new Y(c,w,c.path,v)));return c.common.async?Promise.all(m).then(w=>h(w)):h(m)}min(n,i){return new _e({...this._def,minSize:{value:n,message:x.toString(i)}})}max(n,i){return new _e({...this._def,maxSize:{value:n,message:x.toString(i)}})}size(n,i){return this.min(n,i).max(n,i)}nonempty(n){return this.min(1,n)}}_e.create=(a,n)=>new _e({valueType:a,minSize:null,maxSize:null,typeName:T.ZodSet,...O(n)});class $e extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(n){const{ctx:i}=this._processInputParams(n);if(i.parsedType!==b.function)return _(i,{code:y.invalid_type,expected:b.function,received:i.parsedType}),A;function c(m,w){return xt({data:m,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,bt(),Se].filter(v=>!!v),issueData:{code:y.invalid_arguments,argumentsError:w}})}function u(m,w){return xt({data:m,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,bt(),Se].filter(v=>!!v),issueData:{code:y.invalid_return_type,returnTypeError:w}})}const l={errorMap:i.common.contextualErrorMap},h=i.data;if(this._def.returns instanceof Ce){const m=this;return z(async function(...w){const v=new F([]),E=await m._def.args.parseAsync(w,l).catch(ae=>{throw v.addIssue(c(w,ae)),v}),D=await Reflect.apply(h,this,E);return await m._def.returns._def.type.parseAsync(D,l).catch(ae=>{throw v.addIssue(u(D,ae)),v})})}else{const m=this;return z(function(...w){const v=m._def.args.safeParse(w,l);if(!v.success)throw new F([c(w,v.error)]);const E=Reflect.apply(h,this,v.data),D=m._def.returns.safeParse(E,l);if(!D.success)throw new F([u(E,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...n){return new $e({...this._def,args:Q.create(n).rest(we.create())})}returns(n){return new $e({...this._def,returns:n})}implement(n){return this.parse(n)}strictImplement(n){return this.parse(n)}static create(n,i,c){return new $e({args:n||Q.create([]).rest(we.create()),returns:i||we.create(),typeName:T.ZodFunction,...O(c)})}}class Ye extends I{get schema(){return this._def.getter()}_parse(n){const{ctx:i}=this._processInputParams(n);return this._def.getter()._parse({data:i.data,path:i.path,parent:i})}}Ye.create=(a,n)=>new Ye({getter:a,typeName:T.ZodLazy,...O(n)});class Qe extends I{_parse(n){if(n.data!==this._def.value){const i=this._getOrReturnCtx(n);return _(i,{received:i.data,code:y.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:n.data}}get value(){return this._def.value}}Qe.create=(a,n)=>new Qe({value:a,typeName:T.ZodLiteral,...O(n)});function Bn(a,n){return new de({values:a,typeName:T.ZodEnum,...O(n)})}class de extends I{constructor(){super(...arguments),ze.set(this,void 0)}_parse(n){if(typeof n.data!="string"){const i=this._getOrReturnCtx(n),c=this._def.values;return _(i,{expected:M.joinValues(c),received:i.parsedType,code:y.invalid_type}),A}if(kt(this,ze)||Dn(this,ze,new Set(this._def.values)),!kt(this,ze).has(n.data)){const i=this._getOrReturnCtx(n),c=this._def.values;return _(i,{received:i.data,code:y.invalid_enum_value,options:c}),A}return z(n.data)}get options(){return this._def.values}get enum(){const n={};for(const i of this._def.values)n[i]=i;return n}get Values(){const n={};for(const i of this._def.values)n[i]=i;return n}get Enum(){const n={};for(const i of this._def.values)n[i]=i;return n}extract(n,i=this._def){return de.create(n,{...this._def,...i})}exclude(n,i=this._def){return de.create(this.options.filter(c=>!n.includes(c)),{...this._def,...i})}}ze=new WeakMap,de.create=Bn;class Xe extends I{constructor(){super(...arguments),Fe.set(this,void 0)}_parse(n){const i=M.getValidEnumValues(this._def.values),c=this._getOrReturnCtx(n);if(c.parsedType!==b.string&&c.parsedType!==b.number){const u=M.objectValues(i);return _(c,{expected:M.joinValues(u),received:c.parsedType,code:y.invalid_type}),A}if(kt(this,Fe)||Dn(this,Fe,new Set(M.getValidEnumValues(this._def.values))),!kt(this,Fe).has(n.data)){const u=M.objectValues(i);return _(c,{received:c.data,code:y.invalid_enum_value,options:u}),A}return z(n.data)}get enum(){return this._def.values}}Fe=new WeakMap,Xe.create=(a,n)=>new Xe({values:a,typeName:T.ZodNativeEnum,...O(n)});class Ce extends I{unwrap(){return this._def.type}_parse(n){const{ctx:i}=this._processInputParams(n);if(i.parsedType!==b.promise&&i.common.async===!1)return _(i,{code:y.invalid_type,expected:b.promise,received:i.parsedType}),A;const c=i.parsedType===b.promise?i.data:Promise.resolve(i.data);return z(c.then(u=>this._def.type.parseAsync(u,{path:i.path,errorMap:i.common.contextualErrorMap})))}}Ce.create=(a,n)=>new Ce({type:a,typeName:T.ZodPromise,...O(n)});class q extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(n){const{status:i,ctx:c}=this._processInputParams(n),u=this._def.effect||null,l={addIssue:h=>{_(c,h),h.fatal?i.abort():i.dirty()},get path(){return c.path}};if(l.addIssue=l.addIssue.bind(l),u.type==="preprocess"){const h=u.transform(c.data,l);if(c.common.async)return Promise.resolve(h).then(async m=>{if(i.value==="aborted")return A;const w=await this._def.schema._parseAsync({data:m,path:c.path,parent:c});return w.status==="aborted"?A:w.status==="dirty"||i.value==="dirty"?Oe(w.value):w});{if(i.value==="aborted")return A;const m=this._def.schema._parseSync({data:h,path:c.path,parent:c});return m.status==="aborted"?A:m.status==="dirty"||i.value==="dirty"?Oe(m.value):m}}if(u.type==="refinement"){const h=m=>{const w=u.refinement(m,l);if(c.common.async)return Promise.resolve(w);if(w instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return m};if(c.common.async===!1){const m=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});return m.status==="aborted"?A:(m.status==="dirty"&&i.dirty(),h(m.value),{status:i.value,value:m.value})}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(m=>m.status==="aborted"?A:(m.status==="dirty"&&i.dirty(),h(m.value).then(()=>({status:i.value,value:m.value}))))}if(u.type==="transform")if(c.common.async===!1){const h=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(!ye(h))return h;const m=u.transform(h.value,l);if(m instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:i.value,value:m}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(h=>ye(h)?Promise.resolve(u.transform(h.value,l)).then(m=>({status:i.value,value:m})):h);M.assertNever(u)}}q.create=(a,n,i)=>new q({schema:a,typeName:T.ZodEffects,effect:n,...O(i)}),q.createWithPreprocess=(a,n,i)=>new q({schema:n,effect:{type:"preprocess",transform:a},typeName:T.ZodEffects,...O(i)});class X extends I{_parse(n){return this._getType(n)===b.undefined?z(void 0):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}X.create=(a,n)=>new X({innerType:a,typeName:T.ZodOptional,...O(n)});class fe extends I{_parse(n){return this._getType(n)===b.null?z(null):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}fe.create=(a,n)=>new fe({innerType:a,typeName:T.ZodNullable,...O(n)});class Je extends I{_parse(n){const{ctx:i}=this._processInputParams(n);let c=i.data;return i.parsedType===b.undefined&&(c=this._def.defaultValue()),this._def.innerType._parse({data:c,path:i.path,parent:i})}removeDefault(){return this._def.innerType}}Je.create=(a,n)=>new Je({innerType:a,typeName:T.ZodDefault,defaultValue:typeof n.default=="function"?n.default:()=>n.default,...O(n)});class et extends I{_parse(n){const{ctx:i}=this._processInputParams(n),c={...i,common:{...i.common,issues:[]}},u=this._def.innerType._parse({data:c.data,path:c.path,parent:{...c}});return Le(u)?u.then(l=>({status:"valid",value:l.status==="valid"?l.value:this._def.catchValue({get error(){return new F(c.common.issues)},input:c.data})})):{status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new F(c.common.issues)},input:c.data})}}removeCatch(){return this._def.innerType}}et.create=(a,n)=>new et({innerType:a,typeName:T.ZodCatch,catchValue:typeof n.catch=="function"?n.catch:()=>n.catch,...O(n)});class Ot extends I{_parse(n){if(this._getType(n)!==b.nan){const c=this._getOrReturnCtx(n);return _(c,{code:y.invalid_type,expected:b.nan,received:c.parsedType}),A}return{status:"valid",value:n.data}}}Ot.create=a=>new Ot({typeName:T.ZodNaN,...O(a)});const Qi=Symbol("zod_brand");class Jt extends I{_parse(n){const{ctx:i}=this._processInputParams(n),c=i.data;return this._def.type._parse({data:c,path:i.path,parent:i})}unwrap(){return this._def.type}}class tt extends I{_parse(n){const{status:i,ctx:c}=this._processInputParams(n);if(c.common.async)return(async()=>{const l=await this._def.in._parseAsync({data:c.data,path:c.path,parent:c});return l.status==="aborted"?A:l.status==="dirty"?(i.dirty(),Oe(l.value)):this._def.out._parseAsync({data:l.value,path:c.path,parent:c})})();{const u=this._def.in._parseSync({data:c.data,path:c.path,parent:c});return u.status==="aborted"?A:u.status==="dirty"?(i.dirty(),{status:"dirty",value:u.value}):this._def.out._parseSync({data:u.value,path:c.path,parent:c})}}static create(n,i){return new tt({in:n,out:i,typeName:T.ZodPipeline})}}class rt extends I{_parse(n){const i=this._def.innerType._parse(n),c=u=>(ye(u)&&(u.value=Object.freeze(u.value)),u);return Le(i)?i.then(u=>c(u)):c(i)}unwrap(){return this._def.innerType}}rt.create=(a,n)=>new rt({innerType:a,typeName:T.ZodReadonly,...O(n)});function Ln(a,n={},i){return a?Ie.create().superRefine((c,u)=>{var l,h;if(!a(c)){const m=typeof n=="function"?n(c):typeof n=="string"?{message:n}:n,w=(h=(l=m.fatal)!==null&&l!==void 0?l:i)!==null&&h!==void 0?h:!0,v=typeof m=="string"?{message:m}:m;u.addIssue({code:"custom",...v,fatal:w})}}):Ie.create()}const Xi={object:R.lazycreate};var T;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(T||(T={}));const Ji=(a,n={message:`Input not instance of ${a.name}`})=>Ln(i=>i instanceof a,n),zn=W.create,Fn=ue.create,ea=Ot.create,ta=le.create,Vn=Ve.create,ra=ve.create,na=Et.create,sa=We.create,ia=He.create,aa=Ie.create,oa=we.create,ca=ne.create,ua=Tt.create,la=H.create,da=R.create,fa=R.strictCreate,ha=qe.create,ma=At.create,pa=Ge.create,ga=Q.create,ya=Ke.create,va=St.create,wa=_e.create,_a=$e.create,ba=Ye.create,xa=Qe.create,ka=de.create,Ea=Xe.create,Ta=Ce.create,Wn=q.create,Aa=X.create,Sa=fe.create,Oa=q.createWithPreprocess,Ia=tt.create;var J=Object.freeze({__proto__:null,defaultErrorMap:Se,setErrorMap:Oi,getErrorMap:bt,makeIssue:xt,EMPTY_PATH:Ii,addIssueToContext:_,ParseStatus:B,INVALID:A,DIRTY:Oe,OK:z,isAborted:Kt,isDirty:Yt,isValid:ye,isAsync:Le,get util(){return M},get objectUtil(){return Gt},ZodParsedType:b,getParsedType:re,ZodType:I,datetimeRegex:Zn,ZodString:W,ZodNumber:ue,ZodBigInt:le,ZodBoolean:Ve,ZodDate:ve,ZodSymbol:Et,ZodUndefined:We,ZodNull:He,ZodAny:Ie,ZodUnknown:we,ZodNever:ne,ZodVoid:Tt,ZodArray:H,ZodObject:R,ZodUnion:qe,ZodDiscriminatedUnion:At,ZodIntersection:Ge,ZodTuple:Q,ZodRecord:Ke,ZodMap:St,ZodSet:_e,ZodFunction:$e,ZodLazy:Ye,ZodLiteral:Qe,ZodEnum:de,ZodNativeEnum:Xe,ZodPromise:Ce,ZodEffects:q,ZodTransformer:q,ZodOptional:X,ZodNullable:fe,ZodDefault:Je,ZodCatch:et,ZodNaN:Ot,BRAND:Qi,ZodBranded:Jt,ZodPipeline:tt,ZodReadonly:rt,custom:Ln,Schema:I,ZodSchema:I,late:Xi,get ZodFirstPartyTypeKind(){return T},coerce:{string:a=>W.create({...a,coerce:!0}),number:a=>ue.create({...a,coerce:!0}),boolean:a=>Ve.create({...a,coerce:!0}),bigint:a=>le.create({...a,coerce:!0}),date:a=>ve.create({...a,coerce:!0})},any:aa,array:la,bigint:ta,boolean:Vn,date:ra,discriminatedUnion:ma,effect:Wn,enum:ka,function:_a,instanceof:Ji,intersection:pa,lazy:ba,literal:xa,map:va,nan:ea,nativeEnum:Ea,never:ca,null:ia,nullable:Sa,number:Fn,object:da,oboolean:()=>Vn().optional(),onumber:()=>Fn().optional(),optional:Aa,ostring:()=>zn().optional(),pipeline:Ia,preprocess:Oa,promise:Ta,record:ya,set:wa,strictObject:fa,string:zn,symbol:na,transformer:Wn,tuple:ga,undefined:sa,union:ha,unknown:oa,void:ua,NEVER:A,ZodIssueCode:y,quotelessJson:Si,ZodError:F});const Hn=K.getInstance(),Ma=J.object({id:J.string(),message:J.string(),username:J.string(),address:J.string(),timestamp:J.number(),signature:J.string(),index:J.number(),chatTopic:J.string(),userTopic:J.string()});function $a(a){const n=Ma.safeParse(a);return n.success?Ca({usnermame:a.username,address:a.address,timestamp:a.timestamp})?!0:(console.warn("Invalid messageSender"),!1):(Hn.warn(n.error.format()),!1)}function Ca(a){try{const n={username:a.username,address:a.address,timestamp:a.timestamp},i=new TextEncoder,c=Z.concatBytes(i.encode(`Ethereum Signed Message:
11
+ 32`),Z.keccak256(i.encode(JSON.stringify(n))));if(new S.Signature(a.signature).isValid(c,a.address))throw new Error("Signature verification failed!");return!0}catch(n){return Hn.warn("Error in validateUserSignature",n),!1}}const G={LOADING_INIT:"loadingInit",LOADING_PREVIOUS_MESSAGES:"loadingPreviousMessages",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_INITIATED:"messageRequestInitiated",MESSAGE_REQUEST_UPLOADED:"messageRequestUploaded",MESSAGE_REQUEST_ERROR:"messageRequestError",CRITICAL_ERROR:"criticalError"};class Na{constructor(n,i){this.utils=n,this.emitter=i,this.logger=K.getInstance(),this.errorHandler=new qt,this.historyIndex=null}async init(){try{const n=await this.utils.fetchLatestChatMessage();return this.historyIndex=n.index,await this.fetchPreviousMessages(),this.historyIndex}catch(n){return this.errorHandler.handleError(n,"SwarmHistory.init"),S.FeedIndex.fromBigInt(0n)}}async fetchPreviousMessages(n=10){try{if(!this.historyIndex){this.logger.warn("History index is not set. Cannot fetch previous messages.");return}if(this.historyIndex.toBigInt()===0n){this.logger.warn("No previous messages to fetch.");return}const i=this.historyIndex.toBigInt(),c=i>BigInt(n)?i-BigInt(n):0n;for(let u=i-1n;u>=c;u--){const l=await this.utils.fetchChatMessage(S.FeedIndex.fromBigInt(u));if(this.emitter.emit(G.MESSAGE_RECEIVED,l),this.historyIndex=S.FeedIndex.fromBigInt(u),u===0n)break}}catch(i){this.errorHandler.handleError(i,"SwarmHistory.fetchPreviousMessages")}}}class Ra{constructor(n,i){this.userDetails=n,this.swarmSettings=i,this.depth=24,this.logger=K.getInstance(),this.errorHandler=new qt,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(n,i){const{enveloped:c,stamp:u}=this.swarmSettings;if(!c)await this.writeOwnFeedDataByIndexOwned(n,i);else if(u)await this.writeOwnFeedDataByIndexEnvelope(n,i);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(n,i){const{bee:c,stamp:u,chatTopic:l}=this.swarmSettings,{privateKey:h,ownAddress:m}=this.userDetails,w=this.generateUserOwnedFeedId(l,m),v=S.Topic.fromString(w);console.log("DEBUG: feedID write",v.toString(),m,n,w),await c.makeFeedWriter(v,new S.PrivateKey(h)).uploadPayload(u,JSON.stringify(i),{index:n})}async writeOwnFeedDataByIndexEnvelope(n,i){const{bee:c,stamp:u,chatTopic:l}=this.swarmSettings,{privateKey:h,ownAddress:m}=this.userDetails,w=new S.PrivateKey(h),v=S.Stamper.fromBlank(h,u,this.depth),E=this.generateUserOwnedFeedId(l,m),D=S.Topic.fromString(E),ie=$n(D,n),ae=Cn(i),nt=Nn(ae,ie,w),Ne={hash:()=>nt.address.toUint8Array()},er=v.stamp(Ne),{upload:tr}=c.makeSOCWriter(w),st=S.Bytes.fromUtf8(i);return(await tr(er,ie,st.toUint8Array())).reference.toHex()}orderMessages(n){return n.sort((i,c)=>i.timestamp-c.timestamp)}async retryAwaitableAsync(n,i=3,c=250){return new Promise((u,l)=>{n().then(u).catch(h=>{i>0?(this.logger.info(`Retrying... Attempts left: ${i}. Error: ${h.message}`),setTimeout(()=>{this.retryAwaitableAsync(n,i-1,c).then(u).catch(l)},c)):(this.errorHandler.handleError(h,"Utils.retryAwaitableAsync"),l(h))})})}async uploadObjectToBee(n){const{enveloped:i,stamp:c}=this.swarmSettings;if(i){if(c)return this.uploadObjectToBeeEnvelope(n);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(n)}async uploadObjectToBeeOwn(n){try{const{bee:i,stamp:c}=this.swarmSettings,u=await i.uploadData(c,JSON.stringify(n),{redundancyLevel:4});return console.log("DEBUG: result",u.reference.toString()),u.reference.toString()}catch(i){return this.errorHandler.handleError(i,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(n){try{const{bee:i,stamp:c}=this.swarmSettings,{privateKey:u}=this.userDetails,l=S.Stamper.fromBlank(u,c,this.depth),h=S.Bytes.fromUtf8(JSON.stringify(n)),m=new _i(async v=>{await i.uploadChunk(l.stamp(v),v.build())});await m.append(h.toUint8Array());const w=await m.finalize();return Z.uint8ArrayToHex(w.hash())}catch(i){return this.errorHandler.handleError(i,"Utils.uploadObjectToBee"),null}}async getOwnLatestFeedIndex(){try{const{bee:n,chatTopic:i}=this.swarmSettings,{ownAddress:c}=this.userDetails,u=this.generateUserOwnedFeedId(i,c),l=S.Topic.fromString(u),m=await n.makeFeedReader(l,c).downloadPayload(),w=Number(m.feedIndex.toBigInt()),v=w+1;return console.log("DEBUG: getLatestFeedIndex",w,v),{latestIndex:w,nextIndex:v}}catch(n){if(this.isNotFoundError(n))return{latestIndex:-1,nextIndex:0};throw n}}async fetchLatestChatMessage(){const{bee:n,chatTopic:i,chatAddress:c}=this.swarmSettings,l=await n.makeFeedReader(S.Topic.fromString(i),Ht(c)).downloadPayload();return{message:l.payload.toJSON(),index:l.feedIndex}}async fetchChatMessage(n){const{bee:i,chatTopic:c,chatAddress:u}=this.swarmSettings;return(await i.makeFeedReader(S.Topic.fromString(c),Ht(u)).downloadPayload({index:n})).payload.toJSON()}async sendMessageToGsoc(n){const{enveloped:i,stamp:c}=this.swarmSettings;if(!i)await this.sendMessageToGsocOwn(n);else if(c)await this.sendMessageToGsocEnvelope(n);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async rawSocDownload(n,i){const{beeUrl:c}=this.swarmSettings,u=await fetch(`${c}/soc/${n}/${i}`,{headers:{"swarm-chunk-retrieval-timeout":"2000ms"}});if(!u.ok)throw new Error(`Failed to fetch: ${n}/${i}`);return u}async sendMessageToGsocOwn(n){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:i,stamp:c,gsocTopic:u,gsocResourceId:l}=this.swarmSettings,h=new S.PrivateKey(l),m=S.Identifier.fromString(u),w=S.Bytes.fromUtf8(n),{upload:v}=i.makeSOCWriter(h,{timeout:this.UPLOAD_GSOC_TIMEOUT});await v(c,m,w.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(n){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:i,stamp:c,gsocTopic:u,gsocResourceId:l}=this.swarmSettings,{privateKey:h}=this.userDetails,m=S.Stamper.fromBlank(h,c,this.depth),w=new S.PrivateKey(l),v=S.Identifier.fromString(u),E=S.Bytes.fromUtf8(n),D=Cn(E.toUint8Array()),ie=Nn(D,v,w),ae={hash:()=>ie.address.toUint8Array()},nt=m.stamp(ae),{upload:Ne}=i.makeSOCWriter(w,{timeout:this.UPLOAD_GSOC_TIMEOUT});await Ne(nt,v,E.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(n,i){return`${n}_EthercastChat_${i}`}isNotFoundError(n){return n.stack.includes("404")||n.message.includes("Not Found")||n.message.includes("404")}}class Da{constructor(n){this.logger=K.getInstance(),this.errorHandler=new qt,this.gsocIndex=null,this.fetchMessageTimer=null;const i=new S.PrivateKey(Ht(n.user.privateKey));this.userDetails={privateKey:n.user.privateKey,ownAddress:i.publicKey().address().toString(),nickname:n.user.nickname,ownIndex:-1},this.swarmSettings={bee:new S.Bee(n.infra.beeUrl),beeUrl:n.infra.beeUrl,stamp:n.infra.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:n.infra.enveloped,gsocTopic:n.infra.gsocTopic,gsocResourceId:n.infra.gsocResourceId,chatTopic:n.infra.chatTopic,chatAddress:n.infra.chatAddress,messageFetchInterval:n.infra.messageFetchInterval||1500},this.emitter=new Ai,this.utils=new Ra(this.userDetails,this.swarmSettings),this.history=new Na(this.utils,this.emitter)}start(){this.init(),this.startMessagesFetchProcess()}stop(){this.emitter.cleanAll(),this.stopMessagesFetchProcess()}getEmitter(){return this.emitter}orderMessages(n){return this.utils.orderMessages(n)}async sendMessage(n,i){const c=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,u={id:i||vi(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,chatTopic:this.swarmSettings.chatTopic,userTopic:this.utils.generateUserOwnedFeedId(this.swarmSettings.chatTopic,this.userDetails.ownAddress),signature:this.getSignature(),timestamp:Date.now(),index:c,message:n};try{this.emitter.emit(G.MESSAGE_REQUEST_INITIATED,u),await this.utils.writeOwnFeedDataByIndex(c,JSON.stringify(u)),this.userDetails.ownIndex=c,this.emitter.emit(G.MESSAGE_REQUEST_UPLOADED,u),await this.broadcastUserMessage(u)}catch(l){this.emitter.emit(G.MESSAGE_REQUEST_ERROR,u),this.errorHandler.handleError(l,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(G.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages()}finally{this.emitter.emit(G.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(n){this.sendMessage(n.message,n.id)}async retryBroadcastUserMessage(n){this.broadcastUserMessage(n)}async init(){try{this.emitter.emit(G.LOADING_INIT,!0);const[n,i]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(n.status==="rejected")throw n.reason;i.status==="fulfilled"&&(this.gsocIndex=i.value),this.emitter.emit(G.LOADING_INIT,!1)}catch(n){this.errorHandler.handleError(n,"Chat.initSelfState"),this.emitter.emit(G.CRITICAL_ERROR,n)}}async initOwnIndex(){const{latestIndex:c}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=c}async fetchLatestMessage(){var n;try{const i=(n=this.gsocIndex)==null?void 0:n.next();if(!i){this.logger.error("No next index available for fetching the latest message.");return}const c=S.Topic.fromString(this.swarmSettings.chatTopic),u=$n(c,i),l=await this.utils.rawSocDownload(this.swarmSettings.chatAddress,u.toString());if(this.logger.debug("fetchLatestMessage entry CALLED",l),!$a(l)){this.logger.warn("Invalid GSOC message during fetching");return}this.emitter.emit(G.MESSAGE_RECEIVED,JSON.parse(l)),this.gsocIndex=i}catch(i){this.errorHandler.handleError(i,"Chat.fetchLatestMessage")}}async broadcastUserMessage(n){try{return this.logger.debug("broadcastUserMessage entry CALLED"),console.log("DEBUG broadcastUserMessage",n),this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify(n)))}catch(i){this.errorHandler.handleError(i,"Chat.broadcastUserMessage")}}getSignature(){const{ownAddress:n,privateKey:i,nickname:c}=this.userDetails,u=new S.EthAddress(n).toString(),l=new S.PrivateKey(i);if(l.publicKey().address().toString()!==u)throw new Error("The provided address does not match the address derived from the private key");const m=Date.now();return l.sign(JSON.stringify({username:c,address:u,timestamp:m})).toHex()}startMessagesFetchProcess(){const{messageFetchInterval:n}=this.swarmSettings;if(this.fetchMessageTimer){this.logger.warn("Messages fetch process is already running.");return}this.fetchMessageTimer=setInterval(this.fetchLatestMessage.bind(this),n)}stopMessagesFetchProcess(){this.fetchMessageTimer&&(clearInterval(this.fetchMessageTimer),this.fetchMessageTimer=null)}}ce.EVENTS=G,ce.SwarmChat=Da,Object.defineProperty(ce,Symbol.toStringTag,{value:"Module"})});