@solarpunkltd/swarm-chat-js 0.0.1 → 2.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.
- package/README.md +3 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.esm.js +43198 -23601
- package/dist/index.js +23 -26
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/{libs → src/lib}/constants.d.ts +5 -5
- package/dist/src/lib/constants.d.ts.map +1 -0
- package/dist/src/lib/core.d.ts +47 -0
- package/dist/src/lib/core.d.ts.map +1 -0
- package/dist/src/lib/history.d.ts +49 -0
- package/dist/src/lib/history.d.ts.map +1 -0
- package/dist/src/lib/mine.d.ts +2 -0
- package/dist/src/lib/mine.d.ts.map +1 -0
- package/dist/src/lib/swarmEventEmitterReader.d.ts +15 -0
- package/dist/src/lib/swarmEventEmitterReader.d.ts.map +1 -0
- package/dist/src/lib/types/chat.d.ts +57 -0
- package/dist/src/lib/types/chat.d.ts.map +1 -0
- package/dist/src/lib/types/index.d.ts +4 -0
- package/dist/src/lib/types/index.d.ts.map +1 -0
- package/dist/src/lib/types/message.d.ts +14 -0
- package/dist/src/lib/types/message.d.ts.map +1 -0
- package/dist/src/lib/types/user.d.ts +35 -0
- package/dist/src/lib/types/user.d.ts.map +1 -0
- package/dist/src/lib/utils.d.ts +31 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/utils/bee.d.ts +18 -0
- package/dist/src/utils/bee.d.ts.map +1 -0
- package/dist/src/utils/common.d.ts +4 -0
- package/dist/src/utils/common.d.ts.map +1 -0
- package/dist/src/utils/error.d.ts +6 -0
- package/dist/src/utils/error.d.ts.map +1 -0
- package/dist/src/utils/eventEmitter.d.ts.map +1 -0
- package/dist/src/utils/logger.d.ts +12 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/{utils → src/utils}/queue.d.ts +3 -8
- package/dist/src/utils/queue.d.ts.map +1 -0
- package/dist/src/utils/validation.d.ts +7 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/src/utils/waitForBroadcast.d.ts +10 -0
- package/dist/src/utils/waitForBroadcast.d.ts.map +1 -0
- package/dist/swarm-chat-umd.js +27 -0
- package/package.json +12 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/libs/constants.d.ts.map +0 -1
- package/dist/libs/core.d.ts +0 -59
- package/dist/libs/core.d.ts.map +0 -1
- package/dist/libs/mine.d.ts +0 -4
- package/dist/libs/mine.d.ts.map +0 -1
- package/dist/libs/types.d.ts +0 -85
- package/dist/libs/types.d.ts.map +0 -1
- package/dist/libs/utils.d.ts +0 -34
- package/dist/libs/utils.d.ts.map +0 -1
- package/dist/swarm-stream-umd.js +0 -30
- package/dist/utils/common.d.ts +0 -2
- package/dist/utils/common.d.ts.map +0 -1
- package/dist/utils/eventEmitter.d.ts.map +0 -1
- package/dist/utils/queue.d.ts.map +0 -1
- /package/dist/{utils → src/utils}/eventEmitter.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
(function(ft,Te){typeof exports=="object"&&typeof module<"u"?Te(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],Te):(ft=typeof globalThis<"u"?globalThis:ft||self,Te(ft.SwarmChatJs={},ft.BeeJs))})(this,function(ft,Te){"use strict";var rae=Object.defineProperty;var c6=ft=>{throw TypeError(ft)};var nae=(ft,Te,ut)=>Te in ft?rae(ft,Te,{enumerable:!0,configurable:!0,writable:!0,value:ut}):ft[Te]=ut;var Q=(ft,Te,ut)=>nae(ft,typeof Te!="symbol"?Te+"":Te,ut),M_=(ft,Te,ut)=>Te.has(ft)||c6("Cannot "+ut);var T=(ft,Te,ut)=>(M_(ft,Te,"read from private field"),ut?ut.call(ft):Te.get(ft)),se=(ft,Te,ut)=>Te.has(ft)?c6("Cannot add the same private member more than once"):Te instanceof WeakSet?Te.add(ft):Te.set(ft,ut),F=(ft,Te,ut,xn)=>(M_(ft,Te,"write to private field"),xn?xn.call(ft,ut):Te.set(ft,ut),ut),Ee=(ft,Te,ut)=>(M_(ft,Te,"access private method"),ut);var bd=(ft,Te,ut,xn)=>({set _(Mc){F(ft,Te,Mc,ut)},get _(){return T(ft,Te,xn)}});var Zu,ic,$o,Qu,Yu,Oi,js,Ju,Xu,Hr,qn,Ks,sc,oc,ac,as,Ni,Fo,cc,_d,Nh,Ch,Bh,Zn,el,uc,tl,Ws,lc,nl,yg,Un,Qn,fc,hc,Ho,dc,U_,f6,il,sl,ol,pc,qs,yc,cs,al,cl,ul,ll,fl,hl,dl,pl,gl,yl,ml,mc,zo,Qs,Go,wl,mg,Ph,Js,bl,Zp,h6,Xr,Bi,Mh,D_,_l,wg,Vo,Kl,us,ls,fs,cn,hs,bg,_g,Xs,Lh,jo,Al,Uh,Dh,eC,Ko,bc,Wo,Wl,Jp,d6,Fh,Hh,El,xl,qo,eo,hi,Zo,ds,Il,Ag,_c,Ac,Qo,Sl,to,Xp,kl,ro,Tl,Ol,Yo,di,eg,p6,un,Jo,ln,Nl,Yn,vc,Xo,no,zh,pi,Cl,Bl,ct,Jn,$_,F_,Ad,H_,vd,vg,En,ps,Ec,ea,xc,Pl,ta,z_,G_,Rc,Ic,Ml,io,gs,Pi,gi,Dn,Gh,V_,ra,Ll,ys,Vh,na,Sc,ia,jh,kc,Ul,sa,Tc,Mi;var ut=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Mc(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function g6(){this.__data__=[],this.size=0}var y6=g6;function m6(r,e){return r===e||r!==r&&e!==e}var ql=m6,w6=ql;function b6(r,e){for(var t=r.length;t--;)if(w6(r[t][0],e))return t;return-1}var Ed=b6,_6=Ed,A6=Array.prototype,v6=A6.splice;function E6(r){var e=this.__data__,t=_6(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():v6.call(e,t,1),--this.size,!0}var x6=E6,R6=Ed;function I6(r){var e=this.__data__,t=R6(e,r);return t<0?void 0:e[t][1]}var S6=I6,k6=Ed;function T6(r){return k6(this.__data__,r)>-1}var O6=T6,N6=Ed;function C6(r,e){var t=this.__data__,n=N6(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var B6=C6,P6=y6,M6=x6,L6=S6,U6=O6,D6=B6;function Lc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Lc.prototype.clear=P6,Lc.prototype.delete=M6,Lc.prototype.get=L6,Lc.prototype.has=U6,Lc.prototype.set=D6;var xd=Lc,$6=xd;function F6(){this.__data__=new $6,this.size=0}var H6=F6;function z6(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var G6=z6;function V6(r){return this.__data__.get(r)}var j6=V6;function K6(r){return this.__data__.has(r)}var W6=K6,q6=typeof ut=="object"&&ut&&ut.Object===Object&&ut,j_=q6,Z6=j_,Q6=typeof self=="object"&&self&&self.Object===Object&&self,Y6=Z6||Q6||Function("return this")(),Rn=Y6,J6=Rn,X6=J6.Symbol,Uc=X6,K_=Uc,W_=Object.prototype,e3=W_.hasOwnProperty,t3=W_.toString,Zl=K_?K_.toStringTag:void 0;function r3(r){var e=e3.call(r,Zl),t=r[Zl];try{r[Zl]=void 0;var n=!0}catch{}var i=t3.call(r);return n&&(e?r[Zl]=t:delete r[Zl]),i}var n3=r3,i3=Object.prototype,s3=i3.toString;function o3(r){return s3.call(r)}var a3=o3,q_=Uc,c3=n3,u3=a3,l3="[object Null]",f3="[object Undefined]",Z_=q_?q_.toStringTag:void 0;function h3(r){return r==null?r===void 0?f3:l3:Z_&&Z_ in Object(r)?c3(r):u3(r)}var la=h3;function d3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var yi=d3,p3=la,g3=yi,y3="[object AsyncFunction]",m3="[object Function]",w3="[object GeneratorFunction]",b3="[object Proxy]";function _3(r){if(!g3(r))return!1;var e=p3(r);return e==m3||e==w3||e==y3||e==b3}var Rd=_3,A3=Rn,v3=A3["__core-js_shared__"],E3=v3,Eg=E3,Q_=function(){var r=/[^.]+$/.exec(Eg&&Eg.keys&&Eg.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function x3(r){return!!Q_&&Q_ in r}var R3=x3,I3=Function.prototype,S3=I3.toString;function k3(r){if(r!=null){try{return S3.call(r)}catch{}try{return r+""}catch{}}return""}var Y_=k3,T3=Rd,O3=R3,N3=yi,C3=Y_,B3=/[\\^$.*+?()[\]{}|]/g,P3=/^\[object .+?Constructor\]$/,M3=Function.prototype,L3=Object.prototype,U3=M3.toString,D3=L3.hasOwnProperty,$3=RegExp("^"+U3.call(D3).replace(B3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F3(r){if(!N3(r)||O3(r))return!1;var e=T3(r)?$3:P3;return e.test(C3(r))}var H3=F3;function z3(r,e){return r==null?void 0:r[e]}var G3=z3,V3=H3,j3=G3;function K3(r,e){var t=j3(r,e);return V3(t)?t:void 0}var fa=K3,W3=fa,q3=Rn,Z3=W3(q3,"Map"),xg=Z3,Q3=fa,Y3=Q3(Object,"create"),Id=Y3,J_=Id;function J3(){this.__data__=J_?J_(null):{},this.size=0}var X3=J3;function eB(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var tB=eB,rB=Id,nB="__lodash_hash_undefined__",iB=Object.prototype,sB=iB.hasOwnProperty;function oB(r){var e=this.__data__;if(rB){var t=e[r];return t===nB?void 0:t}return sB.call(e,r)?e[r]:void 0}var aB=oB,cB=Id,uB=Object.prototype,lB=uB.hasOwnProperty;function fB(r){var e=this.__data__;return cB?e[r]!==void 0:lB.call(e,r)}var hB=fB,dB=Id,pB="__lodash_hash_undefined__";function gB(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=dB&&e===void 0?pB:e,this}var yB=gB,mB=X3,wB=tB,bB=aB,_B=hB,AB=yB;function Dc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Dc.prototype.clear=mB,Dc.prototype.delete=wB,Dc.prototype.get=bB,Dc.prototype.has=_B,Dc.prototype.set=AB;var vB=Dc,X_=vB,EB=xd,xB=xg;function RB(){this.size=0,this.__data__={hash:new X_,map:new(xB||EB),string:new X_}}var IB=RB;function SB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var kB=SB,TB=kB;function OB(r,e){var t=r.__data__;return TB(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Sd=OB,NB=Sd;function CB(r){var e=NB(this,r).delete(r);return this.size-=e?1:0,e}var BB=CB,PB=Sd;function MB(r){return PB(this,r).get(r)}var LB=MB,UB=Sd;function DB(r){return UB(this,r).has(r)}var $B=DB,FB=Sd;function HB(r,e){var t=FB(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var zB=HB,GB=IB,VB=BB,jB=LB,KB=$B,WB=zB;function $c(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}$c.prototype.clear=GB,$c.prototype.delete=VB,$c.prototype.get=jB,$c.prototype.has=KB,$c.prototype.set=WB;var Rg=$c,qB=xd,ZB=xg,QB=Rg,YB=200;function JB(r,e){var t=this.__data__;if(t instanceof qB){var n=t.__data__;if(!ZB||n.length<YB-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new QB(n)}return t.set(r,e),this.size=t.size,this}var XB=JB,e8=xd,t8=H6,r8=G6,n8=j6,i8=W6,s8=XB;function Fc(r){var e=this.__data__=new e8(r);this.size=e.size}Fc.prototype.clear=t8,Fc.prototype.delete=r8,Fc.prototype.get=n8,Fc.prototype.has=i8,Fc.prototype.set=s8;var kd=Fc,o8="__lodash_hash_undefined__";function a8(r){return this.__data__.set(r,o8),this}var c8=a8;function u8(r){return this.__data__.has(r)}var l8=u8,f8=Rg,h8=c8,d8=l8;function Td(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new f8;++e<t;)this.add(r[e])}Td.prototype.add=Td.prototype.push=h8,Td.prototype.has=d8;var p8=Td;function g8(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var y8=g8;function m8(r,e){return r.has(e)}var w8=m8,b8=p8,_8=y8,A8=w8,v8=1,E8=2;function x8(r,e,t,n,i,s){var o=t&v8,a=r.length,u=e.length;if(a!=u&&!(o&&u>a))return!1;var l=s.get(r),h=s.get(e);if(l&&h)return l==e&&h==r;var g=-1,b=!0,w=t&E8?new b8:void 0;for(s.set(r,e),s.set(e,r);++g<a;){var I=r[g],S=e[g];if(n)var x=o?n(S,I,g,e,r,s):n(I,S,g,r,e,s);if(x!==void 0){if(x)continue;b=!1;break}if(w){if(!_8(e,function(C,H){if(!A8(w,H)&&(I===C||i(I,C,t,n,s)))return w.push(H)})){b=!1;break}}else if(!(I===S||i(I,S,t,n,s))){b=!1;break}}return s.delete(r),s.delete(e),b}var eA=x8,R8=Rn,I8=R8.Uint8Array,tA=I8;function S8(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var k8=S8;function T8(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var O8=T8,rA=Uc,nA=tA,N8=ql,C8=eA,B8=k8,P8=O8,M8=1,L8=2,U8="[object Boolean]",D8="[object Date]",$8="[object Error]",F8="[object Map]",H8="[object Number]",z8="[object RegExp]",G8="[object Set]",V8="[object String]",j8="[object Symbol]",K8="[object ArrayBuffer]",W8="[object DataView]",iA=rA?rA.prototype:void 0,Ig=iA?iA.valueOf:void 0;function q8(r,e,t,n,i,s,o){switch(t){case W8:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case K8:return!(r.byteLength!=e.byteLength||!s(new nA(r),new nA(e)));case U8:case D8:case H8:return N8(+r,+e);case $8:return r.name==e.name&&r.message==e.message;case z8:case V8:return r==e+"";case F8:var a=B8;case G8:var u=n&M8;if(a||(a=P8),r.size!=e.size&&!u)return!1;var l=o.get(r);if(l)return l==e;n|=L8,o.set(r,e);var h=C8(a(r),a(e),n,i,s,o);return o.delete(r),h;case j8:if(Ig)return Ig.call(r)==Ig.call(e)}return!1}var Z8=q8;function Q8(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Sg=Q8,Y8=Array.isArray,In=Y8,J8=Sg,X8=In;function eP(r,e,t){var n=e(r);return X8(r)?n:J8(n,t(r))}var sA=eP;function tP(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var rP=tP;function nP(){return[]}var oA=nP,iP=rP,sP=oA,oP=Object.prototype,aP=oP.propertyIsEnumerable,aA=Object.getOwnPropertySymbols,cP=aA?function(r){return r==null?[]:(r=Object(r),iP(aA(r),function(e){return aP.call(r,e)}))}:sP,kg=cP;function uP(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var lP=uP;function fP(r){return r!=null&&typeof r=="object"}var Xn=fP,hP=la,dP=Xn,pP="[object Arguments]";function gP(r){return dP(r)&&hP(r)==pP}var yP=gP,cA=yP,mP=Xn,uA=Object.prototype,wP=uA.hasOwnProperty,bP=uA.propertyIsEnumerable,_P=cA(function(){return arguments}())?cA:function(r){return mP(r)&&wP.call(r,"callee")&&!bP.call(r,"callee")},Od=_P,Nd={exports:{}};function AP(){return!1}var vP=AP;Nd.exports,function(r,e){var t=Rn,n=vP,i=e&&!e.nodeType&&e,s=i&&!0&&r&&!r.nodeType&&r,o=s&&s.exports===i,a=o?t.Buffer:void 0,u=a?a.isBuffer:void 0,l=u||n;r.exports=l}(Nd,Nd.exports);var Cd=Nd.exports,EP=9007199254740991,xP=/^(?:0|[1-9]\d*)$/;function RP(r,e){var t=typeof r;return e=e??EP,!!e&&(t=="number"||t!="symbol"&&xP.test(r))&&r>-1&&r%1==0&&r<e}var Bd=RP,IP=9007199254740991;function SP(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=IP}var Tg=SP,kP=la,TP=Tg,OP=Xn,NP="[object Arguments]",CP="[object Array]",BP="[object Boolean]",PP="[object Date]",MP="[object Error]",LP="[object Function]",UP="[object Map]",DP="[object Number]",$P="[object Object]",FP="[object RegExp]",HP="[object Set]",zP="[object String]",GP="[object WeakMap]",VP="[object ArrayBuffer]",jP="[object DataView]",KP="[object Float32Array]",WP="[object Float64Array]",qP="[object Int8Array]",ZP="[object Int16Array]",QP="[object Int32Array]",YP="[object Uint8Array]",JP="[object Uint8ClampedArray]",XP="[object Uint16Array]",e5="[object Uint32Array]",jt={};jt[KP]=jt[WP]=jt[qP]=jt[ZP]=jt[QP]=jt[YP]=jt[JP]=jt[XP]=jt[e5]=!0,jt[NP]=jt[CP]=jt[VP]=jt[BP]=jt[jP]=jt[PP]=jt[MP]=jt[LP]=jt[UP]=jt[DP]=jt[$P]=jt[FP]=jt[HP]=jt[zP]=jt[GP]=!1;function t5(r){return OP(r)&&TP(r.length)&&!!jt[kP(r)]}var r5=t5;function n5(r){return function(e){return r(e)}}var Og=n5,Pd={exports:{}};Pd.exports,function(r,e){var t=j_,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s&&t.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();r.exports=a}(Pd,Pd.exports);var Ng=Pd.exports,i5=r5,s5=Og,lA=Ng,fA=lA&&lA.isTypedArray,o5=fA?s5(fA):i5,Cg=o5,a5=lP,c5=Od,u5=In,l5=Cd,f5=Bd,h5=Cg,d5=Object.prototype,p5=d5.hasOwnProperty;function g5(r,e){var t=u5(r),n=!t&&c5(r),i=!t&&!n&&l5(r),s=!t&&!n&&!i&&h5(r),o=t||n||i||s,a=o?a5(r.length,String):[],u=a.length;for(var l in r)(e||p5.call(r,l))&&!(o&&(l=="length"||i&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||f5(l,u)))&&a.push(l);return a}var hA=g5,y5=Object.prototype;function m5(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||y5;return r===t}var Bg=m5;function w5(r,e){return function(t){return r(e(t))}}var dA=w5,b5=dA,_5=b5(Object.keys,Object),A5=_5,v5=Bg,E5=A5,x5=Object.prototype,R5=x5.hasOwnProperty;function I5(r){if(!v5(r))return E5(r);var e=[];for(var t in Object(r))R5.call(r,t)&&t!="constructor"&&e.push(t);return e}var pA=I5,S5=Rd,k5=Tg;function T5(r){return r!=null&&k5(r.length)&&!S5(r)}var Md=T5,O5=hA,N5=pA,C5=Md;function B5(r){return C5(r)?O5(r):N5(r)}var Ld=B5,P5=sA,M5=kg,L5=Ld;function U5(r){return P5(r,L5,M5)}var gA=U5,yA=gA,D5=1,$5=Object.prototype,F5=$5.hasOwnProperty;function H5(r,e,t,n,i,s){var o=t&D5,a=yA(r),u=a.length,l=yA(e),h=l.length;if(u!=h&&!o)return!1;for(var g=u;g--;){var b=a[g];if(!(o?b in e:F5.call(e,b)))return!1}var w=s.get(r),I=s.get(e);if(w&&I)return w==e&&I==r;var S=!0;s.set(r,e),s.set(e,r);for(var x=o;++g<u;){b=a[g];var C=r[b],H=e[b];if(n)var D=o?n(H,C,b,e,r,s):n(C,H,b,r,e,s);if(!(D===void 0?C===H||i(C,H,t,n,s):D)){S=!1;break}x||(x=b=="constructor")}if(S&&!x){var z=r.constructor,W=e.constructor;z!=W&&"constructor"in r&&"constructor"in e&&!(typeof z=="function"&&z instanceof z&&typeof W=="function"&&W instanceof W)&&(S=!1)}return s.delete(r),s.delete(e),S}var z5=H5,G5=fa,V5=Rn,j5=G5(V5,"DataView"),K5=j5,W5=fa,q5=Rn,Z5=W5(q5,"Promise"),Q5=Z5,Y5=fa,J5=Rn,X5=Y5(J5,"Set"),e4=X5,t4=fa,r4=Rn,n4=t4(r4,"WeakMap"),mA=n4,Pg=K5,Mg=xg,Lg=Q5,Ug=e4,Dg=mA,wA=la,Hc=Y_,bA="[object Map]",i4="[object Object]",_A="[object Promise]",AA="[object Set]",vA="[object WeakMap]",EA="[object DataView]",s4=Hc(Pg),o4=Hc(Mg),a4=Hc(Lg),c4=Hc(Ug),u4=Hc(Dg),ha=wA;(Pg&&ha(new Pg(new ArrayBuffer(1)))!=EA||Mg&&ha(new Mg)!=bA||Lg&&ha(Lg.resolve())!=_A||Ug&&ha(new Ug)!=AA||Dg&&ha(new Dg)!=vA)&&(ha=function(r){var e=wA(r),t=e==i4?r.constructor:void 0,n=t?Hc(t):"";if(n)switch(n){case s4:return EA;case o4:return bA;case a4:return _A;case c4:return AA;case u4:return vA}return e});var Ql=ha,$g=kd,l4=eA,f4=Z8,h4=z5,xA=Ql,RA=In,IA=Cd,d4=Cg,p4=1,SA="[object Arguments]",kA="[object Array]",Ud="[object Object]",g4=Object.prototype,TA=g4.hasOwnProperty;function y4(r,e,t,n,i,s){var o=RA(r),a=RA(e),u=o?kA:xA(r),l=a?kA:xA(e);u=u==SA?Ud:u,l=l==SA?Ud:l;var h=u==Ud,g=l==Ud,b=u==l;if(b&&IA(r)){if(!IA(e))return!1;o=!0,h=!1}if(b&&!h)return s||(s=new $g),o||d4(r)?l4(r,e,t,n,i,s):f4(r,e,u,t,n,i,s);if(!(t&p4)){var w=h&&TA.call(r,"__wrapped__"),I=g&&TA.call(e,"__wrapped__");if(w||I){var S=w?r.value():r,x=I?e.value():e;return s||(s=new $g),i(S,x,t,n,s)}}return b?(s||(s=new $g),h4(r,e,t,n,i,s)):!1}var m4=y4,w4=m4,OA=Xn;function NA(r,e,t,n,i){return r===e?!0:r==null||e==null||!OA(r)&&!OA(e)?r!==r&&e!==e:w4(r,e,t,n,NA,i)}var Fg=NA,b4=Fg;function _4(r,e){return b4(r,e)}var A4=_4;const v4=xn(A4),Vr=[];for(let r=0;r<256;++r)Vr.push((r+256).toString(16).slice(1));function E4(r,e=0){return(Vr[r[e+0]]+Vr[r[e+1]]+Vr[r[e+2]]+Vr[r[e+3]]+"-"+Vr[r[e+4]]+Vr[r[e+5]]+"-"+Vr[r[e+6]]+Vr[r[e+7]]+"-"+Vr[r[e+8]]+Vr[r[e+9]]+"-"+Vr[r[e+10]]+Vr[r[e+11]]+Vr[r[e+12]]+Vr[r[e+13]]+Vr[r[e+14]]+Vr[r[e+15]]).toLowerCase()}let Hg;const x4=new Uint8Array(16);function R4(){if(!Hg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Hg=crypto.getRandomValues.bind(crypto)}return Hg(x4)}const CA={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I4(r,e,t){if(CA.randomUUID&&!e&&!r)return CA.randomUUID();r=r||{};const n=r.random||(r.rng||R4)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,E4(n)}function zg(r){return new Promise(e=>{setTimeout(e,r)})}function BA(r,e,t,n){const i=new Map;return r.forEach(s=>{i.set(t(s),s)}),e.forEach(s=>{i.set(t(s),s)}),Array.from(i.values()).sort(n)}function Gg(r){return(r.startsWith("0x")?r.slice(2):r).toLowerCase()}class Ui{constructor(){}static getInstance(){return Ui.instance||(Ui.instance=new Ui),Ui.instance}formatMessage(e,...t){return`[${new Date().toISOString()}] [${e.toUpperCase()}] - ${t.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...e){console.log(this.formatMessage("log",...e))}info(...e){console.info(this.formatMessage("info",...e))}warn(...e){console.warn(this.formatMessage("warn",...e))}error(...e){console.error(this.formatMessage("error",...e))}debug(...e){console.debug(this.formatMessage("debug",...e))}}class Dd{constructor(){this.logger=Ui.getInstance()}handleError(e,t){const n=e instanceof Error?e.message:"Unknown error occurred",i=e instanceof Error?e.stack:null;this.logger.error(`Error in ${t||"unknown context"}: ${n}`,{stack:i})}}let S4=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(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){if(!this.events[e])return;const n=this.events[e].indexOf(t);n>-1&&this.events[e].splice(n,1)}cleanAll(){this.events={}}emit(e,t){this.events[e]&&this.events[e].forEach(n=>n(t))}};class Vg{constructor(e={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new Dd,this.clearWaitTime=e.clearWaitTime||500}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const e=this.tasks.shift();if(e)try{const t=e();t instanceof Promise&&await t}catch(t){this.errorHandler.handleError(t,"Queue.processQueue")}}this.isProcessing=!1}}enqueue(e){this.tasks.push(e),this.processQueue()}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await zg(this.clearWaitTime);return this.isWaiting=!1,!1}}var PA={};(function(r){var e;Object.defineProperty(r,"__esModule",{value:!0}),r.Vector=r.Cache=r.Assertions=r.Strings=r.Types=r.Objects=r.Dates=r.Promises=r.Numbers=r.System=r.Arrays=r.Random=r.Elliptic=r.Binary=r.AsyncQueue=r.PubSubChannel=r.FixedPointNumber=r.MerkleTree=r.Chunk=r.Uint8ArrayWriter=r.Uint8ArrayReader=r.AsyncLazy=r.Lazy=r.Optional=void 0;async function t(c){return new Promise((f,d)=>c.then(d,f))}async function n(c){return t(Promise.all(c.map(t)))}async function i(c,f=1){const d=BC(c,f),y=[],R=d.map(async L=>{for(const J of L)y.push(await J())});return await Promise.all(R),y}async function s(c){return new Promise(f=>setTimeout(()=>{f(!0)},c))}function o(c,f=Math.random){for(let d=c.length-1;d>0;d--){const y=Math.floor(f()*(d+1)),R=c[d];c[d]=c[y],c[y]=R}return c}function a(c){if(c.length===1)return c[0];throw Error(`Expected exactly one element, actual: ${c.length}`)}function u(c){return c.length===1?c[0]:null}function l(c){return c.length>0?c[0]:null}function h(c){if(!c.length)throw Error("Received empty array");return c[0]}function g(c,f){const d=[];for(let y=0;y<c;y++)d.push(f(y));return d}function b(c){const f=[];for(let d=0;d<c[0].length;d++){f.push([]);for(let y=0;y<c.length;y++)f[d].push(c[y][d])}return f}function w(c,f,d){const y=[];for(let R=0;R<c;R++){y.push([]);for(let L=0;L<f;L++)y[R].push(d)}return y}function I(c,f,d,y){if(d<0||y<0||y+f[0].length>c[0].length||d+f.length>c.length)return!1;for(let R=0;R<f.length;R++)for(let L=0;L<f[R].length;L++)if(f[R][L]!==void 0&&c[d+R][y+L]!==f[R][L])return!1;return!0}function S(c,f,d=Math.random){return o(tC(0,c.length-1),d).slice(0,f)}function x(c,f){return c.map(d=>d[f])}function C(c){let f=c,d=3405648695,y=3735928559;return function(){return f+=d,d^=f<<7,f*=y,y^=f<<13,f^=d^y,(f>>>0)/4294967296}}function H(c,f,d=Math.random){return Math.floor(d()*(f-c+1))+c}function D(c,f,d=Math.random){return d()*(f-c)+c}function z(){return Math.random()*2-1}function W(c,f,d){return f>=c.x&&f<c.x+c.width&&d>=c.y&&d<c.y+c.height}function Z(c,f,d,y=Math.random){let R,L;do R=H(0,c-1,y),L=H(0,f-1,y);while(d&&W(d,R,L));return[R,L]}function V(c,f=Math.random){const d=Math.floor(c),y=c-d;return K(y,f)?d+1:d}function K(c,f=Math.random){return f()<c}function oe(c,f=Math.random){return c[Math.floor(c.length*f())]}function ce(c,f,d=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);return S(c,f,d).map(y=>c[y])}function ie(c,f,d,y=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);const R=[];for(;R.length<f;){const L=oe(c,y);R.some(J=>d(J,L))||R.push(L)}return R}function ue(c,f,d,y,R,L=Math.random){const J=c.filter(fe=>fe!==f&&fe!==d),de=[];for(f!==null&&de.push(f);J.length&&de.length<y;){const fe=r.Random.intBetween(0,J.length-1,L);R(J[fe],de)&&de.push(J[fe]),J.splice(fe,1)}return o(de,L),{values:de,indexOfGuaranteed:f!==null?de.indexOf(f):-1}}function B(c){if(!c.length)throw Error("Received empty array");return c[c.length-1]}function p(c,f,d){return d(f.reduce((y,R)=>R(y),c))}function m(c,f){return d=>p(d,c,f)}function E(c,f,d){if(d===void 0&&(d=Math.random()),c.length!==f.length)throw new Error("Array length mismatch");let y=f.reduce((L,J)=>L+J,0);const R=d*y;for(let L=0;L<c.length-1;L++)if(y-=f[L],R>=y)return c[L];return B(c)}function k(c,f,d=Math.random){const y=f.map(L=>d()*L),R=[];for(let L=0;L<c.length;L++)R.push([c[L],y[L]]);return R.sort((L,J)=>J[1]-L[1]).map(L=>L[0])}function O(c,f){if(c==null)return null;const d=f.split(".");let y=c;for(const R of d){if(y[R]===null||y[R]===void 0)return null;y=y[R]}return y}function M(c,f,d){const y=f.split(/\.|\[/);let R=c;for(let L=0;L<y.length;L++){const J=y[L],de=L<y.length-1&&y[L+1].includes("]"),fe=J.includes("]")?J.replace(/\[|\]/g,""):J;if(L===y.length-1)return R[fe]=d,d;sr(R[fe])||(de?R[fe]=[]:R[fe]={}),R=R[fe]}return d}function G(c,f,d=1){const y=O(c,f)||0;return M(c,f,y+d),y}function P(c,f,d){return O(c,f)||M(c,f,d)}function A(c,f){const d=_b(f,"."),y=nC(f,".");if(!d||!y)return;const R=O(c,d);delete R[y]}function U(c,f,d){const y=O(c,f);if(!y)throw new Error("Key '"+f+"' does not exist.");return M(c,f,d),y}function le(c,f,d){for(const y of f){const R=O(c,y);if(R)return R}if(d){const y=Object.values(c);if(y.length)return y[0]}return null}async function te(c,f,d){for(;;){try{await c()}catch(y){d&&d("Error in forever",y)}await s(f)}}function re(c,f){c();const d=setInterval(()=>{c()},f);return()=>clearInterval(d)}function he(c){return c/1024/1024}function ye(c){return c>=1024*1024*1024*1024?(c/1024/1024/1024/1024).toFixed(3)+" TB":c>=1024*1024*1024?(c/1024/1024/1024).toFixed(3)+" GB":c>=1024*1024?(c/1024/1024).toFixed(3)+" MB":c>=1024?(c/1024).toFixed(3)+" KB":c+" B"}function be(c){const f=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c.toLowerCase());if(!f)throw new Error("Invalid hex color: "+c);return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}function Ke(c){return"#"+c.map(f=>f.toString(16).padStart(2,"0")).join("")}function Fe(c,f,d,y){const R=c*Math.PI/180,L=d*Math.PI/180,J=(d-c)*Math.PI/180,de=(y-f)*Math.PI/180,fe=Math.sin(J/2)*Math.sin(J/2)+Math.cos(R)*Math.cos(L)*Math.sin(de/2)*Math.sin(de/2);return 6371e3*(2*Math.atan2(Math.sqrt(fe),Math.sqrt(1-fe)))}function Be(c,f){return Math.round(c/f)*f}function et(c){return c>1e3?(c/1e3).toFixed(0)+" km":c>=500?Be(c,100)+" m":c>=100?Be(c,50)+" m":Be(c,10)+" m"}function Qe(c){return c*(c+1)/2}function ot(c){const f=c.match(/-?\d+(\.\d+)?/);if(!f)throw Error("No float found in "+c);return parseFloat(f[0])}function sr(c,f=!0){return!c||f&&!It(c._readableState)||f&&c.constructor&&(c.constructor.isBuffer||c.constructor.name=="Uint8Array"||c.constructor.name==="ArrayBuffer"||c.constructor.name==="ReadableStream")?!1:typeof c=="object"}function dt(c){return sr(c)&&!Array.isArray(c)}function Ut(c){return Array.isArray(c)&&c.length===0}function oa(c){return dt(c)&&Object.keys(c).length===0}function It(c){return c===void 0}function Ct(c){return Object.prototype.toString.call(c)==="[object Function]"||Object.prototype.toString.call(c)==="[object AsyncFunction]"}function kr(c){return Object.prototype.toString.call(c)==="[object String]"}function pt(c){return typeof c=="number"&&isFinite(c)}function St(c){return c===!0||c===!1}function or(c){return Object.prototype.toString.call(c)==="[object Date]"}function xt(c){return!kr(c)||c.trim().length===0}function Bt(c){return pt(c)&&Number.isInteger(c)&&c>=1}function fn(c){return kr(c)&&c.match(/^-?\d+$/)!==null}function Dt(c){return kr(c)&&c.match(/^(0x)?[0-9a-f]+$/i)!==null}const N="!@#$%^&*()_+-=[]{}|;:<>?,./",_="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),v="abcdefghijklmnopqrstuvwxyz",$="ABCDEFGHIJKLMNOPQRSTUVWXYZ",j="1234567890",Y=v+$+j,ae=Y+N,Ye=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],qe="0123456789abcdef";function We(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=v[Math.floor(f()*v.length)];return d}function $t(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Y[Math.floor(f()*Y.length)];return d}function Ge(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=ae[Math.floor(f()*ae.length)];return d}function fr(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Ye[Math.floor(f()*Ye.length)];return d}function tg(c,f){const d=new RegExp(`[0-9a-f]{${f}}`,"i"),y=c.match(d);return y?y[0]:null}function hr(c,f,d=_){const y=iC(c,d);for(const R of y)if(f(R))return R;return null}function dr(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=qe[Math.floor(f()*qe.length)];return d}function rg(c,f){if(!fn(c))throw new TypeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=BigInt(c);if(f&&(f.min&&d<f.min||f.max&&d>f.max))throw RangeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: `+d);return c}function ar(c,f){if(xt(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);if(f&&(f.min!==void 0&&c.length<f.min||f.max!==void 0&&c.length>f.max))throw RangeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""} length in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c.length}`);return c}function pr(c,f){if(!Dt(c))throw new TypeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.replace(/^0x/,"");if(f&&f.byteLength&&d.length!==f.byteLength*2)throw RangeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""} of byte length ${f.byteLength}; got: `+d);return d}function ng(c,f){if(!ar(c,f).split("").every(d=>d==="_"||od(d)))throw new TypeError(`Expected safe string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function cr(c,f){if(f.min!==void 0&&c<f.min||f.max!==void 0&&c>f.max)throw RangeError(`Expected value${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c}`)}function gr(c,f){if(!Ct(c))throw new TypeError(`Expected function${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Oc(c,f){if(pt(c))return f&&cr(c,f),c;if(!kr(c)||!c.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=parseFloat(c);return f&&cr(d,f),d}function Jt(c,f){return Oc(c,f)|0}function yr(c,f){if(c==="true")return!0;if(c==="false")return!1;if(!St(c))throw new TypeError(`Expected boolean${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function ig(c,f){if(!or(c))throw new TypeError(`Expected date${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function mr(c){return xt(c)?null:c}function wr(c,f){if(!kr(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function sg(c,f){if(Bt(c))return c;const d=parseInt(c,10);if(!Bt(d))throw new TypeError(`Expected id${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function br(c,f){if(!kr(c))throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.split(":");if(d.length!==2)throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const y=parseInt(d[0],10),R=parseInt(d[1],10);if(!pt(y)||!pt(R)||y<0||y>23||R<0||R>59)throw new TypeError(`Expected time, got${f!=null&&f.name?` for ${f.name}`:""}: `+c);return`${String(y).padStart(2,"0")}:${String(R).padStart(2,"0")}`}function _r(c,f){if(!Array.isArray(c))throw new TypeError(`Expected array${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Nc(c,f){if(!dt(c))throw new TypeError(`Expected object${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Ar(c,f){return c===null?null:Nc(c,f)}function vr(c,f){const d=Nc(c,f);for(const y of Object.keys(d))if(!kr(d[y]))throw new TypeError(`Expected string map${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Kh(c,f){const d=Nc(c),y=Object.keys(d),R=Object.values(d);if(!y.every(kr)||!R.every(pt))throw new TypeError(`Expected numeric dictionary${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Dl(c){return kr(c)&&c.match(/^https?:\/\/.+/)!==null}function Wh(c,f){if(!Dl(c))throw new TypeError(`Expected url${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function qh(c,f){return f==null?!0:c(f)}function Zh(c,f){return f==null?null:c(f)}function Qh(c,f){return f==null?void 0:c(f)}function $l(c,f){for(const[d,y]of Object.entries(f))if(!y(c[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(c))if(!f[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Yh(c,f){return c.every(d=>$l(d,f))}function so(c,f="json",d=0){if(sr(c,!1)){if(d>1)return"[object Object]";if(f==="json"){if(Array.isArray(c)){const R=c.map(L=>so(L,"json",d+1));return d===0?JSON.stringify(R):R}const y={};c.message&&(y.message=so(c.message,"json",d+1));for(const[R,L]of Object.entries(c))y[R]=so(L,"json",d+1);return d===0?JSON.stringify(y):y}else if(f==="key-value"){const y=Object.keys(c);return c.message&&!y.includes("message")&&y.unshift("message"),y.map(R=>`${R}=${JSON.stringify(so(c[R],"json",d+1))}`).join(" ")}}return It(c)&&(c="undefined"),d===0?JSON.stringify(c):c}function Jh(c,f){if(kr(c))return c;const d=Object.keys(c);c.message&&!d.includes("message")&&d.push("message");const y=d.map(R=>`${R}: ${c[R]}`).join("; ");return f&&c.stack?y+`
|
|
2
|
+
`+c.stack:y}function Li(c,f){if(dt(c)&&dt(f))for(const d in f)dt(f[d])?(c[d]||(c[d]={}),Li(c[d],f[d])):Array.isArray(f[d])?c[d]=[...f[d]]:(f[d]!==null&&f[d]!==void 0||c[d]===null||c[d]===void 0)&&(c[d]=f[d]);return c}function Xh(c,f){const d={};return Li(d,c),Li(d,f),d}function ed(c,f,d){const y={};return Li(y,c),Li(y,f),Li(y,d),y}function Fl(c,f){const d={};for(const y of c)for(const R of Object.keys(y))d[R]?d[R]=f(d[R],y[R]):d[R]=y[R];return d}function td(c){return Fl(c,(f,d)=>f+d)}function rd(c,f,d){c[f]||(c[f]=[]),c[f].push(d)}function nd(c,f,d){for(c.unshift(f);c.length>d;)c.pop()}function id(c,f){let d=f%c.length;return d<0&&(d+=c.length),c[d]}function aa(c,f){Array.prototype.push.apply(c,f)}function ene(c,f){Array.prototype.unshift.apply(c,f)}async function tne(c,f){const d=[];for(const y of c)d.push(await f(y));return d}function rne(c,f){const d=[];for(let y=0;y<c.length;y++)d.push(c[y]),y<c.length-1&&(Ct(f)?d.push(f()):d.push(f));return d}function nne(c,f){if(c!==f)throw Error(`Expected [${c}] to equal [${f}]`);return[c,f]}function ine(c){if(c!==!0)throw Error(`Expected [true], got: [${c}]`);return c}function sne(c){if(!c)throw Error(`Expected truthy value, got: [${c}]`);return c}function one(c){if(c!==!1)throw Error(`Expected [false], got: [${c}]`);return c}function ane(c){if(c)throw Error(`Expected falsy value, got: [${c}]`);return c}function cne(c,f){if(!f.includes(c))throw Error(`Expected any of [${f.join(", ")}], got: [${c}]`);return c}function une(c,f){for(let d=0;d<c.length;d++){const y=c[d],R=f[d],L=Math.max(0,R.getTime()-Date.now());setTimeout(y,L)}}function lne(c,f,d){return c+(f-c)*d}function fne(c){return c.reduce((f,d)=>f+d,0)}function hne(c){return c.reduce((f,d)=>f+d,0)/c.length}function dne(c){const f=[...c].sort((y,R)=>y-R),d=Math.floor(f.length/2);return f.length%2===0?(f[d]+f[d-1])/2:f[d]}function pne(c,f){return c-(f-1)/2}function tC(c,f){const d=[];for(let y=c;y<=f;y++)d.push(y);return d}function gne(c,f){return f.some(d=>c.includes(d))}function yne(c){return/^[\u4E00-\u9FA5]+$/.test(c)}function wb(c,f=()=>!1){return c.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||f(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function mne(c){return wb(c).replaceAll("-","")}function wne(c){return ag(c.replace(/([A-Z])/g," $1"))}function bne(c){return c.split("-").map(ag).join(" ")}function _ne(c){return oC(c.split("-").map(ag).join(""))}function Ane(c,f=", ",d=" and "){return!c||!c.length?"":c.length===1?c[0]:c.length===2?`${c[0]}${d}${c[1]}`:`${c.slice(0,c.length-1).join(f)}${d}${c[c.length-1]}`}function vne(c,f){return f+c.split("").join(f)+f}function Ene(c){return wb(c).replace(/-/g,"_").toUpperCase()}function og(c,f){if(f.length===0)return 0;const d=c.toLowerCase(),y=f.toLowerCase();return c===f?1e4:d.startsWith(y)?1e4-c.length:d.includes(y)?5e3-c.length:new RegExp(".*"+y.split("").join(".*")+".*").test(d)?1e3-c.length:0}function xne(c,f){return c.filter(d=>og(d,f)).sort((d,y)=>og(y,f)-og(d,f))}function Rne(c){return c.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ine={"&":"&",""":'"',"'":"'",">":">","<":"<"};function Sne(c){let f=c.replace(/&#(\d+);/g,(d,y)=>String.fromCharCode(y)).replace(/&#x(\d+);/g,(d,y)=>String.fromCharCode(parseInt(y,16)));for(const[d,y]of Object.entries(Ine))f=f.replaceAll(d,y);return f}function rC(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(0,d)}function bb(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(d+f.length)}function _b(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(0,d)}function nC(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(d+f.length)}function kne(c,f,d){const y=_b(c,d);return y?bb(y,f):null}function Tne(c,f,d){const y=bb(c,f);return y?rC(y,d):null}function Ab(c,f,d=!1){const y=d?c.lastIndexOf(f):c.indexOf(f);return y===-1?d?[null,c]:[c,null]:[c.slice(0,y),c.slice(y+f.length)]}function iC(c,f){let d=[c];for(const y of f)d=d.flatMap(R=>R.split(y));return d.filter(y=>y)}function vb(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?"":f.slice(d+1)}function Eb(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?f:f.slice(0,d)}function One(c){let[f,d]=c.split("@");f=sd(f.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[y]=f.split("+");if(!y||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=sd(d.toLowerCase()).replaceAll(" ",""),`${y}@${d}`}function Nne(c){const f=Eb(c),d=vb(c);return d?`${f}.${d}`:f}function Cne(c){const f=Eb(c),d=vb(c);return{basename:f,extension:d,filename:d?`${f}.${d}`:f}}function Bne(c,f=Math.random){return c.replace(/\{(.+?)\}/g,(d,y)=>oe(y.split("|"),f))}function sC(c){const f=/\{(.+?)\}/,d=c.match(f);if(!d||!d.index)return[c];const y=d[1].split(","),R=c.slice(0,d.index),L=c.slice(d.index+d[0].length);let J=[];for(const de of y){const fe=sC(R+de+L);J=J.concat(fe)}return J}function sd(c){return c.split(`
|
|
3
|
+
`).map(f=>f.trim().replace(/\s+/g," ")).filter(f=>f.length>0).join(`
|
|
4
|
+
`)}function ag(c){return c.charAt(0).toUpperCase()+c.slice(1)}function oC(c){return c.charAt(0).toLowerCase()+c.slice(1)}function aC(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=65&&f<=90||f>=97&&f<=122}function cC(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=48&&f<=57}function od(c){return aC(c)||cC(c)}const Pne=`
|
|
5
|
+
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function Mne(c){return Pne.includes(c)}function Lne(c){return od(c)||c==="."||c==="["||c==="]"||c==="_"}function Une(c,f,d,y,R){return c.slice(0,f)+y+c.slice(f,f+d)+R+c.slice(f+d)}function uC(c,f,d=0){const y=f.exec(c.slice(d));return y?{index:y.index,match:y[0]}:null}function lC(c,f,d=!0){if(!d)return f.every(R=>R instanceof RegExp?R.test(c):c.indexOf(R,0)!==-1);let y=0;for(const R of f)if(R instanceof RegExp){const L=uC(c,R,y);if(!L)return!1;y=L.index+L.match.length}else{const L=c.indexOf(R,y);if(L===-1)return!1;y=L+R.length}return!0}function Dne(c,f,d=!0){let y=0;for(const R of f){let L=!1;for(;!L&&y<c.length;)lC(c[y],R,d)&&(L=!0),y++;if(!L)return!1}return!0}function $ne(c){return c.match(/"|,/)?`"${c.replace(/"/g,'""')}"`:c}function Hl(c,f,d=0){let y=-1;for(const R of f){const L=c.indexOf(R,d);L!==-1&&(y===-1||L<y)&&(y=L)}return y}function Fne(c,f=0){for(let d=f;d<c.length;d++)if(Mne(c[d]))return d;return-1}function Hne(c,f=0){for(let d=f;d<c.length;d++)if(c[d]==="#"&&od(c[d+1]))return d;return-1}function fC(c,f,d=0){return c.slice(0,d).lastIndexOf(f)}function hC(c,f=0,d="{",y="}"){let R=1;for(let L=f;L<c.length;L++)if(c.slice(L,L+y.length)===y){if(--R===0)return L}else c.slice(L,L+d.length)===d&&R++;return-1}function dC(c,f){const d=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
|
|
6
|
+
`],f.start||0):c.indexOf(f.opening,f.start||0);if(d===-1)return null;const y=hC(c,d+f.opening.length,f.opening,f.closing);return y===-1?null:f.exclusive?c.slice(d+f.opening.length,y):c.slice(d,y+f.closing.length)}function zne(c,f){const d=[];let y=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
|
|
7
|
+
`],f.start||0):c.indexOf(f.opening,f.start||0);for(;;){if(y===-1)return d;const R=dC(c,{...f,start:y});if(!R)return d;d.push(R),y=f.wordBoundary?Hl(c,[`${f.opening} `,`${f.opening}
|
|
8
|
+
`],y+R.length):c.indexOf(f.opening,y+R.length)}}function Gne(c,f,d){let y=0;for(;;){const R=r.Strings.extractBlock(c,{...d,start:y});if(!R)return c;const L=f(R);y=c.indexOf(R,y)+L.length,c=c.replace(R,L)}}function Vne(c,f){const d=[];let y=0;for(;y<c.length;){const R=c.indexOf(f,y);if(R===-1){d.push({string:c.slice(y),symbol:null});break}const L=c.indexOf(f,R+f.length);if(R>y&&L!==-1&&d.push({string:c.slice(y,R),symbol:null}),L===-1){d.push({string:c.slice(y),symbol:null});break}d.push({string:c.slice(R+f.length,L),symbol:f}),y=L+f.length}return d}function jne(c){const f=[];let d=0;for(;d<c.length;){const y=Hne(c,d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=Fne(c,y+1);if(R===-1){f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1),symbol:"#"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1,R),symbol:"#"}),d=R}return f}function Kne(c){const f=[];let d=0;for(;d<c.length;){const y=Hl(c,["http://","https://"],d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=Hl(c,[" ",`
|
|
9
|
+
`],y);if(R===-1){y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y),symbol:"http"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y,R),symbol:"http"}),d=R}return f}const pC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gC="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Wne(c){return yC(c,pC)}function qne(c){return mC(c,pC)}function Zne(c){return yC(c,gC)}function Qne(c){return mC(c,gC)}function yC(c,f){const d="=",y=f.length;let R=0,L=0;const J=[];for(let de=0;de<c.length;de++){const fe=c[de];if(fe===d)break;const De=f.indexOf(fe);if(De===-1)throw new Error(`Invalid character: ${fe}`);L=L<<Math.log2(y)|De,R+=Math.log2(y),R>=8&&(R-=8,J.push(L>>R&255))}return new Uint8Array(J)}function mC(c,f){const d=f.length;let y=0,R=0,L="";for(let J=0;J<c.length;J++)for(R=R<<8|c[J],y+=8;y>=Math.log2(d);)y-=Math.log2(d),L+=f[R>>y&d-1];return y>0&&(L+=f[R<<Math.log2(d)-y&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function Yne(c){c.startsWith("0x")&&(c=c.slice(2));const f=c.length/2,d=new Uint8Array(f);for(let y=0;y<f;y++){const R=parseInt(c.slice(y*2,y*2+2),16);d[y]=R}return d}function Jne(c){return Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("")}function Xne(c,f){const d=c.split("/").filter(L=>L),y=f.split("/").filter(L=>L);if(d.length!==y.length)return null;const R={};for(let L=0;L<d.length;L++){const J=d[L];if(J.startsWith(":"))R[J.slice(1)]=y[L];else if(J!==y[L])return null}return R}function xb(c,f,d){const y=[];for(const R of d)R!==f&&y.push(c.replace(f,R));return y}function eie(c,f,d,y=Math.random){const R=r.Arrays.shuffle(f.map(J=>({variants:r.Arrays.shuffle(J.variants.map(de=>de),y),avoid:J.avoid})),y),L=[];for(const J of R){const de=J.variants.filter(De=>De!==J.avoid),fe=de.find(De=>c.includes(De));if(fe&&(aa(L,xb(c,fe,de)),L.length>=d))break}if(L.length<d)for(const J of R){const de=J.variants.find(fe=>c.includes(fe));if(de&&(aa(L,xb(c,de,J.variants)),L.length>=d))break}return L.slice(0,d)}function tie(c,f,d,y=!1){const R=new RegExp(y?`(?<=\\s|^)${f}(?=\\s|$)`:`\\b${f}\\b`,"g");return c.replace(R,d)}function rie(c,f){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return c.replace(d,y=>y.toUpperCase()===y?y:f(y))}function nie(c){return c.replace(/<[^>]*>/g,"")}function wC(c){const f=c.lastIndexOf(" ");if(f===-1)return{line:c,rest:""};const d=c.slice(0,f),y=c.slice(f+1);return{line:d,rest:y}}function iie(c,f={}){return[...c].reduce((d,y)=>d+(f[y]||1),0)}function sie(c,f,d={}){const y=[];let R="",L=0;for(let J=0;J<c.length;J++){const de=c[J],fe=d[de]||1;if(R+=de,L+=fe,L>f){const{line:De,rest:Lt}=wC(R);y.push(De),R=Lt,L=Lt.split("").map(Gr=>d[Gr]||1).reduce((Gr,jl)=>Gr+jl,0)}}return R&&y.push(R),y}function oie(c,f){const d=[];for(let y=0;y<=c.length;y++)d[y]=[y];for(let y=0;y<=f.length;y++)d[0][y]=y;for(let y=1;y<=c.length;y++)for(let R=1;R<=f.length;R++){const L=c[y-1]===f[R-1]?0:1;d[y][R]=Math.min(d[y-1][R]+1,d[y][R-1]+1,d[y-1][R-1]+L)}return d[c.length][f.length]}function Rb(c,f){return new RegExp(`\\b${f}\\b`).test(c)}function aie(c,f,d){return d==="any"?f.some(y=>Rb(c,y)):f.every(y=>Rb(c,y))}function cie(c){const f={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const y of d){const[R,L]=Ab(y,"=");f[R]=L.slice(1,L.length-1)}return f}function cg(c,f,d=[]){let y="";for(;f<c.length&&(od(c[f])||d.includes(c[f]));)y+=c[f++];return y}function uie(c,f,d="$",y=":"){for(const R in f)c=bC(c,R,f[R],d,y);return c=_C(c),c}function bC(c,f,d,y="$",R=":"){if(d==="")return c;let L=c.indexOf(`${y}${f}`);for(;L!==-1;){if(c[L+f.length+1]===R)if(c[L+f.length+2]===R)c=c.replace(`${y}${f}${R}${R}`,d);else{const J=cg(c,L+f.length+2,["_"]);c=c.replace(`${y}${f}${R}${J}`,d)}else c=c.replace(`${y}${f}`,d);L=c.indexOf(`${y}${f}`,L+d.length)}return c}function _C(c,f="$",d=":"){let y=c.indexOf(f);for(;y!==-1;){const R=cg(c,y+1);if(c[y+R.length+1]===d)if(c[y+R.length+2]===d)c=c.replace(`${f}${R}${d}${d}`,"");else{const L=cg(c,y+R.length+2);c=c.replace(`${f}${R}${d}${L}`,L)}y=c.indexOf(f,y+1)}return c}function lie(c,f){let d=c.indexOf("](");for(;d!==-1;){const y=fC(c,"[",d),R=c.indexOf(")",d);if(y!==-1&&R!==-1){const[L,J]=c.slice(y+1,R).split("]("),de=f(L,J);c=c.slice(0,y)+de+c.slice(R+1)}d=c.indexOf("](",d+1)}return c}function AC(c,f=!0){const d=Object.entries(c).filter(([y,R])=>R!=null).map(([y,R])=>`${y}=${encodeURIComponent(R)}`).join("&");return d?(f?"?":"")+d:""}function fie(c){const f={},d=c.split("&");for(const y of d){const[R,L]=y.split("=");R&&L&&(f[R]=decodeURIComponent(L))}return f}function hie(c,f){return Object.prototype.hasOwnProperty.call(c,f)}function die(c,f){let d=null,y=-1/0;for(const[R,L]of Object.entries(c)){const J=f(L);J>y&&(y=J,d=R)}return d?[d,c[d]]:null}function pie(c,f,d,y){const R=c.find(J=>J[f]===d),L=c.find(J=>J[f]===d+y);R&&L?(R[f]=d+y,L[f]=d):R&&(R[f]=d+y),c.sort((J,de)=>Oc(J[f])-Oc(de[f])),c.forEach((J,de)=>J[f]=de+1)}function gie(c){const f=Object.keys(c);if(f.length===1)return c[f[0]];throw new Error("Expected object to have a single key")}function yie(c,f=":"){return Object.fromEntries(c.map(d=>Ab(d,f)).map(d=>d[0]&&d[1]?[sd(d[0]),sd(d[1])]:null).filter(d=>d))}function mie(c,f,d){return RC(c,f)+AC(d||{})}function wie(c,f=",",d='"'){const y=[];let R="",L=!1;const J=c.split("");for(const de of J)de===f&&!L?(y.push(R),R=""):de===d&&(!R&&!L||L)?L=!L:R+=de;return y.push(R),y}function bie(c){return`[${Math.floor(c.progress*100)}%] ${ug(c.deltaMs)} out of ${ug(c.totalTimeMs)} (${ug(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function _ie(c,f,d){for(let y=0;y<d;y++){try{if(await c())return!0}catch{}y<d-1&&await s(f)}return!1}function Aie(c,f){const d=[];for(let y=c.length-1;y>=0;y--)f(c[y])&&d.push(c.splice(y,1)[0]);return d}function vie(c){return JSON.parse(JSON.stringify(c))}function Eie(c){return Math.ceil((c||Date.now())/1e3)}function xie(c){return(c||new Date).toISOString().slice(0,10)}function Rie(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function Iie(c){const f=new Date(c);return new Date(f.getTime()-f.getTimezoneOffset()*6e4)}function Sie(c){return new Date(c)}function ms(c){return String(Math.floor(c)).padStart(2,"0")}function kie(c){let[f,d]=c.split(":");pt(parseInt(f,10))||(f="0"),pt(parseInt(d,10))||(d="0");let y=Ob(Jt(f),0,23),R=Ob(Jt(d),0,59);return`${ms(y)}:${ms(R)}`}function ug(c){const f=Math.floor(c/36e5);c=c%36e5;const d=Math.floor(c/6e4);c=c%6e4;const y=Math.floor(c/1e3);return f?`${ms(f)}:${ms(d)}:${ms(y)}`:`${ms(d)}:${ms(y)}`}function Cc(c){return Math.floor((or(c)?c.getTime():c)/864e5)}const Tie={today:(c,f)=>ms(c)+":"+ms(f),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:c=>`${c}w`};function Oie(c,f){const d=new Date((f==null?void 0:f.now)||Date.now()),y=(f==null?void 0:f.labels)||Tie,R=or(c)?c:new Date(c);if(Cc(d)===Cc(R))return y.today(R.getUTCHours(),R.getUTCMinutes(),R.getUTCHours()>12);if(Cc(d)-Cc(R)===1)return y.yesterday();const L=Sb(R);return Cc(d)-Cc(R)<7?y[L.day]():y.weeks(Math.round((d.getTime()-R.getTime())/6048e5))}const vC={now:()=>"A few seconds",seconds:c=>`${c} seconds`,minutes:c=>`${c} minutes`,hours:c=>`${c} hours`,days:c=>`${c} days`,weeks:c=>`${c} weeks`};function EC(c,f){const d=(f==null?void 0:f.now)??Date.now(),y=(f==null?void 0:f.labels)||vC,R=r.Types.isDate(c)?c.getTime():c;let L=(d-R)/1e3;return L<10?y.now():L<120?y.seconds(Math.floor(L)):(L/=60,L<120?y.minutes(Math.floor(L)):(L/=60,L<48?y.hours(Math.floor(L)):(L/=24,L<14?y.days(Math.floor(L)):(L/=7,y.weeks(Math.floor(L))))))}function Nie(c,f=vC){return EC(0,{now:c*1e3,labels:f})}function Cie(c,f,d){const y=((d==null?void 0:d.now)??Date.now())-c,R=Math.floor(y/f),L=f/((d==null?void 0:d.precision)??1)-Math.ceil(y%f/((d==null?void 0:d.precision)??1));return{cycles:R,remaining:L}}const Ib={};function Bie(c,f){return!Ib[c]||Date.now()>Ib[c]?(Ib[c]=Date.now()+f,!0):!1}const Pie={s:1e3,m:6e4,h:36e5,d:864e5};function Mie(c,f,d){return f=or(f)?f.getTime():f,d=d?or(d)?d.getTime():d:Date.now(),(d-f)/Pie[c]}function Lie(c,f,d,y){y||(y=Date.now());const R=f/d,L=y-c,J=L/f,de=J*d,fe=de-L;return{deltaMs:L,progress:R,baseTimeMs:J,totalTimeMs:de,remainingTimeMs:fe}}const Uie={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function xC(c){return{zeroBasedIndex:c,day:Uie[c]}}function Sb(c){return xC(c.getDay())}function Die(c){return Sb(new Date(c))}function $ie(c){return c*1e3}function Fie(c){return c*6e4}function Hie(c){return c*36e5}function zie(c){return c*864e5}const Gie={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 Vie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=Gie[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}const jie={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 Kie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=jie[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}function Wie(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const kb={};async function qie(c,f,d){const y=Date.now(),R=kb[c];if(R&&R.validUntil>y)return R.value;const L=await d(),J=y+f;return kb[c]={value:L,validUntil:J},L}function Zie(c){delete kb[c]}function RC(...c){return c.filter(f=>f).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function Qie(c,f,d,y,R=!0){const L=c.indexOf(f),J=c.indexOf(d,L+f.length);if(L===-1||J===-1)throw Error("Start or end not found");return R?c.substring(0,L+f.length)+y+c.substring(J):c.substring(0,L)+y+c.substring(J+d.length)}function Yie(c){let f="p";c.startsWith("#")?(f="h1",c=c.slice(1).trim()):c.startsWith("-")&&(f="li",c=c.slice(1).trim());const d=c[0]===c[0].toUpperCase(),y=/[.?!]$/.test(c),R=/:$/.test(c);return{type:f,isCapitalized:d,hasPunctuation:y,endsWithColon:R}}function Jie(c,f="(",d=")"){let y=0,R=0;for(;R<c.length;)if(c.startsWith(f,R)?(y++,R+=f.length):c.startsWith(d,R)?(y--,R+=d.length):R++,y<0)return!1;return f===d?y%2===0:y===0}function Xie(c){c=c.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let f=c.length;for(;c=c.replace(/(\w+)[\s,']+\w+/g,"$1"),c.length!==f;)f=c.length;return c=c.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),c=c.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),c=c.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),c}function IC(c){const f=Object.keys(c).sort((y,R)=>y.localeCompare(R)),d={};for(const y of f)d[y]=Bc(c[y]);return d}function SC(c){const f=[];return c.sort((d,y)=>JSON.stringify(Bc(d)).localeCompare(JSON.stringify(Bc(y)))).forEach(d=>f.push(Bc(d))),f}function Bc(c){return Array.isArray(c)?SC(c):sr(c)?IC(c):c}function kC(c,f){return JSON.stringify(Bc(c))===JSON.stringify(Bc(f))}function ese(...c){for(let f=1;f<c.length;f++)if(!kC(c[f-1],c[f]))return!1;return!0}function tse(c){try{return JSON.parse(c)}catch{return null}}function rse(){let c=0;return{next:()=>c++}}function nse(c){let f=0;return{next:()=>c[f++%c.length]}}function ise(c){let f;return d=>{const y=d===c&&f!==c;return f=d,y}}function sse(c,f,d,y,R){const L={};for(const J of Object.keys(f))L[J]=[];L[y]=[],R&&(c=c.sort(R));for(const J of c){const de=J[d],fe=f[de]?de:y;L[fe].length>=f[fe]?L[y].push(J):L[fe].push(J)}return L}function ose(c,f){const d=Object.keys(c),y=Object.keys(f);return{uniqueToA:d.filter(R=>!y.includes(R)),uniqueToB:y.filter(R=>!d.includes(R))}}function TC(c){const f=Object.keys(c);return f[Math.floor(Math.random()*f.length)]}function ase(c,f){const d=TC(c);return c[d]=f(c[d]),d}function cse(c){return c=c.replace(/\r\n/g,`
|
|
10
|
+
`),c=c.replace(/(\w+)\((.+)\)/g,(f,d,y)=>`${d}(${y.replaceAll(",",",")})`),c=c.replace(/(,)(\s+})/g,"$2"),c=c.replace(/\.\.\..+?,/g,""),c=c.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/:(.+)\?(.+):/g,(f,d,y)=>`: (${d.trim()} && ${y.trim()}) ||`),c=c.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),c=c.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(f,d,y,R)=>`"${d}":"${y.trim()}"${R}`),c=c.replace(/("'|'")/g,'"'),c=c.replaceAll(",",","),JSON.parse(c)}const ca=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],use=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],OC=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function lse(c,f,d){let y=c.length-f;if(y<=0)return"0."+"0".repeat(-y)+c+(d?" "+d:"");let R=c.substring(0,y),L=c.substring(y);return R===""&&(R="0"),R+"."+L+(d?" "+d:"")}function fse(c,f){const d=(f==null?void 0:f.longForm)??!1,y=f!=null&&f.unit?` ${f.unit}`:"",R=d?use:OC,L=(f==null?void 0:f.precision)??1;if(c<ca[0])return`${c}${y}`;for(let J=0;J<ca.length-1;J++)if(c<ca[J+1])return`${(c/ca[J]).toFixed(L)}${d?" ":""}${R[J]}${y}`;return`${(c/ca[ca.length-1]).toFixed(L)}${d?" ":""}${R[ca.length-1]}${y}`}function Tb(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),y=OC.findIndex(R=>R.toLowerCase()===d.toLowerCase());return y===-1?f:f*ca[y]}function Ob(c,f,d){return c<f?f:c>d?d:c}function hse(c,f,d){const y=c+f;return y>d?d:y}function dse(c,f,d){const y=c-f;return y<d?d:y}function pse(c,f){return f(c),c}function gse(c,f){c&&f(c)}function yse(c,f){const d=Object.keys(f);for(const y of d)Array.isArray(f[y])&&Array.isArray(c[y])&&aa(c[y],f[y])}function mse(c){return c.splice(0,c.length),c}function wse(c){for(const f of Object.keys(c))(Ut(c[f])||Array.isArray(c[f])&&c[f].every(d=>d==null))&&delete c[f];return c}function bse(c){for(const f of Object.entries(c))(f[1]===null||f[1]===void 0||kr(f[1])&&xt(f[1]))&&delete c[f[0]];return c}function _se(c,f){const d={};for(const[y,R]of Object.entries(c))f(y)&&(d[y]=R);return d}function Ase(c,f){const d={};for(const[y,R]of Object.entries(c))f(R)&&(d[y]=R);return d}function vse(c,f){const d={};for(const y of Object.entries(c))d[y[0]]=f(y[1]);return d}function Ese(c,f){const d=[];let y=0;for(const R of c)d.push(f(R,y++));return d}async function xse(c,f){try{return await c()}catch{throw f}}function Rse(c,f,d){d!=null&&(c[f]=d)}function Ise(c,f,d,y){const R=O(d,y);R!=null&&M(c,f,R)}function Sse(c){const f={};for(const[d,y]of Object.entries(c))f[y]=d;return f}function kse(c){const f=Object.keys(c),d=f.map(de=>c[de].length),y=d.reduce((de,fe)=>de*=fe);let R=1;const L=[1];for(let de=0;de<d.length-1;de++)R*=d[de],L.push(R);const J=[];for(let de=0;de<y;de++){const fe={};for(let De=0;De<f.length;De++){const Lt=c[f[De]],Gr=Math.floor(de/L[De])%Lt.length;fe[f[De]]=Lt[Gr]}J.push(fe)}return J}function Tse(c){return Object.values(c).filter(f=>f).length}function Ose(c,f,d){return c+(d?"["+f+"]":(c.length?".":"")+f)}function lg(c,f,d,y,R){if(!sr(f))return f;for(const[L,J]of Object.entries(f)){const de=Ose(d,L,y);Array.isArray(J)?R?lg(c,J,de,!0,R):c[de]=J.map(fe=>lg(Array.isArray(fe)?[]:{},fe,"",!1,R)):sr(J)?lg(c,J,de,!1,R):c[de]=J}return c}function Nse(c,f=!1,d){return lg({},c,d||"",!1,f)}function NC(c){if(!sr(c))return c;const f=Array.isArray(c)?[]:{};for(const[d,y]of Object.entries(c))Array.isArray(y)?M(f,d,y.map(R=>NC(R))):M(f,d,y);return f}function Cse(c,f,d){return f[c]?f[c]:d}function CC(c,f){const d={};for(const y of c){const R=f(y);d[R]=y}return d}function Bse(c,f){const d={};for(const y of c){const R=f(y);d[R]||(d[R]=[]),d[R].push(y)}return d}function Pse(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.slice(y,y+f));return d}function BC(c,f){const d=Math.ceil(c.length/f),y=[];for(let R=0;R<c.length;R+=d)y.push(c.slice(R,R+d));return y}function PC(c,f){const d=[],y=Math.ceil(c.length/f);for(let R=0;R<y;R++)d.push(c.slice(R*f,R*f+f));return d}function Mse(c,f){const d=Math.ceil(c.length/f);return PC(c,d)}function Lse(c,f){return Object.values(CC(c,f))}function Use(c,f,d,y,R){const L=f?c.map(f):c,J={};for(const fe of L)J[fe]=(J[fe]||0)+1;const de=y?MC(J,R?(fe,De)=>fe[1]-De[1]:(fe,De)=>De[1]-fe[1]):J;return d?Object.keys(de):de}function MC(c,f){return Object.fromEntries(Object.entries(c).sort(f))}function Dse(c){const f=[],d=Object.keys(c),y=c[d[0]].length;for(let R=0;R<y;R++){const L={};for(const J of d)L[J]=c[J][R];f.push(L)}return f}function $se(c,f,d=1){for(const y of c)y[f]+=d}function Fse(c,f,d){for(const y of c)y[f]=d}function Nb(c,f){const d=[];let y=[];return c.forEach((R,L)=>{(L===0||!f(R,c[L-1]))&&(y=[],d.push(y)),y.push(R)}),d}function Hse(){return{map:new Map,keys:[]}}function zse(){return{map:new Map,keys:[]}}function LC(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.push(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function Gse(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.unshift(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function Vse(c,f,d,y,R=100){LC(c,f,{validUntil:Date.now()+y,data:d},R)}function jse(c,f){const d=c.map.get(f);return d&&d.validUntil>Date.now()?d.data:null}class ua{constructor(f){this.value=f}static of(f){return new ua(f)}static empty(){return new ua(null)}map(f){return new ua(this.value!==null&&this.value!==void 0?f(this.value):null)}mapAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(d=>ua.of(d)):Promise.resolve(ua.empty())}ifPresent(f){return this.value!==null&&this.value!==void 0&&f(this.value),this}ifPresentAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(f){return(this.value===null||this.value===void 0)&&f(),this}ifAbsentAsync(f){return this.value===null||this.value===void 0?f().then(()=>this):Promise.resolve(this)}getOrFallback(f){return this.value??f()}getOrFallbackAsync(f){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):f()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}r.Optional=ua;class Kse{constructor(f){this.supplier=f,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}r.Lazy=Kse;class Wse{constructor(f){this.supplier=f,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}r.AsyncLazy=Wse;function qse(c){return()=>c.forEach(f=>f())}function Zse(c,f){return c.reduce((d,y)=>f(d)>f(y)?d:y)}function Qse(c,f){const d=c.find(y=>y instanceof f);return ua.of(d)}function Yse(c,f){return c.filter(d=>d instanceof f)}function Jse(c,f){const d=[],y=Math.max(c.length,f.length);for(let R=0;R<y;R++)c[R]&&d.push(c[R]),f[R]&&d.push(f[R]);return d}function Xse(c,f){return c.includes(f)?c.filter(d=>d!==f):[...c,f]}class eoe{constructor(f){this.value=f,this.children=[]}}function toe(c,f,d,y,R=!1){const L=new Map,J=[];c.forEach(fe=>{const De=new eoe(fe);L.set(fe[f],De)}),c.forEach(fe=>{const De=L.get(fe[f]);if(!De)return;const Lt=fe[d];if(Lt){const Gr=L.get(Lt);Gr&&Gr.children.push(De)}else J.push(De)});const de=fe=>{fe.children.sort((De,Lt)=>{const Gr=De.value[y],jl=Lt.value[y];return R?jl-Gr:Gr-jl}),fe.children.forEach(de)};return J.forEach(de),J}function UC(c,f){if(Math.log2(c.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...c];for(;d.length>1;){const y=[];for(let R=0;R<d.length;R+=2){const L=d[R+1];y.push(f(d[R],L))}d=y}return d[0]}function zl(...c){const f=c.reduce((R,L)=>R+L.length,0),d=new Uint8Array(f);let y=0;return c.forEach(R=>{d.set(R,y),y+=R.length}),d}function DC(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function $C(c){return c[0]===255&&c[1]===216}function FC(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function roe(c){return DC(c)||$C(c)||FC(c)}function noe(c){return new Uint8Array([c])}function ioe(c){return c[0]}function soe(c,f){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,f==="LE"),new Uint8Array(d)}function ooe(c,f){return new DataView(c.buffer).getUint16(c.byteOffset,f==="LE")}function aoe(c,f){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,f==="LE"),new Uint8Array(d)}function coe(c,f){return new DataView(c.buffer).getUint32(c.byteOffset,f==="LE")}function Cb(c,f){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),f==="LE"),new Uint8Array(d)}function uoe(c,f){return new DataView(c.buffer).getBigUint64(c.byteOffset,f==="LE")}function Gl(c,f){const d=new Uint8Array(32);let y=c;if(f==="LE"){for(let R=0;R<32;R++)d[R]=Number(y&0xffn),y>>=8n;return d}for(let R=31;R>=0;R--)d[R]=Number(y&0xffn),y>>=8n;return d}function Vl(c,f){let d=0n;if(f==="LE"){for(let y=31;y>=0;y--)d=d<<8n|BigInt(c[y]);return d}for(let y=0;y<32;y++)d=d<<8n|BigInt(c[y]);return d}function loe(c,f){const d=[];let y=0;for(const R of f)d.push(c.subarray(y,y+R)),y+=R;return d}function Bb(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.subarray(y,y+f));return d}const HC=[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 foe(c){for(let f=0;f<24;f++){const d=c[0]^c[10]^c[20]^c[30]^c[40],y=c[1]^c[11]^c[21]^c[31]^c[41],R=c[2]^c[12]^c[22]^c[32]^c[42],L=c[3]^c[13]^c[23]^c[33]^c[43],J=c[4]^c[14]^c[24]^c[34]^c[44],de=c[5]^c[15]^c[25]^c[35]^c[45],fe=c[6]^c[16]^c[26]^c[36]^c[46],De=c[7]^c[17]^c[27]^c[37]^c[47],Lt=c[8]^c[18]^c[28]^c[38]^c[48],Gr=c[9]^c[19]^c[29]^c[39]^c[49],jl=R<<1|L>>>31,Woe=L<<1|R>>>31,ud=Lt^jl,ld=Gr^Woe,qoe=J<<1|de>>>31,Zoe=de<<1|J>>>31,fd=d^qoe,hd=y^Zoe,Qoe=fe<<1|De>>>31,Yoe=De<<1|fe>>>31,dd=R^Qoe,pd=L^Yoe,Joe=Lt<<1|Gr>>>31,Xoe=Gr<<1|Lt>>>31,gd=J^Joe,yd=de^Xoe,eae=d<<1|y>>>31,tae=y<<1|d>>>31,md=fe^eae,wd=De^tae;c[0]^=ud,c[1]^=ld,c[2]^=fd,c[3]^=hd,c[4]^=dd,c[5]^=pd,c[6]^=gd,c[7]^=yd,c[8]^=md,c[9]^=wd,c[10]^=ud,c[11]^=ld,c[12]^=fd,c[13]^=hd,c[14]^=dd,c[15]^=pd,c[16]^=gd,c[17]^=yd,c[18]^=md,c[19]^=wd,c[20]^=ud,c[21]^=ld,c[22]^=fd,c[23]^=hd,c[24]^=dd,c[25]^=pd,c[26]^=gd,c[27]^=yd,c[28]^=md,c[29]^=wd,c[30]^=ud,c[31]^=ld,c[32]^=fd,c[33]^=hd,c[34]^=dd,c[35]^=pd,c[36]^=gd,c[37]^=yd,c[38]^=md,c[39]^=wd,c[40]^=ud,c[41]^=ld,c[42]^=fd,c[43]^=hd,c[44]^=dd,c[45]^=pd,c[46]^=gd,c[47]^=yd,c[48]^=md,c[49]^=wd;const $b=c[0],Fb=c[1],Hb=c[2]<<1|c[3]>>>31,zb=c[3]<<1|c[2]>>>31,Gb=c[5]<<30|c[4]>>>2,Vb=c[4]<<30|c[5]>>>2,jb=c[6]<<28|c[7]>>>4,Kb=c[7]<<28|c[6]>>>4,Wb=c[8]<<27|c[9]>>>5,qb=c[9]<<27|c[8]>>>5,Zb=c[11]<<4|c[10]>>>28,Qb=c[10]<<4|c[11]>>>28,Yb=c[13]<<12|c[12]>>>20,Jb=c[12]<<12|c[13]>>>20,Xb=c[14]<<6|c[15]>>>26,e_=c[15]<<6|c[14]>>>26,t_=c[17]<<23|c[16]>>>9,r_=c[16]<<23|c[17]>>>9,n_=c[18]<<20|c[19]>>>12,i_=c[19]<<20|c[18]>>>12,s_=c[20]<<3|c[21]>>>29,o_=c[21]<<3|c[20]>>>29,a_=c[22]<<10|c[23]>>>22,c_=c[23]<<10|c[22]>>>22,u_=c[25]<<11|c[24]>>>21,l_=c[24]<<11|c[25]>>>21,f_=c[26]<<25|c[27]>>>7,h_=c[27]<<25|c[26]>>>7,d_=c[29]<<7|c[28]>>>25,p_=c[28]<<7|c[29]>>>25,g_=c[31]<<9|c[30]>>>23,y_=c[30]<<9|c[31]>>>23,m_=c[33]<<13|c[32]>>>19,w_=c[32]<<13|c[33]>>>19,b_=c[34]<<15|c[35]>>>17,__=c[35]<<15|c[34]>>>17,A_=c[36]<<21|c[37]>>>11,v_=c[37]<<21|c[36]>>>11,E_=c[38]<<8|c[39]>>>24,x_=c[39]<<8|c[38]>>>24,R_=c[40]<<18|c[41]>>>14,I_=c[41]<<18|c[40]>>>14,S_=c[42]<<2|c[43]>>>30,k_=c[43]<<2|c[42]>>>30,T_=c[45]<<29|c[44]>>>3,O_=c[44]<<29|c[45]>>>3,N_=c[47]<<24|c[46]>>>8,C_=c[46]<<24|c[47]>>>8,B_=c[48]<<14|c[49]>>>18,P_=c[49]<<14|c[48]>>>18;c[0]=$b^~Yb&u_,c[1]=Fb^~Jb&l_,c[2]=Yb^~u_&A_,c[3]=Jb^~l_&v_,c[4]=u_^~A_&B_,c[5]=l_^~v_&P_,c[6]=A_^~B_&$b,c[7]=v_^~P_&Fb,c[8]=B_^~$b&Yb,c[9]=P_^~Fb&Jb,c[10]=jb^~n_&s_,c[11]=Kb^~i_&o_,c[12]=n_^~s_&m_,c[13]=i_^~o_&w_,c[14]=s_^~m_&T_,c[15]=o_^~w_&O_,c[16]=m_^~T_&jb,c[17]=w_^~O_&Kb,c[18]=T_^~jb&n_,c[19]=O_^~Kb&i_,c[20]=Hb^~Xb&f_,c[21]=zb^~e_&h_,c[22]=Xb^~f_&E_,c[23]=e_^~h_&x_,c[24]=f_^~E_&R_,c[25]=h_^~x_&I_,c[26]=E_^~R_&Hb,c[27]=x_^~I_&zb,c[28]=R_^~Hb&Xb,c[29]=I_^~zb&e_,c[30]=Wb^~Zb&a_,c[31]=qb^~Qb&c_,c[32]=Zb^~a_&b_,c[33]=Qb^~c_&__,c[34]=a_^~b_&N_,c[35]=c_^~__&C_,c[36]=b_^~N_&Wb,c[37]=__^~C_&qb,c[38]=N_^~Wb&Zb,c[39]=C_^~qb&Qb,c[40]=Gb^~t_&d_,c[41]=Vb^~r_&p_,c[42]=t_^~d_&g_,c[43]=r_^~p_&y_,c[44]=d_^~g_&S_,c[45]=p_^~y_&k_,c[46]=g_^~S_&Gb,c[47]=y_^~k_&Vb,c[48]=S_^~Gb&t_,c[49]=k_^~Vb&r_,c[0]^=HC[f*2],c[1]^=HC[f*2+1]}}function zC(c){const f=[];for(let d=0;d<c.length;d+=4)f.push(c[d]|c[d+1]<<8|c[d+2]<<16|c[d+3]<<24);return f}function GC(c,f){if(!c.length){const R=new Uint8Array(136);return R[0]=f,R[135]=128,[zC(R)]}const d=Bb(c,136),y=d[d.length-1];if(y.length<136){const R=new Uint8Array(136);R.set(y),R[y.length]=f,R[135]|=128,d[d.length-1]=R}if(y.length===136){const R=new Uint8Array(136);R[0]=f,R[135]=128,d.push(R)}return d.map(zC)}function VC(c,f){for(const d of f){for(let y=0;y<34;y+=2)c[y]^=d[y+1],c[y+1]^=d[y];foe(c)}return c}function jC(c){return new Uint8Array([c[1],c[1]>>-24,c[1]>>-16,c[1]>>-8,c[0],c[0]>>8,c[0]>>16,c[0]>>24,c[3],c[3]>>-24,c[3]>>-16,c[3]>>-8,c[2],c[2]>>8,c[2]>>16,c[2]>>24,c[5],c[5]>>-24,c[5]>>-16,c[5]>>-8,c[4],c[4]>>8,c[4]>>16,c[4]>>24,c[7],c[7]>>-24,c[7]>>-16,c[7]>>-8,c[6],c[6]>>8,c[6]>>16,c[6]>>24])}function oo(c){return jC(VC(new Array(50).fill(0),GC(c,1)))}function hoe(c){return jC(VC(new Array(50).fill(0),GC(c,6)))}function doe(c,f,d){const y=Math.min(c.length,f.length,d/8+1);for(let R=0;R<y;R++){const L=c[R]^f[R];for(let J=0;J<8;J++)if(L>>7-J&1)return R*8+J}return d}function poe(c,f){const d=Math.min(c.length,f.length);for(let y=0;y<d;y++)if(c[y]!==f[y])return c.subarray(0,y);return c.subarray(0,d)}function goe(c,f,d,y){const R=Math.floor(f/8),L=f%8;d===1?c[R]|=1<<(y==="BE"?7-L:L):c[R]&=~(1<<(y==="BE"?7-L:L))}function yoe(c,f,d){const y=Math.floor(f/8),R=f%8;return c[y]>>(d==="BE"?7-R:R)&1}function moe(c,f,d=0){for(let y=d;y<c.length;y++)for(let R=0;R<f.length&&c[y+R]===f[R];R++)if(R===f.length-1)return y;return-1}function KC(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,f-c.length),y}function woe(c,f,d=0){const y=c.length%f;return y===0?c:KC(c,c.length+f-y,d)}function WC(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,0),y}function boe(c,f,d=0){const y=c.length%f;return y===0?c:WC(c,c.length+f-y,d)}function _oe(c,f){const d=new Uint8Array(c.length);for(let y=0;y<c.length;y++)d[y]=c[y]^f[y%f.length];return d}function Aoe(c,f){if(c.length!==f.length)return!1;for(let d=0;d<c.length;d++)if(c[d]!==f[d])return!1;return!0}function Vt(c,f){return(c%f+f)%f}function ad(c,f){c=Vt(c,f);let[d,y]=[0n,1n],[R,L]=[f,c];for(;L!==0n;){const J=R/L;[d,y]=[y,d-J*y],[R,L]=[L,R-J*L]}if(R>1n)throw new Error("a is not invertible");return d<0n&&(d+=f),d}function voe(c,f,d){let y=1n;for(c=Vt(c,d);f>0;)f%2n===1n&&(y=Vt(y*c,d)),c=Vt(c*c,d),f=f/2n;return y}function qC(c,f){return Vt(c,f)===0n?0n:f%4n===3n?voe(c,(f+1n)/4n,f):null}const hn=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,zr=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,fg=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,hg=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Pb(c,f,d){if(f===0n)return[0n,0n];const y=Vt(3n*c*c*ad(2n*f,d),d),R=Vt(y*y-2n*c,d),L=Vt(y*(c-R)-f,d);return[R,L]}function dg(c,f,d,y,R){if(c===0n&&f===0n)return[d,y];if(d===0n&&y===0n)return[c,f];if(c===d&&f===Vt(-y,R))return[0n,0n];if(c===d&&f===y)return Pb(c,f,R);const L=Vt((y-f)*ad(d-c,R),R),J=Vt(L*L-c-d,R),de=Vt(L*(c-J)-f,R);return[J,de]}function Eoe(c){if(c<=0n||c>=zr)throw new Error("Invalid private key");return Pc(fg,hg,c,hn)}function xoe(c){const f=c[1]%2n===0n?2:3;return new Uint8Array([f,...Gl(c[0],"BE")])}function Roe(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const f=Vl(c.slice(1),"BE"),d=qC(Vt(f**3n+7n,hn),hn);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const y=Vt(-d,hn),R=d%2n===0n;return[f,c[0]===2?R?d:y:R?y:d]}function Ioe(c){const f=new Uint8Array(20),d=oo(zl(Gl(c[0],"BE"),Gl(c[1],"BE")));return f.set(d.subarray(12)),f}function Soe(c){const f=r.Binary.uint8ArrayToHex(c),d=r.Binary.uint8ArrayToHex(r.Binary.keccak256(new Uint8Array([...f].map(R=>R.charCodeAt(0)))));let y="0x";for(let R=0;R<f.length;R++)parseInt(d[R],16)>7?y+=f[R].toUpperCase():y+=f[R];return y}function Pc(c,f,d,y){let R=[0n,0n],L=[c,f];const J=d.toString(2);for(const de of J)de==="0"?(L=dg(R[0],R[1],L[0],L[1],y),R=Pb(R[0],R[1],y)):(R=dg(R[0],R[1],L[0],L[1],y),L=Pb(L[0],L[1],y));return R}function koe(c,f,d){return ZC(Vl(oo(c),"BE"),f,d)}function ZC(c,f,d){if(f<=0n||f>=zr)throw new Error("Invalid private key");if(d||(d=Vt(Vl(oo(zl(oo(Gl(f,"BE")),Gl(c,"BE"))),"BE"),zr)),d<=0n||d>=zr)throw new Error("Invalid nonce");const y=Vt(c,zr),R=Pc(fg,hg,d,hn),L=Vt(R[0],zr);let J=Vt((y+Vt(L,zr)*f)*ad(d,zr),zr);if(L===0n||J===0n)throw new Error("Invalid r or s value");let de=R[1]%2n===0n?27n:28n;return J>zr/2n&&(J=zr-J,de=de===27n?28n:27n),[L,J,de]}function Toe(c,f,d,y){const R=qC(Vt(f**3n+7n,hn),hn);if(!R)throw new Error("Invalid r: does not correspond to a valid curve point");const L=y===27n?0n:1n,J=R%2n===L?R:hn-R,de=Vt(Vl(oo(c),"BE"),zr),fe=Pc(f,J,d,hn),De=Pc(fg,hg,de,hn),Lt=dg(fe[0],fe[1],De[0],Vt(-De[1],hn),hn);return Pc(Lt[0],Lt[1],ad(f,zr),hn)}function Ooe(c,f,d,y){const R=Vt(Vl(oo(c),"BE"),zr),L=ad(y,zr),J=Vt(R*L,zr),de=Vt(d*L,zr),fe=Pc(fg,hg,J,hn),De=Pc(f[0],f[1],de,hn),Lt=dg(fe[0],fe[1],De[0],De[1],hn);return d===Vt(Lt[0],zr)}class QC{constructor(f){this.cursor=0,this.buffer=f}read(f){const d=this.buffer.subarray(this.cursor,this.cursor+f);return this.cursor+=f,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayReader=QC;class YC{constructor(f){this.buffer=f,this.cursor=0}write(f){const d=Math.min(this.max(),f.max());return this.buffer.set(f.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayWriter=YC;class pg{constructor(f,d=0n){this.span=d,this.writer=new YC(new Uint8Array(f))}build(){return zl(Cb(this.span,"LE"),this.writer.buffer)}hash(){const f=UC(Bb(this.writer.buffer,32),(d,y)=>oo(zl(d,y)));return oo(zl(Cb(this.span,"LE"),f))}}r.Chunk=pg;class Mb{constructor(f,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new pg(d)],this.onChunk=f}static async root(f,d=4096){const y=new e(e.NOOP,d);return await y.append(f),y.finalize()}async append(f,d=0,y=0n){const R=new QC(f);for(;R.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(R);y?this.chunks[d].span+=y:this.chunks[0].span+=BigInt(L)}}async elevate(f){this.counters[f]=++this.counters[f]%(this.capacity/32),this.chunks[f+1]||(this.chunks.push(new pg(this.capacity)),this.counters.push(1)),await this.append(this.chunks[f].hash(),f+1,this.chunks[f].span),await this.onChunk(this.chunks[f]),this.chunks[f]=new pg(this.capacity)}async finalize(f=0){return this.chunks[f+1]?this.counters[f]===1?(await this.elevate(f+1),this.chunks[f+1]=this.chunks[f],this.finalize(f+1)):(await this.elevate(f),this.finalize(f+1)):(await this.onChunk(this.chunks[f]),this.chunks[f])}}r.MerkleTree=Mb,e=Mb,Mb.NOOP=async c=>{};class ws{constructor(f,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(f),this.scale=d}static fromDecimalString(f,d){let[y,R]=f.split(".");return R=(R||"").padEnd(d,"0").slice(0,d),new ws(BigInt(y+R),d)}add(f){return this.assertSameScale(f),new ws(this.value+f.value,this.scale)}subtract(f){return this.assertSameScale(f),new ws(this.value-f.value,this.scale)}multiply(f){return new ws(this.value*f,this.scale)}divmod(f){if(f===0n)throw new Error("Division by zero is not allowed");const d=this.value/f,y=this.value%f;return[new ws(d,this.scale),new ws(y,this.scale)]}exchange(f,d,y){if(f==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new ws(L,y)}this.assertSameScale(d);const R=this.value*10n**BigInt(y)/d.value;return new ws(R,y)}compare(f){return this.assertSameScale(f),this.value>f.value?1:this.value<f.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const f=this.value.toString(),d=f.slice(0,-this.scale)||"0",y=f.slice(-this.scale).padStart(this.scale,"0");return`${d}.${y}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(f){if(this.scale!==f.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${f.scale}`)}}r.FixedPointNumber=ws;function Noe(c){if(c.length===0)return null;const f=c[0];return f.ttlMax?--f.ttl<=0&&c.shift():f.ttlMax=f.ttl,{progress:(f.ttlMax-f.ttl)/f.ttlMax,data:f.data}}function gg(c,f,d,y){const R=c.findIndex(de=>de===`--${f}`||de.startsWith(`--${f}=`)),L=c[R];if(!L)return(d||{})[y||f||""]||null;if(L.includes("="))return L.split("=")[1];const J=c[R+1];return J&&!J.startsWith("-")?J:(d||{})[y||f||""]||null}function Coe(c,f,d,y){const R=gg(c,f,d,y);if(!R)return null;try{return Tb(R)}catch{throw new Error(`Invalid number argument ${f}: ${R}`)}}function Boe(c,f,d,y){const R=c.some(fe=>fe.endsWith("-"+f)),L=gg(c,f,d,y);if(!L&&R)return!0;if(!L&&!R)return null;const J=["true","1","yes","y","on"],de=["false","0","no","n","off"];if(J.includes(L.toLowerCase()))return!0;if(de.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${f}: ${L}`)}function JC(c,f,d,y){const R=gg(c,f,d,y);if(!R)throw new Error(`Missing argument ${f}`);return R}function Poe(c,f,d,y){const R=JC(c,f,d,y);try{return Tb(R)}catch{throw new Error(`Invalid argument ${f}: ${R}`)}}function XC(c,f){const d=c[f];c.splice(f,1),c.unshift(d)}function Moe(c,f){const d=[...c];return XC(d,f),d}function e6(c,f){return{x:c.x+f.x,y:c.y+f.y}}function Loe(c,f){return{x:c.x-f.x,y:c.y-f.y}}function Lb(c,f){return{x:c.x*f,y:c.y*f}}function Uoe(c){const f=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/f,y:c.y/f}}function t6(c,f,d){return{x:c.x+Math.cos(f)*d,y:c.y+Math.sin(f)*d}}function r6(c,f){return Math.sqrt((c.x-f.x)**2+(c.y-f.y)**2)}function cd(c,f,d="row-first"){const y=[];if(d==="column-first")for(let R=0;R<c.length;R++)for(let L=0;L<c[0].length;L++)f(R,L)&&y.push({x:R,y:L});else for(let R=0;R<c[0].length;R++)for(let L=0;L<c.length;L++)f(L,R)&&y.push({x:L,y:R});return y}function Doe(c,f,d){var y,R;return((y=c[f+1])==null?void 0:y[d])&&((R=c[f-1])==null?void 0:R[d])&&!c[f][d-1]&&!c[f][d+1]}function $oe(c,f,d){var y,R;return c[f][d+1]&&c[f][d-1]&&!((y=c[f-1])!=null&&y[d])&&!((R=c[f+1])!=null&&R[d])}function n6(c,f,d){var y;return!((y=c[f-1])!=null&&y[d])}function i6(c,f,d){var y;return!((y=c[f+1])!=null&&y[d])}function s6(c,f,d){return!c[f][d-1]}function o6(c,f,d){return!c[f][d+1]}function Foe(c,f,d){var R,L,J,de,fe,De,Lt,Gr;const y=[];return c[f][d]?Doe(c,f,d)||$oe(c,f,d)?[]:(!((R=c[f-1])!=null&&R[d-1])&&n6(c,f,d)&&s6(c,f,d)&&y.push({x:f,y:d}),!((L=c[f+1])!=null&&L[d-1])&&i6(c,f,d)&&s6(c,f,d)&&y.push({x:f+1,y:d}),!((J=c[f-1])!=null&&J[d+1])&&n6(c,f,d)&&o6(c,f,d)&&y.push({x:f,y:d+1}),!((de=c[f+1])!=null&&de[d+1])&&i6(c,f,d)&&o6(c,f,d)&&y.push({x:f+1,y:d+1}),y):((fe=c[f-1])!=null&&fe[d]&&c[f][d-1]&&y.push({x:f,y:d}),(De=c[f+1])!=null&&De[d]&&c[f][d-1]&&y.push({x:f+1,y:d}),(Lt=c[f-1])!=null&&Lt[d]&&c[f][d+1]&&y.push({x:f,y:d+1}),(Gr=c[f+1])!=null&&Gr[d]&&c[f][d+1]&&y.push({x:f+1,y:d+1}),y)}function Hoe(c,f,d,y){const R=[{x:0,y:0},{x:d,y:0},{x:0,y},{x:d,y}];for(let L=0;L<c.length;L++)for(let J=0;J<c[0].length;J++){const de=Foe(c,L,J);for(const fe of de)R.some(De=>De.x===fe.x&&De.y===fe.y)||R.push(fe)}return R.map(L=>({x:L.x*f,y:L.y*f}))}function zoe(c,f){const d=cd(c,(fe,De)=>c[fe][De]===0&&c[fe][De+1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),y=cd(c,(fe,De)=>c[fe][De]===0&&c[fe][De-1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),R=cd(c,(fe,De)=>{var Lt;return c[fe][De]===0&&((Lt=c[fe-1])==null?void 0:Lt[De])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1})),L=cd(c,(fe,De)=>{var Lt;return c[fe][De]===0&&((Lt=c[fe+1])==null?void 0:Lt[De])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1}));d.forEach(fe=>fe.y++),L.forEach(fe=>fe.x++);const J=Nb([...R,...L],(fe,De)=>fe.x===De.x&&fe.y-1===De.y),de=Nb([...y,...d],(fe,De)=>fe.y===De.y&&fe.x-1===De.x);return[...J,...de].map(fe=>({start:fe[0],end:B(fe)})).map(fe=>({start:Lb(fe.start,f),end:Lb(e6(fe.end,{x:fe.start.dx,y:fe.start.dy}),f)}))}function Goe(c,f){return Math.atan2(f.y-c.y,f.x-c.x)}function Voe(c,f){return f.map(d=>Goe(c,d)).sort((d,y)=>d-y)}function a6(c,f,d,y){const R=(y.y-d.y)*(f.x-c.x)-(y.x-d.x)*(f.y-c.y);if(R===0)return null;let L=c.y-d.y,J=c.x-d.x;const de=(y.x-d.x)*L-(y.y-d.y)*J,fe=(f.x-c.x)*L-(f.y-c.y)*J;return L=de/R,J=fe/R,L>0&&L<1&&J>0&&J<1?{x:c.x+L*(f.x-c.x),y:c.y+L*(f.y-c.y)}:null}function Ub(c,f,d){const y=[],R=t6(c,d,1e4);for(const L of f){const J=a6(c,R,L.start,L.end);J&&y.push(J)}return y.length?y.reduce((L,J)=>{const de=r6(c,J),fe=r6(c,L);return de<fe?J:L}):null}function joe(c,f,d){const y=Voe(c,d),R=[];for(const L of y){const J=Ub(c,f,L-.001),de=Ub(c,f,L+.001);J&&R.push(J),de&&R.push(de)}return R}class Db{constructor(){this.subscribers=[]}subscribe(f){return this.subscribers.push(f),()=>{this.subscribers=this.subscribers.filter(d=>d!==f)}}publish(f){this.subscribers.forEach(d=>d(f))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}r.PubSubChannel=Db;class Koe{constructor(f,d){this.queue=[],this.running=0,this.onProcessed=new Db,this.onDrained=new Db,this.concurrency=f,this.capacity=d}process(){if(this.running>=this.concurrency)return;const f=this.queue.shift();f&&(this.running++,f().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(f){if(this.queue.length<this.capacity)return this.queue.push(f),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(f),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(f=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),f()})})}}r.AsyncQueue=Koe,r.Binary={hexToUint8Array:Yne,uint8ArrayToHex:Jne,base64ToUint8Array:Wne,uint8ArrayToBase64:qne,base32ToUint8Array:Zne,uint8ArrayToBase32:Qne,log2Reduce:UC,partition:Bb,concatBytes:zl,numberToUint8:noe,uint8ToNumber:ioe,numberToUint16:soe,uint16ToNumber:ooe,numberToUint32:aoe,uint32ToNumber:coe,numberToUint64:Cb,uint64ToNumber:uoe,numberToUint256:Gl,uint256ToNumber:Vl,sliceBytes:loe,keccak256:oo,sha3_256:hoe,proximity:doe,commonPrefix:poe,setBit:goe,getBit:yoe,indexOf:moe,equals:Aoe,padStart:KC,padStartToMultiple:woe,padEnd:WC,padEndToMultiple:boe,xorCypher:_oe},r.Elliptic={privateKeyToPublicKey:Eoe,compressPublicKey:xoe,publicKeyFromCompressed:Roe,publicKeyToAddress:Ioe,signMessage:koe,signHash:ZC,verifySignature:Ooe,recoverPublicKey:Toe,checksumEncode:Soe},r.Random={intBetween:H,floatBetween:D,chance:K,signed:z,makeSeededRng:C,point:Z,procs:V},r.Arrays={countUnique:Use,makeUnique:Lse,splitBySize:Pse,splitByCount:BC,index:CC,indexCollection:Bse,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:l,shuffle:o,initialize:g,initialize2D:w,rotate2D:b,containsShape:I,glue:rne,pluck:x,pick:oe,pickMany:ce,pickManyUnique:ie,pickWeighted:E,pickRandomIndices:S,pickGuaranteed:ue,last:B,pipe:p,makePipe:m,sortWeighted:k,pushAll:aa,unshiftAll:ene,filterAndRemove:Aie,merge:yse,empty:mse,pushToBucket:rd,unshiftAndLimit:nd,atRolling:id,group:Nb,createOscillator:nse,organiseWithLimits:sse,tickPlaybook:Noe,getArgument:gg,getBooleanArgument:Boe,getNumberArgument:Coe,requireStringArgument:JC,requireNumberArgument:Poe,bringToFront:Moe,bringToFrontInPlace:XC,findInstance:Qse,filterInstances:Yse,interleave:Jse,toggle:Xse,createHierarchy:toe,multicall:qse,maxBy:Zse},r.System={sleepMillis:s,forever:te,scheduleMany:une,waitFor:_ie,expandError:Jh,runAndSetInterval:re},r.Numbers={make:Tb,sum:fne,average:hne,median:dne,getDistanceFromMidpoint:pne,clamp:Ob,range:tC,interpolate:lne,createSequence:rse,increment:hse,decrement:dse,format:fse,fromDecimals:lse,makeStorage:Kie,asMegabytes:he,convertBytes:ye,hexToRgb:be,rgbToHex:Ke,haversineDistanceToMeters:Fe,roundToNearest:Be,formatDistance:et,triangularNumber:Qe,searchFloat:ot},r.Promises={raceFulfilled:n,invert:t,runInParallelBatches:i},r.Dates={getTimestamp:Oie,getTimeDelta:EC,secondsToHumanTime:Nie,countCycles:Cie,isoDate:xie,throttle:Bie,timeSince:Mie,dateTimeSlug:Rie,unixTimestamp:Eie,fromUtcString:Iie,fromMillis:Sie,getProgress:Lie,humanizeTime:ug,humanizeProgress:bie,createTimeDigits:ms,mapDayNumber:xC,getDayInfoFromDate:Sb,getDayInfoFromDateTimeString:Die,seconds:$ie,minutes:Fie,hours:Hie,days:zie,make:Vie,normalizeTime:kie,absoluteDays:Cc},r.Objects={safeParse:tse,deleteDeep:A,getDeep:O,setDeep:M,incrementDeep:G,ensureDeep:P,replaceDeep:U,getFirstDeep:le,deepMergeInPlace:Li,deepMerge2:Xh,deepMerge3:ed,mapAllAsync:tne,cloneWithJson:vie,sortObject:IC,sortArray:SC,sortAny:Bc,deepEquals:kC,deepEqualsEvery:ese,runOn:pse,ifPresent:gse,zip:Fl,zipSum:td,removeEmptyArrays:wse,removeEmptyValues:bse,flatten:Nse,unflatten:NC,match:Cse,sort:MC,map:vse,mapIterable:Ese,filterKeys:_se,filterValues:Ase,rethrow:xse,setSomeOnObject:Rse,setSomeDeep:Ise,flip:Sse,getAllPermutations:kse,countTruthyValues:Tse,transformToArray:Dse,setMulti:Fse,incrementMulti:$se,createBidirectionalMap:Hse,createTemporalBidirectionalMap:zse,pushToBidirectionalMap:LC,unshiftToBidirectionalMap:Gse,addToTemporalBidirectionalMap:Vse,getFromTemporalBidirectionalMap:jse,createStatefulToggle:ise,diffKeys:ose,pickRandomKey:TC,mapRandomKey:ase,fromObjectString:cse,toQueryString:AC,parseQueryString:fie,hasKey:hie,selectMax:die,reposition:pie,unwrapSingleKey:gie,parseKeyValues:yie},r.Types={isFunction:Ct,isObject:sr,isStrictlyObject:dt,isEmptyArray:Ut,isEmptyObject:oa,isUndefined:It,isString:kr,isNumber:pt,isBoolean:St,isDate:or,isBlank:xt,isId:Bt,isIntegerString:fn,isHexString:Dt,isUrl:Dl,isNullable:qh,asString:ar,asHexString:pr,asSafeString:ng,asIntegerString:rg,asNumber:Oc,asFunction:gr,asInteger:Jt,asBoolean:yr,asDate:ig,asNullableString:mr,asEmptiableString:wr,asId:sg,asTime:br,asArray:_r,asObject:Nc,asNullableObject:Ar,asStringMap:vr,asNumericDictionary:Kh,asUrl:Wh,asNullable:Zh,asOptional:Qh,enforceObjectShape:$l,enforceArrayShape:Yh,isPng:DC,isJpg:$C,isWebp:FC,isImage:roe},r.Strings={tokenizeByCount:Mse,tokenizeByLength:PC,searchHex:tg,searchSubstring:hr,randomHex:dr,randomLetter:We,randomAlphanumeric:$t,randomRichAscii:Ge,randomUnicode:fr,includesAny:gne,slugify:wb,normalForm:mne,enumify:Ene,escapeHtml:Rne,decodeHtmlEntities:Sne,after:bb,afterLast:nC,before:rC,beforeLast:_b,betweenWide:kne,betweenNarrow:Tne,getPreLine:Wie,containsWord:Rb,containsWords:aie,joinUrl:RC,getFuzzyMatchScore:og,sortByFuzzyScore:xne,splitOnce:Ab,splitAll:iC,randomize:Bne,expand:sC,shrinkTrim:sd,capitalize:ag,decapitalize:oC,csvEscape:$ne,parseCsv:wie,surroundInOut:vne,getExtension:vb,getBasename:Eb,normalizeEmail:One,normalizeFilename:Nne,parseFilename:Cne,camelToTitle:wne,slugToTitle:bne,slugToCamel:_ne,joinHumanly:Ane,findWeightedPair:hC,extractBlock:dC,extractAllBlocks:zne,replaceBlocks:Gne,indexOfEarliest:Hl,lastIndexOfBefore:fC,parseHtmlAttributes:cie,readNextWord:cg,resolveVariables:uie,resolveVariableWithDefaultSyntax:bC,resolveRemainingVariablesWithDefaults:_C,isLetter:aC,isDigit:cC,isLetterOrDigit:od,isValidObjectPathCharacter:Lne,insert:Une,indexOfRegex:uC,lineMatches:lC,linesMatchInOrder:Dne,represent:so,resolveMarkdownLinks:lie,buildUrl:mie,isChinese:yne,replaceBetweenStrings:Qie,describeMarkdown:Yie,isBalanced:Jie,textToFormat:Xie,splitFormatting:Vne,splitHashtags:jne,splitUrls:Kne,route:Xne,explodeReplace:xb,generateVariants:eie,replaceWord:tie,replacePascalCaseWords:rie,stripHtml:nie,breakLine:wC,measureTextWidth:iie,toLines:sie,levenshteinDistance:oie},r.Assertions={asEqual:nne,asTrue:ine,asTruthy:sne,asFalse:one,asFalsy:ane,asEither:cne},r.Cache={get:qie,invalidate:Zie},r.Vector={addPoint:e6,subtractPoint:Loe,multiplyPoint:Lb,normalizePoint:Uoe,pushPoint:t6,filterCoordinates:cd,findCorners:Hoe,findLines:zoe,raycast:Ub,raycastCircle:joe,getLineIntersectionPoint:a6}})(PA);const Kt=xn(PA);Kt.Arrays,Kt.Assertions;const en=Kt.Binary;Kt.Cache,Kt.Dates,Kt.Elliptic,Kt.Numbers,Kt.Objects,Kt.Pagination,Kt.Promises,Kt.Random,Kt.Strings,Kt.System,Kt.Types,Kt.Optional,Kt.Vector,Kt.PubSubChannel,Kt.Chunk;const k4=Kt.MerkleTree;Kt.FixedPointNumber,Kt.Lazy,Kt.AsyncLazy,Kt.AsyncQueue,Kt.Uint8ArrayReader,Kt.Uint8ArrayWriter;var gt;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.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},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(gt||(gt={}));var jg;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(jg||(jg={}));const ke=gt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=r=>{switch(typeof r){case"undefined":return ke.undefined;case"string":return ke.string;case"number":return isNaN(r)?ke.nan:ke.number;case"boolean":return ke.boolean;case"function":return ke.function;case"bigint":return ke.bigint;case"symbol":return ke.symbol;case"object":return Array.isArray(r)?ke.array:r===null?ke.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ke.promise:typeof Map<"u"&&r instanceof Map?ke.map:typeof Set<"u"&&r instanceof Set?ke.set:typeof Date<"u"&&r instanceof Date?ke.date:ke.object;default:return ke.unknown}},we=gt.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"]),T4=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class $n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(s){return s.message},n={_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)n._errors.push(t(o));else{let a=n,u=0;for(;u<o.path.length;){const l=o.path[u];u===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof $n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,gt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}$n.create=r=>new $n(r);const zc=(r,e)=>{let t;switch(r.code){case we.invalid_type:r.received===ke.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case we.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,gt.jsonStringifyReplacer)}`;break;case we.unrecognized_keys:t=`Unrecognized key(s) in object: ${gt.joinValues(r.keys,", ")}`;break;case we.invalid_union:t="Invalid input";break;case we.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${gt.joinValues(r.options)}`;break;case we.invalid_enum_value:t=`Invalid enum value. Expected ${gt.joinValues(r.options)}, received '${r.received}'`;break;case we.invalid_arguments:t="Invalid function arguments";break;case we.invalid_return_type:t="Invalid function return type";break;case we.invalid_date:t="Invalid date";break;case we.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:gt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case we.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case we.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case we.custom:t="Invalid input";break;case we.invalid_intersection_types:t="Intersection results could not be merged";break;case we.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case we.not_finite:t="Number must be finite";break;default:t=e.defaultError,gt.assertNever(r)}return{message:t}};let MA=zc;function O4(r){MA=r}function $d(){return MA}const Fd=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)a=l(o,{data:e,defaultError:a}).message;return{...i,path:s,message:a}},N4=[];function xe(r,e){const t=$d(),n=Fd({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===zc?void 0:zc].filter(i=>!!i)});r.common.issues.push(n)}class tn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return je;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return tn.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return je;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const je=Object.freeze({status:"aborted"}),Gc=r=>({status:"dirty",value:r}),dn=r=>({status:"valid",value:r}),Kg=r=>r.status==="aborted",Wg=r=>r.status==="dirty",da=r=>r.status==="valid",Yl=r=>typeof Promise<"u"&&r instanceof Promise;function Hd(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function LA(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ue;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ue||(Ue={}));var Jl,Xl;class Di{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,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 UA=(r,e)=>{if(da(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new $n(r.common.issues);return this._error=t,this._error}}};function Je(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{var u,l;const{message:h}=r;return o.code==="invalid_enum_value"?{message:h??a.defaultError}:typeof a.data>"u"?{message:(u=h??n)!==null&&u!==void 0?u:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l:a.defaultError}},description:i}}class tt{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new tn,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Yl(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},s=this._parseSync({data:e,path:i.path,parent:i});return UA(i,s)}"~validate"(e){var t,n;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:i});return da(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((n=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(s=>da(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Yl(i)?i:Promise.resolve(i));return UA(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),a=()=>s.addIssue({code:we.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new bi({schema:this,typeName:Ve.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:t=>this["~validate"](t)}}optional(){return Fi.create(this,this._def)}nullable(){return lo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return wi.create(this)}promise(){return Wc.create(this,this._def)}or(e){return nf.create([this,e],this._def)}and(e){return sf.create(this,e,this._def)}transform(e){return new bi({...Je(this._def),schema:this,typeName:Ve.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lf({...Je(this._def),innerType:this,defaultValue:t,typeName:Ve.ZodDefault})}brand(){return new Qg({typeName:Ve.ZodBranded,type:this,...Je(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ff({...Je(this._def),innerType:this,catchValue:t,typeName:Ve.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return hf.create(this,e)}readonly(){return df.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C4=/^c[^\s-]{8,}$/i,B4=/^[0-9a-z]+$/,P4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,M4=/^[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,L4=/^[a-z0-9_-]{21}$/i,U4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,D4=/^[-+]?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)?)??$/,$4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qg;const H4=/^(?:(?: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])$/,z4=/^(?:(?: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])$/,G4=/^(([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]))$/,V4=/^(([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])$/,j4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,K4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DA="((\\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])))",W4=new RegExp(`^${DA}$`);function $A(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function q4(r){return new RegExp(`^${$A(r)}$`)}function FA(r){let e=`${DA}T${$A(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Z4(r,e){return!!((e==="v4"||!e)&&H4.test(r)||(e==="v6"||!e)&&G4.test(r))}function Q4(r,e){if(!U4.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function Y4(r,e){return!!((e==="v4"||!e)&&z4.test(r)||(e==="v6"||!e)&&V4.test(r))}class mi extends tt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ke.string){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.string,received:s.parsedType}),je}const n=new tn;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")$4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"email",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")qg||(qg=new RegExp(F4,"u")),qg.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"emoji",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")M4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"uuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")L4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"nanoid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")C4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")B4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid2",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")P4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ulid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),xe(i,{validation:"url",code:we.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"regex",code:we.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?FA(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?W4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?q4(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?D4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"duration",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Z4(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ip",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Q4(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"jwt",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Y4(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cidr",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?j4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?K4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64url",code:we.invalid_string,message:s.message}),n.dirty()):gt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:we.invalid_string,...Ue.errToObj(n)})}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ue.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ue.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ue.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ue.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ue.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ue.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ue.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ue.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ue.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ue.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ue.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ue.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ue.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ue.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ue.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ue.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ue.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ue.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ue.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ue.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ue.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ue.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ue.errToObj(t)})}nonempty(e){return this.min(1,Ue.errToObj(e))}trim(){return new mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}mi.create=r=>{var e;return new mi({checks:[],typeName:Ve.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};function J4(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class ao extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ke.number){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.number,received:s.parsedType}),je}let n;const i=new tn;for(const s of this._def.checks)s.kind==="int"?gt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?J4(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_finite,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new ao({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new ao({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ue.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ue.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ue.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ue.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&>.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ao.create=r=>new ao({checks:[],typeName:Ve.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Je(r)});class co extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ke.bigint)return this._getInvalidInput(e);let n;const i=new tn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:ke.bigint,received:t.parsedType}),je}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new co({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new co({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}co.create=r=>{var e;return new co({checks:[],typeName:Ve.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};class ef extends tt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ke.boolean){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.boolean,received:n.parsedType}),je}return dn(e.data)}}ef.create=r=>new ef({typeName:Ve.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Je(r)});class pa extends tt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ke.date){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.date,received:s.parsedType}),je}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_date}),je}const n=new tn;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):gt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new pa({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ue.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ue.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}pa.create=r=>new pa({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ve.ZodDate,...Je(r)});class zd extends tt{_parse(e){if(this._getType(e)!==ke.symbol){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.symbol,received:n.parsedType}),je}return dn(e.data)}}zd.create=r=>new zd({typeName:Ve.ZodSymbol,...Je(r)});class tf extends tt{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.undefined,received:n.parsedType}),je}return dn(e.data)}}tf.create=r=>new tf({typeName:Ve.ZodUndefined,...Je(r)});class rf extends tt{_parse(e){if(this._getType(e)!==ke.null){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.null,received:n.parsedType}),je}return dn(e.data)}}rf.create=r=>new rf({typeName:Ve.ZodNull,...Je(r)});class Vc extends tt{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}}Vc.create=r=>new Vc({typeName:Ve.ZodAny,...Je(r)});class ga extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}}ga.create=r=>new ga({typeName:Ve.ZodUnknown,...Je(r)});class _s extends tt{_parse(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:ke.never,received:t.parsedType}),je}}_s.create=r=>new _s({typeName:Ve.ZodNever,...Je(r)});class Gd extends tt{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.void,received:n.parsedType}),je}return dn(e.data)}}Gd.create=r=>new Gd({typeName:Ve.ZodVoid,...Je(r)});class wi extends tt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ke.array)return xe(t,{code:we.invalid_type,expected:ke.array,received:t.parsedType}),je;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(o||a)&&(xe(t,{code:o?we.too_big:we.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(xe(t,{code:we.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(xe(t,{code:we.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>i.type._parseAsync(new Di(t,o,t.path,a)))).then(o=>tn.mergeArray(n,o));const s=[...t.data].map((o,a)=>i.type._parseSync(new Di(t,o,t.path,a)));return tn.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new wi({...this._def,minLength:{value:e,message:Ue.toString(t)}})}max(e,t){return new wi({...this._def,maxLength:{value:e,message:Ue.toString(t)}})}length(e,t){return new wi({...this._def,exactLength:{value:e,message:Ue.toString(t)}})}nonempty(e){return this.min(1,e)}}wi.create=(r,e)=>new wi({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ve.ZodArray,...Je(e)});function jc(r){if(r instanceof Xt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Fi.create(jc(n))}return new Xt({...r._def,shape:()=>e})}else return r instanceof wi?new wi({...r._def,type:jc(r.element)}):r instanceof Fi?Fi.create(jc(r.unwrap())):r instanceof lo?lo.create(jc(r.unwrap())):r instanceof $i?$i.create(r.items.map(e=>jc(e))):r}class Xt extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=gt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ke.object){const l=this._getOrReturnCtx(e);return xe(l,{code:we.invalid_type,expected:ke.object,received:l.parsedType}),je}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof _s&&this._def.unknownKeys==="strip"))for(const l in i.data)o.includes(l)||a.push(l);const u=[];for(const l of o){const h=s[l],g=i.data[l];u.push({key:{status:"valid",value:l},value:h._parse(new Di(i,g,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof _s){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of a)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(l==="strict")a.length>0&&(xe(i,{code:we.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of a){const g=i.data[h];u.push({key:{status:"valid",value:h},value:l._parse(new Di(i,g,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of u){const g=await h.key,b=await h.value;l.push({key:g,value:b,alwaysSet:h.alwaysSet})}return l}).then(l=>tn.mergeObjectSync(n,l)):tn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ue.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,a;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(a=Ue.errToObj(e).message)!==null&&a!==void 0?a:u}:{message:u}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ve.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return gt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return jc(this)}partial(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Fi;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return HA(gt.objectKeys(this.shape))}}Xt.create=(r,e)=>new Xt({shape:()=>r,unknownKeys:"strip",catchall:_s.create(),typeName:Ve.ZodObject,...Je(e)}),Xt.strictCreate=(r,e)=>new Xt({shape:()=>r,unknownKeys:"strict",catchall:_s.create(),typeName:Ve.ZodObject,...Je(e)}),Xt.lazycreate=(r,e)=>new Xt({shape:r,unknownKeys:"strip",catchall:_s.create(),typeName:Ve.ZodObject,...Je(e)});class nf extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new $n(a.ctx.common.issues));return xe(t,{code:we.invalid_union,unionErrors:o}),je}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(u=>new $n(u));return xe(t,{code:we.invalid_union,unionErrors:a}),je}}get options(){return this._def.options}}nf.create=(r,e)=>new nf({options:r,typeName:Ve.ZodUnion,...Je(e)});const As=r=>r instanceof af?As(r.schema):r instanceof bi?As(r.innerType()):r instanceof cf?[r.value]:r instanceof uo?r.options:r instanceof uf?gt.objectValues(r.enum):r instanceof lf?As(r._def.innerType):r instanceof tf?[void 0]:r instanceof rf?[null]:r instanceof Fi?[void 0,...As(r.unwrap())]:r instanceof lo?[null,...As(r.unwrap())]:r instanceof Qg||r instanceof df?As(r.unwrap()):r instanceof ff?As(r._def.innerType):[];class Vd extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.object)return xe(t,{code:we.invalid_type,expected:ke.object,received:t.parsedType}),je;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(xe(t,{code:we.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),je)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=As(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Vd({typeName:Ve.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Je(n)})}}function Zg(r,e){const t=bs(r),n=bs(e);if(r===e)return{valid:!0,data:r};if(t===ke.object&&n===ke.object){const i=gt.objectKeys(e),s=gt.objectKeys(r).filter(a=>i.indexOf(a)!==-1),o={...r,...e};for(const a of s){const u=Zg(r[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(t===ke.array&&n===ke.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],a=e[s],u=Zg(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ke.date&&n===ke.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class sf extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(Kg(s)||Kg(o))return je;const a=Zg(s.value,o.value);return a.valid?((Wg(s)||Wg(o))&&t.dirty(),{status:t.value,value:a.data}):(xe(n,{code:we.invalid_intersection_types}),je)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}sf.create=(r,e,t)=>new sf({left:r,right:e,typeName:Ve.ZodIntersection,...Je(t)});class $i extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.array)return xe(n,{code:we.invalid_type,expected:ke.array,received:n.parsedType}),je;if(n.data.length<this._def.items.length)return xe(n,{code:we.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),je;!this._def.rest&&n.data.length>this._def.items.length&&(xe(n,{code:we.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,a)=>{const u=this._def.items[a]||this._def.rest;return u?u._parse(new Di(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>tn.mergeArray(t,o)):tn.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new $i({...this._def,rest:e})}}$i.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $i({items:r,typeName:Ve.ZodTuple,rest:null,...Je(e)})};class of extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.object)return xe(n,{code:we.invalid_type,expected:ke.object,received:n.parsedType}),je;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in n.data)i.push({key:s._parse(new Di(n,a,n.path,a)),value:o._parse(new Di(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?tn.mergeObjectAsync(t,i):tn.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof tt?new of({keyType:e,valueType:t,typeName:Ve.ZodRecord,...Je(n)}):new of({keyType:mi.create(),valueType:e,typeName:Ve.ZodRecord,...Je(t)})}}class jd extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.map)return xe(n,{code:we.invalid_type,expected:ke.map,received:n.parsedType}),je;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([a,u],l)=>({key:i._parse(new Di(n,a,n.path,[l,"key"])),value:s._parse(new Di(n,u,n.path,[l,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const u of o){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return je;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const u of o){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return je;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}}}}jd.create=(r,e,t)=>new jd({valueType:e,keyType:r,typeName:Ve.ZodMap,...Je(t)});class ya extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.set)return xe(n,{code:we.invalid_type,expected:ke.set,received:n.parsedType}),je;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(xe(n,{code:we.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(xe(n,{code:we.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const l=new Set;for(const h of u){if(h.status==="aborted")return je;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const a=[...n.data.values()].map((u,l)=>s._parse(new Di(n,u,n.path,l)));return n.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(e,t){return new ya({...this._def,minSize:{value:e,message:Ue.toString(t)}})}max(e,t){return new ya({...this._def,maxSize:{value:e,message:Ue.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ya.create=(r,e)=>new ya({valueType:r,minSize:null,maxSize:null,typeName:Ve.ZodSet,...Je(e)});class Kc extends tt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.function)return xe(t,{code:we.invalid_type,expected:ke.function,received:t.parsedType}),je;function n(a,u){return Fd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$d(),zc].filter(l=>!!l),issueData:{code:we.invalid_arguments,argumentsError:u}})}function i(a,u){return Fd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$d(),zc].filter(l=>!!l),issueData:{code:we.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Wc){const a=this;return dn(async function(...u){const l=new $n([]),h=await a._def.args.parseAsync(u,s).catch(w=>{throw l.addIssue(n(u,w)),l}),g=await Reflect.apply(o,this,h);return await a._def.returns._def.type.parseAsync(g,s).catch(w=>{throw l.addIssue(i(g,w)),l})})}else{const a=this;return dn(function(...u){const l=a._def.args.safeParse(u,s);if(!l.success)throw new $n([n(u,l.error)]);const h=Reflect.apply(o,this,l.data),g=a._def.returns.safeParse(h,s);if(!g.success)throw new $n([i(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Kc({...this._def,args:$i.create(e).rest(ga.create())})}returns(e){return new Kc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Kc({args:e||$i.create([]).rest(ga.create()),returns:t||ga.create(),typeName:Ve.ZodFunction,...Je(n)})}}class af extends tt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}af.create=(r,e)=>new af({getter:r,typeName:Ve.ZodLazy,...Je(e)});class cf extends tt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return xe(t,{received:t.data,code:we.invalid_literal,expected:this._def.value}),je}return{status:"valid",value:e.data}}get value(){return this._def.value}}cf.create=(r,e)=>new cf({value:r,typeName:Ve.ZodLiteral,...Je(e)});function HA(r,e){return new uo({values:r,typeName:Ve.ZodEnum,...Je(e)})}class uo extends tt{constructor(){super(...arguments),Jl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{expected:gt.joinValues(n),received:t.parsedType,code:we.invalid_type}),je}if(Hd(this,Jl)||LA(this,Jl,new Set(this._def.values)),!Hd(this,Jl).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{received:t.data,code:we.invalid_enum_value,options:n}),je}return dn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return uo.create(e,{...this._def,...t})}exclude(e,t=this._def){return uo.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Jl=new WeakMap,uo.create=HA;class uf extends tt{constructor(){super(...arguments),Xl.set(this,void 0)}_parse(e){const t=gt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ke.string&&n.parsedType!==ke.number){const i=gt.objectValues(t);return xe(n,{expected:gt.joinValues(i),received:n.parsedType,code:we.invalid_type}),je}if(Hd(this,Xl)||LA(this,Xl,new Set(gt.getValidEnumValues(this._def.values))),!Hd(this,Xl).has(e.data)){const i=gt.objectValues(t);return xe(n,{received:n.data,code:we.invalid_enum_value,options:i}),je}return dn(e.data)}get enum(){return this._def.values}}Xl=new WeakMap,uf.create=(r,e)=>new uf({values:r,typeName:Ve.ZodNativeEnum,...Je(e)});class Wc extends tt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.promise&&t.common.async===!1)return xe(t,{code:we.invalid_type,expected:ke.promise,received:t.parsedType}),je;const n=t.parsedType===ke.promise?t.data:Promise.resolve(t.data);return dn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Wc.create=(r,e)=>new Wc({type:r,typeName:Ve.ZodPromise,...Je(e)});class bi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ve.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{xe(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return je;const u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?je:u.status==="dirty"||t.value==="dirty"?Gc(u.value):u});{if(t.value==="aborted")return je;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?je:a.status==="dirty"||t.value==="dirty"?Gc(a.value):a}}if(i.type==="refinement"){const o=a=>{const u=i.refinement(a,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?je:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?je:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!da(o))return o;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>da(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:t.value,value:a})):o);gt.assertNever(i)}}bi.create=(r,e,t)=>new bi({schema:r,typeName:Ve.ZodEffects,effect:e,...Je(t)}),bi.createWithPreprocess=(r,e,t)=>new bi({schema:e,effect:{type:"preprocess",transform:r},typeName:Ve.ZodEffects,...Je(t)});class Fi extends tt{_parse(e){return this._getType(e)===ke.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fi.create=(r,e)=>new Fi({innerType:r,typeName:Ve.ZodOptional,...Je(e)});class lo extends tt{_parse(e){return this._getType(e)===ke.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}lo.create=(r,e)=>new lo({innerType:r,typeName:Ve.ZodNullable,...Je(e)});class lf extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ke.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lf.create=(r,e)=>new lf({innerType:r,typeName:Ve.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Je(e)});class ff extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yl(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $n(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $n(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ff.create=(r,e)=>new ff({innerType:r,typeName:Ve.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Je(e)});class Kd extends tt{_parse(e){if(this._getType(e)!==ke.nan){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.nan,received:n.parsedType}),je}return{status:"valid",value:e.data}}}Kd.create=r=>new Kd({typeName:Ve.ZodNaN,...Je(r)});const X4=Symbol("zod_brand");class Qg extends tt{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class hf extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?je:s.status==="dirty"?(t.dirty(),Gc(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?je:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new hf({in:e,out:t,typeName:Ve.ZodPipeline})}}class df extends tt{_parse(e){const t=this._def.innerType._parse(e),n=i=>(da(i)&&(i.value=Object.freeze(i.value)),i);return Yl(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}df.create=(r,e)=>new df({innerType:r,typeName:Ve.ZodReadonly,...Je(e)});function zA(r,e={},t){return r?Vc.create().superRefine((n,i)=>{var s,o;if(!r(n)){const a=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=a.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,l=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...l,fatal:u})}}):Vc.create()}const eM={object:Xt.lazycreate};var Ve;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Ve||(Ve={}));const tM=(r,e={message:`Input not instance of ${r.name}`})=>zA(t=>t instanceof r,e),GA=mi.create,VA=ao.create,rM=Kd.create,nM=co.create,jA=ef.create,iM=pa.create,sM=zd.create,oM=tf.create,aM=rf.create,cM=Vc.create,uM=ga.create,lM=_s.create,fM=Gd.create,hM=wi.create,dM=Xt.create,pM=Xt.strictCreate,gM=nf.create,yM=Vd.create,mM=sf.create,wM=$i.create,bM=of.create,_M=jd.create,AM=ya.create,vM=Kc.create,EM=af.create,xM=cf.create,RM=uo.create,IM=uf.create,SM=Wc.create,KA=bi.create,kM=Fi.create,TM=lo.create,OM=bi.createWithPreprocess,NM=hf.create;var er=Object.freeze({__proto__:null,defaultErrorMap:zc,setErrorMap:O4,getErrorMap:$d,makeIssue:Fd,EMPTY_PATH:N4,addIssueToContext:xe,ParseStatus:tn,INVALID:je,DIRTY:Gc,OK:dn,isAborted:Kg,isDirty:Wg,isValid:da,isAsync:Yl,get util(){return gt},get objectUtil(){return jg},ZodParsedType:ke,getParsedType:bs,ZodType:tt,datetimeRegex:FA,ZodString:mi,ZodNumber:ao,ZodBigInt:co,ZodBoolean:ef,ZodDate:pa,ZodSymbol:zd,ZodUndefined:tf,ZodNull:rf,ZodAny:Vc,ZodUnknown:ga,ZodNever:_s,ZodVoid:Gd,ZodArray:wi,ZodObject:Xt,ZodUnion:nf,ZodDiscriminatedUnion:Vd,ZodIntersection:sf,ZodTuple:$i,ZodRecord:of,ZodMap:jd,ZodSet:ya,ZodFunction:Kc,ZodLazy:af,ZodLiteral:cf,ZodEnum:uo,ZodNativeEnum:uf,ZodPromise:Wc,ZodEffects:bi,ZodTransformer:bi,ZodOptional:Fi,ZodNullable:lo,ZodDefault:lf,ZodCatch:ff,ZodNaN:Kd,BRAND:X4,ZodBranded:Qg,ZodPipeline:hf,ZodReadonly:df,custom:zA,Schema:tt,ZodSchema:tt,late:eM,get ZodFirstPartyTypeKind(){return Ve},coerce:{string:r=>mi.create({...r,coerce:!0}),number:r=>ao.create({...r,coerce:!0}),boolean:r=>ef.create({...r,coerce:!0}),bigint:r=>co.create({...r,coerce:!0}),date:r=>pa.create({...r,coerce:!0})},any:cM,array:hM,bigint:nM,boolean:jA,date:iM,discriminatedUnion:yM,effect:KA,enum:RM,function:vM,instanceof:tM,intersection:mM,lazy:EM,literal:xM,map:_M,nan:rM,nativeEnum:IM,never:lM,null:aM,nullable:TM,number:VA,object:dM,oboolean:()=>jA().optional(),onumber:()=>VA().optional(),optional:kM,ostring:()=>GA().optional(),pipeline:NM,preprocess:OM,promise:SM,record:bM,set:AM,strictObject:pM,string:GA,symbol:sM,transformer:KA,tuple:wM,undefined:oM,union:gM,unknown:uM,void:fM,NEVER:je,ZodIssueCode:we,quotelessJson:T4,ZodError:$n});const pf=Ui.getInstance(),WA=er.object({username:er.string(),address:er.string(),timestamp:er.number(),index:er.number(),signature:er.string()}),qA=er.object({id:er.number(),ref:er.string(),updater:er.string(),timestamp:er.number()}),CM=er.object({messageSender:WA.optional(),historyEntry:qA}),BM=er.object({events:er.array(er.object({type:er.string(),timestamp:er.number()})),messageEntries:er.array(er.object({index:er.number(),timestamp:er.number()}))}),PM=er.object({allTimeUsers:er.record(BM)});function ZA(r){const e=CM.safeParse(r);return e.success?r.messageSender&&!UM(r.messageSender)?(console.warn("Invalid messageSender"),!1):MM(r.historyEntry)?!0:(console.warn("Invalid historyEntry"),!1):(pf.warn(e.error.format()),!1)}function MM(r){const e=qA.safeParse(r);return e.success?!0:(pf.warn(e.error.format()),!1)}function LM(r){const e=PM.safeParse(r);return e.success?!0:(pf.warn(e.error.format()),!1)}function UM(r){const e=WA.safeParse(r);return e.success?DM(r):(pf.warn(e.error.format()),!1)}function DM(r){try{const e={username:r.username,address:r.address,timestamp:r.timestamp},t=new TextEncoder,n=en.concatBytes(t.encode(`Ethereum Signed Message:
|
|
11
|
+
32`),en.keccak256(t.encode(JSON.stringify(e))));if(new Te.Signature(r.signature).isValid(n,r.address))throw new Error("Signature verification failed!");return!0}catch(e){return pf.warn("Error in validateUserSignature",e),!1}}async function QA(r){const{condition:e,broadcast:t,maxRetries:n=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=r;return new Promise((a,u)=>{let l=0;const h=async()=>{await zg(i);for(let g=0;g<o;g++){if(await Promise.resolve(e()))return a();await zg(s)}if(++l>=n)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${l} of ${n}`),await t(),h()};console.log("Starting broadcast..."),t().then(()=>h()).catch(u)})}const ei={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"},$M=1e3,FM=new Error("request for lock canceled");var HM=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class zM{constructor(e,t=FM){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const s={resolve:n,reject:i,weight:e,priority:t},o=YA(this._queue,a=>t<=a.priority);o===-1&&e<=this._value?this._dispatchItem(s):this._queue.splice(o+1,0,s)})}runExclusive(e){return HM(this,arguments,void 0,function*(t,n=1,i=0){const[s,o]=yield this.acquire(n,i);try{return yield t(s)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),GM(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const i=n.findIndex(s=>s.priority<=e);(i===-1?n:n.splice(0,i)).forEach(s=>s.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function GM(r,e){const t=YA(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function YA(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var VM=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class jM{constructor(e){this._semaphore=new zM(1,e)}acquire(){return VM(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var JA={};(function(r){r.aliasToReal={each:"forEach",eachRight:"forEachRight",entries:"toPairs",entriesIn:"toPairsIn",extend:"assignIn",extendAll:"assignInAll",extendAllWith:"assignInAllWith",extendWith:"assignInWith",first:"head",conforms:"conformsTo",matches:"isMatch",property:"get",__:"placeholder",F:"stubFalse",T:"stubTrue",all:"every",allPass:"overEvery",always:"constant",any:"some",anyPass:"overSome",apply:"spread",assoc:"set",assocPath:"set",complement:"negate",compose:"flowRight",contains:"includes",dissoc:"unset",dissocPath:"unset",dropLast:"dropRight",dropLastWhile:"dropRightWhile",equals:"isEqual",identical:"eq",indexBy:"keyBy",init:"initial",invertObj:"invert",juxt:"over",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",paths:"at",pickAll:"pick",pipe:"flow",pluck:"map",prop:"get",propEq:"matchesProperty",propOr:"getOr",props:"at",symmetricDifference:"xor",symmetricDifferenceBy:"xorBy",symmetricDifferenceWith:"xorWith",takeLast:"takeRight",takeLastWhile:"takeRightWhile",unapply:"rest",unnest:"flatten",useWith:"overArgs",where:"conformsTo",whereEq:"isMatch",zipObj:"zipObject"},r.aryMethod={1:["assignAll","assignInAll","attempt","castArray","ceil","create","curry","curryRight","defaultsAll","defaultsDeepAll","floor","flow","flowRight","fromPairs","invert","iteratee","memoize","method","mergeAll","methodOf","mixin","nthArg","over","overEvery","overSome","rest","reverse","round","runInContext","spread","template","trim","trimEnd","trimStart","uniqueId","words","zipAll"],2:["add","after","ary","assign","assignAllWith","assignIn","assignInAllWith","at","before","bind","bindAll","bindKey","chunk","cloneDeepWith","cloneWith","concat","conformsTo","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","defaultTo","delay","difference","divide","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","flatMapDeep","flattenDepth","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","meanBy","merge","mergeAllWith","minBy","multiply","nth","omit","omitBy","overArgs","pad","padEnd","padStart","parseInt","partial","partialRight","partition","pick","pickBy","propertyOf","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","restFrom","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","spreadFrom","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","trimChars","trimCharsEnd","trimCharsStart","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"],3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","findFrom","findIndexFrom","findLastFrom","findLastIndexFrom","getOr","includesFrom","indexOfFrom","inRange","intersectionBy","intersectionWith","invokeArgs","invokeArgsMap","isEqualWith","isMatchWith","flatMapDepth","lastIndexOfFrom","mergeWith","orderBy","padChars","padCharsEnd","padCharsStart","pullAllBy","pullAllWith","rangeStep","rangeStepRight","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","update","xorBy","xorWith","zipWith"],4:["fill","setWith","updateWith"]},r.aryRearg={2:[1,0],3:[2,0,1],4:[3,2,0,1]},r.iterateeAry={dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findFrom:1,findIndex:1,findIndexFrom:1,findKey:1,findLast:1,findLastFrom:1,findLastIndex:1,findLastIndexFrom:1,findLastKey:1,flatMap:1,flatMapDeep:1,flatMapDepth:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,transform:2},r.iterateeRearg={mapKeys:[1],reduceRight:[1,0]},r.methodRearg={assignInAllWith:[1,0],assignInWith:[1,2,0],assignAllWith:[1,0],assignWith:[1,2,0],differenceBy:[1,2,0],differenceWith:[1,2,0],getOr:[2,1,0],intersectionBy:[1,2,0],intersectionWith:[1,2,0],isEqualWith:[1,2,0],isMatchWith:[2,1,0],mergeAllWith:[1,0],mergeWith:[1,2,0],padChars:[2,1,0],padCharsEnd:[2,1,0],padCharsStart:[2,1,0],pullAllBy:[2,1,0],pullAllWith:[2,1,0],rangeStep:[1,2,0],rangeStepRight:[1,2,0],setWith:[3,1,2,0],sortedIndexBy:[2,1,0],sortedLastIndexBy:[2,1,0],unionBy:[1,2,0],unionWith:[1,2,0],updateWith:[3,1,2,0],xorBy:[1,2,0],xorWith:[1,2,0],zipWith:[1,2,0]},r.methodSpread={assignAll:{start:0},assignAllWith:{start:0},assignInAll:{start:0},assignInAllWith:{start:0},defaultsAll:{start:0},defaultsDeepAll:{start:0},invokeArgs:{start:2},invokeArgsMap:{start:2},mergeAll:{start:0},mergeAllWith:{start:0},partial:{start:1},partialRight:{start:1},without:{start:1},zipAll:{start:0}},r.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAllWith:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignAll:!0,assignAllWith:!0,assignIn:!0,assignInAll:!0,assignInAllWith:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsAll:!0,defaultsDeep:!0,defaultsDeepAll:!0,merge:!0,mergeAll:!0,mergeAllWith:!0,mergeWith:!0},set:{set:!0,setWith:!0,unset:!0,update:!0,updateWith:!0}},r.realToAlias=function(){var e=Object.prototype.hasOwnProperty,t=r.aliasToReal,n={};for(var i in t){var s=t[i];e.call(n,s)?n[s].push(i):n[s]=[i]}return n}(),r.remap={assignAll:"assign",assignAllWith:"assignWith",assignInAll:"assignIn",assignInAllWith:"assignInWith",curryN:"curry",curryRightN:"curryRight",defaultsAll:"defaults",defaultsDeepAll:"defaultsDeep",findFrom:"find",findIndexFrom:"findIndex",findLastFrom:"findLast",findLastIndexFrom:"findLastIndex",getOr:"get",includesFrom:"includes",indexOfFrom:"indexOf",invokeArgs:"invoke",invokeArgsMap:"invokeMap",lastIndexOfFrom:"lastIndexOf",mergeAll:"merge",mergeAllWith:"mergeWith",padChars:"pad",padCharsEnd:"padEnd",padCharsStart:"padStart",propertyOf:"get",rangeStep:"range",rangeStepRight:"rangeRight",restFrom:"rest",spreadFrom:"spread",trimChars:"trim",trimCharsEnd:"trimEnd",trimCharsStart:"trimStart",zipAll:"zip"},r.skipFixed={castArray:!0,flow:!0,flowRight:!0,iteratee:!0,mixin:!0,rearg:!0,runInContext:!0},r.skipRearg={add:!0,assign:!0,assignIn:!0,bind:!0,bindKey:!0,concat:!0,difference:!0,divide:!0,eq:!0,gt:!0,gte:!0,isEqual:!0,lt:!0,lte:!0,matchesProperty:!0,merge:!0,multiply:!0,overArgs:!0,partial:!0,partialRight:!0,propertyOf:!0,random:!0,range:!0,rangeRight:!0,subtract:!0,zip:!0,zipObject:!0,zipObjectDeep:!0}})(JA);var Yg,XA;function ev(){return XA||(XA=1,Yg={}),Yg}var Cr=JA,KM=ev(),tv=Array.prototype.push;function WM(r,e){return e==2?function(t,n){return r.apply(void 0,arguments)}:function(t){return r.apply(void 0,arguments)}}function Jg(r,e){return e==2?function(t,n){return r(t,n)}:function(t){return r(t)}}function rv(r){for(var e=r?r.length:0,t=Array(e);e--;)t[e]=r[e];return t}function qM(r){return function(e){return r({},e)}}function ZM(r,e){return function(){for(var t=arguments.length,n=t-1,i=Array(t);t--;)i[t]=arguments[t];var s=i[e],o=i.slice(0,e);return s&&tv.apply(o,s),e!=n&&tv.apply(o,i.slice(e+1)),r.apply(this,o)}}function Xg(r,e){return function(){var t=arguments.length;if(t){for(var n=Array(t);t--;)n[t]=arguments[t];var i=n[0]=e.apply(void 0,n);return r.apply(void 0,n),i}}}function ey(r,e,t,n){var i=typeof e=="function",s=e===Object(e);if(s&&(n=t,t=e,e=void 0),t==null)throw new TypeError;n||(n={});var o={cap:"cap"in n?n.cap:!0,curry:"curry"in n?n.curry:!0,fixed:"fixed"in n?n.fixed:!0,immutable:"immutable"in n?n.immutable:!0,rearg:"rearg"in n?n.rearg:!0},a=i?t:KM,u="curry"in n&&n.curry,l="fixed"in n&&n.fixed,h="rearg"in n&&n.rearg,g=i?t.runInContext():void 0,b=i?t:{ary:r.ary,assign:r.assign,clone:r.clone,curry:r.curry,forEach:r.forEach,isArray:r.isArray,isError:r.isError,isFunction:r.isFunction,isWeakMap:r.isWeakMap,iteratee:r.iteratee,keys:r.keys,rearg:r.rearg,toInteger:r.toInteger,toPath:r.toPath},w=b.ary,I=b.assign,S=b.clone,x=b.curry,C=b.forEach,H=b.isArray,D=b.isError,z=b.isFunction,W=b.isWeakMap,Z=b.keys,V=b.rearg,K=b.toInteger,oe=b.toPath,ce=Z(Cr.aryMethod),ie={castArray:function(te){return function(){var re=arguments[0];return H(re)?te(rv(re)):te.apply(void 0,arguments)}},iteratee:function(te){return function(){var re=arguments[0],he=arguments[1],ye=te(re,he),be=ye.length;return o.cap&&typeof he=="number"?(he=he>2?he-2:1,be&&be<=he?ye:Jg(ye,he)):ye}},mixin:function(te){return function(re){var he=this;if(!z(he))return te(he,Object(re));var ye=[];return C(Z(re),function(be){z(re[be])&&ye.push([be,he.prototype[be]])}),te(he,Object(re)),C(ye,function(be){var Ke=be[1];z(Ke)?he.prototype[be[0]]=Ke:delete he.prototype[be[0]]}),he}},nthArg:function(te){return function(re){var he=re<0?1:K(re)+1;return x(te(re),he)}},rearg:function(te){return function(re,he){var ye=he?he.length:0;return x(te(re,he),ye)}},runInContext:function(te){return function(re){return ey(r,te(re),n)}}};function ue(te,re){if(o.cap){var he=Cr.iterateeRearg[te];if(he)return G(re,he);var ye=!i&&Cr.iterateeAry[te];if(ye)return M(re,ye)}return re}function B(te,re,he){return u||o.curry&&he>1?x(re,he):re}function p(te,re,he){if(o.fixed&&(l||!Cr.skipFixed[te])){var ye=Cr.methodSpread[te],be=ye&&ye.start;return be===void 0?w(re,he):ZM(re,be)}return re}function m(te,re,he){return o.rearg&&he>1&&(h||!Cr.skipRearg[te])?V(re,Cr.methodRearg[te]||Cr.aryRearg[he]):re}function E(te,re){re=oe(re);for(var he=-1,ye=re.length,be=ye-1,Ke=S(Object(te)),Fe=Ke;Fe!=null&&++he<ye;){var Be=re[he],et=Fe[Be];et!=null&&!(z(et)||D(et)||W(et))&&(Fe[Be]=S(he==be?et:Object(et))),Fe=Fe[Be]}return Ke}function k(te){return U.runInContext.convert(te)(void 0)}function O(te,re){var he=Cr.aliasToReal[te]||te,ye=Cr.remap[he]||he,be=n;return function(Ke){var Fe=i?g:b,Be=i?g[ye]:re,et=I(I({},be),Ke);return ey(Fe,he,Be,et)}}function M(te,re){return P(te,function(he){return typeof he=="function"?Jg(he,re):he})}function G(te,re){return P(te,function(he){var ye=re.length;return WM(V(Jg(he,ye),re),ye)})}function P(te,re){return function(){var he=arguments.length;if(!he)return te();for(var ye=Array(he);he--;)ye[he]=arguments[he];var be=o.rearg?0:he-1;return ye[be]=re(ye[be]),te.apply(void 0,ye)}}function A(te,re,he){var ye,be=Cr.aliasToReal[te]||te,Ke=re,Fe=ie[be];return Fe?Ke=Fe(re):o.immutable&&(Cr.mutate.array[be]?Ke=Xg(re,rv):Cr.mutate.object[be]?Ke=Xg(re,qM(re)):Cr.mutate.set[be]&&(Ke=Xg(re,E))),C(ce,function(Be){return C(Cr.aryMethod[Be],function(et){if(be==et){var Qe=Cr.methodSpread[be],ot=Qe&&Qe.afterRearg;return ye=ot?p(be,m(be,Ke,Be),Be):m(be,p(be,Ke,Be),Be),ye=ue(be,ye),ye=B(be,ye,Be),!1}}),!ye}),ye||(ye=Ke),ye==re&&(ye=u?x(ye,1):function(){return re.apply(this,arguments)}),ye.convert=O(be,re),ye.placeholder=re.placeholder=he,ye}if(!s)return A(e,t,a);var U=t,le=[];return C(ce,function(te){C(Cr.aryMethod[te],function(re){var he=U[Cr.remap[re]||re];he&&le.push([re,A(re,he,U)])})}),C(Z(U),function(te){var re=U[te];if(typeof re=="function"){for(var he=le.length;he--;)if(le[he][0]==te)return;re.convert=O(te,re),le.push([te,re])}}),C(le,function(te){U[te[0]]=te[1]}),U.convert=k,U.placeholder=U,C(Z(U),function(te){C(Cr.realToAlias[te]||[],function(re){U[re]=U[te]})}),U}var QM=ey,ty,nv;function Wd(){if(nv)return ty;nv=1;function r(e){return e}return ty=r,ty}var iv=mA,YM=iv&&new iv,sv=YM,JM=Wd(),ov=sv,XM=ov?function(r,e){return ov.set(r,e),r}:JM,av=XM,ry,cv;function qd(){if(cv)return ry;cv=1;var r=yi,e=Object.create,t=function(){function n(){}return function(i){if(!r(i))return{};if(e)return e(i);n.prototype=i;var s=new n;return n.prototype=void 0,s}}();return ry=t,ry}var eL=qd(),tL=yi;function rL(r){return function(){var e=arguments;switch(e.length){case 0:return new r;case 1:return new r(e[0]);case 2:return new r(e[0],e[1]);case 3:return new r(e[0],e[1],e[2]);case 4:return new r(e[0],e[1],e[2],e[3]);case 5:return new r(e[0],e[1],e[2],e[3],e[4]);case 6:return new r(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new r(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var t=eL(r.prototype),n=r.apply(t,e);return tL(n)?n:t}}var Zd=rL,nL=Zd,iL=Rn,sL=1;function oL(r,e,t){var n=e&sL,i=nL(r);function s(){var o=this&&this!==iL&&this instanceof s?i:r;return o.apply(n?t:this,arguments)}return s}var aL=oL,ny,uv;function iy(){if(uv)return ny;uv=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return ny=r,ny}var cL=Math.max;function uL(r,e,t,n){for(var i=-1,s=r.length,o=t.length,a=-1,u=e.length,l=cL(s-o,0),h=Array(u+l),g=!n;++a<u;)h[a]=e[a];for(;++i<o;)(g||i<s)&&(h[t[i]]=r[i]);for(;l--;)h[a++]=r[i++];return h}var lv=uL,lL=Math.max;function fL(r,e,t,n){for(var i=-1,s=r.length,o=-1,a=t.length,u=-1,l=e.length,h=lL(s-a,0),g=Array(h+l),b=!n;++i<h;)g[i]=r[i];for(var w=i;++u<l;)g[w+u]=e[u];for(;++o<a;)(b||i<s)&&(g[w+t[o]]=r[i++]);return g}var fv=fL;function hL(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&++n;return n}var dL=hL;function pL(){}var sy=pL,gL=qd(),yL=sy,mL=4294967295;function Qd(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=mL,this.__views__=[]}Qd.prototype=gL(yL.prototype),Qd.prototype.constructor=Qd;var oy=Qd;function wL(){}var bL=wL,hv=sv,_L=bL,AL=hv?function(r){return hv.get(r)}:_L,dv=AL,vL={},EL=vL,pv=EL,xL=Object.prototype,RL=xL.hasOwnProperty;function IL(r){for(var e=r.name+"",t=pv[e],n=RL.call(pv,e)?t.length:0;n--;){var i=t[n],s=i.func;if(s==null||s==r)return i.name}return e}var SL=IL,kL=qd(),TL=sy;function Yd(r,e){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}Yd.prototype=kL(TL.prototype),Yd.prototype.constructor=Yd;var gv=Yd;function OL(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var gf=OL,NL=oy,CL=gv,BL=gf;function PL(r){if(r instanceof NL)return r.clone();var e=new CL(r.__wrapped__,r.__chain__);return e.__actions__=BL(r.__actions__),e.__index__=r.__index__,e.__values__=r.__values__,e}var ML=PL,LL=oy,yv=gv,UL=sy,DL=In,$L=Xn,FL=ML,HL=Object.prototype,zL=HL.hasOwnProperty;function Jd(r){if($L(r)&&!DL(r)&&!(r instanceof LL)){if(r instanceof yv)return r;if(zL.call(r,"__wrapped__"))return FL(r)}return new yv(r)}Jd.prototype=UL.prototype,Jd.prototype.constructor=Jd;var GL=Jd,VL=oy,jL=dv,KL=SL,WL=GL;function qL(r){var e=KL(r),t=WL[e];if(typeof t!="function"||!(e in VL.prototype))return!1;if(r===t)return!0;var n=jL(t);return!!n&&r===n[0]}var ZL=qL,ay,mv;function wv(){if(mv)return ay;mv=1;var r=800,e=16,t=Date.now;function n(i){var s=0,o=0;return function(){var a=t(),u=e-(a-o);if(o=a,u>0){if(++s>=r)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return ay=n,ay}var QL=av,YL=wv(),JL=YL(QL),bv=JL,XL=/\{\n\/\* \[wrapped with (.+)\] \*/,eU=/,? & /;function tU(r){var e=r.match(XL);return e?e[1].split(eU):[]}var rU=tU,nU=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function iU(r,e){var t=e.length;if(!t)return r;var n=t-1;return e[n]=(t>1?"& ":"")+e[n],e=e.join(t>2?", ":" "),r.replace(nU,`{
|
|
12
|
+
/* [wrapped with `+e+`] */
|
|
13
|
+
`)}var sU=iU,cy,_v;function oU(){if(_v)return cy;_v=1;function r(e){return function(){return e}}return cy=r,cy}var uy,Av;function vv(){if(Av)return uy;Av=1;var r=fa,e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return uy=e,uy}var ly,Ev;function aU(){if(Ev)return ly;Ev=1;var r=oU(),e=vv(),t=Wd(),n=e?function(i,s){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(s),writable:!0})}:t;return ly=n,ly}var fy,xv;function hy(){if(xv)return fy;xv=1;var r=aU(),e=wv(),t=e(r);return fy=t,fy}function cU(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var dy=cU;function uU(r,e,t,n){for(var i=r.length,s=t+(n?1:-1);n?s--:++s<i;)if(e(r[s],s,r))return s;return-1}var lU=uU;function fU(r){return r!==r}var hU=fU;function dU(r,e,t){for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}var pU=dU,gU=lU,yU=hU,mU=pU;function wU(r,e,t){return e===e?mU(r,e,t):gU(r,yU,t)}var bU=wU,_U=bU;function AU(r,e){var t=r==null?0:r.length;return!!t&&_U(r,e,0)>-1}var vU=AU,EU=dy,xU=vU,RU=1,IU=2,SU=8,kU=16,TU=32,OU=64,NU=128,CU=256,BU=512,PU=[["ary",NU],["bind",RU],["bindKey",IU],["curry",SU],["curryRight",kU],["flip",BU],["partial",TU],["partialRight",OU],["rearg",CU]];function MU(r,e){return EU(PU,function(t){var n="_."+t[0];e&t[1]&&!xU(r,n)&&r.push(n)}),r.sort()}var LU=MU,UU=rU,DU=sU,$U=hy(),FU=LU;function HU(r,e,t){var n=e+"";return $U(r,DU(n,FU(UU(n),t)))}var Rv=HU,zU=ZL,GU=bv,VU=Rv,jU=1,KU=2,WU=4,qU=8,Iv=32,Sv=64;function ZU(r,e,t,n,i,s,o,a,u,l){var h=e&qU,g=h?o:void 0,b=h?void 0:o,w=h?s:void 0,I=h?void 0:s;e|=h?Iv:Sv,e&=~(h?Sv:Iv),e&WU||(e&=~(jU|KU));var S=[r,e,i,w,g,I,b,a,u,l],x=t.apply(void 0,S);return zU(r)&&GU(x,S),x.placeholder=n,VU(x,r,e)}var kv=ZU;function QU(r){var e=r;return e.placeholder}var Tv=QU,YU=gf,JU=Bd,XU=Math.min;function eD(r,e){for(var t=r.length,n=XU(e.length,t),i=YU(r);n--;){var s=e[n];r[n]=JU(s,t)?i[s]:void 0}return r}var tD=eD,Ov="__lodash_placeholder__";function rD(r,e){for(var t=-1,n=r.length,i=0,s=[];++t<n;){var o=r[t];(o===e||o===Ov)&&(r[t]=Ov,s[i++]=t)}return s}var py=rD,nD=lv,iD=fv,sD=dL,Nv=Zd,oD=kv,aD=Tv,cD=tD,uD=py,lD=Rn,fD=1,hD=2,dD=8,pD=16,gD=128,yD=512;function Cv(r,e,t,n,i,s,o,a,u,l){var h=e&gD,g=e&fD,b=e&hD,w=e&(dD|pD),I=e&yD,S=b?void 0:Nv(r);function x(){for(var C=arguments.length,H=Array(C),D=C;D--;)H[D]=arguments[D];if(w)var z=aD(x),W=sD(H,z);if(n&&(H=nD(H,n,i,w)),s&&(H=iD(H,s,o,w)),C-=W,w&&C<l){var Z=uD(H,z);return oD(r,e,Cv,x.placeholder,t,H,Z,a,u,l-C)}var V=g?t:this,K=b?V[r]:r;return C=H.length,a?H=cD(H,a):I&&C>1&&H.reverse(),h&&u<C&&(H.length=u),this&&this!==lD&&this instanceof x&&(K=S||Nv(K)),K.apply(V,H)}return x}var Bv=Cv,mD=iy(),wD=Zd,bD=Bv,_D=kv,AD=Tv,vD=py,ED=Rn;function xD(r,e,t){var n=wD(r);function i(){for(var s=arguments.length,o=Array(s),a=s,u=AD(i);a--;)o[a]=arguments[a];var l=s<3&&o[0]!==u&&o[s-1]!==u?[]:vD(o,u);if(s-=l.length,s<t)return _D(r,e,bD,i.placeholder,void 0,o,l,void 0,void 0,t-s);var h=this&&this!==ED&&this instanceof i?n:r;return mD(h,this,o)}return i}var RD=xD,ID=iy(),SD=Zd,kD=Rn,TD=1;function OD(r,e,t,n){var i=e&TD,s=SD(r);function o(){for(var a=-1,u=arguments.length,l=-1,h=n.length,g=Array(h+u),b=this&&this!==kD&&this instanceof o?s:r;++l<h;)g[l]=n[l];for(;u--;)g[l++]=arguments[++a];return ID(b,i?t:this,g)}return o}var ND=OD,CD=lv,BD=fv,Pv=py,Mv="__lodash_placeholder__",gy=1,PD=2,MD=4,Lv=8,yf=128,Uv=256,LD=Math.min;function UD(r,e){var t=r[1],n=e[1],i=t|n,s=i<(gy|PD|yf),o=n==yf&&t==Lv||n==yf&&t==Uv&&r[7].length<=e[8]||n==(yf|Uv)&&e[7].length<=e[8]&&t==Lv;if(!(s||o))return r;n&gy&&(r[2]=e[2],i|=t&gy?0:MD);var a=e[3];if(a){var u=r[3];r[3]=u?CD(u,a,e[4]):a,r[4]=u?Pv(r[3],Mv):e[4]}return a=e[5],a&&(u=r[5],r[5]=u?BD(u,a,e[6]):a,r[6]=u?Pv(r[5],Mv):e[6]),a=e[7],a&&(r[7]=a),n&yf&&(r[8]=r[8]==null?e[8]:LD(r[8],e[8])),r[9]==null&&(r[9]=e[9]),r[0]=e[0],r[1]=i,r}var DD=UD,$D=/\s/;function FD(r){for(var e=r.length;e--&&$D.test(r.charAt(e)););return e}var HD=FD,zD=HD,GD=/^\s+/;function VD(r){return r&&r.slice(0,zD(r)+1).replace(GD,"")}var jD=VD,KD=la,WD=Xn,qD="[object Symbol]";function ZD(r){return typeof r=="symbol"||WD(r)&&KD(r)==qD}var mf=ZD,QD=jD,Dv=yi,YD=mf,$v=NaN,JD=/^[-+]0x[0-9a-f]+$/i,XD=/^0b[01]+$/i,e$=/^0o[0-7]+$/i,t$=parseInt;function r$(r){if(typeof r=="number")return r;if(YD(r))return $v;if(Dv(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Dv(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=QD(r);var t=XD.test(r);return t||e$.test(r)?t$(r.slice(2),t?2:8):JD.test(r)?$v:+r}var n$=r$,i$=n$,Fv=1/0,s$=17976931348623157e292;function o$(r){if(!r)return r===0?r:0;if(r=i$(r),r===Fv||r===-Fv){var e=r<0?-1:1;return e*s$}return r===r?r:0}var a$=o$,c$=a$;function u$(r){var e=c$(r),t=e%1;return e===e?t?e-t:e:0}var Hv=u$,l$=av,f$=aL,h$=RD,d$=Bv,p$=ND,g$=dv,y$=DD,m$=bv,w$=Rv,zv=Hv,b$="Expected a function",Gv=1,_$=2,yy=8,my=16,wy=32,Vv=64,jv=Math.max;function A$(r,e,t,n,i,s,o,a){var u=e&_$;if(!u&&typeof r!="function")throw new TypeError(b$);var l=n?n.length:0;if(l||(e&=~(wy|Vv),n=i=void 0),o=o===void 0?o:jv(zv(o),0),a=a===void 0?a:zv(a),l-=i?i.length:0,e&Vv){var h=n,g=i;n=i=void 0}var b=u?void 0:g$(r),w=[r,e,t,n,i,h,g,s,o,a];if(b&&y$(w,b),r=w[0],e=w[1],t=w[2],n=w[3],i=w[4],a=w[9]=w[9]===void 0?u?0:r.length:jv(w[9]-l,0),!a&&e&(yy|my)&&(e&=~(yy|my)),!e||e==Gv)var I=f$(r,e,t);else e==yy||e==my?I=h$(r,e,a):(e==wy||e==(Gv|wy))&&!i.length?I=p$(r,e,t,n):I=d$.apply(void 0,w);var S=b?l$:m$;return w$(S(I,w),r,e)}var by=A$,v$=by,E$=128;function x$(r,e,t){return e=t?void 0:e,e=r&&e==null?r.length:e,v$(r,E$,void 0,void 0,void 0,void 0,e)}var R$=x$,_y,Kv;function Ay(){if(Kv)return _y;Kv=1;var r=vv();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return _y=e,_y}var I$=Ay(),S$=ql,k$=Object.prototype,T$=k$.hasOwnProperty;function O$(r,e,t){var n=r[e];(!(T$.call(r,e)&&S$(n,t))||t===void 0&&!(e in r))&&I$(r,e,t)}var Wv=O$,N$=Wv,C$=Ay();function B$(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],u=n?n(t[a],r[a],a,t,r):void 0;u===void 0&&(u=r[a]),i?C$(t,a,u):N$(t,a,u)}return t}var wf=B$,P$=wf,M$=Ld;function L$(r,e){return r&&P$(e,M$(e),r)}var qv=L$,vy,Zv;function U$(){if(Zv)return vy;Zv=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return vy=r,vy}var Ey,Qv;function D$(){if(Qv)return Ey;Qv=1;var r=yi,e=Bg,t=U$(),n=Object.prototype,i=n.hasOwnProperty;function s(o){if(!r(o))return t(o);var a=e(o),u=[];for(var l in o)l=="constructor"&&(a||!i.call(o,l))||u.push(l);return u}return Ey=s,Ey}var xy,Yv;function bf(){if(Yv)return xy;Yv=1;var r=hA,e=D$(),t=Md;function n(i){return t(i)?r(i,!0):e(i)}return xy=n,xy}var $$=wf,F$=bf();function H$(r,e){return r&&$$(e,F$(e),r)}var z$=H$,_f={exports:{}};_f.exports;var Jv;function Xv(){return Jv||(Jv=1,function(r,e){var t=Rn,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function u(l,h){if(h)return l.slice();var g=l.length,b=a?a(g):new l.constructor(g);return l.copy(b),b}r.exports=u}(_f,_f.exports)),_f.exports}var G$=wf,V$=kg;function j$(r,e){return G$(r,V$(r),e)}var K$=j$,W$=dA,q$=W$(Object.getPrototypeOf,Object),Ry=q$,Z$=Sg,Q$=Ry,Y$=kg,J$=oA,X$=Object.getOwnPropertySymbols,eF=X$?function(r){for(var e=[];r;)Z$(e,Y$(r)),r=Q$(r);return e}:J$,eE=eF,tF=wf,rF=eE;function nF(r,e){return tF(r,rF(r),e)}var iF=nF,sF=sA,oF=eE,aF=bf();function cF(r){return sF(r,aF,oF)}var uF=cF,lF=Object.prototype,fF=lF.hasOwnProperty;function hF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&fF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var dF=hF,Iy,tE;function Sy(){if(tE)return Iy;tE=1;var r=tA;function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return Iy=e,Iy}var pF=Sy();function gF(r,e){var t=e?pF(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var yF=gF,mF=/\w*$/;function wF(r){var e=new r.constructor(r.source,mF.exec(r));return e.lastIndex=r.lastIndex,e}var bF=wF,rE=Uc,nE=rE?rE.prototype:void 0,iE=nE?nE.valueOf:void 0;function _F(r){return iE?Object(iE.call(r)):{}}var AF=_F,ky,sE;function oE(){if(sE)return ky;sE=1;var r=Sy();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return ky=e,ky}var vF=Sy(),EF=yF,xF=bF,RF=AF,IF=oE(),SF="[object Boolean]",kF="[object Date]",TF="[object Map]",OF="[object Number]",NF="[object RegExp]",CF="[object Set]",BF="[object String]",PF="[object Symbol]",MF="[object ArrayBuffer]",LF="[object DataView]",UF="[object Float32Array]",DF="[object Float64Array]",$F="[object Int8Array]",FF="[object Int16Array]",HF="[object Int32Array]",zF="[object Uint8Array]",GF="[object Uint8ClampedArray]",VF="[object Uint16Array]",jF="[object Uint32Array]";function KF(r,e,t){var n=r.constructor;switch(e){case MF:return vF(r);case SF:case kF:return new n(+r);case LF:return EF(r,t);case UF:case DF:case $F:case FF:case HF:case zF:case GF:case VF:case jF:return IF(r,t);case TF:return new n;case OF:case BF:return new n(r);case NF:return xF(r);case CF:return new n;case PF:return RF(r)}}var WF=KF,Ty,aE;function cE(){if(aE)return Ty;aE=1;var r=qd(),e=Ry,t=Bg;function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return Ty=n,Ty}var qF=Ql,ZF=Xn,QF="[object Map]";function YF(r){return ZF(r)&&qF(r)==QF}var JF=YF,XF=JF,e9=Og,uE=Ng,lE=uE&&uE.isMap,t9=lE?e9(lE):XF,r9=t9,n9=Ql,i9=Xn,s9="[object Set]";function o9(r){return i9(r)&&n9(r)==s9}var a9=o9,c9=a9,u9=Og,fE=Ng,hE=fE&&fE.isSet,l9=hE?u9(hE):c9,f9=l9,h9=kd,d9=dy,p9=Wv,g9=qv,y9=z$,m9=Xv(),w9=gf,b9=K$,_9=iF,A9=gA,v9=uF,E9=Ql,x9=dF,R9=WF,I9=cE(),S9=In,k9=Cd,T9=r9,O9=yi,N9=f9,C9=Ld,B9=bf(),P9=1,M9=2,L9=4,dE="[object Arguments]",U9="[object Array]",D9="[object Boolean]",$9="[object Date]",F9="[object Error]",pE="[object Function]",H9="[object GeneratorFunction]",z9="[object Map]",G9="[object Number]",gE="[object Object]",V9="[object RegExp]",j9="[object Set]",K9="[object String]",W9="[object Symbol]",q9="[object WeakMap]",Z9="[object ArrayBuffer]",Q9="[object DataView]",Y9="[object Float32Array]",J9="[object Float64Array]",X9="[object Int8Array]",eH="[object Int16Array]",tH="[object Int32Array]",rH="[object Uint8Array]",nH="[object Uint8ClampedArray]",iH="[object Uint16Array]",sH="[object Uint32Array]",Ft={};Ft[dE]=Ft[U9]=Ft[Z9]=Ft[Q9]=Ft[D9]=Ft[$9]=Ft[Y9]=Ft[J9]=Ft[X9]=Ft[eH]=Ft[tH]=Ft[z9]=Ft[G9]=Ft[gE]=Ft[V9]=Ft[j9]=Ft[K9]=Ft[W9]=Ft[rH]=Ft[nH]=Ft[iH]=Ft[sH]=!0,Ft[F9]=Ft[pE]=Ft[q9]=!1;function Xd(r,e,t,n,i,s){var o,a=e&P9,u=e&M9,l=e&L9;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!O9(r))return r;var h=S9(r);if(h){if(o=x9(r),!a)return w9(r,o)}else{var g=E9(r),b=g==pE||g==H9;if(k9(r))return m9(r,a);if(g==gE||g==dE||b&&!i){if(o=u||b?{}:I9(r),!a)return u?_9(r,y9(o,r)):b9(r,g9(o,r))}else{if(!Ft[g])return i?r:{};o=R9(r,g,a)}}s||(s=new h9);var w=s.get(r);if(w)return w;s.set(r,o),N9(r)?r.forEach(function(x){o.add(Xd(x,e,t,x,r,s))}):T9(r)&&r.forEach(function(x,C){o.set(C,Xd(x,e,t,C,r,s))});var I=l?u?v9:A9:u?B9:C9,S=h?void 0:I(r);return d9(S||r,function(x,C){S&&(C=x,x=r[C]),p9(o,C,Xd(x,e,t,C,r,s))}),o}var yE=Xd,oH=yE,aH=4;function cH(r){return oH(r,aH)}var uH=cH,lH=by,fH=8;function Oy(r,e,t){e=t?void 0:e;var n=lH(r,fH,void 0,void 0,void 0,void 0,void 0,e);return n.placeholder=Oy.placeholder,n}Oy.placeholder={};var hH=Oy,dH=la,pH=Ry,gH=Xn,yH="[object Object]",mH=Function.prototype,wH=Object.prototype,mE=mH.toString,bH=wH.hasOwnProperty,_H=mE.call(Object);function AH(r){if(!gH(r)||dH(r)!=yH)return!1;var e=pH(r);if(e===null)return!0;var t=bH.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&mE.call(t)==_H}var wE=AH,vH=la,EH=Xn,xH=wE,RH="[object DOMException]",IH="[object Error]";function SH(r){if(!EH(r))return!1;var e=vH(r);return e==IH||e==RH||typeof r.message=="string"&&typeof r.name=="string"&&!xH(r)}var kH=SH,TH=Ql,OH=Xn,NH="[object WeakMap]";function CH(r){return OH(r)&&TH(r)==NH}var BH=CH,PH=kd,MH=Fg,LH=1,UH=2;function DH(r,e,t,n){var i=t.length,s=i,o=!n;if(r==null)return!s;for(r=Object(r);i--;){var a=t[i];if(o&&a[2]?a[1]!==r[a[0]]:!(a[0]in r))return!1}for(;++i<s;){a=t[i];var u=a[0],l=r[u],h=a[1];if(o&&a[2]){if(l===void 0&&!(u in r))return!1}else{var g=new PH;if(n)var b=n(l,h,u,r,e,g);if(!(b===void 0?MH(h,l,LH|UH,n,g):b))return!1}}return!0}var $H=DH,FH=yi;function HH(r){return r===r&&!FH(r)}var bE=HH,zH=bE,GH=Ld;function VH(r){for(var e=GH(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,zH(i)]}return e}var jH=VH;function KH(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var _E=KH,WH=$H,qH=jH,ZH=_E;function QH(r){var e=qH(r);return e.length==1&&e[0][2]?ZH(e[0][0],e[0][1]):function(t){return t===r||WH(t,r,e)}}var YH=QH,JH=In,XH=mf,e7=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t7=/^\w*$/;function r7(r,e){if(JH(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||XH(r)?!0:t7.test(r)||!e7.test(r)||e!=null&&r in Object(e)}var Ny=r7,AE=Rg,n7="Expected a function";function Cy(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(n7);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(Cy.Cache||AE),t}Cy.Cache=AE;var i7=Cy,s7=i7,o7=500;function a7(r){var e=s7(r,function(n){return t.size===o7&&t.clear(),n}),t=e.cache;return e}var c7=a7,u7=c7,l7=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,f7=/\\(\\)?/g,h7=u7(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(l7,function(t,n,i,s){e.push(i?s.replace(f7,"$1"):n||t)}),e}),vE=h7;function d7(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var EE=d7,xE=Uc,p7=EE,g7=In,y7=mf,m7=1/0,RE=xE?xE.prototype:void 0,IE=RE?RE.toString:void 0;function SE(r){if(typeof r=="string")return r;if(g7(r))return p7(r,SE)+"";if(y7(r))return IE?IE.call(r):"";var e=r+"";return e=="0"&&1/r==-m7?"-0":e}var w7=SE,b7=w7;function _7(r){return r==null?"":b7(r)}var kE=_7,A7=In,v7=Ny,E7=vE,x7=kE;function R7(r,e){return A7(r)?r:v7(r,e)?[r]:E7(x7(r))}var TE=R7,I7=mf,S7=1/0;function k7(r){if(typeof r=="string"||I7(r))return r;var e=r+"";return e=="0"&&1/r==-S7?"-0":e}var Af=k7,T7=TE,O7=Af;function N7(r,e){e=T7(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[O7(e[t++])];return t&&t==n?r:void 0}var OE=N7,C7=OE;function B7(r,e,t){var n=r==null?void 0:C7(r,e);return n===void 0?t:n}var P7=B7;function M7(r,e){return r!=null&&e in Object(r)}var L7=M7,U7=TE,D7=Od,$7=In,F7=Bd,H7=Tg,z7=Af;function G7(r,e,t){e=U7(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=z7(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&H7(i)&&F7(o,i)&&($7(r)||D7(r)))}var V7=G7,j7=L7,K7=V7;function W7(r,e){return r!=null&&K7(r,e,j7)}var q7=W7,Z7=Fg,Q7=P7,Y7=q7,J7=Ny,X7=bE,ez=_E,tz=Af,rz=1,nz=2;function iz(r,e){return J7(r)&&X7(e)?ez(tz(r),e):function(t){var n=Q7(t,r);return n===void 0&&n===e?Y7(t,r):Z7(e,n,rz|nz)}}var sz=iz;function oz(r){return function(e){return e==null?void 0:e[r]}}var az=oz,cz=OE;function uz(r){return function(e){return cz(e,r)}}var lz=uz,fz=az,hz=lz,dz=Ny,pz=Af;function gz(r){return dz(r)?fz(pz(r)):hz(r)}var yz=gz,mz=YH,wz=sz,bz=Wd(),_z=In,Az=yz;function vz(r){return typeof r=="function"?r:r==null?bz:typeof r=="object"?_z(r)?wz(r[0],r[1]):mz(r):Az(r)}var Ez=vz,xz=yE,Rz=Ez,Iz=1;function Sz(r){return Rz(typeof r=="function"?r:xz(r,Iz))}var kz=Sz,NE=Uc,Tz=Od,Oz=In,CE=NE?NE.isConcatSpreadable:void 0;function Nz(r){return Oz(r)||Tz(r)||!!(CE&&r&&r[CE])}var Cz=Nz,Bz=Sg,Pz=Cz;function BE(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=Pz),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?BE(a,e-1,t,n,i):Bz(i,a):n||(i[i.length]=a)}return i}var Mz=BE,Lz=Mz;function Uz(r){var e=r==null?0:r.length;return e?Lz(r,1):[]}var Dz=Uz,By,PE;function ME(){if(PE)return By;PE=1;var r=iy(),e=Math.max;function t(n,i,s){return i=e(i===void 0?n.length-1:i,0),function(){for(var o=arguments,a=-1,u=e(o.length-i,0),l=Array(u);++a<u;)l[a]=o[i+a];a=-1;for(var h=Array(i+1);++a<i;)h[a]=o[a];return h[i]=s(l),r(n,this,h)}}return By=t,By}var $z=Dz,Fz=ME(),Hz=hy();function zz(r){return Hz(Fz(r,void 0,$z),r+"")}var Gz=zz,Vz=by,jz=Gz,Kz=256,Wz=jz(function(r,e){return Vz(r,Kz,void 0,void 0,void 0,e)}),qz=Wz,Zz=EE,Qz=gf,Yz=In,Jz=mf,Xz=vE,eG=Af,tG=kE;function rG(r){return Yz(r)?Zz(r,eG):Jz(r)?[r]:Qz(Xz(tG(r)))}var nG=rG,iG={ary:R$,assign:qv,clone:uH,curry:hH,forEach:dy,isArray:In,isError:kH,isFunction:Rd,isWeakMap:BH,iteratee:kz,keys:pA,rearg:qz,toInteger:Hv,toPath:nG},sG=QM,oG=iG;function aG(r,e,t){return sG(oG,r,e,t)}var cG=aG,Py,LE;function UE(){if(LE)return Py;LE=1;var r=Ay(),e=ql;function t(n,i,s){(s!==void 0&&!e(n[i],s)||s===void 0&&!(i in n))&&r(n,i,s)}return Py=t,Py}var My,DE;function uG(){if(DE)return My;DE=1;function r(e){return function(t,n,i){for(var s=-1,o=Object(t),a=i(t),u=a.length;u--;){var l=a[e?u:++s];if(n(o[l],l,o)===!1)break}return t}}return My=r,My}var Ly,$E;function lG(){if($E)return Ly;$E=1;var r=uG(),e=r();return Ly=e,Ly}var Uy,FE;function fG(){if(FE)return Uy;FE=1;var r=Md,e=Xn;function t(n){return e(n)&&r(n)}return Uy=t,Uy}var Dy,HE;function zE(){if(HE)return Dy;HE=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return Dy=r,Dy}var $y,GE;function hG(){if(GE)return $y;GE=1;var r=wf,e=bf();function t(n){return r(n,e(n))}return $y=t,$y}var Fy,VE;function dG(){if(VE)return Fy;VE=1;var r=UE(),e=Xv(),t=oE(),n=gf,i=cE(),s=Od,o=In,a=fG(),u=Cd,l=Rd,h=yi,g=wE,b=Cg,w=zE(),I=hG();function S(x,C,H,D,z,W,Z){var V=w(x,H),K=w(C,H),oe=Z.get(K);if(oe){r(x,H,oe);return}var ce=W?W(V,K,H+"",x,C,Z):void 0,ie=ce===void 0;if(ie){var ue=o(K),B=!ue&&u(K),p=!ue&&!B&&b(K);ce=K,ue||B||p?o(V)?ce=V:a(V)?ce=n(V):B?(ie=!1,ce=e(K,!0)):p?(ie=!1,ce=t(K,!0)):ce=[]:g(K)||s(K)?(ce=V,s(V)?ce=I(V):(!h(V)||l(V))&&(ce=i(K))):ie=!1}ie&&(Z.set(K,ce),z(ce,K,D,W,Z),Z.delete(K)),r(x,H,ce)}return Fy=S,Fy}var Hy,jE;function pG(){if(jE)return Hy;jE=1;var r=kd,e=UE(),t=lG(),n=dG(),i=yi,s=bf(),o=zE();function a(u,l,h,g,b){u!==l&&t(l,function(w,I){if(b||(b=new r),i(w))n(u,l,I,h,a,g,b);else{var S=g?g(o(u,I),w,I+"",u,l,b):void 0;S===void 0&&(S=w),e(u,I,S)}},s)}return Hy=a,Hy}var zy,KE;function gG(){if(KE)return zy;KE=1;var r=Wd(),e=ME(),t=hy();function n(i,s){return t(e(i,s,r),i+"")}return zy=n,zy}var Gy,WE;function yG(){if(WE)return Gy;WE=1;var r=ql,e=Md,t=Bd,n=yi;function i(s,o,a){if(!n(a))return!1;var u=typeof o;return(u=="number"?e(a)&&t(o,a.length):u=="string"&&o in a)?r(a[o],s):!1}return Gy=i,Gy}var Vy,qE;function mG(){if(qE)return Vy;qE=1;var r=gG(),e=yG();function t(n){return r(function(i,s){var o=-1,a=s.length,u=a>1?s[a-1]:void 0,l=a>2?s[2]:void 0;for(u=n.length>3&&typeof u=="function"?(a--,u):void 0,l&&e(s[0],s[1],l)&&(u=a<3?void 0:u,a=1),i=Object(i);++o<a;){var h=s[o];h&&n(i,h,o,u)}return i})}return Vy=t,Vy}var jy,ZE;function wG(){if(ZE)return jy;ZE=1;var r=pG(),e=mG(),t=e(function(n,i,s,o){r(n,i,s,o)});return jy=t,jy}var bG=cG,QE=bG("mergeWith",wG());QE.placeholder=ev();var _G=QE;const AG=xn(_G);class vG{constructor(e,t,n){this.userDetails=e,this.utils=t,this.emitter=n,this.mutex=new jM,this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.messagesQueue=new Vg({clearWaitTime:200}),this.history={allTimeUsers:{}},this.processedUpdaterRefs=new Set,this.loadedMessagesCache=new Set,this.updaterEntryBuffer=[],this.historyUpdateTimer=null,this.HISTORY_UPDATE_INTERVAL_TIME=5e3,this.MAX_LOADED_MESSAGES_CACHE_SIZE=10}async init(){const e=await this.fetchLatestHistoryEntry();if(!this.historyEntry&&!e){this.initializeDefaultEntry();return}if(e!=null&&e.ref){this.setHistoryEntry(e);const t=await this.fetchHistory(e);this.history=t||this.history,this.trimHistory(),await this.fetchPreviousMessages({preDownloadHistory:!1})}}startHistoryUpdateProcess(){if(this.historyUpdateTimer){this.logger.warn("History update process is already running.");return}this.historyUpdateTimer=setInterval(this.createHistoryEntry.bind(this),this.HISTORY_UPDATE_INTERVAL_TIME)}stopHistoryUpdateProcess(){this.historyUpdateTimer&&(clearInterval(this.historyUpdateTimer),this.historyUpdateTimer=null)}getHistoryEntryWithNewUpdater(e){return{...this.historyEntry,updater:this.chooseNewUpdater(e)}}setHistoryEntry(e){this.historyEntry=e}async processHistoryUpdaterEntry(e,t){const n=await this.mutex.acquire();try{this.updateLocalHistory(e),t.updater===this.userDetails.ownAddress&&this.updaterEntryBuffer.push(t)}catch(i){this.errorHandler.handleError(i,"Chat.processHistoryUpdaterEntry")}finally{n()}}async fetchPreviousMessages(e){const t=await this.mutex.acquire();try{const n=e.preDownloadHistory?await this.fetchHistory(this.historyEntry):null,{allTimeUsers:i}=n?this.mergeChatHistory(n,this.history):this.history,s=this.selectLatestMessages(i);s.length>0&&await this.readAllMessageEntry(s)}finally{t()}}async createHistoryEntry(){const e=await this.mutex.acquire();try{const t=this.selectBestEntryForUpdate([...this.updaterEntryBuffer]);if(!t||this.processedUpdaterRefs.has(t.ref)){this.cleanupUpdaterEntryBuffer(t==null?void 0:t.id);return}const n=t.ref?await this.fetchHistory(this.historyEntry):null,i=n?this.mergeChatHistory(n,this.history):this.history,s=await this.uploadHistory(i),o=this.createNewHistoryEntry(s);await this.waitForHistoryEntryBroadcast(o),this.cleanupUpdaterEntryBuffer(t.id),this.processedUpdaterRefs.add(t.ref)}catch(t){this.errorHandler.handleError(t,"Chat.updateHistory")}finally{e()}}async waitForHistoryEntryBroadcast(e){return QA({condition:()=>this.historyEntry.ref===e.ref,broadcast:()=>this.broadcastHistoryEntry(e)})}async broadcastHistoryEntry(e){try{await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({historyEntry:e}))),this.logger.debug("NEW history entry broadcast CALLED")}catch(t){this.errorHandler.handleError(t,"Chat.broadcastNewAppState")}}async uploadHistory(e){const t=await this.utils.uploadObjectToBeeV2(e);if(!t)throw new Error("History reference is null");return t}async fetchHistory(e){const t=e||await this.fetchLatestHistoryEntry();if(!t)return null;const n=await this.utils.downloadObjectFromBee(t.ref);return LM(n)?n:(this.logger.warn("Could not fetch remote history: invalid history data"),null)}async fetchLatestHistoryEntry(){try{const e=await this.utils.fetchLatestChatMessage();return this.logger.debug("Init GSOC message:",e),ZA(e)?e.historyEntry:(this.logger.warn("Invalid GSOC message during latest history entry fetch"),null)}catch(e){return this.errorHandler.handleError(e,"Chat.fetchLatestHistoryEntry"),null}}async readAllMessageEntry(e){e.forEach(t=>{this.messagesQueue.enqueue(()=>this.readMessage(t))}),await this.messagesQueue.waitForProcessing()}async readMessage(e){try{const t=await this.utils.fetchUserFeedDataByIndex(e.address,e.entry.index);this.emitter.emit(ei.MESSAGE_RECEIVED,t)}catch(t){this.errorHandler.handleError(t,"SwarmHistory.readMessage")}}updateLocalHistory(e){const t={};Object.entries(e).forEach(([n,i])=>{t[n]={events:[],messageEntries:[{index:i.index,timestamp:i.timestamp}]}}),this.history={allTimeUsers:this.mergeUserHistory(t,this.history.allTimeUsers)}}mergeChatHistory(e,t){return{allTimeUsers:this.mergeUserHistory(e.allTimeUsers,t.allTimeUsers)}}mergeUserHistory(e,t){return AG((n,i)=>{if(!n)return i;if(!i)return n;const s=BA(n.events,i.events,a=>`${a.type}-${a.timestamp}`,(a,u)=>a.timestamp-u.timestamp),o=BA(n.messageEntries,i.messageEntries,a=>a.index,(a,u)=>a.timestamp-u.timestamp);return{events:s,messageEntries:o}},e,t)}trimHistory(e=2,t=1e4){try{const n=JSON.stringify(this.history);if(new Blob([n]).size/(1024*1024)<=e)return;const o=[];for(const l in this.history.allTimeUsers)this.history.allTimeUsers[l].messageEntries.forEach(g=>{o.push({address:l,entry:g})});o.sort((l,h)=>l.entry.timestamp-h.entry.timestamp);const a=o.slice(t),u={allTimeUsers:{}};for(const{address:l,entry:h}of a)u.allTimeUsers[l]||(u.allTimeUsers[l]={events:[],messageEntries:[]}),u.allTimeUsers[l].messageEntries.push(h);this.history=u}catch(n){this.errorHandler.handleError(n,"SwarmHistory.trimHistory")}}chooseNewUpdater(e){const t=Object.values(e);if(t.length===0)return this.userDetails.ownAddress;let n;if(window.crypto&&window.crypto.getRandomValues){const i=new Uint32Array(1);window.crypto.getRandomValues(i),n=i[0]%t.length}else n=Math.floor(Math.random()*t.length);return t[n].address}selectLatestMessages(e){const t=[];for(const[i,s]of Object.entries(e))for(const o of s.messageEntries)t.push({address:i,entry:o});t.sort((i,s)=>s.entry.timestamp-i.entry.timestamp);const n=[];for(const{address:i,entry:s}of t){const o=`${i}:${s.index}`;if(!this.loadedMessagesCache.has(o)&&(n.push({address:i,entry:s}),this.loadedMessagesCache.add(o),n.length===this.MAX_LOADED_MESSAGES_CACHE_SIZE))break}return n}selectBestEntryForUpdate(e){return e.filter(t=>t.updater===this.userDetails.ownAddress).reduce((t,n)=>!t||n.id>t.id||n.id===t.id&&n.timestamp>t.timestamp?n:t,null)}cleanupUpdaterEntryBuffer(e){e!==void 0&&(this.updaterEntryBuffer=this.updaterEntryBuffer.filter(t=>t.id!==e))}createNewHistoryEntry(e){return{id:this.historyEntry.id+1,ref:e,updater:this.userDetails.ownAddress,timestamp:Date.now()}}initializeDefaultEntry(){this.historyEntry={id:0,ref:"",updater:this.userDetails.ownAddress,timestamp:Date.now()}}}const qc=globalThis||void 0||self;var Ky={},e0={};e0.byteLength=RG,e0.toByteArray=SG,e0.fromByteArray=OG;for(var Hi=[],ti=[],EG=typeof Uint8Array<"u"?Uint8Array:Array,Wy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zc=0,xG=Wy.length;Zc<xG;++Zc)Hi[Zc]=Wy[Zc],ti[Wy.charCodeAt(Zc)]=Zc;ti[45]=62,ti[95]=63;function YE(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function RG(r){var e=YE(r),t=e[0],n=e[1];return(t+n)*3/4-n}function IG(r,e,t){return(e+t)*3/4-t}function SG(r){var e,t=YE(r),n=t[0],i=t[1],s=new EG(IG(r,n,i)),o=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)e=ti[r.charCodeAt(u)]<<18|ti[r.charCodeAt(u+1)]<<12|ti[r.charCodeAt(u+2)]<<6|ti[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=ti[r.charCodeAt(u)]<<2|ti[r.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=ti[r.charCodeAt(u)]<<10|ti[r.charCodeAt(u+1)]<<4|ti[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function kG(r){return Hi[r>>18&63]+Hi[r>>12&63]+Hi[r>>6&63]+Hi[r&63]}function TG(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(kG(n));return i.join("")}function OG(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,a=t-n;o<a;o+=s)i.push(TG(r,o,o+s>a?a:o+s));return n===1?(e=r[t-1],i.push(Hi[e>>2]+Hi[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Hi[e>>10]+Hi[e>>4&63]+Hi[e<<2&63]+"=")),i.join("")}var qy={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */qy.read=function(r,e,t,n,i){var s,o,a=i*8-n-1,u=(1<<a)-1,l=u>>1,h=-7,g=t?i-1:0,b=t?-1:1,w=r[e+g];for(g+=b,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+r[e+g],g+=b,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+r[e+g],g+=b,h-=8);if(s===0)s=1-l;else{if(s===u)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)},qy.write=function(r,e,t,n,i,s){var o,a,u,l=s*8-i-1,h=(1<<l)-1,g=h>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,I=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+g>=1?e+=b/u:e+=b*Math.pow(2,1-g),e*u>=2&&(o++,u/=2),o+g>=h?(a=0,o=h):o+g>=1?(a=(e*u-1)*Math.pow(2,i),o=o+g):(a=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;r[t+w]=a&255,w+=I,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;r[t+w]=o&255,w+=I,o/=256,l-=8);r[t+w-I]|=S*128};/*!
|
|
14
|
+
* The buffer module from node.js, for the browser.
|
|
15
|
+
*
|
|
16
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
17
|
+
* @license MIT
|
|
18
|
+
*/(function(r){const e=e0,t=qy,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=W,r.INSPECT_MAX_BYTES=50;const i=2147483647;r.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=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 N=new s(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,s.prototype),Object.setPrototypeOf(N,_),N.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 l(N){if(N>i)throw new RangeError('The value "'+N+'" is invalid for option "size"');const _=new s(N);return Object.setPrototypeOf(_,h.prototype),_}function h(N,_,v){if(typeof N=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(N)}return g(N,_,v)}h.poolSize=8192;function g(N,_,v){if(typeof N=="string")return S(N,_);if(o.isView(N))return C(N);if(N==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N);if(or(N,o)||N&&or(N.buffer,o)||typeof a<"u"&&(or(N,a)||N&&or(N.buffer,a)))return H(N,_,v);if(typeof N=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const $=N.valueOf&&N.valueOf();if($!=null&&$!==N)return h.from($,_,v);const j=D(N);if(j)return j;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof N[Symbol.toPrimitive]=="function")return h.from(N[Symbol.toPrimitive]("string"),_,v);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N)}h.from=function(N,_,v){return g(N,_,v)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function b(N){if(typeof N!="number")throw new TypeError('"size" argument must be of type number');if(N<0)throw new RangeError('The value "'+N+'" is invalid for option "size"')}function w(N,_,v){return b(N),N<=0?l(N):_!==void 0?typeof v=="string"?l(N).fill(_,v):l(N).fill(_):l(N)}h.alloc=function(N,_,v){return w(N,_,v)};function I(N){return b(N),l(N<0?0:z(N)|0)}h.allocUnsafe=function(N){return I(N)},h.allocUnsafeSlow=function(N){return I(N)};function S(N,_){if((typeof _!="string"||_==="")&&(_="utf8"),!h.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const v=Z(N,_)|0;let $=l(v);const j=$.write(N,_);return j!==v&&($=$.slice(0,j)),$}function x(N){const _=N.length<0?0:z(N.length)|0,v=l(_);for(let $=0;$<_;$+=1)v[$]=N[$]&255;return v}function C(N){if(or(N,s)){const _=new s(N);return H(_.buffer,_.byteOffset,_.byteLength)}return x(N)}function H(N,_,v){if(_<0||N.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(N.byteLength<_+(v||0))throw new RangeError('"length" is outside of buffer bounds');let $;return _===void 0&&v===void 0?$=new s(N):v===void 0?$=new s(N,_):$=new s(N,_,v),Object.setPrototypeOf($,h.prototype),$}function D(N){if(h.isBuffer(N)){const _=z(N.length)|0,v=l(_);return v.length===0||N.copy(v,0,0,_),v}if(N.length!==void 0)return typeof N.length!="number"||xt(N.length)?l(0):x(N);if(N.type==="Buffer"&&Array.isArray(N.data))return x(N.data)}function z(N){if(N>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return N|0}function W(N){return+N!=N&&(N=0),h.alloc(+N)}h.isBuffer=function(_){return _!=null&&_._isBuffer===!0&&_!==h.prototype},h.compare=function(_,v){if(or(_,s)&&(_=h.from(_,_.offset,_.byteLength)),or(v,s)&&(v=h.from(v,v.offset,v.byteLength)),!h.isBuffer(_)||!h.isBuffer(v))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(_===v)return 0;let $=_.length,j=v.length;for(let Y=0,ae=Math.min($,j);Y<ae;++Y)if(_[Y]!==v[Y]){$=_[Y],j=v[Y];break}return $<j?-1:j<$?1:0},h.isEncoding=function(_){switch(String(_).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(_,v){if(!Array.isArray(_))throw new TypeError('"list" argument must be an Array of Buffers');if(_.length===0)return h.alloc(0);let $;if(v===void 0)for(v=0,$=0;$<_.length;++$)v+=_[$].length;const j=h.allocUnsafe(v);let Y=0;for($=0;$<_.length;++$){let ae=_[$];if(or(ae,s))Y+ae.length>j.length?(h.isBuffer(ae)||(ae=h.from(ae)),ae.copy(j,Y)):s.prototype.set.call(j,ae,Y);else if(h.isBuffer(ae))ae.copy(j,Y);else throw new TypeError('"list" argument must be an Array of Buffers');Y+=ae.length}return j};function Z(N,_){if(h.isBuffer(N))return N.length;if(o.isView(N)||or(N,o))return N.byteLength;if(typeof N!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof N);const v=N.length,$=arguments.length>2&&arguments[2]===!0;if(!$&&v===0)return 0;let j=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return v;case"utf8":case"utf-8":return It(N).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v*2;case"hex":return v>>>1;case"base64":return pt(N).length;default:if(j)return $?-1:It(N).length;_=(""+_).toLowerCase(),j=!0}}h.byteLength=Z;function V(N,_,v){let $=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((v===void 0||v>this.length)&&(v=this.length),v<=0)||(v>>>=0,_>>>=0,v<=_))return"";for(N||(N="utf8");;)switch(N){case"hex":return A(this,_,v);case"utf8":case"utf-8":return k(this,_,v);case"ascii":return G(this,_,v);case"latin1":case"binary":return P(this,_,v);case"base64":return E(this,_,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,_,v);default:if($)throw new TypeError("Unknown encoding: "+N);N=(N+"").toLowerCase(),$=!0}}h.prototype._isBuffer=!0;function K(N,_,v){const $=N[_];N[_]=N[v],N[v]=$}h.prototype.swap16=function(){const _=this.length;if(_%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let v=0;v<_;v+=2)K(this,v,v+1);return this},h.prototype.swap32=function(){const _=this.length;if(_%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let v=0;v<_;v+=4)K(this,v,v+3),K(this,v+1,v+2);return this},h.prototype.swap64=function(){const _=this.length;if(_%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let v=0;v<_;v+=8)K(this,v,v+7),K(this,v+1,v+6),K(this,v+2,v+5),K(this,v+3,v+4);return this},h.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?k(this,0,_):V.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(_){if(!h.isBuffer(_))throw new TypeError("Argument must be a Buffer");return this===_?!0:h.compare(this,_)===0},h.prototype.inspect=function(){let _="";const v=r.INSPECT_MAX_BYTES;return _=this.toString("hex",0,v).replace(/(.{2})/g,"$1 ").trim(),this.length>v&&(_+=" ... "),"<Buffer "+_+">"},n&&(h.prototype[n]=h.prototype.inspect),h.prototype.compare=function(_,v,$,j,Y){if(or(_,s)&&(_=h.from(_,_.offset,_.byteLength)),!h.isBuffer(_))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof _);if(v===void 0&&(v=0),$===void 0&&($=_?_.length:0),j===void 0&&(j=0),Y===void 0&&(Y=this.length),v<0||$>_.length||j<0||Y>this.length)throw new RangeError("out of range index");if(j>=Y&&v>=$)return 0;if(j>=Y)return-1;if(v>=$)return 1;if(v>>>=0,$>>>=0,j>>>=0,Y>>>=0,this===_)return 0;let ae=Y-j,Ye=$-v;const qe=Math.min(ae,Ye),We=this.slice(j,Y),$t=_.slice(v,$);for(let Ge=0;Ge<qe;++Ge)if(We[Ge]!==$t[Ge]){ae=We[Ge],Ye=$t[Ge];break}return ae<Ye?-1:Ye<ae?1:0};function oe(N,_,v,$,j){if(N.length===0)return-1;if(typeof v=="string"?($=v,v=0):v>2147483647?v=2147483647:v<-2147483648&&(v=-2147483648),v=+v,xt(v)&&(v=j?0:N.length-1),v<0&&(v=N.length+v),v>=N.length){if(j)return-1;v=N.length-1}else if(v<0)if(j)v=0;else return-1;if(typeof _=="string"&&(_=h.from(_,$)),h.isBuffer(_))return _.length===0?-1:ce(N,_,v,$,j);if(typeof _=="number")return _=_&255,typeof s.prototype.indexOf=="function"?j?s.prototype.indexOf.call(N,_,v):s.prototype.lastIndexOf.call(N,_,v):ce(N,[_],v,$,j);throw new TypeError("val must be string, number or Buffer")}function ce(N,_,v,$,j){let Y=1,ae=N.length,Ye=_.length;if($!==void 0&&($=String($).toLowerCase(),$==="ucs2"||$==="ucs-2"||$==="utf16le"||$==="utf-16le")){if(N.length<2||_.length<2)return-1;Y=2,ae/=2,Ye/=2,v/=2}function qe($t,Ge){return Y===1?$t[Ge]:$t.readUInt16BE(Ge*Y)}let We;if(j){let $t=-1;for(We=v;We<ae;We++)if(qe(N,We)===qe(_,$t===-1?0:We-$t)){if($t===-1&&($t=We),We-$t+1===Ye)return $t*Y}else $t!==-1&&(We-=We-$t),$t=-1}else for(v+Ye>ae&&(v=ae-Ye),We=v;We>=0;We--){let $t=!0;for(let Ge=0;Ge<Ye;Ge++)if(qe(N,We+Ge)!==qe(_,Ge)){$t=!1;break}if($t)return We}return-1}h.prototype.includes=function(_,v,$){return this.indexOf(_,v,$)!==-1},h.prototype.indexOf=function(_,v,$){return oe(this,_,v,$,!0)},h.prototype.lastIndexOf=function(_,v,$){return oe(this,_,v,$,!1)};function ie(N,_,v,$){v=Number(v)||0;const j=N.length-v;$?($=Number($),$>j&&($=j)):$=j;const Y=_.length;$>Y/2&&($=Y/2);let ae;for(ae=0;ae<$;++ae){const Ye=parseInt(_.substr(ae*2,2),16);if(xt(Ye))return ae;N[v+ae]=Ye}return ae}function ue(N,_,v,$){return St(It(_,N.length-v),N,v,$)}function B(N,_,v,$){return St(Ct(_),N,v,$)}function p(N,_,v,$){return St(pt(_),N,v,$)}function m(N,_,v,$){return St(kr(_,N.length-v),N,v,$)}h.prototype.write=function(_,v,$,j){if(v===void 0)j="utf8",$=this.length,v=0;else if($===void 0&&typeof v=="string")j=v,$=this.length,v=0;else if(isFinite(v))v=v>>>0,isFinite($)?($=$>>>0,j===void 0&&(j="utf8")):(j=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Y=this.length-v;if(($===void 0||$>Y)&&($=Y),_.length>0&&($<0||v<0)||v>this.length)throw new RangeError("Attempt to write outside buffer bounds");j||(j="utf8");let ae=!1;for(;;)switch(j){case"hex":return ie(this,_,v,$);case"utf8":case"utf-8":return ue(this,_,v,$);case"ascii":case"latin1":case"binary":return B(this,_,v,$);case"base64":return p(this,_,v,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,_,v,$);default:if(ae)throw new TypeError("Unknown encoding: "+j);j=(""+j).toLowerCase(),ae=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(N,_,v){return _===0&&v===N.length?e.fromByteArray(N):e.fromByteArray(N.slice(_,v))}function k(N,_,v){v=Math.min(N.length,v);const $=[];let j=_;for(;j<v;){const Y=N[j];let ae=null,Ye=Y>239?4:Y>223?3:Y>191?2:1;if(j+Ye<=v){let qe,We,$t,Ge;switch(Ye){case 1:Y<128&&(ae=Y);break;case 2:qe=N[j+1],(qe&192)===128&&(Ge=(Y&31)<<6|qe&63,Ge>127&&(ae=Ge));break;case 3:qe=N[j+1],We=N[j+2],(qe&192)===128&&(We&192)===128&&(Ge=(Y&15)<<12|(qe&63)<<6|We&63,Ge>2047&&(Ge<55296||Ge>57343)&&(ae=Ge));break;case 4:qe=N[j+1],We=N[j+2],$t=N[j+3],(qe&192)===128&&(We&192)===128&&($t&192)===128&&(Ge=(Y&15)<<18|(qe&63)<<12|(We&63)<<6|$t&63,Ge>65535&&Ge<1114112&&(ae=Ge))}}ae===null?(ae=65533,Ye=1):ae>65535&&(ae-=65536,$.push(ae>>>10&1023|55296),ae=56320|ae&1023),$.push(ae),j+=Ye}return M($)}const O=4096;function M(N){const _=N.length;if(_<=O)return String.fromCharCode.apply(String,N);let v="",$=0;for(;$<_;)v+=String.fromCharCode.apply(String,N.slice($,$+=O));return v}function G(N,_,v){let $="";v=Math.min(N.length,v);for(let j=_;j<v;++j)$+=String.fromCharCode(N[j]&127);return $}function P(N,_,v){let $="";v=Math.min(N.length,v);for(let j=_;j<v;++j)$+=String.fromCharCode(N[j]);return $}function A(N,_,v){const $=N.length;(!_||_<0)&&(_=0),(!v||v<0||v>$)&&(v=$);let j="";for(let Y=_;Y<v;++Y)j+=Bt[N[Y]];return j}function U(N,_,v){const $=N.slice(_,v);let j="";for(let Y=0;Y<$.length-1;Y+=2)j+=String.fromCharCode($[Y]+$[Y+1]*256);return j}h.prototype.slice=function(_,v){const $=this.length;_=~~_,v=v===void 0?$:~~v,_<0?(_+=$,_<0&&(_=0)):_>$&&(_=$),v<0?(v+=$,v<0&&(v=0)):v>$&&(v=$),v<_&&(v=_);const j=this.subarray(_,v);return Object.setPrototypeOf(j,h.prototype),j};function le(N,_,v){if(N%1!==0||N<0)throw new RangeError("offset is not uint");if(N+_>v)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)j+=this[_+ae]*Y;return j},h.prototype.readUintBE=h.prototype.readUIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_+--v],Y=1;for(;v>0&&(Y*=256);)j+=this[_+--v]*Y;return j},h.prototype.readUint8=h.prototype.readUInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]|this[_+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]<<8|this[_+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),(this[_]|this[_+1]<<8|this[_+2]<<16)+this[_+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]*16777216+(this[_+1]<<16|this[_+2]<<8|this[_+3])},h.prototype.readBigUInt64LE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const j=v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,Y=this[++_]+this[++_]*2**8+this[++_]*2**16+$*2**24;return BigInt(j)+(BigInt(Y)<<BigInt(32))}),h.prototype.readBigUInt64BE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const j=v*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],Y=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$;return(BigInt(j)<<BigInt(32))+BigInt(Y)}),h.prototype.readIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)j+=this[_+ae]*Y;return Y*=128,j>=Y&&(j-=Math.pow(2,8*v)),j},h.prototype.readIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=v,Y=1,ae=this[_+--j];for(;j>0&&(Y*=256);)ae+=this[_+--j]*Y;return Y*=128,ae>=Y&&(ae-=Math.pow(2,8*v)),ae},h.prototype.readInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]&128?(255-this[_]+1)*-1:this[_]},h.prototype.readInt16LE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_]|this[_+1]<<8;return $&32768?$|4294901760:$},h.prototype.readInt16BE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_+1]|this[_]<<8;return $&32768?$|4294901760:$},h.prototype.readInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]|this[_+1]<<8|this[_+2]<<16|this[_+3]<<24},h.prototype.readInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]<<24|this[_+1]<<16|this[_+2]<<8|this[_+3]},h.prototype.readBigInt64LE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const j=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+($<<24);return(BigInt(j)<<BigInt(32))+BigInt(v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24)}),h.prototype.readBigInt64BE=fn(function(_){_=_>>>0,sr(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&dt(_,this.length-8);const j=(v<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(j)<<BigInt(32))+BigInt(this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$)}),h.prototype.readFloatLE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!0,23,4)},h.prototype.readFloatBE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!1,23,4)},h.prototype.readDoubleLE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!0,52,8)},h.prototype.readDoubleBE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!1,52,8)};function te(N,_,v,$,j,Y){if(!h.isBuffer(N))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>j||_<Y)throw new RangeError('"value" argument is out of bounds');if(v+$>N.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(_,v,$,j){if(_=+_,v=v>>>0,$=$>>>0,!j){const Ye=Math.pow(2,8*$)-1;te(this,_,v,$,Ye,0)}let Y=1,ae=0;for(this[v]=_&255;++ae<$&&(Y*=256);)this[v+ae]=_/Y&255;return v+$},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(_,v,$,j){if(_=+_,v=v>>>0,$=$>>>0,!j){const Ye=Math.pow(2,8*$)-1;te(this,_,v,$,Ye,0)}let Y=$-1,ae=1;for(this[v+Y]=_&255;--Y>=0&&(ae*=256);)this[v+Y]=_/ae&255;return v+$},h.prototype.writeUint8=h.prototype.writeUInt8=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,1,255,0),this[v]=_&255,v+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,65535,0),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,65535,0),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,4294967295,0),this[v+3]=_>>>24,this[v+2]=_>>>16,this[v+1]=_>>>8,this[v]=_&255,v+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,4294967295,0),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4};function re(N,_,v,$,j){ot(_,$,j,N,v,7);let Y=Number(_&BigInt(4294967295));N[v++]=Y,Y=Y>>8,N[v++]=Y,Y=Y>>8,N[v++]=Y,Y=Y>>8,N[v++]=Y;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,v}function he(N,_,v,$,j){ot(_,$,j,N,v,7);let Y=Number(_&BigInt(4294967295));N[v+7]=Y,Y=Y>>8,N[v+6]=Y,Y=Y>>8,N[v+5]=Y,Y=Y>>8,N[v+4]=Y;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v+3]=ae,ae=ae>>8,N[v+2]=ae,ae=ae>>8,N[v+1]=ae,ae=ae>>8,N[v]=ae,v+8}h.prototype.writeBigUInt64LE=fn(function(_,v=0){return re(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=fn(function(_,v=0){return he(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(_,v,$,j){if(_=+_,v=v>>>0,!j){const qe=Math.pow(2,8*$-1);te(this,_,v,$,qe-1,-qe)}let Y=0,ae=1,Ye=0;for(this[v]=_&255;++Y<$&&(ae*=256);)_<0&&Ye===0&&this[v+Y-1]!==0&&(Ye=1),this[v+Y]=(_/ae>>0)-Ye&255;return v+$},h.prototype.writeIntBE=function(_,v,$,j){if(_=+_,v=v>>>0,!j){const qe=Math.pow(2,8*$-1);te(this,_,v,$,qe-1,-qe)}let Y=$-1,ae=1,Ye=0;for(this[v+Y]=_&255;--Y>=0&&(ae*=256);)_<0&&Ye===0&&this[v+Y+1]!==0&&(Ye=1),this[v+Y]=(_/ae>>0)-Ye&255;return v+$},h.prototype.writeInt8=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,1,127,-128),_<0&&(_=255+_+1),this[v]=_&255,v+1},h.prototype.writeInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,32767,-32768),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,2,32767,-32768),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,2147483647,-2147483648),this[v]=_&255,this[v+1]=_>>>8,this[v+2]=_>>>16,this[v+3]=_>>>24,v+4},h.prototype.writeInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||te(this,_,v,4,2147483647,-2147483648),_<0&&(_=4294967295+_+1),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4},h.prototype.writeBigInt64LE=fn(function(_,v=0){return re(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=fn(function(_,v=0){return he(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ye(N,_,v,$,j,Y){if(v+$>N.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("Index out of range")}function be(N,_,v,$,j){return _=+_,v=v>>>0,j||ye(N,_,v,4),t.write(N,_,v,$,23,4),v+4}h.prototype.writeFloatLE=function(_,v,$){return be(this,_,v,!0,$)},h.prototype.writeFloatBE=function(_,v,$){return be(this,_,v,!1,$)};function Ke(N,_,v,$,j){return _=+_,v=v>>>0,j||ye(N,_,v,8),t.write(N,_,v,$,52,8),v+8}h.prototype.writeDoubleLE=function(_,v,$){return Ke(this,_,v,!0,$)},h.prototype.writeDoubleBE=function(_,v,$){return Ke(this,_,v,!1,$)},h.prototype.copy=function(_,v,$,j){if(!h.isBuffer(_))throw new TypeError("argument should be a Buffer");if($||($=0),!j&&j!==0&&(j=this.length),v>=_.length&&(v=_.length),v||(v=0),j>0&&j<$&&(j=$),j===$||_.length===0||this.length===0)return 0;if(v<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(j<0)throw new RangeError("sourceEnd out of bounds");j>this.length&&(j=this.length),_.length-v<j-$&&(j=_.length-v+$);const Y=j-$;return this===_&&typeof s.prototype.copyWithin=="function"?this.copyWithin(v,$,j):s.prototype.set.call(_,this.subarray($,j),v),Y},h.prototype.fill=function(_,v,$,j){if(typeof _=="string"){if(typeof v=="string"?(j=v,v=0,$=this.length):typeof $=="string"&&(j=$,$=this.length),j!==void 0&&typeof j!="string")throw new TypeError("encoding must be a string");if(typeof j=="string"&&!h.isEncoding(j))throw new TypeError("Unknown encoding: "+j);if(_.length===1){const ae=_.charCodeAt(0);(j==="utf8"&&ae<128||j==="latin1")&&(_=ae)}}else typeof _=="number"?_=_&255:typeof _=="boolean"&&(_=Number(_));if(v<0||this.length<v||this.length<$)throw new RangeError("Out of range index");if($<=v)return this;v=v>>>0,$=$===void 0?this.length:$>>>0,_||(_=0);let Y;if(typeof _=="number")for(Y=v;Y<$;++Y)this[Y]=_;else{const ae=h.isBuffer(_)?_:h.from(_,j),Ye=ae.length;if(Ye===0)throw new TypeError('The value "'+_+'" is invalid for argument "value"');for(Y=0;Y<$-v;++Y)this[Y+v]=ae[Y%Ye]}return this};const Fe={};function Be(N,_,v){Fe[N]=class extends v{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${N}]`,this.stack,delete this.name}get code(){return N}set code(j){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:j,writable:!0})}toString(){return`${this.name} [${N}]: ${this.message}`}}}Be("ERR_BUFFER_OUT_OF_BOUNDS",function(N){return N?`${N} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Be("ERR_INVALID_ARG_TYPE",function(N,_){return`The "${N}" argument must be of type number. Received type ${typeof _}`},TypeError),Be("ERR_OUT_OF_RANGE",function(N,_,v){let $=`The value of "${N}" is out of range.`,j=v;return Number.isInteger(v)&&Math.abs(v)>2**32?j=et(String(v)):typeof v=="bigint"&&(j=String(v),(v>BigInt(2)**BigInt(32)||v<-(BigInt(2)**BigInt(32)))&&(j=et(j)),j+="n"),$+=` It must be ${_}. Received ${j}`,$},RangeError);function et(N){let _="",v=N.length;const $=N[0]==="-"?1:0;for(;v>=$+4;v-=3)_=`_${N.slice(v-3,v)}${_}`;return`${N.slice(0,v)}${_}`}function Qe(N,_,v){sr(_,"offset"),(N[_]===void 0||N[_+v]===void 0)&&dt(_,N.length-(v+1))}function ot(N,_,v,$,j,Y){if(N>v||N<_){const ae=typeof _=="bigint"?"n":"";let Ye;throw _===0||_===BigInt(0)?Ye=`>= 0${ae} and < 2${ae} ** ${(Y+1)*8}${ae}`:Ye=`>= -(2${ae} ** ${(Y+1)*8-1}${ae}) and < 2 ** ${(Y+1)*8-1}${ae}`,new Fe.ERR_OUT_OF_RANGE("value",Ye,N)}Qe($,j,Y)}function sr(N,_){if(typeof N!="number")throw new Fe.ERR_INVALID_ARG_TYPE(_,"number",N)}function dt(N,_,v){throw Math.floor(N)!==N?(sr(N,v),new Fe.ERR_OUT_OF_RANGE("offset","an integer",N)):_<0?new Fe.ERR_BUFFER_OUT_OF_BOUNDS:new Fe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,N)}const Ut=/[^+/0-9A-Za-z-_]/g;function oa(N){if(N=N.split("=")[0],N=N.trim().replace(Ut,""),N.length<2)return"";for(;N.length%4!==0;)N=N+"=";return N}function It(N,_){_=_||1/0;let v;const $=N.length;let j=null;const Y=[];for(let ae=0;ae<$;++ae){if(v=N.charCodeAt(ae),v>55295&&v<57344){if(!j){if(v>56319){(_-=3)>-1&&Y.push(239,191,189);continue}else if(ae+1===$){(_-=3)>-1&&Y.push(239,191,189);continue}j=v;continue}if(v<56320){(_-=3)>-1&&Y.push(239,191,189),j=v;continue}v=(j-55296<<10|v-56320)+65536}else j&&(_-=3)>-1&&Y.push(239,191,189);if(j=null,v<128){if((_-=1)<0)break;Y.push(v)}else if(v<2048){if((_-=2)<0)break;Y.push(v>>6|192,v&63|128)}else if(v<65536){if((_-=3)<0)break;Y.push(v>>12|224,v>>6&63|128,v&63|128)}else if(v<1114112){if((_-=4)<0)break;Y.push(v>>18|240,v>>12&63|128,v>>6&63|128,v&63|128)}else throw new Error("Invalid code point")}return Y}function Ct(N){const _=[];for(let v=0;v<N.length;++v)_.push(N.charCodeAt(v)&255);return _}function kr(N,_){let v,$,j;const Y=[];for(let ae=0;ae<N.length&&!((_-=2)<0);++ae)v=N.charCodeAt(ae),$=v>>8,j=v%256,Y.push(j),Y.push($);return Y}function pt(N){return e.toByteArray(oa(N))}function St(N,_,v,$){let j;for(j=0;j<$&&!(j+v>=_.length||j>=N.length);++j)_[j+v]=N[j];return j}function or(N,_){return N instanceof _||N!=null&&N.constructor!=null&&N.constructor.name!=null&&N.constructor.name===_.name}function xt(N){return N!==N}const Bt=function(){const N="0123456789abcdef",_=new Array(256);for(let v=0;v<16;++v){const $=v*16;for(let j=0;j<16;++j)_[$+j]=N[v]+N[j]}return _}();function fn(N){return typeof BigInt>"u"?Dt:N}function Dt(){throw new Error("BigInt not supported")}})(Ky);const Ze=Ky.Buffer,Ne=Ky.Buffer,NG=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Ne,default:Ze},Symbol.toStringTag,{value:"Module"}));var Zy={exports:{}};const Qy=Mc(NG);Zy.exports,function(r){(function(e,t){function n(B,p){if(!B)throw new Error(p||"Assertion failed")}function i(B,p){B.super_=p;var m=function(){};m.prototype=p.prototype,B.prototype=new m,B.prototype.constructor=B}function s(B,p,m){if(s.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,B!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(B||0,p||10,m||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qy.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,E){if(typeof p=="number")return this._initNumber(p,m,E);if(typeof p=="object")return this._initArray(p,m,E);m==="hex"&&(m=16),n(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var k=0;p[0]==="-"&&(k++,this.negative=1),k<p.length&&(m===16?this._parseHex(p,k,E):(this._parseBase(p,m,k),E==="le"&&this._initArray(this.toArray(),m,E)))},s.prototype._initNumber=function(p,m,E){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):(n(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),m,E)},s.prototype._initArray=function(p,m,E){if(n(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 k=0;k<this.length;k++)this.words[k]=0;var O,M,G=0;if(E==="be")for(k=p.length-1,O=0;k>=0;k-=3)M=p[k]|p[k-1]<<8|p[k-2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);else if(E==="le")for(k=0,O=0;k<p.length;k+=3)M=p[k]|p[k+1]<<8|p[k+2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);return this._strip()};function a(B,p){var m=B.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;n(!1,"Invalid character in "+B)}function u(B,p,m){var E=a(B,m);return m-1>=p&&(E|=a(B,m-1)<<4),E}s.prototype._parseHex=function(p,m,E){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var O=0,M=0,G;if(E==="be")for(k=p.length-1;k>=m;k-=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8;else{var P=p.length-m;for(k=P%2===0?m+1:m;k<p.length;k+=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8}this._strip()};function l(B,p,m,E){for(var k=0,O=0,M=Math.min(B.length,m),G=p;G<M;G++){var P=B.charCodeAt(G)-48;k*=E,P>=49?O=P-49+10:P>=17?O=P-17+10:O=P,n(P>=0&&O<E,"Invalid character"),k+=O}return k}s.prototype._parseBase=function(p,m,E){this.words=[0],this.length=1;for(var k=0,O=1;O<=67108863;O*=m)k++;k--,O=O/m|0;for(var M=p.length-E,G=M%k,P=Math.min(M,M-G)+E,A=0,U=E;U<P;U+=k)A=l(p,U,U+k,m),this.imuln(O),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A);if(G!==0){var le=1;for(A=l(p,U,p.length,m),U=0;U<G;U++)le*=m;this.imuln(le),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A)}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(B,p){B.words=p.words,B.length=p.length,B.negative=p.negative,B.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")]=g}catch{s.prototype.inspect=g}else s.prototype.inspect=g;function g(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var b=["","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"],w=[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],I=[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 E;if(p===16||p==="hex"){E="";for(var k=0,O=0,M=0;M<this.length;M++){var G=this.words[M],P=((G<<k|O)&16777215).toString(16);O=G>>>24-k&16777215,k+=2,k>=26&&(k-=26,M--),O!==0||M!==this.length-1?E=b[6-P.length]+P+E:E=P+E}for(O!==0&&(E=O.toString(16)+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(p===(p|0)&&p>=2&&p<=36){var A=w[p],U=I[p];E="";var le=this.clone();for(le.negative=0;!le.isZero();){var te=le.modrn(U).toString(p);le=le.idivn(U),le.isZero()?E=te+E:E=b[A-te.length]+te+E}for(this.isZero()&&(E="0"+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}n(!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&&n(!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 S=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,E){this._strip();var k=this.byteLength(),O=E||Math.max(1,k);n(k<=O,"byte array longer than desired length"),n(O>0,"Requested array length <= 0");var M=S(p,O),G=m==="le"?"LE":"BE";return this["_toArrayLike"+G](M,k),M},s.prototype._toArrayLikeLE=function(p,m){for(var E=0,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E++]=G&255,E<p.length&&(p[E++]=G>>8&255),E<p.length&&(p[E++]=G>>16&255),M===6?(E<p.length&&(p[E++]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E<p.length)for(p[E++]=k;E<p.length;)p[E++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var E=p.length-1,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E--]=G&255,E>=0&&(p[E--]=G>>8&255),E>=0&&(p[E--]=G>>16&255),M===6?(E>=0&&(p[E--]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E>=0)for(p[E--]=k;E>=0;)p[E--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,E=0;return m>=4096&&(E+=13,m>>>=13),m>=64&&(E+=7,m>>>=7),m>=8&&(E+=4,m>>>=4),m>=2&&(E+=2,m>>>=2),E+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,E=0;return m&8191||(E+=13,m>>>=13),m&127||(E+=7,m>>>=7),m&15||(E+=4,m>>>=4),m&3||(E+=2,m>>>=2),m&1||E++,E},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function x(B){for(var p=new Array(B.bitLength()),m=0;m<p.length;m++){var E=m/26|0,k=m%26;p[m]=B.words[E]>>>k&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var E=this._zeroBits(this.words[m]);if(p+=E,E!==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 n((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 E=0;E<m.length;E++)this.words[E]=this.words[E]&p.words[E];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return n((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,E;this.length>p.length?(m=this,E=p):(m=p,E=this);for(var k=0;k<E.length;k++)this.words[k]=m.words[k]^E.words[k];if(this!==m)for(;k<m.length;k++)this.words[k]=m.words[k];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return n((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){n(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,E=p%26;this._expand(m),E>0&&m--;for(var k=0;k<m;k++)this.words[k]=~this.words[k]&67108863;return E>0&&(this.words[k]=~this.words[k]&67108863>>26-E),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){n(typeof p=="number"&&p>=0);var E=p/26|0,k=p%26;return this._expand(E+1),m?this.words[E]=this.words[E]|1<<k:this.words[E]=this.words[E]&~(1<<k),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 E,k;this.length>p.length?(E=this,k=p):(E=p,k=this);for(var O=0,M=0;M<k.length;M++)m=(E.words[M]|0)+(k.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;for(;O!==0&&M<E.length;M++)m=(E.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;if(this.length=E.length,O!==0)this.words[this.length]=O,this.length++;else if(E!==this)for(;M<E.length;M++)this.words[M]=E.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 E=this.cmp(p);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,O;E>0?(k=this,O=p):(k=p,O=this);for(var M=0,G=0;G<O.length;G++)m=(k.words[G]|0)-(O.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;for(;M!==0&&G<k.length;G++)m=(k.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;if(M===0&&G<k.length&&k!==this)for(;G<k.length;G++)this.words[G]=k.words[G];return this.length=Math.max(this.length,G),k!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function C(B,p,m){m.negative=p.negative^B.negative;var E=B.length+p.length|0;m.length=E,E=E-1|0;var k=B.words[0]|0,O=p.words[0]|0,M=k*O,G=M&67108863,P=M/67108864|0;m.words[0]=G;for(var A=1;A<E;A++){for(var U=P>>>26,le=P&67108863,te=Math.min(A,p.length-1),re=Math.max(0,A-B.length+1);re<=te;re++){var he=A-re|0;k=B.words[he]|0,O=p.words[re]|0,M=k*O+le,U+=M/67108864|0,le=M&67108863}m.words[A]=le|0,P=U|0}return P!==0?m.words[A]=P|0:m.length--,m._strip()}var H=function(p,m,E){var k=p.words,O=m.words,M=E.words,G=0,P,A,U,le=k[0]|0,te=le&8191,re=le>>>13,he=k[1]|0,ye=he&8191,be=he>>>13,Ke=k[2]|0,Fe=Ke&8191,Be=Ke>>>13,et=k[3]|0,Qe=et&8191,ot=et>>>13,sr=k[4]|0,dt=sr&8191,Ut=sr>>>13,oa=k[5]|0,It=oa&8191,Ct=oa>>>13,kr=k[6]|0,pt=kr&8191,St=kr>>>13,or=k[7]|0,xt=or&8191,Bt=or>>>13,fn=k[8]|0,Dt=fn&8191,N=fn>>>13,_=k[9]|0,v=_&8191,$=_>>>13,j=O[0]|0,Y=j&8191,ae=j>>>13,Ye=O[1]|0,qe=Ye&8191,We=Ye>>>13,$t=O[2]|0,Ge=$t&8191,fr=$t>>>13,tg=O[3]|0,hr=tg&8191,dr=tg>>>13,rg=O[4]|0,ar=rg&8191,pr=rg>>>13,ng=O[5]|0,cr=ng&8191,gr=ng>>>13,Oc=O[6]|0,Jt=Oc&8191,yr=Oc>>>13,ig=O[7]|0,mr=ig&8191,wr=ig>>>13,sg=O[8]|0,br=sg&8191,_r=sg>>>13,Nc=O[9]|0,Ar=Nc&8191,vr=Nc>>>13;E.negative=p.negative^m.negative,E.length=19,P=Math.imul(te,Y),A=Math.imul(te,ae),A=A+Math.imul(re,Y)|0,U=Math.imul(re,ae);var Kh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Kh>>>26)|0,Kh&=67108863,P=Math.imul(ye,Y),A=Math.imul(ye,ae),A=A+Math.imul(be,Y)|0,U=Math.imul(be,ae),P=P+Math.imul(te,qe)|0,A=A+Math.imul(te,We)|0,A=A+Math.imul(re,qe)|0,U=U+Math.imul(re,We)|0;var Dl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Dl>>>26)|0,Dl&=67108863,P=Math.imul(Fe,Y),A=Math.imul(Fe,ae),A=A+Math.imul(Be,Y)|0,U=Math.imul(Be,ae),P=P+Math.imul(ye,qe)|0,A=A+Math.imul(ye,We)|0,A=A+Math.imul(be,qe)|0,U=U+Math.imul(be,We)|0,P=P+Math.imul(te,Ge)|0,A=A+Math.imul(te,fr)|0,A=A+Math.imul(re,Ge)|0,U=U+Math.imul(re,fr)|0;var Wh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Wh>>>26)|0,Wh&=67108863,P=Math.imul(Qe,Y),A=Math.imul(Qe,ae),A=A+Math.imul(ot,Y)|0,U=Math.imul(ot,ae),P=P+Math.imul(Fe,qe)|0,A=A+Math.imul(Fe,We)|0,A=A+Math.imul(Be,qe)|0,U=U+Math.imul(Be,We)|0,P=P+Math.imul(ye,Ge)|0,A=A+Math.imul(ye,fr)|0,A=A+Math.imul(be,Ge)|0,U=U+Math.imul(be,fr)|0,P=P+Math.imul(te,hr)|0,A=A+Math.imul(te,dr)|0,A=A+Math.imul(re,hr)|0,U=U+Math.imul(re,dr)|0;var qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(qh>>>26)|0,qh&=67108863,P=Math.imul(dt,Y),A=Math.imul(dt,ae),A=A+Math.imul(Ut,Y)|0,U=Math.imul(Ut,ae),P=P+Math.imul(Qe,qe)|0,A=A+Math.imul(Qe,We)|0,A=A+Math.imul(ot,qe)|0,U=U+Math.imul(ot,We)|0,P=P+Math.imul(Fe,Ge)|0,A=A+Math.imul(Fe,fr)|0,A=A+Math.imul(Be,Ge)|0,U=U+Math.imul(Be,fr)|0,P=P+Math.imul(ye,hr)|0,A=A+Math.imul(ye,dr)|0,A=A+Math.imul(be,hr)|0,U=U+Math.imul(be,dr)|0,P=P+Math.imul(te,ar)|0,A=A+Math.imul(te,pr)|0,A=A+Math.imul(re,ar)|0,U=U+Math.imul(re,pr)|0;var Zh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Zh>>>26)|0,Zh&=67108863,P=Math.imul(It,Y),A=Math.imul(It,ae),A=A+Math.imul(Ct,Y)|0,U=Math.imul(Ct,ae),P=P+Math.imul(dt,qe)|0,A=A+Math.imul(dt,We)|0,A=A+Math.imul(Ut,qe)|0,U=U+Math.imul(Ut,We)|0,P=P+Math.imul(Qe,Ge)|0,A=A+Math.imul(Qe,fr)|0,A=A+Math.imul(ot,Ge)|0,U=U+Math.imul(ot,fr)|0,P=P+Math.imul(Fe,hr)|0,A=A+Math.imul(Fe,dr)|0,A=A+Math.imul(Be,hr)|0,U=U+Math.imul(Be,dr)|0,P=P+Math.imul(ye,ar)|0,A=A+Math.imul(ye,pr)|0,A=A+Math.imul(be,ar)|0,U=U+Math.imul(be,pr)|0,P=P+Math.imul(te,cr)|0,A=A+Math.imul(te,gr)|0,A=A+Math.imul(re,cr)|0,U=U+Math.imul(re,gr)|0;var Qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Qh>>>26)|0,Qh&=67108863,P=Math.imul(pt,Y),A=Math.imul(pt,ae),A=A+Math.imul(St,Y)|0,U=Math.imul(St,ae),P=P+Math.imul(It,qe)|0,A=A+Math.imul(It,We)|0,A=A+Math.imul(Ct,qe)|0,U=U+Math.imul(Ct,We)|0,P=P+Math.imul(dt,Ge)|0,A=A+Math.imul(dt,fr)|0,A=A+Math.imul(Ut,Ge)|0,U=U+Math.imul(Ut,fr)|0,P=P+Math.imul(Qe,hr)|0,A=A+Math.imul(Qe,dr)|0,A=A+Math.imul(ot,hr)|0,U=U+Math.imul(ot,dr)|0,P=P+Math.imul(Fe,ar)|0,A=A+Math.imul(Fe,pr)|0,A=A+Math.imul(Be,ar)|0,U=U+Math.imul(Be,pr)|0,P=P+Math.imul(ye,cr)|0,A=A+Math.imul(ye,gr)|0,A=A+Math.imul(be,cr)|0,U=U+Math.imul(be,gr)|0,P=P+Math.imul(te,Jt)|0,A=A+Math.imul(te,yr)|0,A=A+Math.imul(re,Jt)|0,U=U+Math.imul(re,yr)|0;var $l=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+($l>>>26)|0,$l&=67108863,P=Math.imul(xt,Y),A=Math.imul(xt,ae),A=A+Math.imul(Bt,Y)|0,U=Math.imul(Bt,ae),P=P+Math.imul(pt,qe)|0,A=A+Math.imul(pt,We)|0,A=A+Math.imul(St,qe)|0,U=U+Math.imul(St,We)|0,P=P+Math.imul(It,Ge)|0,A=A+Math.imul(It,fr)|0,A=A+Math.imul(Ct,Ge)|0,U=U+Math.imul(Ct,fr)|0,P=P+Math.imul(dt,hr)|0,A=A+Math.imul(dt,dr)|0,A=A+Math.imul(Ut,hr)|0,U=U+Math.imul(Ut,dr)|0,P=P+Math.imul(Qe,ar)|0,A=A+Math.imul(Qe,pr)|0,A=A+Math.imul(ot,ar)|0,U=U+Math.imul(ot,pr)|0,P=P+Math.imul(Fe,cr)|0,A=A+Math.imul(Fe,gr)|0,A=A+Math.imul(Be,cr)|0,U=U+Math.imul(Be,gr)|0,P=P+Math.imul(ye,Jt)|0,A=A+Math.imul(ye,yr)|0,A=A+Math.imul(be,Jt)|0,U=U+Math.imul(be,yr)|0,P=P+Math.imul(te,mr)|0,A=A+Math.imul(te,wr)|0,A=A+Math.imul(re,mr)|0,U=U+Math.imul(re,wr)|0;var Yh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Yh>>>26)|0,Yh&=67108863,P=Math.imul(Dt,Y),A=Math.imul(Dt,ae),A=A+Math.imul(N,Y)|0,U=Math.imul(N,ae),P=P+Math.imul(xt,qe)|0,A=A+Math.imul(xt,We)|0,A=A+Math.imul(Bt,qe)|0,U=U+Math.imul(Bt,We)|0,P=P+Math.imul(pt,Ge)|0,A=A+Math.imul(pt,fr)|0,A=A+Math.imul(St,Ge)|0,U=U+Math.imul(St,fr)|0,P=P+Math.imul(It,hr)|0,A=A+Math.imul(It,dr)|0,A=A+Math.imul(Ct,hr)|0,U=U+Math.imul(Ct,dr)|0,P=P+Math.imul(dt,ar)|0,A=A+Math.imul(dt,pr)|0,A=A+Math.imul(Ut,ar)|0,U=U+Math.imul(Ut,pr)|0,P=P+Math.imul(Qe,cr)|0,A=A+Math.imul(Qe,gr)|0,A=A+Math.imul(ot,cr)|0,U=U+Math.imul(ot,gr)|0,P=P+Math.imul(Fe,Jt)|0,A=A+Math.imul(Fe,yr)|0,A=A+Math.imul(Be,Jt)|0,U=U+Math.imul(Be,yr)|0,P=P+Math.imul(ye,mr)|0,A=A+Math.imul(ye,wr)|0,A=A+Math.imul(be,mr)|0,U=U+Math.imul(be,wr)|0,P=P+Math.imul(te,br)|0,A=A+Math.imul(te,_r)|0,A=A+Math.imul(re,br)|0,U=U+Math.imul(re,_r)|0;var so=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(so>>>26)|0,so&=67108863,P=Math.imul(v,Y),A=Math.imul(v,ae),A=A+Math.imul($,Y)|0,U=Math.imul($,ae),P=P+Math.imul(Dt,qe)|0,A=A+Math.imul(Dt,We)|0,A=A+Math.imul(N,qe)|0,U=U+Math.imul(N,We)|0,P=P+Math.imul(xt,Ge)|0,A=A+Math.imul(xt,fr)|0,A=A+Math.imul(Bt,Ge)|0,U=U+Math.imul(Bt,fr)|0,P=P+Math.imul(pt,hr)|0,A=A+Math.imul(pt,dr)|0,A=A+Math.imul(St,hr)|0,U=U+Math.imul(St,dr)|0,P=P+Math.imul(It,ar)|0,A=A+Math.imul(It,pr)|0,A=A+Math.imul(Ct,ar)|0,U=U+Math.imul(Ct,pr)|0,P=P+Math.imul(dt,cr)|0,A=A+Math.imul(dt,gr)|0,A=A+Math.imul(Ut,cr)|0,U=U+Math.imul(Ut,gr)|0,P=P+Math.imul(Qe,Jt)|0,A=A+Math.imul(Qe,yr)|0,A=A+Math.imul(ot,Jt)|0,U=U+Math.imul(ot,yr)|0,P=P+Math.imul(Fe,mr)|0,A=A+Math.imul(Fe,wr)|0,A=A+Math.imul(Be,mr)|0,U=U+Math.imul(Be,wr)|0,P=P+Math.imul(ye,br)|0,A=A+Math.imul(ye,_r)|0,A=A+Math.imul(be,br)|0,U=U+Math.imul(be,_r)|0,P=P+Math.imul(te,Ar)|0,A=A+Math.imul(te,vr)|0,A=A+Math.imul(re,Ar)|0,U=U+Math.imul(re,vr)|0;var Jh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Jh>>>26)|0,Jh&=67108863,P=Math.imul(v,qe),A=Math.imul(v,We),A=A+Math.imul($,qe)|0,U=Math.imul($,We),P=P+Math.imul(Dt,Ge)|0,A=A+Math.imul(Dt,fr)|0,A=A+Math.imul(N,Ge)|0,U=U+Math.imul(N,fr)|0,P=P+Math.imul(xt,hr)|0,A=A+Math.imul(xt,dr)|0,A=A+Math.imul(Bt,hr)|0,U=U+Math.imul(Bt,dr)|0,P=P+Math.imul(pt,ar)|0,A=A+Math.imul(pt,pr)|0,A=A+Math.imul(St,ar)|0,U=U+Math.imul(St,pr)|0,P=P+Math.imul(It,cr)|0,A=A+Math.imul(It,gr)|0,A=A+Math.imul(Ct,cr)|0,U=U+Math.imul(Ct,gr)|0,P=P+Math.imul(dt,Jt)|0,A=A+Math.imul(dt,yr)|0,A=A+Math.imul(Ut,Jt)|0,U=U+Math.imul(Ut,yr)|0,P=P+Math.imul(Qe,mr)|0,A=A+Math.imul(Qe,wr)|0,A=A+Math.imul(ot,mr)|0,U=U+Math.imul(ot,wr)|0,P=P+Math.imul(Fe,br)|0,A=A+Math.imul(Fe,_r)|0,A=A+Math.imul(Be,br)|0,U=U+Math.imul(Be,_r)|0,P=P+Math.imul(ye,Ar)|0,A=A+Math.imul(ye,vr)|0,A=A+Math.imul(be,Ar)|0,U=U+Math.imul(be,vr)|0;var Li=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Li>>>26)|0,Li&=67108863,P=Math.imul(v,Ge),A=Math.imul(v,fr),A=A+Math.imul($,Ge)|0,U=Math.imul($,fr),P=P+Math.imul(Dt,hr)|0,A=A+Math.imul(Dt,dr)|0,A=A+Math.imul(N,hr)|0,U=U+Math.imul(N,dr)|0,P=P+Math.imul(xt,ar)|0,A=A+Math.imul(xt,pr)|0,A=A+Math.imul(Bt,ar)|0,U=U+Math.imul(Bt,pr)|0,P=P+Math.imul(pt,cr)|0,A=A+Math.imul(pt,gr)|0,A=A+Math.imul(St,cr)|0,U=U+Math.imul(St,gr)|0,P=P+Math.imul(It,Jt)|0,A=A+Math.imul(It,yr)|0,A=A+Math.imul(Ct,Jt)|0,U=U+Math.imul(Ct,yr)|0,P=P+Math.imul(dt,mr)|0,A=A+Math.imul(dt,wr)|0,A=A+Math.imul(Ut,mr)|0,U=U+Math.imul(Ut,wr)|0,P=P+Math.imul(Qe,br)|0,A=A+Math.imul(Qe,_r)|0,A=A+Math.imul(ot,br)|0,U=U+Math.imul(ot,_r)|0,P=P+Math.imul(Fe,Ar)|0,A=A+Math.imul(Fe,vr)|0,A=A+Math.imul(Be,Ar)|0,U=U+Math.imul(Be,vr)|0;var Xh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Xh>>>26)|0,Xh&=67108863,P=Math.imul(v,hr),A=Math.imul(v,dr),A=A+Math.imul($,hr)|0,U=Math.imul($,dr),P=P+Math.imul(Dt,ar)|0,A=A+Math.imul(Dt,pr)|0,A=A+Math.imul(N,ar)|0,U=U+Math.imul(N,pr)|0,P=P+Math.imul(xt,cr)|0,A=A+Math.imul(xt,gr)|0,A=A+Math.imul(Bt,cr)|0,U=U+Math.imul(Bt,gr)|0,P=P+Math.imul(pt,Jt)|0,A=A+Math.imul(pt,yr)|0,A=A+Math.imul(St,Jt)|0,U=U+Math.imul(St,yr)|0,P=P+Math.imul(It,mr)|0,A=A+Math.imul(It,wr)|0,A=A+Math.imul(Ct,mr)|0,U=U+Math.imul(Ct,wr)|0,P=P+Math.imul(dt,br)|0,A=A+Math.imul(dt,_r)|0,A=A+Math.imul(Ut,br)|0,U=U+Math.imul(Ut,_r)|0,P=P+Math.imul(Qe,Ar)|0,A=A+Math.imul(Qe,vr)|0,A=A+Math.imul(ot,Ar)|0,U=U+Math.imul(ot,vr)|0;var ed=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ed>>>26)|0,ed&=67108863,P=Math.imul(v,ar),A=Math.imul(v,pr),A=A+Math.imul($,ar)|0,U=Math.imul($,pr),P=P+Math.imul(Dt,cr)|0,A=A+Math.imul(Dt,gr)|0,A=A+Math.imul(N,cr)|0,U=U+Math.imul(N,gr)|0,P=P+Math.imul(xt,Jt)|0,A=A+Math.imul(xt,yr)|0,A=A+Math.imul(Bt,Jt)|0,U=U+Math.imul(Bt,yr)|0,P=P+Math.imul(pt,mr)|0,A=A+Math.imul(pt,wr)|0,A=A+Math.imul(St,mr)|0,U=U+Math.imul(St,wr)|0,P=P+Math.imul(It,br)|0,A=A+Math.imul(It,_r)|0,A=A+Math.imul(Ct,br)|0,U=U+Math.imul(Ct,_r)|0,P=P+Math.imul(dt,Ar)|0,A=A+Math.imul(dt,vr)|0,A=A+Math.imul(Ut,Ar)|0,U=U+Math.imul(Ut,vr)|0;var Fl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,P=Math.imul(v,cr),A=Math.imul(v,gr),A=A+Math.imul($,cr)|0,U=Math.imul($,gr),P=P+Math.imul(Dt,Jt)|0,A=A+Math.imul(Dt,yr)|0,A=A+Math.imul(N,Jt)|0,U=U+Math.imul(N,yr)|0,P=P+Math.imul(xt,mr)|0,A=A+Math.imul(xt,wr)|0,A=A+Math.imul(Bt,mr)|0,U=U+Math.imul(Bt,wr)|0,P=P+Math.imul(pt,br)|0,A=A+Math.imul(pt,_r)|0,A=A+Math.imul(St,br)|0,U=U+Math.imul(St,_r)|0,P=P+Math.imul(It,Ar)|0,A=A+Math.imul(It,vr)|0,A=A+Math.imul(Ct,Ar)|0,U=U+Math.imul(Ct,vr)|0;var td=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(td>>>26)|0,td&=67108863,P=Math.imul(v,Jt),A=Math.imul(v,yr),A=A+Math.imul($,Jt)|0,U=Math.imul($,yr),P=P+Math.imul(Dt,mr)|0,A=A+Math.imul(Dt,wr)|0,A=A+Math.imul(N,mr)|0,U=U+Math.imul(N,wr)|0,P=P+Math.imul(xt,br)|0,A=A+Math.imul(xt,_r)|0,A=A+Math.imul(Bt,br)|0,U=U+Math.imul(Bt,_r)|0,P=P+Math.imul(pt,Ar)|0,A=A+Math.imul(pt,vr)|0,A=A+Math.imul(St,Ar)|0,U=U+Math.imul(St,vr)|0;var rd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(rd>>>26)|0,rd&=67108863,P=Math.imul(v,mr),A=Math.imul(v,wr),A=A+Math.imul($,mr)|0,U=Math.imul($,wr),P=P+Math.imul(Dt,br)|0,A=A+Math.imul(Dt,_r)|0,A=A+Math.imul(N,br)|0,U=U+Math.imul(N,_r)|0,P=P+Math.imul(xt,Ar)|0,A=A+Math.imul(xt,vr)|0,A=A+Math.imul(Bt,Ar)|0,U=U+Math.imul(Bt,vr)|0;var nd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(nd>>>26)|0,nd&=67108863,P=Math.imul(v,br),A=Math.imul(v,_r),A=A+Math.imul($,br)|0,U=Math.imul($,_r),P=P+Math.imul(Dt,Ar)|0,A=A+Math.imul(Dt,vr)|0,A=A+Math.imul(N,Ar)|0,U=U+Math.imul(N,vr)|0;var id=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(id>>>26)|0,id&=67108863,P=Math.imul(v,Ar),A=Math.imul(v,vr),A=A+Math.imul($,Ar)|0,U=Math.imul($,vr);var aa=(G+P|0)+((A&8191)<<13)|0;return G=(U+(A>>>13)|0)+(aa>>>26)|0,aa&=67108863,M[0]=Kh,M[1]=Dl,M[2]=Wh,M[3]=qh,M[4]=Zh,M[5]=Qh,M[6]=$l,M[7]=Yh,M[8]=so,M[9]=Jh,M[10]=Li,M[11]=Xh,M[12]=ed,M[13]=Fl,M[14]=td,M[15]=rd,M[16]=nd,M[17]=id,M[18]=aa,G!==0&&(M[19]=G,E.length++),E};Math.imul||(H=C);function D(B,p,m){m.negative=p.negative^B.negative,m.length=B.length+p.length;for(var E=0,k=0,O=0;O<m.length-1;O++){var M=k;k=0;for(var G=E&67108863,P=Math.min(O,p.length-1),A=Math.max(0,O-B.length+1);A<=P;A++){var U=O-A,le=B.words[U]|0,te=p.words[A]|0,re=le*te,he=re&67108863;M=M+(re/67108864|0)|0,he=he+G|0,G=he&67108863,M=M+(he>>>26)|0,k+=M>>>26,M&=67108863}m.words[O]=G,E=M,M=k}return E!==0?m.words[O]=E:m.length--,m._strip()}function z(B,p,m){return D(B,p,m)}s.prototype.mulTo=function(p,m){var E,k=this.length+p.length;return this.length===10&&p.length===10?E=H(this,p,m):k<63?E=C(this,p,m):k<1024?E=D(this,p,m):E=z(this,p,m),E},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),z(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),n(typeof p=="number"),n(p<67108864);for(var E=0,k=0;k<this.length;k++){var O=(this.words[k]|0)*p,M=(O&67108863)+(E&67108863);E>>=26,E+=O/67108864|0,E+=M>>>26,this.words[k]=M&67108863}return E!==0&&(this.words[k]=E,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=x(p);if(m.length===0)return new s(1);for(var E=this,k=0;k<m.length&&m[k]===0;k++,E=E.sqr());if(++k<m.length)for(var O=E.sqr();k<m.length;k++,O=O.sqr())m[k]!==0&&(E=E.mul(O));return E},s.prototype.iushln=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=67108863>>>26-m<<26-m,O;if(m!==0){var M=0;for(O=0;O<this.length;O++){var G=this.words[O]&k,P=(this.words[O]|0)-G<<m;this.words[O]=P|M,M=G>>>26-m}M&&(this.words[O]=M,this.length++)}if(E!==0){for(O=this.length-1;O>=0;O--)this.words[O+E]=this.words[O];for(O=0;O<E;O++)this.words[O]=0;this.length+=E}return this._strip()},s.prototype.ishln=function(p){return n(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,E){n(typeof p=="number"&&p>=0);var k;m?k=(m-m%26)/26:k=0;var O=p%26,M=Math.min((p-O)/26,this.length),G=67108863^67108863>>>O<<O,P=E;if(k-=M,k=Math.max(0,k),P){for(var A=0;A<M;A++)P.words[A]=this.words[A];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,A=0;A<this.length;A++)this.words[A]=this.words[A+M];else this.words[0]=0,this.length=1;var U=0;for(A=this.length-1;A>=0&&(U!==0||A>=k);A--){var le=this.words[A]|0;this.words[A]=U<<26-O|le>>>O,U=le&G}return P&&U!==0&&(P.words[P.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,E){return n(this.negative===0),this.iushrn(p,m,E)},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){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return!1;var O=this.words[E];return!!(O&k)},s.prototype.imaskn=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(m!==0&&E++,this.length=Math.min(E,this.length),m!==0){var k=67108863^67108863>>>m<<m;this.words[this.length-1]&=k}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return n(typeof p=="number"),n(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(n(typeof p=="number"),n(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,E){var k=p.length+E,O;this._expand(k);var M,G=0;for(O=0;O<p.length;O++){M=(this.words[O+E]|0)+G;var P=(p.words[O]|0)*m;M-=P&67108863,G=(M>>26)-(P/67108864|0),this.words[O+E]=M&67108863}for(;O<this.length-E;O++)M=(this.words[O+E]|0)+G,G=M>>26,this.words[O+E]=M&67108863;if(G===0)return this._strip();for(n(G===-1),G=0,O=0;O<this.length;O++)M=-(this.words[O]|0)+G,G=M>>26,this.words[O]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var E=this.length-p.length,k=this.clone(),O=p,M=O.words[O.length-1]|0,G=this._countBits(M);E=26-G,E!==0&&(O=O.ushln(E),k.iushln(E),M=O.words[O.length-1]|0);var P=k.length-O.length,A;if(m!=="mod"){A=new s(null),A.length=P+1,A.words=new Array(A.length);for(var U=0;U<A.length;U++)A.words[U]=0}var le=k.clone()._ishlnsubmul(O,1,P);le.negative===0&&(k=le,A&&(A.words[P]=1));for(var te=P-1;te>=0;te--){var re=(k.words[O.length+te]|0)*67108864+(k.words[O.length+te-1]|0);for(re=Math.min(re/M|0,67108863),k._ishlnsubmul(O,re,te);k.negative!==0;)re--,k.negative=0,k._ishlnsubmul(O,1,te),k.isZero()||(k.negative^=1);A&&(A.words[te]=re)}return A&&A._strip(),k._strip(),m!=="div"&&E!==0&&k.iushrn(E),{div:A||null,mod:k}},s.prototype.divmod=function(p,m,E){if(n(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,O,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(k=M.div.neg()),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.iadd(p)),{div:k,mod:O}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(k=M.div.neg()),{div:k,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.isub(p)),{div:M.div,mod:O}):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 E=m.div.negative!==0?m.mod.isub(p):m.mod,k=p.ushrn(1),O=p.andln(1),M=E.cmp(k);return M<0||O===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),n(p<=67108863);for(var E=(1<<26)%p,k=0,O=this.length-1;O>=0;O--)k=(E*k+(this.words[O]|0))%p;return m?-k:k},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),n(p<=67108863);for(var E=0,k=this.length-1;k>=0;k--){var O=(this.words[k]|0)+E*67108864;this.words[k]=O/p|0,E=O%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=new s(0),G=new s(1),P=0;m.isEven()&&E.isEven();)m.iushrn(1),E.iushrn(1),++P;for(var A=E.clone(),U=m.clone();!m.isZero();){for(var le=0,te=1;!(m.words[0]&te)&&le<26;++le,te<<=1);if(le>0)for(m.iushrn(le);le-- >0;)(k.isOdd()||O.isOdd())&&(k.iadd(A),O.isub(U)),k.iushrn(1),O.iushrn(1);for(var re=0,he=1;!(E.words[0]&he)&&re<26;++re,he<<=1);if(re>0)for(E.iushrn(re);re-- >0;)(M.isOdd()||G.isOdd())&&(M.iadd(A),G.isub(U)),M.iushrn(1),G.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(M),O.isub(G)):(E.isub(m),M.isub(k),G.isub(O))}return{a:M,b:G,gcd:E.iushln(P)}},s.prototype._invmp=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=E.clone();m.cmpn(1)>0&&E.cmpn(1)>0;){for(var G=0,P=1;!(m.words[0]&P)&&G<26;++G,P<<=1);if(G>0)for(m.iushrn(G);G-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);for(var A=0,U=1;!(E.words[0]&U)&&A<26;++A,U<<=1);if(A>0)for(E.iushrn(A);A-- >0;)O.isOdd()&&O.iadd(M),O.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(O)):(E.isub(m),O.isub(k))}var le;return m.cmpn(1)===0?le=k:le=O,le.cmpn(0)<0&&le.iadd(p),le},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),E=p.clone();m.negative=0,E.negative=0;for(var k=0;m.isEven()&&E.isEven();k++)m.iushrn(1),E.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;E.isEven();)E.iushrn(1);var O=m.cmp(E);if(O<0){var M=m;m=E,E=M}else if(O===0||E.cmpn(1)===0)break;m.isub(E)}while(!0);return E.iushln(k)},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){n(typeof p=="number");var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return this._expand(E+1),this.words[E]|=k,this;for(var O=k,M=E;O!==0&&M<this.length;M++){var G=this.words[M]|0;G+=O,O=G>>>26,G&=67108863,this.words[M]=G}return O!==0&&(this.words[M]=O,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 E;if(this.length>1)E=1;else{m&&(p=-p),n(p<=67108863,"Number is too big");var k=this.words[0]|0;E=k===p?0:k<p?-1:1}return this.negative!==0?-E|0:E},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,E=this.length-1;E>=0;E--){var k=this.words[E]|0,O=p.words[E]|0;if(k!==O){k<O?m=-1:k>O&&(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 ie(p)},s.prototype.toRed=function(p){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return n(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 n(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return n(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 Z(B,p){this.name=B,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()}Z.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},Z.prototype.ireduce=function(p){var m=p,E;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),E=m.bitLength();while(E>this.n);var k=E<this.n?-1:m.ucmp(this.p);return k===0?(m.words[0]=0,m.length=1):k>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},Z.prototype.split=function(p,m){p.iushrn(this.n,0,m)},Z.prototype.imulK=function(p){return p.imul(this.k)};function V(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(V,Z),V.prototype.split=function(p,m){for(var E=4194303,k=Math.min(p.length,9),O=0;O<k;O++)m.words[O]=p.words[O];if(m.length=k,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&E,O=10;O<p.length;O++){var G=p.words[O]|0;p.words[O-10]=(G&E)<<4|M>>>22,M=G}M>>>=22,p.words[O-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},V.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,E=0;E<p.length;E++){var k=p.words[E]|0;m+=k*977,p.words[E]=m&67108863,m=k*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function K(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(K,Z);function oe(){Z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(oe,Z);function ce(){Z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ce,Z),ce.prototype.imulK=function(p){for(var m=0,E=0;E<p.length;E++){var k=(p.words[E]|0)*19+m,O=k&67108863;k>>>=26,p.words[E]=O,m=k}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 V;else if(p==="p224")m=new K;else if(p==="p192")m=new oe;else if(p==="p25519")m=new ce;else throw new Error("Unknown prime "+p);return W[p]=m,m};function ie(B){if(typeof B=="string"){var p=s._prime(B);this.m=p.p,this.prime=p}else n(B.gtn(1),"modulus must be greater than 1"),this.m=B,this.prime=null}ie.prototype._verify1=function(p){n(p.negative===0,"red works only with positives"),n(p.red,"red works only with red numbers")},ie.prototype._verify2=function(p,m){n((p.negative|m.negative)===0,"red works only with positives"),n(p.red&&p.red===m.red,"red works only with red numbers")},ie.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},ie.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},ie.prototype.add=function(p,m){this._verify2(p,m);var E=p.add(m);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},ie.prototype.iadd=function(p,m){this._verify2(p,m);var E=p.iadd(m);return E.cmp(this.m)>=0&&E.isub(this.m),E},ie.prototype.sub=function(p,m){this._verify2(p,m);var E=p.sub(m);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},ie.prototype.isub=function(p,m){this._verify2(p,m);var E=p.isub(m);return E.cmpn(0)<0&&E.iadd(this.m),E},ie.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},ie.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},ie.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},ie.prototype.isqr=function(p){return this.imul(p,p.clone())},ie.prototype.sqr=function(p){return this.mul(p,p)},ie.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(n(m%2===1),m===3){var E=this.m.add(new s(1)).iushrn(2);return this.pow(p,E)}for(var k=this.m.subn(1),O=0;!k.isZero()&&k.andln(1)===0;)O++,k.iushrn(1);n(!k.isZero());var M=new s(1).toRed(this),G=M.redNeg(),P=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new s(2*A*A).toRed(this);this.pow(A,P).cmp(G)!==0;)A.redIAdd(G);for(var U=this.pow(A,k),le=this.pow(p,k.addn(1).iushrn(1)),te=this.pow(p,k),re=O;te.cmp(M)!==0;){for(var he=te,ye=0;he.cmp(M)!==0;ye++)he=he.redSqr();n(ye<re);var be=this.pow(U,new s(1).iushln(re-ye-1));le=le.redMul(be),U=be.redSqr(),te=te.redMul(U),re=ye}return le},ie.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},ie.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var E=4,k=new Array(1<<E);k[0]=new s(1).toRed(this),k[1]=p;for(var O=2;O<k.length;O++)k[O]=this.mul(k[O-1],p);var M=k[0],G=0,P=0,A=m.bitLength()%26;for(A===0&&(A=26),O=m.length-1;O>=0;O--){for(var U=m.words[O],le=A-1;le>=0;le--){var te=U>>le&1;if(M!==k[0]&&(M=this.sqr(M)),te===0&&G===0){P=0;continue}G<<=1,G|=te,P++,!(P!==E&&(O!==0||le!==0))&&(M=this.mul(M,k[G]),P=0,G=0)}A=26}return M},ie.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},ie.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ue(p)};function ue(B){ie.call(this,B),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(ue,ie),ue.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ue.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ue.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var E=p.imul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var E=p.mul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(r,ut)}(Zy);var Yy=Zy.exports;const vs=xn(Yy);function t0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function CG(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function vf(r,...e){if(!CG(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function BG(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");t0(r.outputLen),t0(r.blockLen)}function Qc(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function JE(r,e){vf(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Yc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function PG(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Jy(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function zi(r,e){return r<<32-e|r>>>e}const XE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function MG(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function e2(r){for(let e=0;e<r.length;e++)r[e]=MG(r[e])}function LG(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function r0(r){return typeof r=="string"&&(r=LG(r)),vf(r),r}function UG(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];vf(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}let Xy=class{clone(){return this._cloneInto()}};function em(r){const e=n=>r().update(r0(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function t2(r=32){if(Yc&&typeof Yc.getRandomValues=="function")return Yc.getRandomValues(new Uint8Array(r));if(Yc&&typeof Yc.randomBytes=="function")return Yc.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function DG(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}function $G(r,e,t){return r&e^~r&t}function FG(r,e,t){return r&e^r&t^e&t}class r2 extends Xy{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Jy(this.buffer)}update(e){Qc(this);const{view:t,buffer:n,blockLen:i}=this;e=r0(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Jy(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qc(this),JE(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;DG(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Jy(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const n0=BigInt(2**32-1),tm=BigInt(32);function n2(r,e=!1){return e?{h:Number(r&n0),l:Number(r>>tm&n0)}:{h:Number(r>>tm&n0)|0,l:Number(r&n0)|0}}function i2(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=n2(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const HG=(r,e)=>BigInt(r>>>0)<<tm|BigInt(e>>>0),zG=(r,e,t)=>r>>>t,GG=(r,e,t)=>r<<32-t|e>>>t,VG=(r,e,t)=>r>>>t|e<<32-t,jG=(r,e,t)=>r<<32-t|e>>>t,KG=(r,e,t)=>r<<64-t|e>>>t-32,WG=(r,e,t)=>r>>>t-32|e<<64-t,qG=(r,e)=>e,ZG=(r,e)=>r,s2=(r,e,t)=>r<<t|e>>>32-t,o2=(r,e,t)=>e<<t|r>>>32-t,a2=(r,e,t)=>e<<t-32|r>>>64-t,c2=(r,e,t)=>r<<t-32|e>>>64-t;function QG(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const rt={fromBig:n2,split:i2,toBig:HG,shrSH:zG,shrSL:GG,rotrSH:VG,rotrSL:jG,rotrBH:KG,rotrBL:WG,rotr32H:qG,rotr32L:ZG,rotlSH:s2,rotlSL:o2,rotlBH:a2,rotlBL:c2,add:QG,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,add5H:(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,add5L:(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0)},[YG,JG]=rt.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(r=>BigInt(r))),fo=new Uint32Array(80),ho=new Uint32Array(80);let XG=class extends r2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)fo[D]=e.getUint32(t),ho[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=fo[D-15]|0,W=ho[D-15]|0,Z=rt.rotrSH(z,W,1)^rt.rotrSH(z,W,8)^rt.shrSH(z,W,7),V=rt.rotrSL(z,W,1)^rt.rotrSL(z,W,8)^rt.shrSL(z,W,7),K=fo[D-2]|0,oe=ho[D-2]|0,ce=rt.rotrSH(K,oe,19)^rt.rotrBH(K,oe,61)^rt.shrSH(K,oe,6),ie=rt.rotrSL(K,oe,19)^rt.rotrBL(K,oe,61)^rt.shrSL(K,oe,6),ue=rt.add4L(V,ie,ho[D-7],ho[D-16]),B=rt.add4H(ue,Z,ce,fo[D-7],fo[D-16]);fo[D]=B|0,ho[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=rt.rotrSH(g,b,14)^rt.rotrSH(g,b,18)^rt.rotrBH(g,b,41),W=rt.rotrSL(g,b,14)^rt.rotrSL(g,b,18)^rt.rotrBL(g,b,41),Z=g&w^~g&S,V=b&I^~b&x,K=rt.add5L(H,W,V,JG[D],ho[D]),oe=rt.add5H(K,C,z,Z,YG[D],fo[D]),ce=K|0,ie=rt.rotrSH(n,i,28)^rt.rotrBH(n,i,34)^rt.rotrBH(n,i,39),ue=rt.rotrSL(n,i,28)^rt.rotrBL(n,i,34)^rt.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=rt.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=rt.add3L(ce,ue,p);n=rt.add3H(m,oe,ie,B),i=m|0}({h:n,l:i}=rt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=rt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=rt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=rt.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=rt.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=rt.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=rt.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=rt.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){fo.fill(0),ho.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 eV=em(()=>new XG);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const i0=BigInt(0),s0=BigInt(1),tV=BigInt(2);function ma(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ef(r){if(!ma(r))throw new Error("Uint8Array expected")}function Es(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}const rV=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function wa(r){Ef(r);let e="";for(let t=0;t<r.length;t++)e+=rV[r[t]];return e}function Jc(r){const e=r.toString(16);return e.length&1?"0"+e:e}function rm(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?i0:BigInt("0x"+r)}const xs={_0:48,_9:57,A:65,F:70,a:97,f:102};function u2(r){if(r>=xs._0&&r<=xs._9)return r-xs._0;if(r>=xs.A&&r<=xs.F)return r-(xs.A-10);if(r>=xs.a&&r<=xs.f)return r-(xs.a-10)}function Xc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const o=u2(r.charCodeAt(s)),a=u2(r.charCodeAt(s+1));if(o===void 0||a===void 0){const u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+a}return n}function ba(r){return rm(wa(r))}function eu(r){return Ef(r),rm(wa(Uint8Array.from(r).reverse()))}function tu(r,e){return Xc(r.toString(16).padStart(e*2,"0"))}function xf(r,e){return tu(r,e).reverse()}function nV(r){return Xc(Jc(r))}function Tr(r,e,t){let n;if(typeof e=="string")try{n=Xc(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ma(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function _a(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];Ef(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}function iV(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function sV(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}const nm=r=>typeof r=="bigint"&&i0<=r;function o0(r,e,t){return nm(r)&&nm(e)&&nm(t)&&e<=r&&r<t}function ri(r,e,t,n){if(!o0(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function l2(r){let e;for(e=0;r>i0;r>>=s0,e+=1);return e}function oV(r,e){return r>>BigInt(e)&s0}function aV(r,e,t){return r|(t?s0:i0)<<BigInt(e)}const im=r=>(tV<<BigInt(r-1))-s0,sm=r=>new Uint8Array(r),f2=r=>Uint8Array.from(r);function h2(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=sm(r),i=sm(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=sm())=>{i=a(f2([0]),g),n=a(),g.length!==0&&(i=a(f2([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return _a(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const cV={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ma(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ru(r,e,t={}){const n=(i,s,o)=>{const a=cV[s];if(typeof a!="function")throw new Error("invalid validator function");const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const uV=()=>{throw new Error("not implemented")};function Rf(r){const e=new WeakMap;return(t,...n)=>{const i=e.get(t);if(i!==void 0)return i;const s=r(t,...n);return e.set(t,s),s}}const lV=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ri,abool:Es,abytes:Ef,bitGet:oV,bitLen:l2,bitMask:im,bitSet:aV,bytesToHex:wa,bytesToNumberBE:ba,bytesToNumberLE:eu,concatBytes:_a,createHmacDrbg:h2,ensureBytes:Tr,equalBytes:iV,hexToBytes:Xc,hexToNumber:rm,inRange:o0,isBytes:ma,memoized:Rf,notImplemented:uV,numberToBytesBE:tu,numberToBytesLE:xf,numberToHexUnpadded:Jc,numberToVarBytesBE:nV,utf8ToBytes:sV,validateObject:ru},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mr=BigInt(0),tr=BigInt(1),Aa=BigInt(2),fV=BigInt(3),om=BigInt(4),d2=BigInt(5),p2=BigInt(8);function Zt(r,e){const t=r%e;return t>=Mr?t:e+t}function hV(r,e,t){if(e<Mr)throw new Error("invalid exponent, negatives unsupported");if(t<=Mr)throw new Error("invalid modulus");if(t===tr)return Mr;let n=tr;for(;e>Mr;)e&tr&&(n=n*r%t),r=r*r%t,e>>=tr;return n}function ur(r,e,t){let n=r;for(;e-- >Mr;)n*=n,n%=t;return n}function am(r,e){if(r===Mr)throw new Error("invert: expected non-zero number");if(e<=Mr)throw new Error("invert: expected positive modulus, got "+e);let t=Zt(r,e),n=e,i=Mr,s=tr;for(;t!==Mr;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==tr)throw new Error("invert: does not exist");return Zt(i,e)}function dV(r){const e=(r-tr)/Aa;let t,n,i;for(t=r-tr,n=0;t%Aa===Mr;t/=Aa,n++);for(i=Aa;i<r&&hV(i,e,r)!==r-tr;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(r+tr)/om;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+tr)/Aa;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,tr<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function pV(r){if(r%om===fV){const e=(r+tr)/om;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%p2===d2){const e=(r-d2)/p2;return function(n,i){const s=n.mul(i,Aa),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,Aa),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return dV(r)}const gV=(r,e)=>(Zt(r,e)&tr)===tr,yV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function mV(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=yV.reduce((n,i)=>(n[i]="function",n),e);return ru(r,t)}function wV(r,e,t){if(t<Mr)throw new Error("invalid exponent, negatives unsupported");if(t===Mr)return r.ONE;if(t===tr)return e;let n=r.ONE,i=e;for(;t>Mr;)t&tr&&(n=r.mul(n,i)),i=r.sqr(i),t>>=tr;return n}function bV(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function g2(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function a0(r,e,t=!1,n={}){if(r<=Mr)throw new Error("invalid field: expected ORDER > 0, got "+r);const{nBitLength:i,nByteLength:s}=g2(r,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:s,MASK:im(i),ZERO:Mr,ONE:tr,create:u=>Zt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Mr<=u&&u<r},is0:u=>u===Mr,isOdd:u=>(u&tr)===tr,neg:u=>Zt(-u,r),eql:(u,l)=>u===l,sqr:u=>Zt(u*u,r),add:(u,l)=>Zt(u+l,r),sub:(u,l)=>Zt(u-l,r),mul:(u,l)=>Zt(u*l,r),pow:(u,l)=>wV(a,u,l),div:(u,l)=>Zt(u*am(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>am(u,r),sqrt:n.sqrt||(u=>(o||(o=pV(r)),o(a,u))),invertBatch:u=>bV(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?xf(u,s):tu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?eu(u):ba(u)}});return Object.freeze(a)}function y2(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function m2(r){const e=y2(r);return e+Math.ceil(e/2)}function _V(r,e,t=!1){const n=r.length,i=y2(e),s=m2(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=t?eu(r):ba(r),a=Zt(o,e-tr)+tr;return t?xf(a,i):tu(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const w2=BigInt(0),c0=BigInt(1);function cm(r,e){const t=e.negate();return r?t:e}function b2(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function um(r,e){b2(r,e);const t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function AV(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function vV(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}const lm=new WeakMap,_2=new WeakMap;function fm(r){return _2.get(r)||1}function A2(r,e){return{constTimeNegate:cm,hasPrecomputes(t){return fm(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>w2;)n&c0&&(i=i.add(s)),s=s.double(),n>>=c0;return i},precomputeWindow(t,n){const{windows:i,windowSize:s}=um(n,e),o=[];let a=t,u=a;for(let l=0;l<i;l++){u=a,o.push(u);for(let h=1;h<s;h++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(t,n,i){const{windows:s,windowSize:o}=um(t,e);let a=r.ZERO,u=r.BASE;const l=BigInt(2**t-1),h=2**t,g=BigInt(t);for(let b=0;b<s;b++){const w=b*o;let I=Number(i&l);i>>=g,I>o&&(I-=h,i+=c0);const S=w,x=w+Math.abs(I)-1,C=b%2!==0,H=I<0;I===0?u=u.add(cm(C,n[S])):a=a.add(cm(H,n[x]))}return{p:a,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){const{windows:o,windowSize:a}=um(t,e),u=BigInt(2**t-1),l=2**t,h=BigInt(t);for(let g=0;g<o;g++){const b=g*a;if(i===w2)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=l,i+=c0),w===0)continue;let I=n[b+Math.abs(w)-1];w<0&&(I=I.negate()),s=s.add(I)}return s},getPrecomputes(t,n,i){let s=lm.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&lm.set(n,i(s))),s},wNAFCached(t,n,i){const s=fm(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){const o=fm(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){b2(n,e),_2.set(t,n),lm.delete(t)}}}function v2(r,e,t,n){if(AV(t,r),vV(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=r.ZERO,s=l2(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,u=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let h=i;for(let g=l;g>=0;g-=o){u.fill(i);for(let w=0;w<n.length;w++){const I=n[w],S=Number(I>>BigInt(g)&BigInt(a));u[S]=u[S].add(t[w])}let b=i;for(let w=u.length-1,I=i;w>0;w--)I=I.add(u[w]),b=b.add(I);if(h=h.add(b),g!==0)for(let w=0;w<o;w++)h=h.double()}return h}function hm(r){return mV(r.Fp),ru(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...g2(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _i=BigInt(0),Sn=BigInt(1),u0=BigInt(2),EV=BigInt(8),xV={zip215:!0};function RV(r){const e=hm(r);return ru(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function IV(r){const e=RV(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=e,l=u0<<BigInt(a*8)-Sn,h=t.create,g=a0(e.n,e.nBitLength),b=e.uvRatio||((E,k)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(k))}}catch{return{isValid:!1,value:_i}}}),w=e.adjustScalarBytes||(E=>E),I=e.domain||((E,k,O)=>{if(Es("phflag",O),k.length||O)throw new Error("Contexts/pre-hash are not supported");return E});function S(E,k){ri("coordinate "+E,k,_i,l)}function x(E){if(!(E instanceof D))throw new Error("ExtendedPoint expected")}const C=Rf((E,k)=>{const{ex:O,ey:M,ez:G}=E,P=E.is0();k==null&&(k=P?EV:t.inv(G));const A=h(O*k),U=h(M*k),le=h(G*k);if(P)return{x:_i,y:Sn};if(le!==Sn)throw new Error("invZ was invalid");return{x:A,y:U}}),H=Rf(E=>{const{a:k,d:O}=e;if(E.is0())throw new Error("bad point: ZERO");const{ex:M,ey:G,ez:P,et:A}=E,U=h(M*M),le=h(G*G),te=h(P*P),re=h(te*te),he=h(U*k),ye=h(te*h(he+le)),be=h(re+h(O*h(U*le)));if(ye!==be)throw new Error("bad point: equation left != right (1)");const Ke=h(M*G),Fe=h(P*A);if(Ke!==Fe)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(k,O,M,G){this.ex=k,this.ey=O,this.ez=M,this.et=G,S("x",k),S("y",O),S("z",M),S("t",G),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof D)throw new Error("extended point not allowed");const{x:O,y:M}=k||{};return S("x",O),S("y",M),new D(O,M,Sn,h(O*M))}static normalizeZ(k){const O=t.invertBatch(k.map(M=>M.ez));return k.map((M,G)=>M.toAffine(O[G])).map(D.fromAffine)}static msm(k,O){return v2(D,g,k,O)}_setWindowSize(k){Z.setWindowSize(this,k)}assertValidity(){H(this)}equals(k){x(k);const{ex:O,ey:M,ez:G}=this,{ex:P,ey:A,ez:U}=k,le=h(O*U),te=h(P*G),re=h(M*U),he=h(A*G);return le===te&&re===he}is0(){return this.equals(D.ZERO)}negate(){return new D(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:k}=e,{ex:O,ey:M,ez:G}=this,P=h(O*O),A=h(M*M),U=h(u0*h(G*G)),le=h(k*P),te=O+M,re=h(h(te*te)-P-A),he=le+A,ye=he-U,be=le-A,Ke=h(re*ye),Fe=h(he*be),Be=h(re*be),et=h(ye*he);return new D(Ke,Fe,et,Be)}add(k){x(k);const{a:O,d:M}=e,{ex:G,ey:P,ez:A,et:U}=this,{ex:le,ey:te,ez:re,et:he}=k;if(O===BigInt(-1)){const It=h((P-G)*(te+le)),Ct=h((P+G)*(te-le)),kr=h(Ct-It);if(kr===_i)return this.double();const pt=h(A*u0*he),St=h(U*u0*re),or=St+pt,xt=Ct+It,Bt=St-pt,fn=h(or*kr),Dt=h(xt*Bt),N=h(or*Bt),_=h(kr*xt);return new D(fn,Dt,_,N)}const ye=h(G*le),be=h(P*te),Ke=h(U*M*he),Fe=h(A*re),Be=h((G+P)*(le+te)-ye-be),et=Fe-Ke,Qe=Fe+Ke,ot=h(be-O*ye),sr=h(Be*et),dt=h(Qe*ot),Ut=h(Be*ot),oa=h(et*Qe);return new D(sr,dt,oa,Ut)}subtract(k){return this.add(k.negate())}wNAF(k){return Z.wNAFCached(this,k,D.normalizeZ)}multiply(k){const O=k;ri("scalar",O,Sn,n);const{p:M,f:G}=this.wNAF(O);return D.normalizeZ([M,G])[0]}multiplyUnsafe(k,O=D.ZERO){const M=k;return ri("scalar",M,_i,n),M===_i?W:this.is0()||M===Sn?this:Z.wNAFCachedUnsafe(this,M,D.normalizeZ,O)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Z.unsafeLadder(this,n).is0()}toAffine(k){return C(this,k)}clearCofactor(){const{h:k}=e;return k===Sn?this:this.multiplyUnsafe(k)}static fromHex(k,O=!1){const{d:M,a:G}=e,P=t.BYTES;k=Tr("pointHex",k,P),Es("zip215",O);const A=k.slice(),U=k[P-1];A[P-1]=U&-129;const le=eu(A),te=O?l:t.ORDER;ri("pointHex.y",le,_i,te);const re=h(le*le),he=h(re-Sn),ye=h(M*re-G);let{isValid:be,value:Ke}=b(he,ye);if(!be)throw new Error("Point.fromHex: invalid y coordinate");const Fe=(Ke&Sn)===Sn,Be=(U&128)!==0;if(!O&&Ke===_i&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==Fe&&(Ke=h(-Ke)),D.fromAffine({x:Ke,y:le})}static fromPrivateKey(k){return oe(k).point}toRawBytes(){const{x:k,y:O}=this.toAffine(),M=xf(O,t.BYTES);return M[M.length-1]|=k&Sn?128:0,M}toHex(){return wa(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,Sn,h(e.Gx*e.Gy)),D.ZERO=new D(_i,Sn,Sn,_i);const{BASE:z,ZERO:W}=D,Z=A2(D,a*8);function V(E){return Zt(E,n)}function K(E){return V(eu(E))}function oe(E){const k=t.BYTES;E=Tr("private key",E,k);const O=Tr("hashed private key",s(E),2*k),M=w(O.slice(0,k)),G=O.slice(k,2*k),P=K(M),A=z.multiply(P),U=A.toRawBytes();return{head:M,prefix:G,scalar:P,point:A,pointBytes:U}}function ce(E){return oe(E).pointBytes}function ie(E=new Uint8Array,...k){const O=_a(...k);return K(s(I(O,Tr("context",E),!!i)))}function ue(E,k,O={}){E=Tr("message",E),i&&(E=i(E));const{prefix:M,scalar:G,pointBytes:P}=oe(k),A=ie(O.context,M,E),U=z.multiply(A).toRawBytes(),le=ie(O.context,U,P,E),te=V(A+le*G);ri("signature.s",te,_i,n);const re=_a(U,xf(te,t.BYTES));return Tr("result",re,t.BYTES*2)}const B=xV;function p(E,k,O,M=B){const{context:G,zip215:P}=M,A=t.BYTES;E=Tr("signature",E,2*A),k=Tr("message",k),O=Tr("publicKey",O,A),P!==void 0&&Es("zip215",P),i&&(k=i(k));const U=eu(E.slice(A,2*A));let le,te,re;try{le=D.fromHex(O,P),te=D.fromHex(E.slice(0,A),P),re=z.multiplyUnsafe(U)}catch{return!1}if(!P&&le.isSmallOrder())return!1;const he=ie(G,te.toRawBytes(),le.toRawBytes(),k);return te.add(le.multiplyUnsafe(he)).subtract(re).clearCofactor().equals(D.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:ue,verify:p,ExtendedPoint:D,utils:{getExtendedPublicKey:oe,randomPrivateKey:()=>o(t.BYTES),precompute(E=8,k=D.BASE){return k._setWindowSize(E),k.multiply(BigInt(3)),k}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dm=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),E2=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const SV=BigInt(1),x2=BigInt(2);BigInt(3);const kV=BigInt(5),TV=BigInt(8);function OV(r){const e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=dm,a=r*r%s*r%s,u=ur(a,x2,s)*a%s,l=ur(u,SV,s)*r%s,h=ur(l,kV,s)*l%s,g=ur(h,e,s)*h%s,b=ur(g,t,s)*g%s,w=ur(b,n,s)*b%s,I=ur(w,i,s)*w%s,S=ur(I,i,s)*w%s,x=ur(S,e,s)*h%s;return{pow_p_5_8:ur(x,x2,s)*r%s,b2:a}}function NV(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function CV(r,e){const t=dm,n=Zt(e*e*e,t),i=Zt(n*n*e,t),s=OV(r*i).pow_p_5_8;let o=Zt(r*n*s,t);const a=Zt(e*o*o,t),u=o,l=Zt(o*E2,t),h=a===r,g=a===Zt(-r,t),b=a===Zt(-r*E2,t);return h&&(o=u),(g||b)&&(o=l),gV(o,t)&&(o=Zt(-o,t)),{isValid:h||g,value:o}}const BV=a0(dm,void 0,!0),PV={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:BV,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:TV,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:eV,randomBytes:t2,adjustScalarBytes:NV,uvRatio:CV},nu=IV(PV);var pm={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,e){var t=Qy,n=t.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=t:(i(t,e),e.Buffer=s);function s(o,a,u){return n(o,a,u)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,u)},s.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=n(o);return a!==void 0?typeof u=="string"?l.fill(a,u):l.fill(a):l.fill(0),l},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}})(pm,pm.exports);var MV=pm.exports,l0=MV.Buffer;function LV(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var o=r.length,a=r.charAt(0),u=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function h(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=l0.from(w)),!l0.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var I=0,S=0,x=0,C=w.length;x!==C&&w[x]===0;)x++,I++;for(var H=(C-x)*l+1>>>0,D=new Uint8Array(H);x!==C;){for(var z=w[x],W=0,Z=H-1;(z!==0||W<S)&&Z!==-1;Z--,W++)z+=256*D[Z]>>>0,D[Z]=z%o>>>0,z=z/o>>>0;if(z!==0)throw new Error("Non-zero carry");S=W,x++}for(var V=H-S;V!==H&&D[V]===0;)V++;for(var K=a.repeat(I);V<H;++V)K+=r.charAt(D[V]);return K}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return l0.alloc(0);for(var I=0,S=0,x=0;w[I]===a;)S++,I++;for(var C=(w.length-I)*u+1>>>0,H=new Uint8Array(C);I<w.length;){var D=w.charCodeAt(I);if(D>255)return;var z=e[D];if(z===255)return;for(var W=0,Z=C-1;(z!==0||W<x)&&Z!==-1;Z--,W++)z+=o*H[Z]>>>0,H[Z]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");x=W,I++}for(var V=C-x;V!==C&&H[V]===0;)V++;var K=l0.allocUnsafe(S+(C-V));K.fill(0,0,S);for(var oe=S;V!==C;)K[oe++]=H[V++];return K}function b(w){var I=g(w);if(I)return I;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:g,decode:b}}var UV=LV,DV=UV,$V="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",R2=DV($V);const Or=xn(R2),FV=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]),po=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),go=new Uint32Array(64);let HV=class extends r2{constructor(){super(64,32,8,!1),this.A=po[0]|0,this.B=po[1]|0,this.C=po[2]|0,this.D=po[3]|0,this.E=po[4]|0,this.F=po[5]|0,this.G=po[6]|0,this.H=po[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)go[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=go[g-15],w=go[g-2],I=zi(b,7)^zi(b,18)^b>>>3,S=zi(w,17)^zi(w,19)^w>>>10;go[g]=S+go[g-7]+I+go[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=zi(a,6)^zi(a,11)^zi(a,25),w=h+b+$G(a,u,l)+FV[g]+go[g]|0,S=(zi(n,2)^zi(n,13)^zi(n,22))+FG(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){go.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const gm=em(()=>new HV);var jr={};function Rs(r,e,t){return e<=r&&r<=t}function f0(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function zV(r){for(var e=String(r),t=e.length,n=0,i=[];n<t;){var s=e.charCodeAt(n);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(n===t-1)i.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var a=s&1023,u=o&1023;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function GV(r){for(var e="",t=0;t<r.length;++t){var n=r[t];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return e}var h0=-1;function ym(r){this.tokens=[].slice.call(r)}ym.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():h0},prepend:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.push(e.shift());else this.tokens.push(r)}};var iu=-1;function mm(r,e){if(r)throw TypeError("Decoder error");return e||65533}var d0="utf-8";function p0(r,e){if(!(this instanceof p0))return new p0(r,e);if(r=r!==void 0?String(r).toLowerCase():d0,r!==d0)throw new Error("Encoding not supported. Only utf-8 is supported");e=f0(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}p0.prototype={decode:function(e,t){var n;typeof e=="object"&&e instanceof ArrayBuffer?n=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):n=new Uint8Array(0),t=f0(t),this._streaming||(this._decoder=new VV({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new ym(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==iu);)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===iu)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),GV(s)}};function g0(r,e){if(!(this instanceof g0))return new g0(r,e);if(r=r!==void 0?String(r).toLowerCase():d0,r!==d0)throw new Error("Encoding not supported. Only utf-8 is supported");e=f0(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}g0.prototype={encode:function(e,t){e=e?String(e):"",t=f0(t),this._streaming||(this._encoder=new jV(this._options)),this._streaming=!!t.stream;for(var n=[],i=new ym(zV(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==iu);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==iu;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function VV(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===h0&&i!==0)return i=0,mm(e);if(u===h0)return iu;if(i===0){if(Rs(u,0,127))return u;if(Rs(u,194,223))i=1,t=u-192;else if(Rs(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,t=u-224;else if(Rs(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,t=u-240;else return mm(e);return t=t<<6*i,null}if(!Rs(u,s,o))return t=i=n=0,s=128,o=191,a.prepend(u),mm(e);if(s=128,o=191,n+=1,t+=u-128<<6*(i-n),n!==i)return null;var l=t;return t=i=n=0,l}}function jV(r){r.fatal,this.handler=function(e,t){if(t===h0)return iu;if(Rs(t,0,127))return t;var n,i;Rs(t,128,2047)?(n=1,i=192):Rs(t,2048,65535)?(n=2,i=224):Rs(t,65536,1114111)&&(n=3,i=240);for(var s=[(t>>6*n)+i];n>0;){var o=t>>6*(n-1);s.push(128|o&63),n-=1}return s}}const KV=Mc(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:p0,TextEncoder:g0},Symbol.toStringTag,{value:"Module"})));var WV=ut&&ut.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t),Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[t]}})}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),qV=ut&&ut.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),Gi=ut&&ut.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ZV=ut&&ut.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.hasOwnProperty.call(r,t)&&WV(e,r,t);return qV(e,r),e},I2=ut&&ut.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(jr,"__esModule",{value:!0});var S2=jr.deserializeUnchecked=B2=jr.deserialize=C2=jr.serialize=jr.BinaryReader=jr.BinaryWriter=jr.BorshError=jr.baseDecode=jr.baseEncode=void 0;const yo=I2(Yy),k2=I2(R2),QV=ZV(KV),YV=typeof TextDecoder!="function"?QV.TextDecoder:TextDecoder,JV=new YV("utf-8",{fatal:!0});function XV(r){return typeof r=="string"&&(r=Ze.from(r,"utf8")),k2.default.encode(Ze.from(r))}jr.baseEncode=XV;function ej(r){return Ze.from(k2.default.decode(r))}jr.baseDecode=ej;const wm=1024;class pn extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}jr.BorshError=pn;class T2{constructor(){this.buf=Ze.alloc(wm),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Ze.concat([this.buf,Ze.alloc(wm)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Ze.from(new yo.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Ze.concat([Ze.from(this.buf.subarray(0,this.length)),e,Ze.alloc(wm)]),this.length+=e.length}writeString(e){this.maybeResize();const t=Ze.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Ze.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(const n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}}jr.BinaryWriter=T2;function Vi(r,e,t){const n=t.value;t.value=function(...i){try{return n.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 pn("Reached the end of buffer when deserializing")}throw s}}}class Fn{constructor(e){this.buf=e,this.offset=0}readU8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){const e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){const e=this.readBuffer(8);return new yo.default(e,"le")}readU128(){const e=this.readBuffer(16);return new yo.default(e,"le")}readU256(){const e=this.readBuffer(32);return new yo.default(e,"le")}readU512(){const e=this.readBuffer(64);return new yo.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new pn(`Expected buffer length ${e} isn't within bounds`);const t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){const e=this.readU32(),t=this.readBuffer(e);try{return JV.decode(t)}catch(n){throw new pn(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){const t=this.readU32(),n=Array();for(let i=0;i<t;++i)n.push(e());return n}}Gi([Vi],Fn.prototype,"readU8",null),Gi([Vi],Fn.prototype,"readU16",null),Gi([Vi],Fn.prototype,"readU32",null),Gi([Vi],Fn.prototype,"readU64",null),Gi([Vi],Fn.prototype,"readU128",null),Gi([Vi],Fn.prototype,"readU256",null),Gi([Vi],Fn.prototype,"readU512",null),Gi([Vi],Fn.prototype,"readString",null),Gi([Vi],Fn.prototype,"readFixedArray",null),Gi([Vi],Fn.prototype,"readArray",null),jr.BinaryReader=Fn;function O2(r){return r.charAt(0).toUpperCase()+r.slice(1)}function va(r,e,t,n,i){try{if(typeof n=="string")i[`write${O2(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new pn(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);i.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new pn(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let s=0;s<n[1];s++)va(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{va(r,e,s,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?i.writeU8(0):(i.writeU8(1),va(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{va(r,e,o,n.key,i),va(r,e,s,n.value,i)});break}default:throw new pn(`FieldType ${n} unrecognized`)}else N2(r,t,i)}catch(s){throw s instanceof pn&&s.addToFieldPath(e),s}}function N2(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}const n=r.get(e.constructor);if(!n)throw new pn(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,s])=>{va(r,i,e[i],s,t)});else if(n.kind==="enum"){const i=e[n.field];for(let s=0;s<n.values.length;++s){const[o,a]=n.values[s];if(o===i){t.writeU8(s),va(r,o,e[o],a,t);break}}}else throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function tj(r,e,t=T2){const n=new t;return N2(r,e,n),n.toArray()}var C2=jr.serialize=tj;function Ea(r,e,t,n){try{if(typeof t=="string")return n[`read${O2(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){const i=[];for(let s=0;s<t[1];s++)i.push(Ea(r,null,t[0],n));return i}else return n.readArray(()=>Ea(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?Ea(r,e,t.type,n):void 0;if(t.kind==="map"){let i=new Map;const s=n.readU32();for(let o=0;o<s;o++){const a=Ea(r,e,t.key,n),u=Ea(r,e,t.value,n);i.set(a,u)}return i}return bm(r,t,n)}catch(i){throw i instanceof pn&&i.addToFieldPath(e),i}}function bm(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);const n=r.get(e);if(!n)throw new pn(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){const i={};for(const[s,o]of r.get(e).fields)i[s]=Ea(r,s,o,t);return new e(i)}if(n.kind==="enum"){const i=t.readU8();if(i>=n.values.length)throw new pn(`Enum index: ${i} is out of range`);const[s,o]=n.values[i],a=Ea(r,s,o,t);return new e({[s]:a})}throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function rj(r,e,t,n=Fn){const i=new n(t),s=bm(r,e,i);if(i.offset<t.length)throw new pn(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}var B2=jr.deserialize=rj;function nj(r,e,t,n=Fn){const i=new n(t);return bm(r,e,i)}S2=jr.deserializeUnchecked=nj;var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.s16=ne.s8=ne.nu64be=ne.u48be=ne.u40be=ne.u32be=ne.u24be=ne.u16be=Kr=ne.nu64=ne.u48=ne.u40=Pe=ne.u32=ne.u24=ii=ne.u16=bt=ne.u8=mo=ne.offset=ne.greedy=ne.Constant=ne.UTF8=ne.CString=ne.Blob=ne.Boolean=ne.BitField=ne.BitStructure=ne.VariantLayout=ne.Union=ne.UnionLayoutDiscriminator=ne.UnionDiscriminator=ne.Structure=ne.Sequence=ne.DoubleBE=ne.Double=ne.FloatBE=ne.Float=ne.NearInt64BE=ne.NearInt64=ne.NearUInt64BE=ne.NearUInt64=ne.IntBE=ne.Int=ne.UIntBE=ne.UInt=ne.OffsetLayout=ne.GreedyCount=ne.ExternalLayout=ne.bindConstructorLayout=ne.nameWithProperty=ne.Layout=ne.uint8ArrayToBuffer=ne.checkUint8Array=void 0,ne.constant=ne.utf8=ne.cstr=Wt=ne.blob=ne.unionLayoutDiscriminator=ne.union=Wr=ne.seq=ne.bits=Me=ne.struct=ne.f64be=ne.f64=ne.f32be=ne.f32=ne.ns64be=ne.s48be=ne.s40be=ne.s32be=ne.s24be=ne.s16be=Hn=ne.ns64=ne.s48=ne.s40=ne.s32=ne.s24=void 0;const _m=Qy;function su(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ne.checkUint8Array=su;function At(r){return su(r),_m.Buffer.from(r.buffer,r.byteOffset,r.length)}ne.uint8ArrayToBuffer=At;let Tt=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};ne.Layout=Tt;function Am(r,e){return e.property?r+"["+e.property+"]":r}ne.nameWithProperty=Am;function ij(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Tt))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value(t,n){return e.decode(t,n)},writable:!0})}ne.bindConstructorLayout=ij;let kn=class extends Tt{isCount(){throw new Error("ExternalLayout is abstract")}};ne.ExternalLayout=kn;let P2=class extends kn{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){su(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};ne.GreedyCount=P2;let vm=class extends kn{constructor(e,t=0,n){if(!(e instanceof Tt))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof ni||this.layout instanceof Ai}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};ne.OffsetLayout=vm;let ni=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readUIntLE(t,this.span)}encode(e,t,n=0){return At(t).writeUIntLE(e,n,this.span),this.span}};ne.UInt=ni;let Ai=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readUIntBE(t,this.span)}encode(e,t,n=0){return At(t).writeUIntBE(e,n,this.span),this.span}};ne.UIntBE=Ai;let xa=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readIntLE(t,this.span)}encode(e,t,n=0){return At(t).writeIntLE(e,n,this.span),this.span}};ne.Int=xa;let ou=class extends Tt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return At(e).readIntBE(t,this.span)}encode(e,t,n=0){return At(t).writeIntBE(e,n,this.span),this.span}};ne.IntBE=ou;const Em=Math.pow(2,32);function y0(r){const e=Math.floor(r/Em),t=r-e*Em;return{hi32:e,lo32:t}}function m0(r,e){return r*Em+e}let M2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32LE(t),s=n.readUInt32LE(t+4);return m0(s,i)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};ne.NearUInt64=M2;let L2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32BE(t),s=n.readUInt32BE(t+4);return m0(i,s)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearUInt64BE=L2;let U2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readUInt32LE(t),s=n.readInt32LE(t+4);return m0(s,i)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};ne.NearInt64=U2;let D2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){const n=At(e),i=n.readInt32BE(t),s=n.readUInt32BE(t+4);return m0(i,s)}encode(e,t,n=0){const i=y0(e),s=At(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearInt64BE=D2;let $2=class extends Tt{constructor(e){super(4,e)}decode(e,t=0){return At(e).readFloatLE(t)}encode(e,t,n=0){return At(t).writeFloatLE(e,n),4}};ne.Float=$2;let F2=class extends Tt{constructor(e){super(4,e)}decode(e,t=0){return At(e).readFloatBE(t)}encode(e,t,n=0){return At(t).writeFloatBE(e,n),4}};ne.FloatBE=F2;let H2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){return At(e).readDoubleLE(t)}encode(e,t,n=0){return At(t).writeDoubleLE(e,n),8}};ne.Double=H2;let z2=class extends Tt{constructor(e){super(8,e)}decode(e,t=0){return At(e).readDoubleBE(t)}encode(e,t,n=0){return At(t).writeDoubleBE(e,n),8}};ne.DoubleBE=z2;let G2=class extends Tt{constructor(e,t,n){if(!(e instanceof Tt))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof kn&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof kn)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof kn&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t=0){const n=[];let i=0,s=this.count;for(s instanceof kn&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n=0){const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof kn&&this.count.encode(e.length,t,n),s}};ne.Sequence=G2;let V2=class extends Tt{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Tt,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){su(e);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};ne.Structure=V2;let xm=class{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}};ne.UnionDiscriminator=xm;let w0=class extends xm{constructor(e,t){if(!(e instanceof kn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};ne.UnionLayoutDiscriminator=w0;let Rm=class extends Tt{constructor(e,t,n){let i;if(e instanceof ni||e instanceof Ai)i=new w0(new vm(e));else if(e instanceof kn&&e.isCount())i=new w0(e);else if(e instanceof xm)i=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Tt))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof ni||e instanceof Ai)&&(s+=i.layout.span)),super(s,n),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof ni||e instanceof Ai,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const i=this.discriminator,s=i.decode(e,t),o=this.registry[s];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[a.property]=a.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new j2(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};ne.Union=Rm;let j2=class extends Tt{constructor(e,t,n,i){if(!(e instanceof Rm))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Tt))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.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=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+n)),n+i}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};ne.VariantLayout=j2;function au(r){return 0>r&&(r+=4294967296),r}let Im=class extends Tt{constructor(e,t,n){if(!(e instanceof ni||e instanceof Ai))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=au(s),this},this._packedGetValue=function(){return i}}decode(e,t=0){const n=this.makeDestinationObject(),i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(e));return n}encode(e,t,n=0){const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Sm(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new K2(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}};ne.BitStructure=Im;let Sm=class{constructor(e,t,n){if(!(e instanceof Im))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=au(this.valueMask<<this.start),this.property=n}decode(e,t){const n=this.container._packedGetValue();return au(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==au(e&this.valueMask))throw new TypeError(Am("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=au(e<<this.start);this.container._packedSetValue(au(t&~this.wordMask)|n)}};ne.BitField=Sm;let K2=class extends Sm{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};ne.Boolean=K2;let W2=class extends Tt{constructor(e,t){if(!(e instanceof kn&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof kn||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),At(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof kn&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw new TypeError(Am("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>t.length)throw new RangeError("encoding overruns Uint8Array");const s=At(e);return At(t).write(s.toString("hex"),n,i,"hex"),this.length instanceof kn&&this.length.encode(i,t,n),i}};ne.Blob=W2;let q2=class extends Tt{constructor(e){super(-1,e)}getSpan(e,t=0){su(e);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return At(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=_m.Buffer.from(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");const o=At(t);return i.copy(o,n),o[n+s]=0,s+1}};ne.CString=q2;let Z2=class extends Tt{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return su(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return At(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=_m.Buffer.from(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(At(t),n),s}};ne.UTF8=Z2;let Q2=class extends Tt{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};ne.Constant=Q2,ne.greedy=(r,e)=>new P2(r,e);var mo=ne.offset=(r,e,t)=>new vm(r,e,t),bt=ne.u8=r=>new ni(1,r),ii=ne.u16=r=>new ni(2,r);ne.u24=r=>new ni(3,r);var Pe=ne.u32=r=>new ni(4,r);ne.u40=r=>new ni(5,r),ne.u48=r=>new ni(6,r);var Kr=ne.nu64=r=>new M2(r);ne.u16be=r=>new Ai(2,r),ne.u24be=r=>new Ai(3,r),ne.u32be=r=>new Ai(4,r),ne.u40be=r=>new Ai(5,r),ne.u48be=r=>new Ai(6,r),ne.nu64be=r=>new L2(r),ne.s8=r=>new xa(1,r),ne.s16=r=>new xa(2,r),ne.s24=r=>new xa(3,r),ne.s32=r=>new xa(4,r),ne.s40=r=>new xa(5,r),ne.s48=r=>new xa(6,r);var Hn=ne.ns64=r=>new U2(r);ne.s16be=r=>new ou(2,r),ne.s24be=r=>new ou(3,r),ne.s32be=r=>new ou(4,r),ne.s40be=r=>new ou(5,r),ne.s48be=r=>new ou(6,r),ne.ns64be=r=>new D2(r),ne.f32=r=>new $2(r),ne.f32be=r=>new F2(r),ne.f64=r=>new H2(r),ne.f64be=r=>new z2(r);var Me=ne.struct=(r,e,t)=>new V2(r,e,t);ne.bits=(r,e,t)=>new Im(r,e,t);var Wr=ne.seq=(r,e,t)=>new G2(r,e,t);ne.union=(r,e,t)=>new Rm(r,e,t),ne.unionLayoutDiscriminator=(r,e)=>new w0(r,e);var Wt=ne.blob=(r,e)=>new W2(r,e);ne.cstr=r=>new q2(r),ne.utf8=(r,e)=>new Z2(r,e),ne.constant=(r,e)=>new Q2(r,e);var If={};Object.defineProperty(If,"__esModule",{value:!0});function sj(r){{const e=Ze.from(r);e.reverse();const t=e.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}var oj=If.toBigIntLE=sj;function aj(r){{const e=r.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}If.toBigIntBE=aj;function cj(r,e){{const t=r.toString(16),n=Ze.from(t.padStart(e*2,"0").slice(0,e*2),"hex");return n.reverse(),n}}var Y2=If.toBufferLE=cj;function uj(r,e){{const t=r.toString(16);return Ze.from(t.padStart(e*2,"0").slice(0,e*2),"hex")}}If.toBufferBE=uj;let lj=class extends TypeError{constructor(e,t){let n;const{message:i,explanation:s,...o}=e,{path:a}=e,u=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function fj(r){return Sf(r)&&typeof r[Symbol.iterator]=="function"}function Sf(r){return typeof r=="object"&&r!=null}function b0(r){return Sf(r)&&!Array.isArray(r)}function vi(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function hj(r){const{done:e,value:t}=r.next();return e?void 0:t}function dj(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${vi(n)}\``}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*J2(r,e,t,n){fj(r)||(r=[r]);for(const i of r){const s=dj(i,e,t,n);s&&(yield s)}}function*km(r,e,t={}){const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i,mask:o};s&&(r=e.coercer(r,a));let u="valid";for(const l of e.validator(r,a))l.explanation=t.message,u="not_valid",yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=km(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o,message:t.message});for(const w of b)w[0]?(u=w[0].refinement!=null?"not_refined":"not_valid",yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):Sf(r)&&(h!==void 0||l in r)&&(r[l]=h))}if(u!=="not_valid")for(const l of e.refiner(r,a))l.explanation=t.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,r])}let ji=class{constructor(e){const{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return J2(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return J2(h,l,this,u)}:this.refiner=()=>[]}assert(e,t){return X2(e,this,t)}create(e,t){return Ae(e,this,t)}is(e){return ex(e,this)}mask(e,t){return pj(e,this,t)}validate(e,t={}){return kf(e,this,t)}};function X2(r,e,t){const n=kf(r,e,{message:t});if(n[0])throw n[0]}function Ae(r,e,t){const n=kf(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function pj(r,e,t){const n=kf(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function ex(r,e){return!kf(r,e)[0]}function kf(r,e,t={}){const n=km(r,e,t),i=hj(n);return i[0]?[new lj(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Ra(r,e){return new ji({type:r,schema:null,validator:e})}function gj(){return Ra("any",()=>!0)}function Re(r){return new ji({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${vi(e)}`}})}function Ki(){return Ra("boolean",r=>typeof r=="boolean")}function Tm(r){return Ra("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${vi(e)}`)}function rr(r){const e=vi(r),t=typeof r;return new ji({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${vi(n)}`}})}function yj(){return Ra("never",()=>!1)}function Ie(r){return new ji({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X(){return Ra("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${vi(r)}`)}function He(r){return new ji({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function tx(r,e){return new ji({type:"record",schema:null,*entries(t){if(Sf(t))for(const n in t){const i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return b0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return b0(t)?{...t}:t}})}function _e(){return Ra("string",r=>typeof r=="string"||`Expected a string, but received: ${vi(r)}`)}function Om(r){const e=yj();return new ji({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const n=Math.max(r.length,t.length);for(let i=0;i<n;i++)yield[i,t[i],r[i]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${vi(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function pe(r){const e=Object.keys(r);return new ji({type:"type",schema:r,*entries(t){if(Sf(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return b0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return b0(t)?{...t}:t}})}function gn(r){const e=r.map(t=>t.type).join(" | ");return new ji({type:"union",schema:null,coercer(t,n){for(const i of r){const[s,o]=i.validate(t,{coerce:!0,mask:n.mask});if(!s)return o}return t},validator(t,n){const i=[];for(const s of r){const[...o]=km(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${vi(t)}`,...i]}})}function cu(){return Ra("unknown",()=>!0)}function Tf(r,e,t){return new ji({...r,coercer:(n,i)=>ex(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var _0,mj=new Uint8Array(16);function rx(){if(!_0&&(_0=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!_0))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _0(mj)}const wj=/^(?:[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 A0(r){return typeof r=="string"&&wj.test(r)}for(var qr=[],Nm=0;Nm<256;++Nm)qr.push((Nm+256).toString(16).substr(1));function v0(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(qr[r[e+0]]+qr[r[e+1]]+qr[r[e+2]]+qr[r[e+3]]+"-"+qr[r[e+4]]+qr[r[e+5]]+"-"+qr[r[e+6]]+qr[r[e+7]]+"-"+qr[r[e+8]]+qr[r[e+9]]+"-"+qr[r[e+10]]+qr[r[e+11]]+qr[r[e+12]]+qr[r[e+13]]+qr[r[e+14]]+qr[r[e+15]]).toLowerCase();if(!A0(t))throw TypeError("Stringified UUID is invalid");return t}var nx,Cm,Bm=0,Pm=0;function bj(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||nx,o=r.clockseq!==void 0?r.clockseq:Cm;if(s==null||o==null){var a=r.random||(r.rng||rx)();s==null&&(s=nx=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Cm=(a[6]<<8|a[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),l=r.nsecs!==void 0?r.nsecs:Pm+1,h=u-Bm+(l-Pm)/1e4;if(h<0&&r.clockseq===void 0&&(o=o+1&16383),(h<0||u>Bm)&&r.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Bm=u,Pm=l,Cm=o,u+=122192928e5;var g=((u&268435455)*1e4+l)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=g&255;var b=u/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=b&255,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var w=0;w<6;++w)i[n+w]=s[w];return e||v0(i)}function ix(r){if(!A0(r))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function _j(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var Aj="6ba7b810-9dad-11d1-80b4-00c04fd430c8",vj="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function sx(r,e,t){function n(i,s,o,a){if(typeof i=="string"&&(i=_j(i)),typeof s=="string"&&(s=ix(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=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(var l=0;l<16;++l)o[a+l]=u[l];return o}return v0(u)}try{n.name=r}catch{}return n.DNS=Aj,n.URL=vj,n}function Ej(r){if(typeof r=="string"){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var t=0;t<e.length;++t)r[t]=e.charCodeAt(t)}return xj(Rj(Ij(r),r.length*8))}function xj(r){for(var e=[],t=r.length*32,n="0123456789abcdef",i=0;i<t;i+=8){var s=r[i>>5]>>>i%32&255,o=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);e.push(o)}return e}function ox(r){return(r+64>>>9<<4)+14+1}function Rj(r,e){r[e>>5]|=128<<e%32,r[ox(e)-1]=e;for(var t=1732584193,n=-271733879,i=-1732584194,s=271733878,o=0;o<r.length;o+=16){var a=t,u=n,l=i,h=s;t=rn(t,n,i,s,r[o],7,-680876936),s=rn(s,t,n,i,r[o+1],12,-389564586),i=rn(i,s,t,n,r[o+2],17,606105819),n=rn(n,i,s,t,r[o+3],22,-1044525330),t=rn(t,n,i,s,r[o+4],7,-176418897),s=rn(s,t,n,i,r[o+5],12,1200080426),i=rn(i,s,t,n,r[o+6],17,-1473231341),n=rn(n,i,s,t,r[o+7],22,-45705983),t=rn(t,n,i,s,r[o+8],7,1770035416),s=rn(s,t,n,i,r[o+9],12,-1958414417),i=rn(i,s,t,n,r[o+10],17,-42063),n=rn(n,i,s,t,r[o+11],22,-1990404162),t=rn(t,n,i,s,r[o+12],7,1804603682),s=rn(s,t,n,i,r[o+13],12,-40341101),i=rn(i,s,t,n,r[o+14],17,-1502002290),n=rn(n,i,s,t,r[o+15],22,1236535329),t=nn(t,n,i,s,r[o+1],5,-165796510),s=nn(s,t,n,i,r[o+6],9,-1069501632),i=nn(i,s,t,n,r[o+11],14,643717713),n=nn(n,i,s,t,r[o],20,-373897302),t=nn(t,n,i,s,r[o+5],5,-701558691),s=nn(s,t,n,i,r[o+10],9,38016083),i=nn(i,s,t,n,r[o+15],14,-660478335),n=nn(n,i,s,t,r[o+4],20,-405537848),t=nn(t,n,i,s,r[o+9],5,568446438),s=nn(s,t,n,i,r[o+14],9,-1019803690),i=nn(i,s,t,n,r[o+3],14,-187363961),n=nn(n,i,s,t,r[o+8],20,1163531501),t=nn(t,n,i,s,r[o+13],5,-1444681467),s=nn(s,t,n,i,r[o+2],9,-51403784),i=nn(i,s,t,n,r[o+7],14,1735328473),n=nn(n,i,s,t,r[o+12],20,-1926607734),t=sn(t,n,i,s,r[o+5],4,-378558),s=sn(s,t,n,i,r[o+8],11,-2022574463),i=sn(i,s,t,n,r[o+11],16,1839030562),n=sn(n,i,s,t,r[o+14],23,-35309556),t=sn(t,n,i,s,r[o+1],4,-1530992060),s=sn(s,t,n,i,r[o+4],11,1272893353),i=sn(i,s,t,n,r[o+7],16,-155497632),n=sn(n,i,s,t,r[o+10],23,-1094730640),t=sn(t,n,i,s,r[o+13],4,681279174),s=sn(s,t,n,i,r[o],11,-358537222),i=sn(i,s,t,n,r[o+3],16,-722521979),n=sn(n,i,s,t,r[o+6],23,76029189),t=sn(t,n,i,s,r[o+9],4,-640364487),s=sn(s,t,n,i,r[o+12],11,-421815835),i=sn(i,s,t,n,r[o+15],16,530742520),n=sn(n,i,s,t,r[o+2],23,-995338651),t=on(t,n,i,s,r[o],6,-198630844),s=on(s,t,n,i,r[o+7],10,1126891415),i=on(i,s,t,n,r[o+14],15,-1416354905),n=on(n,i,s,t,r[o+5],21,-57434055),t=on(t,n,i,s,r[o+12],6,1700485571),s=on(s,t,n,i,r[o+3],10,-1894986606),i=on(i,s,t,n,r[o+10],15,-1051523),n=on(n,i,s,t,r[o+1],21,-2054922799),t=on(t,n,i,s,r[o+8],6,1873313359),s=on(s,t,n,i,r[o+15],10,-30611744),i=on(i,s,t,n,r[o+6],15,-1560198380),n=on(n,i,s,t,r[o+13],21,1309151649),t=on(t,n,i,s,r[o+4],6,-145523070),s=on(s,t,n,i,r[o+11],10,-1120210379),i=on(i,s,t,n,r[o+2],15,718787259),n=on(n,i,s,t,r[o+9],21,-343485551),t=wo(t,a),n=wo(n,u),i=wo(i,l),s=wo(s,h)}return[t,n,i,s]}function Ij(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(ox(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function wo(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function Sj(r,e){return r<<e|r>>>32-e}function E0(r,e,t,n,i,s){return wo(Sj(wo(wo(e,r),wo(n,s)),i),t)}function rn(r,e,t,n,i,s,o){return E0(e&t|~e&n,r,e,i,s,o)}function nn(r,e,t,n,i,s,o){return E0(e&n|t&~n,r,e,i,s,o)}function sn(r,e,t,n,i,s,o){return E0(e^t^n,r,e,i,s,o)}function on(r,e,t,n,i,s,o){return E0(t^(e|~n),r,e,i,s,o)}var kj=sx("v3",48,Ej);function Tj(r,e,t){r=r||{};var n=r.random||(r.rng||rx)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=n[i];return e}return v0(n)}function Oj(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function Mm(r,e){return r<<e|r>>>32-e}function Nj(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var s=r.length/4+2,o=Math.ceil(s/16),a=new Array(o),u=0;u<o;++u){for(var l=new Uint32Array(16),h=0;h<16;++h)l[h]=r[u*64+h*4]<<24|r[u*64+h*4+1]<<16|r[u*64+h*4+2]<<8|r[u*64+h*4+3];a[u]=l}a[o-1][14]=(r.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(r.length-1)*8&4294967295;for(var g=0;g<o;++g){for(var b=new Uint32Array(80),w=0;w<16;++w)b[w]=a[g][w];for(var I=16;I<80;++I)b[I]=Mm(b[I-3]^b[I-8]^b[I-14]^b[I-16],1);for(var S=t[0],x=t[1],C=t[2],H=t[3],D=t[4],z=0;z<80;++z){var W=Math.floor(z/20),Z=Mm(S,5)+Oj(W,x,C,H)+D+e[W]+b[z]>>>0;D=H,H=C,C=Mm(x,30)>>>0,x=S,S=Z}t[0]=t[0]+S>>>0,t[1]=t[1]+x>>>0,t[2]=t[2]+C>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+D>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var Cj=sx("v5",80,Nj);const Bj="00000000-0000-0000-0000-000000000000";function Pj(r){if(!A0(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const ax=Mc(Object.freeze(Object.defineProperty({__proto__:null,NIL:Bj,parse:ix,stringify:v0,v1:bj,v3:kj,v4:Tj,v5:Cj,validate:A0,version:Pj},Symbol.toStringTag,{value:"Module"}))),Mj=ax.v4;var Lj=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};const i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:r};if(i===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){const o=typeof n.generator=="function"?n.generator:function(){return Mj()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};const Uj=ax.v4,Dj=Lj,Of=function(r,e){if(!(this instanceof Of))return new Of(r,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return Uj()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};var $j=Of;Of.prototype.request=function(r,e,t,n){const i=this;let s=null;const o=Array.isArray(r)&&typeof e=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof e=="function")n=e,s=r;else{typeof t=="function"&&(n=t,t=void 0);const l=typeof n=="function";try{s=Dj(r,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(l)return n(h);throw h}if(!l)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(l){return n(l)}return this.callServer(u,function(l,h){i._parseResponse(l,h,n)}),s},Of.prototype._parseResponse=function(r,e,t){if(r){t(r);return}if(!e)return t();let n;try{n=JSON.parse(e,this.options.reviver)}catch(i){return t(i)}if(t.length===3)if(Array.isArray(n)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return t(null,n.filter(i),n.filter(s))}else return t(null,n.error,n.result);t(null,n)};const Fj=xn($j);var cx={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,W;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(W=1,H=new Array(C-1);W<C;W++)H[W-1]=arguments[W];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(cx);var Hj=cx.exports;const ux=xn(Hj);var zj=class extends ux{constructor(e,t,n){super();Q(this,"socket");this.socket=new window.WebSocket(e,n),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(e,t,n){const i=n||t;try{this.socket.send(e),i()}catch(s){i(s)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function Gj(r,e){return new zj(r,e)}var Vj=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},jj=class extends ux{constructor(e,t="ws://localhost:8080",{autoconnect:n=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...a}={},u,l){super();Q(this,"address");Q(this,"rpc_id");Q(this,"queue");Q(this,"options");Q(this,"autoconnect");Q(this,"ready");Q(this,"reconnect");Q(this,"reconnect_timer_id");Q(this,"reconnect_interval");Q(this,"max_reconnects");Q(this,"rest_options");Q(this,"current_reconnects");Q(this,"generate_request_id");Q(this,"socket");Q(this,"webSocketFactory");Q(this,"dataPack");this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),l?this.dataPack=l:this.dataPack=new Vj,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(e,t,n,i){return!i&&typeof n=="object"&&(i=n,n=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(e,t),u={jsonrpc:"2.0",method:e,params:t||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,l=>{if(l)return o(l);this.queue[a]={promise:[s,o]},n&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},n))})})}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((n,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);n()})})}async subscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.on",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.off",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Ne.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const i=[n.notification];if(n.params.constructor===Object)i.push(n.params);else for(let s=0;s<n.params.length;s++)i.push(n.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",n,i),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}};const lx=[],fx=[],hx=[],Kj=BigInt(0),Nf=BigInt(1),Wj=BigInt(2),qj=BigInt(7),Zj=BigInt(256),Qj=BigInt(113);for(let r=0,e=Nf,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],lx.push(2*(5*n+t)),fx.push((r+1)*(r+2)/2%64);let i=Kj;for(let s=0;s<7;s++)e=(e<<Nf^(e>>qj)*Qj)%Zj,e&Wj&&(i^=Nf<<(Nf<<BigInt(s))-Nf);hx.push(i)}const[Yj,Jj]=i2(hx,!0),dx=(r,e,t)=>t>32?a2(r,e,t):s2(r,e,t),px=(r,e,t)=>t>32?c2(r,e,t):o2(r,e,t);function Xj(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=dx(l,h,1)^t[a],b=px(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=fx[o],u=dx(i,s,a),l=px(i,s,a),h=lx[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Yj[n],r[1]^=Jj[n]}t.fill(0)}let eK=class u6 extends Xy{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,t0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=PG(this.state)}keccak(){XE||e2(this.state32),Xj(this.state32,this.rounds),XE||e2(this.state32),this.posOut=0,this.pos=0}update(e){Qc(this);const{blockLen:t,state:n}=this;e=r0(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Qc(this,!1),vf(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return t0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(JE(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new u6(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const gx=((r,e,t)=>em(()=>new eK(e,r,t)))(1,136,256/8);let yx=class extends Xy{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,BG(e);const n=r0(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Qc(this),this.iHash.update(e),this}digestInto(e){Qc(this),vf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const mx=(r,e,t)=>new yx(r,e).update(t).digest();mx.create=(r,e)=>new yx(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wx(r){r.lowS!==void 0&&Es("lowS",r.lowS),r.prehash!==void 0&&Es("prehash",r.prehash)}function tK(r){const e=hm(r);ru(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:rK,hexToBytes:nK}=lV;class iK extends Error{constructor(e=""){super(e)}}const Is={Err:iK,_tlv:{encode:(r,e)=>{const{Err:t}=Is;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const n=e.length/2,i=Jc(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=n>127?Jc(i.length/2|128):"";return Jc(r)+s+i+e},decode(r,e){const{Err:t}=Is;let n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new t("tlv.decode(long): indefinite length not supported");if(u>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+u);if(l.length!==u)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(n+=u,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(r){const{Err:e}=Is;if(r<Ss)throw new e("integer: negative integers are not allowed");let t=Jc(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){const{Err:e}=Is;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return rK(r)}},toSig(r){const{Err:e,_int:t,_tlv:n}=Is,i=typeof r=="string"?nK(r):r;Ef(i);const{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:u}=n.decode(2,s),{v:l,l:h}=n.decode(2,u);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(r){const{_tlv:e,_int:t}=Is,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),s=n+i;return e.encode(48,s)}},Ss=BigInt(0),Lr=BigInt(1);BigInt(2);const bx=BigInt(3);BigInt(4);function sK(r){const e=tK(r),{Fp:t}=e,n=a0(e.n,e.nBitLength),i=e.toBytes||((S,x,C)=>{const H=x.toAffine();return _a(Uint8Array.from([4]),t.toBytes(H.x),t.toBytes(H.y))}),s=e.fromBytes||(S=>{const x=S.subarray(1),C=t.fromBytes(x.subarray(0,t.BYTES)),H=t.fromBytes(x.subarray(t.BYTES,2*t.BYTES));return{x:C,y:H}});function o(S){const{a:x,b:C}=e,H=t.sqr(S),D=t.mul(H,S);return t.add(t.add(D,t.mul(S,x)),C)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return o0(S,Lr,e.n)}function u(S){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:H,n:D}=e;if(x&&typeof S!="bigint"){if(ma(S)&&(S=wa(S)),typeof S!="string"||!x.includes(S.length))throw new Error("invalid private key");S=S.padStart(C*2,"0")}let z;try{z=typeof S=="bigint"?S:ba(Tr("private key",S,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof S)}return H&&(z=Zt(z,D)),ri("private key",z,Lr,D),z}function l(S){if(!(S instanceof b))throw new Error("ProjectivePoint expected")}const h=Rf((S,x)=>{const{px:C,py:H,pz:D}=S;if(t.eql(D,t.ONE))return{x:C,y:H};const z=S.is0();x==null&&(x=z?t.ONE:t.inv(D));const W=t.mul(C,x),Z=t.mul(H,x),V=t.mul(D,x);if(z)return{x:t.ZERO,y:t.ZERO};if(!t.eql(V,t.ONE))throw new Error("invZ was invalid");return{x:W,y:Z}}),g=Rf(S=>{if(S.is0()){if(e.allowInfinityPoint&&!t.is0(S.py))return;throw new Error("bad point: ZERO")}const{x,y:C}=S.toAffine();if(!t.isValid(x)||!t.isValid(C))throw new Error("bad point: x or y not FE");const H=t.sqr(C),D=o(x);if(!t.eql(H,D))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class b{constructor(x,C,H){if(this.px=x,this.py=C,this.pz=H,x==null||!t.isValid(x))throw new Error("x required");if(C==null||!t.isValid(C))throw new Error("y required");if(H==null||!t.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(x){const{x:C,y:H}=x||{};if(!x||!t.isValid(C)||!t.isValid(H))throw new Error("invalid affine point");if(x instanceof b)throw new Error("projective point not allowed");const D=z=>t.eql(z,t.ZERO);return D(C)&&D(H)?b.ZERO:new b(C,H,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(b.fromAffine)}static fromHex(x){const C=b.fromAffine(s(Tr("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return b.BASE.multiply(u(x))}static msm(x,C){return v2(b,n,x,C)}_setWindowSize(x){I.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){const{y:x}=this.toAffine();if(t.isOdd)return!t.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:W,pz:Z}=x,V=t.eql(t.mul(C,Z),t.mul(z,D)),K=t.eql(t.mul(H,Z),t.mul(W,D));return V&&K}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:x,b:C}=e,H=t.mul(C,bx),{px:D,py:z,pz:W}=this;let Z=t.ZERO,V=t.ZERO,K=t.ZERO,oe=t.mul(D,D),ce=t.mul(z,z),ie=t.mul(W,W),ue=t.mul(D,z);return ue=t.add(ue,ue),K=t.mul(D,W),K=t.add(K,K),Z=t.mul(x,K),V=t.mul(H,ie),V=t.add(Z,V),Z=t.sub(ce,V),V=t.add(ce,V),V=t.mul(Z,V),Z=t.mul(ue,Z),K=t.mul(H,K),ie=t.mul(x,ie),ue=t.sub(oe,ie),ue=t.mul(x,ue),ue=t.add(ue,K),K=t.add(oe,oe),oe=t.add(K,oe),oe=t.add(oe,ie),oe=t.mul(oe,ue),V=t.add(V,oe),ie=t.mul(z,W),ie=t.add(ie,ie),oe=t.mul(ie,ue),Z=t.sub(Z,oe),K=t.mul(ie,ce),K=t.add(K,K),K=t.add(K,K),new b(Z,V,K)}add(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:W,pz:Z}=x;let V=t.ZERO,K=t.ZERO,oe=t.ZERO;const ce=e.a,ie=t.mul(e.b,bx);let ue=t.mul(C,z),B=t.mul(H,W),p=t.mul(D,Z),m=t.add(C,H),E=t.add(z,W);m=t.mul(m,E),E=t.add(ue,B),m=t.sub(m,E),E=t.add(C,D);let k=t.add(z,Z);return E=t.mul(E,k),k=t.add(ue,p),E=t.sub(E,k),k=t.add(H,D),V=t.add(W,Z),k=t.mul(k,V),V=t.add(B,p),k=t.sub(k,V),oe=t.mul(ce,E),V=t.mul(ie,p),oe=t.add(V,oe),V=t.sub(B,oe),oe=t.add(B,oe),K=t.mul(V,oe),B=t.add(ue,ue),B=t.add(B,ue),p=t.mul(ce,p),E=t.mul(ie,E),B=t.add(B,p),p=t.sub(ue,p),p=t.mul(ce,p),E=t.add(E,p),ue=t.mul(B,E),K=t.add(K,ue),ue=t.mul(k,E),V=t.mul(m,V),V=t.sub(V,ue),ue=t.mul(m,B),oe=t.mul(k,oe),oe=t.add(oe,ue),new b(V,K,oe)}subtract(x){return this.add(x.negate())}is0(){return this.equals(b.ZERO)}wNAF(x){return I.wNAFCached(this,x,b.normalizeZ)}multiplyUnsafe(x){const{endo:C,n:H}=e;ri("scalar",x,Ss,H);const D=b.ZERO;if(x===Ss)return D;if(this.is0()||x===Lr)return this;if(!C||I.hasPrecomputes(this))return I.wNAFCachedUnsafe(this,x,b.normalizeZ);let{k1neg:z,k1:W,k2neg:Z,k2:V}=C.splitScalar(x),K=D,oe=D,ce=this;for(;W>Ss||V>Ss;)W&Lr&&(K=K.add(ce)),V&Lr&&(oe=oe.add(ce)),ce=ce.double(),W>>=Lr,V>>=Lr;return z&&(K=K.negate()),Z&&(oe=oe.negate()),oe=new b(t.mul(oe.px,C.beta),oe.py,oe.pz),K.add(oe)}multiply(x){const{endo:C,n:H}=e;ri("scalar",x,Lr,H);let D,z;if(C){const{k1neg:W,k1:Z,k2neg:V,k2:K}=C.splitScalar(x);let{p:oe,f:ce}=this.wNAF(Z),{p:ie,f:ue}=this.wNAF(K);oe=I.constTimeNegate(W,oe),ie=I.constTimeNegate(V,ie),ie=new b(t.mul(ie.px,C.beta),ie.py,ie.pz),D=oe.add(ie),z=ce.add(ue)}else{const{p:W,f:Z}=this.wNAF(x);D=W,z=Z}return b.normalizeZ([D,z])[0]}multiplyAndAddUnsafe(x,C,H){const D=b.BASE,z=(Z,V)=>V===Ss||V===Lr||!Z.equals(D)?Z.multiplyUnsafe(V):Z.multiply(V),W=z(this,C).add(z(x,H));return W.is0()?void 0:W}toAffine(x){return h(this,x)}isTorsionFree(){const{h:x,isTorsionFree:C}=e;if(x===Lr)return!0;if(C)return C(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:x,clearCofactor:C}=e;return x===Lr?this:C?C(b,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return Es("isCompressed",x),this.assertValidity(),i(b,this,x)}toHex(x=!0){return Es("isCompressed",x),wa(this.toRawBytes(x))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const w=e.nBitLength,I=A2(b,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function oK(r){const e=hm(r);return ru(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function aK(r){const e=oK(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(p){return Zt(p,n)}function a(p){return am(p,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:g}=sK({...e,toBytes(p,m,E){const k=m.toAffine(),O=t.toBytes(k.x),M=_a;return Es("isCompressed",E),E?M(Uint8Array.from([m.hasEvenY()?2:3]),O):M(Uint8Array.from([4]),O,t.toBytes(k.y))},fromBytes(p){const m=p.length,E=p[0],k=p.subarray(1);if(m===i&&(E===2||E===3)){const O=ba(k);if(!o0(O,Lr,t.ORDER))throw new Error("Point is not on curve");const M=h(O);let G;try{G=t.sqrt(M)}catch(U){const le=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+le)}const P=(G&Lr)===Lr;return(E&1)===1!==P&&(G=t.neg(G)),{x:O,y:G}}else if(m===s&&E===4){const O=t.fromBytes(k.subarray(0,t.BYTES)),M=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:O,y:M}}else{const O=i,M=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+M+", got "+m)}}}),b=p=>wa(tu(p,e.nByteLength));function w(p){const m=n>>Lr;return p>m}function I(p){return w(p)?o(-p):p}const S=(p,m,E)=>ba(p.slice(m,E));class x{constructor(m,E,k){this.r=m,this.s=E,this.recovery=k,this.assertValidity()}static fromCompact(m){const E=e.nByteLength;return m=Tr("compactSignature",m,E*2),new x(S(m,0,E),S(m,E,2*E))}static fromDER(m){const{r:E,s:k}=Is.toSig(Tr("DER",m));return new x(E,k)}assertValidity(){ri("r",this.r,Lr,n),ri("s",this.s,Lr,n)}addRecoveryBit(m){return new x(this.r,this.s,m)}recoverPublicKey(m){const{r:E,s:k,recovery:O}=this,M=Z(Tr("msgHash",m));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?E+e.n:E;if(G>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=O&1?"03":"02",A=u.fromHex(P+b(G)),U=a(G),le=o(-M*U),te=o(k*U),re=u.BASE.multiplyAndAddUnsafe(A,le,te);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Xc(this.toDERHex())}toDERHex(){return Is.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xc(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const C={isValidPrivateKey(p){try{return l(p),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const p=m2(e.n);return _V(e.randomBytes(p),e.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 D(p){const m=ma(p),E=typeof p=="string",k=(m||E)&&p.length;return m?k===i||k===s:E?k===2*i||k===2*s:p instanceof u}function z(p,m,E=!0){if(D(p))throw new Error("first arg must be private key");if(!D(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(l(p)).toRawBytes(E)}const W=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=ba(p),E=p.length*8-e.nBitLength;return E>0?m>>BigInt(E):m},Z=e.bits2int_modN||function(p){return o(W(p))},V=im(e.nBitLength);function K(p){return ri("num < 2^"+e.nBitLength,p,Ss,V),tu(p,e.nByteLength)}function oe(p,m,E=ce){if(["recovered","canonical"].some(ye=>ye in E))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:O}=e;let{lowS:M,prehash:G,extraEntropy:P}=E;M==null&&(M=!0),p=Tr("msgHash",p),wx(E),G&&(p=Tr("prehashed msgHash",k(p)));const A=Z(p),U=l(m),le=[K(U),K(A)];if(P!=null&&P!==!1){const ye=P===!0?O(t.BYTES):P;le.push(Tr("extraEntropy",ye))}const te=_a(...le),re=A;function he(ye){const be=W(ye);if(!g(be))return;const Ke=a(be),Fe=u.BASE.multiply(be).toAffine(),Be=o(Fe.x);if(Be===Ss)return;const et=o(Ke*o(re+Be*U));if(et===Ss)return;let Qe=(Fe.x===Be?0:2)|Number(Fe.y&Lr),ot=et;return M&&w(et)&&(ot=I(et),Qe^=1),new x(Be,ot,Qe)}return{seed:te,k2sig:he}}const ce={lowS:e.lowS,prehash:!1},ie={lowS:e.lowS,prehash:!1};function ue(p,m,E=ce){const{seed:k,k2sig:O}=oe(p,m,E),M=e;return h2(M.hash.outputLen,M.nByteLength,M.hmac)(k,O)}u.BASE._setWindowSize(8);function B(p,m,E,k=ie){var Qe;const O=p;m=Tr("msgHash",m),E=Tr("publicKey",E);const{lowS:M,prehash:G,format:P}=k;if(wx(k),"strict"in k)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 A=typeof O=="string"||ma(O),U=!A&&!P&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!A&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let le,te;try{if(U&&(le=new x(O.r,O.s)),A){try{P!=="compact"&&(le=x.fromDER(O))}catch(ot){if(!(ot instanceof Is.Err))throw ot}!le&&P!=="der"&&(le=x.fromCompact(O))}te=u.fromHex(E)}catch{return!1}if(!le||M&&le.hasHighS())return!1;G&&(m=e.hash(m));const{r:re,s:he}=le,ye=Z(m),be=a(he),Ke=o(ye*be),Fe=o(re*be),Be=(Qe=u.BASE.multiplyAndAddUnsafe(te,Ke,Fe))==null?void 0:Qe.toAffine();return Be?o(Be.x)===re:!1}return{CURVE:e,getPublicKey:H,getSharedSecret:z,sign:ue,verify:B,ProjectivePoint:u,Signature:x,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function cK(r){return{hash:r,hmac:(e,...t)=>mx(r,e,UG(...t)),randomBytes:t2}}function uK(r,e){const t=n=>aK({...r,...cK(n)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _x=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ax=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lK=BigInt(1),Lm=BigInt(2),vx=(r,e)=>(r+e/Lm)/e;function fK(r){const e=_x,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=ur(h,t,e)*h%e,b=ur(g,t,e)*h%e,w=ur(b,Lm,e)*l%e,I=ur(w,i,e)*w%e,S=ur(I,s,e)*I%e,x=ur(S,a,e)*S%e,C=ur(x,u,e)*x%e,H=ur(C,a,e)*S%e,D=ur(H,t,e)*h%e,z=ur(D,o,e)*I%e,W=ur(z,n,e)*l%e,Z=ur(W,Lm,e);if(!Um.eql(Um.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Um=a0(_x,void 0,void 0,{sqrt:fK}),x0=uK({a:BigInt(0),b:BigInt(7),Fp:Um,n:Ax,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Ax,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-lK*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=vx(s*r,e),u=vx(-n*r,e);let l=Zt(r-a*t-u*i,e),h=Zt(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},gm);BigInt(0),x0.ProjectivePoint;const hK=nu.utils.randomPrivateKey,Ex=()=>{const r=nu.utils.randomPrivateKey(),e=R0(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},R0=nu.getPublicKey;function xx(r){try{return nu.ExtendedPoint.fromHex(r),!0}catch{return!1}}const Dm=(r,e)=>nu.sign(r,e.slice(0,32)),dK=nu.verify,nt=r=>Ne.isBuffer(r)?r:r instanceof Uint8Array?Ne.from(r.buffer,r.byteOffset,r.byteLength):Ne.from(r);let $m=class{constructor(e){Object.assign(this,e)}encode(){return Ne.from(C2(Cf,this))}static decode(e){return B2(Cf,this,e)}static decodeUnchecked(e){return S2(Cf,this,e)}};class pK extends $m{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const Cf=new Map;var Rx;const Ix=32,Wi=32;function gK(r){return r._bn!==void 0}let Sx=1;class me extends $m{constructor(e){if(super({}),this._bn=void 0,gK(e))this._bn=e._bn;else{if(typeof e=="string"){const t=Or.decode(e);if(t.length!=Wi)throw new Error("Invalid public key input");this._bn=new vs(t)}else this._bn=new vs(e);if(this._bn.byteLength()>Wi)throw new Error("Invalid public key input")}}static unique(){const e=new me(Sx);return Sx+=1,new me(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Or.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Ne);if(e.length===Wi)return e;const t=Ne.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const i=Ne.concat([e.toBuffer(),Ne.from(t),n.toBuffer()]),s=gm(i);return new me(s)}static createProgramAddressSync(e,t){let n=Ne.alloc(0);e.forEach(function(s){if(s.length>Ix)throw new TypeError("Max seed length exceeded");n=Ne.concat([n,nt(s)])}),n=Ne.concat([n,t.toBuffer(),Ne.from("ProgramDerivedAddress")]);const i=gm(n);if(xx(i))throw new Error("Invalid seeds, address must fall off the curve");return new me(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,i;for(;n!=0;){try{const s=e.concat(Ne.from([n]));i=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new me(e);return xx(t.toBytes())}}Rx=me,me.default=new Rx("11111111111111111111111111111111"),Cf.set(me,{kind:"struct",fields:[["_bn","u256"]]});class yK{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=nt(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=nt(hK()),this._publicKey=nt(R0(this._secretKey))}get publicKey(){return new me(this._publicKey)}get secretKey(){return Ne.concat([this._secretKey,this._publicKey],64)}}const mK=new me("BPFLoader1111111111111111111111111111111111"),bo=1232,I0=127,Bf=64;class Fm extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Fm.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Hm extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Hm.prototype,"name",{value:"TransactionExpiredTimeoutError"});class uu extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(uu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Pf{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((s,o)=>{n.set(s.toBase58(),o)});const i=s=>{const o=n.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const lt=(r="publicKey")=>Wt(32,r),wK=(r="signature")=>Wt(64,r),Ia=(r="string")=>{const e=Me([Pe("length"),Pe("lengthPadding"),Wt(mo(Pe(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(s,o)=>t(s,o).chars.toString(),i.encode=(s,o,a)=>{const u={chars:Ne.from(s,"utf8")};return n(u,o,a)},i.alloc=s=>Pe().span+Pe().span+Ne.from(s,"utf8").length,i},bK=(r="authorized")=>Me([lt("staker"),lt("withdrawer")],r),_K=(r="lockup")=>Me([Hn("unixTimestamp"),Hn("epoch"),lt("custodian")],r),AK=(r="voteInit")=>Me([lt("nodePubkey"),lt("authorizedVoter"),lt("authorizedWithdrawer"),bt("commission")],r),vK=(r="voteAuthorizeWithSeedArgs")=>Me([Pe("voteAuthorizationType"),lt("currentAuthorityDerivedKeyOwnerPubkey"),Ia("currentAuthorityDerivedKeySeed"),lt("newAuthorized")],r);function kx(r,e){const t=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(e[i.property]);if("count"in i&&"elementLayout"in i){const s=e[i.property];if(Array.isArray(s))return s.length*t(i.elementLayout)}else if("fields"in i)return kx({layout:i},e[i.property]);return 0};let n=0;return r.layout.fields.forEach(i=>{n+=t(i)}),n}function Tn(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,!(n&128))break}return e}function zn(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function vt(r,e){if(!r)throw new Error(e||"Assertion failed")}class S0{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const n=new Map,i=o=>{const a=o.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},s=i(t);s.isSigner=!0,s.isWritable=!0;for(const o of e){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new S0(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];vt(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),i=e.filter(([,u])=>!u.isSigner&&u.isWritable),s=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{vt(t.length>0,"Expected at least one writable signer key");const[u]=t[0];vt(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([u])=>new me(u)),...n.map(([u])=>new me(u)),...i.map(([u])=>new me(u)),...s.map(([u])=>new me(u))];return[o,a]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(e,t){const n=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(t(o)){const a=new me(s),u=e.findIndex(l=>l.equals(a));u>=0&&(vt(u<256,"Max lookup table index exceeded"),n.push(u),i.push(a),this.keyMetaMap.delete(s))}return[n,i]}}const Tx="Reached end of buffer unexpectedly";function qi(r){if(r.length===0)throw new Error(Tx);return r.shift()}function On(r,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>r.length:t>=r.length)throw new Error(Tx);return r.splice(...e)}class Ei{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new me(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Or.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Pf(this.staticAccountKeys)}static compile(e){const t=S0.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new Pf(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Or.encode(a.data)}));return new Ei({header:n,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<s}else{const n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];zn(t,e);const n=this.instructions.map(g=>{const{accounts:b,programIdIndex:w}=g,I=Array.from(Or.decode(g.data));let S=[];zn(S,b.length);let x=[];return zn(x,I.length),{programIdIndex:w,keyIndicesCount:Ne.from(S),keyIndices:b,dataLength:Ne.from(x),data:I}});let i=[];zn(i,n.length);let s=Ne.alloc(bo);Ne.from(i).copy(s);let o=i.length;n.forEach(g=>{const w=Me([bt("programIdIndex"),Wt(g.keyIndicesCount.length,"keyIndicesCount"),Wr(bt("keyIndex"),g.keyIndices.length,"keyIndices"),Wt(g.dataLength.length,"dataLength"),Wr(bt("userdatum"),g.data.length,"data")]).encode(g,s,o);o+=w}),s=s.slice(0,o);const a=Me([Wt(1,"numRequiredSignatures"),Wt(1,"numReadonlySignedAccounts"),Wt(1,"numReadonlyUnsignedAccounts"),Wt(t.length,"keyCount"),Wr(lt("key"),e,"keys"),lt("recentBlockhash")]),u={numRequiredSignatures:Ne.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ne.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ne.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ne.from(t),keys:this.accountKeys.map(g=>nt(g.toBytes())),recentBlockhash:Or.decode(this.recentBlockhash)};let l=Ne.alloc(2048);const h=a.encode(u,l);return s.copy(l,h),l.slice(0,h+s.length)}static from(e){let t=[...e];const n=qi(t);if(n!==(n&I0))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=qi(t),s=qi(t),o=Tn(t);let a=[];for(let b=0;b<o;b++){const w=On(t,0,Wi);a.push(new me(Ne.from(w)))}const u=On(t,0,Wi),l=Tn(t);let h=[];for(let b=0;b<l;b++){const w=qi(t),I=Tn(t),S=On(t,0,I),x=Tn(t),C=On(t,0,x),H=Or.encode(Ne.from(C));h.push({programIdIndex:w,accounts:S,data:H})}const g={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:Or.encode(Ne.from(u)),accountKeys:a,instructions:h};return new Ei(g)}}class Sa{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Pf(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){const i=e-n,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){const i=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=t-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const i=e.find(s=>s.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const s of n.writableIndexes)if(s<i.state.addresses.length)t.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(const s of n.readonlyIndexes)if(s<i.state.addresses.length)t.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){const t=S0.compile(e.instructions,e.payerKey),n=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(const h of s){const g=t.extractTableLookup(h);if(g!==void 0){const[b,{writable:w,readonly:I}]=g;n.push(b),i.writable.push(...w),i.readonly.push(...I)}}const[o,a]=t.getMessageComponents(),l=new Pf(a,i).compileInstructions(e.instructions);return new Sa({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:l,addressTableLookups:n})}serialize(){const e=Array();zn(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();zn(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();zn(s,this.addressTableLookups.length);const o=Me([bt("prefix"),Me([bt("numRequiredSignatures"),bt("numReadonlySignedAccounts"),bt("numReadonlyUnsignedAccounts")],"header"),Wt(e.length,"staticAccountKeysLength"),Wr(lt(),this.staticAccountKeys.length,"staticAccountKeys"),lt("recentBlockhash"),Wt(n.length,"instructionsLength"),Wt(t.length,"serializedInstructions"),Wt(s.length,"addressTableLookupsLength"),Wt(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(bo),l=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:Or.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,l)}serializeInstructions(){let e=0;const t=new Uint8Array(bo);for(const n of this.compiledInstructions){const i=Array();zn(i,n.accountKeyIndexes.length);const s=Array();zn(s,n.data.length);const o=Me([bt("programIdIndex"),Wt(i.length,"encodedAccountKeyIndexesLength"),Wr(bt(),n.accountKeyIndexes.length,"accountKeyIndexes"),Wt(s.length,"encodedDataLength"),Wt(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(bo);for(const n of this.addressTableLookups){const i=Array();zn(i,n.writableIndexes.length);const s=Array();zn(s,n.readonlyIndexes.length);const o=Me([lt("accountKey"),Wt(i.length,"encodedWritableIndexesLength"),Wr(bt(),n.writableIndexes.length,"writableIndexes"),Wt(s.length,"encodedReadonlyIndexesLength"),Wr(bt(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=qi(t),i=n&I0;vt(n!==i,"Expected versioned message but received legacy message");const s=i;vt(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:qi(t),numReadonlySignedAccounts:qi(t),numReadonlyUnsignedAccounts:qi(t)},a=[],u=Tn(t);for(let I=0;I<u;I++)a.push(new me(On(t,0,Wi)));const l=Or.encode(On(t,0,Wi)),h=Tn(t),g=[];for(let I=0;I<h;I++){const S=qi(t),x=Tn(t),C=On(t,0,x),H=Tn(t),D=new Uint8Array(On(t,0,H));g.push({programIdIndex:S,accountKeyIndexes:C,data:D})}const b=Tn(t),w=[];for(let I=0;I<b;I++){const S=new me(On(t,0,Wi)),x=Tn(t),C=On(t,0,x),H=Tn(t),D=On(t,0,H);w.push({accountKey:S,writableIndexes:C,readonlyIndexes:D})}return new Sa({header:o,staticAccountKeys:a,recentBlockhash:l,compiledInstructions:g,addressTableLookups:w})}}const zm={deserializeMessageVersion(r){const e=r[0],t=e&I0;return t===e?"legacy":t},deserialize:r=>{const e=zm.deserializeMessageVersion(r);if(e==="legacy")return Ei.from(r);if(e===0)return Sa.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let ks=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const EK=Ne.alloc(Bf).fill(0);class Pt{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Ne.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}let Ot=class L_{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){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,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{const{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}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(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Pt(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let S=0;S<t.length;S++)if(t[S].programId===void 0)throw new Error(`Transaction instruction index ${S} has undefined program id`);const i=[],s=[];t.forEach(S=>{S.keys.forEach(C=>{s.push({...C})});const x=S.programId.toString();i.includes(x)||i.push(x)}),i.forEach(S=>{s.push({pubkey:new me(S),isSigner:!1,isWritable:!1})});const o=[];s.forEach(S=>{const x=S.pubkey.toString(),C=o.findIndex(H=>H.pubkey.toString()===x);C>-1?(o[C].isWritable=o[C].isWritable||S.isWritable,o[C].isSigner=o[C].isSigner||S.isSigner):o.push(S)}),o.sort(function(S,x){if(S.isSigner!==x.isSigner)return S.isSigner?-1:1;if(S.isWritable!==x.isWritable)return S.isWritable?-1:1;const C={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return S.pubkey.toBase58().localeCompare(x.pubkey.toBase58(),"en",C)});const a=o.findIndex(S=>S.pubkey.equals(n));if(a>-1){const[S]=o.splice(a,1);S.isSigner=!0,S.isWritable=!0,o.unshift(S)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const S of this.signatures){const x=o.findIndex(C=>C.pubkey.equals(S.publicKey));if(x>-1)o[x].isSigner||(o[x].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: ${S.publicKey.toString()}`)}let u=0,l=0,h=0;const g=[],b=[];o.forEach(({pubkey:S,isSigner:x,isWritable:C})=>{x?(g.push(S.toString()),u+=1,C||(l+=1)):(b.push(S.toString()),C||(h+=1))});const w=g.concat(b),I=t.map(S=>{const{data:x,programId:C}=S;return{programIdIndex:w.indexOf(C.toString()),accounts:S.keys.map(H=>w.indexOf(H.pubkey.toString())),data:Or.encode(x)}});return I.forEach(S=>{vt(S.programIdIndex>=0),S.accounts.forEach(x=>vt(x>=0))}),new Ei({header:{numRequiredSignatures:u,numReadonlySignedAccounts:l,numReadonlyUnsignedAccounts:h},accountKeys:w,recentBlockhash:e,instructions:I})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((i,s)=>t[s].equals(i.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(n=>{const i=n.toString();return t.has(i)?!1:(t.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}const i=this._compile();this._partialSign(i,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(i=>{const s=Dm(n,i.secretKey);this._addSignature(i.publicKey,nt(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){vt(t.length===64);const n=this.signatures.findIndex(i=>e.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=Ne.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const n={};for(const{signature:i,publicKey:s}of this.signatures)i===null?t&&(n.missing||(n.missing=[])).push(s):dK(i,e,s.toBytes())||(n.invalid||(n.invalid=[])).push(s);return n.invalid||n.missing?n:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(n){const s=this._getMessageSignednessErrors(i,t);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
|
|
19
|
+
Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
|
|
20
|
+
Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){const{signatures:t}=this,n=[];zn(n,t.length);const i=n.length+t.length*64+e.length,s=Ne.alloc(i);return vt(t.length<256),Ne.from(n).copy(s,0),t.forEach(({signature:o},a)=>{o!==null&&(vt(o.length===64,"signature has invalid length"),Ne.from(o).copy(s,n.length+a*64))}),e.copy(s,n.length+t.length*64),vt(s.length<=bo,`Transaction too large: ${s.length} > ${bo}`),s}get keys(){return vt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return vt(this.instructions.length===1),this.instructions[0].programId}get data(){return vt(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const n=Tn(t);let i=[];for(let s=0;s<n;s++){const o=On(t,0,Bf);i.push(Or.encode(Ne.from(o)))}return L_.populate(Ei.from(t),i)}static populate(e,t=[]){const n=new L_;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((i,s)=>{const o={signature:i==Or.encode(EK)?null:Or.decode(i),publicKey:e.accountKeys[s]};n.signatures.push(o)}),e.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});n.instructions.push(new Pt({keys:s,programId:e.accountKeys[i.programIdIndex],data:Or.decode(i.data)}))}),n._message=e,n._json=n.toJSON(),n}};class Gm{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:n,compiledInstructions:i,recentBlockhash:s}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=n,l=o-a;vt(l>0,"Message header is invalid");const h=e.staticAccountKeys.length-o-u;vt(h>=0,"Message header is invalid");const g=e.getAccountKeys(t),b=g.get(0);if(b===void 0)throw new Error("Failed to decompile message because no account keys were found");const w=[];for(const I of i){const S=[];for(const C of I.accountKeyIndexes){const H=g.get(C);if(H===void 0)throw new Error(`Failed to find key for account key index ${C}`);const D=C<o;let z;D?z=C<l:C<g.staticAccountKeys.length?z=C-o<h:z=C-g.staticAccountKeys.length<g.accountKeysFromLookups.writable.length,S.push({pubkey:H,isSigner:C<n.numRequiredSignatures,isWritable:z})}const x=g.get(I.programIdIndex);if(x===void 0)throw new Error(`Failed to find program id for program id index ${I.programIdIndex}`);w.push(new Pt({programId:x,data:nt(I.data),keys:S}))}return new Gm({payerKey:b,instructions:w,recentBlockhash:s})}compileToLegacyMessage(){return Ei.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Sa.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class Vm{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)vt(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const n=[];for(let i=0;i<e.header.numRequiredSignatures;i++)n.push(new Uint8Array(Bf));this.signatures=n}this.message=e}serialize(){const e=this.message.serialize(),t=Array();zn(t,this.signatures.length);const n=Me([Wt(t.length,"encodedSignaturesLength"),Wr(wK(),this.signatures.length,"signatures"),Wt(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e];const n=[],i=Tn(t);for(let o=0;o<i;o++)n.push(new Uint8Array(On(t,0,Bf)));const s=zm.deserialize(new Uint8Array(t));return new Vm(s,n)}sign(e){const t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const s=n.findIndex(o=>o.equals(i.publicKey));vt(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Dm(t,i.secretKey)}}addSignature(e,t){vt(t.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));vt(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=t}}const Ox=1e3/(160/64),Zi=new me("SysvarC1ock11111111111111111111111111111111"),xK=new me("SysvarEpochSchedu1e111111111111111111111111"),RK=new me("Sysvar1nstructions1111111111111111111111111"),k0=new me("SysvarRecentB1ockHashes11111111111111111111"),lu=new me("SysvarRent111111111111111111111111111111111"),IK=new me("SysvarRewards111111111111111111111111111111"),SK=new me("SysvarS1otHashes111111111111111111111111111"),kK=new me("SysvarS1otHistory11111111111111111111111111"),T0=new me("SysvarStakeHistory1111111111111111111111111");class _o extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:i}){const s=i?`Logs:
|
|
21
|
+
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(e){case"send":a=`Transaction ${t} resulted in an error.
|
|
22
|
+
${n}. `+s+o;break;case"simulate":a=`Simulation failed.
|
|
23
|
+
Message: ${n}.
|
|
24
|
+
`+s+o;break;default:a=`Unknown action '${(u=>u)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,t(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const TK={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 $e extends Error{constructor({code:e,message:t,data:n},i){super(i!=null?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}async function jm(r,e,t,n){const i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await r.sendTransaction(e,t,i);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,u=a.keys[0].pubkey;o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else(n==null?void 0:n.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 r.confirmTransaction(s,n&&n.commitment)).value;if(o.err)throw s!=null?new _o({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function ka(r){return new Promise(e=>setTimeout(e,r))}function yt(r,e){const t=r.layout.span>=0?r.layout.span:kx(r,e),n=Ne.alloc(t),i=Object.assign({instruction:r.index},e);return r.layout.encode(i,n),n}function kt(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.instruction!==r.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${r.index}`);return t}const Nx=Kr("lamportsPerSignature"),Cx=Me([Pe("version"),Pe("state"),lt("authorizedPubkey"),lt("nonce"),Me([Nx],"feeCalculator")]),Km=Cx.span;class O0{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Cx.decode(nt(e),0);return new O0({authorizedPubkey:new me(t.authorizedPubkey),nonce:new me(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const OK=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},fu=(r=>e=>{const t=Wt(r,e),{encode:n,decode:i}=OK(t),s=t;return s.decode=(o,a)=>{const u=i(o,a);return oj(Ne.from(u))},s.encode=(o,a,u)=>{const l=Y2(o,r);return n(l,a,u)},s})(8);class NK{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ht))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:n,programId:i}=kt(Ht.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new me(i)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=kt(Ht.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:n,programId:i}=kt(Ht.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new me(i)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=kt(Ht.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,space:i,programId:s}=kt(Ht.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,space:i,programId:new me(s)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=kt(Ht.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new me(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,programId:i}=kt(Ht.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,programId:new me(i)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:n,lamports:i,space:s,programId:o}=kt(Ht.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new me(t),seed:n,lamports:i,space:s,programId:new me(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=kt(Ht.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new me(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ht.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt(Ht.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=kt(Ht.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new me(t)}}static checkProgramId(e){if(!e.equals(Br.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Ht=Object.freeze({Create:{index:0,layout:Me([Pe("instruction"),Hn("lamports"),Hn("space"),lt("programId")])},Assign:{index:1,layout:Me([Pe("instruction"),lt("programId")])},Transfer:{index:2,layout:Me([Pe("instruction"),fu("lamports")])},CreateWithSeed:{index:3,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),Hn("lamports"),Hn("space"),lt("programId")])},AdvanceNonceAccount:{index:4,layout:Me([Pe("instruction")])},WithdrawNonceAccount:{index:5,layout:Me([Pe("instruction"),Hn("lamports")])},InitializeNonceAccount:{index:6,layout:Me([Pe("instruction"),lt("authorized")])},AuthorizeNonceAccount:{index:7,layout:Me([Pe("instruction"),lt("authorized")])},Allocate:{index:8,layout:Me([Pe("instruction"),Hn("space")])},AllocateWithSeed:{index:9,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),Hn("space"),lt("programId")])},AssignWithSeed:{index:10,layout:Me([Pe("instruction"),lt("base"),Ia("seed"),lt("programId")])},TransferWithSeed:{index:11,layout:Me([Pe("instruction"),fu("lamports"),Ia("seed"),lt("programId")])},UpgradeNonceAccount:{index:12,layout:Me([Pe("instruction")])}});class Br{constructor(){}static createAccount(e){const t=Ht.Create,n=yt(t,{lamports:e.lamports,space:e.space,programId:nt(e.programId.toBuffer())});return new Pt({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){const i=Ht.TransferWithSeed;t=yt(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=Ht.Transfer;t=yt(i,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const i=Ht.AssignWithSeed;t=yt(i,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Assign;t=yt(i,{programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Ht.CreateWithSeed,n=yt(t,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:nt(e.programId.toBuffer())});let i=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||i.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Pt({keys:i,programId:this.programId,data:n})}static createNonceAccount(e){const t=new Ot;"basePubkey"in e&&"seed"in e?t.add(Br.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Km,programId:this.programId})):t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Km,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=Ht.InitializeNonceAccount,n=yt(t,{authorized:nt(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Pt(i)}static nonceAdvance(e){const t=Ht.AdvanceNonceAccount,n=yt(t),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Pt(i)}static nonceWithdraw(e){const t=Ht.WithdrawNonceAccount,n=yt(t,{lamports:e.lamports});return new Pt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:k0,isSigner:!1,isWritable:!1},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=Ht.AuthorizeNonceAccount,n=yt(t,{authorized:nt(e.newAuthorizedPubkey.toBuffer())});return new Pt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){const i=Ht.AllocateWithSeed;t=yt(i,{base:nt(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:nt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Allocate;t=yt(i,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:n,programId:this.programId,data:t})}}Br.programId=new me("11111111111111111111111111111111");const CK=bo-300;class Ta{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Ta.chunkSize)+1+1)}static async load(e,t,n,i,s){{const g=await e.getMinimumBalanceForRentExemption(s.length),b=await e.getAccountInfo(n.publicKey,"confirmed");let w=null;if(b!==null){if(b.executable)return console.error("Program load failed, account is already executable"),!1;b.data.length!==s.length&&(w=w||new Ot,w.add(Br.allocate({accountPubkey:n.publicKey,space:s.length}))),b.owner.equals(i)||(w=w||new Ot,w.add(Br.assign({accountPubkey:n.publicKey,programId:i}))),b.lamports<g&&(w=w||new Ot,w.add(Br.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:g-b.lamports})))}else w=new Ot().add(Br.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:g>0?g:1,space:s.length,programId:i}));w!==null&&await jm(e,w,[t,n],{commitment:"confirmed"})}const o=Me([Pe("instruction"),Pe("offset"),Pe("bytesLength"),Pe("bytesLengthPadding"),Wr(bt("byte"),mo(Pe(),-8),"bytes")]),a=Ta.chunkSize;let u=0,l=s,h=[];for(;l.length>0;){const g=l.slice(0,a),b=Ne.alloc(a+16);o.encode({instruction:0,offset:u,bytes:g,bytesLength:0,bytesLengthPadding:0},b);const w=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:b});h.push(jm(e,w,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await ka(1e3/4),u+=a,l=l.slice(a)}await Promise.all(h);{const g=Me([Pe("instruction")]),b=Ne.alloc(g.span);g.encode({instruction:1},b);const w=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:i,data:b}),I="processed",S=await e.sendTransaction(w,[t,n],{preflightCommitment:I}),{context:x,value:C}=await e.confirmTransaction({signature:S,lastValidBlockHeight:w.lastValidBlockHeight,blockhash:w.recentBlockhash},I);if(C.err)throw new Error(`Transaction ${S} failed (${JSON.stringify(C)})`);for(;;){try{if(await e.getSlot({commitment:I})>x.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(Ox/2)))}}return!0}}Ta.chunkSize=CK;const BK=new me("BPFLoader2111111111111111111111111111111111");class PK{static getMinNumSignatures(e){return Ta.getMinNumSignatures(e)}static load(e,t,n,i,s){return Ta.load(e,t,n,s,i)}}function MK(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wm,Bx;function LK(){if(Bx)return Wm;Bx=1;var r=Object.prototype.toString,e=Object.keys||function(n){var i=[];for(var s in n)i.push(s);return i};function t(n,i){var s,o,a,u,l,h,g;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return t(n.toJSON(),i);if(g=r.call(n),g==="[object Array]"){for(a="[",o=n.length-1,s=0;s<o;s++)a+=t(n[s],!0)+",";return o>-1&&(a+=t(n[s],!0)),a+"]"}else if(g==="[object Object]"){for(u=e(n).sort(),o=u.length,a="",s=0;s<o;)l=u[s],h=t(n[l],!1),h!==void 0&&(a&&(a+=","),a+=JSON.stringify(l)+":"+h),s++;return"{"+a+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return Wm=function(n){var i=t(n,!1);if(i!==void 0)return""+i},Wm}var UK=LK(),Px=MK(UK);const Mf=32;function qm(r){let e=0;for(;r>1;)r/=2,e++;return e}function DK(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class Mx{constructor(e,t,n,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=qm(DK(e+Mf+1))-qm(Mf)-1,n=this.getSlotsInEpoch(t),i=e-(n-Mf);return[t,i]}else{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),i=this.firstNormalEpoch+n,s=t%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Mf:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+qm(Mf)):this.slotsPerEpoch}}var $K=globalThis.fetch;class FK extends jj{constructor(e,t,n){const i=s=>{const o=Gj(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,e,t,n),this.underlyingSocket=void 0}call(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function HK(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}const Lx=56;class Zm{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=HK(zK,e),n=e.length-Lx;vt(n>=0,"lookup table is invalid"),vt(n%32===0,"lookup table is invalid");const i=n/32,{addresses:s}=Me([Wr(lt(),i,"addresses")]).decode(e.slice(Lx));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new me(t.authority[0]):void 0,addresses:s.map(o=>new me(o))}}}const zK={index:1,layout:Me([Pe("typeIndex"),fu("deactivationSlot"),Kr("lastExtendedSlot"),bt("lastExtendedStartIndex"),bt(),Wr(lt(),mo(bt(),-1),"authority")])},GK=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function VK(r){const e=r.match(GK);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[t,n,i,s]=e,o=r.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${n}${u}${s}`}const nr=Tf(Tm(me),_e(),r=>new me(r)),Ux=Om([_e(),rr("base64")]),Qm=Tf(Tm(Ne),Ux,r=>Ne.from(r[0],"base64")),Dx=30*1e3;function jK(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function zt(r){let e,t;if(typeof r=="string")e=r;else if(r){const{commitment:n,...i}=r;e=n,t=i}return{commitment:e,config:t}}function $x(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function Fx(r){return gn([pe({jsonrpc:rr("2.0"),id:_e(),result:r}),pe({jsonrpc:rr("2.0"),id:_e(),error:pe({code:cu(),message:_e(),data:He(gj())})})])}const KK=Fx(cu());function it(r){return Tf(Fx(r),KK,e=>"error"in e?e:{...e,result:Ae(e.result,r)})}function Er(r){return it(pe({context:pe({slot:X()}),value:r}))}function N0(r){return pe({context:pe({slot:X()}),value:r})}function Ym(r,e){return r===0?new Sa({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new me(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Or.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Ei(e)}const WK=pe({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),qK=it(Re(Ie(pe({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:He(Ie(X()))})))),ZK=Re(pe({slot:X(),prioritizationFee:X()})),QK=pe({total:X(),validator:X(),foundation:X(),epoch:X()}),YK=pe({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:He(X()),transactionCount:He(X())}),JK=pe({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:Ki(),firstNormalEpoch:X(),firstNormalSlot:X()}),XK=tx(_e(),Re(X())),Oa=Ie(gn([pe({}),_e()])),eW=pe({err:Oa}),tW=rr("receivedSignature"),rW=pe({"solana-core":_e(),"feature-set":He(X())}),nW=pe({program:_e(),programId:nr,parsed:cu()}),iW=pe({programId:nr,accounts:Re(nr),data:_e()}),Hx=Er(pe({err:Ie(gn([pe({}),_e()])),logs:Ie(Re(_e())),accounts:He(Ie(Re(Ie(pe({executable:Ki(),owner:_e(),lamports:X(),data:Re(_e()),rentEpoch:He(X())}))))),unitsConsumed:He(X()),returnData:He(Ie(pe({programId:_e(),data:Om([_e(),rr("base64")])}))),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(gn([nW,iW]))}))))})),sW=Er(pe({byIdentity:tx(_e(),Re(X())),range:pe({firstSlot:X(),lastSlot:X()})}));function oW(r,e,t,n,i,s){const o=t||$K;let a;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 n&&(u=async(h,g)=>{const b=await new Promise((w,I)=>{try{n(h,g,(S,x)=>w([S,x]))}catch(S){I(S)}});return await o(...b)}),new Fj(async(h,g)=>{const b={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},oq)};try{let w=5,I,S=500;for(;u?I=await u(r,b):I=await o(r,b),!(I.status!==429||i===!0||(w-=1,w===0));)console.error(`Server responded with ${I.status} ${I.statusText}. Retrying after ${S}ms delay...`),await ka(S),S*=2;const x=await I.text();I.ok?g(null,x):g(new Error(`${I.status} ${I.statusText}: ${x}`))}catch(w){w instanceof Error&&g(w)}},{})}function aW(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function cW(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);const i=e.map(s=>r.request(s.methodName,s.args));r.request(i,(s,o)=>{if(s){n(s);return}t(o)})})}const uW=it(WK),lW=it(QK),fW=it(ZK),hW=it(YK),dW=it(JK),pW=it(XK),gW=it(X()),yW=Er(pe({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Re(nr)})),Jm=pe({amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}),mW=Er(Re(pe({address:nr,amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}))),wW=Er(Re(pe({pubkey:nr,account:pe({executable:Ki(),owner:nr,lamports:X(),data:Qm,rentEpoch:X()})}))),Xm=pe({program:_e(),parsed:cu(),space:X()}),bW=Er(Re(pe({pubkey:nr,account:pe({executable:Ki(),owner:nr,lamports:X(),data:Xm,rentEpoch:X()})}))),_W=Er(Re(pe({lamports:X(),address:nr}))),Lf=pe({executable:Ki(),owner:nr,lamports:X(),data:Qm,rentEpoch:X()}),AW=pe({pubkey:nr,account:Lf}),vW=Tf(gn([Tm(Ne),Xm]),gn([Ux,Xm]),r=>Array.isArray(r)?Ae(r,Qm):r),e1=pe({executable:Ki(),owner:nr,lamports:X(),data:vW,rentEpoch:X()}),EW=pe({pubkey:nr,account:e1}),xW=pe({state:gn([rr("active"),rr("inactive"),rr("activating"),rr("deactivating")]),active:X(),inactive:X()}),RW=it(Re(pe({signature:_e(),slot:X(),err:Oa,memo:Ie(_e()),blockTime:He(Ie(X()))}))),IW=it(Re(pe({signature:_e(),slot:X(),err:Oa,memo:Ie(_e()),blockTime:He(Ie(X()))}))),SW=pe({subscription:X(),result:N0(Lf)}),kW=pe({pubkey:nr,account:Lf}),TW=pe({subscription:X(),result:N0(kW)}),OW=pe({parent:X(),slot:X(),root:X()}),NW=pe({subscription:X(),result:OW}),CW=gn([pe({type:gn([rr("firstShredReceived"),rr("completed"),rr("optimisticConfirmation"),rr("root")]),slot:X(),timestamp:X()}),pe({type:rr("createdBank"),parent:X(),slot:X(),timestamp:X()}),pe({type:rr("frozen"),slot:X(),timestamp:X(),stats:pe({numTransactionEntries:X(),numSuccessfulTransactions:X(),numFailedTransactions:X(),maxTransactionsPerEntry:X()})}),pe({type:rr("dead"),slot:X(),timestamp:X(),err:_e()})]),BW=pe({subscription:X(),result:CW}),PW=pe({subscription:X(),result:N0(gn([eW,tW]))}),MW=pe({subscription:X(),result:X()}),LW=pe({pubkey:_e(),gossip:Ie(_e()),tpu:Ie(_e()),rpc:Ie(_e()),version:Ie(_e())}),zx=pe({votePubkey:_e(),nodePubkey:_e(),activatedStake:X(),epochVoteAccount:Ki(),epochCredits:Re(Om([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:Ie(X())}),UW=it(pe({current:Re(zx),delinquent:Re(zx)})),DW=gn([rr("processed"),rr("confirmed"),rr("finalized")]),$W=pe({slot:X(),confirmations:Ie(X()),err:Oa,confirmationStatus:He(DW)}),FW=Er(Re(Ie($W))),HW=it(X()),Gx=pe({accountKey:nr,writableIndexes:Re(X()),readonlyIndexes:Re(X())}),t1=pe({signatures:Re(_e()),message:pe({accountKeys:Re(_e()),header:pe({numRequiredSignatures:X(),numReadonlySignedAccounts:X(),numReadonlyUnsignedAccounts:X()}),instructions:Re(pe({accounts:Re(X()),data:_e(),programIdIndex:X()})),recentBlockhash:_e(),addressTableLookups:He(Re(Gx))})}),Vx=pe({pubkey:nr,signer:Ki(),writable:Ki(),source:He(gn([rr("transaction"),rr("lookupTable")]))}),jx=pe({accountKeys:Re(Vx),signatures:Re(_e())}),Kx=pe({parsed:cu(),program:_e(),programId:nr}),Wx=pe({accounts:Re(nr),data:_e(),programId:nr}),zW=gn([Wx,Kx]),GW=gn([pe({parsed:cu(),program:_e(),programId:_e()}),pe({accounts:Re(_e()),data:_e(),programId:_e()})]),qx=Tf(zW,GW,r=>"accounts"in r?Ae(r,Wx):Ae(r,Kx)),Zx=pe({signatures:Re(_e()),message:pe({accountKeys:Re(Vx),instructions:Re(qx),recentBlockhash:_e(),addressTableLookups:He(Ie(Re(Gx)))})}),C0=pe({accountIndex:X(),mint:_e(),owner:He(_e()),programId:He(_e()),uiTokenAmount:Jm}),Qx=pe({writable:Re(nr),readonly:Re(nr)}),B0=pe({err:Oa,fee:X(),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(pe({accounts:Re(X()),data:_e(),programIdIndex:X()}))})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:He(Ie(Re(_e()))),preTokenBalances:He(Ie(Re(C0))),postTokenBalances:He(Ie(Re(C0))),loadedAddresses:He(Qx),computeUnitsConsumed:He(X())}),r1=pe({err:Oa,fee:X(),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(qx)})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:He(Ie(Re(_e()))),preTokenBalances:He(Ie(Re(C0))),postTokenBalances:He(Ie(Re(C0))),loadedAddresses:He(Qx),computeUnitsConsumed:He(X())}),hu=gn([rr(0),rr("legacy")]),Na=pe({pubkey:_e(),lamports:X(),postBalance:Ie(X()),rewardType:Ie(_e()),commission:He(Ie(X()))}),VW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:t1,meta:Ie(B0),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),jW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),KW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:jx,meta:Ie(B0),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),WW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Zx,meta:Ie(r1),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),qW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:jx,meta:Ie(r1),version:He(hu)})),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),ZW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Na)),blockTime:Ie(X()),blockHeight:Ie(X())}))),QW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:t1,meta:Ie(B0)})),rewards:He(Re(Na)),blockTime:Ie(X())}))),Yx=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),signatures:Re(_e()),blockTime:Ie(X())}))),n1=it(Ie(pe({slot:X(),meta:Ie(B0),blockTime:He(Ie(X())),transaction:t1,version:He(hu)}))),P0=it(Ie(pe({slot:X(),transaction:Zx,meta:Ie(r1),blockTime:He(Ie(X())),version:He(hu)}))),YW=Er(pe({blockhash:_e(),lastValidBlockHeight:X()})),JW=Er(Ki()),XW=pe({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),eq=it(Re(XW)),tq=Er(Ie(pe({feeCalculator:pe({lamportsPerSignature:X()})}))),rq=it(_e()),nq=it(_e()),iq=pe({err:Oa,logs:Re(_e()),signature:_e()}),sq=pe({result:N0(iq),subscription:X()}),oq={"solana-client":"js/1.0.0-maintenance"};class Jx{constructor(e,t){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 l={};return async h=>{const{commitment:g,config:b}=zt(h),w=this._buildArgs([],g,void 0,b),I=Px(w);return l[I]=l[I]??(async()=>{try{const S=await this._rpcRequest("getBlockHeight",w),x=Ae(S,it(X()));if("error"in x)throw new $e(x.error,"failed to get block height information");return x.result}finally{delete l[I]}})(),await l[I]}})();let n,i,s,o,a,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=jK(e),this._rpcWsEndpoint=n||VK(e),this._rpcClient=oW(e,i,s,o,a,u),this._rpcRequest=aW(this._rpcClient),this._rpcBatchRequest=cW(this._rpcClient),this._rpcWebSocket=new FK(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(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",s),a=Ae(o,Er(X()));if("error"in a)throw new $e(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=Ae(t,it(Ie(X())));if("error"in n)throw new $e(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=Ae(e,it(X()));if("error"in t)throw new $e(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=Ae(e,gW);if("error"in t)throw new $e(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),i=Ae(n,yW);if("error"in i)throw new $e(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",n),s=Ae(i,Er(Jm));if("error"in s)throw new $e(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",n),s=Ae(i,Er(Jm));if("error"in s)throw new $e(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,n){const{commitment:i,config:s}=zt(n);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",a),l=Ae(u,wW);if("error"in l)throw new $e(l.error,`failed to get token accounts owned by account ${e.toBase58()}`);return l.result}async getParsedTokenAccountsByOwner(e,t,n){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});const s=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),a=Ae(o,bW);if("error"in a)throw new $e(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",n),s=Ae(i,_W);if("error"in s)throw new $e(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",n),s=Ae(i,mW);if("error"in s)throw new $e(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,Er(Ie(Lf)));if("error"in a)throw new $e(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,Er(Ie(e1)));if("error"in a)throw new $e(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:i}=zt(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,Er(Re(Ie(e1))));if("error"in u)throw new $e(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:i}=zt(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,Er(Re(Ie(Lf))));if("error"in u)throw new $e(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){const{commitment:i,config:s}=zt(t),o=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:n??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=Ae(a,it(xW));if("error"in u)throw new $e(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){const{commitment:n,config:i}=zt(t),{encoding:s,...o}=i||{},a=this._buildArgs([e.toBase58()],n,s||"base64",{...o,...o.filters?{filters:$x(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),l=Re(AW),h=o.withContext===!0?Ae(u,Er(l)):Ae(u,it(l));if("error"in h)throw new $e(h.error,`failed to get accounts owned by program ${e.toBase58()}`);return h.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),a=Ae(o,it(Re(EW)));if("error"in a)throw new $e(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var s;let n;if(typeof e=="string")n=e;else{const o=e;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let i;try{i=Or.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return vt(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,i,s=!1;const o=new Promise((u,l)=>{try{n=this.onSignature(t,(g,b)=>{n=void 0;const w={context:b,value:g};u({__type:ks.PROCESSED,response:w})},e);const h=new Promise(g=>{n==null?g():i=this._onSubscriptionStateChange(n,b=>{b==="subscribed"&&g()})});(async()=>{if(await h,s)return;const g=await this.getSignatureStatus(t);if(s||g==null)return;const{context:b,value:w}=g;if(w!=null)if(w!=null&&w.err)l(w.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(w.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(w.confirmationStatus==="processed"||w.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:ks.PROCESSED,response:{context:b,value:w}})}})()}catch(h){l(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:i}}){let s=!1;const o=new Promise(g=>{const b=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let w=await b();if(!s){for(;w<=n;)if(await ka(1e3),s||(w=await b(),s))return;g({__type:ks.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),l=this.getCancellationPromise(t);let h;try{const g=await Promise.race([l,u,o]);if(g.__type===ks.PROCESSED)h=g.response;else throw new Fm(i)}finally{s=!0,a()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let a=!1;const u=new Promise(w=>{let I=s,S=null;const x=async()=>{try{const{context:C,value:H}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:n});return S=C.slot,H==null?void 0:H.nonce}catch{return I}};(async()=>{if(I=await x(),!a)for(;;){if(s!==I){w({__type:ks.NONCE_INVALID,slotInWhichNonceDidAdvance:S});return}if(await ka(2e3),a||(I=await x(),a))return}})()}),{abortConfirmation:l,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),g=this.getCancellationPromise(t);let b;try{const w=await Promise.race([g,h,u]);if(w.__type===ks.PROCESSED)b=w.response;else{let I;for(;;){const S=await this.getSignatureStatus(o);if(S==null)break;if(S.context.slot<(w.slotInWhichNonceDidAdvance??n)){await ka(400);continue}I=S;break}if(I!=null&&I.value){const S=e||"finalized",{confirmationStatus:x}=I.value;switch(S){case"processed":case"recent":if(x!=="processed"&&x!=="confirmed"&&x!=="finalized")throw new uu(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new uu(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new uu(o);break;default:}b={context:I.context,value:{err:I.value.err}}}else throw new uu(o)}}finally{a=!0,l()}return b}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const i=new Promise(u=>{let l=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{l=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:ks.TIMED_OUT,timeoutMs:l}),l)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const u=await Promise.race([o,i]);if(u.__type===ks.PROCESSED)a=u.response;else throw new Hm(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Ae(e,it(Re(LW)));if("error"in t)throw new $e(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),i=Ae(n,UW);if("error"in i)throw new $e(i.error,"failed to get vote accounts");return i.result}async getSlot(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlot",i),o=Ae(s,it(X()));if("error"in o)throw new $e(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlotLeader",i),o=Ae(s,it(_e()));if("error"in o)throw new $e(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const n=[e,t],i=await this._rpcRequest("getSlotLeaders",n),s=Ae(i,it(Re(nr)));if("error"in s)throw new $e(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){const{context:n,value:i}=await this.getSignatureStatuses([e],t);vt(i.length===1);const s=i[0];return{context:n,value:s}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const i=await this._rpcRequest("getSignatureStatuses",n),s=Ae(i,FW);if("error"in s)throw new $e(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getTransactionCount",i),o=Ae(s,it(X()));if("error"in o)throw new $e(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),i=Ae(n,uW);if("error"in i)throw new $e(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,n){const{commitment:i,config:s}=zt(n),o=this._buildArgs([e.map(l=>l.toBase58())],i,void 0,{...s,epoch:t??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=Ae(a,qK);if("error"in u)throw new $e(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=Ae(e,lW);if("error"in t)throw new $e(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getEpochInfo",i),o=Ae(s,hW);if("error"in o)throw new $e(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=Ae(e,dW);if("error"in t)throw new $e(t.error,"failed to get epoch schedule");const n=t.result;return new Mx(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Ae(e,pW);if("error"in t)throw new $e(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=Ae(i,HW);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,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(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=Ae(t,eq);if("error"in n)throw new $e(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=Ae(i,tq);if("error"in s)throw new $e(s.error,"failed to get fee calculator");const{context:o,value:a}=s.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const n=nt(e.serialize()).toString("base64"),i=this._buildArgs([n],t),s=await this._rpcRequest("getFeeForMessage",i),o=Ae(s,Er(Ie(X())));if("error"in o)throw new $e(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){var o;const t=(o=e==null?void 0:e.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),n=t!=null&&t.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),s=Ae(i,fW);if("error"in s)throw new $e(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getLatestBlockhash",i),o=Ae(s,YW);if("error"in o)throw new $e(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgs([e],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),a=Ae(o,JW);if("error"in a)throw new $e(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=Ae(e,it(rW));if("error"in t)throw new $e(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=Ae(e,it(_e()));if("error"in t)throw new $e(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,KW);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,jW);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,VW);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:l,meta:h,version:g})=>({meta:h,transaction:{...l,message:Ym(g,l.message)},version:g}))}:null}}}catch(a){throw new $e(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,qW);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,ZW);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,WW);if("error"in a)throw a.error;return a.result}}}catch(a){throw new $e(a,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){const{commitment:a,...u}=e;n=a,t=u}const i=this._buildArgs([],n,"base64",t),s=await this._rpcRequest("getBlockProduction",i),o=Ae(s,sW);if("error"in o)throw new $e(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,n1);if("error"in a)throw new $e(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Ym(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:n,config:i}=zt(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,P0);if("error"in a)throw new $e(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:n,config:i}=zt(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,P0);if("error"in l)throw new $e(l.error,"failed to get transactions");return l.result})}async getTransactions(e,t){const{commitment:n,config:i}=zt(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,n1);if("error"in l)throw new $e(l.error,"failed to get transactions");const h=l.result;return h&&{...h,transaction:{...h.transaction,message:Ym(h.version,h.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=Ae(i,QW);if("error"in s)throw new $e(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:l})=>{const h=new Ei(u.message);return{meta:l,transaction:{...u,message:h}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:l})=>({meta:l,transaction:Ot.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){const i=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),s=await this._rpcRequest("getBlocks",i),o=Ae(s,it(Re(X())));if("error"in o)throw new $e(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,Yx);if("error"in s)throw new $e(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,Yx);if("error"in s)throw new $e(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",n),s=Ae(i,n1);if("error"in s)throw new $e(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const a=new Ei(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Ot.populate(a,u)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),s=Ae(i,P0);if("error"in s)throw new $e(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){const n=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const a=Ae(o,P0);if("error"in a)throw new $e(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,n){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(t--,!(t<=0||t<s));)try{const u=await this.getConfirmedBlockSignatures(t,"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)&&(n++,!(n>o));)try{const u=await this.getConfirmedBlockSignatures(n);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(e,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=Ae(s,RW);if("error"in o)throw new $e(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),o=Ae(s,IW);if("error"in o)throw new $e(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=new Zm({key:e,state:Zm.deserialize(i.data)})),{context:n,value:s}}async getNonceAndContext(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=O0.fromAccountData(i.data)),{context:n,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=Ae(n,rq);if("error"in i)throw new $e(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await ka(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Dx;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await ka(Ox/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:n}=zt(e),i=this._buildArgs([],t,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=Ae(s,Er(X()));if("error"in o)throw new $e(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,n){if("message"in e){const S=e.serialize(),x=Ne.from(S).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");const C=t||{};C.encoding="base64","commitment"in C||(C.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(C.innerInstructions=t.innerInstructions);const H=[x,C],D=await this._rpcRequest("simulateTransaction",H),z=Ae(D,Hx);if("error"in z)throw new Error("failed to simulate transaction: "+z.error.message);return z.result}let i;if(e instanceof Ot){let I=e;i=new Ot,i.feePayer=I.feePayer,i.instructions=e.instructions,i.nonceInfo=I.nonceInfo,i.signatures=I.signatures}else i=Ot.populate(e),i._message=i._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(i.nonceInfo&&s)i.sign(...s);else{let I=this._disableBlockhashCaching;for(;;){const S=await this._blockhashWithExpiryBlockHeight(I);if(i.lastValidBlockHeight=S.lastValidBlockHeight,i.recentBlockhash=S.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else I=!0}}const o=i._compile(),a=o.serialize(),l=i._serialize(a).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(n){const I=(Array.isArray(n)?n:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}s&&(h.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(h.innerInstructions=t.innerInstructions);const g=[l,h],b=await this._rpcRequest("simulateTransaction",g),w=Ae(b,Hx);if("error"in w){let I;if("data"in w.error&&(I=w.error.data.logs,I&&Array.isArray(I))){const S=`
|
|
25
|
+
`,x=S+I.join(S);console.error(w.error.message,x)}throw new _o({action:"simulate",signature:"",transactionMessage:w.error.message,logs:I})}return w.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(e.nonceInfo)e.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");const u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=e.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(e,t){const n=nt(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){const n={encoding:"base64"},i=t&&t.skipPreflight,s=i===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),i&&(n.skipPreflight=i),s&&(n.preflightCommitment=s);const o=[e,n],a=await this._rpcRequest("sendTransaction",o),u=Ae(a,nq);if("error"in u){let l;throw"data"in u.error&&(l=u.error.data.logs),new _o({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:l})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){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),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){var i;const n=(i=this._subscriptionsByHash[e])==null?void 0:i.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(o=>{try{o(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var s;const n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[n]||(s[n]=new Set);return i.add(t),()=>{i.delete(t),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}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(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,s);this._setSubscription(n,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:a}),!t())return;this._setSubscription(n,{...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(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(i=>{try{i(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=Ae(e,SW);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,i=Px([e.method,t]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[i];vt(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const{commitment:i,config:s}=zt(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:n}=Ae(e,TW);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,i){const{commitment:s,config:o}=zt(n),a=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:$x(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){const i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=Ae(e,sq);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Ae(e,NW);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:n}=Ae(e,BW);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,i){const s=t||this._commitment;if(s||n||i){let o={};n&&(o.encoding=n),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,i){const s=t||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(e,t,n,i)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=Ae(e,PW);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const i=this._buildArgs([e],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(e,t,n){const{commitment:i,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],i,void 0,s),a=this._makeSubscription({callback:(u,l)=>{t(u,l);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=Ae(e,MW);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Ca{constructor(e){this._keypair=void 0,this._keypair=e??Ex()}static generate(){return new Ca(Ex())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const i=e.slice(0,32),s=R0(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new Ca({publicKey:n,secretKey:e})}static fromSeed(e){const t=R0(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new Ca({publicKey:t,secretKey:n})}get publicKey(){return new me(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Ts=Object.freeze({CreateLookupTable:{index:0,layout:Me([Pe("instruction"),fu("recentSlot"),bt("bumpSeed")])},FreezeLookupTable:{index:1,layout:Me([Pe("instruction")])},ExtendLookupTable:{index:2,layout:Me([Pe("instruction"),fu(),Wr(lt(),mo(Pe(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Me([Pe("instruction")])},CloseLookupTable:{index:4,layout:Me([Pe("instruction")])}});class aq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ts))if(o.index==n){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=kt(Ts.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=kt(Ts.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(n=>new me(n))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(i1.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class i1{constructor(){}static createLookupTable(e){const[t,n]=me.findProgramAddressSync([e.authority.toBuffer(),Y2(BigInt(e.recentSlot),8)],this.programId),i=Ts.CreateLookupTable,s=yt(i,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Br.programId,isSigner:!1,isWritable:!1}];return[new Pt({programId:this.programId,keys:o,data:s}),t]}static freezeLookupTable(e){const t=Ts.FreezeLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:i,data:n})}static extendLookupTable(e){const t=Ts.ExtendLookupTable,n=yt(t,{addresses:e.addresses.map(s=>s.toBytes())}),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&i.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Br.programId,isSigner:!1,isWritable:!1}),new Pt({programId:this.programId,keys:i,data:n})}static deactivateLookupTable(e){const t=Ts.DeactivateLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:i,data:n})}static closeLookupTable(e){const t=Ts.CloseLookupTable,n=yt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Pt({programId:this.programId,keys:i,data:n})}}i1.programId=new me("AddressLookupTab1e1111111111111111111111111");class cq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=bt("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Qi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:n}=kt(Qi.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=kt(Qi.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=kt(Qi.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=kt(Qi.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(s1.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qi=Object.freeze({RequestUnits:{index:0,layout:Me([bt("instruction"),Pe("units"),Pe("additionalFee")])},RequestHeapFrame:{index:1,layout:Me([bt("instruction"),Pe("bytes")])},SetComputeUnitLimit:{index:2,layout:Me([bt("instruction"),Pe("units")])},SetComputeUnitPrice:{index:3,layout:Me([bt("instruction"),fu("microLamports")])}});class s1{constructor(){}static requestUnits(e){const t=Qi.RequestUnits,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=Qi.RequestHeapFrame,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=Qi.SetComputeUnitLimit,n=yt(t,e);return new Pt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=Qi.SetComputeUnitPrice,n=yt(t,{microLamports:BigInt(e.microLamports)});return new Pt({keys:[],programId:this.programId,data:n})}}s1.programId=new me("ComputeBudget111111111111111111111111111111");const Xx=64,eR=32,tR=64,rR=Me([bt("numSignatures"),bt("padding"),ii("signatureOffset"),ii("signatureInstructionIndex"),ii("publicKeyOffset"),ii("publicKeyInstructionIndex"),ii("messageDataOffset"),ii("messageDataSize"),ii("messageInstructionIndex")]);class M0{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;vt(t.length===eR,`Public Key must be ${eR} bytes but received ${t.length} bytes`),vt(i.length===tR,`Signature must be ${tR} bytes but received ${i.length} bytes`);const o=rR.span,a=o+t.length,u=a+i.length,l=1,h=Ne.alloc(u+n.length),g=s??65535;return rR.encode({numSignatures:l,padding:0,signatureOffset:a,signatureInstructionIndex:g,publicKeyOffset:o,publicKeyInstructionIndex:g,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:g},h),h.fill(t,o),h.fill(i,a),h.fill(n,u),new Pt({keys:[],programId:M0.programId,data:h})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;vt(t.length===Xx,`Private key must be ${Xx} bytes but received ${t.length} bytes`);try{const s=Ca.fromSecretKey(t),o=s.publicKey.toBytes(),a=Dm(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}M0.programId=new me("Ed25519SigVerify111111111111111111111111111");const uq=(r,e)=>{const t=x0.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};x0.utils.isValidPrivateKey;const lq=x0.getPublicKey,nR=32,o1=20,iR=64,fq=11,a1=Me([bt("numSignatures"),ii("signatureOffset"),bt("signatureInstructionIndex"),ii("ethAddressOffset"),bt("ethAddressInstructionIndex"),ii("messageDataOffset"),ii("messageDataSize"),bt("messageInstructionIndex"),Wt(20,"ethAddress"),Wt(64,"signature"),bt("recoveryId")]);class du{constructor(){}static publicKeyToEthAddress(e){vt(e.length===iR,`Public key must be ${iR} bytes but received ${e.length} bytes`);try{return Ne.from(gx(nt(e))).slice(-o1)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,recoveryId:s,instructionIndex:o}=e;return du.createInstructionWithEthAddress({ethAddress:du.publicKeyToEthAddress(t),message:n,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=Ne.from(t.substr(2),"hex"):a=Ne.from(t,"hex"):a=t,vt(a.length===o1,`Address must be ${o1} bytes but received ${a.length} bytes`);const u=1+fq,l=u,h=u+a.length,g=h+i.length+1,b=1,w=Ne.alloc(a1.span+n.length);return a1.encode({numSignatures:b,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:l,ethAddressInstructionIndex:o,messageDataOffset:g,messageDataSize:n.length,messageInstructionIndex:o,signature:nt(i),ethAddress:nt(a),recoveryId:s},w),w.fill(nt(n),a1.span),new Pt({keys:[],programId:du.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;vt(t.length===nR,`Private key must be ${nR} bytes but received ${t.length} bytes`);try{const s=nt(t),o=lq(s,!1).slice(1),a=Ne.from(gx(nt(n))),[u,l]=uq(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:l,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}du.programId=new me("KeccakSecp256k11111111111111111111111111111");var sR;const oR=new me("StakeConfig11111111111111111111111111111111");class aR{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class Uf{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}}sR=Uf,Uf.default=new sR(0,0,me.default);class hq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ur))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:n}=kt(Ur.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new aR(new me(t.staker),new me(t.withdrawer)),lockup:new Uf(n.unixTimestamp,n.epoch,new me(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),kt(Ur.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:n}=kt(Ur.Authorize,e.data),i={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:i,authorityOwner:s}=kt(Ur.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:i,authorityOwner:new me(s),newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt(Ur.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ur.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt(Ur.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(Ur.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(L0.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Ur=Object.freeze({Initialize:{index:0,layout:Me([Pe("instruction"),bK(),_K()])},Authorize:{index:1,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("stakeAuthorizationType")])},Delegate:{index:2,layout:Me([Pe("instruction")])},Split:{index:3,layout:Me([Pe("instruction"),Hn("lamports")])},Withdraw:{index:4,layout:Me([Pe("instruction"),Hn("lamports")])},Deactivate:{index:5,layout:Me([Pe("instruction")])},Merge:{index:7,layout:Me([Pe("instruction")])},AuthorizeWithSeed:{index:8,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("stakeAuthorizationType"),Ia("authoritySeed"),lt("authorityOwner")])}}),dq=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class L0{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:i}=e,s=i||Uf.default,o=Ur.Initialize,a=yt(o,{authorized:{staker:nt(n.staker.toBuffer()),withdrawer:nt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:nt(s.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Pt(u)}static createAccountWithSeed(e){const t=new Ot;t.add(Br.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static createAccount(e){const t=new Ot;t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:i}=e,s=Ur.Delegate,o=yt(s);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:oR,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=e,a=Ur.Authorize,u=yt(a,{newAuthorized:nt(i.toBuffer()),stakeAuthorizationType:s.index}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ot().add({keys:l,programId:this.programId,data:u})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:u}=e,l=Ur.AuthorizeWithSeed,h=yt(l,{newAuthorized:nt(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:nt(s.toBuffer())}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1}];return u&&g.push({pubkey:u,isSigner:!0,isWritable:!1}),new Ot().add({keys:g,programId:this.programId,data:h})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:i,lamports:s}=e,o=Ur.Split,a=yt(o,{lamports:s});return new Pt({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const n=new Ot;return n.add(Br.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:a,lamports:u}=e,l=new Ot;return l.add(Br.allocate({accountPubkey:s,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&l.add(Br.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),l.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:i}=e,s=Ur.Merge,o=yt(s);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:i,lamports:s,custodianPubkey:o}=e,a=Ur.Withdraw,u=yt(a,{lamports:s}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:T0,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ot().add({keys:l,programId:this.programId,data:u})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,i=Ur.Deactivate,s=yt(i);return new Ot().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}L0.programId=new me("Stake11111111111111111111111111111111111111"),L0.space=200;class cR{constructor(e,t,n,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=i}}class pq{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Pe("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Yi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=kt(Yi.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new cR(new me(t.nodePubkey),new me(t.authorizedVoter),new me(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:n}=kt(Yi.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:i,voteAuthorizationType:s}}=kt(Yi.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new me(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new me(i),voteAuthorizationType:{index:s},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt(Yi.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(pu.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Yi=Object.freeze({InitializeAccount:{index:0,layout:Me([Pe("instruction"),AK()])},Authorize:{index:1,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("voteAuthorizationType")])},Withdraw:{index:3,layout:Me([Pe("instruction"),Hn("lamports")])},UpdateValidatorIdentity:{index:4,layout:Me([Pe("instruction")])},AuthorizeWithSeed:{index:10,layout:Me([Pe("instruction"),vK()])}}),gq=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class pu{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:i}=e,s=Yi.InitializeAccount,o=yt(s,{voteInit:{nodePubkey:nt(i.nodePubkey.toBuffer()),authorizedVoter:nt(i.authorizedVoter.toBuffer()),authorizedWithdrawer:nt(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pt(a)}static createAccount(e){const t=new Ot;return t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,o=Yi.Authorize,a=yt(o,{newAuthorized:nt(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:a}=e,u=Yi.AuthorizeWithSeed,l=yt(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:nt(n.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:nt(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Ot().add({keys:h,programId:this.programId,data:l})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:i,toPubkey:s}=e,o=Yi.Withdraw,a=yt(o,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return pu.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:i}=e,s=Yi.UpdateValidatorIdentity,o=yt(s),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:a,programId:this.programId,data:o})}}pu.programId=new me("Vote111111111111111111111111111111111111111"),pu.space=3762;const uR=new me("Va1idator1nfo111111111111111111111111111111"),yq=pe({name:_e(),website:He(_e()),details:He(_e()),iconUrl:He(_e()),keybaseUsername:He(_e())});class c1{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(Tn(t)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new me(On(t,0,Wi)),a=qi(t)===1;i.push({publicKey:o,isSigner:a})}if(i[0].publicKey.equals(uR)&&i[1].isSigner){const s=Ia().decode(Ne.from(t)),o=JSON.parse(s);return X2(o,yq),new c1(i[1].publicKey,o)}return null}}const mq=new me("Vote111111111111111111111111111111111111111"),wq=Me([lt("nodePubkey"),lt("authorizedWithdrawer"),bt("commission"),Kr(),Wr(Me([Kr("slot"),Pe("confirmationCount")]),mo(Pe(),-8),"votes"),bt("rootSlotValid"),Kr("rootSlot"),Kr(),Wr(Me([Kr("epoch"),lt("authorizedVoter")]),mo(Pe(),-8),"authorizedVoters"),Me([Wr(Me([lt("authorizedPubkey"),Kr("epochOfLastAuthorizedSwitch"),Kr("targetEpoch")]),32,"buf"),Kr("idx"),bt("isEmpty")],"priorVoters"),Kr(),Wr(Me([Kr("epoch"),Kr("credits"),Kr("prevCredits")]),mo(Pe(),-8),"epochCredits"),Me([Kr("slot"),Kr("timestamp")],"lastTimestamp")]);class u1{constructor(e){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=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const n=wq.decode(nt(e),4);let i=n.rootSlot;return n.rootSlotValid||(i=null),new u1({nodePubkey:new me(n.nodePubkey),authorizedWithdrawer:new me(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:i,authorizedVoters:n.authorizedVoters.map(bq),priorVoters:_q(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function bq({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new me(r)}}function lR({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new me(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function _q({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(lR),...r.slice(0,e).map(lR)]}const fR={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 Aq(r,e){const t=e===!1?"http":"https";if(!r)return fR[t].devnet;const n=fR[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function vq(r,e,t,n){let i,s;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(i=t,s=n):s=t;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},a=await r.sendRawTransaction(e,o),u=s&&s.commitment,h=(await(i?r.confirmTransaction(i,u):r.confirmTransaction(a,u))).value;if(h.err)throw a!=null?new _o({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a}const Eq=Object.freeze(Object.defineProperty({__proto__:null,Account:yK,AddressLookupTableAccount:Zm,AddressLookupTableInstruction:aq,AddressLookupTableProgram:i1,Authorized:aR,BLOCKHASH_CACHE_TIMEOUT_MS:Dx,BPF_LOADER_DEPRECATED_PROGRAM_ID:mK,BPF_LOADER_PROGRAM_ID:BK,BpfLoader:PK,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qi,ComputeBudgetInstruction:cq,ComputeBudgetProgram:s1,Connection:Jx,Ed25519Program:M0,Enum:pK,EpochSchedule:Mx,FeeCalculatorLayout:Nx,Keypair:Ca,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ts,Loader:Ta,Lockup:Uf,MAX_SEED_LENGTH:Ix,Message:Ei,MessageAccountKeys:Pf,MessageV0:Sa,NONCE_ACCOUNT_LENGTH:Km,NonceAccount:O0,PACKET_DATA_SIZE:bo,PUBLIC_KEY_LENGTH:Wi,PublicKey:me,SIGNATURE_LENGTH_IN_BYTES:Bf,SOLANA_SCHEMA:Cf,STAKE_CONFIG_ID:oR,STAKE_INSTRUCTION_LAYOUTS:Ur,SYSTEM_INSTRUCTION_LAYOUTS:Ht,SYSVAR_CLOCK_PUBKEY:Zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:xK,SYSVAR_INSTRUCTIONS_PUBKEY:RK,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:k0,SYSVAR_RENT_PUBKEY:lu,SYSVAR_REWARDS_PUBKEY:IK,SYSVAR_SLOT_HASHES_PUBKEY:SK,SYSVAR_SLOT_HISTORY_PUBKEY:kK,SYSVAR_STAKE_HISTORY_PUBKEY:T0,Secp256k1Program:du,SendTransactionError:_o,SolanaJSONRPCError:$e,SolanaJSONRPCErrorCode:TK,StakeAuthorizationLayout:dq,StakeInstruction:hq,StakeProgram:L0,Struct:$m,SystemInstruction:NK,SystemProgram:Br,Transaction:Ot,TransactionExpiredBlockheightExceededError:Fm,TransactionExpiredNonceInvalidError:uu,TransactionExpiredTimeoutError:Hm,TransactionInstruction:Pt,TransactionMessage:Gm,TransactionStatus:ks,VALIDATOR_INFO_KEY:uR,VERSION_PREFIX_MASK:I0,VOTE_PROGRAM_ID:mq,ValidatorInfo:c1,VersionedMessage:zm,VersionedTransaction:Vm,VoteAccount:u1,VoteAuthorizationLayout:gq,VoteInit:cR,VoteInstruction:pq,VoteProgram:pu,clusterApiUrl:Aq,sendAndConfirmRawTransaction:vq,sendAndConfirmTransaction:jm},Symbol.toStringTag,{value:"Module"}));var l1={exports:{}};const xq=/[\p{Lu}]/u,Rq=/[\p{Ll}]/u,hR=/^[\p{Lu}](?![\p{Lu}])/gu,dR=/([\p{Alpha}\p{N}_]|$)/u,pR=/[_.\- ]+/,Iq=new RegExp("^"+pR.source),gR=new RegExp(pR.source+dR.source,"gu"),yR=new RegExp("\\d+"+dR.source,"gu"),Sq=(r,e,t)=>{let n=!1,i=!1,s=!1;for(let o=0;o<r.length;o++){const a=r[o];n&&xq.test(a)?(r=r.slice(0,o)+"-"+r.slice(o),n=!1,s=i,i=!0,o++):i&&s&&Rq.test(a)?(r=r.slice(0,o-1)+"-"+r.slice(o-1),s=i,i=!1,n=!0):(n=e(a)===a&&t(a)!==a,s=i,i=t(a)===a&&e(a)!==a)}return r},kq=(r,e)=>(hR.lastIndex=0,r.replace(hR,t=>e(t))),Tq=(r,e)=>(gR.lastIndex=0,yR.lastIndex=0,r.replace(gR,(t,n)=>e(n)).replace(yR,t=>e(t))),mR=(r,e)=>{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(s=>s.trim()).filter(s=>s.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),n=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return r.length===1?e.pascalCase?n(r):t(r):(r!==t(r)&&(r=Sq(r,t,n)),r=r.replace(Iq,""),e.preserveConsecutiveUppercase?r=kq(r,t):r=t(r),e.pascalCase&&(r=n(r.charAt(0))+r.slice(1)),Tq(r,n))};l1.exports=mR,l1.exports.default=mR;var Oq=l1.exports;const Nq=xn(Oq);var Xe={},Se={};let Nt=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};Se.Layout=Nt;function f1(r,e){return e.property?r+"["+e.property+"]":r}Se.nameWithProperty=f1;function Cq(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(r.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Nt))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value:function(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value:function(t,n){return e.decode(t,n)},writable:!0})}Se.bindConstructorLayout=Cq;let Nn=class extends Nt{isCount(){throw new Error("ExternalLayout is abstract")}};class wR extends Nn{constructor(e,t){if(e===void 0&&(e=1),!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t){t===void 0&&(t=0);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}let h1=class extends Nn{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof Ji||this.layout instanceof Os}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}},Ji=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}},Os=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}};class Ba extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntLE(e,n,this.span),this.span}}class gu extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntBE(e,n,this.span),this.span}}const d1=Math.pow(2,32);function U0(r){const e=Math.floor(r/d1),t=r-e*d1;return{hi32:e,lo32:t}}function D0(r,e){return r*d1+e}let Bq=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return D0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}};class Pq extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32BE(t),i=e.readUInt32BE(t+4);return D0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}let Mq=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return D0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}};class Lq extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readInt32BE(t),i=e.readUInt32BE(t+4);return D0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=U0(e);return t.writeInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}class bR extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatLE(e,n),4}}class _R extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatBE(e,n),4}}class AR extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleLE(e,n),8}}class vR extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleBE(e,n),8}}class ER extends Nt{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Nn&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof Nn)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0,i=this.count;if(i instanceof Nn&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t){t===void 0&&(t=0);const n=[];let i=0,s=this.count;for(s instanceof Nn&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n){n===void 0&&(n=0);const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof Nn&&this.count.encode(e.length,t,n),s}}let xR=class extends Nt{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Nt,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}},p1=class{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},$0=class extends p1{constructor(e,t){if(!(e instanceof Nn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}},g1=class extends Nt{constructor(e,t,n){const i=e instanceof Ji||e instanceof Os;if(i)e=new $0(new h1(e));else if(e instanceof Nn&&e.isCount())e=new $0(e);else if(!(e instanceof p1))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Nt))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new RR(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Ze.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}},RR=class extends Nt{constructor(e,t,n,i){if(!(e instanceof g1))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Nt))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.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=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};function yu(r){return 0>r&&(r+=4294967296),r}class y1 extends Nt{constructor(e,t,n){if(!(e instanceof Ji||e instanceof Os))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=void 0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=yu(s),this},this._packedGetValue=function(){return i}}decode(e,t){const n=this.makeDestinationObject();t===void 0&&(t=0);const i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(i));return n}encode(e,t,n){n===void 0&&(n=0);const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Df(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new IR(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}class Df{constructor(e,t,n){if(!(e instanceof y1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=yu(this.valueMask<<this.start),this.property=n}decode(){const e=this.container._packedGetValue();return yu(e&this.wordMask)>>>this.start}encode(e){if(!Number.isInteger(e)||e!==yu(e&this.valueMask))throw new TypeError(f1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=yu(e<<this.start);this.container._packedSetValue(yu(t&~this.wordMask)|n)}}let IR=class extends Df{constructor(e,t){super(e,1,t)}decode(e,t){return!!Df.prototype.decode.call(this,e,t)}encode(e){return typeof e=="boolean"&&(e=+e),Df.prototype.encode.call(this,e)}},SR=class extends Nt{constructor(e,t){if(!(e instanceof Nn&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof Nn||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof Nn&&(i=e.length),!(Ze.isBuffer(e)&&i===e.length))throw new TypeError(f1("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof Nn&&this.length.encode(i,t,n),i}};class kR extends Nt{constructor(e){super(-1,e)}getSpan(e,t){if(!Ze.isBuffer(e))throw new TypeError("b must be a Buffer");t===void 0&&(t=0);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);return e.slice(t,t+i-1).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Ze(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),t[n+s]=0,s+1}}class TR extends Nt{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t){if(!Ze.isBuffer(e))throw new TypeError("b must be a Buffer");return t===void 0&&(t=0),e.length-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return e.slice(t,t+i).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Ze(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),s}}class OR extends Nt{constructor(e,t){super(0,t),this.value=e}decode(e,t,n){return this.value}encode(e,t,n){return 0}}Se.ExternalLayout=Nn,Se.GreedyCount=wR,Se.OffsetLayout=h1,Se.UInt=Ji,Se.UIntBE=Os,Se.Int=Ba,Se.IntBE=gu,Se.Float=bR,Se.FloatBE=_R,Se.Double=AR,Se.DoubleBE=vR,Se.Sequence=ER,Se.Structure=xR,Se.UnionDiscriminator=p1,Se.UnionLayoutDiscriminator=$0,Se.Union=g1,Se.VariantLayout=RR,Se.BitStructure=y1,Se.BitField=Df,Se.Boolean=IR,Se.Blob=SR,Se.CString=kR,Se.UTF8=TR,Se.Constant=OR,Se.greedy=(r,e)=>new wR(r,e),Se.offset=(r,e,t)=>new h1(r,e,t),Se.u8=r=>new Ji(1,r),Se.u16=r=>new Ji(2,r),Se.u24=r=>new Ji(3,r),Se.u32=r=>new Ji(4,r),Se.u40=r=>new Ji(5,r),Se.u48=r=>new Ji(6,r),Se.nu64=r=>new Bq(r),Se.u16be=r=>new Os(2,r),Se.u24be=r=>new Os(3,r),Se.u32be=r=>new Os(4,r),Se.u40be=r=>new Os(5,r),Se.u48be=r=>new Os(6,r),Se.nu64be=r=>new Pq(r),Se.s8=r=>new Ba(1,r),Se.s16=r=>new Ba(2,r),Se.s24=r=>new Ba(3,r),Se.s32=r=>new Ba(4,r),Se.s40=r=>new Ba(5,r),Se.s48=r=>new Ba(6,r),Se.ns64=r=>new Mq(r),Se.s16be=r=>new gu(2,r),Se.s24be=r=>new gu(3,r),Se.s32be=r=>new gu(4,r),Se.s40be=r=>new gu(5,r),Se.s48be=r=>new gu(6,r),Se.ns64be=r=>new Lq(r),Se.f32=r=>new bR(r),Se.f32be=r=>new _R(r),Se.f64=r=>new AR(r),Se.f64be=r=>new vR(r),Se.struct=(r,e,t)=>new xR(r,e,t),Se.bits=(r,e,t)=>new y1(r,e,t),Se.seq=(r,e,t)=>new ER(r,e,t),Se.union=(r,e,t)=>new g1(r,e,t),Se.unionLayoutDiscriminator=(r,e)=>new $0(r,e),Se.blob=(r,e)=>new SR(r,e),Se.cstr=r=>new kR(r),Se.utf8=(r,e)=>new TR(r,e),Se.const=(r,e)=>new OR(r,e);const Uq=Mc(Eq);(function(r){var e=ut&&ut.__importDefault||function(ue){return ue&&ue.__esModule?ue:{default:ue}};Object.defineProperty(r,"__esModule",{value:!0}),r.struct=r.f64=r.f32=r.i32=r.u32=r.i16=r.u16=r.i8=r.u8=void 0,r.u64=a,r.i64=u,r.u128=l,r.i128=h,r.u256=g,r.i256=b,r.publicKey=I,r.option=x,r.bool=C,r.vec=z,r.tagged=W,r.vecU8=Z,r.str=V,r.rustEnum=K,r.array=oe,r.map=ie;const t=Se,n=Uq,i=e(Yy);var s=Se;Object.defineProperty(r,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(r,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(r,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(r,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(r,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(r,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(r,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(r,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(r,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends t.Layout{constructor(B,p,m){super(B,m),this.blob=(0,t.blob)(B),this.signed=p}decode(B,p=0){const m=new i.default(this.blob.decode(B,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(B,p,m=0){return this.signed&&(B=B.toTwos(this.span*8)),this.blob.encode(B.toArrayLike(Ze,"le",this.span),p,m)}}function a(ue){return new o(8,!1,ue)}function u(ue){return new o(8,!0,ue)}function l(ue){return new o(16,!1,ue)}function h(ue){return new o(16,!0,ue)}function g(ue){return new o(32,!1,ue)}function b(ue){return new o(32,!0,ue)}class w extends t.Layout{constructor(B,p,m,E){super(B.span,E),this.layout=B,this.decoder=p,this.encoder=m}decode(B,p){return this.decoder(this.layout.decode(B,p))}encode(B,p,m){return this.layout.encode(this.encoder(B),p,m)}getSpan(B,p){return this.layout.getSpan(B,p)}}function I(ue){return new w((0,t.blob)(32),B=>new n.PublicKey(B),B=>B.toBuffer(),ue)}class S extends t.Layout{constructor(B,p){super(-1,p),this.layout=B,this.discriminator=(0,t.u8)()}encode(B,p,m=0){return B==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(B,p,m+1)+1)}decode(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return null;if(m===1)return this.layout.decode(B,p+1);throw new Error("Invalid option "+this.property)}getSpan(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(B,p+1)+1;throw new Error("Invalid option "+this.property)}}function x(ue,B){return new S(ue,B)}function C(ue){return new w((0,t.u8)(),H,D,ue)}function H(ue){if(ue===0)return!1;if(ue===1)return!0;throw new Error("Invalid bool: "+ue)}function D(ue){return ue?1:0}function z(ue,B){const p=(0,t.u32)("length"),m=(0,t.struct)([p,(0,t.seq)(ue,(0,t.offset)(p,-p.span),"values")]);return new w(m,({values:E})=>E,E=>({values:E}),B)}function W(ue,B,p){const m=(0,t.struct)([a("tag"),B.replicate("data")]);function E({tag:k,data:O}){if(!k.eq(ue))throw new Error("Invalid tag, expected: "+ue.toString("hex")+", got: "+k.toString("hex"));return O}return new w(m,E,k=>({tag:ue,data:k}),p)}function Z(ue){const B=(0,t.u32)("length"),p=(0,t.struct)([B,(0,t.blob)((0,t.offset)(B,-B.span),"data")]);return new w(p,({data:m})=>m,m=>({data:m}),ue)}function V(ue){return new w(Z(),B=>B.toString("utf-8"),B=>Ze.from(B,"utf-8"),ue)}function K(ue,B,p){const m=(0,t.union)(p??(0,t.u8)(),B);return ue.forEach((E,k)=>m.addVariant(k,E,E.property)),m}function oe(ue,B,p){const m=(0,t.struct)([(0,t.seq)(ue,B,"values")]);return new w(m,({values:E})=>E,E=>({values:E}),p)}class ce extends t.Layout{constructor(B,p,m){super(B.span+p.span,m),this.keyLayout=B,this.valueLayout=p}decode(B,p){p=p||0;const m=this.keyLayout.decode(B,p),E=this.valueLayout.decode(B,p+this.keyLayout.getSpan(B,p));return[m,E]}encode(B,p,m){m=m||0;const E=this.keyLayout.encode(B[0],p,m),k=this.valueLayout.encode(B[1],p,m+E);return E+k}getSpan(B,p){return this.keyLayout.getSpan(B,p)+this.valueLayout.getSpan(B,p)}}function ie(ue,B,p){const m=(0,t.u32)("length"),E=(0,t.struct)([m,(0,t.seq)(new ce(ue,B),(0,t.offset)(m,-m.span),"values")]);return new w(E,({values:k})=>new Map(k),k=>({values:Array.from(k.entries())}),p)}})(Xe);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const Dq=4,NR=0,CR=1,$q=2;function mu(r){let e=r.length;for(;--e>=0;)r[e]=0}const Fq=0,BR=1,Hq=2,zq=3,Gq=258,m1=29,$f=256,Ff=$f+1+m1,wu=30,w1=19,PR=2*Ff+1,Pa=15,b1=16,Vq=7,_1=256,MR=16,LR=17,UR=18,A1=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]),F0=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]),jq=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),DR=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kq=512,Ns=new Array((Ff+2)*2);mu(Ns);const Hf=new Array(wu*2);mu(Hf);const zf=new Array(Kq);mu(zf);const Gf=new Array(Gq-zq+1);mu(Gf);const v1=new Array(m1);mu(v1);const H0=new Array(wu);mu(H0);function E1(r,e,t,n,i){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=n,this.max_length=i,this.has_stree=r&&r.length}let $R,FR,HR;function x1(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}const zR=r=>r<256?zf[r]:zf[256+(r>>>7)],Vf=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Cn=(r,e,t)=>{r.bi_valid>b1-t?(r.bi_buf|=e<<r.bi_valid&65535,Vf(r,r.bi_buf),r.bi_buf=e>>b1-r.bi_valid,r.bi_valid+=t-b1):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},Xi=(r,e,t)=>{Cn(r,t[e*2],t[e*2+1])},GR=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},Wq=r=>{r.bi_valid===16?(Vf(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},qq=(r,e)=>{const t=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,u=e.stat_desc.max_length;let l,h,g,b,w,I,S=0;for(b=0;b<=Pa;b++)r.bl_count[b]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<PR;l++)h=r.heap[l],b=t[t[h*2+1]*2+1]+1,b>u&&(b=u,S++),t[h*2+1]=b,!(h>n)&&(r.bl_count[b]++,w=0,h>=a&&(w=o[h-a]),I=t[h*2],r.opt_len+=I*(b+w),s&&(r.static_len+=I*(i[h*2+1]+w)));if(S!==0){do{for(b=u-1;r.bl_count[b]===0;)b--;r.bl_count[b]--,r.bl_count[b+1]+=2,r.bl_count[u]--,S-=2}while(S>0);for(b=u;b!==0;b--)for(h=r.bl_count[b];h!==0;)g=r.heap[--l],!(g>n)&&(t[g*2+1]!==b&&(r.opt_len+=(b-t[g*2+1])*t[g*2],t[g*2+1]=b),h--)}},VR=(r,e,t)=>{const n=new Array(Pa+1);let i=0,s,o;for(s=1;s<=Pa;s++)i=i+t[s-1]<<1,n[s]=i;for(o=0;o<=e;o++){let a=r[o*2+1];a!==0&&(r[o*2]=GR(n[a]++,a))}},Zq=()=>{let r,e,t,n,i;const s=new Array(Pa+1);for(t=0,n=0;n<m1-1;n++)for(v1[n]=t,r=0;r<1<<A1[n];r++)Gf[t++]=n;for(Gf[t-1]=n,i=0,n=0;n<16;n++)for(H0[n]=i,r=0;r<1<<F0[n];r++)zf[i++]=n;for(i>>=7;n<wu;n++)for(H0[n]=i<<7,r=0;r<1<<F0[n]-7;r++)zf[256+i++]=n;for(e=0;e<=Pa;e++)s[e]=0;for(r=0;r<=143;)Ns[r*2+1]=8,r++,s[8]++;for(;r<=255;)Ns[r*2+1]=9,r++,s[9]++;for(;r<=279;)Ns[r*2+1]=7,r++,s[7]++;for(;r<=287;)Ns[r*2+1]=8,r++,s[8]++;for(VR(Ns,Ff+1,s),r=0;r<wu;r++)Hf[r*2+1]=5,Hf[r*2]=GR(r,5);$R=new E1(Ns,A1,$f+1,Ff,Pa),FR=new E1(Hf,F0,0,wu,Pa),HR=new E1(new Array(0),jq,0,w1,Vq)},jR=r=>{let e;for(e=0;e<Ff;e++)r.dyn_ltree[e*2]=0;for(e=0;e<wu;e++)r.dyn_dtree[e*2]=0;for(e=0;e<w1;e++)r.bl_tree[e*2]=0;r.dyn_ltree[_1*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},KR=r=>{r.bi_valid>8?Vf(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},WR=(r,e,t,n)=>{const i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},R1=(r,e,t)=>{const n=r.heap[t];let i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&WR(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!WR(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},qR=(r,e,t)=>{let n,i,s=0,o,a;if(r.sym_next!==0)do n=r.pending_buf[r.sym_buf+s++]&255,n+=(r.pending_buf[r.sym_buf+s++]&255)<<8,i=r.pending_buf[r.sym_buf+s++],n===0?Xi(r,i,e):(o=Gf[i],Xi(r,o+$f+1,e),a=A1[o],a!==0&&(i-=v1[o],Cn(r,i,a)),n--,o=zR(n),Xi(r,o,t),a=F0[o],a!==0&&(n-=H0[o],Cn(r,n,a)));while(s<r.sym_next);Xi(r,_1,e)},I1=(r,e)=>{const t=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,u=-1,l;for(r.heap_len=0,r.heap_max=PR,o=0;o<s;o++)t[o*2]!==0?(r.heap[++r.heap_len]=u=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)l=r.heap[++r.heap_len]=u<2?++u:0,t[l*2]=1,r.depth[l]=0,r.opt_len--,i&&(r.static_len-=n[l*2+1]);for(e.max_code=u,o=r.heap_len>>1;o>=1;o--)R1(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],R1(r,t,1),a=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=a,t[l*2]=t[o*2]+t[a*2],r.depth[l]=(r.depth[o]>=r.depth[a]?r.depth[o]:r.depth[a])+1,t[o*2+1]=t[a*2+1]=l,r.heap[1]=l++,R1(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],qq(r,e),VR(t,u,r.bl_count)},ZR=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),e[(t+1)*2+1]=65535,n=0;n<=t;n++)s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)&&(a<l?r.bl_tree[s*2]+=a:s!==0?(s!==i&&r.bl_tree[s*2]++,r.bl_tree[MR*2]++):a<=10?r.bl_tree[LR*2]++:r.bl_tree[UR*2]++,a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4))},QR=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),n=0;n<=t;n++)if(s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)){if(a<l)do Xi(r,s,r.bl_tree);while(--a!==0);else s!==0?(s!==i&&(Xi(r,s,r.bl_tree),a--),Xi(r,MR,r.bl_tree),Cn(r,a-3,2)):a<=10?(Xi(r,LR,r.bl_tree),Cn(r,a-3,3)):(Xi(r,UR,r.bl_tree),Cn(r,a-11,7));a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4)}},Qq=r=>{let e;for(ZR(r,r.dyn_ltree,r.l_desc.max_code),ZR(r,r.dyn_dtree,r.d_desc.max_code),I1(r,r.bl_desc),e=w1-1;e>=3&&r.bl_tree[DR[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},Yq=(r,e,t,n)=>{let i;for(Cn(r,e-257,5),Cn(r,t-1,5),Cn(r,n-4,4),i=0;i<n;i++)Cn(r,r.bl_tree[DR[i]*2+1],3);QR(r,r.dyn_ltree,e-1),QR(r,r.dyn_dtree,t-1)},Jq=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return NR;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return CR;for(t=32;t<$f;t++)if(r.dyn_ltree[t*2]!==0)return CR;return NR};let YR=!1;const Xq=r=>{YR||(Zq(),YR=!0),r.l_desc=new x1(r.dyn_ltree,$R),r.d_desc=new x1(r.dyn_dtree,FR),r.bl_desc=new x1(r.bl_tree,HR),r.bi_buf=0,r.bi_valid=0,jR(r)},JR=(r,e,t,n)=>{Cn(r,(Fq<<1)+(n?1:0),3),KR(r),Vf(r,t),Vf(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},eZ=r=>{Cn(r,BR<<1,3),Xi(r,_1,Ns),Wq(r)},tZ=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===$q&&(r.strm.data_type=Jq(r)),I1(r,r.l_desc),I1(r,r.d_desc),o=Qq(r),i=r.opt_len+3+7>>>3,s=r.static_len+3+7>>>3,s<=i&&(i=s)):i=s=t+5,t+4<=i&&e!==-1?JR(r,e,t,n):r.strategy===Dq||s===i?(Cn(r,(BR<<1)+(n?1:0),3),qR(r,Ns,Hf)):(Cn(r,(Hq<<1)+(n?1:0),3),Yq(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),qR(r,r.dyn_ltree,r.dyn_dtree)),jR(r),n&&KR(r)},rZ=(r,e,t)=>(r.pending_buf[r.sym_buf+r.sym_next++]=e,r.pending_buf[r.sym_buf+r.sym_next++]=e>>8,r.pending_buf[r.sym_buf+r.sym_next++]=t,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(Gf[t]+$f+1)*2]++,r.dyn_dtree[zR(e)*2]++),r.sym_next===r.sym_end);var nZ=Xq,iZ=JR,sZ=tZ,oZ=rZ,aZ=eZ,cZ={_tr_init:nZ,_tr_stored_block:iZ,_tr_flush_block:sZ,_tr_tally:oZ,_tr_align:aZ},jf=(r,e,t,n)=>{let i=r&65535|0,s=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do i=i+e[n++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};const uZ=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},lZ=new Uint32Array(uZ());var Dr=(r,e,t,n)=>{const i=lZ,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},bu={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"},Kf={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:fZ,_tr_stored_block:S1,_tr_flush_block:hZ,_tr_tally:Ao,_tr_align:dZ}=cZ,{Z_NO_FLUSH:vo,Z_PARTIAL_FLUSH:pZ,Z_FULL_FLUSH:gZ,Z_FINISH:si,Z_BLOCK:XR,Z_OK:Zr,Z_STREAM_END:eI,Z_STREAM_ERROR:es,Z_DATA_ERROR:yZ,Z_BUF_ERROR:k1,Z_DEFAULT_COMPRESSION:mZ,Z_FILTERED:wZ,Z_HUFFMAN_ONLY:z0,Z_RLE:bZ,Z_FIXED:_Z,Z_DEFAULT_STRATEGY:AZ,Z_UNKNOWN:vZ,Z_DEFLATED:G0}=Kf,EZ=9,xZ=15,RZ=8,T1=256+1+29,IZ=30,SZ=19,kZ=2*T1+1,TZ=15,ht=3,Eo=258,ts=Eo+ht+1,OZ=32,_u=42,O1=57,N1=69,C1=73,B1=91,P1=103,Ma=113,Wf=666,yn=1,Au=2,La=3,vu=4,NZ=3,Ua=(r,e)=>(r.msg=bu[e],e),tI=r=>r*2-(r>4?9:0),xo=r=>{let e=r.length;for(;--e>=0;)r[e]=0},CZ=r=>{let e,t,n,i=r.w_size;e=r.hash_size,n=e;do t=r.head[--n],r.head[n]=t>=i?t-i:0;while(--e);e=i,n=e;do t=r.prev[--n],r.prev[n]=t>=i?t-i:0;while(--e)};let Ro=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask;const Gn=r=>{const e=r.state;let t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},Vn=(r,e)=>{hZ(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,Gn(r.strm)},Rt=(r,e)=>{r.pending_buf[r.pending++]=e},qf=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},M1=(r,e,t,n)=>{let i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.input.subarray(r.next_in,r.next_in+i),t),r.state.wrap===1?r.adler=jf(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Dr(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},rI=(r,e)=>{let t=r.max_chain_length,n=r.strstart,i,s,o=r.prev_length,a=r.nice_match;const u=r.strstart>r.w_size-ts?r.strstart-(r.w_size-ts):0,l=r.window,h=r.w_mask,g=r.prev,b=r.strstart+Eo;let w=l[n+o-1],I=l[n+o];r.prev_length>=r.good_match&&(t>>=2),a>r.lookahead&&(a=r.lookahead);do if(i=e,!(l[i+o]!==I||l[i+o-1]!==w||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<b);if(s=Eo-(b-n),n=b-Eo,s>o){if(r.match_start=e,o=s,s>=a)break;w=l[n+o-1],I=l[n+o]}}while((e=g[e&h])>u&&--t!==0);return o<=r.lookahead?o:r.lookahead},Eu=r=>{const e=r.w_size;let t,n,i;do{if(n=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-ts)&&(r.window.set(r.window.subarray(e,e+e-n),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,r.insert>r.strstart&&(r.insert=r.strstart),CZ(r),n+=e),r.strm.avail_in===0)break;if(t=M1(r.strm,r.window,r.strstart+r.lookahead,n),r.lookahead+=t,r.lookahead+r.insert>=ht)for(i=r.strstart-r.insert,r.ins_h=r.window[i],r.ins_h=Ro(r,r.ins_h,r.window[i+1]);r.insert&&(r.ins_h=Ro(r,r.ins_h,r.window[i+ht-1]),r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,r.insert--,!(r.lookahead+r.insert<ht)););}while(r.lookahead<ts&&r.strm.avail_in!==0)},nI=(r,e)=>{let t=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,n,i,s,o=0,a=r.strm.avail_in;do{if(n=65535,s=r.bi_valid+42>>3,r.strm.avail_out<s||(s=r.strm.avail_out-s,i=r.strstart-r.block_start,n>i+r.strm.avail_in&&(n=i+r.strm.avail_in),n>s&&(n=s),n<t&&(n===0&&e!==si||e===vo||n!==i+r.strm.avail_in)))break;o=e===si&&n===i+r.strm.avail_in?1:0,S1(r,0,0,o),r.pending_buf[r.pending-4]=n,r.pending_buf[r.pending-3]=n>>8,r.pending_buf[r.pending-2]=~n,r.pending_buf[r.pending-1]=~n>>8,Gn(r.strm),i&&(i>n&&(i=n),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+i),r.strm.next_out),r.strm.next_out+=i,r.strm.avail_out-=i,r.strm.total_out+=i,r.block_start+=i,n-=i),n&&(M1(r.strm,r.strm.output,r.strm.next_out,n),r.strm.next_out+=n,r.strm.avail_out-=n,r.strm.total_out+=n)}while(o===0);return a-=r.strm.avail_in,a&&(a>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=a&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-a,r.strm.next_in),r.strstart),r.strstart+=a,r.insert+=a>r.w_size-r.insert?r.w_size-r.insert:a),r.block_start=r.strstart),r.high_water<r.strstart&&(r.high_water=r.strstart),o?vu:e!==vo&&e!==si&&r.strm.avail_in===0&&r.strstart===r.block_start?Au:(s=r.window_size-r.strstart,r.strm.avail_in>s&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,s+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),s>r.strm.avail_in&&(s=r.strm.avail_in),s&&(M1(r.strm,r.window,r.strstart,s),r.strstart+=s,r.insert+=s>r.w_size-r.insert?r.w_size-r.insert:s),r.high_water<r.strstart&&(r.high_water=r.strstart),s=r.bi_valid+42>>3,s=r.pending_buf_size-s>65535?65535:r.pending_buf_size-s,t=s>r.w_size?r.w_size:s,i=r.strstart-r.block_start,(i>=t||(i||e===si)&&e!==vo&&r.strm.avail_in===0&&i<=s)&&(n=i>s?s:i,o=e===si&&r.strm.avail_in===0&&n===i?1:0,S1(r,r.block_start,n,o),r.block_start+=n,Gn(r.strm)),o?La:yn)},L1=(r,e)=>{let t,n;for(;;){if(r.lookahead<ts){if(Eu(r),r.lookahead<ts&&e===vo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-ts&&(r.match_length=rI(r,t)),r.match_length>=ht)if(n=Ao(r,r.strstart-r.match_start,r.match_length-ht),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=ht){r.match_length--;do r.strstart++,r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+1]);else n=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=r.strstart<ht-1?r.strstart:ht-1,e===si?(Vn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Au},xu=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<ts){if(Eu(r),r.lookahead<ts&&e===vo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=ht-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-ts&&(r.match_length=rI(r,t),r.match_length<=5&&(r.strategy===wZ||r.match_length===ht&&r.strstart-r.match_start>4096)&&(r.match_length=ht-1)),r.prev_length>=ht&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-ht,n=Ao(r,r.strstart-1-r.prev_match,r.prev_length-ht),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=Ro(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=ht-1,r.strstart++,n&&(Vn(r,!1),r.strm.avail_out===0))return yn}else if(r.match_available){if(n=Ao(r,0,r.window[r.strstart-1]),n&&Vn(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return yn}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=Ao(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<ht-1?r.strstart:ht-1,e===si?(Vn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Au},BZ=(r,e)=>{let t,n,i,s;const o=r.window;for(;;){if(r.lookahead<=Eo){if(Eu(r),r.lookahead<=Eo&&e===vo)return yn;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=ht&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=r.strstart+Eo;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);r.match_length=Eo-(s-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=ht?(t=Ao(r,1,r.match_length-ht),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(Vn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Au},PZ=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(Eu(r),r.lookahead===0)){if(e===vo)return yn;break}if(r.match_length=0,t=Ao(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(Vn(r,!0),r.strm.avail_out===0?La:vu):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Au};function rs(r,e,t,n,i){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=n,this.func=i}const Zf=[new rs(0,0,0,0,nI),new rs(4,4,8,4,L1),new rs(4,5,16,8,L1),new rs(4,6,32,32,L1),new rs(4,4,16,16,xu),new rs(8,16,32,32,xu),new rs(8,16,128,128,xu),new rs(8,32,128,256,xu),new rs(32,128,258,1024,xu),new rs(32,258,258,4096,xu)],MZ=r=>{r.window_size=2*r.w_size,xo(r.head),r.max_lazy_match=Zf[r.level].max_lazy,r.good_match=Zf[r.level].good_length,r.nice_match=Zf[r.level].nice_length,r.max_chain_length=Zf[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=ht-1,r.match_available=0,r.ins_h=0};function LZ(){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(kZ*2),this.dyn_dtree=new Uint16Array((2*IZ+1)*2),this.bl_tree=new Uint16Array((2*SZ+1)*2),xo(this.dyn_ltree),xo(this.dyn_dtree),xo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(TZ+1),this.heap=new Uint16Array(2*T1+1),xo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*T1+1),xo(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 Qf=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.status!==_u&&e.status!==O1&&e.status!==N1&&e.status!==C1&&e.status!==B1&&e.status!==P1&&e.status!==Ma&&e.status!==Wf?1:0},iI=r=>{if(Qf(r))return Ua(r,es);r.total_in=r.total_out=0,r.data_type=vZ;const e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?O1:e.wrap?_u:Ma,r.adler=e.wrap===2?0:1,e.last_flush=-2,fZ(e),Zr},sI=r=>{const e=iI(r);return e===Zr&&MZ(r.state),e},UZ=(r,e)=>Qf(r)||r.state.wrap!==2?es:(r.state.gzhead=e,Zr),oI=(r,e,t,n,i,s)=>{if(!r)return es;let o=1;if(e===mZ&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>EZ||t!==G0||n<8||n>15||e<0||e>9||s<0||s>_Z||n===8&&o!==1)return Ua(r,es);n===8&&(n=9);const a=new LZ;return r.state=a,a.strm=r,a.status=_u,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+ht-1)/ht),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=e,a.strategy=s,a.method=t,sI(r)},DZ=(r,e)=>oI(r,e,G0,xZ,RZ,AZ),$Z=(r,e)=>{if(Qf(r)||e>XR||e<0)return r?Ua(r,es):es;const t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===Wf&&e!==si)return Ua(r,r.avail_out===0?k1:es);const n=t.last_flush;if(t.last_flush=e,t.pending!==0){if(Gn(r),r.avail_out===0)return t.last_flush=-1,Zr}else if(r.avail_in===0&&tI(e)<=tI(n)&&e!==si)return Ua(r,k1);if(t.status===Wf&&r.avail_in!==0)return Ua(r,k1);if(t.status===_u&&t.wrap===0&&(t.status=Ma),t.status===_u){let i=G0+(t.w_bits-8<<4)<<8,s=-1;if(t.strategy>=z0||t.level<2?s=0:t.level<6?s=1:t.level===6?s=2:s=3,i|=s<<6,t.strstart!==0&&(i|=OZ),i+=31-i%31,qf(t,i),t.strstart!==0&&(qf(t,r.adler>>>16),qf(t,r.adler&65535)),r.adler=1,t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===O1){if(r.adler=0,Rt(t,31),Rt(t,139),Rt(t,8),t.gzhead)Rt(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),Rt(t,t.gzhead.time&255),Rt(t,t.gzhead.time>>8&255),Rt(t,t.gzhead.time>>16&255),Rt(t,t.gzhead.time>>24&255),Rt(t,t.level===9?2:t.strategy>=z0||t.level<2?4:0),Rt(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(Rt(t,t.gzhead.extra.length&255),Rt(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(r.adler=Dr(r.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=N1;else if(Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,t.level===9?2:t.strategy>=z0||t.level<2?4:0),Rt(t,NZ),t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===N1){if(t.gzhead.extra){let i=t.pending,s=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+s>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex+=a,Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0,s-=a}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending+=s,t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=C1}if(t.status===C1){if(t.gzhead.name){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0}t.gzindex<t.gzhead.name.length?s=t.gzhead.name.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=B1}if(t.status===B1){if(t.gzhead.comment){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i)),Gn(r),t.pending!==0)return t.last_flush=-1,Zr;i=0}t.gzindex<t.gzhead.comment.length?s=t.gzhead.comment.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Dr(r.adler,t.pending_buf,t.pending-i,i))}t.status=P1}if(t.status===P1){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Gn(r),t.pending!==0))return t.last_flush=-1,Zr;Rt(t,r.adler&255),Rt(t,r.adler>>8&255),r.adler=0}if(t.status=Ma,Gn(r),t.pending!==0)return t.last_flush=-1,Zr}if(r.avail_in!==0||t.lookahead!==0||e!==vo&&t.status!==Wf){let i=t.level===0?nI(t,e):t.strategy===z0?PZ(t,e):t.strategy===bZ?BZ(t,e):Zf[t.level].func(t,e);if((i===La||i===vu)&&(t.status=Wf),i===yn||i===La)return r.avail_out===0&&(t.last_flush=-1),Zr;if(i===Au&&(e===pZ?dZ(t):e!==XR&&(S1(t,0,0,!1),e===gZ&&(xo(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Gn(r),r.avail_out===0))return t.last_flush=-1,Zr}return e!==si?Zr:t.wrap<=0?eI:(t.wrap===2?(Rt(t,r.adler&255),Rt(t,r.adler>>8&255),Rt(t,r.adler>>16&255),Rt(t,r.adler>>24&255),Rt(t,r.total_in&255),Rt(t,r.total_in>>8&255),Rt(t,r.total_in>>16&255),Rt(t,r.total_in>>24&255)):(qf(t,r.adler>>>16),qf(t,r.adler&65535)),Gn(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Zr:eI)},FZ=r=>{if(Qf(r))return es;const e=r.state.status;return r.state=null,e===Ma?Ua(r,yZ):Zr},HZ=(r,e)=>{let t=e.length;if(Qf(r))return es;const n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==_u||n.lookahead)return es;if(i===1&&(r.adler=jf(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(xo(n.head),n.strstart=0,n.block_start=0,n.insert=0);let u=new Uint8Array(n.w_size);u.set(e.subarray(t-n.w_size,t),0),e=u,t=n.w_size}const s=r.avail_in,o=r.next_in,a=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,Eu(n);n.lookahead>=ht;){let u=n.strstart,l=n.lookahead-(ht-1);do n.ins_h=Ro(n,n.ins_h,n.window[u+ht-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++;while(--l);n.strstart=u,n.lookahead=ht-1,Eu(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=ht-1,n.match_available=0,r.next_in=o,r.input=a,r.avail_in=s,n.wrap=i,Zr};var zZ=DZ,GZ=oI,VZ=sI,jZ=iI,KZ=UZ,WZ=$Z,qZ=FZ,ZZ=HZ,QZ="pako deflate (from Nodeca project)",Yf={deflateInit:zZ,deflateInit2:GZ,deflateReset:VZ,deflateResetKeep:jZ,deflateSetHeader:KZ,deflate:WZ,deflateEnd:qZ,deflateSetDictionary:ZZ,deflateInfo:QZ};const YZ=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);var JZ=function(r){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)YZ(t,n)&&(r[n]=t[n])}}return r},XZ=r=>{let e=0;for(let n=0,i=r.length;n<i;n++)e+=r[n].length;const t=new Uint8Array(e);for(let n=0,i=0,s=r.length;n<s;n++){let o=r[n];t.set(o,i),i+=o.length}return t},V0={assign:JZ,flattenChunks:XZ};let aI=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{aI=!1}const Jf=new Uint8Array(256);for(let r=0;r<256;r++)Jf[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Jf[254]=Jf[254]=1;var eQ=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,n,i,s,o=r.length,a=0;for(i=0;i<o;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const tQ=(r,e)=>{if(e<65534&&r.subarray&&aI)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(r[n]);return t};var rQ=(r,e)=>{const t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let n,i;const s=new Array(t*2);for(i=0,n=0;n<t;){let o=r[n++];if(o<128){s[i++]=o;continue}let a=Jf[o];if(a>4){s[i++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n<t;)o=o<<6|r[n++]&63,a--;if(a>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return tQ(s,i)},nQ=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+Jf[r[t]]>e?t:e},Xf={string2buf:eQ,buf2string:rQ,utf8border:nQ};function iQ(){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 cI=iQ;const uI=Object.prototype.toString,{Z_NO_FLUSH:sQ,Z_SYNC_FLUSH:oQ,Z_FULL_FLUSH:aQ,Z_FINISH:cQ,Z_OK:j0,Z_STREAM_END:uQ,Z_DEFAULT_COMPRESSION:lQ,Z_DEFAULT_STRATEGY:fQ,Z_DEFLATED:hQ}=Kf;function U1(r){this.options=V0.assign({level:lQ,method:hQ,chunkSize:16384,windowBits:15,memLevel:8,strategy:fQ},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cI,this.strm.avail_out=0;let t=Yf.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==j0)throw new Error(bu[t]);if(e.header&&Yf.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=Xf.string2buf(e.dictionary):uI.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=Yf.deflateSetDictionary(this.strm,n),t!==j0)throw new Error(bu[t]);this._dict_set=!0}}U1.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?cQ:sQ,typeof r=="string"?t.input=Xf.string2buf(r):uI.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(s===oQ||s===aQ)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=Yf.deflate(t,s),i===uQ)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=Yf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===j0;if(t.avail_out===0){this.onData(t.output);continue}if(s>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0},U1.prototype.onData=function(r){this.chunks.push(r)},U1.prototype.onEnd=function(r){r===j0&&(this.result=V0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};const K0=16209,dQ=16191;var pQ=function(e,t){let n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H,D,z,W,Z,V,K,oe,ce;const ie=e.state;n=e.next_in,oe=e.input,i=n+(e.avail_in-5),s=e.next_out,ce=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),u=ie.dmax,l=ie.wsize,h=ie.whave,g=ie.wnext,b=ie.window,w=ie.hold,I=ie.bits,S=ie.lencode,x=ie.distcode,C=(1<<ie.lenbits)-1,H=(1<<ie.distbits)-1;e:do{I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=S[w&C];t:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z===0)ce[s++]=D&65535;else if(z&16){W=D&65535,z&=15,z&&(I<z&&(w+=oe[n++]<<I,I+=8),W+=w&(1<<z)-1,w>>>=z,I-=z),I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=x[w&H];r:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z&16){if(Z=D&65535,z&=15,I<z&&(w+=oe[n++]<<I,I+=8,I<z&&(w+=oe[n++]<<I,I+=8)),Z+=w&(1<<z)-1,Z>u){e.msg="invalid distance too far back",ie.mode=K0;break e}if(w>>>=z,I-=z,z=s-o,Z>z){if(z=Z-z,z>h&&ie.sane){e.msg="invalid distance too far back",ie.mode=K0;break e}if(V=0,K=b,g===0){if(V+=l-z,z<W){W-=z;do ce[s++]=b[V++];while(--z);V=s-Z,K=ce}}else if(g<z){if(V+=l+g-z,z-=g,z<W){W-=z;do ce[s++]=b[V++];while(--z);if(V=0,g<W){z=g,W-=z;do ce[s++]=b[V++];while(--z);V=s-Z,K=ce}}}else if(V+=g-z,z<W){W-=z;do ce[s++]=b[V++];while(--z);V=s-Z,K=ce}for(;W>2;)ce[s++]=K[V++],ce[s++]=K[V++],ce[s++]=K[V++],W-=3;W&&(ce[s++]=K[V++],W>1&&(ce[s++]=K[V++]))}else{V=s-Z;do ce[s++]=ce[V++],ce[s++]=ce[V++],ce[s++]=ce[V++],W-=3;while(W>2);W&&(ce[s++]=ce[V++],W>1&&(ce[s++]=ce[V++]))}}else if(z&64){e.msg="invalid distance code",ie.mode=K0;break e}else{D=x[(D&65535)+(w&(1<<z)-1)];continue r}break}}else if(z&64)if(z&32){ie.mode=dQ;break e}else{e.msg="invalid literal/length code",ie.mode=K0;break e}else{D=S[(D&65535)+(w&(1<<z)-1)];continue t}break}}while(n<i&&s<a);W=I>>3,n-=W,I-=W<<3,w&=(1<<I)-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=s<a?257+(a-s):257-(s-a),ie.hold=w,ie.bits=I};const Ru=15,lI=852,fI=592,hI=0,D1=1,dI=2,gQ=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]),yQ=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]),mQ=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]),wQ=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 eh=(r,e,t,n,i,s,o,a)=>{const u=a.bits;let l=0,h=0,g=0,b=0,w=0,I=0,S=0,x=0,C=0,H=0,D,z,W,Z,V,K=null,oe;const ce=new Uint16Array(Ru+1),ie=new Uint16Array(Ru+1);let ue=null,B,p,m;for(l=0;l<=Ru;l++)ce[l]=0;for(h=0;h<n;h++)ce[e[t+h]]++;for(w=u,b=Ru;b>=1&&ce[b]===0;b--);if(w>b&&(w=b),b===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(g=1;g<b&&ce[g]===0;g++);for(w<g&&(w=g),x=1,l=1;l<=Ru;l++)if(x<<=1,x-=ce[l],x<0)return-1;if(x>0&&(r===hI||b!==1))return-1;for(ie[1]=0,l=1;l<Ru;l++)ie[l+1]=ie[l]+ce[l];for(h=0;h<n;h++)e[t+h]!==0&&(o[ie[e[t+h]]++]=h);if(r===hI?(K=ue=o,oe=20):r===D1?(K=gQ,ue=yQ,oe=257):(K=mQ,ue=wQ,oe=0),H=0,h=0,l=g,V=s,I=w,S=0,W=-1,C=1<<w,Z=C-1,r===D1&&C>lI||r===dI&&C>fI)return 1;for(;;){B=l-S,o[h]+1<oe?(p=0,m=o[h]):o[h]>=oe?(p=ue[o[h]-oe],m=K[o[h]-oe]):(p=96,m=0),D=1<<l-S,z=1<<I,g=z;do z-=D,i[V+(H>>S)+z]=B<<24|p<<16|m|0;while(z!==0);for(D=1<<l-1;H&D;)D>>=1;if(D!==0?(H&=D-1,H+=D):H=0,h++,--ce[l]===0){if(l===b)break;l=e[t+o[h]]}if(l>w&&(H&Z)!==W){for(S===0&&(S=w),V+=g,I=l-S,x=1<<I;I+S<b&&(x-=ce[I+S],!(x<=0));)I++,x<<=1;if(C+=1<<I,r===D1&&C>lI||r===dI&&C>fI)return 1;W=H&Z,i[W]=w<<24|I<<16|V-s|0}}return H!==0&&(i[V+H]=l-S<<24|64<<16|0),a.bits=w,0};const bQ=0,pI=1,gI=2,{Z_FINISH:yI,Z_BLOCK:_Q,Z_TREES:W0,Z_OK:Da,Z_STREAM_END:AQ,Z_NEED_DICT:vQ,Z_STREAM_ERROR:oi,Z_DATA_ERROR:mI,Z_MEM_ERROR:wI,Z_BUF_ERROR:EQ,Z_DEFLATED:bI}=Kf,q0=16180,_I=16181,AI=16182,vI=16183,EI=16184,xI=16185,RI=16186,II=16187,SI=16188,kI=16189,Z0=16190,Cs=16191,$1=16192,TI=16193,F1=16194,OI=16195,NI=16196,CI=16197,BI=16198,Q0=16199,Y0=16200,PI=16201,MI=16202,LI=16203,UI=16204,DI=16205,H1=16206,$I=16207,FI=16208,Qt=16209,HI=16210,zI=16211,xQ=852,RQ=592,IQ=15,GI=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function SQ(){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 $a=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.mode<q0||e.mode>zI?1:0},VI=r=>{if($a(r))return oi;const e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=q0,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(xQ),e.distcode=e.distdyn=new Int32Array(RQ),e.sane=1,e.back=-1,Da},jI=r=>{if($a(r))return oi;const e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,VI(r)},KI=(r,e)=>{let t;if($a(r))return oi;const n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?oi:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,jI(r))},WI=(r,e)=>{if(!r)return oi;const t=new SQ;r.state=t,t.strm=r,t.window=null,t.mode=q0;const n=KI(r,e);return n!==Da&&(r.state=null),n},kQ=r=>WI(r,IQ);let qI=!0,z1,G1;const TQ=r=>{if(qI){z1=new Int32Array(512),G1=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(eh(pI,r.lens,0,288,z1,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;eh(gI,r.lens,0,32,G1,0,r.work,{bits:5}),qI=!1}r.lencode=z1,r.lenbits=9,r.distcode=G1,r.distbits=5},ZI=(r,e,t,n)=>{let i;const s=r.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(t-n,t-n+i),s.wnext),n-=i,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},OQ=(r,e)=>{let t,n,i,s,o,a,u,l,h,g,b,w,I,S,x=0,C,H,D,z,W,Z,V,K;const oe=new Uint8Array(4);let ce,ie;const ue=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($a(r)||!r.output||!r.input&&r.avail_in!==0)return oi;t=r.state,t.mode===Cs&&(t.mode=$1),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,g=a,b=u,K=Da;e:for(;;)switch(t.mode){case q0:if(t.wrap===0){t.mode=$1;break}for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0),l=0,h=0,t.mode=_I;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=Qt;break}if((l&15)!==bI){r.msg="unknown compression method",t.mode=Qt;break}if(l>>>=4,h-=4,V=(l&15)+8,t.wbits===0&&(t.wbits=V),V>15||V>t.wbits){r.msg="invalid window size",t.mode=Qt;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=l&512?kI:Cs,l=0,h=0;break;case _I:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==bI){r.msg="unknown compression method",t.mode=Qt;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=Qt;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0,t.mode=AI;case AI:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,oe[2]=l>>>16&255,oe[3]=l>>>24&255,t.check=Dr(t.check,oe,4,0)),l=0,h=0,t.mode=vI;case vI:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0,t.mode=EI;case EI:if(t.flags&1024){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Dr(t.check,oe,2,0)),l=0,h=0}else t.head&&(t.head.extra=null);t.mode=xI;case xI:if(t.flags&1024&&(w=t.length,w>a&&(w=a),w&&(t.head&&(V=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+w),V)),t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,t.length-=w),t.length))break e;t.length=0,t.mode=RI;case RI:if(t.flags&2048){if(a===0)break e;w=0;do V=n[s+w++],t.head&&V&&t.length<65536&&(t.head.name+=String.fromCharCode(V));while(V&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,V)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=II;case II:if(t.flags&4096){if(a===0)break e;w=0;do V=n[s+w++],t.head&&V&&t.length<65536&&(t.head.comment+=String.fromCharCode(V));while(V&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,V)break e}else t.head&&(t.head.comment=null);t.mode=SI;case SI:if(t.flags&512){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.check&65535)){r.msg="header crc mismatch",t.mode=Qt;break}l=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=Cs;break;case kI:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}r.adler=t.check=GI(l),l=0,h=0,t.mode=Z0;case Z0:if(t.havedict===0)return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,vQ;r.adler=t.check=1,t.mode=Cs;case Cs:if(e===_Q||e===W0)break e;case $1:if(t.last){l>>>=h&7,h-=h&7,t.mode=H1;break}for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}switch(t.last=l&1,l>>>=1,h-=1,l&3){case 0:t.mode=TI;break;case 1:if(TQ(t),t.mode=Q0,e===W0){l>>>=2,h-=2;break e}break;case 2:t.mode=NI;break;case 3:r.msg="invalid block type",t.mode=Qt}l>>>=2,h-=2;break;case TI:for(l>>>=h&7,h-=h&7;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){r.msg="invalid stored block lengths",t.mode=Qt;break}if(t.length=l&65535,l=0,h=0,t.mode=F1,e===W0)break e;case F1:t.mode=OI;case OI:if(w=t.length,w){if(w>a&&(w=a),w>u&&(w=u),w===0)break e;i.set(n.subarray(s,s+w),o),a-=w,s+=w,u-=w,o+=w,t.length-=w;break}t.mode=Cs;break;case NI:for(;h<14;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.nlen=(l&31)+257,l>>>=5,h-=5,t.ndist=(l&31)+1,l>>>=5,h-=5,t.ncode=(l&15)+4,l>>>=4,h-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=Qt;break}t.have=0,t.mode=CI;case CI:for(;t.have<t.ncode;){for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.lens[ue[t.have++]]=l&7,l>>>=3,h-=3}for(;t.have<19;)t.lens[ue[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,ce={bits:t.lenbits},K=eh(bQ,t.lens,0,19,t.lencode,0,t.work,ce),t.lenbits=ce.bits,K){r.msg="invalid code lengths set",t.mode=Qt;break}t.have=0,t.mode=BI;case BI:for(;t.have<t.nlen+t.ndist;){for(;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(D<16)l>>>=C,h-=C,t.lens[t.have++]=D;else{if(D===16){for(ie=C+2;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(l>>>=C,h-=C,t.have===0){r.msg="invalid bit length repeat",t.mode=Qt;break}V=t.lens[t.have-1],w=3+(l&3),l>>>=2,h-=2}else if(D===17){for(ie=C+3;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,V=0,w=3+(l&7),l>>>=3,h-=3}else{for(ie=C+7;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,V=0,w=11+(l&127),l>>>=7,h-=7}if(t.have+w>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=Qt;break}for(;w--;)t.lens[t.have++]=V}}if(t.mode===Qt)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=Qt;break}if(t.lenbits=9,ce={bits:t.lenbits},K=eh(pI,t.lens,0,t.nlen,t.lencode,0,t.work,ce),t.lenbits=ce.bits,K){r.msg="invalid literal/lengths set",t.mode=Qt;break}if(t.distbits=6,t.distcode=t.distdyn,ce={bits:t.distbits},K=eh(gI,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,ce),t.distbits=ce.bits,K){r.msg="invalid distances set",t.mode=Qt;break}if(t.mode=Q0,e===W0)break e;case Q0:t.mode=Y0;case Y0:if(a>=6&&u>=258){r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,pQ(r,b),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,t.mode===Cs&&(t.back=-1);break}for(t.back=0;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(H&&!(H&240)){for(z=C,W=H,Z=D;x=t.lencode[Z+((l&(1<<z+W)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,t.length=D,H===0){t.mode=DI;break}if(H&32){t.back=-1,t.mode=Cs;break}if(H&64){r.msg="invalid literal/length code",t.mode=Qt;break}t.extra=H&15,t.mode=PI;case PI:if(t.extra){for(ie=t.extra;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=MI;case MI:for(;x=t.distcode[l&(1<<t.distbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(!(H&240)){for(z=C,W=H,Z=D;x=t.distcode[Z+((l&(1<<z+W)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,H&64){r.msg="invalid distance code",t.mode=Qt;break}t.offset=D,t.extra=H&15,t.mode=LI;case LI:if(t.extra){for(ie=t.extra;h<ie;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=Qt;break}t.mode=UI;case UI:if(u===0)break e;if(w=b-u,t.offset>w){if(w=t.offset-w,w>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=Qt;break}w>t.wnext?(w-=t.wnext,I=t.wsize-w):I=t.wnext-w,w>t.length&&(w=t.length),S=t.window}else S=i,I=o-t.offset,w=t.length;w>u&&(w=u),u-=w,t.length-=w;do i[o++]=S[I++];while(--w);t.length===0&&(t.mode=Y0);break;case DI:if(u===0)break e;i[o++]=t.length,u--,t.mode=Y0;break;case H1:if(t.wrap){for(;h<32;){if(a===0)break e;a--,l|=n[s++]<<h,h+=8}if(b-=u,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Dr(t.check,i,b,o-b):jf(t.check,i,b,o-b)),b=u,t.wrap&4&&(t.flags?l:GI(l))!==t.check){r.msg="incorrect data check",t.mode=Qt;break}l=0,h=0}t.mode=$I;case $I:if(t.wrap&&t.flags){for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=Qt;break}l=0,h=0}t.mode=FI;case FI:K=AQ;break e;case Qt:K=mI;break e;case HI:return wI;case zI:default:return oi}return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,(t.wsize||b!==r.avail_out&&t.mode<Qt&&(t.mode<H1||e!==yI))&&ZI(r,r.output,r.next_out,b-r.avail_out),g-=r.avail_in,b-=r.avail_out,r.total_in+=g,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Dr(t.check,i,b,r.next_out-b):jf(t.check,i,b,r.next_out-b)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Cs?128:0)+(t.mode===Q0||t.mode===F1?256:0),(g===0&&b===0||e===yI)&&K===Da&&(K=EQ),K},NQ=r=>{if($a(r))return oi;let e=r.state;return e.window&&(e.window=null),r.state=null,Da},CQ=(r,e)=>{if($a(r))return oi;const t=r.state;return t.wrap&2?(t.head=e,e.done=!1,Da):oi},BQ=(r,e)=>{const t=e.length;let n,i,s;return $a(r)||(n=r.state,n.wrap!==0&&n.mode!==Z0)?oi:n.mode===Z0&&(i=1,i=jf(i,e,t,0),i!==n.check)?mI:(s=ZI(r,e,t,t),s?(n.mode=HI,wI):(n.havedict=1,Da))};var PQ=jI,MQ=KI,LQ=VI,UQ=kQ,DQ=WI,$Q=OQ,FQ=NQ,HQ=CQ,zQ=BQ,GQ="pako inflate (from Nodeca project)",Bs={inflateReset:PQ,inflateReset2:MQ,inflateResetKeep:LQ,inflateInit:UQ,inflateInit2:DQ,inflate:$Q,inflateEnd:FQ,inflateGetHeader:HQ,inflateSetDictionary:zQ,inflateInfo:GQ};function VQ(){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 jQ=VQ;const QI=Object.prototype.toString,{Z_NO_FLUSH:KQ,Z_FINISH:WQ,Z_OK:th,Z_STREAM_END:V1,Z_NEED_DICT:j1,Z_STREAM_ERROR:qQ,Z_DATA_ERROR:YI,Z_MEM_ERROR:ZQ}=Kf;function rh(r){this.options=V0.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new cI,this.strm.avail_out=0;let t=Bs.inflateInit2(this.strm,e.windowBits);if(t!==th)throw new Error(bu[t]);if(this.header=new jQ,Bs.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Xf.string2buf(e.dictionary):QI.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Bs.inflateSetDictionary(this.strm,e.dictionary),t!==th)))throw new Error(bu[t])}rh.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?WQ:KQ,QI.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=Bs.inflate(t,o),s===j1&&i&&(s=Bs.inflateSetDictionary(t,i),s===th?s=Bs.inflate(t,o):s===YI&&(s=j1));t.avail_in>0&&s===V1&&t.state.wrap>0&&r[t.next_in]!==0;)Bs.inflateReset(t),s=Bs.inflate(t,o);switch(s){case qQ:case YI:case j1:case ZQ:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===V1))if(this.options.to==="string"){let u=Xf.utf8border(t.output,t.next_out),l=t.next_out-u,h=Xf.buf2string(t.output,u);t.next_out=l,t.avail_out=n-l,l&&t.output.set(t.output.subarray(u,u+l),0),this.onData(h)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===th&&a===0)){if(s===V1)return s=Bs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},rh.prototype.onData=function(r){this.chunks.push(r)},rh.prototype.onEnd=function(r){r===th&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=V0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function K1(r,e){const t=new rh(e);if(t.push(r),t.err)throw t.msg||bu[t.err];return t.result}function QQ(r,e){return e=e||{},e.raw=!0,K1(r,e)}var YQ=rh,JQ=K1,XQ=QQ,eY=K1,tY=Kf,rY={Inflate:YQ,inflate:JQ,inflateRaw:XQ,ungzip:eY,constants:tY};const{Inflate:Cae,inflate:nY,inflateRaw:Bae,ungzip:Pae}=rY;var iY=nY,JI={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,W;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(W=1,H=new Array(C-1);W<C;W++)H[W-1]=arguments[W];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(JI);var sY=JI.exports;const oY=xn(sY);function aY(r,e){return Array.apply(0,new Array(Math.ceil(r.length/e))).map((t,n)=>r.slice(n*e,(n+1)*e))}const Fa=r=>"version"in r;function cY(r){return new TextDecoder("utf-8").decode(r)}function XI(r){return Or.encode(r)}function eS(r){return Ne.from(r,"base64")}function Io(r){return"accounts"in r}async function uY(r){const e=(await me.findProgramAddress([],r))[0];return await me.createWithSeed(e,lY(),r)}function lY(){return"anchor:idl"}const fY=Xe.struct([Xe.publicKey("authority"),Xe.vecU8("data")]);function hY(r){return fY.decode(r)}function dY(r){const e=["name","path","account","relations","generic"],t=s=>s.split(".").map(Nq).join("."),n=s=>{for(const o in s){const a=s[o];e.includes(o)?s[o]=Array.isArray(a)?a.map(t):t(a):typeof a=="object"&&n(a)}},i=structuredClone(r);return n(i),i}function Iu(r,e,t,n){return r!=null&&r.length?r[0].name?t(r):n(r):e()}function pY(r){const e=new Map;return r.errors&&r.errors.forEach(t=>{var n;let i=(n=t.msg)!==null&&n!==void 0?n:t.name;e.set(t.code,i)}),e}function gY(r,...e){if(r.args.length!=e.length)throw new Error("Invalid argument length");const t={};let n=0;return r.args.forEach(i=>{t[i.name]=e[n],n+=1}),t}function tS(r,e={}){r.forEach(t=>{if(Io(t))tS(t.accounts,e[t.name]);else if(!e[t.name])throw new Error(`Account \`${t.name}\` not provided.`)})}function xi(r){return r instanceof me?r:new me(r)}class yY extends TypeError{constructor(e,t){let n;const{message:i,...s}=e,{path:o}=e,a=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(a),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=n)!=null?u:n=[e,...t()]}}}function mY(r){return Su(r)&&typeof r[Symbol.iterator]=="function"}function Su(r){return typeof r=="object"&&r!=null}function So(r){return typeof r=="string"?JSON.stringify(r):""+r}function wY(r){const{done:e,value:t}=r.next();return e?void 0:t}function bY(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u="Expected a value of type `"+o+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+So(n)+"`"}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*rS(r,e,t,n){mY(r)||(r=[r]);for(const i of r){const s=bY(i,e,t,n);s&&(yield s)}}function*W1(r,e,t){t===void 0&&(t={});const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i};if(s&&(r=e.coercer(r,a),o&&e.type!=="type"&&Su(e.schema)&&Su(r)&&!Array.isArray(r)))for(const l in r)e.schema[l]===void 0&&delete r[l];let u=!0;for(const l of e.validator(r,a))u=!1,yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=W1(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o});for(const w of b)w[0]?(u=!1,yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):Su(r)&&(r[l]=h))}if(u)for(const l of e.refiner(r,a))u=!1,yield[l,void 0];u&&(yield[void 0,r])}class ko{constructor(e){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:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return rS(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return rS(h,l,this,u)}:this.refiner=()=>[]}assert(e){return _Y(e,this)}create(e){return q1(e,this)}is(e){return nS(e,this)}mask(e){return AY(e,this)}validate(e,t){return t===void 0&&(t={}),nh(e,this,t)}}function _Y(r,e){const t=nh(r,e);if(t[0])throw t[0]}function q1(r,e){const t=nh(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function AY(r,e){const t=nh(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function nS(r,e){return!nh(r,e)[0]}function nh(r,e,t){t===void 0&&(t={});const n=W1(r,e,t),i=wY(n);return i[0]?[new yY(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function ih(r,e){return new ko({type:r,schema:null,validator:e})}function vY(){return ih("any",()=>!0)}function Z1(r){return new ko({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+So(e)}})}function EY(){return ih("boolean",r=>typeof r=="boolean")}function iS(r){const e=So(r);return new ko({type:"literal",schema:r,validator(t){return t===r||"Expected the literal `"+e+"`, but received: "+So(t)}})}function J0(r){return new ko({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X0(){return ih("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+So(r))}function ep(r){return new ko({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function Ha(){return ih("string",r=>typeof r=="string"||"Expected a string, but received: "+So(r))}function To(r){const e=Object.keys(r);return new ko({type:"type",schema:r,*entries(t){if(Su(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return Su(t)||"Expected an object, but received: "+So(t)}})}function sS(r){const e=r.map(t=>t.type).join(" | ");return new ko({type:"union",schema:null,coercer(t,n){return(r.find(s=>{const[o]=s.validate(t,{coerce:!0});return!o})||Q1()).coercer(t,n)},validator(t,n){const i=[];for(const s of r){const[...o]=W1(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+So(t),...i]}})}function Q1(){return ih("unknown",()=>!0)}function xY(r,e,t){return new ko({...r,coercer:(n,i)=>nS(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}const oS=99;async function RY(r,e,t){if(e.length<=oS)return await aS(r,e,t);{const n=aY(e,oS);return(await Promise.all(n.map(s=>aS(r,s,t)))).flat()}}async function aS(r,e,t){const n=t??r.commitment,{value:i,context:s}=await r.getMultipleAccountsInfoAndContext(e,n);return i.map((a,u)=>a===null?null:{publicKey:e[u],account:a,context:s})}async function IY(r,e,t,n,i){var s;t&&t.length>0&&e.sign(...t);const o=e._compile(),a=o.serialize(),l=e._serialize(a).toString("base64"),h={encoding:"base64",commitment:n??r.commitment};if(i){const I=(Array.isArray(i)?i:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}t&&t.length>0&&(h.sigVerify=!0);const g=[l,h],b=await r._rpcRequest("simulateTransaction",g),w=q1(b,OY);if("error"in w){let I;if("data"in w.error&&(I=(s=w.error.data)===null||s===void 0?void 0:s.logs,I&&Array.isArray(I))){const S=`
|
|
26
|
+
`,x=S+I.join(S);console.error(w.error.message,x)}throw new _o("failed to simulate transaction: "+w.error.message,I)}return w.result}function SY(r){return xY(cS(r),kY,e=>"error"in e?e:{...e,result:q1(e.result,r)})}const kY=cS(Q1());function cS(r){return sS([To({jsonrpc:iS("2.0"),id:Ha(),result:r}),To({jsonrpc:iS("2.0"),id:Ha(),error:To({code:Q1(),message:Ha(),data:ep(vY())})})])}function TY(r){return SY(To({context:To({slot:X0()}),value:r}))}const OY=TY(To({err:J0(sS([To({}),Ha()])),logs:J0(Z1(Ha())),accounts:ep(J0(Z1(J0(To({executable:EY(),owner:Ha(),lamports:X0(),data:Z1(Ha()),rentEpoch:ep(X0())}))))),unitsConsumed:ep(X0())}));class sh{constructor(e,t,n=sh.defaultOptions()){this.connection=e,this.wallet=t,this.opts=n,this.publicKey=t==null?void 0:t.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(e,t=sh.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(e,t,n){var i,s,o,a;if(n===void 0&&(n=this.opts),Fa(e))t&&e.sign(t);else if(e.feePayer=(i=e.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,e.recentBlockhash=(await this.connection.getLatestBlockhash(n.preflightCommitment)).blockhash,t)for(const l of t)e.partialSign(l);e=await this.wallet.signTransaction(e);const u=e.serialize();try{return await uS(this.connection,u,n)}catch(l){if(l instanceof Y1){const h=XI(Fa(e)?((s=e.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=e.signature)!==null&&o!==void 0?o:new Uint8Array),g=Fa(e)?0:void 0,b=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:g});if(b){const w=(a=b.meta)===null||a===void 0?void 0:a.logMessages;throw w?new _o(l.message,w):l}else throw l}else throw l}}async sendAll(e,t){var n,i,s;t===void 0&&(t=this.opts);const o=(await this.connection.getLatestBlockhash(t.preflightCommitment)).blockhash;let a=e.map(h=>{var g,b;if(Fa(h.tx)){let w=h.tx;return h.signers&&w.sign(h.signers),w}else{let w=h.tx,I=(g=h.signers)!==null&&g!==void 0?g:[];return w.feePayer=(b=w.feePayer)!==null&&b!==void 0?b:this.wallet.publicKey,w.recentBlockhash=o,I.forEach(S=>{w.partialSign(S)}),w}});const u=await this.wallet.signAllTransactions(a),l=[];for(let h=0;h<a.length;h+=1){const g=u[h],b=g.serialize();try{l.push(await uS(this.connection,b,t))}catch(w){if(w instanceof Y1){const I=XI(Fa(g)?((n=g.signatures)===null||n===void 0?void 0:n[0])||new Uint8Array:(i=g.signature)!==null&&i!==void 0?i:new Uint8Array),S=Fa(g)?0:void 0,x=await this.connection.getTransaction(I,{commitment:"confirmed",maxSupportedTransactionVersion:S});if(x){const C=(s=x.meta)===null||s===void 0?void 0:s.logMessages;throw C?new _o(w.message,C):w}else throw w}else throw w}}return l}async simulate(e,t,n,i){let s=(await this.connection.getLatestBlockhash(n??this.connection.commitment)).blockhash,o;if(Fa(e)?(t&&t.length>0&&(e.sign(t),e=await this.wallet.signTransaction(e)),o=await this.connection.simulateTransaction(e,{commitment:n})):(e.feePayer=e.feePayer||this.wallet.publicKey,e.recentBlockhash=s,t&&t.length>0&&(e=await this.wallet.signTransaction(e)),o=await IY(this.connection,e,t,n,i)),o.value.err)throw new NY(o.value);return o.value}}class NY extends Error{constructor(e,t){super(t),this.simulationResponse=e}}async function uS(r,e,t){const n=t?{skipPreflight:t.skipPreflight,preflightCommitment:t.preflightCommitment||t.commitment,maxRetries:t.maxRetries,minContextSlot:t.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await r.sendRawTransaction(e,n);if(t!=null&&t.blockhash)if(n.maxRetries===0){const a=AbortSignal.timeout(15e3);i=(await r.confirmTransaction({abortSignal:a,signature:o,...t.blockhash},t&&t.commitment)).value}else i=(await r.confirmTransaction({signature:o,...t.blockhash},t&&t.commitment)).value;else i=(await r.confirmTransaction(o,t&&t.commitment)).value;if(i.err)throw new Y1(`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 Y1 extends Error{constructor(e){super(e)}}function J1(){return sh.local()}var CY=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof qc<"u"?qc:typeof self<"u"?self:{},ee={};Object.defineProperty(ee,"__esModule",{value:!0});var lS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=ok=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=WS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=KS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=jS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=GS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=HS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=FS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=$S=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=DS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=US=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=LS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=MS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=PS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=BS=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=CS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=NS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=OS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=TS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=kS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=SS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=IS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=RS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=xS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=ES=ee.ANCHOR_ERROR__CONSTRAINT_RAW=vS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=AS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=_S=ee.ANCHOR_ERROR__CONSTRAINT_MUT=bS=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=wS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=mS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=yS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=gS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=pS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=dS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=hS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,fS=ee.ANCHOR_ERROR__DEPRECATED=Ck=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=Nk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=Ok=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=Tk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=kk=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=Sk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=Rk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=xk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=Ek=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=Ak=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=_k=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=bk=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=wk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=mk=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=yk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=gk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=pk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=dk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=hk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=fk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=lk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=uk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=ck=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=ak=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,hS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=100,dS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,pS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,gS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,yS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,mS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,wS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,bS=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,_S=ee.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,AS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,vS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,ES=ee.ANCHOR_ERROR__CONSTRAINT_RAW=2003,xS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,RS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,IS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,SS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,kS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=2008,TS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,OS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,NS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,CS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,BS=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,PS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,MS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,LS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,US=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,DS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,$S=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,FS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,HS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,GS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,jS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,KS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,WS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,ok=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;lS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var ak=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,ck=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,uk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,lk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,fk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,hk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,dk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,pk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,gk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,yk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,mk=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,wk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,bk=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,_k=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,Ak=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,Ek=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,xk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,Rk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,Sk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,kk=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,Tk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,Ok=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,Nk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,Ck=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;fS=ee.ANCHOR_ERROR__DEPRECATED=5e3;const BY=new Map;function Bk(r){return BY.get(r)!==void 0}class Oo extends Error{constructor(e){super(e),this.name="IdlError"}}class oh{constructor(e){this.stack=e}static parse(e){var t;const n=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<e.length;o++){if(i.exec(e[o])){s.pop();continue}const a=(t=n.exec(e[o]))===null||t===void 0?void 0:t[1];a&&s.push(new me(a))}return new oh(s)}}class ah extends Error{constructor(e,t,n,i,s,o){super(n.join(`
|
|
27
|
+
`).replace("Program log: ","")),this.errorLogs=n,this.logs=i,this.error={errorCode:e,errorMessage:t,comparedValues:o,origin:s},this._programErrorStack=oh.parse(i)}static parse(e){if(!e)return null;const t=e.findIndex(b=>b.startsWith("Program log: AnchorError"));if(t===-1)return null;const n=e[t],i=[n];let s;if(t+1<e.length){if(e[t+1]==="Program log: Left:"){const b=/^Program log: (.*)$/,w=b.exec(e[t+2])[1],I=b.exec(e[t+4])[1];s=[new me(w),new me(I)],i.push(...e.slice(t+1,t+5))}else if(e[t+1].startsWith("Program log: Left:")){const b=/^Program log: (Left|Right): (.*)$/,w=b.exec(e[t+1])[2],I=b.exec(e[t+2])[2];i.push(...e.slice(t+1,t+3)),s=[w,I]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),l=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),g=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(a){const[b,w,I]=a.slice(1,4),S={code:b,number:parseInt(w)};return new ah(S,I,i,e,void 0,s)}else if(l){const[b,w,I,S,x]=l.slice(1,6),C={code:I,number:parseInt(S)},H={file:b,line:parseInt(w)};return new ah(C,x,i,e,H,s)}else if(g){const[b,w,I,S]=g.slice(1,5),x=b,C={code:w,number:parseInt(I)};return new ah(C,S,i,e,x,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 tp extends Error{constructor(e,t,n){super(),this.code=e,this.msg=t,this.logs=n,n&&(this._programErrorStack=oh.parse(n))}static parse(e,t){const n=e.toString();let i;if(n.includes("custom program error:")){let a=n.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=n.match(/"Custom":([0-9]+)}/g);if(!a||a.length>1)return null;i=a[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=t.get(s);return o!==void 0?new tp(s,o,e.logs):(o=PY.get(s),o!==void 0?new tp(s,o,e.logs):null)}get program(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack}toString(){return this.msg}}function Pk(r,e){Bk("debug-logs")&&console.log("Translating error:",r);const t=ah.parse(r.logs);if(t)return t;const n=tp.parse(r,e);if(n)return n;if(r.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[r.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return r.programErrorStack=oh.parse(r.logs),new Proxy(r,i)}return r}const ve={InstructionMissing:hS,InstructionFallbackNotFound:dS,InstructionDidNotDeserialize:pS,InstructionDidNotSerialize:gS,IdlInstructionStub:yS,IdlInstructionInvalidProgram:mS,IdlAccountNotEmpty:wS,EventInstructionStub:bS,ConstraintMut:_S,ConstraintHasOne:AS,ConstraintSigner:vS,ConstraintRaw:ES,ConstraintOwner:xS,ConstraintRentExempt:RS,ConstraintSeeds:IS,ConstraintExecutable:SS,ConstraintState:kS,ConstraintAssociated:TS,ConstraintAssociatedInit:OS,ConstraintClose:NS,ConstraintAddress:CS,ConstraintZero:BS,ConstraintTokenMint:PS,ConstraintTokenOwner:MS,ConstraintMintMintAuthority:LS,ConstraintMintFreezeAuthority:US,ConstraintMintDecimals:DS,ConstraintSpace:$S,ConstraintAccountIsNone:FS,ConstraintTokenTokenProgram:HS,ConstraintMintTokenProgram:zS,ConstraintAssociatedTokenTokenProgram:GS,ConstraintMintGroupPointerExtension:VS,ConstraintMintGroupPointerExtensionAuthority:jS,ConstraintMintGroupPointerExtensionGroupAddress:KS,ConstraintMintGroupMemberPointerExtension:WS,ConstraintMintGroupMemberPointerExtensionAuthority:qS,ConstraintMintGroupMemberPointerExtensionMemberAddress:ZS,ConstraintMintMetadataPointerExtension:QS,ConstraintMintMetadataPointerExtensionAuthority:YS,ConstraintMintMetadataPointerExtensionMetadataAddress:JS,ConstraintMintCloseAuthorityExtension:XS,ConstraintMintCloseAuthorityExtensionAuthority:ek,ConstraintMintPermanentDelegateExtension:tk,ConstraintMintPermanentDelegateExtensionDelegate:rk,ConstraintMintTransferHookExtension:nk,ConstraintMintTransferHookExtensionAuthority:ik,ConstraintMintTransferHookExtensionProgramId:sk,RequireViolated:ok,RequireEqViolated:lS,RequireKeysEqViolated:ak,RequireNeqViolated:ck,RequireKeysNeqViolated:uk,RequireGtViolated:lk,RequireGteViolated:fk,AccountDiscriminatorAlreadySet:hk,AccountDiscriminatorNotFound:dk,AccountDiscriminatorMismatch:pk,AccountDidNotDeserialize:gk,AccountDidNotSerialize:yk,AccountNotEnoughKeys:mk,AccountNotMutable:wk,AccountOwnedByWrongProgram:bk,InvalidProgramId:_k,InvalidProgramExecutable:Ak,AccountNotSigner:vk,AccountNotSystemOwned:Ek,AccountNotInitialized:xk,AccountNotProgramData:Rk,AccountNotAssociatedTokenAccount:Ik,AccountSysvarMismatch:Sk,AccountReallocExceedsLimit:kk,AccountDuplicateReallocs:Tk,DeclaredProgramIdMismatch:Ok,TryingToInitPayerAsProgramAccount:Nk,InvalidNumericConversion:Ck,Deprecated:fS},PY=new Map([[ve.InstructionMissing,"Instruction discriminator not provided"],[ve.InstructionFallbackNotFound,"Fallback functions are not supported"],[ve.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[ve.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[ve.IdlInstructionStub,"The program was compiled without idl instructions"],[ve.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[ve.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[ve.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[ve.ConstraintMut,"A mut constraint was violated"],[ve.ConstraintHasOne,"A has one constraint was violated"],[ve.ConstraintSigner,"A signer constraint was violated"],[ve.ConstraintRaw,"A raw constraint was violated"],[ve.ConstraintOwner,"An owner constraint was violated"],[ve.ConstraintRentExempt,"A rent exemption constraint was violated"],[ve.ConstraintSeeds,"A seeds constraint was violated"],[ve.ConstraintExecutable,"An executable constraint was violated"],[ve.ConstraintState,"Deprecated Error, feel free to replace with something else"],[ve.ConstraintAssociated,"An associated constraint was violated"],[ve.ConstraintAssociatedInit,"An associated init constraint was violated"],[ve.ConstraintClose,"A close constraint was violated"],[ve.ConstraintAddress,"An address constraint was violated"],[ve.ConstraintZero,"Expected zero account discriminant"],[ve.ConstraintTokenMint,"A token mint constraint was violated"],[ve.ConstraintTokenOwner,"A token owner constraint was violated"],[ve.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[ve.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[ve.ConstraintMintDecimals,"A mint decimals constraint was violated"],[ve.ConstraintSpace,"A space constraint was violated"],[ve.ConstraintAccountIsNone,"A required account for the constraint is None"],[ve.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[ve.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[ve.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[ve.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[ve.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[ve.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[ve.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[ve.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[ve.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[ve.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[ve.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[ve.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[ve.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[ve.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[ve.RequireViolated,"A require expression was violated"],[ve.RequireEqViolated,"A require_eq expression was violated"],[ve.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[ve.RequireNeqViolated,"A require_neq expression was violated"],[ve.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[ve.RequireGtViolated,"A require_gt expression was violated"],[ve.RequireGteViolated,"A require_gte expression was violated"],[ve.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[ve.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[ve.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[ve.AccountDidNotDeserialize,"Failed to deserialize the account"],[ve.AccountDidNotSerialize,"Failed to serialize the account"],[ve.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[ve.AccountNotMutable,"The given account is not mutable"],[ve.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[ve.InvalidProgramId,"Program ID was not as expected"],[ve.InvalidProgramExecutable,"Program account is not executable"],[ve.AccountNotSigner,"The given account did not sign"],[ve.AccountNotSystemOwned,"The given account is not owned by the system program"],[ve.AccountNotInitialized,"The program expected this account to be already initialized"],[ve.AccountNotProgramData,"The given account is not a program data account"],[ve.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[ve.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[ve.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[ve.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[ve.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[ve.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[ve.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[ve.Deprecated,"The API being used is deprecated and should no longer be used"]]);class mt{static fieldLayout(e,t=[],n){const i=e.name;switch(e.type){case"bool":return Xe.bool(i);case"u8":return Xe.u8(i);case"i8":return Xe.i8(i);case"u16":return Xe.u16(i);case"i16":return Xe.i16(i);case"u32":return Xe.u32(i);case"i32":return Xe.i32(i);case"f32":return Xe.f32(i);case"u64":return Xe.u64(i);case"i64":return Xe.i64(i);case"f64":return Xe.f64(i);case"u128":return Xe.u128(i);case"i128":return Xe.i128(i);case"u256":return Xe.u256(i);case"i256":return Xe.i256(i);case"bytes":return Xe.vecU8(i);case"string":return Xe.str(i);case"pubkey":return Xe.publicKey(i);default:{if("option"in e.type)return Xe.option(mt.fieldLayout({type:e.type.option},t,n),i);if("vec"in e.type)return Xe.vec(mt.fieldLayout({type:e.type.vec},t,n),i);if("array"in e.type){let[s,o]=e.type.array;return o=mt.resolveArrayLen(o,n),Xe.array(mt.fieldLayout({type:s},t,n),o,i)}if("defined"in e.type){if(!t)throw new Oo("User defined types not provided");const s=e.type.defined.name,o=t.find(a=>a.name===s);if(!o)throw new Oo(`Type not found: ${e.name}`);return mt.typeDefLayout({typeDef:o,types:t,genericArgs:n??e.type.defined.generics,name:i})}if("generic"in e.type){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new Oo(`Invalid generic field: ${e.name}`);return mt.fieldLayout({...e,type:s.type},t)}throw new Oo(`Not yet implemented: ${JSON.stringify(e.type)}`)}}}static typeDefLayout({typeDef:e,types:t,name:n,genericArgs:i}){switch(e.type.kind){case"struct":{const s=Iu(e.type.fields,()=>[],o=>o.map(a=>{const u=i&&mt.resolveGenericArgs({type:a.type,typeDef:e,genericArgs:i});return mt.fieldLayout(a,t,u)}),o=>o.map((a,u)=>{const l=i&&mt.resolveGenericArgs({type:a,typeDef:e,genericArgs:i});return mt.fieldLayout({name:u.toString(),type:a},t,l)}));return Xe.struct(s,n)}case"enum":{const s=e.type.variants.map(o=>{const a=Iu(o.fields,()=>[],u=>u.map(l=>{const h=i&&mt.resolveGenericArgs({type:l.type,typeDef:e,genericArgs:i});return mt.fieldLayout(l,t,h)}),u=>u.map((l,h)=>{const g=i&&mt.resolveGenericArgs({type:l,typeDef:e,genericArgs:i});return mt.fieldLayout({name:h.toString(),type:l},t,g)}));return Xe.struct(a,o.name)});return n!==void 0?Xe.rustEnum(s).replicate(n):Xe.rustEnum(s,n)}case"type":return mt.fieldLayout({type:e.type.alias,name:n},t)}}static typeSize(e,t,n){var i;switch(e){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 e)return 1+mt.typeSize(e.option,t,n);if("coption"in e)return 4+mt.typeSize(e.coption,t,n);if("vec"in e)return 1;if("array"in e){let[s,o]=e.array;return o=mt.resolveArrayLen(o,n),mt.typeSize(s,t,n)*o}if("defined"in e){const s=(i=t.types)===null||i===void 0?void 0:i.find(a=>a.name===e.defined.name);if(!s)throw new Oo(`Type not found: ${JSON.stringify(e)}`);const o=a=>{const u=n??e.defined.generics,l=u&&mt.resolveGenericArgs({type:a,typeDef:s,genericArgs:u});return mt.typeSize(a,t,l)};switch(s.type.kind){case"struct":return Iu(s.type.fields,()=>[0],a=>a.map(u=>o(u.type)),a=>a.map(u=>o(u))).reduce((a,u)=>a+u,0);case"enum":{const a=s.type.variants.map(u=>Iu(u.fields,()=>[0],l=>l.map(h=>o(h.type)),l=>l.map(h=>o(h))).reduce((l,h)=>l+h,0));return Math.max(...a)+1}case"type":return mt.typeSize(s.type.alias,t,n)}}if("generic"in e){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new Oo(`Invalid generic: ${e.generic}`);return mt.typeSize(s.type,t,n)}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}static resolveArrayLen(e,t){if(typeof e=="number")return e;if(t){const n=t.find(i=>i.kind==="const");(n==null?void 0:n.kind)==="const"&&(e=+n.value)}if(typeof e!="number")throw new Oo("Generic array length did not resolve");return e}static resolveGenericArgs({type:e,typeDef:t,genericArgs:n,isDefined:i}){if(typeof e!="object")return null;for(const s in t.generics){const o=t.generics[s];if("generic"in e&&o.name===e.generic)return[n[s]];if("option"in e){const a=mt.resolveGenericArgs({type:e.option,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{option:a[0].type}}]}if("vec"in e){const a=mt.resolveGenericArgs({type:e.vec,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{vec:a[0].type}}]}if("array"in e){const[a,u]=e.array,l=typeof u=="object",h=mt.resolveGenericArgs({type:a,typeDef:t,genericArgs:n,isDefined:i});if(h){for(const g in t.generics.slice(+s)){const b=+s+ +g;l&&t.generics[b].name===u.generic&&h.push(n[b])}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(l&&o.name===u.generic){const g=n[s];return i?[{kind:"type",type:{array:[a,+g.value]}}]:[g]}return null}if("defined"in e)return e.defined.generics?e.defined.generics.flatMap(a=>{switch(a.kind){case"type":return mt.resolveGenericArgs({type:a.type,typeDef:t,genericArgs:n,isDefined:!0});case"const":return[a]}}).filter(a=>a!==null):null}return null}}class MY{constructor(e){this.idl=e;const t=e.instructions.map(n=>{const i=n.name,s=n.args.map(a=>mt.fieldLayout(a,e.types)),o=Xe.struct(s,i);return[i,{discriminator:n.discriminator,layout:o}]});this.ixLayouts=new Map(t)}encode(e,t){const n=Ne.alloc(1e3),i=this.ixLayouts.get(e);if(!i)throw new Error(`Unknown method: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s);return Ne.concat([Ne.from(i.discriminator),o])}decode(e,t="hex"){typeof e=="string"&&(e=t==="hex"?Ne.from(e,"hex"):Or.decode(e));for(const[n,i]of this.ixLayouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(e.subarray(s.length))}}return null}format(e,t){return jn.format(e,t,this.idl)}}class jn{static format(e,t,n){const i=n.instructions.find(u=>e.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:jn.formatIdlType(u.type),data:jn.formatIdlData(u,e.data[u.name],n.types)})),o=jn.flattenIdlAccounts(i.accounts),a=t.map((u,l)=>l<o.length?{name:o[l].name,...u}:{name:void 0,...u});return{args:s,accounts:a}}static formatIdlType(e){if(typeof e=="string")return e;if("option"in e)return`Option<${this.formatIdlType(e.option)}>`;if("coption"in e)return`COption<${this.formatIdlType(e.coption)}>`;if("vec"in e)return`Vec<${this.formatIdlType(e.vec)}>`;if("array"in e)return`Array<${e.array[0]}; ${e.array[1]}>`;if("defined"in e){const t=e.defined.name;if(e.defined.generics){const n=e.defined.generics.map(i=>{switch(i.kind){case"type":return jn.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${t}<${n}>`}return t}throw new Error(`Unknown IDL type: ${e}`)}static formatIdlData(e,t,n){if(typeof e.type=="string")return t.toString();if("vec"in e.type)return"["+t.map(i=>this.formatIdlData({name:"",type:e.type.vec},i,n)).join(", ")+"]";if("option"in e.type)return t===null?"null":this.formatIdlData({name:"",type:e.type.option},t,n);if("defined"in e.type){if(!n)throw new Error("User defined types not provided");const i=e.type.defined.name,s=n.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return jn.formatIdlDataDefined(s,t,n)}return"unknown"}static formatIdlDataDefined(e,t,n){switch(e.type.kind){case"struct":return"{ "+Iu(e.type.fields,()=>"",i=>Object.entries(t).map(([s,o])=>{const a=i.find(u=>u.name===s);if(!a)throw new Error(`Field not found: ${s}`);return s+": "+jn.formatIdlData(a,o,n)}).join(", "),i=>Object.entries(t).map(([s,o])=>s+": "+jn.formatIdlData({name:"",type:i[s]},o,n)).join(", "))+" }";case"enum":{const i=Object.keys(t)[0],s=e.type.variants.find(a=>a.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=t[i];return Iu(s.fields,()=>i,a=>{const u=Object.keys(o).map(l=>{const h=o[l],g=a.find(b=>b.name===l);if(!g)throw new Error(`Field not found: ${l}`);return l+": "+jn.formatIdlData(g,h,n)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([l,h])=>l+": "+jn.formatIdlData({name:"",type:a[l]},h,n)).join(", ");return`${i} { ${u} }`})}case"type":return jn.formatIdlType(e.type.alias)}}static flattenIdlAccounts(e,t){return e.map(n=>{const i=LY(n.name);if(n.hasOwnProperty("accounts")){const s=t?`${t} > ${i}`:i;return jn.flattenIdlAccounts(n.accounts,s)}else return{...n,name:t?`${t} > ${i}`:i}}).flat()}}function LY(r){const e=r.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}class UY{constructor(e){if(this.idl=e,!e.accounts){this.accountLayouts=new Map;return}const t=e.types;if(!t)throw new Error("Accounts require `idl.types`");const n=e.accounts.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:mt.typeDefLayout({typeDef:s,types:t})}]});this.accountLayouts=new Map(n)}async encode(e,t){const n=Ne.alloc(1e3),i=this.accountLayouts.get(e);if(!i)throw new Error(`Unknown account: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s),a=this.accountDiscriminator(e);return Ne.concat([a,o])}decode(e,t){const n=this.accountDiscriminator(e);if(n.compare(t.slice(0,n.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(e,t)}decodeAny(e){for(const[t,n]of this.accountLayouts)if(e.subarray(0,n.discriminator.length).equals(Ne.from(n.discriminator)))return this.decodeUnchecked(t,e);throw new Error("Account not found")}decodeUnchecked(e,t){const n=this.accountDiscriminator(e),i=t.subarray(n.length),s=this.accountLayouts.get(e);if(!s)throw new Error(`Unknown account: ${e}`);return s.layout.decode(i)}memcmp(e,t){const n=this.accountDiscriminator(e);return{offset:0,bytes:Or.encode(t?Ne.concat([n,t]):n)}}size(e){return this.accountDiscriminator(e).length+mt.typeSize({defined:{name:e}},this.idl)}accountDiscriminator(e){var t;const n=(t=this.idl.accounts)===null||t===void 0?void 0:t.find(i=>i.name===e);if(!n)throw new Error(`Account not found: ${e}`);return Ne.from(n.discriminator)}}class DY{constructor(e){if(!e.events){this.layouts=new Map;return}const t=e.types;if(!t)throw new Error("Events require `idl.types`");const n=e.events.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:mt.typeDefLayout({typeDef:s,types:t})}]});this.layouts=new Map(n)}decode(e){let t;try{t=eS(e)}catch{return null}for(const[n,i]of this.layouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(t.subarray(s.length))}}return null}}class $Y{constructor(e){const t=e.types;if(!t){this.typeLayouts=new Map;return}const n=t.filter(i=>!i.generics).map(i=>[i.name,mt.typeDefLayout({typeDef:i,types:t})]);this.typeLayouts=new Map(n)}encode(e,t){const n=Ne.alloc(1e3),i=this.typeLayouts.get(e);if(!i)throw new Error(`Unknown type: ${e}`);const s=i.encode(t,n);return n.slice(0,s)}decode(e,t){const n=this.typeLayouts.get(e);if(!n)throw new Error(`Unknown type: ${e}`);return n.decode(t)}}class Mk{constructor(e){this.instruction=new MY(e),this.accounts=new UY(e),this.events=new DY(e),this.types=new $Y(e)}}class Bn{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}var rp=Bn;function FY(r,e){return e.property?r+"["+e.property+"]":r}class za extends Bn{isCount(){throw new Error("ExternalLayout is abstract")}}class Lk extends za{constructor(e,t,n){if(!(e instanceof Bn))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof np||this.layout instanceof Uk}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}}class np extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}}class Uk extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}}const X1=Math.pow(2,32);function Dk(r){const e=Math.floor(r/X1),t=r-e*X1;return{hi32:e,lo32:t}}function $k(r,e){return r*X1+e}class HY extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return $k(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Dk(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}}class zY extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return $k(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Dk(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}}class GY extends Bn{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Bn,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}class Fk{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Hk extends Fk{constructor(e,t){if(!(e instanceof za&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}class zk extends Bn{constructor(e,t,n){const i=e instanceof np||e instanceof Uk;if(i)e=new Hk(new Lk(e));else if(e instanceof za&&e.isCount())e=new Hk(e);else if(!(e instanceof Fk))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Bn))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new VY(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Ze.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}}class VY extends Bn{constructor(e,t,n,i){if(!(e instanceof zk))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Bn))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.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=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}class jY extends Bn{constructor(e,t){if(!(e instanceof za&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof za||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof za&&(i=e.length),!(Ze.isBuffer(e)&&i===e.length))throw new TypeError(FY("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof za&&this.length.encode(i,t,n),i}}var KY=(r,e,t)=>new Lk(r,e,t),WY=r=>new np(1,r),Ps=r=>new np(4,r),qY=r=>new HY(r),Ms=r=>new zY(r),Pr=(r,e,t)=>new GY(r,e,t),Gk=(r,e,t)=>new zk(r,e,t),ch=(r,e)=>new jY(r,e);class ZY extends rp{constructor(e){super(-1,e),this.property=e,this.layout=Pr([Ps("length"),Ps("lengthPadding"),ch(KY(Ps(),-8),"chars")],this.property)}encode(e,t,n=0){if(e==null)return this.layout.span;const i={chars:Ze.from(e,"utf8")};return this.layout.encode(i,t,n)}decode(e,t=0){return this.layout.decode(e,t).chars.toString()}getSpan(e,t=0){return Ps().span+Ps().span+new vs(new Uint8Array(e).slice(t,t+4),10,"le").toNumber()}}function ip(r){return new ZY(r)}function ai(r){return ch(32,r)}const Kn=Gk(Ps("instruction"));Kn.addVariant(0,Pr([Ms("lamports"),Ms("space"),ai("owner")]),"createAccount"),Kn.addVariant(1,Pr([ai("owner")]),"assign"),Kn.addVariant(2,Pr([Ms("lamports")]),"transfer"),Kn.addVariant(3,Pr([ai("base"),ip("seed"),Ms("lamports"),Ms("space"),ai("owner")]),"createAccountWithSeed"),Kn.addVariant(4,Pr([ai("authorized")]),"advanceNonceAccount"),Kn.addVariant(5,Pr([Ms("lamports")]),"withdrawNonceAccount"),Kn.addVariant(6,Pr([ai("authorized")]),"initializeNonceAccount"),Kn.addVariant(7,Pr([ai("authorized")]),"authorizeNonceAccount"),Kn.addVariant(8,Pr([Ms("space")]),"allocate"),Kn.addVariant(9,Pr([ai("base"),ip("seed"),Ms("space"),ai("owner")]),"allocateWithSeed"),Kn.addVariant(10,Pr([ai("base"),ip("seed"),ai("owner")]),"assignWithSeed"),Kn.addVariant(11,Pr([Ms("lamports"),ip("seed"),ai("owner")]),"transferWithSeed"),Math.max(...Object.values(Kn.registry).map(r=>r.span));class QY extends rp{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}function Vk(r){return new QY(ch(32),e=>new me(e),e=>e.toBuffer(),r)}Pr([Ps("version"),Ps("state"),Vk("authorizedPubkey"),Vk("nonce"),Pr([qY("lamportsPerSignature")],"feeCalculator")]),new me("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new me("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var jk={exports:{}};(function(r,e){var t=typeof self<"u"?self:CY,n=function(){function s(){this.fetch=!1,this.DOMException=t.DOMException}return s.prototype=t,new s}();(function(s){(function(o){var a={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(a.arrayBuffer)var l=["[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&&l.indexOf(Object.prototype.toString.call(p))>-1};function g(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 b(p){return typeof p!="string"&&(p=String(p)),p}function w(p){var m={next:function(){var E=p.shift();return{done:E===void 0,value:E}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function I(p){this.map={},p instanceof I?p.forEach(function(m,E){this.append(E,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)}I.prototype.append=function(p,m){p=g(p),m=b(m);var E=this.map[p];this.map[p]=E?E+", "+m:m},I.prototype.delete=function(p){delete this.map[g(p)]},I.prototype.get=function(p){return p=g(p),this.has(p)?this.map[p]:null},I.prototype.has=function(p){return this.map.hasOwnProperty(g(p))},I.prototype.set=function(p,m){this.map[g(p)]=b(m)},I.prototype.forEach=function(p,m){for(var E in this.map)this.map.hasOwnProperty(E)&&p.call(m,this.map[E],E,this)},I.prototype.keys=function(){var p=[];return this.forEach(function(m,E){p.push(E)}),w(p)},I.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),w(p)},I.prototype.entries=function(){var p=[];return this.forEach(function(m,E){p.push([E,m])}),w(p)},a.iterable&&(I.prototype[Symbol.iterator]=I.prototype.entries);function S(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function x(p){return new Promise(function(m,E){p.onload=function(){m(p.result)},p.onerror=function(){E(p.error)}})}function C(p){var m=new FileReader,E=x(m);return m.readAsArrayBuffer(p),E}function H(p){var m=new FileReader,E=x(m);return m.readAsText(p),E}function D(p){for(var m=new Uint8Array(p),E=new Array(m.length),k=0;k<m.length;k++)E[k]=String.fromCharCode(m[k]);return E.join("")}function z(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:a.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:a.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():a.arrayBuffer&&a.blob&&u(p)?(this._bodyArrayBuffer=z(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=z(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):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var p=S(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?S(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(C)}),this.text=function(){var p=S(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(oe)}),this.json=function(){return this.text().then(JSON.parse)},this}var Z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function V(p){var m=p.toUpperCase();return Z.indexOf(m)>-1?m:p}function K(p,m){m=m||{};var E=m.body;if(p instanceof K){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new I(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!E&&p._bodyInit!=null&&(E=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 I(m.headers)),this.method=V(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")&&E)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(E)}K.prototype.clone=function(){return new K(this,{body:this._bodyInit})};function oe(p){var m=new FormData;return p.trim().split("&").forEach(function(E){if(E){var k=E.split("="),O=k.shift().replace(/\+/g," "),M=k.join("=").replace(/\+/g," ");m.append(decodeURIComponent(O),decodeURIComponent(M))}}),m}function ce(p){var m=new I,E=p.replace(/\r?\n[\t ]+/g," ");return E.split(/\r?\n/).forEach(function(k){var O=k.split(":"),M=O.shift().trim();if(M){var G=O.join(":").trim();m.append(M,G)}}),m}W.call(K.prototype);function ie(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 I(m.headers),this.url=m.url||"",this._initBody(p)}W.call(ie.prototype),ie.prototype.clone=function(){return new ie(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new I(this.headers),url:this.url})},ie.error=function(){var p=new ie(null,{status:0,statusText:""});return p.type="error",p};var ue=[301,302,303,307,308];ie.redirect=function(p,m){if(ue.indexOf(m)===-1)throw new RangeError("Invalid status code");return new ie(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,E){this.message=m,this.name=E;var k=Error(m);this.stack=k.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function B(p,m){return new Promise(function(E,k){var O=new K(p,m);if(O.signal&&O.signal.aborted)return k(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function G(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ce(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var A="response"in M?M.response:M.responseText;E(new ie(A,P))},M.onerror=function(){k(new TypeError("Network request failed"))},M.ontimeout=function(){k(new TypeError("Network request failed"))},M.onabort=function(){k(new o.DOMException("Aborted","AbortError"))},M.open(O.method,O.url,!0),O.credentials==="include"?M.withCredentials=!0:O.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),O.headers.forEach(function(P,A){M.setRequestHeader(A,P)}),O.signal&&(O.signal.addEventListener("abort",G),M.onreadystatechange=function(){M.readyState===4&&O.signal.removeEventListener("abort",G)}),M.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return B.polyfill=!0,s.fetch||(s.fetch=B,s.Headers=I,s.Request=K,s.Response=ie),o.Headers=I,o.Request=K,o.Response=ie,o.fetch=B,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,r.exports=e})(jk,jk.exports),Xe.rustEnum([Xe.struct([],"uninitialized"),Xe.struct([Xe.option(Xe.publicKey(),"authorityAddress")],"buffer"),Xe.struct([Xe.publicKey("programdataAddress")],"program"),Xe.struct([Xe.u64("slot"),Xe.option(Xe.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,Xe.u32());const ew="Program log: ",Kk="Program data: ",YY=ew.length,JY=Kk.length;class XY{constructor(e,t,n){this._programId=e,this._provider=t,this._eventParser=new Wk(e,n),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(e,t,n){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.set(e,((i=this._eventListeners.get(e))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[e,t]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,a)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const l=this._eventListeners.get(u.name);l&&l.forEach(h=>{const g=this._eventCallbacks.get(h);if(g){const[,b]=g;b(u.data,a.slot,o.signature)}})}},n)),s}async removeEventListener(e){const t=this._eventCallbacks.get(e);if(!t)throw new Error(`Event listener ${e} doesn't exist!`);const[n]=t;let i=this._eventListeners.get(n);if(!i)throw new Error(`Event listeners don't exist for ${n}!`);if(this._eventCallbacks.delete(e),i=i.filter(s=>s!==e),this._eventListeners.set(n,i),i.length===0&&this._eventListeners.delete(n),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 Wk{constructor(e,t){this.coder=t,this.programId=e}*parseLogs(e,t=!1){const n=new tJ(e),i=new eJ;let s=n.next();for(;s!==null;){let[o,a,u]=this.handleLog(i,s,t);o&&(yield o),a&&i.push(a),u&&i.pop(),s=n.next()}}handleLog(e,t,n){return e.stack.length>0&&e.program()===this.programId.toString()?this.handleProgramLog(t,n):[null,...this.handleSystemLog(t)]}handleProgramLog(e,t){if(e.startsWith(ew)||e.startsWith(Kk)){const n=e.startsWith(ew)?e.slice(YY):e.slice(JY),i=this.coder.events.decode(n);if(t&&i===null)throw new Error(`Unable to decode event ${n}`);return[i,null,!1]}else return[null,...this.handleSystemLog(e)]}handleSystemLog(e){const t=e.split(":")[0];return t.match(/^Program (.*) success/g)!==null?[null,!0]:t.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:t.includes("invoke")?["cpi",!1]:[null,!1]}}class eJ{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(e){this.stack.push(e)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class tJ{constructor(e){this.logs=e}next(){if(this.logs.length===0)return null;let e=this.logs[0];return this.logs=this.logs.slice(1),e}}function sp(r,e){var t,n;let i={};const s=r.args?r.args.length:0;if(e.length>s){if(e.length!==s+1)throw new Error(`provided too many arguments ${e} to instruction ${r==null?void 0:r.name} expecting: ${(n=(t=r.args)===null||t===void 0?void 0:t.map(o=>o.name))!==null&&n!==void 0?n:[]}`);i=e.pop()}return[e,i]}class op{static build(e,t,n){if(e.name==="_inner")throw new Oo("the _inner name is reserved");const i=(...s)=>{const[o,a]=sp(e,[...s]);tS(e.accounts,a.accounts),rJ(e,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),Bk("debug-logs")&&console.log("Outgoing account metas:",u),new Pt({keys:u,programId:n,data:t(e.name,gY(e,...o))})};return i.accounts=s=>op.accountsArray(s,e.accounts,n,e.name),i}static accountsArray(e,t,n,i){return e?t.map(s=>{if(Io(s)){const h=e[s.name];return op.accountsArray(h,s.accounts,n,i).flat()}let o;try{o=xi(e[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 a=s.optional&&o.equals(n),u=!!(s.writable&&!a),l=!!(s.signer&&!a);return{pubkey:o,isWritable:u,isSigner:l}}).flat():[]}}function rJ(r,...e){}class nJ{static build(e,t){return(...i)=>{var s,o,a;const[,u]=sp(e,[...i]),l=new Ot;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>l.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>l.add(h)),l.add(t(...i)),(a=u.postInstructions)===null||a===void 0||a.forEach(h=>l.add(h)),l}}}class iJ{static build(e,t,n,i){return async(...o)=>{var a;const u=t(...o),[,l]=sp(e,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(a=l.signers)!==null&&a!==void 0?a:[],l.options)}catch(h){throw Pk(h,n)}}}}class sJ{static build(e,t,n,i){var s;return((s=e.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new oJ(e,a,n,i,t),o),{})}}class oJ{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(e,t,n,i,s){this._idlAccount=t,this._programId=n,this._provider=i??J1(),this._coder=s??new Mk(e),this._size=this._coder.accounts.size(t.name)}async fetchNullable(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);return n}async fetchNullableAndContext(e,t){const n=await this.getAccountInfoAndContext(e,t),{value:i,context:s}=n;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist or has no data ${e.toString()}`);return n}async fetchAndContext(e,t){const{data:n,context:i}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist ${e.toString()}`);return{data:n,context:i}}async fetchMultiple(e,t){return(await this.fetchMultipleAndContext(e,t)).map(i=>i?i.data:null)}async fetchMultipleAndContext(e,t){return(await RY(this._provider.connection,e.map(i=>xi(i)),t)).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(e){const t=this.coder.accounts.memcmp(this._idlAccount.name,e instanceof Ze?e:void 0),n=[];return(t==null?void 0:t.offset)!=null&&(t==null?void 0:t.bytes)!=null&&n.push({memcmp:{offset:t.offset,bytes:t.bytes}}),(t==null?void 0:t.dataSize)!=null&&n.push({dataSize:t.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...n,...Array.isArray(e)?e:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(e,t){const n=uh.get(e.toString());if(n)return n.ee;const i=new oY;e=xi(e);const s=this._provider.connection.onAccountChange(e,o=>{const a=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",a)},t);return uh.set(e.toString(),{ee:i,listener:s}),i}async unsubscribe(e){let t=uh.get(e.toString());if(!t){console.warn("Address is not subscribed");return}uh&&await this._provider.connection.removeAccountChangeListener(t.listener).then(()=>{uh.delete(e.toString())}).catch(console.error)}async createInstruction(e,t){const n=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Br.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:e.publicKey,space:t??n,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(t??n),programId:this._programId})}async getAccountInfo(e,t){return await this._provider.connection.getAccountInfo(xi(e),t)}async getAccountInfoAndContext(e,t){return await this._provider.connection.getAccountInfoAndContext(xi(e),t)}}const uh=new Map;class aJ{static build(e,t,n,i,s,o,a){return async(...l)=>{var h;const g=t(...l),[,b]=sp(e,[...l]);let w;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{w=await i.simulate(g,b.signers,(h=b.options)===null||h===void 0?void 0:h.commitment)}catch(x){throw Pk(x,n)}if(w===void 0)throw new Error("Unable to simulate transaction");const I=w.logs;if(!I)throw new Error("Simulated logs not found");const S=[];if(a.events){let x=new Wk(o,s);for(const C of x.parseLogs(I))S.push(C)}return{events:S,raw:I}}}}function tw(r){return new qk(ch(8),e=>uJ.fromBuffer(e),e=>e.toBuffer(),r)}function ap(r){return new qk(ch(32),e=>new me(e),e=>e.toBuffer(),r)}function rw(r,e){return new cJ(r,e)}class qk extends rp{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}class cJ extends rp{constructor(e,t){super(-1,t),this.layout=e,this.discriminator=Ps()}encode(e,t,n=0){return e==null?this.layout.span+this.discriminator.encode(0,t,n):(this.discriminator.encode(1,t,n),this.layout.encode(e,t,n+4)+4)}decode(e,t=0){const n=this.discriminator.decode(e,t);if(n===0)return null;if(n===1)return this.layout.decode(e,t+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(e,t=0){return this.layout.getSpan(e,t+4)+4}}let uJ=class l6 extends vs{toBuffer(){const e=super.toArray().reverse(),t=Ze.from(e);if(t.length===8)return t;if(t.length>=8)throw new Error("u64 too large");const n=Ze.alloc(8);return t.copy(n),n}static fromBuffer(e){if(e.length!==8)throw new Error(`Invalid buffer length: ${e.length}`);return new l6([...e].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}};const lJ=Pr([ap("mint"),ap("owner"),tw("amount"),rw(ap(),"delegate"),(r=>{const e=Gk(WY("discriminator"),null,r);return e.addVariant(0,Pr([]),"uninitialized"),e.addVariant(1,Pr([]),"initialized"),e.addVariant(2,Pr([]),"frozen"),e})("state"),rw(tw(),"isNative"),tw("delegatedAmount"),rw(ap(),"closeAuthority")]);function fJ(r){return lJ.decode(r)}class hJ{constructor(e,t,n,i,s,o,a,u){this._args=e,this._accounts=t,this._provider=n,this._programId=i,this._idlIx=s,this._idlTypes=a,this._customResolver=u,this._accountStore=new dJ(n,o,i)}args(e){this._args=e}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let e=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(e++,e===16){const t=o=>Io(o)?o.accounts.some(t):!!(o.address||o.pda||o.relations),n=(o,a=[],u=[])=>{for(const l of o)Io(l)?u.push(...n(l.accounts,[...a,l.name])):u.push([...a,l.name]);return u},i=this._idlIx.accounts.filter(t),s=n(i).filter(o=>!this.get(o)).map(o=>o.reduce((a,u)=>a+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(e){Object.assign(this._accounts,this.resolveOptionalsHelper(e,this._idlIx.accounts))}get(e){const t=e.reduce((n,i)=>n&&n[i],this._accounts);if(t&&t.toBase58)return t}set(e,t){let n=this._accounts;e.forEach((i,s)=>{var o;s===e.length-1&&(n[i]=t),n[i]=(o=n[i])!==null&&o!==void 0?o:{},n=n[i]})}resolveOptionalsHelper(e,t){const n={};for(const i of t){const s=i.name,o=e[s];o!==void 0&&(Zk(o)?Io(i)?n[s]=this.resolveOptionalsHelper(o,i.accounts):n[s]=Qk(o):o!==null?n[s]=xi(o):i.optional&&(n[s]=this._programId))}return n}async resolveCustom(){if(this._customResolver){const{accounts:e,resolved:t}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=e,t}return 0}resolveEventCpi(e,t=[]){for(const n in e){const i=e[n];Io(i)&&this.resolveEventCpi(i.accounts,[...t,i.name]);const s=+n+1;if(s===e.length)return;const o=e[n].name,a=e[s].name;if(o==="eventAuthority"&&a==="program"){const u=[...t,o],l=[...t,a];this.get(u)||this.set(u,me.findProgramAddressSync([Ze.from("__event_authority")],this._programId)[0]),this.get(l)||this.set(l,this._programId);return}}}resolveConst(e,t=[]){for(const n of e){const i=n.name;if(Io(n))this.resolveConst(n.accounts,[...t,i]);else{const s=n;if((s.signer||s.address)&&!this.get([...t,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([...t,i],this._provider.wallet.publicKey)}s.address&&this.set([...t,i],xi(s.address))}}}}async resolvePdasAndRelations(e,t=[]){let n=0;for(const i of e){const s=i.name;if(Io(i))n+=await this.resolvePdasAndRelations(i.accounts,[...t,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...t,s])){n++;try{if(o.pda){const a=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,t)));if(a.some(h=>!h))continue;const u=await this.parseProgramId(o,t),[l]=me.findProgramAddressSync(a,u);this.set([...t,s],l)}}catch{}try{if(o.relations){const a=this.get([...t,o.relations[0]]);if(a){const u=await this._accountStore.fetchAccount({publicKey:a});this.set([...t,s],u[s])}}}catch{}}}}return n}async parseProgramId(e,t=[]){var n;if(!(!((n=e.pda)===null||n===void 0)&&n.program))return this._programId;const i=await this.toBuffer(e.pda.program,t);if(!i)throw new Error(`Program seed not resolved: ${e.name}`);return new me(i)}async toBuffer(e,t=[]){switch(e.kind){case"const":return this.toBufferConst(e);case"arg":return await this.toBufferArg(e);case"account":return await this.toBufferAccount(e,t);default:throw new Error(`Unexpected seed: ${e}`)}}toBufferConst(e){return this.toBufferValue("bytes",e.value)}async toBufferArg(e){const[t,...n]=e.path.split("."),i=this._idlIx.args.findIndex(a=>a.name===t);if(i===-1)throw new Error(`Unable to find argument for seed: ${t}`);const s=n.reduce((a,u)=>(a??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,n);return this.toBufferValue(o,s)}async toBufferAccount(e,t=[]){const[n,...i]=e.path.split("."),s=this.get([...t,n]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!e.account)throw new Error(`Seed account is required in order to resolve type: ${e.path}`);let a=await this._accountStore.fetchAccount({publicKey:s,name:e.account}),u=i;for(;u.length>0;)a=a[u[0]],u=u.slice(1);if(a===void 0)return;const l=this.getType({defined:{name:e.account}},i);return this.toBufferValue(l,a)}toBufferValue(e,t){switch(e){case"u8":case"i8":return Ze.from([t]);case"u16":case"i16":return new vs(t).toArrayLike(Ze,"le",2);case"u32":case"i32":return new vs(t).toArrayLike(Ze,"le",4);case"u64":case"i64":return new vs(t).toArrayLike(Ze,"le",8);case"u128":case"i128":return new vs(t).toArrayLike(Ze,"le",16);case"u256":case"i256":return new vs(t).toArrayLike(Ze,"le",32);case"string":return Ze.from(t);case"pubkey":return t.toBuffer();case"bytes":return Ze.from(t);default:if(e!=null&&e.array)return Ze.from(t);throw new Error(`Unexpected seed type: ${e}`)}}getType(e,t=[]){var n;const i=(n=e==null?void 0:e.defined)===null||n===void 0?void 0:n.name;if(i){if(i==="tokenAccount")switch(t.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${t}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...a]=t,l=s.type.fields.find(h=>h.name===o);if(!l)throw new Error(`Field not found: ${o}`);return this.getType(l.type,a)}return e}}class dJ{constructor(e,t,n){this._provider=e,this._cache=new Map,this._idls={},this._idls[n.toBase58()]=t}async fetchAccount({publicKey:e,name:t}){const n=e.toBase58();if(!this._cache.has(n)){const i=await this._provider.connection.getAccountInfo(e);if(i===null)throw new Error(`Account not found: ${n}`);if(t==="tokenAccount"){const s=fJ(i.data);this._cache.set(n,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const a=o.coder.accounts.decodeAny(i.data);this._cache.set(n,a)}}}}return this._cache.get(n)}async getAccountsNs(e){const t=e.toBase58();if(!this._idls[t]){const n=await ku.fetchIdl(e,this._provider);if(n){const i=new ku(n,this._provider);this._idls[t]=i.account}}return this._idls[t]}}class pJ{static build(e,t,n,i,s,o,a,u,l,h,g){return(...b)=>new gJ(b,i,s,o,a,u,e,t,n,l,h,g)}}function Zk(r){return typeof r=="object"&&r!==null&&!("_bn"in r)}function Qk(r,e){const t={};for(const n in r){const i=r[n];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");t[n]=Zk(i)?Qk(i):xi(i)}return t}class gJ{constructor(e,t,n,i,s,o,a,u,l,h,g,b){this._args=e,this._ixFn=t,this._txFn=n,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 hJ(e,this._accounts,a,u,l,h,g,b)}args(e){this._args=e,this._accountsResolver.args(e)}accounts(e){return this.accountsPartial(e)}accountsPartial(e){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(e),this}accountsStrict(e){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(e),this}signers(e){return this._signers=this._signers.concat(e),this}remainingAccounts(e){return this._remainingAccounts=this._remainingAccounts.concat(e),this}preInstructions(e,t=!1){return t?this._preInstructions=e.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(e),this}postInstructions(e){return this._postInstructions=this._postInstructions.concat(e),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(e){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:e})}async view(e){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:e})}async rpc(e){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:e})}async rpcAndKeys(e){return{signature:await this.rpc(e),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class yJ{static build(e,t,n,i){const s=t.accounts.find(u=>u.writable),o=!!t.returns;return s||!o?void 0:async(...u)=>{let l=await n(...u);const h=`Program return: ${e} `;let g=l.raw.find(S=>S.startsWith(h));if(!g)throw new Error("View expected return log");let b=eS(g.slice(h.length)),w=t.returns;if(!w)throw new Error("View expected return type");return mt.fieldLayout({type:w},i.types).decode(b)}}}class mJ{static build(e,t,n,i,s){const o={},a={},u={},l={},h={},g={},b=pY(e),w=e.accounts?sJ.build(e,t,n,i):{};return e.instructions.forEach(I=>{const S=op.build(I,(Z,V)=>t.instruction.encode(Z,V),n),x=nJ.build(I,S),C=iJ.build(I,x,b,i),H=aJ.build(I,x,b,i,t,n,e),D=yJ.build(n,I,H,e),z=pJ.build(i,n,I,S,x,C,H,D,w,e.types||[],s==null?void 0:s(I)),W=I.name;a[W]=S,u[W]=x,o[W]=C,l[W]=H,h[W]=z,D&&(g[W]=D)}),[o,a,u,w,l,h,g]}}class ku{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(e,t=J1(),n,i){this._idl=dY(e),this._rawIdl=e,this._provider=t,this._programId=xi(e.address),this._coder=n??new Mk(this._idl),this._events=new XY(this._programId,t,this._coder);const[s,o,a,u,l,h,g]=mJ.build(this._idl,this._coder,this._programId,t,i);this.rpc=s,this.instruction=o,this.transaction=a,this.account=u,this.simulate=l,this.methods=h,this.views=g}static async at(e,t){const n=xi(e),i=await ku.fetchIdl(n,t);if(!i)throw new Error(`IDL not found for program: ${e.toString()}`);return new ku(i,t)}static async fetchIdl(e,t){t=t??J1();const n=xi(e),i=await uY(n),s=await t.connection.getAccountInfo(i);if(!s)return null;let o=hY(s.data.slice(8));const a=iY(o.data);return JSON.parse(cY(a))}addEventListener(e,t,n){return this._events.addEventListener(e,t,n)}async removeEventListener(e){return await this._events.removeEventListener(e)}}new me("11111111111111111111111111111111");const wJ="6.13.5";function bJ(r,e,t){const n=e.split("|").map(s=>s.trim());for(let s=0;s<n.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${t}`,i.value=r,i}async function mn(r){const e=Object.keys(r);return(await Promise.all(e.map(n=>Promise.resolve(r[n])))).reduce((n,i,s)=>(n[e[s]]=i,n),{})}function ze(r,e,t){for(let n in e){let i=e[n];const s=t?t[n]:null;s&&bJ(i,s,n),Object.defineProperty(r,n,{enumerable:!0,value:i,writable:!1})}}function Tu(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(Tu).join(", ")+" ]";if(r instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let n=0;n<r.length;n++)t+=e[r[n]>>4],t+=e[r[n]&15];return t}if(typeof r=="object"&&typeof r.toJSON=="function")return Tu(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const e=Object.keys(r);return e.sort(),"{ "+e.map(t=>`${Tu(t)}: ${Tu(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Qr(r,e){return r&&r.code===e}function nw(r){return Qr(r,"CALL_EXCEPTION")}function Yt(r,e,t){let n=r;{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Tu(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];s.push(o+"="+Tu(a))}}s.push(`code=${e}`),s.push(`version=${wJ}`),s.length&&(r+=" ("+s.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(r);break;default:i=new Error(r)}return ze(i,{code:e}),t&&Object.assign(i,t),i.shortMessage==null&&ze(i,{shortMessage:n}),i}function ge(r,e,t,n){if(!r)throw Yt(e,t,n)}function q(r,e,t,n){ge(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function Yk(r,e,t){t==null&&(t=""),t&&(t=": "+t),ge(r>=e,"missing argument"+t,"MISSING_ARGUMENT",{count:r,expectedCount:e}),ge(r<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((r,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(e)}catch{}return r},[]);function cp(r,e,t){if(t==null&&(t=""),r!==e){let n=t,i="new";t&&(n+=".",i+=" "+t),ge(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function Jk(r,e,t){if(r instanceof Uint8Array)return t?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let i=2;for(let s=0;s<n.length;s++)n[s]=parseInt(r.substring(i,i+2),16),i+=2;return n}q(!1,"invalid BytesLike value",e||"value",r)}function _t(r,e){return Jk(r,e,!1)}function wn(r,e){return Jk(r,e,!0)}function Gt(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&r.length!==2+2*e||e===!0&&r.length%2!==0)}function iw(r){return Gt(r,!0)||r instanceof Uint8Array}const Xk="0123456789abcdef";function Ce(r){const e=_t(r);let t="0x";for(let n=0;n<e.length;n++){const i=e[n];t+=Xk[(i&240)>>4]+Xk[i&15]}return t}function xr(r){return"0x"+r.map(e=>Ce(e).substring(2)).join("")}function Ou(r){return Gt(r,!0)?(r.length-2)/2:_t(r).length}function lr(r,e,t){const n=_t(r);return t!=null&&t>n.length&&ge(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),Ce(n.slice(e??0,t??n.length))}function eT(r,e,t){const n=_t(r);ge(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),t?i.set(n,e-n.length):i.set(n,0),Ce(i)}function Ga(r,e){return eT(r,e,!0)}function _J(r,e){return eT(r,e,!1)}const up=BigInt(0),Ri=BigInt(1),Nu=9007199254740991;function AJ(r,e){const t=lp(r,"value"),n=BigInt(at(e,"width"));if(ge(t>>n===up,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ri){const i=(Ri<<n)-Ri;return-((~t&i)+Ri)}return t}function tT(r,e){let t=Le(r,"value");const n=BigInt(at(e,"width")),i=Ri<<n-Ri;if(t<up){t=-t,ge(t<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const s=(Ri<<n)-Ri;return(~t&s)+Ri}else ge(t<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return t}function lh(r,e){const t=lp(r,"value"),n=BigInt(at(e,"bits"));return t&(Ri<<n)-Ri}function Le(r,e){switch(typeof r){case"bigint":return r;case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(t){q(!1,`invalid BigNumberish string: ${t.message}`,e||"value",r)}}q(!1,"invalid BigNumberish value",e||"value",r)}function lp(r,e){const t=Le(r,e);return ge(t>=up,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const rT="0123456789abcdef";function sw(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=rT[t>>4],e+=rT[t&15];return BigInt(e)}return Le(r)}function at(r,e){switch(typeof r){case"bigint":return q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),Number(r);case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-Nu&&r<=Nu,"overflow",e||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return at(BigInt(r),e)}catch(t){q(!1,`invalid numeric string: ${t.message}`,e||"value",r)}}q(!1,"invalid numeric value",e||"value",r)}function vJ(r){return at(sw(r))}function No(r,e){let n=lp(r,"value").toString(16);if(e==null)n.length%2&&(n="0"+n);else{const i=at(e,"width");for(ge(i*2>=n.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<i*2;)n="0"+n}return"0x"+n}function bn(r){const e=lp(r,"value");if(e===up)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const n=new Uint8Array(t.length/2);for(let i=0;i<n.length;i++){const s=i*2;n[i]=parseInt(t.substring(s,s+2),16)}return n}function Cu(r){let e=Ce(iw(r)?r:bn(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const nT="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const iT=BigInt(58);function EJ(r){const e=_t(r);let t=sw(e),n="";for(;t;)n=nT[Number(t%iT)]+n,t/=iT;for(let i=0;i<e.length&&!e[i];i++)n=nT[0]+n;return n}function xJ(r){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return _t(e)}function RJ(r){const e=_t(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}class sT{constructor(e,t,n){Q(this,"filter");Q(this,"emitter");se(this,Zu);F(this,Zu,t),ze(this,{emitter:e,filter:n})}async removeListener(){T(this,Zu)!=null&&await this.emitter.off(this.filter,T(this,Zu))}}Zu=new WeakMap;function IJ(r,e,t,n,i){q(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function oT(r,e,t,n,i){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r==="OVERRUN"?t.length-e-1:0}function SJ(r,e,t,n,i){return r==="OVERLONG"?(q(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),oT(r,e,t))}const kJ=Object.freeze({error:IJ,ignore:oT,replace:SJ});function TJ(r,e){e==null&&(e=kJ.error);const t=_t(r,"bytes"),n=[];let i=0;for(;i<t.length;){const s=t[i++];if(!(s>>7)){n.push(s);continue}let o=null,a=null;if((s&224)===192)o=1,a=127;else if((s&240)===224)o=2,a=2047;else if((s&248)===240)o=3,a=65535;else{(s&192)===128?i+=e("UNEXPECTED_CONTINUE",i-1,t,n):i+=e("BAD_PREFIX",i-1,t,n);continue}if(i-1+o>=t.length){i+=e("OVERRUN",i-1,t,n);continue}let u=s&(1<<8-o-1)-1;for(let l=0;l<o;l++){let h=t[i];if((h&192)!=128){i+=e("MISSING_CONTINUE",i,t,n),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=e("OUT_OF_RANGE",i-1-o,t,n,u);continue}if(u>=55296&&u<=57343){i+=e("UTF16_SURROGATE",i-1-o,t,n,u);continue}if(u<=a){i+=e("OVERLONG",i-1-o,t,n,u);continue}n.push(u)}}return n}function Ls(r,e){q(typeof r=="string","invalid string value","str",r);let t=[];for(let n=0;n<r.length;n++){const i=r.charCodeAt(n);if(i<128)t.push(i);else if(i<2048)t.push(i>>6|192),t.push(i&63|128);else if((i&64512)==55296){n++;const s=r.charCodeAt(n);q(n<r.length&&(s&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((i&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return new Uint8Array(t)}function OJ(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fp(r,e){return OJ(TJ(r,e))}function aT(r){async function e(t,n){ge(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const i=t.url.split(":")[0].toLowerCase();ge(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ge(i==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,a=setTimeout(()=>{s=Yt("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{s=Yt("request cancelled","CANCELLED"),o.abort()});const u={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let l;try{l=await fetch(t.url,u)}catch(w){throw clearTimeout(a),s||w}clearTimeout(a);const h={};l.headers.forEach((w,I)=>{h[I.toLowerCase()]=w});const g=await l.arrayBuffer(),b=g==null?null:new Uint8Array(g);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:b}}return e}const NJ=12,CJ=250;let cT=aT();const BJ=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),PJ=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let ow=!1;async function uT(r,e){try{const t=r.match(BJ);if(!t)throw new Error("invalid data");return new Co(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?xJ(t[3]):LJ(t[3]))}catch{return new Co(599,"BAD REQUEST (invalid data: URI)",{},null,new Us(r))}}function lT(r){async function e(t,n){try{const i=t.match(PJ);if(!i)throw new Error("invalid link");return new Us(`${r}${i[2]}`)}catch{return new Co(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Us(t))}}return e}const hp={data:uT,ipfs:lT("https://gateway.ipfs.io/ipfs/")},fT=new WeakMap;class MJ{constructor(e){se(this,ic);se(this,$o);F(this,ic,[]),F(this,$o,!1),fT.set(e,()=>{if(!T(this,$o)){F(this,$o,!0);for(const t of T(this,ic))setTimeout(()=>{t()},0);F(this,ic,[])}})}addListener(e){ge(!T(this,$o),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,ic).push(e)}get cancelled(){return T(this,$o)}checkSignal(){ge(!this.cancelled,"cancelled","CANCELLED",{})}}ic=new WeakMap,$o=new WeakMap;function dp(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}const qp=class qp{constructor(e){se(this,cc);se(this,Qu);se(this,Yu);se(this,Oi);se(this,js);se(this,Ju);se(this,Xu);se(this,Hr);se(this,qn);se(this,Ks);se(this,sc);se(this,oc);se(this,ac);se(this,as);se(this,Ni);se(this,Fo);F(this,Xu,String(e)),F(this,Qu,!1),F(this,Yu,!0),F(this,Oi,{}),F(this,js,""),F(this,Ju,3e5),F(this,Ni,{slotInterval:CJ,maxAttempts:NJ}),F(this,Fo,null)}get url(){return T(this,Xu)}set url(e){F(this,Xu,String(e))}get body(){return T(this,Hr)==null?null:new Uint8Array(T(this,Hr))}set body(e){if(e==null)F(this,Hr,void 0),F(this,qn,void 0);else if(typeof e=="string")F(this,Hr,Ls(e)),F(this,qn,"text/plain");else if(e instanceof Uint8Array)F(this,Hr,e),F(this,qn,"application/octet-stream");else if(typeof e=="object")F(this,Hr,Ls(JSON.stringify(e))),F(this,qn,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Hr)!=null}get method(){return T(this,js)?T(this,js):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),F(this,js,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,Oi));return T(this,Ks)&&(e.authorization=`Basic ${RJ(Ls(T(this,Ks)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,qn)&&(e["content-type"]=T(this,qn)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,Oi)[String(e).toLowerCase()]=String(t)}clearHeaders(){F(this,Oi,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Ks)||null}setCredentials(e,t){q(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,Ks,`${e}:${t}`)}get allowGzip(){return T(this,Yu)}set allowGzip(e){F(this,Yu,!!e)}get allowInsecureAuthentication(){return!!T(this,Qu)}set allowInsecureAuthentication(e){F(this,Qu,!!e)}get timeout(){return T(this,Ju)}set timeout(e){q(e>=0,"timeout must be non-zero","timeout",e),F(this,Ju,e)}get preflightFunc(){return T(this,sc)||null}set preflightFunc(e){F(this,sc,e)}get processFunc(){return T(this,oc)||null}set processFunc(e){F(this,oc,e)}get retryFunc(){return T(this,ac)||null}set retryFunc(e){F(this,ac,e)}get getUrlFunc(){return T(this,Fo)||cT}set getUrlFunc(e){F(this,Fo,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,Hr)?Ce(T(this,Hr)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,Ni).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,Ni).maxAttempts=e.maxAttempts)}send(){return ge(T(this,as)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),F(this,as,new MJ(this)),Ee(this,cc,_d).call(this,0,hT()+this.timeout,0,this,new Co(0,"",{},null,this))}cancel(){ge(T(this,as)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=fT.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();ge(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new qp(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,F(i,Oi,Object.assign({},T(this,Oi))),T(this,Hr)&&F(i,Hr,new Uint8Array(T(this,Hr))),F(i,qn,T(this,qn)),i}clone(){const e=new qp(this.url);return F(e,js,T(this,js)),T(this,Hr)&&F(e,Hr,T(this,Hr)),F(e,qn,T(this,qn)),F(e,Oi,Object.assign({},T(this,Oi))),F(e,Ks,T(this,Ks)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),F(e,sc,T(this,sc)),F(e,oc,T(this,oc)),F(e,ac,T(this,ac)),F(e,Ni,Object.assign({},T(this,Ni))),F(e,Fo,T(this,Fo)),e}static lockConfig(){ow=!0}static getGateway(e){return hp[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(ow)throw new Error("gateways locked");hp[e]=t}static registerGetUrl(e){if(ow)throw new Error("gateways locked");cT=e}static createGetUrlFunc(e){return aT()}static createDataGateway(){return uT}static createIpfsGatewayFunc(e){return lT(e)}};Qu=new WeakMap,Yu=new WeakMap,Oi=new WeakMap,js=new WeakMap,Ju=new WeakMap,Xu=new WeakMap,Hr=new WeakMap,qn=new WeakMap,Ks=new WeakMap,sc=new WeakMap,oc=new WeakMap,ac=new WeakMap,as=new WeakMap,Ni=new WeakMap,Fo=new WeakMap,cc=new WeakSet,_d=async function(e,t,n,i,s){var h,g,b;if(e>=T(this,Ni).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ge(hT()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),n>0&&await UJ(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in hp){const w=await hp[a](o.url,dp(T(i,as)));if(w instanceof Co){let I=w;if(this.processFunc){dp(T(i,as));try{I=await this.processFunc(o,I)}catch(S){(S.throttle==null||typeof S.stall!="number")&&I.makeServerError("error in post-processing function",S).assertOk()}}return I}o=w}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,dp(T(i,as)));let l=new Co(u.statusCode,u.statusMessage,u.headers,u.body,i);if(l.statusCode===301||l.statusCode===302){try{const w=l.headers.location||"";return Ee(h=o.redirect(w),cc,_d).call(h,e+1,t,0,i,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,l,e))){const w=l.headers["retry-after"];let I=T(this,Ni).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof w=="string"&&w.match(/^[1-9][0-9]*$/)&&(I=parseInt(w)),Ee(g=o.clone(),cc,_d).call(g,e+1,t,I,i,l)}if(this.processFunc){dp(T(i,as));try{l=await this.processFunc(o,l)}catch(w){(w.throttle==null||typeof w.stall!="number")&&l.makeServerError("error in post-processing function",w).assertOk();let I=T(this,Ni).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return w.stall>=0&&(I=w.stall),Ee(b=o.clone(),cc,_d).call(b,e+1,t,I,i,l)}}return l};let Us=qp;const gb=class gb{constructor(e,t,n,i,s){se(this,Nh);se(this,Ch);se(this,Bh);se(this,Zn);se(this,el);se(this,uc);F(this,Nh,e),F(this,Ch,t),F(this,Bh,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),F(this,Zn,i==null?null:new Uint8Array(i)),F(this,el,s||null),F(this,uc,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,Zn)?Ce(T(this,Zn)):"null"}>`}get statusCode(){return T(this,Nh)}get statusMessage(){return T(this,Ch)}get headers(){return Object.assign({},T(this,Bh))}get body(){return T(this,Zn)==null?null:new Uint8Array(T(this,Zn))}get bodyText(){try{return T(this,Zn)==null?"":fp(T(this,Zn))}catch{ge(!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{ge(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const i=new gb(599,n,this.headers,this.body,T(this,el)||void 0);return F(i,uc,{message:e,error:t}),i}throwThrottleError(e,t){t==null?t=-1:q(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw ze(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,Zn)!=null}get request(){return T(this,el)}ok(){return T(this,uc).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,uc);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let i=null;try{T(this,Zn)&&(i=fp(T(this,Zn)))}catch{}ge(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Nh=new WeakMap,Ch=new WeakMap,Bh=new WeakMap,Zn=new WeakMap,el=new WeakMap,uc=new WeakMap;let Co=gb;function hT(){return new Date().getTime()}function LJ(r){return Ls(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function UJ(r){return new Promise(e=>setTimeout(e,r))}function DJ(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function dT(r,e,t){let n=0;for(let i=0;i<t;i++)n=n*256+r[e+i];return n}function pT(r,e,t,n){const i=[];for(;t<e+1+n;){const s=gT(r,t);i.push(s.result),t+=s.consumed,ge(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:r,length:n,offset:e})}return{consumed:1+n,result:i}}function gT(r,e){ge(r.length!==0,"data too short","BUFFER_OVERRUN",{buffer:r,length:0,offset:1});const t=n=>{ge(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[e]>=248){const n=r[e]-247;t(e+1+n);const i=dT(r,e+1,n);return t(e+1+n+i),pT(r,e,e+1+n,n+i)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),pT(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const i=dT(r,e+1,n);t(e+1+n+i);const s=Ce(r.slice(e+1+n,e+1+n+i));return{consumed:1+n+i,result:s}}else if(r[e]>=128){const n=r[e]-128;t(e+1+n);const i=Ce(r.slice(e+1,e+1+n));return{consumed:1+n,result:i}}return{consumed:1,result:DJ(r[e])}}function pp(r){const e=_t(r,"data"),t=gT(e,0);return q(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function yT(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function mT(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(s){n=n.concat(mT(s))}),n.length<=55)return n.unshift(192+n.length),n;const i=yT(n.length);return i.unshift(247+i.length),i.concat(n)}const e=Array.prototype.slice.call(_t(r,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=yT(e.length);return t.unshift(183+t.length),t.concat(e)}const wT="0123456789abcdef";function Va(r){let e="0x";for(const t of mT(r))e+=wT[t>>4],e+=wT[t&15];return e}const _n=32,aw=new Uint8Array(_n),$J=["then"],gp={},bT=new WeakMap;function ja(r){return bT.get(r)}function _T(r,e){bT.set(r,e)}function fh(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function cw(r,e,t){return r.indexOf(null)>=0?e.map((n,i)=>n instanceof Bu?cw(ja(n),n,t):n):r.reduce((n,i,s)=>{let o=e.getValue(i);return i in n||(t&&o instanceof Bu&&(o=cw(ja(o),o,t)),n[i]=o),n},{})}const rl=class rl extends Array{constructor(...t){const n=t[0];let i=t[1],s=(t[2]||[]).slice(),o=!0;n!==gp&&(i=t,s=[],o=!1);super(i.length);se(this,tl);i.forEach((l,h)=>{this[h]=l});const a=s.reduce((l,h)=>(typeof h=="string"&&l.set(h,(l.get(h)||0)+1),l),new Map);if(_T(this,Object.freeze(i.map((l,h)=>{const g=s[h];return g!=null&&a.get(g)===1?g:null}))),F(this,tl,[]),T(this,tl)==null&&T(this,tl),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(l,h,g)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const w=at(h,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const I=l[w];return I instanceof Error&&fh(`index ${w}`,I),I}if($J.indexOf(h)>=0)return Reflect.get(l,h,g);const b=l[h];if(b instanceof Function)return function(...w){return b.apply(this===g?l:this,w)};if(!(h in l))return l.getValue.apply(this===g?l:this,[h])}return Reflect.get(l,h,g)}});return _T(u,ja(this)),u}toArray(t){const n=[];return this.forEach((i,s)=>{i instanceof Error&&fh(`index ${s}`,i),t&&i instanceof rl&&(i=i.toArray(t)),n.push(i)}),n}toObject(t){const n=ja(this);return n.reduce((i,s,o)=>(ge(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),cw(n,this,t)),{})}slice(t,n){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const i=ja(this),s=[],o=[];for(let a=t;a<n;a++)s.push(this[a]),o.push(i[a]);return new rl(gp,s,o)}filter(t,n){const i=ja(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&fh(`index ${a}`,u),t.call(n,u,a,this)&&(s.push(u),o.push(i[a]))}return new rl(gp,s,o)}map(t,n){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&fh(`index ${s}`,o),i.push(t.call(n,o,s,this))}return i}getValue(t){const n=ja(this).indexOf(t);if(n===-1)return;const i=this[n];return i instanceof Error&&fh(`property ${JSON.stringify(t)}`,i.error),i}static fromItems(t,n){return new rl(gp,t,n)}};tl=new WeakMap;let Bu=rl;function AT(r){let e=bn(r);return ge(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=wn(xr([aw.slice(e.length%_n),e]))),e}class Ds{constructor(e,t,n,i){Q(this,"name");Q(this,"type");Q(this,"localName");Q(this,"dynamic");ze(this,{name:e,type:t,localName:n,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){q(!1,e,this.localName,t)}}class uw{constructor(){se(this,nl);se(this,Ws);se(this,lc);F(this,Ws,[]),F(this,lc,0)}get data(){return xr(T(this,Ws))}get length(){return T(this,lc)}appendWriter(e){return Ee(this,nl,yg).call(this,wn(e.data))}writeBytes(e){let t=wn(e);const n=t.length%_n;return n&&(t=wn(xr([t,aw.slice(n)]))),Ee(this,nl,yg).call(this,t)}writeValue(e){return Ee(this,nl,yg).call(this,AT(e))}writeUpdatableValue(){const e=T(this,Ws).length;return T(this,Ws).push(aw),F(this,lc,T(this,lc)+_n),t=>{T(this,Ws)[e]=AT(t)}}}Ws=new WeakMap,lc=new WeakMap,nl=new WeakSet,yg=function(e){return T(this,Ws).push(e),F(this,lc,T(this,lc)+e.length),e.length};const yb=class yb{constructor(e,t,n){se(this,dc);Q(this,"allowLoose");se(this,Un);se(this,Qn);se(this,fc);se(this,hc);se(this,Ho);ze(this,{allowLoose:!!t}),F(this,Un,wn(e)),F(this,fc,0),F(this,hc,null),F(this,Ho,n??1024),F(this,Qn,0)}get data(){return Ce(T(this,Un))}get dataLength(){return T(this,Un).length}get consumed(){return T(this,Qn)}get bytes(){return new Uint8Array(T(this,Un))}subReader(e){const t=new yb(T(this,Un).slice(T(this,Qn)+e),this.allowLoose,T(this,Ho));return F(t,hc,this),t}readBytes(e,t){let n=Ee(this,dc,f6).call(this,0,e,!!t);return Ee(this,dc,U_).call(this,e),F(this,Qn,T(this,Qn)+n.length),n.slice(0,e)}readValue(){return sw(this.readBytes(_n))}readIndex(){return vJ(this.readBytes(_n))}};Un=new WeakMap,Qn=new WeakMap,fc=new WeakMap,hc=new WeakMap,Ho=new WeakMap,dc=new WeakSet,U_=function(e){var t;if(T(this,hc))return Ee(t=T(this,hc),dc,U_).call(t,e);F(this,fc,T(this,fc)+e),ge(T(this,Ho)<1||T(this,fc)<=T(this,Ho)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Ho)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:wn(T(this,Un)),offset:T(this,Qn),length:e,info:{bytesRead:T(this,fc),dataLength:this.dataLength}})},f6=function(e,t,n){let i=Math.ceil(t/_n)*_n;return T(this,Qn)+i>T(this,Un).length&&(this.allowLoose&&n&&T(this,Qn)+t<=T(this,Un).length?i=t:ge(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:wn(T(this,Un)),length:T(this,Un).length,offset:T(this,Qn)+i})),T(this,Un).slice(T(this,Qn),T(this,Qn)+i)};let lw=yb;function yp(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function fw(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function FJ(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");yp(r.outputLen),yp(r.blockLen)}function Pu(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function vT(r,e){fw(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const hw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ET=r=>r instanceof Uint8Array,HJ=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),dw=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ns=(r,e)=>r<<32-e|r>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function zJ(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function mp(r){if(typeof r=="string"&&(r=zJ(r)),!ET(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function GJ(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!ET(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class pw{clone(){return this._cloneInto()}}function gw(r){const e=n=>r().update(mp(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function VJ(r=32){if(hw&&typeof hw.getRandomValues=="function")return hw.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class xT extends pw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,FJ(e);const n=mp(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Pu(this),this.iHash.update(e),this}digestInto(e){Pu(this),fw(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const RT=(r,e,t)=>new xT(r,e).update(t).digest();RT.create=(r,e)=>new xT(r,e);function jJ(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}class IT extends pw{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=dw(this.buffer)}update(e){Pu(this);const{view:t,buffer:n,blockLen:i}=this;e=mp(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=dw(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pu(this),vT(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;jJ(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=dw(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const KJ=(r,e,t)=>r&e^~r&t,WJ=(r,e,t)=>r&e^r&t^e&t,qJ=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]),Bo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Po=new Uint32Array(64);class ZJ extends IT{constructor(){super(64,32,8,!1),this.A=Bo[0]|0,this.B=Bo[1]|0,this.C=Bo[2]|0,this.D=Bo[3]|0,this.E=Bo[4]|0,this.F=Bo[5]|0,this.G=Bo[6]|0,this.H=Bo[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)Po[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=Po[g-15],w=Po[g-2],I=ns(b,7)^ns(b,18)^b>>>3,S=ns(w,17)^ns(w,19)^w>>>10;Po[g]=S+Po[g-7]+I+Po[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=ns(a,6)^ns(a,11)^ns(a,25),w=h+b+KJ(a,u,l)+qJ[g]+Po[g]|0,S=(ns(n,2)^ns(n,13)^ns(n,22))+WJ(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){Po.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ST=gw(()=>new ZJ),wp=BigInt(2**32-1),yw=BigInt(32);function kT(r,e=!1){return e?{h:Number(r&wp),l:Number(r>>yw&wp)}:{h:Number(r>>yw&wp)|0,l:Number(r&wp)|0}}function TT(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=kT(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const QJ=(r,e)=>BigInt(r>>>0)<<yw|BigInt(e>>>0),YJ=(r,e,t)=>r>>>t,JJ=(r,e,t)=>r<<32-t|e>>>t,XJ=(r,e,t)=>r>>>t|e<<32-t,eX=(r,e,t)=>r<<32-t|e>>>t,tX=(r,e,t)=>r<<64-t|e>>>t-32,rX=(r,e,t)=>r>>>t-32|e<<64-t,nX=(r,e)=>e,iX=(r,e)=>r,OT=(r,e,t)=>r<<t|e>>>32-t,NT=(r,e,t)=>e<<t|r>>>32-t,CT=(r,e,t)=>e<<t-32|r>>>64-t,BT=(r,e,t)=>r<<t-32|e>>>64-t;function sX(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const st={fromBig:kT,split:TT,toBig:QJ,shrSH:YJ,shrSL:JJ,rotrSH:XJ,rotrSL:eX,rotrBH:tX,rotrBL:rX,rotr32H:nX,rotr32L:iX,rotlSH:OT,rotlSL:NT,rotlBH:CT,rotlBL:BT,add:sX,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,add5H:(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,add5L:(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0)},[oX,aX]=st.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(r=>BigInt(r))),Mo=new Uint32Array(80),Lo=new Uint32Array(80);class cX extends IT{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)Mo[D]=e.getUint32(t),Lo[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=Mo[D-15]|0,W=Lo[D-15]|0,Z=st.rotrSH(z,W,1)^st.rotrSH(z,W,8)^st.shrSH(z,W,7),V=st.rotrSL(z,W,1)^st.rotrSL(z,W,8)^st.shrSL(z,W,7),K=Mo[D-2]|0,oe=Lo[D-2]|0,ce=st.rotrSH(K,oe,19)^st.rotrBH(K,oe,61)^st.shrSH(K,oe,6),ie=st.rotrSL(K,oe,19)^st.rotrBL(K,oe,61)^st.shrSL(K,oe,6),ue=st.add4L(V,ie,Lo[D-7],Lo[D-16]),B=st.add4H(ue,Z,ce,Mo[D-7],Mo[D-16]);Mo[D]=B|0,Lo[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=st.rotrSH(g,b,14)^st.rotrSH(g,b,18)^st.rotrBH(g,b,41),W=st.rotrSL(g,b,14)^st.rotrSL(g,b,18)^st.rotrBL(g,b,41),Z=g&w^~g&S,V=b&I^~b&x,K=st.add5L(H,W,V,aX[D],Lo[D]),oe=st.add5H(K,C,z,Z,oX[D],Mo[D]),ce=K|0,ie=st.rotrSH(n,i,28)^st.rotrBH(n,i,34)^st.rotrBH(n,i,39),ue=st.rotrSL(n,i,28)^st.rotrBL(n,i,34)^st.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=st.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=st.add3L(ce,ue,p);n=st.add3H(m,oe,ie,B),i=m|0}({h:n,l:i}=st.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=st.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=st.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=st.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=st.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=st.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=st.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=st.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){Mo.fill(0),Lo.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 uX=gw(()=>new cX);function lX(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof qc<"u")return qc;throw new Error("unable to locate global object")}const PT=lX();PT.crypto||PT.msCrypto;function fX(r){switch(r){case"sha256":return ST.create();case"sha512":return uX.create()}q(!1,"invalid hashing algorithm name","algorithm",r)}const[MT,LT,UT]=[[],[],[]],hX=BigInt(0),hh=BigInt(1),dX=BigInt(2),pX=BigInt(7),gX=BigInt(256),yX=BigInt(113);for(let r=0,e=hh,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],MT.push(2*(5*n+t)),LT.push((r+1)*(r+2)/2%64);let i=hX;for(let s=0;s<7;s++)e=(e<<hh^(e>>pX)*yX)%gX,e&dX&&(i^=hh<<(hh<<BigInt(s))-hh);UT.push(i)}const[mX,wX]=TT(UT,!0),DT=(r,e,t)=>t>32?CT(r,e,t):OT(r,e,t),$T=(r,e,t)=>t>32?BT(r,e,t):NT(r,e,t);function bX(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=DT(l,h,1)^t[a],b=$T(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=LT[o],u=DT(i,s,a),l=$T(i,s,a),h=MT[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=mX[n],r[1]^=wX[n]}t.fill(0)}class mw extends pw{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,yp(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=HJ(this.state)}keccak(){bX(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Pu(this);const{blockLen:t,state:n}=this;e=mp(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Pu(this,!1),fw(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return yp(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vT(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new mw(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const _X=((r,e,t)=>gw(()=>new mw(e,r,t)))(1,136,256/8);let FT=!1;const HT=function(r){return _X(r)};let zT=HT;function Nr(r){const e=_t(r,"data");return Ce(zT(e))}Nr._=HT,Nr.lock=function(){FT=!0},Nr.register=function(r){if(FT)throw new TypeError("keccak256 is locked");zT=r},Object.freeze(Nr);const GT=function(r){return fX("sha256").update(r).digest()};let VT=GT,jT=!1;function Mu(r){const e=_t(r,"data");return Ce(VT(e))}Mu._=GT,Mu.lock=function(){jT=!0},Mu.register=function(r){if(jT)throw new Error("sha256 is locked");VT=r},Object.freeze(Mu),Object.freeze(Mu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const KT=BigInt(0),bp=BigInt(1),AX=BigInt(2),_p=r=>r instanceof Uint8Array,vX=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Lu(r){if(!_p(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=vX[r[t]];return e}function WT(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function ww(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Uu(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const i=n*2,s=r.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[n]=o}return t}function Ka(r){return ww(Lu(r))}function bw(r){if(!_p(r))throw new Error("Uint8Array expected");return ww(Lu(Uint8Array.from(r).reverse()))}function Du(r,e){return Uu(r.toString(16).padStart(e*2,"0"))}function _w(r,e){return Du(r,e).reverse()}function EX(r){return Uu(WT(r))}function Ii(r,e,t){let n;if(typeof e=="string")try{n=Uu(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(_p(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function dh(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!_p(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function xX(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function RX(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function IX(r){let e;for(e=0;r>KT;r>>=bp,e+=1);return e}function SX(r,e){return r>>BigInt(e)&bp}const kX=(r,e,t)=>r|(t?bp:KT)<<BigInt(e),Aw=r=>(AX<<BigInt(r-1))-bp,vw=r=>new Uint8Array(r),qT=r=>Uint8Array.from(r);function ZT(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=vw(r),i=vw(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=vw())=>{i=a(qT([0]),g),n=a(),g.length!==0&&(i=a(qT([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return dh(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const TX={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ph(r,e,t={}){const n=(i,s,o)=>{const a=TX[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const OX=Object.freeze(Object.defineProperty({__proto__:null,bitGet:SX,bitLen:IX,bitMask:Aw,bitSet:kX,bytesToHex:Lu,bytesToNumberBE:Ka,bytesToNumberLE:bw,concatBytes:dh,createHmacDrbg:ZT,ensureBytes:Ii,equalBytes:xX,hexToBytes:Uu,hexToNumber:ww,numberToBytesBE:Du,numberToBytesLE:_w,numberToHexUnpadded:WT,numberToVarBytesBE:EX,utf8ToBytes:RX,validateObject:ph},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),Rr=BigInt(1),Wa=BigInt(2),NX=BigInt(3),Ew=BigInt(4),QT=BigInt(5),YT=BigInt(8);BigInt(9),BigInt(16);function Pn(r,e){const t=r%e;return t>=$r?t:e+t}function CX(r,e,t){if(t<=$r||e<$r)throw new Error("Expected power/modulo > 0");if(t===Rr)return $r;let n=Rr;for(;e>$r;)e&Rr&&(n=n*r%t),r=r*r%t,e>>=Rr;return n}function ci(r,e,t){let n=r;for(;e-- >$r;)n*=n,n%=t;return n}function xw(r,e){if(r===$r||e<=$r)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Pn(r,e),n=e,i=$r,s=Rr;for(;t!==$r;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==Rr)throw new Error("invert: does not exist");return Pn(i,e)}function BX(r){const e=(r-Rr)/Wa;let t,n,i;for(t=r-Rr,n=0;t%Wa===$r;t/=Wa,n++);for(i=Wa;i<r&&CX(i,e,r)!==r-Rr;i++);if(n===1){const o=(r+Rr)/Ew;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+Rr)/Wa;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,Rr<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function PX(r){if(r%Ew===NX){const e=(r+Rr)/Ew;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%YT===QT){const e=(r-QT)/YT;return function(n,i){const s=n.mul(i,Wa),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,Wa),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return BX(r)}const MX=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function LX(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=MX.reduce((n,i)=>(n[i]="function",n),e);return ph(r,t)}function UX(r,e,t){if(t<$r)throw new Error("Expected power > 0");if(t===$r)return r.ONE;if(t===Rr)return e;let n=r.ONE,i=e;for(;t>$r;)t&Rr&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Rr;return n}function DX(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function JT(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function $X(r,e,t=!1,n={}){if(r<=$r)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:i,nByteLength:s}=JT(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=PX(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Aw(i),ZERO:$r,ONE:Rr,create:u=>Pn(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return $r<=u&&u<r},is0:u=>u===$r,isOdd:u=>(u&Rr)===Rr,neg:u=>Pn(-u,r),eql:(u,l)=>u===l,sqr:u=>Pn(u*u,r),add:(u,l)=>Pn(u+l,r),sub:(u,l)=>Pn(u-l,r),mul:(u,l)=>Pn(u*l,r),pow:(u,l)=>UX(a,u,l),div:(u,l)=>Pn(u*xw(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>xw(u,r),sqrt:n.sqrt||(u=>o(a,u)),invertBatch:u=>DX(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?_w(u,s):Du(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return t?bw(u):Ka(u)}});return Object.freeze(a)}function XT(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function eO(r){const e=XT(r);return e+Math.ceil(e/2)}function FX(r,e,t=!1){const n=r.length,i=XT(e),s=eO(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=t?Ka(r):bw(r),a=Pn(o,e-Rr)+Rr;return t?_w(a,i):Du(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const HX=BigInt(0),Rw=BigInt(1);function zX(r,e){const t=(i,s)=>{const o=s.negate();return i?o:s},n=i=>{const s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:t,unsafeLadder(i,s){let o=r.ZERO,a=i;for(;s>HX;)s&Rw&&(o=o.add(a)),a=a.double(),s>>=Rw;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=n(s),u=[];let l=i,h=l;for(let g=0;g<o;g++){h=l,u.push(h);for(let b=1;b<a;b++)h=h.add(l),u.push(h);l=h.double()}return u},wNAF(i,s,o){const{windows:a,windowSize:u}=n(i);let l=r.ZERO,h=r.BASE;const g=BigInt(2**i-1),b=2**i,w=BigInt(i);for(let I=0;I<a;I++){const S=I*u;let x=Number(o&g);o>>=w,x>u&&(x-=b,o+=Rw);const C=S,H=S+Math.abs(x)-1,D=I%2!==0,z=x<0;x===0?h=h.add(t(D,s[C])):l=l.add(t(z,s[H]))}return{p:l,f:h}},wNAFCached(i,s,o,a){const u=i._WINDOW_SIZE||1;let l=s.get(i);return l||(l=this.precomputeWindow(i,u),u!==1&&s.set(i,a(l))),this.wNAF(u,l,o)}}}function tO(r){return LX(r.Fp),ph(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...JT(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function GX(r){const e=tO(r);ph(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:VX,hexToBytes:jX}=OX,qa={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=qa;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:VX(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=qa,t=typeof r=="string"?jX(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=qa._parseInt(t.subarray(2)),{d:o,l:a}=qa._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(r){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(r.s)),i=e(t(r.r)),s=n.length/2,o=i.length/2,a=t(s),u=t(o);return`30${t(o+s+4)}02${u}${i}02${a}${n}`}},$s=BigInt(0),ui=BigInt(1);BigInt(2);const rO=BigInt(3);BigInt(4);function KX(r){const e=GX(r),{Fp:t}=e,n=e.toBytes||((I,S,x)=>{const C=S.toAffine();return dh(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(I=>{const S=I.subarray(1),x=t.fromBytes(S.subarray(0,t.BYTES)),C=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x,y:C}});function s(I){const{a:S,b:x}=e,C=t.sqr(I),H=t.mul(C,I);return t.add(t.add(H,t.mul(I,S)),x)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(I){return typeof I=="bigint"&&$s<I&&I<e.n}function a(I){if(!o(I))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(I){const{allowedPrivateKeyLengths:S,nByteLength:x,wrapPrivateKey:C,n:H}=e;if(S&&typeof I!="bigint"){if(I instanceof Uint8Array&&(I=Lu(I)),typeof I!="string"||!S.includes(I.length))throw new Error("Invalid key");I=I.padStart(x*2,"0")}let D;try{D=typeof I=="bigint"?I:Ka(Ii("private key",I,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof I}`)}return C&&(D=Pn(D,H)),a(D),D}const l=new Map;function h(I){if(!(I instanceof g))throw new Error("ProjectivePoint expected")}class g{constructor(S,x,C){if(this.px=S,this.py=x,this.pz=C,S==null||!t.isValid(S))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required")}static fromAffine(S){const{x,y:C}=S||{};if(!S||!t.isValid(x)||!t.isValid(C))throw new Error("invalid affine point");if(S instanceof g)throw new Error("projective point not allowed");const H=D=>t.eql(D,t.ZERO);return H(x)&&H(C)?g.ZERO:new g(x,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const x=t.invertBatch(S.map(C=>C.pz));return S.map((C,H)=>C.toAffine(x[H])).map(g.fromAffine)}static fromHex(S){const x=g.fromAffine(i(Ii("pointHex",S)));return x.assertValidity(),x}static fromPrivateKey(S){return g.BASE.multiply(u(S))}_setWindowSize(S){this._WINDOW_SIZE=S,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:S,y:x}=this.toAffine();if(!t.isValid(S)||!t.isValid(x))throw new Error("bad point: x or y not FE");const C=t.sqr(x),H=s(S);if(!t.eql(C,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:S}=this.toAffine();if(t.isOdd)return!t.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:W}=S,Z=t.eql(t.mul(x,W),t.mul(D,H)),V=t.eql(t.mul(C,W),t.mul(z,H));return Z&&V}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:S,b:x}=e,C=t.mul(x,rO),{px:H,py:D,pz:z}=this;let W=t.ZERO,Z=t.ZERO,V=t.ZERO,K=t.mul(H,H),oe=t.mul(D,D),ce=t.mul(z,z),ie=t.mul(H,D);return ie=t.add(ie,ie),V=t.mul(H,z),V=t.add(V,V),W=t.mul(S,V),Z=t.mul(C,ce),Z=t.add(W,Z),W=t.sub(oe,Z),Z=t.add(oe,Z),Z=t.mul(W,Z),W=t.mul(ie,W),V=t.mul(C,V),ce=t.mul(S,ce),ie=t.sub(K,ce),ie=t.mul(S,ie),ie=t.add(ie,V),V=t.add(K,K),K=t.add(V,K),K=t.add(K,ce),K=t.mul(K,ie),Z=t.add(Z,K),ce=t.mul(D,z),ce=t.add(ce,ce),K=t.mul(ce,ie),W=t.sub(W,K),V=t.mul(ce,oe),V=t.add(V,V),V=t.add(V,V),new g(W,Z,V)}add(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:W}=S;let Z=t.ZERO,V=t.ZERO,K=t.ZERO;const oe=e.a,ce=t.mul(e.b,rO);let ie=t.mul(x,D),ue=t.mul(C,z),B=t.mul(H,W),p=t.add(x,C),m=t.add(D,z);p=t.mul(p,m),m=t.add(ie,ue),p=t.sub(p,m),m=t.add(x,H);let E=t.add(D,W);return m=t.mul(m,E),E=t.add(ie,B),m=t.sub(m,E),E=t.add(C,H),Z=t.add(z,W),E=t.mul(E,Z),Z=t.add(ue,B),E=t.sub(E,Z),K=t.mul(oe,m),Z=t.mul(ce,B),K=t.add(Z,K),Z=t.sub(ue,K),K=t.add(ue,K),V=t.mul(Z,K),ue=t.add(ie,ie),ue=t.add(ue,ie),B=t.mul(oe,B),m=t.mul(ce,m),ue=t.add(ue,B),B=t.sub(ie,B),B=t.mul(oe,B),m=t.add(m,B),ie=t.mul(ue,m),V=t.add(V,ie),ie=t.mul(E,m),Z=t.mul(p,Z),Z=t.sub(Z,ie),ie=t.mul(p,ue),K=t.mul(E,K),K=t.add(K,ie),new g(Z,V,K)}subtract(S){return this.add(S.negate())}is0(){return this.equals(g.ZERO)}wNAF(S){return w.wNAFCached(this,l,S,x=>{const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(g.fromAffine)})}multiplyUnsafe(S){const x=g.ZERO;if(S===$s)return x;if(a(S),S===ui)return this;const{endo:C}=e;if(!C)return w.unsafeLadder(this,S);let{k1neg:H,k1:D,k2neg:z,k2:W}=C.splitScalar(S),Z=x,V=x,K=this;for(;D>$s||W>$s;)D&ui&&(Z=Z.add(K)),W&ui&&(V=V.add(K)),K=K.double(),D>>=ui,W>>=ui;return H&&(Z=Z.negate()),z&&(V=V.negate()),V=new g(t.mul(V.px,C.beta),V.py,V.pz),Z.add(V)}multiply(S){a(S);let x=S,C,H;const{endo:D}=e;if(D){const{k1neg:z,k1:W,k2neg:Z,k2:V}=D.splitScalar(x);let{p:K,f:oe}=this.wNAF(W),{p:ce,f:ie}=this.wNAF(V);K=w.constTimeNegate(z,K),ce=w.constTimeNegate(Z,ce),ce=new g(t.mul(ce.px,D.beta),ce.py,ce.pz),C=K.add(ce),H=oe.add(ie)}else{const{p:z,f:W}=this.wNAF(x);C=z,H=W}return g.normalizeZ([C,H])[0]}multiplyAndAddUnsafe(S,x,C){const H=g.BASE,D=(W,Z)=>Z===$s||Z===ui||!W.equals(H)?W.multiplyUnsafe(Z):W.multiply(Z),z=D(this,x).add(D(S,C));return z.is0()?void 0:z}toAffine(S){const{px:x,py:C,pz:H}=this,D=this.is0();S==null&&(S=D?t.ONE:t.inv(H));const z=t.mul(x,S),W=t.mul(C,S),Z=t.mul(H,S);if(D)return{x:t.ZERO,y:t.ZERO};if(!t.eql(Z,t.ONE))throw new Error("invZ was invalid");return{x:z,y:W}}isTorsionFree(){const{h:S,isTorsionFree:x}=e;if(S===ui)return!0;if(x)return x(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:x}=e;return S===ui?this:x?x(g,this):this.multiplyUnsafe(e.h)}toRawBytes(S=!0){return this.assertValidity(),n(g,this,S)}toHex(S=!0){return Lu(this.toRawBytes(S))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const b=e.nBitLength,w=zX(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function WX(r){const e=tO(r);return ph(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function qX(r){const e=WX(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(m){return $s<m&&m<t.ORDER}function a(m){return Pn(m,n)}function u(m){return xw(m,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:g,isWithinCurveOrder:b}=KX({...e,toBytes(m,E,k){const O=E.toAffine(),M=t.toBytes(O.x),G=dh;return k?G(Uint8Array.from([E.hasEvenY()?2:3]),M):G(Uint8Array.from([4]),M,t.toBytes(O.y))},fromBytes(m){const E=m.length,k=m[0],O=m.subarray(1);if(E===i&&(k===2||k===3)){const M=Ka(O);if(!o(M))throw new Error("Point is not on curve");const G=g(M);let P=t.sqrt(G);const A=(P&ui)===ui;return(k&1)===1!==A&&(P=t.neg(P)),{x:M,y:P}}else if(E===s&&k===4){const M=t.fromBytes(O.subarray(0,t.BYTES)),G=t.fromBytes(O.subarray(t.BYTES,2*t.BYTES));return{x:M,y:G}}else throw new Error(`Point of length ${E} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=m=>Lu(Du(m,e.nByteLength));function I(m){const E=n>>ui;return m>E}function S(m){return I(m)?a(-m):m}const x=(m,E,k)=>Ka(m.slice(E,k));class C{constructor(E,k,O){this.r=E,this.s=k,this.recovery=O,this.assertValidity()}static fromCompact(E){const k=e.nByteLength;return E=Ii("compactSignature",E,k*2),new C(x(E,0,k),x(E,k,2*k))}static fromDER(E){const{r:k,s:O}=qa.toSig(Ii("DER",E));return new C(k,O)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new C(this.r,this.s,E)}recoverPublicKey(E){const{r:k,s:O,recovery:M}=this,G=V(Ii("msgHash",E));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?k+e.n:k;if(P>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=M&1?"03":"02",U=l.fromHex(A+w(P)),le=u(P),te=a(-G*le),re=a(O*le),he=l.BASE.multiplyAndAddUnsafe(U,te,re);if(!he)throw new Error("point at infinify");return he.assertValidity(),he}hasHighS(){return I(this.s)}normalizeS(){return this.hasHighS()?new C(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Uu(this.toDERHex())}toDERHex(){return qa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Uu(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=eO(e.n);return FX(e.randomBytes(m),e.n)},precompute(m=8,E=l.BASE){return E._setWindowSize(m),E.multiply(BigInt(3)),E}};function D(m,E=!0){return l.fromPrivateKey(m).toRawBytes(E)}function z(m){const E=m instanceof Uint8Array,k=typeof m=="string",O=(E||k)&&m.length;return E?O===i||O===s:k?O===2*i||O===2*s:m instanceof l}function W(m,E,k=!0){if(z(m))throw new Error("first arg must be private key");if(!z(E))throw new Error("second arg must be public key");return l.fromHex(E).multiply(h(m)).toRawBytes(k)}const Z=e.bits2int||function(m){const E=Ka(m),k=m.length*8-e.nBitLength;return k>0?E>>BigInt(k):E},V=e.bits2int_modN||function(m){return a(Z(m))},K=Aw(e.nBitLength);function oe(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!($s<=m&&m<K))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Du(m,e.nByteLength)}function ce(m,E,k=ie){if(["recovered","canonical"].some(be=>be in k))throw new Error("sign() legacy options not supported");const{hash:O,randomBytes:M}=e;let{lowS:G,prehash:P,extraEntropy:A}=k;G==null&&(G=!0),m=Ii("msgHash",m),P&&(m=Ii("prehashed msgHash",O(m)));const U=V(m),le=h(E),te=[oe(le),oe(U)];if(A!=null){const be=A===!0?M(t.BYTES):A;te.push(Ii("extraEntropy",be))}const re=dh(...te),he=U;function ye(be){const Ke=Z(be);if(!b(Ke))return;const Fe=u(Ke),Be=l.BASE.multiply(Ke).toAffine(),et=a(Be.x);if(et===$s)return;const Qe=a(Fe*a(he+et*le));if(Qe===$s)return;let ot=(Be.x===et?0:2)|Number(Be.y&ui),sr=Qe;return G&&I(Qe)&&(sr=S(Qe),ot^=1),new C(et,sr,ot)}return{seed:re,k2sig:ye}}const ie={lowS:e.lowS,prehash:!1},ue={lowS:e.lowS,prehash:!1};function B(m,E,k=ie){const{seed:O,k2sig:M}=ce(m,E,k),G=e;return ZT(G.hash.outputLen,G.nByteLength,G.hmac)(O,M)}l.BASE._setWindowSize(8);function p(m,E,k,O=ue){var Be;const M=m;if(E=Ii("msgHash",E),k=Ii("publicKey",k),"strict"in O)throw new Error("options.strict was renamed to lowS");const{lowS:G,prehash:P}=O;let A,U;try{if(typeof M=="string"||M instanceof Uint8Array)try{A=C.fromDER(M)}catch(et){if(!(et instanceof qa.Err))throw et;A=C.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:et,s:Qe}=M;A=new C(et,Qe)}else throw new Error("PARSE");U=l.fromHex(k)}catch(et){if(et.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(G&&A.hasHighS())return!1;P&&(E=e.hash(E));const{r:le,s:te}=A,re=V(E),he=u(te),ye=a(re*he),be=a(le*he),Ke=(Be=l.BASE.multiplyAndAddUnsafe(U,ye,be))==null?void 0:Be.toAffine();return Ke?a(Ke.x)===le:!1}return{CURVE:e,getPublicKey:D,getSharedSecret:W,sign:B,verify:p,ProjectivePoint:l,Signature:C,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ZX(r){return{hash:r,hmac:(e,...t)=>RT(r,e,GJ(...t)),randomBytes:VJ}}function QX(r,e){const t=n=>qX({...r,...ZX(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nO=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),iO=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),YX=BigInt(1),Iw=BigInt(2),sO=(r,e)=>(r+e/Iw)/e;function JX(r){const e=nO,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=ci(h,t,e)*h%e,b=ci(g,t,e)*h%e,w=ci(b,Iw,e)*l%e,I=ci(w,i,e)*w%e,S=ci(I,s,e)*I%e,x=ci(S,a,e)*S%e,C=ci(x,u,e)*x%e,H=ci(C,a,e)*S%e,D=ci(H,t,e)*h%e,z=ci(D,o,e)*I%e,W=ci(z,n,e)*l%e,Z=ci(W,Iw,e);if(!Sw.eql(Sw.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Sw=$X(nO,void 0,void 0,{sqrt:JX}),Uo=QX({a:BigInt(0),b:BigInt(7),Fp:Sw,n:iO,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=iO,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-YX*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=sO(s*r,e),u=sO(-n*r,e);let l=Pn(r-a*t-u*i,e),h=Pn(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},ST);BigInt(0),Uo.ProjectivePoint;const gh="0x0000000000000000000000000000000000000000",oO="0x0000000000000000000000000000000000000000000000000000000000000000",aO=BigInt(0),cO=BigInt(1),uO=BigInt(2),lO=BigInt(27),fO=BigInt(28),Ap=BigInt(35),$u={};function hO(r){return Ga(bn(r),32)}const Ci=class Ci{constructor(e,t,n,i){se(this,il);se(this,sl);se(this,ol);se(this,pc);cp(e,$u,"Signature"),F(this,il,t),F(this,sl,n),F(this,ol,i),F(this,pc,null)}get r(){return T(this,il)}set r(e){q(Ou(e)===32,"invalid r","value",e),F(this,il,Ce(e))}get s(){return T(this,sl)}set s(e){q(Ou(e)===32,"invalid s","value",e);const t=Ce(e);q(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),F(this,sl,t)}get v(){return T(this,ol)}set v(e){const t=at(e,"value");q(t===27||t===28,"invalid v","v",e),F(this,ol,t)}get networkV(){return T(this,pc)}get legacyChainId(){const e=this.networkV;return e==null?null:Ci.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=_t(this.s);return this.yParity&&(e[0]|=128),Ce(e)}get compactSerialized(){return xr([this.r,this.yParityAndS])}get serialized(){return xr([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new Ci($u,this.r,this.s,this.v);return this.networkV&&F(e,pc,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Le(e,"v");return t==lO||t==fO?aO:(q(t>=Ap,"invalid EIP-155 v","v",e),(t-Ap)/uO)}static getChainIdV(e,t){return Le(e)*uO+BigInt(35+t-27)}static getNormalizedV(e){const t=Le(e);return t===aO||t===lO?27:t===cO||t===fO?28:(q(t>=Ap,"invalid v","v",e),t&cO?27:28)}static from(e){function t(l,h){q(l,h,"signature",e)}if(e==null)return new Ci($u,oO,oO,27);if(typeof e=="string"){const l=_t(e,"signature");if(l.length===64){const h=Ce(l.slice(0,32)),g=l.slice(32,64),b=g[0]&128?28:27;return g[0]&=127,new Ci($u,h,Ce(g),b)}if(l.length===65){const h=Ce(l.slice(0,32)),g=l.slice(32,64);t((g[0]&128)===0,"non-canonical s");const b=Ci.getNormalizedV(l[64]);return new Ci($u,h,Ce(g),b)}t(!1,"invalid raw signature length")}if(e instanceof Ci)return e.clone();const n=e.r;t(n!=null,"missing r");const i=hO(n),s=function(l,h){if(l!=null)return hO(l);if(h!=null){t(Gt(h,32),"invalid yParityAndS");const g=_t(h);return g[0]&=127,Ce(g)}t(!1,"missing s")}(e.s,e.yParityAndS);t((_t(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(l,h,g){if(l!=null){const b=Le(l);return{networkV:b>=Ap?b:void 0,v:Ci.getNormalizedV(b)}}if(h!=null)return t(Gt(h,32),"invalid yParityAndS"),{v:_t(h)[0]&128?28:27};if(g!=null){switch(at(g,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),u=new Ci($u,i,s,a);return o&&F(u,pc,o),t(e.yParity==null||at(e.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};il=new WeakMap,sl=new WeakMap,ol=new WeakMap,pc=new WeakMap;let Si=Ci;const gc=class gc{constructor(e){se(this,qs);q(Ou(e)===32,"invalid private key","privateKey","[REDACTED]"),F(this,qs,Ce(e))}get privateKey(){return T(this,qs)}get publicKey(){return gc.computePublicKey(T(this,qs))}get compressedPublicKey(){return gc.computePublicKey(T(this,qs),!0)}sign(e){q(Ou(e)===32,"invalid digest length","digest",e);const t=Uo.sign(wn(e),wn(T(this,qs)),{lowS:!0});return Si.from({r:No(t.r,32),s:No(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=gc.computePublicKey(e);return Ce(Uo.getSharedSecret(wn(T(this,qs)),_t(t),!1))}static computePublicKey(e,t){let n=_t(e,"key");if(n.length===32){const s=Uo.getPublicKey(n,!!t);return Ce(s)}if(n.length===64){const s=new Uint8Array(65);s[0]=4,s.set(n,1),n=s}const i=Uo.ProjectivePoint.fromHex(n);return Ce(i.toRawBytes(t))}static recoverPublicKey(e,t){q(Ou(e)===32,"invalid digest length","digest",e);const n=Si.from(t);let i=Uo.Signature.fromCompact(wn(xr([n.r,n.s])));i=i.addRecoveryBit(n.yParity);const s=i.recoverPublicKey(wn(e));return q(s!=null,"invalid signautre for digest","signature",t),"0x"+s.toHex(!1)}static addPoints(e,t,n){const i=Uo.ProjectivePoint.fromHex(gc.computePublicKey(e).substring(2)),s=Uo.ProjectivePoint.fromHex(gc.computePublicKey(t).substring(2));return"0x"+i.add(s).toHex(!!n)}};qs=new WeakMap;let yh=gc;const XX=BigInt(0),eee=BigInt(36);function dO(r){r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const n=_t(Nr(t));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const kw={};for(let r=0;r<10;r++)kw[String(r)]=String(r);for(let r=0;r<26;r++)kw[String.fromCharCode(65+r)]=String(10+r);const pO=15;function tee(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>kw[n]).join("");for(;e.length>=pO;){let n=e.substring(0,pO);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const ree=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function nee(r){r=r.toLowerCase();let e=XX;for(let t=0;t<r.length;t++)e=e*eee+ree[r[t]];return e}function Mt(r){if(q(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const e=dO(r);return q(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===r,"bad address checksum","address",r),e}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){q(r.substring(2,4)===tee(r),"bad icap checksum","address",r);let e=nee(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return dO("0x"+e)}q(!1,"invalid address","address",r)}function iee(r){const e=Mt(r.from);let n=Le(r.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,Mt(lr(Nr(Va([e,n])),12))}function gO(r){return r&&typeof r.getAddress=="function"}async function Tw(r,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ge(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),q(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),Mt(t)}function An(r,e){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?Mt(r):(ge(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Tw(r,e.resolveName(r)));if(gO(r))return Tw(r,r.getAddress());if(r&&typeof r.then=="function")return Tw(r,r);q(!1,"unsupported addressable value","target",r)}const Fs={};function Oe(r,e){let t=!1;return e<0&&(t=!0,e*=-1),new an(Fs,`${t?"":"u"}int${e}`,r,{signed:t,width:e})}function Et(r,e){return new an(Fs,`bytes${e||""}`,r,{size:e})}const yO=Symbol.for("_ethers_typed"),Zs=class Zs{constructor(e,t,n,i){Q(this,"type");Q(this,"value");se(this,yc);Q(this,"_typedSymbol");i==null&&(i=null),cp(Fs,e,"Typed"),ze(this,{_typedSymbol:yO,type:t,value:n}),F(this,yc,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(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,yc)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,yc)===!0?-1:T(this,yc)===!1?this.value.length:null}static from(e,t){return new Zs(Fs,e,t)}static uint8(e){return Oe(e,8)}static uint16(e){return Oe(e,16)}static uint24(e){return Oe(e,24)}static uint32(e){return Oe(e,32)}static uint40(e){return Oe(e,40)}static uint48(e){return Oe(e,48)}static uint56(e){return Oe(e,56)}static uint64(e){return Oe(e,64)}static uint72(e){return Oe(e,72)}static uint80(e){return Oe(e,80)}static uint88(e){return Oe(e,88)}static uint96(e){return Oe(e,96)}static uint104(e){return Oe(e,104)}static uint112(e){return Oe(e,112)}static uint120(e){return Oe(e,120)}static uint128(e){return Oe(e,128)}static uint136(e){return Oe(e,136)}static uint144(e){return Oe(e,144)}static uint152(e){return Oe(e,152)}static uint160(e){return Oe(e,160)}static uint168(e){return Oe(e,168)}static uint176(e){return Oe(e,176)}static uint184(e){return Oe(e,184)}static uint192(e){return Oe(e,192)}static uint200(e){return Oe(e,200)}static uint208(e){return Oe(e,208)}static uint216(e){return Oe(e,216)}static uint224(e){return Oe(e,224)}static uint232(e){return Oe(e,232)}static uint240(e){return Oe(e,240)}static uint248(e){return Oe(e,248)}static uint256(e){return Oe(e,256)}static uint(e){return Oe(e,256)}static int8(e){return Oe(e,-8)}static int16(e){return Oe(e,-16)}static int24(e){return Oe(e,-24)}static int32(e){return Oe(e,-32)}static int40(e){return Oe(e,-40)}static int48(e){return Oe(e,-48)}static int56(e){return Oe(e,-56)}static int64(e){return Oe(e,-64)}static int72(e){return Oe(e,-72)}static int80(e){return Oe(e,-80)}static int88(e){return Oe(e,-88)}static int96(e){return Oe(e,-96)}static int104(e){return Oe(e,-104)}static int112(e){return Oe(e,-112)}static int120(e){return Oe(e,-120)}static int128(e){return Oe(e,-128)}static int136(e){return Oe(e,-136)}static int144(e){return Oe(e,-144)}static int152(e){return Oe(e,-152)}static int160(e){return Oe(e,-160)}static int168(e){return Oe(e,-168)}static int176(e){return Oe(e,-176)}static int184(e){return Oe(e,-184)}static int192(e){return Oe(e,-192)}static int200(e){return Oe(e,-200)}static int208(e){return Oe(e,-208)}static int216(e){return Oe(e,-216)}static int224(e){return Oe(e,-224)}static int232(e){return Oe(e,-232)}static int240(e){return Oe(e,-240)}static int248(e){return Oe(e,-248)}static int256(e){return Oe(e,-256)}static int(e){return Oe(e,-256)}static bytes1(e){return Et(e,1)}static bytes2(e){return Et(e,2)}static bytes3(e){return Et(e,3)}static bytes4(e){return Et(e,4)}static bytes5(e){return Et(e,5)}static bytes6(e){return Et(e,6)}static bytes7(e){return Et(e,7)}static bytes8(e){return Et(e,8)}static bytes9(e){return Et(e,9)}static bytes10(e){return Et(e,10)}static bytes11(e){return Et(e,11)}static bytes12(e){return Et(e,12)}static bytes13(e){return Et(e,13)}static bytes14(e){return Et(e,14)}static bytes15(e){return Et(e,15)}static bytes16(e){return Et(e,16)}static bytes17(e){return Et(e,17)}static bytes18(e){return Et(e,18)}static bytes19(e){return Et(e,19)}static bytes20(e){return Et(e,20)}static bytes21(e){return Et(e,21)}static bytes22(e){return Et(e,22)}static bytes23(e){return Et(e,23)}static bytes24(e){return Et(e,24)}static bytes25(e){return Et(e,25)}static bytes26(e){return Et(e,26)}static bytes27(e){return Et(e,27)}static bytes28(e){return Et(e,28)}static bytes29(e){return Et(e,29)}static bytes30(e){return Et(e,30)}static bytes31(e){return Et(e,31)}static bytes32(e){return Et(e,32)}static address(e){return new Zs(Fs,"address",e)}static bool(e){return new Zs(Fs,"bool",!!e)}static bytes(e){return new Zs(Fs,"bytes",e)}static string(e){return new Zs(Fs,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Zs(Fs,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===yO}static dereference(e,t){if(Zs.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};yc=new WeakMap;let an=Zs;class see extends Ds{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=an.dereference(t,"string");try{n=Mt(n)}catch(i){return this._throwError(i.message,t)}return e.writeValue(n)}decode(e){return Mt(No(e.readValue(),20))}}class oee extends Ds{constructor(t){super(t.name,t.type,"_",t.dynamic);Q(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}function mO(r,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let u={};n=e.map(l=>{const h=l.localName;return ge(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),ge(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),u[h]=!0,t[h]})}else q(!1,"invalid tuple value","tuple",t);q(e.length===n.length,"types/value length mismatch","tuple",t);let i=new uw,s=new uw,o=[];e.forEach((u,l)=>{let h=n[l];if(u.dynamic){let g=s.length;u.encode(s,h);let b=i.writeUpdatableValue();o.push(w=>{b(w+g)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let a=r.appendWriter(i);return a+=r.appendWriter(s),a}function wO(r,e){let t=[],n=[],i=r.subReader(0);return e.forEach(s=>{let o=null;if(s.dynamic){let a=r.readIndex(),u=i.subReader(a);try{o=s.decode(u)}catch(l){if(Qr(l,"BUFFER_OVERRUN"))throw l;o=l,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(r)}catch(a){if(Qr(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");t.push(o),n.push(s.localName||null)}),Bu.fromItems(t,n)}class aee extends Ds{constructor(t,n,i){const s=t.type+"["+(n>=0?n:"")+"]",o=n===-1||t.dynamic;super("array",s,i,o);Q(this,"coder");Q(this,"length");ze(this,{coder:t,length:n})}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let i=0;i<this.length;i++)n.push(t);return n}encode(t,n){const i=an.dereference(n,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,t.writeValue(i.length)),Yk(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return mO(t,o,i)}decode(t){let n=this.length;n===-1&&(n=t.readIndex(),ge(n*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:n*_n,length:t.dataLength}));let i=[];for(let s=0;s<n;s++)i.push(new oee(this.coder));return wO(t,i)}}class cee extends Ds{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=an.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class bO extends Ds{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=wn(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class uee extends bO{constructor(e){super("bytes",e)}decode(e){return Ce(super.decode(e))}}class lee extends Ds{constructor(t,n){let i="bytes"+String(t);super(i,i,n,!1);Q(this,"size");ze(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let i=wn(an.dereference(n,this.type));return i.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(i)}decode(t){return Ce(t.readBytes(this.size))}}const fee=new Uint8Array([]);class hee extends Ds{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(fee)}decode(e){return e.readBytes(0),null}}const dee=BigInt(0),pee=BigInt(1),gee=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class yee extends Ds{constructor(t,n,i){const s=(n?"int":"uint")+t*8;super(s,s,i,!1);Q(this,"size");Q(this,"signed");ze(this,{size:t,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,n){let i=Le(an.dereference(n,this.type)),s=lh(gee,_n*8);if(this.signed){let o=lh(s,this.size*8-1);(i>o||i<-(o+pee))&&this._throwError("value out-of-bounds",n),i=tT(i,8*_n)}else(i<dee||i>lh(s,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(i)}decode(t){let n=lh(t.readValue(),this.size*8);return this.signed&&(n=AJ(n,this.size*8)),n}}class mee extends bO{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Ls(an.dereference(t,"string")))}decode(e){return fp(super.decode(e))}}class vp extends Ds{constructor(t,n){let i=!1;const s=[];t.forEach(a=>{a.dynamic&&(i=!0),s.push(a.type)});const o="tuple("+s.join(",")+")";super("tuple",o,n,i);Q(this,"coders");ze(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(i=>{t.push(i.defaultValue())});const n=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||n[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[s]))}),Object.freeze(t)}encode(t,n){const i=an.dereference(n,"tuple");return mO(t,this.coders,i)}decode(t){return wO(t,this.coders)}}function Za(r){return Nr(Ls(r))}var wee="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 _O=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),AO=4;function bee(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),i=1,s=[0,1];for(let W=1;W<n;W++)s.push(i+=t());let o=t(),a=e;e+=o;let u=0,l=0;function h(){return u==0&&(l=l<<8|r[e++],u=8),l>>--u&1}const g=31,b=2**g,w=b>>>1,I=w>>1,S=b-1;let x=0;for(let W=0;W<g;W++)x=x<<1|h();let C=[],H=0,D=b;for(;;){let W=Math.floor(((x-H+1)*i-1)/D),Z=0,V=n;for(;V-Z>1;){let ce=Z+V>>>1;W<s[ce]?V=ce:Z=ce}if(Z==0)break;C.push(Z);let K=H+Math.floor(D*s[Z]/i),oe=H+Math.floor(D*s[Z+1]/i)-1;for(;!((K^oe)&w);)x=x<<1&S|h(),K=K<<1&S,oe=oe<<1&S|1;for(;K&~oe&I;)x=x&w|x<<1&S>>>1|h(),K=K<<1^w,oe=(oe^w)<<1|w|1;H=K,D=1+oe-K}let z=n-4;return C.map(W=>{switch(W-z){case 3:return z+65792+(r[a++]<<16|r[a++]<<8|r[a++]);case 2:return z+256+(r[a++]<<8|r[a++]);case 1:return z+r[a++];default:return W-1}})}function _ee(r){let e=0;return()=>r[e++]}function vO(r){return _ee(bee(Aee(r)))}function Aee(r){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>e[i.charCodeAt(0)]=s);let t=r.length,n=new Uint8Array(6*t>>3);for(let i=0,s=0,o=0,a=0;i<t;i++)a=a<<6|e[r.charCodeAt(i)],o+=6,o>=8&&(n[s++]=a>>(o-=8));return n}function vee(r){return r&1?~r>>1:r>>1}function Eee(r,e){let t=Array(r);for(let n=0,i=0;n<r;n++)t[n]=i+=vee(e());return t}function mh(r,e=0){let t=[];for(;;){let n=r(),i=r();if(!i)break;e+=n;for(let s=0;s<i;s++)t.push(e+s);e+=i+1}return t}function EO(r){return wh(()=>{let e=mh(r);if(e.length)return e})}function xO(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(xee(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(Ree(t,r))}return e.flat()}function wh(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function RO(r,e,t){let n=Array(r).fill().map(()=>[]);for(let i=0;i<e;i++)Eee(r,t).forEach((s,o)=>n[o].push(s));return n}function xee(r,e){let t=1+e(),n=e(),i=wh(e);return RO(i.length,1+r,e).flatMap((o,a)=>{let[u,...l]=o;return Array(i[a]).fill().map((h,g)=>{let b=g*n;return[u+g*t,l.map(w=>w+b)]})})}function Ree(r,e){let t=1+e();return RO(t,1+r,e).map(i=>[i[0],i.slice(1)])}function Iee(r){let e=[],t=mh(r);return i(n([]),[]),e;function n(s){let o=r(),a=wh(()=>{let u=mh(r).map(l=>t[l]);if(u.length)return n(u)});return{S:o,B:a,Q:s}}function i({S:s,B:o},a,u){if(!(s&4&&u===a[a.length-1])){s&2&&(u=a[a.length-1]),s&1&&e.push(a);for(let l of o)for(let h of l.Q)i(l,[...a,h],u)}}}function See(r){return r.toString(16).toUpperCase().padStart(2,"0")}function IO(r){return`{${See(r)}}`}function kee(r){let e=[];for(let t=0,n=r.length;t<n;){let i=r.codePointAt(t);t+=i<65536?1:2,e.push(i)}return e}function Fu(r){let t=r.length;if(t<4096)return String.fromCodePoint(...r);let n=[];for(let i=0;i<t;)n.push(String.fromCodePoint(...r.slice(i,i+=4096)));return n.join("")}function Tee(r,e){let t=r.length,n=t-e.length;for(let i=0;n==0&&i<t;i++)n=r[i]-e[i];return n}var Oee="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 bh=44032,Ep=4352,xp=4449,Rp=4519,SO=19,kO=21,Hu=28,Ip=kO*Hu,Nee=SO*Ip,Cee=bh+Nee,Bee=Ep+SO,Pee=xp+kO,Mee=Rp+Hu;function _h(r){return r>>24&255}function TO(r){return r&16777215}let Ow,OO,Nw,Sp;function Lee(){let r=vO(Oee);Ow=new Map(EO(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),OO=new Set(mh(r)),Nw=new Map,Sp=new Map;for(let[e,t]of xO(r)){if(!OO.has(e)&&t.length==2){let[n,i]=t,s=Sp.get(n);s||(s=new Map,Sp.set(n,s)),s.set(i,e)}Nw.set(e,t.reverse())}}function NO(r){return r>=bh&&r<Cee}function Uee(r,e){if(r>=Ep&&r<Bee&&e>=xp&&e<Pee)return bh+(r-Ep)*Ip+(e-xp)*Hu;if(NO(r)&&e>Rp&&e<Mee&&(r-bh)%Hu==0)return r+(e-Rp);{let t=Sp.get(r);return t&&(t=t.get(e),t)?t:-1}}function CO(r){Ow||Lee();let e=[],t=[],n=!1;function i(s){let o=Ow.get(s);o&&(n=!0,s|=o),e.push(s)}for(let s of r)for(;;){if(s<128)e.push(s);else if(NO(s)){let o=s-bh,a=o/Ip|0,u=o%Ip/Hu|0,l=o%Hu;i(Ep+a),i(xp+u),l>0&&i(Rp+l)}else{let o=Nw.get(s);o?t.push(...o):i(s)}if(!t.length)break;s=t.pop()}if(n&&e.length>1){let s=_h(e[0]);for(let o=1;o<e.length;o++){let a=_h(e[o]);if(a==0||s<=a){s=a;continue}let u=o-1;for(;;){let l=e[u+1];if(e[u+1]=e[u],e[u]=l,!u||(s=_h(e[--u]),s<=a))break}s=_h(e[o])}}return e}function Dee(r){let e=[],t=[],n=-1,i=0;for(let s of r){let o=_h(s),a=TO(s);if(n==-1)o==0?n=a:e.push(a);else if(i>0&&i>=o)o==0?(e.push(n,...t),t.length=0,n=a):t.push(a),i=o;else{let u=Uee(n,a);u>=0?n=u:i==0&&o==0?(e.push(n),n=a):(t.push(a),i=o)}}return n>=0&&e.push(n,...t),e}function BO(r){return CO(r).map(TO)}function $ee(r){return Dee(CO(r))}const PO=45,MO=".",LO=65039,UO=1,kp=r=>Array.from(r);function Ah(r,e){return r.P.has(e)||r.Q.has(e)}class Fee extends Array{get is_emoji(){return!0}}let Cw,DO,Qa,Bw,$O,zu,Pw,Gu,Ya,FO,Mw;function Lw(){if(Cw)return;let r=vO(wee);const e=()=>mh(r),t=()=>new Set(e()),n=(h,g)=>g.forEach(b=>h.add(b));Cw=new Map(xO(r)),DO=t(),Qa=e(),Bw=new Set(e().map(h=>Qa[h])),Qa=new Set(Qa),$O=t(),t();let i=EO(r),s=r();const o=()=>{let h=new Set;return e().forEach(g=>n(h,i[g])),n(h,e()),h};zu=wh(h=>{let g=wh(r).map(b=>b+96);if(g.length){let b=h>=s;g[0]-=32,g=Fu(g),b&&(g=`Restricted[${g}]`);let w=o(),I=o(),S=!r();return{N:g,P:w,Q:I,M:S,R:b}}}),Pw=t(),Gu=new Map;let a=e().concat(kp(Pw)).sort((h,g)=>h-g);a.forEach((h,g)=>{let b=r(),w=a[g]=b?a[g-b]:{V:[],M:new Map};w.V.push(h),Pw.has(h)||Gu.set(h,w)});for(let{V:h,M:g}of new Set(Gu.values())){let b=[];for(let I of h){let S=zu.filter(C=>Ah(C,I)),x=b.find(({G:C})=>S.some(H=>C.has(H)));x||(x={G:new Set,V:[]},b.push(x)),x.V.push(I),n(x.G,S)}let w=b.flatMap(I=>kp(I.G));for(let{G:I,V:S}of b){let x=new Set(w.filter(C=>!I.has(C)));for(let C of S)g.set(C,x)}}Ya=new Set;let u=new Set;const l=h=>Ya.has(h)?u.add(h):Ya.add(h);for(let h of zu){for(let g of h.P)l(g);for(let g of h.Q)l(g)}for(let h of Ya)!Gu.has(h)&&!u.has(h)&&Gu.set(h,UO);n(Ya,BO(Ya)),FO=Iee(r).map(h=>Fee.from(h)).sort(Tee),Mw=new Map;for(let h of FO){let g=[Mw];for(let b of h){let w=g.map(I=>{let S=I.get(b);return S||(S=new Map,I.set(b,S)),S});b===LO?g.push(...w):g=w}for(let b of g)b.V=h}}function Uw(r){return(HO(r)?"":`${Dw(Tp([r]))} `)+IO(r)}function Dw(r){return`"${r}"`}function Hee(r){if(r.length>=4&&r[2]==PO&&r[3]==PO)throw new Error(`invalid label extension: "${Fu(r.slice(0,4))}"`)}function zee(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function Gee(r){let e=r[0],t=_O.get(e);if(t)throw vh(`leading ${t}`);let n=r.length,i=-1;for(let s=1;s<n;s++){e=r[s];let o=_O.get(e);if(o){if(i==s)throw vh(`${t} + ${o}`);i=s+1,t=o}}if(i==n)throw vh(`trailing ${t}`)}function Tp(r,e=1/0,t=IO){let n=[];Vee(r[0])&&n.push("◌"),r.length>e&&(e>>=1,r=[...r.slice(0,e),8230,...r.slice(-e)]);let i=0,s=r.length;for(let o=0;o<s;o++){let a=r[o];HO(a)&&(n.push(Fu(r.slice(i,o))),n.push(t(a)),i=o+1)}return n.push(Fu(r.slice(i,s))),n.join("")}function Vee(r){return Lw(),Qa.has(r)}function HO(r){return Lw(),$O.has(r)}function jee(r){return Zee(Kee(r,$ee,Jee))}function Kee(r,e,t){if(!r)return[];Lw();let n=0;return r.split(MO).map(i=>{let s=kee(i),o={input:s,offset:n};n+=s.length+1;try{let a=o.tokens=Yee(s,e,t),u=a.length,l;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(zee(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(b=>b<128))Hee(h),l="ASCII";else{let b=a.flatMap(w=>w.is_emoji?[]:w);if(!b.length)l="Emoji";else{if(Qa.has(h[0]))throw vh("leading combining mark");for(let S=1;S<u;S++){let x=a[S];if(!x.is_emoji&&Qa.has(x[0]))throw vh(`emoji + combining mark: "${Fu(a[S-1])} + ${Tp([x[0]])}"`)}Gee(h);let w=kp(new Set(b)),[I]=qee(w);Qee(I,b),Wee(I,w),l=I.N}}o.type=l}catch(a){o.error=a}return o})}function Wee(r,e){let t,n=[];for(let i of e){let s=Gu.get(i);if(s===UO)return;if(s){let o=s.M.get(i);if(t=t?t.filter(a=>o.has(a)):kp(o),!t.length)return}else n.push(i)}if(t){for(let i of t)if(n.every(s=>Ah(i,s)))throw new Error(`whole-script confusable: ${r.N}/${i.N}`)}}function qee(r){let e=zu;for(let t of r){let n=e.filter(i=>Ah(i,t));if(!n.length)throw zu.some(i=>Ah(i,t))?GO(e[0],t):zO(t);if(e=n,n.length==1)break}return e}function Zee(r){return r.map(({input:e,error:t,output:n})=>{if(t){let i=t.message;throw new Error(r.length==1?i:`Invalid label ${Dw(Tp(e,63))}: ${i}`)}return Fu(n)}).join(MO)}function zO(r){return new Error(`disallowed character: ${Uw(r)}`)}function GO(r,e){let t=Uw(e),n=zu.find(i=>i.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function vh(r){return new Error(`illegal placement: ${r}`)}function Qee(r,e){for(let t of e)if(!Ah(r,t))throw GO(r,t);if(r.M){let t=BO(e);for(let n=1,i=t.length;n<i;n++)if(Bw.has(t[n])){let s=n+1;for(let o;s<i&&Bw.has(o=t[s]);s++)for(let a=n;a<s;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${Uw(o)}`);if(s-n>AO)throw new Error(`excessive non-spacing marks: ${Dw(Tp(t.slice(n-1,s)))} (${s-n}/${AO})`);n=s}}}function Yee(r,e,t){let n=[],i=[];for(r=r.slice().reverse();r.length;){let s=Xee(r);if(s)i.length&&(n.push(e(i)),i=[]),n.push(t(s));else{let o=r.pop();if(Ya.has(o))i.push(o);else{let a=Cw.get(o);if(a)i.push(...a);else if(!DO.has(o))throw zO(o)}}}return i.length&&n.push(e(i)),n}function Jee(r){return r.filter(e=>e!=LO)}function Xee(r,e){let t=Mw,n,i=r.length;for(;i&&(t=t.get(r[--i]),!!t);){let{V:s}=t;s&&(n=s,r.length=i)}return n}const VO=new Uint8Array(32);VO.fill(0);function jO(r){return q(r.length!==0,"invalid ENS name; empty component","comp",r),r}function KO(r){const e=Ls(ete(r)),t=[];if(r.length===0)return t;let n=0;for(let i=0;i<e.length;i++)e[i]===46&&(t.push(jO(e.slice(n,i))),n=i+1);return q(n<e.length,"invalid ENS name; empty component","name",r),t.push(jO(e.slice(n))),t}function ete(r){try{if(r.length===0)throw new Error("empty label");return jee(r)}catch(e){q(!1,`invalid ENS name (${e.message})`,"name",r)}}function $w(r){q(typeof r=="string","invalid ENS name; not a string","name",r),q(r.length,"invalid ENS name (empty label)","name",r);let e=VO;const t=KO(r);for(;t.length;)e=Nr(xr([e,Nr(t.pop())]));return Ce(e)}function tte(r,e){const t=e;return q(t<=255,"DNS encoded label cannot exceed 255","length",t),Ce(xr(KO(r).map(n=>{q(n.length<=t,`label ${JSON.stringify(r)} exceeds ${t} bytes`,"name",r);const i=new Uint8Array(n.length+1);return i.set(n,1),i[0]=i.length-1,i})))+"00"}function Fw(r,e){return{address:Mt(r),storageKeys:e.map((t,n)=>(q(Gt(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function Ja(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(q(t.length===2,"invalid slot set",`value[${n}]`,t),Fw(t[0],t[1])):(q(t!=null&&typeof t=="object","invalid address-slot set","value",r),Fw(t.address,t.storageKeys)));q(r!=null&&typeof r=="object","invalid access list","value",r);const e=Object.keys(r).map(t=>{const n=r[t].reduce((i,s)=>(i[s]=!0,i),{});return Fw(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function rte(r){let e;return typeof r=="string"?e=yh.computePublicKey(r,!1):e=r.publicKey,Mt(Nr("0x"+e.substring(4)).substring(26))}function nte(r,e){return rte(yh.recoverPublicKey(r,e))}const Fr=BigInt(0),ite=BigInt(2),ste=BigInt(27),ote=BigInt(28),ate=BigInt(35),cte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Hw=4096*32;function WO(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=Mu(e).substring(4),"0x"+t}function Op(r){return r==="0x"?null:Mt(r)}function zw(r,e){try{return Ja(r)}catch(t){q(!1,t.message,e,r)}}function Eh(r,e){return r==="0x"?0:at(r,e)}function Ir(r,e){if(r==="0x")return Fr;const t=Le(r,e);return q(t<=cte,"value exceeds uint size",e,t),t}function qt(r,e){const t=Le(r,"value"),n=bn(t);return q(n.length<=32,"value too large",`tx.${e}`,t),n}function Gw(r){return Ja(r).map(e=>[e.address,e.storageKeys])}function ute(r,e){q(Array.isArray(r),`invalid ${e}`,"value",r);for(let t=0;t<r.length;t++)q(Gt(r[t],32),"invalid ${ param } hash",`value[${t}]`,r[t]);return r}function lte(r){const e=pp(r);q(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:Eh(e[0],"nonce"),gasPrice:Ir(e[1],"gasPrice"),gasLimit:Ir(e[2],"gasLimit"),to:Op(e[3]),value:Ir(e[4],"value"),data:Ce(e[5]),chainId:Fr};if(e.length===6)return t;const n=Ir(e[6],"v"),i=Ir(e[7],"r"),s=Ir(e[8],"s");if(i===Fr&&s===Fr)t.chainId=n;else{let o=(n-ate)/ite;o<Fr&&(o=Fr),t.chainId=o,q(o!==Fr||n===ste||n===ote,"non-canonical legacy v","v",e[6]),t.signature=Si.from({r:Ga(e[7],32),s:Ga(e[8],32),v:n})}return t}function fte(r,e){const t=[qt(r.nonce,"nonce"),qt(r.gasPrice||0,"gasPrice"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data];let n=Fr;if(r.chainId!=Fr)n=Le(r.chainId,"tx.chainId"),q(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(r.signature){const s=r.signature.legacyChainId;s!=null&&(n=s)}if(!e)return n!==Fr&&(t.push(bn(n)),t.push("0x"),t.push("0x")),Va(t);let i=BigInt(27+e.yParity);return n!==Fr?i=Si.getChainIdV(n,e.v):BigInt(e.v)!==i&&q(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(bn(i)),t.push(bn(e.r)),t.push(bn(e.s)),Va(t)}function Vw(r,e){let t;try{if(t=Eh(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{q(!1,"invalid yParity","yParity",e[0])}const n=Ga(e[1],32),i=Ga(e[2],32),s=Si.from({r:n,s:i,yParity:t});r.signature=s}function hte(r){const e=pp(_t(r).slice(1));q(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",Ce(r));const t={type:2,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Op(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:zw(e[8],"accessList")};return e.length===9||Vw(t,e.slice(9)),t}function dte(r,e){const t=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qt(r.maxFeePerGas||0,"maxFeePerGas"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data,Gw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"yParity")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x02",Va(t)])}function pte(r){const e=pp(_t(r).slice(1));q(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",Ce(r));const t={type:1,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),gasPrice:Ir(e[2],"gasPrice"),gasLimit:Ir(e[3],"gasLimit"),to:Op(e[4]),value:Ir(e[5],"value"),data:Ce(e[6]),accessList:zw(e[7],"accessList")};return e.length===8||Vw(t,e.slice(8)),t}function gte(r,e){const t=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.gasPrice||0,"gasPrice"),qt(r.gasLimit,"gasLimit"),r.to||"0x",qt(r.value,"value"),r.data,Gw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"recoveryParam")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x01",Va(t)])}function yte(r){let e=pp(_t(r).slice(1)),t="3",n=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const s=e[1],o=e[2],a=e[3];q(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),q(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),q(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),q(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),q(s.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let u=0;u<e[1].length;u++)n.push({data:s[u],commitment:o[u],proof:a[u]});e=e[0]}q(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",Ce(r));const i={type:3,chainId:Ir(e[0],"chainId"),nonce:Eh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Op(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:zw(e[8],"accessList"),maxFeePerBlobGas:Ir(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),q(i.to!=null,`invalid address for transaction type: ${t}`,"data",r),q(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",r);for(let s=0;s<i.blobVersionedHashes.length;s++)q(Gt(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",r);return e.length===11||Vw(i,e.slice(11)),i}function mte(r,e,t){const n=[qt(r.chainId,"chainId"),qt(r.nonce,"nonce"),qt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),qt(r.maxFeePerGas||0,"maxFeePerGas"),qt(r.gasLimit,"gasLimit"),r.to||gh,qt(r.value,"value"),r.data,Gw(r.accessList||[]),qt(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),ute(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(qt(e.yParity,"yParity")),n.push(bn(e.r)),n.push(bn(e.s)),t)?xr(["0x03",Va([n,t.map(i=>i.data),t.map(i=>i.commitment),t.map(i=>i.proof)])]):xr(["0x03",Va(n)])}const Ys=class Ys{constructor(){se(this,wl);se(this,cs);se(this,al);se(this,cl);se(this,ul);se(this,ll);se(this,fl);se(this,hl);se(this,dl);se(this,pl);se(this,gl);se(this,yl);se(this,ml);se(this,mc);se(this,zo);se(this,Qs);se(this,Go);F(this,cs,null),F(this,al,null),F(this,ul,0),F(this,ll,Fr),F(this,fl,null),F(this,hl,null),F(this,dl,null),F(this,cl,"0x"),F(this,pl,Fr),F(this,gl,Fr),F(this,yl,null),F(this,ml,null),F(this,mc,null),F(this,zo,null),F(this,Go,null),F(this,Qs,null)}get type(){return T(this,cs)}set type(e){switch(e){case null:F(this,cs,null);break;case 0:case"legacy":F(this,cs,0);break;case 1:case"berlin":case"eip-2930":F(this,cs,1);break;case 2:case"london":case"eip-1559":F(this,cs,2);break;case 3:case"cancun":case"eip-4844":F(this,cs,3);break;default:q(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,al);return e==null&&this.type===3?gh:e}set to(e){F(this,al,e==null?null:Mt(e))}get nonce(){return T(this,ul)}set nonce(e){F(this,ul,at(e,"value"))}get gasLimit(){return T(this,ll)}set gasLimit(e){F(this,ll,Le(e))}get gasPrice(){const e=T(this,fl);return e==null&&(this.type===0||this.type===1)?Fr:e}set gasPrice(e){F(this,fl,e==null?null:Le(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,hl);return e??(this.type===2||this.type===3?Fr:null)}set maxPriorityFeePerGas(e){F(this,hl,e==null?null:Le(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,dl);return e??(this.type===2||this.type===3?Fr:null)}set maxFeePerGas(e){F(this,dl,e==null?null:Le(e,"maxFeePerGas"))}get data(){return T(this,cl)}set data(e){F(this,cl,Ce(e))}get value(){return T(this,pl)}set value(e){F(this,pl,Le(e,"value"))}get chainId(){return T(this,gl)}set chainId(e){F(this,gl,Le(e))}get signature(){return T(this,yl)||null}set signature(e){F(this,yl,e==null?null:Si.from(e))}get accessList(){const e=T(this,ml)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){F(this,ml,e==null?null:Ja(e))}get maxFeePerBlobGas(){const e=T(this,mc);return e==null&&this.type===3?Fr:e}set maxFeePerBlobGas(e){F(this,mc,e==null?null:Le(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,zo);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){q(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)q(Gt(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}F(this,zo,e)}get blobs(){return T(this,Go)==null?null:T(this,Go).map(e=>Object.assign({},e))}set blobs(e){if(e==null){F(this,Go,null);return}const t=[],n=[];for(let i=0;i<e.length;i++){const s=e[i];if(iw(s)){ge(T(this,Qs),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=_t(s);if(q(o.length<=Hw,"blob is too large",`blobs[${i}]`,s),o.length!==Hw){const l=new Uint8Array(Hw);l.set(o),o=l}const a=T(this,Qs).blobToKzgCommitment(o),u=Ce(T(this,Qs).computeBlobKzgProof(o,a));t.push({data:Ce(o),commitment:Ce(a),proof:u}),n.push(WO(1,a))}else{const o=Ce(s.commitment);t.push({data:Ce(s.data),commitment:o,proof:Ce(s.proof)}),n.push(WO(1,o))}}F(this,Go,t),F(this,zo,n)}get kzg(){return T(this,Qs)}set kzg(e){F(this,Qs,e)}get hash(){return this.signature==null?null:Nr(Ee(this,wl,mg).call(this,!0,!1))}get unsignedHash(){return Nr(this.unsignedSerialized)}get from(){return this.signature==null?null:nte(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:yh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return Ee(this,wl,mg).call(this,!0,!0)}get unsignedSerialized(){return Ee(this,wl,mg).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,i=T(this,mc)!=null||T(this,zo);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ge(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ge(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ge(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):t?s.push(2):e?(s.push(1),n||s.push(0)):n?(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 Ys.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Ys;if(typeof e=="string"){const n=_t(e);if(n[0]>=127)return Ys.from(lte(n));switch(n[0]){case 1:return Ys.from(pte(n));case 2:return Ys.from(hte(n));case 3:return Ys.from(yte(n))}ge(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Ys;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Si.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),q(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),q(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};cs=new WeakMap,al=new WeakMap,cl=new WeakMap,ul=new WeakMap,ll=new WeakMap,fl=new WeakMap,hl=new WeakMap,dl=new WeakMap,pl=new WeakMap,gl=new WeakMap,yl=new WeakMap,ml=new WeakMap,mc=new WeakMap,zo=new WeakMap,Qs=new WeakMap,Go=new WeakMap,wl=new WeakSet,mg=function(e,t){ge(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return fte(this,n);case 1:return gte(this,n);case 2:return dte(this,n);case 3:return mte(this,n,t?this.blobs:null)}ge(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Np=Ys;const qO=new Uint8Array(32);qO.fill(0);const wte=BigInt(-1),ZO=BigInt(0),QO=BigInt(1),bte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function _te(r){const e=_t(r),t=e.length%32;return t?xr([e,qO.slice(t)]):Ce(e)}const Ate=No(QO,32),vte=No(ZO,32),YO={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},jw=["name","version","chainId","verifyingContract","salt"];function JO(r){return function(e){return q(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const Ete={name:JO("name"),version:JO("version"),chainId:function(r){const e=Le(r,"domain.chainId");return q(e>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(e)?Number(e):Cu(e)},verifyingContract:function(r){try{return Mt(r).toLowerCase()}catch{}q(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const e=_t(r,"domain.salt");return q(e.length===32,'invalid domain value "salt"',"domain.salt",r),Ce(e)}};function Kw(r){{const e=r.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);q(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",r);const i=lh(bte,t?n-1:n),s=t?(i+QO)*wte:ZO;return function(o){const a=Le(o,"value");return q(a>=s&&a<=i,`value out-of-bounds for ${r}`,"value",a),No(t?tT(a,256):a,32)}}}{const e=r.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return q(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",r),function(n){const i=_t(n);return q(i.length===t,`invalid length for ${r}`,"value",n),_te(n)}}}switch(r){case"address":return function(e){return Ga(Mt(e),32)};case"bool":return function(e){return e?Ate:vte};case"bytes":return function(e){return Nr(e)};case"string":return function(e){return Za(e)}}return null}function XO(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Cp(r){const e=r.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:r}}const li=class li{constructor(e){se(this,Zp);Q(this,"primaryType");se(this,Ph);se(this,Js);se(this,bl);F(this,Js,new Map),F(this,bl,new Map);const t=new Map,n=new Map,i=new Map,s={};Object.keys(e).forEach(u=>{s[u]=e[u].map(({name:l,type:h})=>{let{base:g,index:b}=Cp(h);return g==="int"&&!e.int&&(g="int256"),g==="uint"&&!e.uint&&(g="uint256"),{name:l,type:g+(b||"")}}),t.set(u,new Set),n.set(u,[]),i.set(u,new Set)}),F(this,Ph,JSON.stringify(s));for(const u in s){const l=new Set;for(const h of s[u]){q(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",e),l.add(h.name);const g=Cp(h.type).base;q(g!==u,`circular type reference to ${JSON.stringify(g)}`,"types",e),!Kw(g)&&(q(n.has(g),`unknown type ${JSON.stringify(g)}`,"types",e),n.get(g).push(u),t.get(u).add(g))}}const o=Array.from(n.keys()).filter(u=>n.get(u).length===0);q(o.length!==0,"missing primary type","types",e),q(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",e),ze(this,{primaryType:o[0]});function a(u,l){q(!l.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",e),l.add(u);for(const h of t.get(u))if(n.has(h)){a(h,l);for(const g of l)i.get(g).add(h)}l.delete(u)}a(this.primaryType,new Set);for(const[u,l]of i){const h=Array.from(l);h.sort(),T(this,Js).set(u,XO(u,s[u])+h.map(g=>XO(g,s[g])).join(""))}}get types(){return JSON.parse(T(this,Ph))}getEncoder(e){let t=T(this,bl).get(e);return t||(t=Ee(this,Zp,h6).call(this,e),T(this,bl).set(e,t)),t}encodeType(e){const t=T(this,Js).get(e);return q(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Nr(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Kw(e))return n(e,t);const i=Cp(e).array;if(i)return q(i.count===-1||i.count===t.length,`array length mismatch; expected length ${i.count}`,"value",t),t.map(o=>this._visit(i.prefix,o,n));const s=this.types[e];if(s)return s.reduce((o,{name:a,type:u})=>(o[a]=this._visit(u,t[a],n),o),{});q(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new li(e)}static getPrimaryType(e){return li.from(e).primaryType}static hashStruct(e,t,n){return li.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const i=YO[n];q(i,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:i})}return t.sort((n,i)=>jw.indexOf(n.name)-jw.indexOf(i.name)),li.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return xr(["0x1901",li.hashDomain(e),li.from(t).hash(n)])}static hash(e,t,n){return Nr(li.encode(e,t,n))}static async resolveNames(e,t,n,i){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const s={};e.verifyingContract&&!Gt(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=li.from(t);o.visit(n,(a,u)=>(a==="address"&&!Gt(u,20)&&(s[u]="0x"),u));for(const a in s)s[a]=await i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=o.visit(n,(a,u)=>a==="address"&&s[u]?s[u]:u),{domain:e,value:n}}static getPayload(e,t,n){li.hashDomain(e);const i={},s=[];jw.forEach(u=>{const l=e[u];l!=null&&(i[u]=Ete[u](l),s.push({name:u,type:YO[u]}))});const o=li.from(t);t=o.types;const a=Object.assign({},t);return q(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=s,o.encode(n),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(n,(u,l)=>{if(u.match(/^bytes(\d*)/))return Ce(_t(l));if(u.match(/^u?int/))return Le(l).toString();switch(u){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return q(typeof l=="string","invalid string","value",l),l}q(!1,"unsupported type","type",u)})}}};Ph=new WeakMap,Js=new WeakMap,bl=new WeakMap,Zp=new WeakSet,h6=function(e){{const i=Kw(e);if(i)return i}const t=Cp(e).array;if(t){const i=t.prefix,s=this.getEncoder(i);return o=>{q(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(s);return T(this,Js).has(i)&&(a=a.map(Nr)),Nr(xr(a))}}const n=this.types[e];if(n){const i=Za(T(this,Js).get(e));return s=>{const o=n.map(({name:a,type:u})=>{const l=this.getEncoder(u)(s[a]);return T(this,Js).has(u)?Nr(l):l});return o.unshift(i),xr(o)}}q(!1,`unknown type: ${e}`,"type",e)};let Bp=li;function vn(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const xte=vn("external public payable override".split(" ")),eN="constant external internal payable private public pure view override",Rte=vn(eN.split(" ")),tN="constructor error event fallback function receive struct",rN=vn(tN.split(" ")),nN="calldata memory storage payable indexed",Ite=vn(nN.split(" ")),Ste=[tN,nN,"tuple returns",eN].join(" "),kte=vn(Ste.split(" ")),Tte={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Ote=new RegExp("^(\\s*)"),Nte=new RegExp("^([0-9]+)"),Cte=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),iN=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),sN=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Qp=class Qp{constructor(e){se(this,Mh);se(this,Xr);se(this,Bi);F(this,Xr,0),F(this,Bi,e.slice())}get offset(){return T(this,Xr)}get length(){return T(this,Bi).length-T(this,Xr)}clone(){return new Qp(T(this,Bi))}reset(){F(this,Xr,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=Ee(this,Mh,D_).call(this,T(this,Xr)+1,e.match+1);return F(this,Xr,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,Xr)<e.match-1;){const n=this.peek().linkNext;t.push(Ee(this,Mh,D_).call(this,T(this,Xr)+1,n)),F(this,Xr,n)}return F(this,Xr,e.match+1),t}peek(){if(T(this,Xr)>=T(this,Bi).length)throw new Error("out-of-bounds");return T(this,Bi)[T(this,Xr)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return bd(this,Xr)._++,e}toString(){const e=[];for(let t=T(this,Xr);t<T(this,Bi).length;t++){const n=T(this,Bi)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};Xr=new WeakMap,Bi=new WeakMap,Mh=new WeakSet,D_=function(e=0,t=0){return new Qp(T(this,Bi).slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))};let ki=Qp;function Do(r){const e=[],t=o=>{const a=s<r.length?JSON.stringify(r[s]):"$EOI";throw new Error(`invalid token ${a} at ${s}: ${o}`)};let n=[],i=[],s=0;for(;s<r.length;){let o=r.substring(s),a=o.match(Ote);a&&(s+=a[1].length,o=r.substring(s));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(u);let l=Tte[o[0]]||"";if(l){if(u.type=l,u.text=o[0],s++,l==="OPEN_PAREN")n.push(e.length-1),i.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),u.match=n.pop(),e[u.match].match=e.length-1,u.depth--,u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1;else if(l==="COMMA")u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if(l==="OPEN_BRACKET")u.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const g=e.pop().text;h=g+h,e[e.length-1].value=at(g)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(a=o.match(Cte),a){if(u.text=a[1],s+=u.text.length,kte.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(sN)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(Nte),a){u.text=a[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new ki(e.map(o=>Object.freeze(o)))}function oN(r,e){let t=[];for(const n in e.keys())r.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Pp(r,e){if(e.peekKeyword(rN)){const t=e.pop().text;if(t!==r)throw new Error(`expected ${r}, got ${t}`)}return e.popType("ID")}function Hs(r,e){const t=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(r.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function aN(r){let e=Hs(r,Rte);return oN(e,vn("constant payable nonpayable".split(" "))),oN(e,vn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function zs(r,e){return r.popParams().map(t=>Yr.from(t,e))}function cN(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return Le(r.pop().text);throw new Error("invalid gas")}return null}function Xa(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Bte=new RegExp(/^(.*)\[([0-9]*)\]$/);function uN(r){const e=r.match(sN);if(q(e,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(e[2]){const t=parseInt(e[2]);q(t!==0&&t<=32,"invalid bytes length","type",r)}else if(e[3]){const t=parseInt(e[3]);q(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",r)}return r}const ir={},Mn=Symbol.for("_ethers_internal"),lN="_ParamTypeInternal",fN="_ErrorInternal",hN="_EventInternal",dN="_ConstructorInternal",pN="_FallbackInternal",gN="_FunctionInternal",yN="_StructInternal",fi=class fi{constructor(e,t,n,i,s,o,a,u){se(this,_l);Q(this,"name");Q(this,"type");Q(this,"baseType");Q(this,"indexed");Q(this,"components");Q(this,"arrayLength");Q(this,"arrayChildren");if(cp(e,ir,"ParamType"),Object.defineProperty(this,Mn,{value:lN}),o&&(o=Object.freeze(o.slice())),i==="array"){if(a==null||u==null)throw new Error("")}else if(a!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");ze(this,{name:t,type:n,baseType:i,indexed:s,components:o,arrayLength:a,arrayChildren:u})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=n,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(i)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(i=>n.arrayChildren.walk(i,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((i,s)=>n.components[s].walk(i,t))}return t(this.type,e)}async walkAsync(e,t){const n=[],i=[e];return Ee(this,_l,wg).call(this,n,e,t,s=>{i[0]=s}),n.length&&await Promise.all(n),i[0]}static from(e,t){if(fi.isParamType(e))return e;if(typeof e=="string")try{return fi.from(Do(e),t)}catch{q(!1,"invalid param type","obj",e)}else if(e instanceof ki){let a="",u="",l=null;Hs(e,vn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(u="tuple",l=e.popParams().map(S=>fi.from(S)),a=`tuple(${l.map(S=>S.format()).join(",")})`):(a=uN(e.popType("TYPE")),u=a);let h=null,g=null;for(;e.length&&e.peekType("BRACKET");){const S=e.pop();h=new fi(ir,"",a,u,null,l,g,h),g=S.value,a+=S.text,u="array",l=null}let b=null;if(Hs(e,Ite).has("indexed")){if(!t)throw new Error("");b=!0}const I=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new fi(ir,I,a,u,b,l,g,h)}const n=e.name;q(!n||typeof n=="string"&&n.match(iN),"invalid name","obj.name",n);let i=e.indexed;i!=null&&(q(t,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,o=s.match(Bte);if(o){const a=parseInt(o[2]||"-1"),u=fi.from({type:o[1],components:e.components});return new fi(ir,n||"",s,"array",i,null,a,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const a=e.components!=null?e.components.map(l=>fi.from(l)):null;return new fi(ir,n||"",s,"tuple",i,a,null,null)}return s=uN(e.type),new fi(ir,n||"",s,s,i,null,null,null)}static isParamType(e){return e&&e[Mn]===lN}};_l=new WeakSet,wg=function(e,t,n,i){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((u,l)=>{var h;Ee(h=o,_l,wg).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in t))throw new Error(`missing value for component ${u.name}`);return t[u.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((u,l)=>{var h;Ee(h=o[l],_l,wg).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}const s=n(this.type,t);s.then?e.push(async function(){i(await s)}()):i(s)};let Yr=fi;class ec{constructor(e,t,n){Q(this,"type");Q(this,"inputs");cp(e,ir,"Fragment"),n=Object.freeze(n.slice()),ze(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{ec.from(JSON.parse(e))}catch{}return ec.from(Do(e))}if(e instanceof ki)switch(e.peekKeyword(rN)){case"constructor":return Gs.from(e);case"error":return Ln.from(e);case"event":return is.from(e);case"fallback":case"receive":return Vs.from(e);case"function":return ss.from(e);case"struct":return tc.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Gs.from(e);case"error":return Ln.from(e);case"event":return is.from(e);case"fallback":case"receive":return Vs.from(e);case"function":return ss.from(e);case"struct":return tc.from(e)}ge(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}q(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Gs.isFragment(e)}static isError(e){return Ln.isFragment(e)}static isEvent(e){return is.isFragment(e)}static isFunction(e){return ss.isFragment(e)}static isStruct(e){return tc.isFragment(e)}}class Mp extends ec{constructor(t,n,i,s){super(t,n,s);Q(this,"name");q(typeof i=="string"&&i.match(iN),"invalid identifier","name",i),s=Object.freeze(s.slice()),ze(this,{name:i})}}function xh(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Ln extends Mp{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Mn,{value:fN})}get selector(){return Za(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+xh(e,this.inputs)),t.join(" ")}static from(e){if(Ln.isFragment(e))return e;if(typeof e=="string")return Ln.from(Do(e));if(e instanceof ki){const t=Pp("error",e),n=zs(e);return Xa(e),new Ln(ir,t,n)}return new Ln(ir,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Mn]===fN}}class is extends Mp{constructor(t,n,i,s){super(t,"event",n,i);Q(this,"anonymous");Object.defineProperty(this,Mn,{value:hN}),ze(this,{anonymous:s})}get topicHash(){return Za(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("event"),n.push(this.name+xh(t,this.inputs)),t!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(t,n){return n=(n||[]).map(s=>Yr.from(s)),new is(ir,t,n,!1).topicHash}static from(t){if(is.isFragment(t))return t;if(typeof t=="string")try{return is.from(Do(t))}catch{q(!1,"invalid event fragment","obj",t)}else if(t instanceof ki){const n=Pp("event",t),i=zs(t,!0),s=!!Hs(t,vn(["anonymous"])).has("anonymous");return Xa(t),new is(ir,n,i,s)}return new is(ir,t.name,t.inputs?t.inputs.map(n=>Yr.from(n,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Mn]===hN}}class Gs extends ec{constructor(t,n,i,s,o){super(t,n,i);Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Mn,{value:dN}),ze(this,{payable:s,gas:o})}format(t){if(ge(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[`constructor${xh(t,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(t){if(Gs.isFragment(t))return t;if(typeof t=="string")try{return Gs.from(Do(t))}catch{q(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ki){Hs(t,vn(["constructor"]));const n=zs(t),i=!!Hs(t,xte).has("payable"),s=cN(t);return Xa(t),new Gs(ir,"constructor",n,i,s)}return new Gs(ir,"constructor",t.inputs?t.inputs.map(Yr.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Mn]===dN}}class Vs extends ec{constructor(t,n,i){super(t,"fallback",n);Q(this,"payable");Object.defineProperty(this,Mn,{value:pN}),ze(this,{payable:i})}format(t){const n=this.inputs.length===0?"receive":"fallback";if(t==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:i})}return`${n}()${this.payable?" payable":""}`}static from(t){if(Vs.isFragment(t))return t;if(typeof t=="string")try{return Vs.from(Do(t))}catch{q(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ki){const n=t.toString(),i=t.peekKeyword(vn(["fallback","receive"]));if(q(i,"type must be fallback or receive","obj",n),t.popKeyword(vn(["fallback","receive"]))==="receive"){const u=zs(t);return q(u.length===0,"receive cannot have arguments","obj.inputs",u),Hs(t,vn(["payable"])),Xa(t),new Vs(ir,[],!0)}let o=zs(t);o.length?q(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Yr.from("bytes")];const a=aN(t);if(q(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Hs(t,vn(["returns"])).has("returns")){const u=zs(t);q(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(l=>l.format("minimal")).join(", "))}return Xa(t),new Vs(ir,o,a==="payable")}if(t.type==="receive")return new Vs(ir,[],!0);if(t.type==="fallback"){const n=[Yr.from("bytes")],i=t.stateMutability==="payable";return new Vs(ir,n,i)}q(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Mn]===pN}}class ss extends Mp{constructor(t,n,i,s,o,a){super(t,"function",n,s);Q(this,"constant");Q(this,"outputs");Q(this,"stateMutability");Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Mn,{value:gN}),o=Object.freeze(o.slice()),ze(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return Za(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t))),outputs:this.outputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("function"),n.push(this.name+xh(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(xh(t,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(t,n){return n=(n||[]).map(s=>Yr.from(s)),new ss(ir,t,"view",n,[],null).selector}static from(t){if(ss.isFragment(t))return t;if(typeof t=="string")try{return ss.from(Do(t))}catch{q(!1,"invalid function fragment","obj",t)}else if(t instanceof ki){const i=Pp("function",t),s=zs(t),o=aN(t);let a=[];Hs(t,vn(["returns"])).has("returns")&&(a=zs(t));const u=cN(t);return Xa(t),new ss(ir,i,o,s,a,u)}let n=t.stateMutability;return n==null&&(n="payable",typeof t.constant=="boolean"?(n="view",t.constant||(n="payable",typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable")),new ss(ir,t.name,n,t.inputs?t.inputs.map(Yr.from):[],t.outputs?t.outputs.map(Yr.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Mn]===gN}}class tc extends Mp{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Mn,{value:yN})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return tc.from(Do(e))}catch{q(!1,"invalid struct fragment","obj",e)}else if(e instanceof ki){const t=Pp("struct",e),n=zs(e);return Xa(e),new tc(ir,t,n)}return new tc(ir,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Mn]===yN}}const Ti=new Map;Ti.set(0,"GENERIC_PANIC"),Ti.set(1,"ASSERT_FALSE"),Ti.set(17,"OVERFLOW"),Ti.set(18,"DIVIDE_BY_ZERO"),Ti.set(33,"ENUM_RANGE_ERROR"),Ti.set(34,"BAD_STORAGE_DATA"),Ti.set(49,"STACK_UNDERFLOW"),Ti.set(50,"ARRAY_RANGE_ERROR"),Ti.set(65,"OUT_OF_MEMORY"),Ti.set(81,"UNINITIALIZED_FUNCTION_CALL");const Pte=new RegExp(/^bytes([0-9]*)$/),Mte=new RegExp(/^(u?int)([0-9]*)$/);let Ww=null,mN=1024;function Lte(r,e,t,n){let i="missing revert data",s=null;const o=null;let a=null;if(t){i="execution reverted";const l=_t(t);if(t=Ce(t),l.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(l.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(Ce(l.slice(0,4))==="0x08c379a0")try{s=n.decode(["string"],l.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(Ce(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Ti.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:e.to?Mt(e.to):null,data:e.data||"0x"};return e.from&&(u.from=Mt(e.from)),Yt(i,"CALL_EXCEPTION",{action:r,data:t,reason:s,transaction:u,invocation:o,revert:a})}const Yp=class Yp{constructor(){se(this,Vo)}getDefaultValue(e){const t=e.map(i=>Ee(this,Vo,Kl).call(this,Yr.from(i)));return new vp(t,"_").defaultValue()}encode(e,t){Yk(t.length,e.length,"types/values length mismatch");const n=e.map(o=>Ee(this,Vo,Kl).call(this,Yr.from(o))),i=new vp(n,"_"),s=new uw;return i.encode(s,t),s.data}decode(e,t,n){const i=e.map(o=>Ee(this,Vo,Kl).call(this,Yr.from(o)));return new vp(i,"_").decode(new lw(t,n,mN))}static _setDefaultMaxInflation(e){q(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),mN=e}static defaultAbiCoder(){return Ww==null&&(Ww=new Yp),Ww}static getBuiltinCallException(e,t,n){return Lte(e,t,n,Yp.defaultAbiCoder())}};Vo=new WeakSet,Kl=function(e){if(e.isArray())return new aee(Ee(this,Vo,Kl).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new vp(e.components.map(n=>Ee(this,Vo,Kl).call(this,n)),e.name);switch(e.baseType){case"address":return new see(e.name);case"bool":return new cee(e.name);case"string":return new mee(e.name);case"bytes":return new uee(e.name);case"":return new hee(e.name)}let t=e.type.match(Mte);if(t){let n=parseInt(t[2]||"256");return q(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new yee(n/8,t[1]==="int",e.name)}if(t=e.type.match(Pte),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,"invalid bytes length","param",e),new lee(n,e.name)}q(!1,"invalid type","type",e.type)};let Rh=Yp;class Ute{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"signature");Q(this,"topic");Q(this,"args");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,signature:s,topic:t,args:n})}}class Dte{constructor(e,t,n,i){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");Q(this,"value");const s=e.name,o=e.format();ze(this,{fragment:e,name:s,args:n,signature:o,selector:t,value:i})}}class $te{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,args:n,signature:s,selector:t})}}class wN{constructor(e){Q(this,"hash");Q(this,"_isIndexed");ze(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const bN={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"},_N={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let e="unknown panic code";return r>=0&&r<=255&&bN[r.toString()]&&(e=bN[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}},wc=class wc{constructor(e){se(this,hs);Q(this,"fragments");Q(this,"deploy");Q(this,"fallback");Q(this,"receive");se(this,us);se(this,ls);se(this,fs);se(this,cn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,F(this,fs,new Map),F(this,us,new Map),F(this,ls,new Map);const n=[];for(const o of t)try{n.push(ec.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}ze(this,{fragments:Object.freeze(n)});let i=null,s=!1;F(this,cn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}ze(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(q(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${a}]`,o),i=o,s=i.payable);return;case"function":u=T(this,fs);break;case"event":u=T(this,ls);break;case"error":u=T(this,us);break;default:return}const l=o.format();u.has(l)||u.set(l,o)}),this.deploy||ze(this,{deploy:Gs.from("constructor()")}),ze(this,{fallback:i,receive:s})}format(e){const t=e?"minimal":"full";return this.fragments.map(i=>i.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Rh.defaultAbiCoder()}getFunctionName(e){const t=Ee(this,hs,bg).call(this,e,null,!1);return q(t,"no matching function","key",e),t.name}hasFunction(e){return!!Ee(this,hs,bg).call(this,e,null,!1)}getFunction(e,t){return Ee(this,hs,bg).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,fs).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,fs).get(i),n)}}getEventName(e){const t=Ee(this,hs,_g).call(this,e,null,!1);return q(t,"no matching event","key",e),t.name}hasEvent(e){return!!Ee(this,hs,_g).call(this,e,null,!1)}getEvent(e,t){return Ee(this,hs,_g).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,ls).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,ls).get(i),n)}}getError(e,t){if(Gt(e)){const i=e.toLowerCase();if(_N[i])return Ln.from(_N[i].signature);for(const s of T(this,us).values())if(i===s.selector)return s;return null}if(e.indexOf("(")===-1){const i=[];for(const[s,o]of T(this,us))s.split("(")[0]===e&&i.push(o);if(i.length===0)return e==="Error"?Ln.from("error Error(string)"):e==="Panic"?Ln.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");q(!1,`ambiguous error description (i.e. ${s})`,"name",e)}return i[0]}if(e=Ln.from(e).format(),e==="Error(string)")return Ln.from("error Error(string)");if(e==="Panic(uint256)")return Ln.from("error Panic(uint256)");const n=T(this,us).get(e);return n||null}forEachError(e){const t=Array.from(T(this,us).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,us).get(i),n)}}_decodeParams(e,t){return T(this,cn).decode(e,t)}_encodeParams(e,t){return T(this,cn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return q(lr(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,lr(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return xr([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return q(lr(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,lr(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return xr([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const s=this.getFunction(e);q(s,"unknown function","fragment",e),e=s}let n="invalid length for result data";const i=wn(t);if(i.length%32===0)try{return T(this,cn).decode(e.outputs,i)}catch{n="could not decode result data"}ge(!1,n,"BAD_DATA",{value:Ce(i),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=_t(e,"data"),i=Rh.getBuiltinCallException("call",t,n);if(i.message.startsWith("execution reverted (unknown custom error)")){const a=Ce(n.slice(0,4)),u=this.getError(a);if(u)try{const l=T(this,cn).decode(u.inputs,n.slice(4));i.revert={name:u.name,signature:u.format(),args:l},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(t);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return Ce(T(this,cn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const s=this.getEvent(e);q(s,"unknown event","eventFragment",e),e=s}ge(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const i=(s,o)=>s.type==="string"?Za(o):s.type==="bytes"?Nr(Ce(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=No(o):s.type.match(/^bytes/)?o=_J(o,32):s.type==="address"&&T(this,cn).encode(["address"],[o]),Ga(Ce(o),32));for(t.forEach((s,o)=>{const a=e.inputs[o];if(!a.indexed){q(s==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?q(!1,"filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?n.push(s.map(u=>i(a,u))):n.push(i(a,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);q(o,"unknown event","eventFragment",e),e=o}const n=[],i=[],s=[];return e.anonymous||n.push(e.topicHash),q(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const u=t[a];if(o.indexed)if(o.type==="string")n.push(Za(u));else if(o.type==="bytes")n.push(Nr(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(T(this,cn).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:T(this,cn).encode(i,s),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const w=this.getEvent(e);q(w,"unknown event","eventFragment",e),e=w}if(n!=null&&!e.anonymous){const w=e.topicHash;q(Gt(n[0],32)&&n[0].toLowerCase()===w,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const i=[],s=[],o=[];e.inputs.forEach((w,I)=>{w.indexed?w.type==="string"||w.type==="bytes"||w.baseType==="tuple"||w.baseType==="array"?(i.push(Yr.from({type:"bytes32",name:w.name})),o.push(!0)):(i.push(w),o.push(!1)):(s.push(w),o.push(!1))});const a=n!=null?T(this,cn).decode(i,xr(n)):null,u=T(this,cn).decode(s,t,!0),l=[],h=[];let g=0,b=0;return e.inputs.forEach((w,I)=>{let S=null;if(w.indexed)if(a==null)S=new wN(null);else if(o[I])S=new wN(a[b++]);else try{S=a[b++]}catch(x){S=x}else try{S=u[g++]}catch(x){S=x}l.push(S),h.push(w.name||null)}),Bu.fromItems(l,h)}parseTransaction(e){const t=_t(e.data,"tx.data"),n=Le(e.value!=null?e.value:0,"tx.value"),i=this.getFunction(Ce(t.slice(0,4)));if(!i)return null;const s=T(this,cn).decode(i.inputs,t.slice(4));return new Dte(i,i.selector,s,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Ute(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=Ce(e),n=this.getError(lr(t,0,4));if(!n)return null;const i=T(this,cn).decode(n.inputs,lr(t,4));return new $te(n,n.selector,i)}static from(e){return e instanceof wc?e:typeof e=="string"?new wc(JSON.parse(e)):typeof e.formatJson=="function"?new wc(e.formatJson()):typeof e.format=="function"?new wc(e.format("json")):new wc(e)}};us=new WeakMap,ls=new WeakMap,fs=new WeakMap,cn=new WeakMap,hs=new WeakSet,bg=function(e,t,n){if(Gt(e)){const s=e.toLowerCase();for(const o of T(this,fs).values())if(s===o.selector)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,fs))o.split("(")[0]===e&&s.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,u=!0;an.isTyped(o)&&o.type==="overrides"&&(u=!1,a--);for(let l=s.length-1;l>=0;l--){const h=s[l].inputs.length;h!==a&&(!u||h!==a-1)&&s.splice(l,1)}for(let l=s.length-1;l>=0;l--){const h=s[l].inputs;for(let g=0;g<t.length;g++)if(an.isTyped(t[g])){if(g>=h.length){if(t[g].type==="overrides")continue;s.splice(l,1);break}if(t[g].type!==h[g].baseType){s.splice(l,1);break}}}}if(s.length===1&&t&&t.length!==s[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,fs).get(ss.from(e).format());return i||null},_g=function(e,t,n){if(Gt(e)){const s=e.toLowerCase();for(const o of T(this,ls).values())if(s===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,ls))o.split("(")[0]===e&&s.push(a);if(t){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<t.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const a=s[o].inputs;for(let u=0;u<t.length;u++)if(an.isTyped(t[u])&&t[u].type!==a[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,ls).get(is.from(e).format());return i||null};let qw=wc;const AN=BigInt(0);function Vu(r){return r??null}function Sr(r){return r==null?null:r.toString()}class vN{constructor(e,t,n){Q(this,"gasPrice");Q(this,"maxFeePerGas");Q(this,"maxPriorityFeePerGas");ze(this,{gasPrice:Vu(e),maxFeePerGas:Vu(t),maxPriorityFeePerGas:Vu(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Sr(e),maxFeePerGas:Sr(t),maxPriorityFeePerGas:Sr(n)}}}function Lp(r){const e={};r.to&&(e.to=r.to),r.from&&(e.from=r.from),r.data&&(e.data=Ce(r.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of t)!(i in r)||r[i]==null||(e[i]=Le(r[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)!(i in r)||r[i]==null||(e[i]=at(r[i],`request.${i}`));return r.accessList&&(e.accessList=Ja(r.accessList)),"blockTag"in r&&(e.blockTag=r.blockTag),"enableCcipRead"in r&&(e.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(e.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(e.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(e.kzg=r.kzg),"blobs"in r&&r.blobs&&(e.blobs=r.blobs.map(i=>iw(i)?Ce(i):Object.assign({},i))),e}class Fte{constructor(e,t){Q(this,"provider");Q(this,"number");Q(this,"hash");Q(this,"timestamp");Q(this,"parentHash");Q(this,"parentBeaconBlockRoot");Q(this,"nonce");Q(this,"difficulty");Q(this,"gasLimit");Q(this,"gasUsed");Q(this,"stateRoot");Q(this,"receiptsRoot");Q(this,"blobGasUsed");Q(this,"excessBlobGas");Q(this,"miner");Q(this,"prevRandao");Q(this,"extraData");Q(this,"baseFeePerGas");se(this,Xs);F(this,Xs,e.transactions.map(n=>typeof n!="string"?new Sh(n,t):n)),ze(this,{provider:t,hash:Vu(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Vu(e.prevRandao),extraData:e.extraData,baseFeePerGas:Vu(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Xs).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Xs).slice();return e.length===0?[]:(ge(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:i,gasUsed:s,hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,timestamp:S,transactions:x}=this;return{_type:"Block",baseFeePerGas:Sr(e),difficulty:Sr(t),extraData:n,gasLimit:Sr(i),gasUsed:Sr(s),blobGasUsed:Sr(this.blobGasUsed),excessBlobGas:Sr(this.excessBlobGas),hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,timestamp:S,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,transactions:x}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Xs).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Xs)[e];else{const n=e.toLowerCase();for(const i of T(this,Xs))if(typeof i=="string"){if(i!==n)continue;t=i;break}else{if(i.hash!==n)continue;t=i;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;q(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return Hte(this)}}Xs=new WeakMap;class Ih{constructor(e,t){Q(this,"provider");Q(this,"transactionHash");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"removed");Q(this,"address");Q(this,"data");Q(this,"topics");Q(this,"index");Q(this,"transactionIndex");this.provider=t;const n=Object.freeze(e.topics.slice());ze(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ge(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ge(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ge(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return zte(this)}}class EN{constructor(e,t){Q(this,"provider");Q(this,"to");Q(this,"from");Q(this,"contractAddress");Q(this,"hash");Q(this,"index");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"logsBloom");Q(this,"gasUsed");Q(this,"blobGasUsed");Q(this,"cumulativeGasUsed");Q(this,"gasPrice");Q(this,"blobGasPrice");Q(this,"type");Q(this,"status");Q(this,"root");se(this,Lh);F(this,Lh,Object.freeze(e.logs.map(i=>new Ih(i,t))));let n=AN;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),ze(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Lh)}toJSON(){const{to:e,from:t,contractAddress:n,hash:i,index:s,blockHash:o,blockNumber:a,logsBloom:u,logs:l,status:h,root:g}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:Sr(this.cumulativeGasUsed),from:t,gasPrice:Sr(this.gasPrice),blobGasUsed:Sr(this.blobGasUsed),blobGasPrice:Sr(this.blobGasPrice),gasUsed:Sr(this.gasUsed),hash:i,index:s,logs:l,logsBloom:u,root:g,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return RN(this)}reorderedEvent(e){return ge(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),xN(this,e)}}Lh=new WeakMap;const mb=class mb{constructor(e,t){Q(this,"provider");Q(this,"blockNumber");Q(this,"blockHash");Q(this,"index");Q(this,"hash");Q(this,"type");Q(this,"to");Q(this,"from");Q(this,"nonce");Q(this,"gasLimit");Q(this,"gasPrice");Q(this,"maxPriorityFeePerGas");Q(this,"maxFeePerGas");Q(this,"maxFeePerBlobGas");Q(this,"data");Q(this,"value");Q(this,"chainId");Q(this,"signature");Q(this,"accessList");Q(this,"blobVersionedHashes");se(this,jo);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,F(this,jo,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:i,type:s,to:o,from:a,nonce:u,data:l,signature:h,accessList:g,blobVersionedHashes:b}=this;return{_type:"TransactionResponse",accessList:g,blockNumber:e,blockHash:t,blobVersionedHashes:b,chainId:Sr(this.chainId),data:l,from:a,gasLimit:Sr(this.gasLimit),gasPrice:Sr(this.gasPrice),hash:i,maxFeePerGas:Sr(this.maxFeePerGas),maxPriorityFeePerGas:Sr(this.maxPriorityFeePerGas),maxFeePerBlobGas:Sr(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:n,type:s,value:Sr(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await mn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,i=t??0;let s=T(this,jo),o=-1,a=s===-1;const u=async()=>{if(a)return null;const{blockNumber:b,nonce:w}=await mn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(w<this.nonce){s=b;return}if(a)return null;const I=await this.getTransaction();if(!(I&&I.blockNumber!=null))for(o===-1&&(o=s-3,o<T(this,jo)&&(o=T(this,jo)));o<=b;){if(a)return null;const S=await this.provider.getBlock(o,!0);if(S==null)return;for(const x of S)if(x===this.hash)return;for(let x=0;x<S.length;x++){const C=await S.getTransaction(x);if(C.from===this.from&&C.nonce===this.nonce){if(a)return null;const H=await this.provider.getTransactionReceipt(C.hash);if(H==null||b-H.blockNumber+1<n)return;let D="replaced";C.data===this.data&&C.to===this.to&&C.value===this.value?D="repriced":C.data==="0x"&&C.from===C.to&&C.value===AN&&(D="cancelled"),ge(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:D==="replaced"||D==="cancelled",reason:D,replacement:C.replaceableTransaction(s),hash:C.hash,receipt:H})}}o++}},l=b=>{if(b==null||b.status!==0)return b;ge(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:b.to,from:b.from,data:""},receipt:b})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(await h.confirmations()>=n)return l(h)}else if(await u(),n===0)return null;return await new Promise((b,w)=>{const I=[],S=()=>{I.forEach(C=>C())};if(I.push(()=>{a=!0}),i>0){const C=setTimeout(()=>{S(),w(Yt("wait for transaction timeout","TIMEOUT"))},i);I.push(()=>{clearTimeout(C)})}const x=async C=>{if(await C.confirmations()>=n){S();try{b(l(C))}catch(H){w(H)}}};if(I.push(()=>{this.provider.off(this.hash,x)}),this.provider.on(this.hash,x),s>=0){const C=async()=>{try{await u()}catch(H){if(Qr(H,"TRANSACTION_REPLACED")){S(),w(H);return}}a||this.provider.once("block",C)};I.push(()=>{this.provider.off("block",C)}),this.provider.once("block",C)}})}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 ge(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),RN(this)}reorderedEvent(e){return ge(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ge(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),xN(this,e)}replaceableTransaction(e){q(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new mb(this,this.provider);return F(t,jo,e),t}};jo=new WeakMap;let Sh=mb;function Hte(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function xN(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function RN(r){return{orphan:"drop-transaction",tx:r}}function zte(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Zw extends Ih{constructor(t,n,i){super(t,t.provider);Q(this,"interface");Q(this,"fragment");Q(this,"args");const s=n.decodeEventLog(i,t.data,t.topics);ze(this,{args:s,fragment:i,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class IN extends Ih{constructor(t,n){super(t,t.provider);Q(this,"error");ze(this,{error:n})}}class Gte extends EN{constructor(t,n,i){super(i,n);se(this,Al);F(this,Al,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?T(this,Al).getEvent(t.topics[0]):null;if(n)try{return new Zw(t,T(this,Al),n)}catch(i){return new IN(t,i)}return t})}}Al=new WeakMap;class Qw extends Sh{constructor(t,n,i){super(i,n);se(this,Uh);F(this,Uh,t)}async wait(t,n){const i=await super.wait(t,n);return i==null?null:new Gte(T(this,Uh),this.provider,i)}}Uh=new WeakMap;class SN extends sT{constructor(t,n,i,s){super(t,n,i);Q(this,"log");ze(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 Vte extends SN{constructor(e,t,n,i,s){super(e,t,n,new Zw(s,e.interface,i));const o=e.interface.decodeEventLog(i,this.log.data,this.log.topics);ze(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const kN=BigInt(0);function TN(r){return r&&typeof r.call=="function"}function ON(r){return r&&typeof r.estimateGas=="function"}function Up(r){return r&&typeof r.resolveName=="function"}function NN(r){return r&&typeof r.sendTransaction=="function"}function CN(r){if(r!=null){if(Up(r))return r;if(r.provider)return r.provider}}class jte{constructor(e,t,n){se(this,Dh);Q(this,"fragment");if(ze(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const i=rc(e.runner,"resolveName"),s=Up(i)?i:null;F(this,Dh,async function(){const o=await Promise.all(t.inputs.map((a,u)=>n[u]==null?null:a.walkAsync(n[u],(h,g)=>h==="address"?Array.isArray(g)?Promise.all(g.map(b=>An(b,s))):An(g,s):g)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Dh)}}Dh=new WeakMap;function rc(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function nc(r){return r==null?null:r.provider||null}async function BN(r,e){const t=an.dereference(r,"overrides");q(typeof t=="object","invalid overrides parameter","overrides",r);const n=Lp(t);return q(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),q(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function Kte(r,e,t){const n=rc(r,"resolveName"),i=Up(n)?n:null;return await Promise.all(e.map((s,o)=>s.walkAsync(t[o],(a,u)=>(u=an.dereference(u,a),a==="address"?An(u,i):u))))}function Wte(r){const e=async function(o){const a=await BN(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await An(a.from,CN(r.runner)));const u=r.interface,l=Le(a.value||kN,"overrides.value")===kN,h=(a.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!l&&q(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const g=u.receive||u.fallback&&u.fallback.payable;return q(g||l,"cannot send value to non-payable fallback","overrides.value",a.value),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=rc(r.runner,"call");ge(TN(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await e(o);try{return await a.call(u)}catch(l){throw nw(l)&&l.data?r.interface.makeError(l.data,u):l}},n=async function(o){const a=r.runner;ge(NN(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await e(o)),l=nc(r.runner);return new Qw(r.interface,l,u)},i=async function(o){const a=rc(r.runner,"estimateGas");return ge(ON(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},s=async o=>await n(o);return ze(s,{_contract:r,estimateGas:i,populateTransaction:e,send:n,staticCall:t}),s}function qte(r,e){const t=function(...l){const h=r.interface.getFunction(e,l);return ge(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let g={};if(h.inputs.length+1===l.length&&(g=await BN(l.pop()),g.from&&(g.from=await An(g.from,CN(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const b=await Kte(r.runner,h.inputs,l);return Object.assign({},g,await mn({to:r.getAddress(),data:r.interface.encodeFunctionData(h,b)}))},i=async function(...l){const h=await a(...l);return h.length===1?h[0]:h},s=async function(...l){const h=r.runner;ge(NN(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const g=await h.sendTransaction(await n(...l)),b=nc(r.runner);return new Qw(r.interface,b,g)},o=async function(...l){const h=rc(r.runner,"estimateGas");return ge(ON(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=rc(r.runner,"call");ge(TN(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const g=await n(...l);let b="0x";try{b=await h.call(g)}catch(I){throw nw(I)&&I.data?r.interface.makeError(I.data,g):I}const w=t(...l);return r.interface.decodeFunctionResult(w,b)},u=async(...l)=>t(...l).constant?await i(...l):await s(...l);return ze(u,{name:r.interface.getFunctionName(e),_contract:r,_key:e,getFragment:t,estimateGas:o,populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=r.interface.getFunction(e);return ge(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),u}function Zte(r,e){const t=function(...i){const s=r.interface.getEvent(e,i);return ge(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:i}}),s},n=function(...i){return new jte(r,t(...i),i)};return ze(n,{name:r.interface.getEventName(e),_contract:r,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=r.interface.getEvent(e);return ge(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),i}}),n}const Dp=Symbol.for("_ethersInternal_contract"),PN=new WeakMap;function Qte(r,e){PN.set(r[Dp],e)}function Wn(r){return PN.get(r[Dp])}function Yte(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function Yw(r,e){let t,n=null;if(Array.isArray(e)){const s=function(o){if(Gt(o,32))return o;const a=r.interface.getEvent(o);return q(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else e==="*"?t=[null]:typeof e=="string"?Gt(e,32)?t=[e]:(n=r.interface.getEvent(e),q(n,"unknown fragment","event",e),t=[n.topicHash]):Yte(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):q(!1,"unknown event name","event",e);t=t.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=t.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:n,tag:i,topics:t}}async function kh(r,e){const{subs:t}=Wn(r);return t.get((await Yw(r,e)).tag)||null}async function MN(r,e,t){const n=nc(r.runner);ge(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=await Yw(r,t),{addr:a,subs:u}=Wn(r);let l=u.get(s);if(!l){const g={address:a||r,topics:o},b=x=>{let C=i;if(C==null)try{C=r.interface.getEvent(x.topics[0])}catch{}if(C){const H=C,D=i?r.interface.decodeEventLog(i,x.data,x.topics):[];Xw(r,t,D,z=>new Vte(r,z,t,H,x))}else Xw(r,t,[],H=>new SN(r,H,t,x))};let w=[];l={tag:s,listeners:[],start:()=>{w.length||w.push(n.on(g,b))},stop:async()=>{if(w.length==0)return;let x=w;w=[],await Promise.all(x),n.off(g,b)}},u.set(s,l)}return l}let Jw=Promise.resolve();async function Jte(r,e,t,n){await Jw;const i=await kh(r,e);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:a})=>{const u=Array.from(t);n&&u.push(n(a?null:o));try{o.call(r,...u)}catch{}return!a}),i.listeners.length===0&&(i.stop(),Wn(r).subs.delete(i.tag)),s>0}async function Xw(r,e,t,n){try{await Jw}catch{}const i=Jte(r,e,t,n);return Jw=i,await i}const $p=["then"];eC=Dp;const $h=class $h{constructor(e,t,n,i){Q(this,"target");Q(this,"interface");Q(this,"runner");Q(this,"filters");Q(this,eC);Q(this,"fallback");q(typeof e=="string"||gO(e),"invalid value for Contract target","target",e),n==null&&(n=null);const s=qw.from(t);ze(this,{target:e,runner:n,interface:s}),Object.defineProperty(this,Dp,{value:{}});let o,a=null,u=null;if(i){const g=nc(n);u=new Qw(this.interface,g,i)}let l=new Map;if(typeof e=="string")if(Gt(e))a=e,o=Promise.resolve(e);else{const g=rc(n,"resolveName");if(!Up(g))throw Yt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=g.resolveName(e).then(b=>{if(b==null)throw Yt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Wn(this).addr=b,b})}else o=e.getAddress().then(g=>{if(g==null)throw new Error("TODO");return Wn(this).addr=g,g});Qte(this,{addrPromise:o,addr:a,deployTx:u,subs:l});const h=new Proxy({},{get:(g,b,w)=>{if(typeof b=="symbol"||$p.indexOf(b)>=0)return Reflect.get(g,b,w);try{return this.getEvent(b)}catch(I){if(!Qr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>$p.indexOf(b)>=0?Reflect.has(g,b):Reflect.has(g,b)||this.interface.hasEvent(String(b))});return ze(this,{filters:h}),ze(this,{fallback:s.receive||s.fallback?Wte(this):null}),new Proxy(this,{get:(g,b,w)=>{if(typeof b=="symbol"||b in g||$p.indexOf(b)>=0)return Reflect.get(g,b,w);try{return g.getFunction(b)}catch(I){if(!Qr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>typeof b=="symbol"||b in g||$p.indexOf(b)>=0?Reflect.has(g,b):g.interface.hasFunction(b)})}connect(e){return new $h(this.target,this.interface,e)}attach(e){return new $h(e,this.interface,this.runner)}async getAddress(){return await Wn(this).addrPromise}async getDeployedCode(){const e=nc(this.runner);ge(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=nc(this.runner);return ge(n!=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);n.once("block",o)}catch(a){s(a)}};o()})}deploymentTransaction(){return Wn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),qte(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),Zte(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:i,addrPromise:s}=Wn(this),o=i||await s,{fragment:a,topics:u}=await Yw(this,e),l={address:o,topics:u,fromBlock:t,toBlock:n},h=nc(this.runner);return ge(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(g=>{let b=a;if(b==null)try{b=this.interface.getEvent(g.topics[0])}catch{}if(b)try{return new Zw(g,this.interface,b)}catch(w){return new IN(g,w)}return new Ih(g,h)})}async on(e,t){const n=await MN(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await MN(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await Xw(this,e,t,null)}async listenerCount(e){if(e){const i=await kh(this,e);return i?i.listeners.length:0}const{subs:t}=Wn(this);let n=0;for(const{listeners:i}of t.values())n+=i.length;return n}async listeners(e){if(e){const i=await kh(this,e);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:t}=Wn(this);let n=[];for(const{listeners:i}of t.values())n=n.concat(i.map(({listener:s})=>s));return n}async off(e,t){const n=await kh(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(t==null||n.listeners.length===0)&&(n.stop(),Wn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await kh(this,e);if(!t)return this;t.stop(),Wn(this).subs.delete(t.tag)}else{const{subs:t}=Wn(this);for(const{tag:n,stop:i}of t.values())i(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends $h{constructor(i,s=null){super(i,e,s)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}};let eb=$h;function Xte(){return eb}class ju extends Xte(){}function tb(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):q(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class ere{constructor(e){Q(this,"name");ze(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const LN=new RegExp("^(ipfs)://(.*)$","i"),UN=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),LN,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],vl=class vl{constructor(e,t,n){se(this,Wo);Q(this,"provider");Q(this,"address");Q(this,"name");se(this,Ko);se(this,bc);ze(this,{provider:e,address:t,name:n}),F(this,Ko,null),F(this,bc,new ju(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Ko)==null&&F(this,Ko,(async()=>{try{return await T(this,bc).supportsInterface("0x9061b923")}catch(e){if(Qr(e,"CALL_EXCEPTION"))return!1;throw F(this,Ko,null),e}})()),await T(this,Ko)}async getAddress(e){if(e==null&&(e=60),e===60)try{const s=await Ee(this,Wo,Wl).call(this,"addr(bytes32)");return s==null||s===gh?null:s}catch(s){if(Qr(s,"CALL_EXCEPTION"))return null;throw s}if(e>=0&&e<2147483648){let s=e+2147483648;const o=await Ee(this,Wo,Wl).call(this,"addr(bytes32,uint)",[s]);if(Gt(o,20))return Mt(o)}let t=null;for(const s of this.provider.plugins)if(s instanceof ere&&s.supportsCoinType(e)){t=s;break}if(t==null)return null;const n=await Ee(this,Wo,Wl).call(this,"addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const i=await t.decodeAddress(e,n);if(i!=null)return i;ge(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await Ee(this,Wo,Wl).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await Ee(this,Wo,Wl).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const i=t[1]==="e3010170"?"ipfs":"ipns",s=parseInt(t[4],16);if(t[5].length===s*2)return`${i}://${EJ("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;ge(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<UN.length;n++){const i=t.match(UN[n]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=tb(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:s,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const u=(i[2]||"").split("/");if(u.length!==2)return e.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:e};const l=u[1],h=new ju(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 S=await h.ownerOf(l);if(a!==S)return e.push({type:"!owner",value:S}),{url:null,linkage:e};e.push({type:"owner",value:S})}else if(s==="erc1155"){const S=await h.balanceOf(a,l);if(!S)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:S.toString()})}let g=await h[o](l);if(g==null||g==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:g}),s==="erc1155"&&(g=g.replace("{id}",No(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:g})),g.match(/^ipfs:/i)&&(g=tb(g)),e.push({type:"metadata-url",value:g});let b={};const w=await new Us(g).send();w.assertOk();try{b=w.bodyJson}catch{try{e.push({type:"!metadata",value:w.bodyText})}catch{const C=w.body;return C&&e.push({type:"!metadata",value:Ce(C)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!b)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(b)});let I=b.image;if(typeof I!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!I.match(/^(https:\/\/|data:)/i)){if(I.match(LN)==null)return e.push({type:"!imageUrl-ipfs",value:I}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:I}),I=tb(I)}return e.push({type:"url",value:I}),{linkage:e,url:I}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return ge(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async fromName(e,t){var i;let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const s=await Ee(i=vl,Jp,d6).call(i,e,n);if(s!=null){const o=new vl(e,s,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Ko=new WeakMap,bc=new WeakMap,Wo=new WeakSet,Wl=async function(e,t){t=(t||[]).slice();const n=T(this,bc).interface;t.unshift($w(this.name));let i=null;await this.supportsWildcard()&&(i=n.getFunction(e),ge(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[tte(this.name,255),n.encodeFunctionData(i,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const s=await T(this,bc)[e](...t);return i?n.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Qr(s,"CALL_EXCEPTION"))throw s}return null},Jp=new WeakSet,d6=async function(e,t){const n=await vl.getEnsAddress(e);try{const s=await new ju(n,["function resolver(bytes32) view returns (address)"],e).resolver($w(t),{enableCcipRead:!0});return s===gh?null:s}catch(i){throw i}return null},se(vl,Jp);let Fp=vl;const DN=BigInt(0);function wt(r,e){return function(t){return t==null?e:r(t)}}function Hp(r,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>r(n))}}function Th(r,e){return t=>{const n={};for(const i in r){let s=i;if(e&&i in e&&!(s in t)){for(const o of e[i])if(o in t){s=o;break}}try{const o=r[i](t[s]);o!==void 0&&(n[i]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ge(!1,`invalid value for value.${i} (${a})`,"BAD_DATA",{value:t})}}return n}}function tre(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}q(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Ku(r){return q(Gt(r,!0),"invalid data","value",r),r}function Jr(r){return q(Gt(r,32),"invalid hash","value",r),r}const rre=Th({address:Mt,blockHash:Jr,blockNumber:at,data:Ku,index:at,removed:wt(tre,!1),topics:Hp(Jr),transactionHash:Jr,transactionIndex:at},{index:["logIndex"]});function nre(r){return rre(r)}const ire=Th({hash:wt(Jr),parentHash:Jr,parentBeaconBlockRoot:wt(Jr,null),number:at,timestamp:at,nonce:wt(Ku),difficulty:Le,gasLimit:Le,gasUsed:Le,stateRoot:wt(Jr,null),receiptsRoot:wt(Jr,null),blobGasUsed:wt(Le,null),excessBlobGas:wt(Le,null),miner:wt(Mt),prevRandao:wt(Jr,null),extraData:Ku,baseFeePerGas:wt(Le)},{prevRandao:["mixHash"]});function sre(r){const e=ire(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:$N(t)),e}const ore=Th({transactionIndex:at,blockNumber:at,transactionHash:Jr,address:Mt,topics:Hp(Jr),data:Ku,index:at,blockHash:Jr},{index:["logIndex"]});function are(r){return ore(r)}const cre=Th({to:wt(Mt,null),from:wt(Mt,null),contractAddress:wt(Mt,null),index:at,root:wt(Ce),gasUsed:Le,blobGasUsed:wt(Le,null),logsBloom:wt(Ku),blockHash:Jr,hash:Jr,logs:Hp(are),blockNumber:at,cumulativeGasUsed:Le,effectiveGasPrice:wt(Le),blobGasPrice:wt(Le,null),status:wt(at),type:wt(at,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function ure(r){return cre(r)}function $N(r){r.to&&Le(r.to)===DN&&(r.to="0x0000000000000000000000000000000000000000");const e=Th({hash:Jr,index:wt(at,void 0),type:t=>t==="0x"||t==null?0:at(t),accessList:wt(Ja,null),blobVersionedHashes:wt(Hp(Jr,!0),null),blockHash:wt(Jr,null),blockNumber:wt(at,null),transactionIndex:wt(at,null),from:Mt,gasPrice:wt(Le),maxPriorityFeePerGas:wt(Le),maxFeePerGas:wt(Le),maxFeePerBlobGas:wt(Le,null),gasLimit:Le,to:wt(Mt,null),value:Le,nonce:at,data:Ku,creates:wt(Mt,null),chainId:wt(Le,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=iee(e)),(r.type===1||r.type===2)&&r.accessList==null&&(e.accessList=[]),r.signature?e.signature=Si.from(r.signature):e.signature=Si.from(r),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Le(e.blockHash)===DN&&(e.blockHash=null),e}const lre="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Oh{constructor(e){Q(this,"name");ze(this,{name:e})}clone(){return new Oh(this.name)}}class zp extends Oh{constructor(t,n){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);Q(this,"effectiveBlock");Q(this,"txBase");Q(this,"txCreate");Q(this,"txDataZero");Q(this,"txDataNonzero");Q(this,"txAccessListStorageKey");Q(this,"txAccessListAddress");const i={effectiveBlock:t};function s(o,a){let u=(n||{})[o];u==null&&(u=a),q(typeof u=="number",`invalud value for ${o}`,"costs",n),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),ze(this,i)}clone(){return new zp(this.effectiveBlock,this)}}class Gp extends Oh{constructor(t,n){super("org.ethers.plugins.network.Ens");Q(this,"address");Q(this,"targetNetwork");ze(this,{address:t||lre,targetNetwork:n??1})}clone(){return new Gp(this.address,this.targetNetwork)}}class fre extends Oh{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");se(this,Fh);se(this,Hh);F(this,Fh,t),F(this,Hh,n)}get url(){return T(this,Fh)}get processFunc(){return T(this,Hh)}clone(){return this}}Fh=new WeakMap,Hh=new WeakMap;const rb=new Map,Rl=class Rl{constructor(e,t){se(this,El);se(this,xl);se(this,qo);F(this,El,e),F(this,xl,Le(t)),F(this,qo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,El)}set name(e){F(this,El,e)}get chainId(){return T(this,xl)}set chainId(e){F(this,xl,Le(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Le(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Le(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Le(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,qo).values())}attachPlugin(e){if(T(this,qo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,qo).set(e.name,e.clone()),this}getPlugin(e){return T(this,qo).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new Rl(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new zp;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let i=2;i<e.data.length;i+=2)e.data.substring(i,i+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const i=Ja(e.accessList);for(const s in i)n+=t.txAccessListAddress+t.txAccessListStorageKey*i[s].storageKeys.length}return n}static from(e){if(hre(),e==null)return Rl.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=rb.get(e);if(t)return t();if(typeof e=="bigint")return new Rl("unknown",e);q(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){q(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new Rl(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Gp(e.ensAddress,e.ensNetwork)),t}q(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=rb.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),rb.set(e,t)}};El=new WeakMap,xl=new WeakMap,qo=new WeakMap;let os=Rl;function FN(r,e){const t=String(r);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${r}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${r}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let i=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||i++,n[1]=i.toString()}return BigInt(n[0]+n[1])}function HN(r){return new fre(r,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([n.send(),e()]);i=s;const a=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:FN(a.maxFee,9),maxPriorityFeePerGas:FN(a.maxPriorityFee,9)}}catch(s){ge(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:i,error:s})}})}let zN=!1;function hre(){if(zN)return;zN=!0;function r(e,t,n){const i=function(){const s=new os(e,t);return n.ensNetwork!=null&&s.attachPlugin(new Gp(null,n.ensNetwork)),s.attachPlugin(new zp),(n.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};os.register(e,i),os.register(t,i),n.altNames&&n.altNames.forEach(s=>{os.register(s,i)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{ensNetwork:11155111}),r("holesky",17e3,{ensNetwork:17e3}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("arbitrum-sepolia",421614,{}),r("base",8453,{ensNetwork:1}),r("base-goerli",84531,{}),r("base-sepolia",84532,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("linea-sepolia",59141,{}),r("matic",137,{ensNetwork:1,plugins:[HN("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[HN("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[]}),r("optimism-goerli",420,{}),r("optimism-sepolia",11155420,{}),r("xdai",100,{ensNetwork:1})}function nb(r){return JSON.parse(JSON.stringify(r))}class dre{constructor(e){se(this,Il);se(this,eo);se(this,hi);se(this,Zo);se(this,ds);F(this,eo,e),F(this,hi,null),F(this,Zo,4e3),F(this,ds,-2)}get pollingInterval(){return T(this,Zo)}set pollingInterval(e){F(this,Zo,e)}start(){T(this,hi)||(F(this,hi,T(this,eo)._setTimeout(Ee(this,Il,Ag).bind(this),T(this,Zo))),Ee(this,Il,Ag).call(this))}stop(){T(this,hi)&&(T(this,eo)._clearTimeout(T(this,hi)),F(this,hi,null))}pause(e){this.stop(),e&&F(this,ds,-2)}resume(){this.start()}}eo=new WeakMap,hi=new WeakMap,Zo=new WeakMap,ds=new WeakMap,Il=new WeakSet,Ag=async function(){try{const e=await T(this,eo).getBlockNumber();if(T(this,ds)===-2){F(this,ds,e);return}if(e!==T(this,ds)){for(let t=T(this,ds)+1;t<=e;t++){if(T(this,hi)==null)return;await T(this,eo).emit("block",t)}F(this,ds,e)}}catch{}T(this,hi)!=null&&F(this,hi,T(this,eo)._setTimeout(Ee(this,Il,Ag).bind(this),T(this,Zo)))};class ib{constructor(e){se(this,_c);se(this,Ac);se(this,Qo);F(this,_c,e),F(this,Qo,!1),F(this,Ac,t=>{this._poll(t,T(this,_c))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Qo)||(F(this,Qo,!0),T(this,Ac).call(this,-2),T(this,_c).on("block",T(this,Ac)))}stop(){T(this,Qo)&&(F(this,Qo,!1),T(this,_c).off("block",T(this,Ac)))}pause(e){this.stop()}resume(){this.start()}}_c=new WeakMap,Ac=new WeakMap,Qo=new WeakMap;class pre extends ib{constructor(t,n){super(t);se(this,Sl);se(this,to);F(this,Sl,n),F(this,to,-2)}pause(t){t&&F(this,to,-2),super.pause(t)}async _poll(t,n){const i=await n.getBlock(T(this,Sl));i!=null&&(T(this,to)===-2?F(this,to,i.number):i.number>T(this,to)&&(n.emit(T(this,Sl),i.number),F(this,to,i.number)))}}Sl=new WeakMap,to=new WeakMap;class gre extends ib{constructor(t,n){super(t);se(this,Xp);F(this,Xp,nb(n))}async _poll(t,n){throw new Error("@TODO")}}Xp=new WeakMap;class yre extends ib{constructor(t,n){super(t);se(this,kl);F(this,kl,n)}async _poll(t,n){const i=await n.getTransactionReceipt(T(this,kl));i&&n.emit(T(this,kl),i)}}kl=new WeakMap;class sb{constructor(e,t){se(this,eg);se(this,ro);se(this,Tl);se(this,Ol);se(this,Yo);se(this,di);F(this,ro,e),F(this,Tl,nb(t)),F(this,Ol,Ee(this,eg,p6).bind(this)),F(this,Yo,!1),F(this,di,-2)}start(){T(this,Yo)||(F(this,Yo,!0),T(this,di)===-2&&T(this,ro).getBlockNumber().then(e=>{F(this,di,e)}),T(this,ro).on("block",T(this,Ol)))}stop(){T(this,Yo)&&(F(this,Yo,!1),T(this,ro).off("block",T(this,Ol)))}pause(e){this.stop(),e&&F(this,di,-2)}resume(){this.start()}}ro=new WeakMap,Tl=new WeakMap,Ol=new WeakMap,Yo=new WeakMap,di=new WeakMap,eg=new WeakSet,p6=async function(e){if(T(this,di)===-2)return;const t=nb(T(this,Tl));t.fromBlock=T(this,di)+1,t.toBlock=e;const n=await T(this,ro).getLogs(t);if(n.length===0){T(this,di)<e-60&&F(this,di,e-60);return}for(const i of n)T(this,ro).emit(T(this,Tl),i),F(this,di,i.blockNumber)};const mre=BigInt(2),wre=10;function Vp(r){return r&&typeof r.then=="function"}function jp(r,e){return r+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const i=Object.keys(n);return i.sort(),i.reduce((s,o)=>(s[o]=n[o],s),{})}return n})}class Kp{constructor(e){Q(this,"name");ze(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function bre(r){return JSON.parse(JSON.stringify(r))}function ob(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function ab(r,e){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:r,tag:r}}if(Gt(r,32)){const t=r.toLowerCase();return{type:"transaction",tag:jp("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:jp("orphan",t),filter:bre(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(i=>i==null?null:Array.isArray(i)?ob(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(t.address){const i=[],s=[],o=a=>{Gt(a)?i.push(a):s.push((async()=>{i.push(await An(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),s.length&&await Promise.all(s),n.address=ob(i.map(a=>a.toLowerCase()))}return{filter:n,tag:jp("event",n),type:"event"}}q(!1,"unknown ProviderEvent","event",r)}function cb(){return new Date().getTime()}const _re={cacheTimeout:250,pollingInterval:4e3};class Are{constructor(e,t){se(this,ct);se(this,un);se(this,Jo);se(this,ln);se(this,Nl);se(this,Yn);se(this,vc);se(this,Xo);se(this,no);se(this,zh);se(this,pi);se(this,Cl);se(this,Bl);if(F(this,Bl,Object.assign({},_re,t||{})),e==="any")F(this,vc,!0),F(this,Yn,null);else if(e){const n=os.from(e);F(this,vc,!1),F(this,Yn,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else F(this,vc,!1),F(this,Yn,null);F(this,no,-1),F(this,Xo,new Map),F(this,un,new Map),F(this,Jo,new Map),F(this,ln,null),F(this,Nl,!1),F(this,zh,1),F(this,pi,new Map),F(this,Cl,!1)}get pollingInterval(){return T(this,Bl).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Jo).values())}attachPlugin(e){if(T(this,Jo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Jo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Jo).get(e)||null}get disableCcipRead(){return T(this,Cl)}set disableCcipRead(e){F(this,Cl,!!e)}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const i=e.to.toLowerCase(),s=t.toLowerCase(),o=[];for(let a=0;a<n.length;a++){const u=n[a],l=u.replace("{sender}",i).replace("{data}",s),h=new Us(l);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:n});let g="unknown error",b;try{b=await h.send()}catch(w){o.push(w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:w}});continue}try{const w=b.bodyJson;if(w.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:w}),w.data;w.message&&(g=w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:w})}catch{}ge(b.statusCode<400||b.statusCode>=500,`response not found during CCIP fetch: ${g}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:u,errorMessage:g}}),o.push(g)}ge(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:o}})}_wrapBlock(e,t){return new Fte(sre(e),this)}_wrapLog(e,t){return new Ih(nre(e),this)}_wrapTransactionReceipt(e,t){return new EN(ure(e),this)}_wrapTransactionResponse(e,t){return new Sh($N(e),this)}_detectNetwork(){ge(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ge(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=at(await Ee(this,ct,Jn).call(this,{method:"getBlockNumber"}),"%response");return T(this,no)>=0&&F(this,no,e),e}_getAddress(e){return An(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(Gt(e))return Gt(e,32)?e:Cu(e);if(typeof e=="bigint"&&(e=at(e,"blockTag")),typeof e=="number")return e>=0?Cu(e):T(this,no)>=0?Cu(T(this,no)+e):this.getBlockNumber().then(t=>Cu(t+e));q(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(u=>u==null?null:Array.isArray(u)?ob(u.map(l=>l.toLowerCase())):u.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,i=(u,l,h)=>{let g;switch(u.length){case 0:break;case 1:g=u[0];break;default:u.sort(),g=u}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const b={};return g&&(b.address=g),t.length&&(b.topics=t),l&&(b.fromBlock=l),h&&(b.toBlock=h),n&&(b.blockHash=n),b};let s=[];if(e.address)if(Array.isArray(e.address))for(const u of e.address)s.push(this._getAddress(u));else s.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(s),o,a]).then(u=>i(u[0],u[1],u[2])):i(s,o,a)}_getTransactionRequest(e){const t=Lp(e),n=[];if(["to","from"].forEach(i=>{if(t[i]==null)return;const s=An(t[i],this);Vp(s)?n.push(async function(){t[i]=await s}()):t[i]=s}),t.blockTag!=null){const i=this._getBlockTag(t.blockTag);Vp(i)?n.push(async function(){t.blockTag=await i}()):t.blockTag=i}return n.length?async function(){return await Promise.all(n),t}():t}async getNetwork(){if(T(this,Yn)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,Yn)===i&&F(this,Yn,null),s}})();return F(this,Yn,i),(await i).clone()}const e=T(this,Yn),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(T(this,vc)?(this.emit("network",n,t),T(this,Yn)===e&&F(this,Yn,Promise.resolve(n))):ge(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await mn({_block:Ee(this,ct,H_).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await Ee(this,ct,Jn).call(this,{method:"getGasPrice"});return Le(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await Ee(this,ct,Jn).call(this,{method:"getPriorityFee"});return Le(h,"%response")}catch{}return null})()});let a=null,u=null;const l=this._wrapBlock(i,e);return l&&l.baseFeePerGas&&(u=o??BigInt("1000000000"),a=l.baseFeePerGas*mre+u),new vN(s,a,u)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const i=new Us(n.url),s=await n.processFunc(t,this,i);return new vN(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Vp(t)&&(t=await t),Le(await Ee(this,ct,Jn).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:n}=await mn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await Ee(this,ct,F_).call(this,Ee(this,ct,$_).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return Le(await Ee(this,ct,Ad).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return at(await Ee(this,ct,Ad).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return Ce(await Ee(this,ct,Ad).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const i=Le(t,"position");return Ce(await Ee(this,ct,Ad).call(this,{method:"getStorage",position:i},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:i}=await mn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),s=Np.from(e);if(s.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(t)}async getBlock(e,t){const{network:n,params:i}=await mn({network:this.getNetwork(),params:Ee(this,ct,H_).call(this,e,!!t)});return i==null?null:this._wrapBlock(i,n)}async getTransaction(e){const{network:t,params:n}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const i=await Ee(this,ct,Jn).call(this,{method:"getTransaction",hash:e});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await mn({network:this.getNetwork(),result:Ee(this,ct,Jn).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:Ce(t)}async getLogs(e){let t=this._getFilter(e);Vp(t)&&(t=await t);const{network:n,params:i}=await mn({network:this.getNetwork(),params:Ee(this,ct,Jn).call(this,{method:"getLogs",filter:t})});return i.map(s=>this._wrapLog(s,n))}_getProvider(e){ge(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Fp.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=Mt(e);const t=$w(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Fp.getEnsAddress(this),s=await new ju(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(s==null||s===gh)return null;const a=await new ju(s,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(n){if(Qr(n,"BAD_DATA")&&n.value==="0x"||Qr(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const i=t??1;return i===0?this.getTransactionReceipt(e):new Promise(async(s,o)=>{let a=null;const u=async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=i){s(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",u),o(Yt("timeout","TIMEOUT",{reason:"timeout"})))},n)),u(await this.getBlockNumber())})}async waitForBlock(e){ge(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,pi).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,pi).delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=bd(this,zh)._++,i=()=>{T(this,pi).delete(n),e()};if(this.paused)T(this,pi).set(n,{timer:null,func:i,time:t});else{const s=setTimeout(i,t);T(this,pi).set(n,{timer:s,func:i,time:cb()})}return n}_forEachSubscriber(e){for(const t of T(this,un).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Kp(e.type);case"block":{const t=new dre(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new pre(this,e.type);case"event":return new sb(this,e.filter);case"transaction":return new yre(this,e.hash);case"orphan":return new gre(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of T(this,un).values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),T(this,ln)!=null&&t.pause(T(this,ln));break}}async on(e,t){const n=await Ee(this,ct,vg).call(this,e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,T(this,ln)!=null&&n.subscriber.pause(T(this,ln))),this}async once(e,t){const n=await Ee(this,ct,vg).call(this,e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,T(this,ln)!=null&&n.subscriber.pause(T(this,ln))),this}async emit(e,...t){const n=await Ee(this,ct,vd).call(this,e,t);if(!n||n.listeners.length===0)return!1;const i=n.listeners.length;return n.listeners=n.listeners.filter(({listener:s,once:o})=>{const a=new sT(this,o?null:s,e);try{s.call(this,...t,a)}catch{}return!o}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),T(this,un).delete(n.tag)),i>0}async listenerCount(e){if(e){const n=await Ee(this,ct,vd).call(this,e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of T(this,un).values())t+=n.length;return t}async listeners(e){if(e){const n=await Ee(this,ct,vd).call(this,e);return n?n.listeners.map(({listener:i})=>i):[]}let t=[];for(const{listeners:n}of T(this,un).values())t=t.concat(n.map(({listener:i})=>i));return t}async off(e,t){const n=await Ee(this,ct,vd).call(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),T(this,un).delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:i}=await Ee(this,ct,vg).call(this,e);n&&i.stop(),T(this,un).delete(t)}else for(const[t,{started:n,subscriber:i}]of T(this,un))n&&i.stop(),T(this,un).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Nl)}destroy(){this.removeAllListeners();for(const e of T(this,pi).keys())this._clearTimeout(e);F(this,Nl,!0)}get paused(){return T(this,ln)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(F(this,no,-1),T(this,ln)!=null){if(T(this,ln)==!!e)return;ge(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),F(this,ln,!!e);for(const t of T(this,pi).values())t.timer&&clearTimeout(t.timer),t.time=cb()-t.time}resume(){if(T(this,ln)!=null){this._forEachSubscriber(e=>e.resume()),F(this,ln,null);for(const e of T(this,pi).values()){let t=e.time;t<0&&(t=0),e.time=cb(),setTimeout(e.func,t)}}}}un=new WeakMap,Jo=new WeakMap,ln=new WeakMap,Nl=new WeakMap,Yn=new WeakMap,vc=new WeakMap,Xo=new WeakMap,no=new WeakMap,zh=new WeakMap,pi=new WeakMap,Cl=new WeakMap,Bl=new WeakMap,ct=new WeakSet,Jn=async function(e){const t=T(this,Bl).cacheTimeout;if(t<0)return await this._perform(e);const n=jp(e.method,e);let i=T(this,Xo).get(n);return i||(i=this._perform(e),T(this,Xo).set(n,i),setTimeout(()=>{T(this,Xo).get(n)===i&&T(this,Xo).delete(n)},t)),await i},$_=async function(e,t,n){ge(n<wre,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const i=Lp(e);try{return Ce(await this._perform({method:"call",transaction:i,blockTag:t}))}catch(s){if(!this.disableCcipRead&&nw(s)&&s.data&&n>=0&&t==="latest"&&i.to!=null&&lr(s.data,0,4)==="0x556f1830"){const o=s.data,a=await An(i.to,this);let u;try{u=Ire(lr(s.data,4))}catch(g){ge(!1,g.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ge(u.sender.toLowerCase()===a.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 l=await this.ccipReadFetch(i,u.calldata,u.urls);ge(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:a,data:xr([u.selector,Rre([l,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const g=await Ee(this,ct,$_).call(this,h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:g}),g}catch(g){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:g}),g}}throw s}},F_=async function(e){const{value:t}=await mn({network:this.getNetwork(),value:e});return t},Ad=async function(e,t,n){let i=this._getAddress(t),s=this._getBlockTag(n);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await Ee(this,ct,F_).call(this,Ee(this,ct,Jn).call(this,Object.assign(e,{address:i,blockTag:s})))},H_=async function(e,t){if(Gt(e,32))return await Ee(this,ct,Jn).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await Ee(this,ct,Jn).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},vd=async function(e,t){let n=await ab(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await ab({orphan:"drop-log",log:t[0]},this)),T(this,un).get(n.tag)||null},vg=async function(e){const t=await ab(e,this),n=t.tag;let i=T(this,un).get(n);return i||(i={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,un).set(n,i)),i};function vre(r,e){try{const t=ub(r,e);if(t)return fp(t)}catch{}return null}function ub(r,e){if(r==="0x")return null;try{const t=at(lr(r,e,e+32)),n=at(lr(r,t,t+32));return lr(r,t+32,t+32+n)}catch{}return null}function GN(r){const e=bn(r);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function Ere(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const xre=new Uint8Array([]);function Rre(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(xre),t+=32;for(let n=0;n<r.length;n++){const i=_t(r[n]);e[n]=GN(t),e.push(GN(i.length)),e.push(Ere(i)),t+=32+Math.ceil(i.length/32)*32}return xr(e)}const VN="0x0000000000000000000000000000000000000000000000000000000000000000";function Ire(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ge(Ou(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=lr(r,0,32);ge(lr(t,0,12)===lr(VN,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=lr(t,12);try{const n=[],i=at(lr(r,32,64)),s=at(lr(r,i,i+32)),o=lr(r,i+32);for(let a=0;a<s;a++){const u=vre(o,a*32);if(u==null)throw new Error("abort");n.push(u)}e.urls=n}catch{ge(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=ub(r,64);if(n==null)throw new Error("abort");e.calldata=n}catch{ge(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ge(lr(r,100,128)===lr(VN,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=lr(r,96,100);try{const n=ub(r,128);if(n==null)throw new Error("abort");e.extraData=n}catch{ge(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function Wu(r,e){if(r.provider)return r.provider;ge(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function jN(r,e){let t=Lp(e);if(t.to!=null&&(t.to=An(t.to,r)),t.from!=null){const n=t.from;t.from=Promise.all([r.getAddress(),An(n,r)]).then(([i,s])=>(q(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else t.from=r.getAddress();return await mn(t)}class Sre{constructor(e){Q(this,"provider");ze(this,{provider:e||null})}async getNonce(e){return Wu(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await jN(this,e)}async populateTransaction(e){const t=Wu(this,"populateTransaction"),n=await jN(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const i=await this.provider.getNetwork();if(n.chainId!=null){const o=Le(n.chainId);q(o===i.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=i.chainId;const s=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||s)?q(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&s&&q(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const o=await t.getFeeData();ge(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(n.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const a=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=a,n.maxPriorityFeePerGas=a}else n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ge(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice),n.type=0):ge(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await mn(n)}async estimateGas(e){return Wu(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Wu(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Wu(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Wu(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const i=Np.from(n);return await t.broadcastTransaction(await this.signTransaction(i))}}function kre(r){return JSON.parse(JSON.stringify(r))}class KN{constructor(e){se(this,ta);se(this,En);se(this,ps);se(this,Ec);se(this,ea);se(this,xc);se(this,Pl);F(this,En,e),F(this,ps,null),F(this,Ec,Ee(this,ta,z_).bind(this)),F(this,ea,!1),F(this,xc,null),F(this,Pl,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,ea)||(F(this,ea,!0),Ee(this,ta,z_).call(this,-2))}stop(){T(this,ea)&&(F(this,ea,!1),F(this,Pl,!0),Ee(this,ta,G_).call(this),T(this,En).off("block",T(this,Ec)))}pause(e){e&&Ee(this,ta,G_).call(this),T(this,En).off("block",T(this,Ec))}resume(){this.start()}}En=new WeakMap,ps=new WeakMap,Ec=new WeakMap,ea=new WeakMap,xc=new WeakMap,Pl=new WeakMap,ta=new WeakSet,z_=async function(e){try{T(this,ps)==null&&F(this,ps,this._subscribe(T(this,En)));let t=null;try{t=await T(this,ps)}catch(s){if(!Qr(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(t==null){F(this,ps,null),T(this,En)._recoverSubscriber(this,this._recover(T(this,En)));return}const n=await T(this,En).getNetwork();if(T(this,xc)||F(this,xc,n),T(this,xc).chainId!==n.chainId)throw new Error("chaid changed");if(T(this,Pl))return;const i=await T(this,En).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,En),i)}catch(t){console.log("@TODO",t)}T(this,En).once("block",T(this,Ec))},G_=function(){const e=T(this,ps);e&&(F(this,ps,null),e.then(t=>{T(this,En).destroyed||T(this,En).send("eth_uninstallFilter",[t])}))};class Tre extends KN{constructor(t,n){super(t);se(this,Rc);F(this,Rc,kre(n))}_recover(t){return new sb(t,T(this,Rc))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,Rc)])}async _emitResults(t,n){for(const i of n)t.emit(T(this,Rc),t._wrapLog(i,t._network))}}Rc=new WeakMap;class Ore extends KN{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const Nre="bigint,boolean,function,number,string,symbol".split(/,/g);function Wp(r){if(r==null||Nre.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(Wp);if(typeof r=="object")return Object.keys(r).reduce((e,t)=>(e[t]=r[t],e),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function Cre(r){return new Promise(e=>{setTimeout(e,r)})}function qu(r){return r&&r.toLowerCase()}function WN(r){return r&&typeof r.pollingInterval=="number"}const qN={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class lb extends Sre{constructor(t,n){super(t);Q(this,"address");n=Mt(n),ze(this,{address:n})}connect(t){ge(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const n=Wp(t),i=[];if(n.from){const o=n.from;i.push((async()=>{const a=await An(o,this.provider);q(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=a})())}else n.from=this.address;if(n.gasLimit==null&&i.push((async()=>{n.gasLimit=await this.provider.estimateGas({...n,from:this.address})})()),n.to!=null){const o=n.to;i.push((async()=>{n.to=await An(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(n);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(t){const n=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(t);return await new Promise((s,o)=>{const a=[1e3,100];let u=0;const l=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(n));return}}catch(h){if(Qr(h,"CANCELLED")||Qr(h,"BAD_DATA")||Qr(h,"NETWORK_ERROR")||Qr(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Qr(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Yt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const n=Wp(t);if(n.from){const s=await An(n.from,this.provider);q(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=s}else n.from=this.address;const i=this.provider.getRpcTransaction(n);return await this.provider.send("eth_signTransaction",[i])}async signMessage(t){const n=typeof t=="string"?Ls(t):t;return await this.provider.send("personal_sign",[Ce(n),this.address.toLowerCase()])}async signTypedData(t,n,i){const s=Wp(i),o=await Bp.resolveNames(t,n,s,async a=>{const u=await An(a);return q(u!=null,"TypedData does not support null address","value",a),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Bp.getPayload(o.domain,n,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const n=typeof t=="string"?Ls(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Ce(n)])}}class ZN extends Are{constructor(t,n){super(t,n);se(this,Gh);se(this,Ic);se(this,Ml);se(this,io);se(this,gs);se(this,Pi);se(this,gi);se(this,Dn);F(this,Ml,1),F(this,Ic,Object.assign({},qN,n||{})),F(this,io,[]),F(this,gs,null),F(this,gi,null),F(this,Dn,null);{let s=null;const o=new Promise(a=>{s=a});F(this,Pi,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(q(!i||t!=="any","staticNetwork cannot be used on special network 'any'","options",n),i&&t!=null&&F(this,gi,os.from(t))):i&&(q(t==null||i.matches(t),"staticNetwork MUST match network object","options",n),F(this,gi,i))}_getOption(t){return T(this,Ic)[t]}get _network(){return ge(T(this,gi),"network is not available yet","NETWORK_ERROR"),T(this,gi)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let i=t.transaction;if(i&&i.type!=null&&Le(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},i,{type:void 0})}))}}const n=this.getRpcRequest(t);return n!=null?await this.send(n.method,n.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,gi))return T(this,gi)}else return t;return T(this,Dn)?await T(this,Dn):this.ready?(F(this,Dn,(async()=>{try{const n=os.from(Le(await this.send("eth_chainId",[])));return F(this,Dn,null),n}catch(n){throw F(this,Dn,null),n}})()),await T(this,Dn)):(F(this,Dn,(async()=>{const n={id:bd(this,Ml)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:n});let i;try{i=(await this._send(n))[0],F(this,Dn,null)}catch(s){throw F(this,Dn,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return os.from(Le(i.result));throw this.getRpcError(n,i)})()),await T(this,Dn))}_start(){T(this,Pi)==null||T(this,Pi).resolve==null||(T(this,Pi).resolve(),F(this,Pi,null),(async()=>{for(;T(this,gi)==null&&!this.destroyed;)try{F(this,gi,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Yt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await Cre(1e3)}Ee(this,Gh,V_).call(this)})())}async _waitUntilReady(){if(T(this,Pi)!=null)return await T(this,Pi).promise}_getSubscriber(t){return t.type==="pending"?new Ore(this):t.type==="event"?this._getOption("polling")?new sb(this,t.filter):new Tre(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Kp("orphan"):super._getSubscriber(t)}get ready(){return T(this,Pi)==null}getRpcTransaction(t){const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(t[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),n[s]=Cu(Le(t[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{t[i]!=null&&(n[i]=Ce(t[i]))}),t.accessList&&(n.accessList=Ja(t.accessList)),t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes.map(i=>i.toLowerCase())),n}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[qu(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[qu(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[qu(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[qu(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(qu):t.filter.address=qu(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,n){const{method:i}=t,{error:s}=n;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Yt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=fb(s),l=Rh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",t.params[0],u?u.data:null);return l.info={error:s,payload:t},l}const o=JSON.stringify(Mre(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Yt("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:t,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Yt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Yt("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Yt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Yt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let a=!!o.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?Yt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:s,payload:t}}):Yt("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const i=bd(this,Ml)._++,s=new Promise((o,a)=>{T(this,io).push({resolve:o,reject:a,payload:{method:t,params:n,id:i,jsonrpc:"2.0"}})});return Ee(this,Gh,V_).call(this),s}async getSigner(t){t==null&&(t=0);const n=this.send("eth_accounts",[]);if(typeof t=="number"){const s=await n;if(t>=s.length)throw new Error("no such account");return new lb(this,s[t])}const{accounts:i}=await mn({network:this.getNetwork(),accounts:n});t=Mt(t);for(const s of i)if(Mt(s)===t)return new lb(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new lb(this,n))}destroy(){T(this,gs)&&(clearTimeout(T(this,gs)),F(this,gs,null));for(const{payload:t,reject:n}of T(this,io))n(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));F(this,io,[]),super.destroy()}}Ic=new WeakMap,Ml=new WeakMap,io=new WeakMap,gs=new WeakMap,Pi=new WeakMap,gi=new WeakMap,Dn=new WeakMap,Gh=new WeakSet,V_=function(){if(T(this,gs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");F(this,gs,setTimeout(()=>{F(this,gs,null);const n=T(this,io);for(F(this,io,[]);n.length;){const i=[n.shift()];for(;n.length&&i.length!==T(this,Ic).batchMaxCount;)if(i.push(n.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,Ic).batchMaxSize){n.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:a,reject:u,payload:l}of i){if(this.destroyed){u(Yt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:l.method}));continue}const h=o.filter(g=>g.id===l.id)[0];if(h==null){const g=Yt("missing response for request","BAD_DATA",{value:o,info:{payload:l}});this.emit("error",g),u(g);continue}if("error"in h){u(this.getRpcError(l,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of i)a(o)}})()}},t))};class Bre extends ZN{constructor(t,n){super(t,n);se(this,ra);let i=this._getOption("pollingInterval");i==null&&(i=qN.pollingInterval),F(this,ra,i)}_getSubscriber(t){const n=super._getSubscriber(t);return WN(n)&&(n.pollingInterval=T(this,ra)),n}get pollingInterval(){return T(this,ra)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");F(this,ra,t),this._forEachSubscriber(n=>{WN(n)&&(n.pollingInterval=T(this,ra))})}}ra=new WeakMap;class Pre extends Bre{constructor(t,n,i){t==null&&(t="http://localhost:8545");super(n,i);se(this,Ll);typeof t=="string"?F(this,Ll,new Us(t)):F(this,Ll,t.clone())}_getConnection(){return T(this,Ll).clone()}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){const n=this._getConnection();n.body=JSON.stringify(t),n.setHeader("content-type","application/json");const i=await n.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}Ll=new WeakMap;function fb(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&Gt(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const e in r){const t=fb(r[e]);if(t)return t}return null}if(typeof r=="string")try{return fb(JSON.parse(r))}catch{}return null}function hb(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)hb(r[t],e);if(typeof r=="string")try{return hb(JSON.parse(r),e)}catch{}}}function Mre(r){const e=[];return hb(r,e),e}function Lre(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof qc<"u")return qc;throw new Error("unable to locate global object")}const Ure=Lre().WebSocket;class db{constructor(e,t){se(this,ys);se(this,Vh);se(this,na);se(this,Sc);se(this,ia);F(this,ys,e),F(this,Vh,JSON.stringify(t)),F(this,na,null),F(this,Sc,null),F(this,ia,null)}get filter(){return JSON.parse(T(this,Vh))}start(){F(this,na,T(this,ys).send("eth_subscribe",this.filter).then(e=>(T(this,ys)._register(e,this),e)))}stop(){T(this,na).then(e=>{T(this,ys).destroyed||T(this,ys).send("eth_unsubscribe",[e])}),F(this,na,null)}pause(e){ge(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),F(this,Sc,!!e)}resume(){F(this,Sc,null)}_handleMessage(e){if(T(this,na)!=null&&T(this,Sc)===null){let t=T(this,ia);t==null?t=this._emit(T(this,ys),e):t=t.then(async()=>{await this._emit(T(this,ys),e)}),F(this,ia,t.then(()=>{T(this,ia)===t&&F(this,ia,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}ys=new WeakMap,Vh=new WeakMap,na=new WeakMap,Sc=new WeakMap,ia=new WeakMap;class Dre extends db{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class $re extends db{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class Fre extends db{constructor(t,n){super(t,["logs",n]);se(this,jh);F(this,jh,JSON.stringify(n))}get logFilter(){return JSON.parse(T(this,jh))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}jh=new WeakMap;class Hre extends ZN{constructor(t,n){const i=Object.assign({},n??{});q(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",n),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(t,i);se(this,kc);se(this,Ul);se(this,sa);F(this,kc,new Map),F(this,Ul,new Map),F(this,sa,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Kp("close");case"block":return new Dre(this);case"pending":return new $re(this);case"event":return new Fre(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Kp("drop-log")}return super._getSubscriber(t)}_register(t,n){T(this,Ul).set(t,n);const i=T(this,sa).get(t);if(i){for(const s of i)n._handleMessage(s);T(this,sa).delete(t)}}async _send(t){q(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const n=new Promise((i,s)=>{T(this,kc).set(t.id,{payload:t,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await n]}async _processMessage(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&"id"in n){const i=T(this,kc).get(n.id);if(i==null){this.emit("error",Yt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}T(this,kc).delete(n.id),i.resolve(n)}else if(n&&n.method==="eth_subscription"){const i=n.params.subscription,s=T(this,Ul).get(i);if(s)s._handleMessage(n.params.result);else{let o=T(this,sa).get(i);o==null&&(o=[],T(this,sa).set(i,o)),o.push(n.params.result)}}else{this.emit("error",Yt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}kc=new WeakMap,Ul=new WeakMap,sa=new WeakMap;class zre extends Hre{constructor(t,n,i){super(n,i);se(this,Tc);se(this,Mi);typeof t=="string"?(F(this,Tc,()=>new Ure(t)),F(this,Mi,T(this,Tc).call(this))):typeof t=="function"?(F(this,Tc,t),F(this,Mi,t())):(F(this,Tc,null),F(this,Mi,t)),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,Mi)==null)throw new Error("websocket closed");return T(this,Mi)}async _write(t){this.websocket.send(t)}async destroy(){T(this,Mi)!=null&&(T(this,Mi).close(),F(this,Mi,null)),super.destroy()}}Tc=new WeakMap,Mi=new WeakMap;const Gre={_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:{}},Vre={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 jre{constructor(e){this.settings=e,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:e,contractAddress:t}=this.settings;if(!t)throw new Error("Contract address is required for EVM chain type");const n=e.startsWith("ws")?new zre(e):new Pre(e),i=new ju(t,Gre.abi,n);this.evm={provider:n,contract:i}}initSvm(){const e=new Jx(this.settings.rpcUrl,"confirmed"),t=Ca.generate(),n={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:t.publicKey},i=new sh(e,n,{}),s=new ku(Vre,i);this.svm={provider:e,program:s}}async onMessageFrom(e){this.settings.chainType==="EVM"?this.listenToEvm(e):this.settings.chainType==="SVM"&&await this.listenToSvm(e)}listenToEvm(e){var t;(t=this.evm)==null||t.contract.on("MessageLogged",(n,i)=>{n.toLowerCase()===this.settings.swarmEmitterAddress.toLowerCase()&&e(n,i)})}async listenToSvm(e){var n;const t=(n=this.svm)==null?void 0:n.program.addEventListener("messageLogged",i=>{const{sender:s,message:o}=i;s.toBase58()===this.settings.swarmEmitterAddress&&e(s.toBase58(),o)});this.svm&&t!==void 0&&(this.svm.listenerId=t)}async removeAllListeners(){var e,t;this.settings.chainType==="EVM"&&((e=this.evm)==null||e.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((t=this.svm)==null?void 0:t.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const Kre=new TextEncoder,QN=1,YN=4096,pb=4096,Wre=32;function qre(r,e){return e=typeof e=="number"?Te.FeedIndex.fromBigInt(BigInt(e)):e,new Te.Identifier(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function Zre(r){const e=r.slice(0,Te.Span.LENGTH),t=r.slice(Te.Span.LENGTH),n=Qre(t),i=en.keccak256(en.concatBytes(e,n));return new Te.Reference(i)}function Qre(r){if(r.length>pb)throw new Te.BeeArgumentError(`payload size ${r.length} exceeds maximum chunk payload size ${pb}`,r);const e=new Uint8Array(pb);return e.set(r),en.log2Reduce(en.partition(e,Wre),(t,n)=>en.keccak256(en.concatBytes(t,n)))}function JN(r){if(r instanceof Uint8Array||(r=Kre.encode(r)),r.length<QN||r.length>YN)throw new RangeError(`payload size ${r.length} exceeds limits [${QN}, ${YN}]`);const e=Te.Span.fromBigInt(BigInt(r.length)),t=en.concatBytes(e.toUint8Array(),r);return{data:t,span:e,payload:Te.Bytes.fromSlice(t,Te.Span.LENGTH),address:Zre(t)}}function Yre(r,e){return new Te.Reference(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function XN(r,e,t){e=new Te.Identifier(e),t=new Te.PrivateKey(t);const n=Yre(e,t.publicKey().address()),i=t.sign(en.concatBytes(e.toUint8Array(),r.address.toUint8Array())),s=en.concatBytes(e.toUint8Array(),i.toUint8Array(),r.data),o=Te.Span.fromSlice(r.data,0),a=Te.Bytes.fromSlice(r.data,Te.Span.LENGTH);return{data:s,identifier:e,signature:i,span:o,payload:a,address:n,owner:t.publicKey().address()}}class Jre{constructor(e,t){this.userDetails=e,this.swarmSettings=t,this.depth=24,this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),l=Te.Topic.fromString(u);console.log("DEBUG: feedID write",l.toString(),a,e,u),await n.makeFeedWriter(l,new Te.PrivateKey(o)).uploadPayload(i,JSON.stringify(t),{index:e})}async writeOwnFeedDataByIndexV2(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new Te.PrivateKey(o),l=Te.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),g=Te.Topic.fromString(h),b=qre(g,e),w=JN(t),I=XN(w,b,u),S={hash:()=>I.address.toUint8Array()},x=l.stamp(S),{upload:C}=n.makeSOCWriter(u),H=Te.Bytes.fromUtf8(t);return(await C(x,b,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(e,t,n){const{bee:i,chatTopic:s}=this.swarmSettings,o=(n==null?void 0:n.timeout)??1500,a=this.generateUserOwnedFeedId(s,e),u=Te.Topic.fromString(a);console.log("DEBUG: feedID read",u.toString(),e,t,a);const h=await i.makeFeedReader(u,e,{timeout:o}).downloadPayload({index:t});return console.log(h.payload.toHex()),console.log(h.payload.toUtf8()),h.payload.toJSON()}orderMessages(e){return e.sort((t,n)=>t.timestamp-n.timestamp)}async retryAwaitableAsync(e,t=3,n=250){return new Promise((i,s)=>{e().then(i).catch(o=>{t>0?(this.logger.info(`Retrying... Attempts left: ${t}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(e,t-1,n).then(i).catch(s)},n)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(e){try{const{bee:t,stamp:n}=this.swarmSettings,i=await t.uploadData(n,JSON.stringify(e),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeV2(e){try{const{bee:t,stamp:n}=this.swarmSettings,{privateKey:i}=this.userDetails,s=Te.Stamper.fromBlank(i,n,this.depth),o=Te.Bytes.fromUtf8(JSON.stringify(e)),a=new k4(async l=>{await t.uploadChunk(s.stamp(l),l.build())});await a.append(o.toUint8Array());const u=await a.finalize();return en.uint8ArrayToHex(u.hash())}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(e){try{const{bee:t}=this.swarmSettings;return(await t.downloadData(e)).toJSON()}catch(t){return this.errorHandler.handleError(t,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:e,chatTopic:t}=this.swarmSettings,{ownAddress:n}=this.userDetails,i=this.generateUserOwnedFeedId(t,n),s=Te.Topic.fromString(i),a=await e.makeFeedReader(s,n).downloadPayload(),u=Number(a.feedIndex.toBigInt()),l=u+1;return console.log("DEBUG: getLatestFeedIndex",u,l),{latestIndex:u,nextIndex:l}}catch(e){if(this.isNotFoundError(e))return{latestIndex:-1,nextIndex:0};throw e}}async fetchLatestChatMessage(){const{bee:e,chatTopic:t,chatAddress:n}=this.swarmSettings;return(await e.makeFeedReader(Te.Topic.fromString(t),Gg(n)).downloadPayload()).payload.toJSON()}async fetchChatMessage(e){const{bee:t,chatTopic:n,chatAddress:i}=this.swarmSettings;return(await t.makeFeedReader(Te.Topic.fromString(n),Gg(i)).downloadPayload({index:Te.FeedIndex.fromBigInt(BigInt(`0x${e}`))})).payload.toJSON()}async sendMessageToGsoc(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=Te.Stamper.fromBlank(o,n,this.depth),u=new Te.PrivateKey(s),l=Te.Identifier.fromString(i),h=Te.Bytes.fromUtf8(e),g=JN(h.toUint8Array()),b=XN(g,l,u),w={hash:()=>b.address.toUint8Array()},I=a.stamp(w),{upload:S}=t.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await S(I,l,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(e,t){return`${e}_EthercastChat_${t}`}isNotFoundError(e){return e.stack.includes("404")||e.message.includes("Not Found")||e.message.includes("404")}}class Xre{constructor(e){var n,i,s;this.logger=Ui.getInstance(),this.errorHandler=new Dd,this.messagesQueue=new Vg({clearWaitTime:200}),this.gsocListenerQueue=new Vg({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const t=new Te.PrivateKey(Gg(e.user.privateKey));this.userDetails={privateKey:e.user.privateKey,ownAddress:t.publicKey().address().toString(),nickname:e.user.nickname,ownIndex:-1},this.swarmSettings={bee:new Te.Bee(e.infra.swarm.rpcUrl),stamp:e.infra.swarm.stamp,gsocTopic:e.infra.swarm.gsocTopic,gsocResourceId:e.infra.swarm.gsocResourceId,chatTopic:e.infra.swarm.chatTopic,chatAddress:e.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((n=e.options)==null?void 0:n.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=e.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=e.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new S4,this.utils=new Jre(this.userDetails,this.swarmSettings),this.history=new vG(this.userDetails,this.utils,this.emitter),this.swarmEventEmitterReader=new jre(e.infra.chain)}start(){this.init(),this.subscribeToGSOCEvent(),this.startMessagesFetchProcess(),this.startIdleUserCleanup(),this.history.startHistoryUpdateProcess()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.unsubFromGSOCEvent(),this.history.stopHistoryUpdateProcess(),this.emitter.cleanAll()}getEmitter(){return this.emitter}orderMessages(e){return this.utils.orderMessages(e)}async sendMessage(e,t){const n=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:t||I4(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:n,message:e};try{this.emitter.emit(ei.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndexV2(n,JSON.stringify(i)),this.userDetails.ownIndex=n,this.emitter.emit(ei.MESSAGE_REQUEST_UPLOADED,i),await this.waitForMessageBroadcast(n)}catch(s){this.emitter.emit(ei.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(ei.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages({preDownloadHistory:!0})}finally{this.emitter.emit(ei.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(e){this.sendMessage(e.message,e.id)}async retryBroadcastUserMessage(e){this.waitForMessageBroadcast(e.index)}async init(){try{this.emitter.emit(ei.LOADING_INIT,!0);const[e,t]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(e.status==="rejected")throw e.reason;t.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${t.reason}`),this.emitter.emit(ei.LOADING_INIT,!1)}catch(e){this.errorHandler.handleError(e,"Chat.initSelfState"),this.emitter.emit(ei.CRITICAL_ERROR,e)}}async initOwnIndex(){const{latestIndex:n}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=n}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom((e,t)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t)))}catch(e){this.errorHandler.handleError(e,"Chat.listenToNewSubscribers"),this.emitter.emit(ei.CRITICAL_ERROR,e)}}async processGsocEvent(e){try{console.log("processGsocMessage CALLED",e);const[t,n]=e.split("_"),i=await this.utils.fetchChatMessage(n);if(console.log("DEBUG processGsocMessage",i),!ZA(i)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",i),v4(this.latestMessage,i))return;i.messageSender?(this.updateActiveUsers(i.messageSender),this.history.processHistoryUpdaterEntry(this.activeUsers,i.historyEntry)):this.history.setHistoryEntry(i.historyEntry),this.latestMessage=i}catch(t){this.errorHandler.handleError(t,"Chat.processGsocMessage")}}async waitForMessageBroadcast(e){return QA({condition:()=>Object.values(this.activeUsers).some(t=>t.index===e),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const e=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",e),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({messageSender:e,historyEntry:this.history.getHistoryEntryWithNewUpdater(this.activeUsers)})))}catch(e){this.errorHandler.handleError(e,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:e,privateKey:t,nickname:n}=this.userDetails,i=new Te.EthAddress(e).toString(),s=new Te.PrivateKey(t);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const a=Date.now(),u=s.sign(JSON.stringify({username:n,address:i,timestamp:a}));return{address:i,timestamp:a,signature:u.toHex(),index:this.getOwnIndex(),username:n}}async readAllActiveUserMessage(){if(!await this.messagesQueue.waitForProcessing())for(const t of Object.values(this.activeUsers))this.messagesQueue.enqueue(()=>this.readMessage(t))}async readMessage(e){try{let t;const n=this.isUserIndexRead(e.address,e.index);if(n.isIndexRead)return;t=n.cachedIndex?n.cachedIndex+1:e.index;const i=await this.utils.fetchUserFeedDataByIndex(e.address,t);this.setUserIndexCache(e.address,t),this.emitter.emit(ei.MESSAGE_RECEIVED,i)}catch(t){this.errorHandler.handleError(t,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:e,FETCH_MESSAGE_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),t)}stopMessagesFetchProcess(){const{fetchMessageTimer:e}=this.options;e&&(clearInterval(e),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:e,IDLE_USER_CLEANUP_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),t)}stopIdleUserCleanup(){const{idleUserCleanupInterval:e}=this.options;e&&(clearInterval(e),this.options.idleUserCleanupInterval=null)}isUserIndexRead(e,t){const n=this.userIndexCache[e];return{cachedIndex:n,isIndexRead:n===t}}setUserIndexCache(e,t){this.userIndexCache[e]=t}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const e=Date.now();for(const t of Object.values(this.activeUsers))e-t.timestamp>300*$M&&delete this.activeUsers[t.address]}updateActiveUsers(e){this.activeUsers[e.address]=e}}ft.EVENTS=ei,ft.SwarmChat=Xre,Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"})});
|