@solarpunkltd/swarm-chat-js 2.2.0 → 3.1.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/dist/index.esm.js +21069 -23105
- package/dist/index.js +20 -22
- package/dist/src/lib/core.d.ts.map +1 -1
- package/dist/src/lib/history.d.ts +3 -40
- package/dist/src/lib/history.d.ts.map +1 -1
- package/dist/src/lib/types/chat.d.ts +1 -1
- package/dist/src/lib/types/chat.d.ts.map +1 -1
- package/dist/src/lib/types/message.d.ts +1 -2
- package/dist/src/lib/types/message.d.ts.map +1 -1
- package/dist/src/lib/types/user.d.ts +0 -14
- package/dist/src/lib/types/user.d.ts.map +1 -1
- package/dist/src/lib/utils.d.ts +7 -3
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/utils/common.d.ts +0 -1
- package/dist/src/utils/common.d.ts.map +1 -1
- package/dist/src/utils/validation.d.ts +0 -3
- package/dist/src/utils/validation.d.ts.map +1 -1
- package/dist/swarm-chat-umd.js +20 -22
- package/package.json +4 -2
- package/dist/src/utils/queue.d.ts +0 -16
- package/dist/src/utils/queue.d.ts.map +0 -1
package/dist/swarm-chat-umd.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
(function(ft,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],Se):(ft=typeof globalThis<"u"?globalThis:ft||self,Se(ft.SwarmChatJs={},ft.BeeJs))})(this,function(ft,Se){"use strict";var Yoe=Object.defineProperty;var h6=ft=>{throw TypeError(ft)};var Joe=(ft,Se,ut)=>Se in ft?Yoe(ft,Se,{enumerable:!0,configurable:!0,writable:!0,value:ut}):ft[Se]=ut;var Q=(ft,Se,ut)=>Joe(ft,typeof Se!="symbol"?Se+"":Se,ut),D_=(ft,Se,ut)=>Se.has(ft)||h6("Cannot "+ut);var T=(ft,Se,ut)=>(D_(ft,Se,"read from private field"),ut?ut.call(ft):Se.get(ft)),se=(ft,Se,ut)=>Se.has(ft)?h6("Cannot add the same private member more than once"):Se instanceof WeakSet?Se.add(ft):Se.set(ft,ut),F=(ft,Se,ut,xn)=>(D_(ft,Se,"write to private field"),xn?xn.call(ft,ut):Se.set(ft,ut),ut),Ee=(ft,Se,ut)=>(D_(ft,Se,"access private method"),ut);var _d=(ft,Se,ut,xn)=>({set _(Lc){F(ft,Se,Lc,ut)},get _(){return T(ft,Se,xn)}});var Qu,sc,$o,Yu,Ju,Oi,Ks,Xu,el,Hr,Zn,Vs,oc,ac,cc,as,Ni,Fo,uc,Ad,Ch,Bh,Ph,Qn,tl,lc,rl,Ws,fc,il,mg,Un,Yn,hc,dc,Ho,pc,F_,g6,sl,ol,al,gc,qs,mc,cs,cl,ul,ll,fl,hl,dl,pl,gl,yl,ml,wl,wc,zo,Qs,Go,bl,wg,Mh,Js,_l,Qp,y6,Xr,Bi,Lh,H_,Al,bg,jo,Wl,us,ls,fs,cn,hs,_g,Ag,Xs,Uh,Ko,vl,Dh,$h,iC,Vo,_c,Wo,ql,Xp,m6,Hh,zh,xl,Rl,qo,eo,hi,Zo,ds,Sl,vg,Ac,vc,Qo,kl,to,eg,Tl,ro,Ol,Nl,Yo,di,tg,w6,un,Jo,ln,Cl,Jn,Ec,Xo,no,Gh,pi,Bl,Pl,ct,Xn,z_,G_,vd,j_,Ed,Eg,En,ps,xc,ea,Rc,Ml,ta,K_,V_,Ic,Sc,Ll,io,gs,Pi,gi,Dn,jh,W_,ra,Ul,ys,Kh,na,kc,ia,Vh,Tc,Dl,sa,Oc,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 Lc(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 b6(){this.__data__=[],this.size=0}var _6=b6;function A6(r,e){return r===e||r!==r&&e!==e}var Zl=A6,v6=Zl;function E6(r,e){for(var t=r.length;t--;)if(v6(r[t][0],e))return t;return-1}var xd=E6,x6=xd,R6=Array.prototype,I6=R6.splice;function S6(r){var e=this.__data__,t=x6(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():I6.call(e,t,1),--this.size,!0}var k6=S6,T6=xd;function O6(r){var e=this.__data__,t=T6(e,r);return t<0?void 0:e[t][1]}var N6=O6,C6=xd;function B6(r){return C6(this.__data__,r)>-1}var P6=B6,M6=xd;function L6(r,e){var t=this.__data__,n=M6(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var U6=L6,D6=_6,$6=k6,F6=N6,H6=P6,z6=U6;function Uc(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])}}Uc.prototype.clear=D6,Uc.prototype.delete=$6,Uc.prototype.get=F6,Uc.prototype.has=H6,Uc.prototype.set=z6;var Rd=Uc,G6=Rd;function j6(){this.__data__=new G6,this.size=0}var K6=j6;function V6(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var W6=V6;function q6(r){return this.__data__.get(r)}var Z6=q6;function Q6(r){return this.__data__.has(r)}var Y6=Q6,J6=typeof ut=="object"&&ut&&ut.Object===Object&&ut,q_=J6,X6=q_,e3=typeof self=="object"&&self&&self.Object===Object&&self,t3=X6||e3||Function("return this")(),Rn=t3,r3=Rn,n3=r3.Symbol,Dc=n3,Z_=Dc,Q_=Object.prototype,i3=Q_.hasOwnProperty,s3=Q_.toString,Ql=Z_?Z_.toStringTag:void 0;function o3(r){var e=i3.call(r,Ql),t=r[Ql];try{r[Ql]=void 0;var n=!0}catch{}var i=s3.call(r);return n&&(e?r[Ql]=t:delete r[Ql]),i}var a3=o3,c3=Object.prototype,u3=c3.toString;function l3(r){return u3.call(r)}var f3=l3,Y_=Dc,h3=a3,d3=f3,p3="[object Null]",g3="[object Undefined]",J_=Y_?Y_.toStringTag:void 0;function y3(r){return r==null?r===void 0?g3:p3:J_&&J_ in Object(r)?h3(r):d3(r)}var la=y3,xg,X_;function yi(){if(X_)return xg;X_=1;function r(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return xg=r,xg}var m3=la,w3=yi(),b3="[object AsyncFunction]",_3="[object Function]",A3="[object GeneratorFunction]",v3="[object Proxy]";function E3(r){if(!w3(r))return!1;var e=m3(r);return e==_3||e==A3||e==b3||e==v3}var Id=E3,x3=Rn,R3=x3["__core-js_shared__"],I3=R3,Rg=I3,eA=function(){var r=/[^.]+$/.exec(Rg&&Rg.keys&&Rg.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function S3(r){return!!eA&&eA in r}var k3=S3,T3=Function.prototype,O3=T3.toString;function N3(r){if(r!=null){try{return O3.call(r)}catch{}try{return r+""}catch{}}return""}var tA=N3,C3=Id,B3=k3,P3=yi(),M3=tA,L3=/[\\^$.*+?()[\]{}|]/g,U3=/^\[object .+?Constructor\]$/,D3=Function.prototype,$3=Object.prototype,F3=D3.toString,H3=$3.hasOwnProperty,z3=RegExp("^"+F3.call(H3).replace(L3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G3(r){if(!P3(r)||B3(r))return!1;var e=C3(r)?z3:U3;return e.test(M3(r))}var j3=G3;function K3(r,e){return r==null?void 0:r[e]}var V3=K3,W3=j3,q3=V3;function Z3(r,e){var t=q3(r,e);return W3(t)?t:void 0}var fa=Z3,Q3=fa,Y3=Rn,J3=Q3(Y3,"Map"),Ig=J3,X3=fa,eB=X3(Object,"create"),Sd=eB,rA=Sd;function tB(){this.__data__=rA?rA(null):{},this.size=0}var rB=tB;function nB(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var iB=nB,sB=Sd,oB="__lodash_hash_undefined__",aB=Object.prototype,cB=aB.hasOwnProperty;function uB(r){var e=this.__data__;if(sB){var t=e[r];return t===oB?void 0:t}return cB.call(e,r)?e[r]:void 0}var lB=uB,fB=Sd,hB=Object.prototype,dB=hB.hasOwnProperty;function pB(r){var e=this.__data__;return fB?e[r]!==void 0:dB.call(e,r)}var gB=pB,yB=Sd,mB="__lodash_hash_undefined__";function wB(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=yB&&e===void 0?mB:e,this}var bB=wB,_B=rB,AB=iB,vB=lB,EB=gB,xB=bB;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=_B,$c.prototype.delete=AB,$c.prototype.get=vB,$c.prototype.has=EB,$c.prototype.set=xB;var RB=$c,nA=RB,IB=Rd,SB=Ig;function kB(){this.size=0,this.__data__={hash:new nA,map:new(SB||IB),string:new nA}}var TB=kB;function OB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var NB=OB,CB=NB;function BB(r,e){var t=r.__data__;return CB(e)?t[typeof e=="string"?"string":"hash"]:t.map}var kd=BB,PB=kd;function MB(r){var e=PB(this,r).delete(r);return this.size-=e?1:0,e}var LB=MB,UB=kd;function DB(r){return UB(this,r).get(r)}var $B=DB,FB=kd;function HB(r){return FB(this,r).has(r)}var zB=HB,GB=kd;function jB(r,e){var t=GB(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var KB=jB,VB=TB,WB=LB,qB=$B,ZB=zB,QB=KB;function Fc(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])}}Fc.prototype.clear=VB,Fc.prototype.delete=WB,Fc.prototype.get=qB,Fc.prototype.has=ZB,Fc.prototype.set=QB;var Sg=Fc,YB=Rd,JB=Ig,XB=Sg,e8=200;function t8(r,e){var t=this.__data__;if(t instanceof YB){var n=t.__data__;if(!JB||n.length<e8-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new XB(n)}return t.set(r,e),this.size=t.size,this}var r8=t8,n8=Rd,i8=K6,s8=W6,o8=Z6,a8=Y6,c8=r8;function Hc(r){var e=this.__data__=new n8(r);this.size=e.size}Hc.prototype.clear=i8,Hc.prototype.delete=s8,Hc.prototype.get=o8,Hc.prototype.has=a8,Hc.prototype.set=c8;var Td=Hc,u8="__lodash_hash_undefined__";function l8(r){return this.__data__.set(r,u8),this}var f8=l8;function h8(r){return this.__data__.has(r)}var d8=h8,p8=Sg,g8=f8,y8=d8;function Od(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new p8;++e<t;)this.add(r[e])}Od.prototype.add=Od.prototype.push=g8,Od.prototype.has=y8;var m8=Od;function w8(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 b8=w8;function _8(r,e){return r.has(e)}var A8=_8,v8=m8,E8=b8,x8=A8,R8=1,I8=2;function S8(r,e,t,n,i,s){var o=t&R8,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&I8?new v8: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(!E8(e,function(C,H){if(!x8(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 iA=S8,k8=Rn,T8=k8.Uint8Array,sA=T8;function O8(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var N8=O8;function C8(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var B8=C8,oA=Dc,aA=sA,P8=Zl,M8=iA,L8=N8,U8=B8,D8=1,$8=2,F8="[object Boolean]",H8="[object Date]",z8="[object Error]",G8="[object Map]",j8="[object Number]",K8="[object RegExp]",V8="[object Set]",W8="[object String]",q8="[object Symbol]",Z8="[object ArrayBuffer]",Q8="[object DataView]",cA=oA?oA.prototype:void 0,kg=cA?cA.valueOf:void 0;function Y8(r,e,t,n,i,s,o){switch(t){case Q8:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Z8:return!(r.byteLength!=e.byteLength||!s(new aA(r),new aA(e)));case F8:case H8:case j8:return P8(+r,+e);case z8:return r.name==e.name&&r.message==e.message;case K8:case W8:return r==e+"";case G8:var a=L8;case V8:var u=n&D8;if(a||(a=U8),r.size!=e.size&&!u)return!1;var l=o.get(r);if(l)return l==e;n|=$8,o.set(r,e);var h=M8(a(r),a(e),n,i,s,o);return o.delete(r),h;case q8:if(kg)return kg.call(r)==kg.call(e)}return!1}var J8=Y8;function X8(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Tg=X8,eP=Array.isArray,In=eP,tP=Tg,rP=In;function nP(r,e,t){var n=e(r);return rP(r)?n:tP(n,t(r))}var uA=nP;function iP(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 sP=iP;function oP(){return[]}var lA=oP,aP=sP,cP=lA,uP=Object.prototype,lP=uP.propertyIsEnumerable,fA=Object.getOwnPropertySymbols,fP=fA?function(r){return r==null?[]:(r=Object(r),aP(fA(r),function(e){return lP.call(r,e)}))}:cP,Og=fP;function hP(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var dP=hP;function pP(r){return r!=null&&typeof r=="object"}var ei=pP,Ng,hA;function gP(){if(hA)return Ng;hA=1;var r=la,e=ei,t="[object Arguments]";function n(i){return e(i)&&r(i)==t}return Ng=n,Ng}var Cg,dA;function Nd(){if(dA)return Cg;dA=1;var r=gP(),e=ei,t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,s=r(function(){return arguments}())?r:function(o){return e(o)&&n.call(o,"callee")&&!i.call(o,"callee")};return Cg=s,Cg}var Cd={exports:{}};function yP(){return!1}var mP=yP;Cd.exports,function(r,e){var t=Rn,n=mP,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}(Cd,Cd.exports);var Bd=Cd.exports,wP=9007199254740991,bP=/^(?:0|[1-9]\d*)$/;function _P(r,e){var t=typeof r;return e=e??wP,!!e&&(t=="number"||t!="symbol"&&bP.test(r))&&r>-1&&r%1==0&&r<e}var Pd=_P,AP=9007199254740991;function vP(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=AP}var Bg=vP,EP=la,xP=Bg,RP=ei,IP="[object Arguments]",SP="[object Array]",kP="[object Boolean]",TP="[object Date]",OP="[object Error]",NP="[object Function]",CP="[object Map]",BP="[object Number]",PP="[object Object]",MP="[object RegExp]",LP="[object Set]",UP="[object String]",DP="[object WeakMap]",$P="[object ArrayBuffer]",FP="[object DataView]",HP="[object Float32Array]",zP="[object Float64Array]",GP="[object Int8Array]",jP="[object Int16Array]",KP="[object Int32Array]",VP="[object Uint8Array]",WP="[object Uint8ClampedArray]",qP="[object Uint16Array]",ZP="[object Uint32Array]",Kt={};Kt[HP]=Kt[zP]=Kt[GP]=Kt[jP]=Kt[KP]=Kt[VP]=Kt[WP]=Kt[qP]=Kt[ZP]=!0,Kt[IP]=Kt[SP]=Kt[$P]=Kt[kP]=Kt[FP]=Kt[TP]=Kt[OP]=Kt[NP]=Kt[CP]=Kt[BP]=Kt[PP]=Kt[MP]=Kt[LP]=Kt[UP]=Kt[DP]=!1;function QP(r){return RP(r)&&xP(r.length)&&!!Kt[EP(r)]}var YP=QP;function JP(r){return function(e){return r(e)}}var Pg=JP,Md={exports:{}};Md.exports,function(r,e){var t=q_,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}(Md,Md.exports);var Mg=Md.exports,XP=YP,e5=Pg,pA=Mg,gA=pA&&pA.isTypedArray,t5=gA?e5(gA):XP,Lg=t5,r5=dP,n5=Nd(),i5=In,s5=Bd,o5=Pd,a5=Lg,c5=Object.prototype,u5=c5.hasOwnProperty;function l5(r,e){var t=i5(r),n=!t&&n5(r),i=!t&&!n&&s5(r),s=!t&&!n&&!i&&a5(r),o=t||n||i||s,a=o?r5(r.length,String):[],u=a.length;for(var l in r)(e||u5.call(r,l))&&!(o&&(l=="length"||i&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||o5(l,u)))&&a.push(l);return a}var yA=l5,f5=Object.prototype;function h5(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||f5;return r===t}var Ug=h5;function d5(r,e){return function(t){return r(e(t))}}var mA=d5,p5=mA,g5=p5(Object.keys,Object),y5=g5,m5=Ug,w5=y5,b5=Object.prototype,_5=b5.hasOwnProperty;function A5(r){if(!m5(r))return w5(r);var e=[];for(var t in Object(r))_5.call(r,t)&&t!="constructor"&&e.push(t);return e}var wA=A5,v5=Id,E5=Bg;function x5(r){return r!=null&&E5(r.length)&&!v5(r)}var Ld=x5,R5=yA,I5=wA,S5=Ld;function k5(r){return S5(r)?R5(r):I5(r)}var Ud=k5,T5=uA,O5=Og,N5=Ud;function C5(r){return T5(r,N5,O5)}var bA=C5,_A=bA,B5=1,P5=Object.prototype,M5=P5.hasOwnProperty;function L5(r,e,t,n,i,s){var o=t&B5,a=_A(r),u=a.length,l=_A(e),h=l.length;if(u!=h&&!o)return!1;for(var g=u;g--;){var b=a[g];if(!(o?b in e:M5.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 U5=L5,D5=fa,$5=Rn,F5=D5($5,"DataView"),H5=F5,z5=fa,G5=Rn,j5=z5(G5,"Promise"),K5=j5,V5=fa,W5=Rn,q5=V5(W5,"Set"),Z5=q5,Q5=fa,Y5=Rn,J5=Q5(Y5,"WeakMap"),AA=J5,Dg=H5,$g=Ig,Fg=K5,Hg=Z5,zg=AA,vA=la,zc=tA,EA="[object Map]",X5="[object Object]",xA="[object Promise]",RA="[object Set]",IA="[object WeakMap]",SA="[object DataView]",e4=zc(Dg),t4=zc($g),r4=zc(Fg),n4=zc(Hg),i4=zc(zg),ha=vA;(Dg&&ha(new Dg(new ArrayBuffer(1)))!=SA||$g&&ha(new $g)!=EA||Fg&&ha(Fg.resolve())!=xA||Hg&&ha(new Hg)!=RA||zg&&ha(new zg)!=IA)&&(ha=function(r){var e=vA(r),t=e==X5?r.constructor:void 0,n=t?zc(t):"";if(n)switch(n){case e4:return SA;case t4:return EA;case r4:return xA;case n4:return RA;case i4:return IA}return e});var Yl=ha,Gg=Td,s4=iA,o4=J8,a4=U5,kA=Yl,TA=In,OA=Bd,c4=Lg,u4=1,NA="[object Arguments]",CA="[object Array]",Dd="[object Object]",l4=Object.prototype,BA=l4.hasOwnProperty;function f4(r,e,t,n,i,s){var o=TA(r),a=TA(e),u=o?CA:kA(r),l=a?CA:kA(e);u=u==NA?Dd:u,l=l==NA?Dd:l;var h=u==Dd,g=l==Dd,b=u==l;if(b&&OA(r)){if(!OA(e))return!1;o=!0,h=!1}if(b&&!h)return s||(s=new Gg),o||c4(r)?s4(r,e,t,n,i,s):o4(r,e,u,t,n,i,s);if(!(t&u4)){var w=h&&BA.call(r,"__wrapped__"),I=g&&BA.call(e,"__wrapped__");if(w||I){var S=w?r.value():r,x=I?e.value():e;return s||(s=new Gg),i(S,x,t,n,s)}}return b?(s||(s=new Gg),a4(r,e,t,n,i,s)):!1}var h4=f4,d4=h4,PA=ei;function MA(r,e,t,n,i){return r===e?!0:r==null||e==null||!PA(r)&&!PA(e)?r!==r&&e!==e:d4(r,e,t,n,MA,i)}var jg=MA,p4=jg;function g4(r,e){return p4(r,e)}var y4=g4;const m4=xn(y4),jr=[];for(let r=0;r<256;++r)jr.push((r+256).toString(16).slice(1));function w4(r,e=0){return(jr[r[e+0]]+jr[r[e+1]]+jr[r[e+2]]+jr[r[e+3]]+"-"+jr[r[e+4]]+jr[r[e+5]]+"-"+jr[r[e+6]]+jr[r[e+7]]+"-"+jr[r[e+8]]+jr[r[e+9]]+"-"+jr[r[e+10]]+jr[r[e+11]]+jr[r[e+12]]+jr[r[e+13]]+jr[r[e+14]]+jr[r[e+15]]).toLowerCase()}let Kg;const b4=new Uint8Array(16);function _4(){if(!Kg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Kg=crypto.getRandomValues.bind(crypto)}return Kg(b4)}const LA={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function A4(r,e,t){if(LA.randomUUID&&!e&&!r)return LA.randomUUID();r=r||{};const n=r.random||(r.rng||_4)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,w4(n)}function Vg(r){return new Promise(e=>{setTimeout(e,r)})}function UA(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 da(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 $d{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 v4=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 Wg{constructor(e={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new $d,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 Vg(this.clearWaitTime);return this.isWaiting=!1,!1}}var DA={};(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=UC(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(sC(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 j(c,f=Math.random){const d=Math.floor(c),y=c-d;return V(y,f)?d+1:d}function V(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=Eb(f,"."),y=aC(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 Ve(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",K="1234567890",Y=v+$+K,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 rg(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=cC(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 ng(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 ig(c,f){if(!ar(c,f).split("").every(d=>d==="_"||ad(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 Nc(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 Xt(c,f){return Nc(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 sg(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 og(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 Cc(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:Cc(c,f)}function vr(c,f){const d=Cc(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 Wh(c,f){const d=Cc(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 $l(c){return kr(c)&&c.match(/^https?:\/\/.+/)!==null}function qh(c,f){if(!$l(c))throw new TypeError(`Expected url${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Zh(c,f){return f==null?!0:c(f)}function Qh(c,f){return f==null?null:c(f)}function Yh(c,f){return f==null?void 0:c(f)}function Fl(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 Jh(c,f){return c.every(d=>Fl(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 Xh(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:
|
|
3
|
-
`).map(
|
|
4
|
-
`)}function
|
|
5
|
-
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function
|
|
6
|
-
`],
|
|
7
|
-
`],
|
|
8
|
-
`],
|
|
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 wC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bC="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function zne(c){return _C(c,wC)}function Gne(c){return AC(c,wC)}function jne(c){return _C(c,bC)}function Kne(c){return AC(c,bC)}function _C(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 AC(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 Vne(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 Wne(c){return Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("")}function qne(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 Sb(c,f,d){const y=[];for(const R of d)R!==f&&y.push(c.replace(f,R));return y}function Zne(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,Sb(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,Sb(c,de,J.variants)),L.length>=d))break}return L.slice(0,d)}function Qne(c,f,d,y=!1){const R=new RegExp(y?`(?<=\\s|^)${f}(?=\\s|$)`:`\\b${f}\\b`,"g");return c.replace(R,d)}function Yne(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 Jne(c){return c.replace(/<[^>]*>/g,"")}function vC(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 Xne(c,f={}){return[...c].reduce((d,y)=>d+(f[y]||1),0)}function eie(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}=vC(R);y.push(De),R=Lt,L=Lt.split("").map(Gr=>d[Gr]||1).reduce((Gr,Vl)=>Gr+Vl,0)}}return R&&y.push(R),y}function tie(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 kb(c,f){return new RegExp(`\\b${f}\\b`).test(c)}function rie(c,f,d){return d==="any"?f.some(y=>kb(c,y)):f.every(y=>kb(c,y))}function nie(c){const f={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const y of d){const[R,L]=xb(y,"=");f[R]=L.slice(1,L.length-1)}return f}function ug(c,f,d=[]){let y="";for(;f<c.length&&(ad(c[f])||d.includes(c[f]));)y+=c[f++];return y}function iie(c,f,d="$",y=":"){for(const R in f)c=EC(c,R,f[R],d,y);return c=xC(c),c}function EC(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=ug(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 xC(c,f="$",d=":"){let y=c.indexOf(f);for(;y!==-1;){const R=ug(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=ug(c,y+R.length+2);c=c.replace(`${f}${R}${d}${L}`,L)}y=c.indexOf(f,y+1)}return c}function sie(c,f){let d=c.indexOf("](");for(;d!==-1;){const y=gC(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 RC(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 oie(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 aie(c,f){return Object.prototype.hasOwnProperty.call(c,f)}function cie(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 uie(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)=>Nc(J[f])-Nc(de[f])),c.forEach((J,de)=>J[f]=de+1)}function lie(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 fie(c,f=":"){return Object.fromEntries(c.map(d=>xb(d,f)).map(d=>d[0]&&d[1]?[od(d[0]),od(d[1])]:null).filter(d=>d))}function hie(c,f,d){return TC(c,f)+RC(d||{})}function die(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 pie(c){return`[${Math.floor(c.progress*100)}%] ${lg(c.deltaMs)} out of ${lg(c.totalTimeMs)} (${lg(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function gie(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 yie(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 mie(c){return JSON.parse(JSON.stringify(c))}function wie(c){return Math.ceil((c||Date.now())/1e3)}function bie(c){return(c||new Date).toISOString().slice(0,10)}function _ie(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function Aie(c){const f=new Date(c);return new Date(f.getTime()-f.getTimezoneOffset()*6e4)}function vie(c){return new Date(c)}function ms(c){return String(Math.floor(c)).padStart(2,"0")}function Eie(c){let[f,d]=c.split(":");pt(parseInt(f,10))||(f="0"),pt(parseInt(d,10))||(d="0");let y=Bb(Xt(f),0,23),R=Bb(Xt(d),0,59);return`${ms(y)}:${ms(R)}`}function lg(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 Bc(c){return Math.floor((or(c)?c.getTime():c)/864e5)}const xie={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 Rie(c,f){const d=new Date((f==null?void 0:f.now)||Date.now()),y=(f==null?void 0:f.labels)||xie,R=or(c)?c:new Date(c);if(Bc(d)===Bc(R))return y.today(R.getUTCHours(),R.getUTCMinutes(),R.getUTCHours()>12);if(Bc(d)-Bc(R)===1)return y.yesterday();const L=Ob(R);return Bc(d)-Bc(R)<7?y[L.day]():y.weeks(Math.round((d.getTime()-R.getTime())/6048e5))}const IC={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 SC(c,f){const d=(f==null?void 0:f.now)??Date.now(),y=(f==null?void 0:f.labels)||IC,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 Iie(c,f=IC){return SC(0,{now:c*1e3,labels:f})}function Sie(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 Tb={};function kie(c,f){return!Tb[c]||Date.now()>Tb[c]?(Tb[c]=Date.now()+f,!0):!1}const Tie={s:1e3,m:6e4,h:36e5,d:864e5};function Oie(c,f,d){return f=or(f)?f.getTime():f,d=d?or(d)?d.getTime():d:Date.now(),(d-f)/Tie[c]}function Nie(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 Cie={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function kC(c){return{zeroBasedIndex:c,day:Cie[c]}}function Ob(c){return kC(c.getDay())}function Bie(c){return Ob(new Date(c))}function Pie(c){return c*1e3}function Mie(c){return c*6e4}function Lie(c){return c*36e5}function Uie(c){return c*864e5}const Die={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 $ie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=Die[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}const Fie={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 Hie(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=Fie[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}function zie(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const Nb={};async function Gie(c,f,d){const y=Date.now(),R=Nb[c];if(R&&R.validUntil>y)return R.value;const L=await d(),J=y+f;return Nb[c]={value:L,validUntil:J},L}function jie(c){delete Nb[c]}function TC(...c){return c.filter(f=>f).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function Kie(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 Vie(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 Wie(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 qie(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 OC(c){const f=Object.keys(c).sort((y,R)=>y.localeCompare(R)),d={};for(const y of f)d[y]=Pc(c[y]);return d}function NC(c){const f=[];return c.sort((d,y)=>JSON.stringify(Pc(d)).localeCompare(JSON.stringify(Pc(y)))).forEach(d=>f.push(Pc(d))),f}function Pc(c){return Array.isArray(c)?NC(c):sr(c)?OC(c):c}function CC(c,f){return JSON.stringify(Pc(c))===JSON.stringify(Pc(f))}function Zie(...c){for(let f=1;f<c.length;f++)if(!CC(c[f-1],c[f]))return!1;return!0}function Qie(c){try{return JSON.parse(c)}catch{return null}}function Yie(){let c=0;return{next:()=>c++}}function Jie(c){let f=0;return{next:()=>c[f++%c.length]}}function Xie(c){let f;return d=>{const y=d===c&&f!==c;return f=d,y}}function ese(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 tse(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 BC(c){const f=Object.keys(c);return f[Math.floor(Math.random()*f.length)]}function rse(c,f){const d=BC(c);return c[d]=f(c[d]),d}function nse(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],ise=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],PC=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function sse(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 ose(c,f){const d=(f==null?void 0:f.longForm)??!1,y=f!=null&&f.unit?` ${f.unit}`:"",R=d?ise:PC,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 Cb(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),y=PC.findIndex(R=>R.toLowerCase()===d.toLowerCase());return y===-1?f:f*ca[y]}function Bb(c,f,d){return c<f?f:c>d?d:c}function ase(c,f,d){const y=c+f;return y>d?d:y}function cse(c,f,d){const y=c-f;return y<d?d:y}function use(c,f){return f(c),c}function lse(c,f){c&&f(c)}function fse(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 hse(c){return c.splice(0,c.length),c}function dse(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 pse(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 gse(c,f){const d={};for(const[y,R]of Object.entries(c))f(y)&&(d[y]=R);return d}function yse(c,f){const d={};for(const[y,R]of Object.entries(c))f(R)&&(d[y]=R);return d}function mse(c,f){const d={};for(const y of Object.entries(c))d[y[0]]=f(y[1]);return d}function wse(c,f){const d=[];let y=0;for(const R of c)d.push(f(R,y++));return d}async function bse(c,f){try{return await c()}catch{throw f}}function _se(c,f,d){d!=null&&(c[f]=d)}function Ase(c,f,d,y){const R=O(d,y);R!=null&&M(c,f,R)}function vse(c){const f={};for(const[d,y]of Object.entries(c))f[y]=d;return f}function Ese(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 xse(c){return Object.values(c).filter(f=>f).length}function Rse(c,f,d){return c+(d?"["+f+"]":(c.length?".":"")+f)}function fg(c,f,d,y,R){if(!sr(f))return f;for(const[L,J]of Object.entries(f)){const de=Rse(d,L,y);Array.isArray(J)?R?fg(c,J,de,!0,R):c[de]=J.map(fe=>fg(Array.isArray(fe)?[]:{},fe,"",!1,R)):sr(J)?fg(c,J,de,!1,R):c[de]=J}return c}function Ise(c,f=!1,d){return fg({},c,d||"",!1,f)}function MC(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=>MC(R))):M(f,d,y);return f}function Sse(c,f,d){return f[c]?f[c]:d}function LC(c,f){const d={};for(const y of c){const R=f(y);d[R]=y}return d}function kse(c,f){const d={};for(const y of c){const R=f(y);d[R]||(d[R]=[]),d[R].push(y)}return d}function Tse(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.slice(y,y+f));return d}function UC(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 DC(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 Ose(c,f){const d=Math.ceil(c.length/f);return DC(c,d)}function Nse(c,f){return Object.values(LC(c,f))}function Cse(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?$C(J,R?(fe,De)=>fe[1]-De[1]:(fe,De)=>De[1]-fe[1]):J;return d?Object.keys(de):de}function $C(c,f){return Object.fromEntries(Object.entries(c).sort(f))}function Bse(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 Pse(c,f,d=1){for(const y of c)y[f]+=d}function Mse(c,f,d){for(const y of c)y[f]=d}function Pb(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 Lse(){return{map:new Map,keys:[]}}function Use(){return{map:new Map,keys:[]}}function FC(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 Dse(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 $se(c,f,d,y,R=100){FC(c,f,{validUntil:Date.now()+y,data:d},R)}function Fse(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 Hse{constructor(f){this.supplier=f,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}r.Lazy=Hse;class zse{constructor(f){this.supplier=f,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}r.AsyncLazy=zse;function Gse(c){return()=>c.forEach(f=>f())}function jse(c,f){return c.reduce((d,y)=>f(d)>f(y)?d:y)}function Kse(c,f){const d=c.find(y=>y instanceof f);return ua.of(d)}function Vse(c,f){return c.filter(d=>d instanceof f)}function Wse(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 qse(c,f){return c.includes(f)?c.filter(d=>d!==f):[...c,f]}class Zse{constructor(f){this.value=f,this.children=[]}}function Qse(c,f,d,y,R=!1){const L=new Map,J=[];c.forEach(fe=>{const De=new Zse(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],Vl=Lt.value[y];return R?Vl-Gr:Gr-Vl}),fe.children.forEach(de)};return J.forEach(de),J}function HC(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 Gl(...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 zC(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function GC(c){return c[0]===255&&c[1]===216}function jC(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function Yse(c){return zC(c)||GC(c)||jC(c)}function Jse(c){return new Uint8Array([c])}function Xse(c){return c[0]}function eoe(c,f){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,f==="LE"),new Uint8Array(d)}function toe(c,f){return new DataView(c.buffer).getUint16(c.byteOffset,f==="LE")}function roe(c,f){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,f==="LE"),new Uint8Array(d)}function noe(c,f){return new DataView(c.buffer).getUint32(c.byteOffset,f==="LE")}function Mb(c,f){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),f==="LE"),new Uint8Array(d)}function ioe(c,f){return new DataView(c.buffer).getBigUint64(c.byteOffset,f==="LE")}function jl(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 Kl(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 soe(c,f){const d=[];let y=0;for(const R of f)d.push(c.subarray(y,y+R)),y+=R;return d}function Lb(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.subarray(y,y+f));return d}const KC=[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 ooe(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],Vl=R<<1|L>>>31,zoe=L<<1|R>>>31,ld=Lt^Vl,fd=Gr^zoe,Goe=J<<1|de>>>31,joe=de<<1|J>>>31,hd=d^Goe,dd=y^joe,Koe=fe<<1|De>>>31,Voe=De<<1|fe>>>31,pd=R^Koe,gd=L^Voe,Woe=Lt<<1|Gr>>>31,qoe=Gr<<1|Lt>>>31,yd=J^Woe,md=de^qoe,Zoe=d<<1|y>>>31,Qoe=y<<1|d>>>31,wd=fe^Zoe,bd=De^Qoe;c[0]^=ld,c[1]^=fd,c[2]^=hd,c[3]^=dd,c[4]^=pd,c[5]^=gd,c[6]^=yd,c[7]^=md,c[8]^=wd,c[9]^=bd,c[10]^=ld,c[11]^=fd,c[12]^=hd,c[13]^=dd,c[14]^=pd,c[15]^=gd,c[16]^=yd,c[17]^=md,c[18]^=wd,c[19]^=bd,c[20]^=ld,c[21]^=fd,c[22]^=hd,c[23]^=dd,c[24]^=pd,c[25]^=gd,c[26]^=yd,c[27]^=md,c[28]^=wd,c[29]^=bd,c[30]^=ld,c[31]^=fd,c[32]^=hd,c[33]^=dd,c[34]^=pd,c[35]^=gd,c[36]^=yd,c[37]^=md,c[38]^=wd,c[39]^=bd,c[40]^=ld,c[41]^=fd,c[42]^=hd,c[43]^=dd,c[44]^=pd,c[45]^=gd,c[46]^=yd,c[47]^=md,c[48]^=wd,c[49]^=bd;const zb=c[0],Gb=c[1],jb=c[2]<<1|c[3]>>>31,Kb=c[3]<<1|c[2]>>>31,Vb=c[5]<<30|c[4]>>>2,Wb=c[4]<<30|c[5]>>>2,qb=c[6]<<28|c[7]>>>4,Zb=c[7]<<28|c[6]>>>4,Qb=c[8]<<27|c[9]>>>5,Yb=c[9]<<27|c[8]>>>5,Jb=c[11]<<4|c[10]>>>28,Xb=c[10]<<4|c[11]>>>28,e_=c[13]<<12|c[12]>>>20,t_=c[12]<<12|c[13]>>>20,r_=c[14]<<6|c[15]>>>26,n_=c[15]<<6|c[14]>>>26,i_=c[17]<<23|c[16]>>>9,s_=c[16]<<23|c[17]>>>9,o_=c[18]<<20|c[19]>>>12,a_=c[19]<<20|c[18]>>>12,c_=c[20]<<3|c[21]>>>29,u_=c[21]<<3|c[20]>>>29,l_=c[22]<<10|c[23]>>>22,f_=c[23]<<10|c[22]>>>22,h_=c[25]<<11|c[24]>>>21,d_=c[24]<<11|c[25]>>>21,p_=c[26]<<25|c[27]>>>7,g_=c[27]<<25|c[26]>>>7,y_=c[29]<<7|c[28]>>>25,m_=c[28]<<7|c[29]>>>25,w_=c[31]<<9|c[30]>>>23,b_=c[30]<<9|c[31]>>>23,__=c[33]<<13|c[32]>>>19,A_=c[32]<<13|c[33]>>>19,v_=c[34]<<15|c[35]>>>17,E_=c[35]<<15|c[34]>>>17,x_=c[36]<<21|c[37]>>>11,R_=c[37]<<21|c[36]>>>11,I_=c[38]<<8|c[39]>>>24,S_=c[39]<<8|c[38]>>>24,k_=c[40]<<18|c[41]>>>14,T_=c[41]<<18|c[40]>>>14,O_=c[42]<<2|c[43]>>>30,N_=c[43]<<2|c[42]>>>30,C_=c[45]<<29|c[44]>>>3,B_=c[44]<<29|c[45]>>>3,P_=c[47]<<24|c[46]>>>8,M_=c[46]<<24|c[47]>>>8,L_=c[48]<<14|c[49]>>>18,U_=c[49]<<14|c[48]>>>18;c[0]=zb^~e_&h_,c[1]=Gb^~t_&d_,c[2]=e_^~h_&x_,c[3]=t_^~d_&R_,c[4]=h_^~x_&L_,c[5]=d_^~R_&U_,c[6]=x_^~L_&zb,c[7]=R_^~U_&Gb,c[8]=L_^~zb&e_,c[9]=U_^~Gb&t_,c[10]=qb^~o_&c_,c[11]=Zb^~a_&u_,c[12]=o_^~c_&__,c[13]=a_^~u_&A_,c[14]=c_^~__&C_,c[15]=u_^~A_&B_,c[16]=__^~C_&qb,c[17]=A_^~B_&Zb,c[18]=C_^~qb&o_,c[19]=B_^~Zb&a_,c[20]=jb^~r_&p_,c[21]=Kb^~n_&g_,c[22]=r_^~p_&I_,c[23]=n_^~g_&S_,c[24]=p_^~I_&k_,c[25]=g_^~S_&T_,c[26]=I_^~k_&jb,c[27]=S_^~T_&Kb,c[28]=k_^~jb&r_,c[29]=T_^~Kb&n_,c[30]=Qb^~Jb&l_,c[31]=Yb^~Xb&f_,c[32]=Jb^~l_&v_,c[33]=Xb^~f_&E_,c[34]=l_^~v_&P_,c[35]=f_^~E_&M_,c[36]=v_^~P_&Qb,c[37]=E_^~M_&Yb,c[38]=P_^~Qb&Jb,c[39]=M_^~Yb&Xb,c[40]=Vb^~i_&y_,c[41]=Wb^~s_&m_,c[42]=i_^~y_&w_,c[43]=s_^~m_&b_,c[44]=y_^~w_&O_,c[45]=m_^~b_&N_,c[46]=w_^~O_&Vb,c[47]=b_^~N_&Wb,c[48]=O_^~Vb&i_,c[49]=N_^~Wb&s_,c[0]^=KC[f*2],c[1]^=KC[f*2+1]}}function VC(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 WC(c,f){if(!c.length){const R=new Uint8Array(136);return R[0]=f,R[135]=128,[VC(R)]}const d=Lb(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(VC)}function qC(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];ooe(c)}return c}function ZC(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 ZC(qC(new Array(50).fill(0),WC(c,1)))}function aoe(c){return ZC(qC(new Array(50).fill(0),WC(c,6)))}function coe(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 uoe(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 loe(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 foe(c,f,d){const y=Math.floor(f/8),R=f%8;return c[y]>>(d==="BE"?7-R:R)&1}function hoe(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 QC(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 doe(c,f,d=0){const y=c.length%f;return y===0?c:QC(c,c.length+f-y,d)}function YC(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 poe(c,f,d=0){const y=c.length%f;return y===0?c:YC(c,c.length+f-y,d)}function goe(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 yoe(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 jt(c,f){return(c%f+f)%f}function cd(c,f){c=jt(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 moe(c,f,d){let y=1n;for(c=jt(c,d);f>0;)f%2n===1n&&(y=jt(y*c,d)),c=jt(c*c,d),f=f/2n;return y}function JC(c,f){return jt(c,f)===0n?0n:f%4n===3n?moe(c,(f+1n)/4n,f):null}const hn=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,zr=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,hg=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,dg=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Ub(c,f,d){if(f===0n)return[0n,0n];const y=jt(3n*c*c*cd(2n*f,d),d),R=jt(y*y-2n*c,d),L=jt(y*(c-R)-f,d);return[R,L]}function pg(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===jt(-y,R))return[0n,0n];if(c===d&&f===y)return Ub(c,f,R);const L=jt((y-f)*cd(d-c,R),R),J=jt(L*L-c-d,R),de=jt(L*(c-J)-f,R);return[J,de]}function woe(c){if(c<=0n||c>=zr)throw new Error("Invalid private key");return Mc(hg,dg,c,hn)}function boe(c){const f=c[1]%2n===0n?2:3;return new Uint8Array([f,...jl(c[0],"BE")])}function _oe(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const f=Kl(c.slice(1),"BE"),d=JC(jt(f**3n+7n,hn),hn);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const y=jt(-d,hn),R=d%2n===0n;return[f,c[0]===2?R?d:y:R?y:d]}function Aoe(c){const f=new Uint8Array(20),d=oo(Gl(jl(c[0],"BE"),jl(c[1],"BE")));return f.set(d.subarray(12)),f}function voe(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 Mc(c,f,d,y){let R=[0n,0n],L=[c,f];const J=d.toString(2);for(const de of J)de==="0"?(L=pg(R[0],R[1],L[0],L[1],y),R=Ub(R[0],R[1],y)):(R=pg(R[0],R[1],L[0],L[1],y),L=Ub(L[0],L[1],y));return R}function Eoe(c,f,d){return XC(Kl(oo(c),"BE"),f,d)}function XC(c,f,d){if(f<=0n||f>=zr)throw new Error("Invalid private key");if(d||(d=jt(Kl(oo(Gl(oo(jl(f,"BE")),jl(c,"BE"))),"BE"),zr)),d<=0n||d>=zr)throw new Error("Invalid nonce");const y=jt(c,zr),R=Mc(hg,dg,d,hn),L=jt(R[0],zr);let J=jt((y+jt(L,zr)*f)*cd(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 xoe(c,f,d,y){const R=JC(jt(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=jt(Kl(oo(c),"BE"),zr),fe=Mc(f,J,d,hn),De=Mc(hg,dg,de,hn),Lt=pg(fe[0],fe[1],De[0],jt(-De[1],hn),hn);return Mc(Lt[0],Lt[1],cd(f,zr),hn)}function Roe(c,f,d,y){const R=jt(Kl(oo(c),"BE"),zr),L=cd(y,zr),J=jt(R*L,zr),de=jt(d*L,zr),fe=Mc(hg,dg,J,hn),De=Mc(f[0],f[1],de,hn),Lt=pg(fe[0],fe[1],De[0],De[1],hn);return d===jt(Lt[0],zr)}class e6{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=e6;class t6{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=t6;class gg{constructor(f,d=0n){this.span=d,this.writer=new t6(new Uint8Array(f))}build(){return Gl(Mb(this.span,"LE"),this.writer.buffer)}hash(){const f=HC(Lb(this.writer.buffer,32),(d,y)=>oo(Gl(d,y)));return oo(Gl(Mb(this.span,"LE"),f))}}r.Chunk=gg;class Db{constructor(f,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new gg(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 e6(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 gg(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 gg(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=Db,e=Db,Db.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 Ioe(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 yg(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 Soe(c,f,d,y){const R=yg(c,f,d,y);if(!R)return null;try{return Cb(R)}catch{throw new Error(`Invalid number argument ${f}: ${R}`)}}function koe(c,f,d,y){const R=c.some(fe=>fe.endsWith("-"+f)),L=yg(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 r6(c,f,d,y){const R=yg(c,f,d,y);if(!R)throw new Error(`Missing argument ${f}`);return R}function Toe(c,f,d,y){const R=r6(c,f,d,y);try{return Cb(R)}catch{throw new Error(`Invalid argument ${f}: ${R}`)}}function n6(c,f){const d=c[f];c.splice(f,1),c.unshift(d)}function Ooe(c,f){const d=[...c];return n6(d,f),d}function i6(c,f){return{x:c.x+f.x,y:c.y+f.y}}function Noe(c,f){return{x:c.x-f.x,y:c.y-f.y}}function $b(c,f){return{x:c.x*f,y:c.y*f}}function Coe(c){const f=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/f,y:c.y/f}}function s6(c,f,d){return{x:c.x+Math.cos(f)*d,y:c.y+Math.sin(f)*d}}function o6(c,f){return Math.sqrt((c.x-f.x)**2+(c.y-f.y)**2)}function ud(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 Boe(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 Poe(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 a6(c,f,d){var y;return!((y=c[f-1])!=null&&y[d])}function c6(c,f,d){var y;return!((y=c[f+1])!=null&&y[d])}function u6(c,f,d){return!c[f][d-1]}function l6(c,f,d){return!c[f][d+1]}function Moe(c,f,d){var R,L,J,de,fe,De,Lt,Gr;const y=[];return c[f][d]?Boe(c,f,d)||Poe(c,f,d)?[]:(!((R=c[f-1])!=null&&R[d-1])&&a6(c,f,d)&&u6(c,f,d)&&y.push({x:f,y:d}),!((L=c[f+1])!=null&&L[d-1])&&c6(c,f,d)&&u6(c,f,d)&&y.push({x:f+1,y:d}),!((J=c[f-1])!=null&&J[d+1])&&a6(c,f,d)&&l6(c,f,d)&&y.push({x:f,y:d+1}),!((de=c[f+1])!=null&&de[d+1])&&c6(c,f,d)&&l6(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 Loe(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=Moe(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 Uoe(c,f){const d=ud(c,(fe,De)=>c[fe][De]===0&&c[fe][De+1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),y=ud(c,(fe,De)=>c[fe][De]===0&&c[fe][De-1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),R=ud(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=ud(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=Pb([...R,...L],(fe,De)=>fe.x===De.x&&fe.y-1===De.y),de=Pb([...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:$b(fe.start,f),end:$b(i6(fe.end,{x:fe.start.dx,y:fe.start.dy}),f)}))}function Doe(c,f){return Math.atan2(f.y-c.y,f.x-c.x)}function $oe(c,f){return f.map(d=>Doe(c,d)).sort((d,y)=>d-y)}function f6(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 Fb(c,f,d){const y=[],R=s6(c,d,1e4);for(const L of f){const J=f6(c,R,L.start,L.end);J&&y.push(J)}return y.length?y.reduce((L,J)=>{const de=o6(c,J),fe=o6(c,L);return de<fe?J:L}):null}function Foe(c,f,d){const y=$oe(c,d),R=[];for(const L of y){const J=Fb(c,f,L-.001),de=Fb(c,f,L+.001);J&&R.push(J),de&&R.push(de)}return R}class Hb{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=Hb;class Hoe{constructor(f,d){this.queue=[],this.running=0,this.onProcessed=new Hb,this.onDrained=new Hb,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=Hoe,r.Binary={hexToUint8Array:Vne,uint8ArrayToHex:Wne,base64ToUint8Array:zne,uint8ArrayToBase64:Gne,base32ToUint8Array:jne,uint8ArrayToBase32:Kne,log2Reduce:HC,partition:Lb,concatBytes:Gl,numberToUint8:Jse,uint8ToNumber:Xse,numberToUint16:eoe,uint16ToNumber:toe,numberToUint32:roe,uint32ToNumber:noe,numberToUint64:Mb,uint64ToNumber:ioe,numberToUint256:jl,uint256ToNumber:Kl,sliceBytes:soe,keccak256:oo,sha3_256:aoe,proximity:coe,commonPrefix:uoe,setBit:loe,getBit:foe,indexOf:hoe,equals:yoe,padStart:QC,padStartToMultiple:doe,padEnd:YC,padEndToMultiple:poe,xorCypher:goe},r.Elliptic={privateKeyToPublicKey:woe,compressPublicKey:boe,publicKeyFromCompressed:_oe,publicKeyToAddress:Aoe,signMessage:Eoe,signHash:XC,verifySignature:Roe,recoverPublicKey:xoe,checksumEncode:voe},r.Random={intBetween:H,floatBetween:D,chance:V,signed:z,makeSeededRng:C,point:Z,procs:j},r.Arrays={countUnique:Cse,makeUnique:Nse,splitBySize:Tse,splitByCount:UC,index:LC,indexCollection:kse,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:l,shuffle:o,initialize:g,initialize2D:w,rotate2D:b,containsShape:I,glue:Yre,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:Zre,filterAndRemove:yie,merge:fse,empty:hse,pushToBucket:nd,unshiftAndLimit:id,atRolling:sd,group:Pb,createOscillator:Jie,organiseWithLimits:ese,tickPlaybook:Ioe,getArgument:yg,getBooleanArgument:koe,getNumberArgument:Soe,requireStringArgument:r6,requireNumberArgument:Toe,bringToFront:Ooe,bringToFrontInPlace:n6,findInstance:Kse,filterInstances:Vse,interleave:Wse,toggle:qse,createHierarchy:Qse,multicall:Gse,maxBy:jse},r.System={sleepMillis:s,forever:te,scheduleMany:ine,waitFor:gie,expandError:Xh,runAndSetInterval:re},r.Numbers={make:Cb,sum:one,average:ane,median:cne,getDistanceFromMidpoint:une,clamp:Bb,range:sC,interpolate:sne,createSequence:Yie,increment:ase,decrement:cse,format:ose,fromDecimals:sse,makeStorage:Hie,asMegabytes:he,convertBytes:ye,hexToRgb:be,rgbToHex:Ve,haversineDistanceToMeters:Fe,roundToNearest:Be,formatDistance:et,triangularNumber:Qe,searchFloat:ot},r.Promises={raceFulfilled:n,invert:t,runInParallelBatches:i},r.Dates={getTimestamp:Rie,getTimeDelta:SC,secondsToHumanTime:Iie,countCycles:Sie,isoDate:bie,throttle:kie,timeSince:Oie,dateTimeSlug:_ie,unixTimestamp:wie,fromUtcString:Aie,fromMillis:vie,getProgress:Nie,humanizeTime:lg,humanizeProgress:pie,createTimeDigits:ms,mapDayNumber:kC,getDayInfoFromDate:Ob,getDayInfoFromDateTimeString:Bie,seconds:Pie,minutes:Mie,hours:Lie,days:Uie,make:$ie,normalizeTime:Eie,absoluteDays:Bc},r.Objects={safeParse:Qie,deleteDeep:A,getDeep:O,setDeep:M,incrementDeep:G,ensureDeep:P,replaceDeep:U,getFirstDeep:le,deepMergeInPlace:Li,deepMerge2:ed,deepMerge3:td,mapAllAsync:Qre,cloneWithJson:mie,sortObject:OC,sortArray:NC,sortAny:Pc,deepEquals:CC,deepEqualsEvery:Zie,runOn:use,ifPresent:lse,zip:Hl,zipSum:rd,removeEmptyArrays:dse,removeEmptyValues:pse,flatten:Ise,unflatten:MC,match:Sse,sort:$C,map:mse,mapIterable:wse,filterKeys:gse,filterValues:yse,rethrow:bse,setSomeOnObject:_se,setSomeDeep:Ase,flip:vse,getAllPermutations:Ese,countTruthyValues:xse,transformToArray:Bse,setMulti:Mse,incrementMulti:Pse,createBidirectionalMap:Lse,createTemporalBidirectionalMap:Use,pushToBidirectionalMap:FC,unshiftToBidirectionalMap:Dse,addToTemporalBidirectionalMap:$se,getFromTemporalBidirectionalMap:Fse,createStatefulToggle:Xie,diffKeys:tse,pickRandomKey:BC,mapRandomKey:rse,fromObjectString:nse,toQueryString:RC,parseQueryString:oie,hasKey:aie,selectMax:cie,reposition:uie,unwrapSingleKey:lie,parseKeyValues:fie},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:$l,isNullable:Zh,asString:ar,asHexString:pr,asSafeString:ig,asIntegerString:ng,asNumber:Nc,asFunction:gr,asInteger:Xt,asBoolean:yr,asDate:sg,asNullableString:mr,asEmptiableString:wr,asId:og,asTime:br,asArray:_r,asObject:Cc,asNullableObject:Ar,asStringMap:vr,asNumericDictionary:Wh,asUrl:qh,asNullable:Qh,asOptional:Yh,enforceObjectShape:Fl,enforceArrayShape:Jh,isPng:zC,isJpg:GC,isWebp:jC,isImage:Yse},r.Strings={tokenizeByCount:Ose,tokenizeByLength:DC,searchHex:rg,searchSubstring:hr,randomHex:dr,randomLetter:We,randomAlphanumeric:$t,randomRichAscii:Ge,randomUnicode:fr,includesAny:lne,slugify:Ab,normalForm:hne,enumify:wne,escapeHtml:_ne,decodeHtmlEntities:vne,after:vb,afterLast:aC,before:oC,beforeLast:Eb,betweenWide:Ene,betweenNarrow:xne,getPreLine:zie,containsWord:kb,containsWords:rie,joinUrl:TC,getFuzzyMatchScore:ag,sortByFuzzyScore:bne,splitOnce:xb,splitAll:cC,randomize:kne,expand:uC,shrinkTrim:od,capitalize:cg,decapitalize:lC,csvEscape:Pne,parseCsv:die,surroundInOut:mne,getExtension:Rb,getBasename:Ib,normalizeEmail:Rne,normalizeFilename:Ine,parseFilename:Sne,camelToTitle:dne,slugToTitle:pne,slugToCamel:gne,joinHumanly:yne,findWeightedPair:yC,extractBlock:mC,extractAllBlocks:Une,replaceBlocks:Dne,indexOfEarliest:zl,lastIndexOfBefore:gC,parseHtmlAttributes:nie,readNextWord:ug,resolveVariables:iie,resolveVariableWithDefaultSyntax:EC,resolveRemainingVariablesWithDefaults:xC,isLetter:fC,isDigit:hC,isLetterOrDigit:ad,isValidObjectPathCharacter:Nne,insert:Cne,indexOfRegex:dC,lineMatches:pC,linesMatchInOrder:Bne,represent:so,resolveMarkdownLinks:sie,buildUrl:hie,isChinese:fne,replaceBetweenStrings:Kie,describeMarkdown:Vie,isBalanced:Wie,textToFormat:qie,splitFormatting:$ne,splitHashtags:Fne,splitUrls:Hne,route:qne,explodeReplace:Sb,generateVariants:Zne,replaceWord:Qne,replacePascalCaseWords:Yne,stripHtml:Jne,breakLine:vC,measureTextWidth:Xne,toLines:eie,levenshteinDistance:tie},r.Assertions={asEqual:Jre,asTrue:Xre,asTruthy:ene,asFalse:tne,asFalsy:rne,asEither:nne},r.Cache={get:Gie,invalidate:jie},r.Vector={addPoint:i6,subtractPoint:Noe,multiplyPoint:$b,normalizePoint:Coe,pushPoint:s6,filterCoordinates:ud,findCorners:Loe,findLines:Uoe,raycast:Fb,raycastCircle:Foe,getLineIntersectionPoint:f6}})(DA);const Vt=xn(DA);Vt.Arrays,Vt.Assertions;const en=Vt.Binary;Vt.Cache,Vt.Dates,Vt.Elliptic,Vt.Numbers,Vt.Objects,Vt.Pagination,Vt.Promises,Vt.Random,Vt.Strings,Vt.System,Vt.Types,Vt.Optional,Vt.Vector,Vt.PubSubChannel,Vt.Chunk;const E4=Vt.MerkleTree;Vt.FixedPointNumber,Vt.Lazy,Vt.AsyncLazy,Vt.AsyncQueue,Vt.Uint8ArrayReader,Vt.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 qg;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(qg||(qg={}));const Te=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 Te.undefined;case"string":return Te.string;case"number":return isNaN(r)?Te.nan:Te.number;case"boolean":return Te.boolean;case"function":return Te.function;case"bigint":return Te.bigint;case"symbol":return Te.symbol;case"object":return Array.isArray(r)?Te.array:r===null?Te.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Te.promise:typeof Map<"u"&&r instanceof Map?Te.map:typeof Set<"u"&&r instanceof Set?Te.set:typeof Date<"u"&&r instanceof Date?Te.date:Te.object;default:return Te.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"]),x4=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 Gc=(r,e)=>{let t;switch(r.code){case we.invalid_type:r.received===Te.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 $A=Gc;function R4(r){$A=r}function Fd(){return $A}const Hd=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}},I4=[];function xe(r,e){const t=Fd(),n=Hd({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Gc?void 0:Gc].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 Ke;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 Ke;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 Ke=Object.freeze({status:"aborted"}),jc=r=>({status:"dirty",value:r}),dn=r=>({status:"valid",value:r}),Zg=r=>r.status==="aborted",Qg=r=>r.status==="dirty",pa=r=>r.status==="valid",Jl=r=>typeof Promise<"u"&&r instanceof Promise;function zd(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 FA(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 Xl,ef;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 HA=(r,e)=>{if(pa(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(Jl(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 HA(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 pa(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=>pa(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(Jl(i)?i:Promise.resolve(i));return HA(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:je.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 qc.create(this,this._def)}or(e){return sf.create([this,e],this._def)}and(e){return of.create(this,e,this._def)}transform(e){return new bi({...Je(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ff({...Je(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new Xg({typeName:je.ZodBranded,type:this,...Je(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new hf({...Je(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return df.create(this,e)}readonly(){return pf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const S4=/^c[^\s-]{8,}$/i,k4=/^[0-9a-z]+$/,T4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O4=/^[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,N4=/^[a-z0-9_-]{21}$/i,C4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,B4=/^[-+]?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)?)??$/,P4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,M4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Yg;const L4=/^(?:(?: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])$/,U4=/^(?:(?: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])$/,D4=/^(([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]))$/,$4=/^(([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])$/,F4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,H4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zA="((\\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])))",z4=new RegExp(`^${zA}$`);function GA(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 G4(r){return new RegExp(`^${GA(r)}$`)}function jA(r){let e=`${zA}T${GA(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 j4(r,e){return!!((e==="v4"||!e)&&L4.test(r)||(e==="v6"||!e)&&D4.test(r))}function K4(r,e){if(!C4.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 V4(r,e){return!!((e==="v4"||!e)&&U4.test(r)||(e==="v6"||!e)&&$4.test(r))}class mi extends tt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Te.string){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.string,received:s.parsedType}),Ke}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")P4.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")Yg||(Yg=new RegExp(M4,"u")),Yg.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")O4.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")N4.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")S4.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")k4.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")T4.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"?jA(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"?z4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?G4(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"?B4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"duration",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?j4(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"?K4(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"?V4(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"?F4.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?H4.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:je.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};function W4(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)!==Te.number){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.number,received:s.parsedType}),Ke}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"?W4(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:je.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)!==Te.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:Te.bigint,received:t.parsedType}),Ke}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:je.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Je(r)})};class tf extends tt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Te.boolean){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.boolean,received:n.parsedType}),Ke}return dn(e.data)}}tf.create=r=>new tf({typeName:je.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Je(r)});class ga extends tt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Te.date){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:Te.date,received:s.parsedType}),Ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_date}),Ke}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 ga({...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}}ga.create=r=>new ga({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:je.ZodDate,...Je(r)});class Gd extends tt{_parse(e){if(this._getType(e)!==Te.symbol){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.symbol,received:n.parsedType}),Ke}return dn(e.data)}}Gd.create=r=>new Gd({typeName:je.ZodSymbol,...Je(r)});class rf extends tt{_parse(e){if(this._getType(e)!==Te.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.undefined,received:n.parsedType}),Ke}return dn(e.data)}}rf.create=r=>new rf({typeName:je.ZodUndefined,...Je(r)});class nf extends tt{_parse(e){if(this._getType(e)!==Te.null){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.null,received:n.parsedType}),Ke}return dn(e.data)}}nf.create=r=>new nf({typeName:je.ZodNull,...Je(r)});class Kc extends tt{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}}Kc.create=r=>new Kc({typeName:je.ZodAny,...Je(r)});class ya extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}}ya.create=r=>new ya({typeName:je.ZodUnknown,...Je(r)});class _s extends tt{_parse(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:Te.never,received:t.parsedType}),Ke}}_s.create=r=>new _s({typeName:je.ZodNever,...Je(r)});class jd extends tt{_parse(e){if(this._getType(e)!==Te.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.void,received:n.parsedType}),Ke}return dn(e.data)}}jd.create=r=>new jd({typeName:je.ZodVoid,...Je(r)});class wi extends tt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==Te.array)return xe(t,{code:we.invalid_type,expected:Te.array,received:t.parsedType}),Ke;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:je.ZodArray,...Je(e)});function Vc(r){if(r instanceof er){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Fi.create(Vc(n))}return new er({...r._def,shape:()=>e})}else return r instanceof wi?new wi({...r._def,type:Vc(r.element)}):r instanceof Fi?Fi.create(Vc(r.unwrap())):r instanceof lo?lo.create(Vc(r.unwrap())):r instanceof $i?$i.create(r.items.map(e=>Vc(e))):r}class er 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)!==Te.object){const l=this._getOrReturnCtx(e);return xe(l,{code:we.invalid_type,expected:Te.object,received:l.parsedType}),Ke}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 er({...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 er({...this._def,unknownKeys:"strip"})}passthrough(){return new er({...this._def,unknownKeys:"passthrough"})}extend(e){return new er({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new er({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new er({...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 er({...this._def,shape:()=>t})}omit(e){const t={};return gt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new er({...this._def,shape:()=>t})}deepPartial(){return Vc(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 er({...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 er({...this._def,shape:()=>t})}keyof(){return KA(gt.objectKeys(this.shape))}}er.create=(r,e)=>new er({shape:()=>r,unknownKeys:"strip",catchall:_s.create(),typeName:je.ZodObject,...Je(e)}),er.strictCreate=(r,e)=>new er({shape:()=>r,unknownKeys:"strict",catchall:_s.create(),typeName:je.ZodObject,...Je(e)}),er.lazycreate=(r,e)=>new er({shape:r,unknownKeys:"strip",catchall:_s.create(),typeName:je.ZodObject,...Je(e)});class sf 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}),Ke}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}),Ke}}get options(){return this._def.options}}sf.create=(r,e)=>new sf({options:r,typeName:je.ZodUnion,...Je(e)});const As=r=>r instanceof cf?As(r.schema):r instanceof bi?As(r.innerType()):r instanceof uf?[r.value]:r instanceof uo?r.options:r instanceof lf?gt.objectValues(r.enum):r instanceof ff?As(r._def.innerType):r instanceof rf?[void 0]:r instanceof nf?[null]:r instanceof Fi?[void 0,...As(r.unwrap())]:r instanceof lo?[null,...As(r.unwrap())]:r instanceof Xg||r instanceof pf?As(r.unwrap()):r instanceof hf?As(r._def.innerType):[];class Kd extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.object)return xe(t,{code:we.invalid_type,expected:Te.object,received:t.parsedType}),Ke;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]}),Ke)}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 Kd({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Je(n)})}}function Jg(r,e){const t=bs(r),n=bs(e);if(r===e)return{valid:!0,data:r};if(t===Te.object&&n===Te.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=Jg(r[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(t===Te.array&&n===Te.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=Jg(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===Te.date&&n===Te.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class of extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(Zg(s)||Zg(o))return Ke;const a=Jg(s.value,o.value);return a.valid?((Qg(s)||Qg(o))&&t.dirty(),{status:t.value,value:a.data}):(xe(n,{code:we.invalid_intersection_types}),Ke)};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}))}}of.create=(r,e,t)=>new of({left:r,right:e,typeName:je.ZodIntersection,...Je(t)});class $i extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.array)return xe(n,{code:we.invalid_type,expected:Te.array,received:n.parsedType}),Ke;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"}),Ke;!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:je.ZodTuple,rest:null,...Je(e)})};class af 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!==Te.object)return xe(n,{code:we.invalid_type,expected:Te.object,received:n.parsedType}),Ke;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 af({keyType:e,valueType:t,typeName:je.ZodRecord,...Je(n)}):new af({keyType:mi.create(),valueType:e,typeName:je.ZodRecord,...Je(t)})}}class Vd 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!==Te.map)return xe(n,{code:we.invalid_type,expected:Te.map,received:n.parsedType}),Ke;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 Ke;(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 Ke;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}}}}Vd.create=(r,e,t)=>new Vd({valueType:e,keyType:r,typeName:je.ZodMap,...Je(t)});class ma extends tt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Te.set)return xe(n,{code:we.invalid_type,expected:Te.set,received:n.parsedType}),Ke;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 Ke;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 ma({...this._def,minSize:{value:e,message:Ue.toString(t)}})}max(e,t){return new ma({...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)}}ma.create=(r,e)=>new ma({valueType:r,minSize:null,maxSize:null,typeName:je.ZodSet,...Je(e)});class Wc extends tt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.function)return xe(t,{code:we.invalid_type,expected:Te.function,received:t.parsedType}),Ke;function n(a,u){return Hd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fd(),Gc].filter(l=>!!l),issueData:{code:we.invalid_arguments,argumentsError:u}})}function i(a,u){return Hd({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fd(),Gc].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 qc){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 Wc({...this._def,args:$i.create(e).rest(ya.create())})}returns(e){return new Wc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Wc({args:e||$i.create([]).rest(ya.create()),returns:t||ya.create(),typeName:je.ZodFunction,...Je(n)})}}class cf 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})}}cf.create=(r,e)=>new cf({getter:r,typeName:je.ZodLazy,...Je(e)});class uf 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}),Ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}uf.create=(r,e)=>new uf({value:r,typeName:je.ZodLiteral,...Je(e)});function KA(r,e){return new uo({values:r,typeName:je.ZodEnum,...Je(e)})}class uo extends tt{constructor(){super(...arguments),Xl.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}),Ke}if(zd(this,Xl)||FA(this,Xl,new Set(this._def.values)),!zd(this,Xl).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}),Ke}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})}}Xl=new WeakMap,uo.create=KA;class lf extends tt{constructor(){super(...arguments),ef.set(this,void 0)}_parse(e){const t=gt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Te.string&&n.parsedType!==Te.number){const i=gt.objectValues(t);return xe(n,{expected:gt.joinValues(i),received:n.parsedType,code:we.invalid_type}),Ke}if(zd(this,ef)||FA(this,ef,new Set(gt.getValidEnumValues(this._def.values))),!zd(this,ef).has(e.data)){const i=gt.objectValues(t);return xe(n,{received:n.data,code:we.invalid_enum_value,options:i}),Ke}return dn(e.data)}get enum(){return this._def.values}}ef=new WeakMap,lf.create=(r,e)=>new lf({values:r,typeName:je.ZodNativeEnum,...Je(e)});class qc extends tt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Te.promise&&t.common.async===!1)return xe(t,{code:we.invalid_type,expected:Te.promise,received:t.parsedType}),Ke;const n=t.parsedType===Te.promise?t.data:Promise.resolve(t.data);return dn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qc.create=(r,e)=>new qc({type:r,typeName:je.ZodPromise,...Je(e)});class bi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.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 Ke;const u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?Ke:u.status==="dirty"||t.value==="dirty"?jc(u.value):u});{if(t.value==="aborted")return Ke;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?Ke:a.status==="dirty"||t.value==="dirty"?jc(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"?Ke:(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"?Ke:(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(!pa(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=>pa(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:je.ZodEffects,effect:e,...Je(t)}),bi.createWithPreprocess=(r,e,t)=>new bi({schema:e,effect:{type:"preprocess",transform:r},typeName:je.ZodEffects,...Je(t)});class Fi extends tt{_parse(e){return this._getType(e)===Te.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fi.create=(r,e)=>new Fi({innerType:r,typeName:je.ZodOptional,...Je(e)});class lo extends tt{_parse(e){return this._getType(e)===Te.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}lo.create=(r,e)=>new lo({innerType:r,typeName:je.ZodNullable,...Je(e)});class ff extends tt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Te.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ff.create=(r,e)=>new ff({innerType:r,typeName:je.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Je(e)});class hf 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 Jl(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}}hf.create=(r,e)=>new hf({innerType:r,typeName:je.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Je(e)});class Wd extends tt{_parse(e){if(this._getType(e)!==Te.nan){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:Te.nan,received:n.parsedType}),Ke}return{status:"valid",value:e.data}}}Wd.create=r=>new Wd({typeName:je.ZodNaN,...Je(r)});const q4=Symbol("zod_brand");class Xg 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 df 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"?Ke:s.status==="dirty"?(t.dirty(),jc(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"?Ke: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 df({in:e,out:t,typeName:je.ZodPipeline})}}class pf extends tt{_parse(e){const t=this._def.innerType._parse(e),n=i=>(pa(i)&&(i.value=Object.freeze(i.value)),i);return Jl(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}pf.create=(r,e)=>new pf({innerType:r,typeName:je.ZodReadonly,...Je(e)});function VA(r,e={},t){return r?Kc.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})}}):Kc.create()}const Z4={object:er.lazycreate};var je;(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"})(je||(je={}));const Q4=(r,e={message:`Input not instance of ${r.name}`})=>VA(t=>t instanceof r,e),WA=mi.create,qA=ao.create,Y4=Wd.create,J4=co.create,ZA=tf.create,X4=ga.create,eM=Gd.create,tM=rf.create,rM=nf.create,nM=Kc.create,iM=ya.create,sM=_s.create,oM=jd.create,aM=wi.create,cM=er.create,uM=er.strictCreate,lM=sf.create,fM=Kd.create,hM=of.create,dM=$i.create,pM=af.create,gM=Vd.create,yM=ma.create,mM=Wc.create,wM=cf.create,bM=uf.create,_M=uo.create,AM=lf.create,vM=qc.create,QA=bi.create,EM=Fi.create,xM=lo.create,RM=bi.createWithPreprocess,IM=df.create;var Zt=Object.freeze({__proto__:null,defaultErrorMap:Gc,setErrorMap:R4,getErrorMap:Fd,makeIssue:Hd,EMPTY_PATH:I4,addIssueToContext:xe,ParseStatus:tn,INVALID:Ke,DIRTY:jc,OK:dn,isAborted:Zg,isDirty:Qg,isValid:pa,isAsync:Jl,get util(){return gt},get objectUtil(){return qg},ZodParsedType:Te,getParsedType:bs,ZodType:tt,datetimeRegex:jA,ZodString:mi,ZodNumber:ao,ZodBigInt:co,ZodBoolean:tf,ZodDate:ga,ZodSymbol:Gd,ZodUndefined:rf,ZodNull:nf,ZodAny:Kc,ZodUnknown:ya,ZodNever:_s,ZodVoid:jd,ZodArray:wi,ZodObject:er,ZodUnion:sf,ZodDiscriminatedUnion:Kd,ZodIntersection:of,ZodTuple:$i,ZodRecord:af,ZodMap:Vd,ZodSet:ma,ZodFunction:Wc,ZodLazy:cf,ZodLiteral:uf,ZodEnum:uo,ZodNativeEnum:lf,ZodPromise:qc,ZodEffects:bi,ZodTransformer:bi,ZodOptional:Fi,ZodNullable:lo,ZodDefault:ff,ZodCatch:hf,ZodNaN:Wd,BRAND:q4,ZodBranded:Xg,ZodPipeline:df,ZodReadonly:pf,custom:VA,Schema:tt,ZodSchema:tt,late:Z4,get ZodFirstPartyTypeKind(){return je},coerce:{string:r=>mi.create({...r,coerce:!0}),number:r=>ao.create({...r,coerce:!0}),boolean:r=>tf.create({...r,coerce:!0}),bigint:r=>co.create({...r,coerce:!0}),date:r=>ga.create({...r,coerce:!0})},any:nM,array:aM,bigint:J4,boolean:ZA,date:X4,discriminatedUnion:fM,effect:QA,enum:_M,function:mM,instanceof:Q4,intersection:hM,lazy:wM,literal:bM,map:gM,nan:Y4,nativeEnum:AM,never:sM,null:rM,nullable:xM,number:qA,object:cM,oboolean:()=>ZA().optional(),onumber:()=>qA().optional(),optional:EM,ostring:()=>WA().optional(),pipeline:IM,preprocess:RM,promise:vM,record:pM,set:yM,strictObject:uM,string:WA,symbol:eM,transformer:QA,tuple:dM,undefined:tM,union:lM,unknown:iM,void:oM,NEVER:Ke,ZodIssueCode:we,quotelessJson:x4,ZodError:$n});const gf=Ui.getInstance(),YA=Zt.object({username:Zt.string(),address:Zt.string(),timestamp:Zt.number(),index:Zt.number(),signature:Zt.string()}),JA=Zt.object({id:Zt.number(),ref:Zt.string(),updater:Zt.string(),timestamp:Zt.number()}),SM=Zt.object({topic:Zt.string(),messageSender:YA.optional(),historyEntry:JA}),kM=Zt.object({events:Zt.array(Zt.object({type:Zt.string(),timestamp:Zt.number()})),messageEntries:Zt.array(Zt.object({index:Zt.number(),timestamp:Zt.number()}))}),TM=Zt.object({allTimeUsers:Zt.record(kM)});function XA(r){const e=SM.safeParse(r);return e.success?r.messageSender&&!CM(r.messageSender)?(console.warn("Invalid messageSender"),!1):OM(r.historyEntry)?!0:(console.warn("Invalid historyEntry"),!1):(gf.warn(e.error.format()),!1)}function OM(r){const e=JA.safeParse(r);return e.success?!0:(gf.warn(e.error.format()),!1)}function NM(r){const e=TM.safeParse(r);return e.success?!0:(gf.warn(e.error.format()),!1)}function CM(r){const e=YA.safeParse(r);return e.success?BM(r):(gf.warn(e.error.format()),!1)}function BM(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 Se.Signature(r.signature).isValid(n,r.address))throw new Error("Signature verification failed!");return!0}catch(e){return gf.warn("Error in validateUserSignature",e),!1}}async function ev(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 Vg(i);for(let g=0;g<o;g++){if(await Promise.resolve(e()))return a();await Vg(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 Fn={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"},PM=1e3,MM=new Error("request for lock canceled");var LM=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 UM{constructor(e,t=MM){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=tv(this._queue,a=>t<=a.priority);o===-1&&e<=this._value?this._dispatchItem(s):this._queue.splice(o+1,0,s)})}runExclusive(e){return LM(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]=[]),DM(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 DM(r,e){const t=tv(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function tv(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var $M=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 FM{constructor(e){this._semaphore=new UM(1,e)}acquire(){return $M(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 rv={};(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}})(rv);var ey,nv;function iv(){return nv||(nv=1,ey={}),ey}var Cr=rv,HM=iv(),sv=Array.prototype.push;function zM(r,e){return e==2?function(t,n){return r.apply(void 0,arguments)}:function(t){return r.apply(void 0,arguments)}}function ty(r,e){return e==2?function(t,n){return r(t,n)}:function(t){return r(t)}}function ov(r){for(var e=r?r.length:0,t=Array(e);e--;)t[e]=r[e];return t}function GM(r){return function(e){return r({},e)}}function jM(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&&sv.apply(o,s),e!=n&&sv.apply(o,i.slice(e+1)),r.apply(this,o)}}function ry(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 ny(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:HM,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,j=b.rearg,V=b.toInteger,oe=b.toPath,ce=Z(Cr.aryMethod),ie={castArray:function(te){return function(){var re=arguments[0];return H(re)?te(ov(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:ty(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 Ve=be[1];z(Ve)?he.prototype[be[0]]=Ve:delete he.prototype[be[0]]}),he}},nthArg:function(te){return function(re){var he=re<0?1:V(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 ny(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):jM(re,be)}return re}function m(te,re,he){return o.rearg&&he>1&&(h||!Cr.skipRearg[te])?j(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,Ve=S(Object(te)),Fe=Ve;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 Ve}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(Ve){var Fe=i?g:b,Be=i?g[ye]:re,et=I(I({},be),Ve);return ny(Fe,he,Be,et)}}function M(te,re){return P(te,function(he){return typeof he=="function"?ty(he,re):he})}function G(te,re){return P(te,function(he){var ye=re.length;return zM(j(ty(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,Ve=re,Fe=ie[be];return Fe?Ve=Fe(re):o.immutable&&(Cr.mutate.array[be]?Ve=ry(re,ov):Cr.mutate.object[be]?Ve=ry(re,GM(re)):Cr.mutate.set[be]&&(Ve=ry(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,Ve,Be),Be):m(be,p(be,Ve,Be),Be),ye=ue(be,ye),ye=B(be,ye,Be),!1}}),!ye}),ye||(ye=Ve),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 KM=ny,iy,av;function qd(){if(av)return iy;av=1;function r(e){return e}return iy=r,iy}var cv=AA,VM=cv&&new cv,uv=VM,WM=qd(),lv=uv,qM=lv?function(r,e){return lv.set(r,e),r}:WM,fv=qM,sy,hv;function Zd(){if(hv)return sy;hv=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 sy=t,sy}var ZM=Zd(),QM=yi();function YM(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=ZM(r.prototype),n=r.apply(t,e);return QM(n)?n:t}}var Qd=YM,JM=Qd,XM=Rn,eL=1;function tL(r,e,t){var n=e&eL,i=JM(r);function s(){var o=this&&this!==XM&&this instanceof s?i:r;return o.apply(n?t:this,arguments)}return s}var rL=tL,oy,dv;function ay(){if(dv)return oy;dv=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 oy=r,oy}var nL=Math.max;function iL(r,e,t,n){for(var i=-1,s=r.length,o=t.length,a=-1,u=e.length,l=nL(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 pv=iL,sL=Math.max;function oL(r,e,t,n){for(var i=-1,s=r.length,o=-1,a=t.length,u=-1,l=e.length,h=sL(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 gv=oL;function aL(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&++n;return n}var cL=aL;function uL(){}var cy=uL,lL=Zd(),fL=cy,hL=4294967295;function Yd(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=hL,this.__views__=[]}Yd.prototype=lL(fL.prototype),Yd.prototype.constructor=Yd;var uy=Yd;function dL(){}var pL=dL,yv=uv,gL=pL,yL=yv?function(r){return yv.get(r)}:gL,mv=yL,mL={},wL=mL,wv=wL,bL=Object.prototype,_L=bL.hasOwnProperty;function AL(r){for(var e=r.name+"",t=wv[e],n=_L.call(wv,e)?t.length:0;n--;){var i=t[n],s=i.func;if(s==null||s==r)return i.name}return e}var vL=AL,EL=Zd(),xL=cy;function Jd(r,e){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}Jd.prototype=EL(xL.prototype),Jd.prototype.constructor=Jd;var bv=Jd;function RL(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var yf=RL,IL=uy,SL=bv,kL=yf;function TL(r){if(r instanceof IL)return r.clone();var e=new SL(r.__wrapped__,r.__chain__);return e.__actions__=kL(r.__actions__),e.__index__=r.__index__,e.__values__=r.__values__,e}var OL=TL,NL=uy,_v=bv,CL=cy,BL=In,PL=ei,ML=OL,LL=Object.prototype,UL=LL.hasOwnProperty;function Xd(r){if(PL(r)&&!BL(r)&&!(r instanceof NL)){if(r instanceof _v)return r;if(UL.call(r,"__wrapped__"))return ML(r)}return new _v(r)}Xd.prototype=CL.prototype,Xd.prototype.constructor=Xd;var DL=Xd,$L=uy,FL=mv,HL=vL,zL=DL;function GL(r){var e=HL(r),t=zL[e];if(typeof t!="function"||!(e in $L.prototype))return!1;if(r===t)return!0;var n=FL(t);return!!n&&r===n[0]}var jL=GL,ly,Av;function vv(){if(Av)return ly;Av=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 ly=n,ly}var KL=fv,VL=vv(),WL=VL(KL),Ev=WL,qL=/\{\n\/\* \[wrapped with (.+)\] \*/,ZL=/,? & /;function QL(r){var e=r.match(qL);return e?e[1].split(ZL):[]}var YL=QL,JL=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function XL(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(JL,`{
|
|
12
|
-
/* [wrapped with `+e+`] */
|
|
13
|
-
`)}var eU=XL,fy,xv;function tU(){if(xv)return fy;xv=1;function r(e){return function(){return e}}return fy=r,fy}var hy,Rv;function Iv(){if(Rv)return hy;Rv=1;var r=fa,e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return hy=e,hy}var dy,Sv;function rU(){if(Sv)return dy;Sv=1;var r=tU(),e=Iv(),t=qd(),n=e?function(i,s){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(s),writable:!0})}:t;return dy=n,dy}var py,kv;function gy(){if(kv)return py;kv=1;var r=rU(),e=vv(),t=e(r);return py=t,py}function nU(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var yy=nU;function iU(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 sU=iU;function oU(r){return r!==r}var aU=oU;function cU(r,e,t){for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}var uU=cU,lU=sU,fU=aU,hU=uU;function dU(r,e,t){return e===e?hU(r,e,t):lU(r,fU,t)}var pU=dU,gU=pU;function yU(r,e){var t=r==null?0:r.length;return!!t&&gU(r,e,0)>-1}var mU=yU,wU=yy,bU=mU,_U=1,AU=2,vU=8,EU=16,xU=32,RU=64,IU=128,SU=256,kU=512,TU=[["ary",IU],["bind",_U],["bindKey",AU],["curry",vU],["curryRight",EU],["flip",kU],["partial",xU],["partialRight",RU],["rearg",SU]];function OU(r,e){return wU(TU,function(t){var n="_."+t[0];e&t[1]&&!bU(r,n)&&r.push(n)}),r.sort()}var NU=OU,CU=YL,BU=eU,PU=gy(),MU=NU;function LU(r,e,t){var n=e+"";return PU(r,BU(n,MU(CU(n),t)))}var Tv=LU,UU=jL,DU=Ev,$U=Tv,FU=1,HU=2,zU=4,GU=8,Ov=32,Nv=64;function jU(r,e,t,n,i,s,o,a,u,l){var h=e&GU,g=h?o:void 0,b=h?void 0:o,w=h?s:void 0,I=h?void 0:s;e|=h?Ov:Nv,e&=~(h?Nv:Ov),e&zU||(e&=~(FU|HU));var S=[r,e,i,w,g,I,b,a,u,l],x=t.apply(void 0,S);return UU(r)&&DU(x,S),x.placeholder=n,$U(x,r,e)}var Cv=jU;function KU(r){var e=r;return e.placeholder}var Bv=KU,VU=yf,WU=Pd,qU=Math.min;function ZU(r,e){for(var t=r.length,n=qU(e.length,t),i=VU(r);n--;){var s=e[n];r[n]=WU(s,t)?i[s]:void 0}return r}var QU=ZU,Pv="__lodash_placeholder__";function YU(r,e){for(var t=-1,n=r.length,i=0,s=[];++t<n;){var o=r[t];(o===e||o===Pv)&&(r[t]=Pv,s[i++]=t)}return s}var my=YU,JU=pv,XU=gv,eD=cL,Mv=Qd,tD=Cv,rD=Bv,nD=QU,iD=my,sD=Rn,oD=1,aD=2,cD=8,uD=16,lD=128,fD=512;function Lv(r,e,t,n,i,s,o,a,u,l){var h=e&lD,g=e&oD,b=e&aD,w=e&(cD|uD),I=e&fD,S=b?void 0:Mv(r);function x(){for(var C=arguments.length,H=Array(C),D=C;D--;)H[D]=arguments[D];if(w)var z=rD(x),W=eD(H,z);if(n&&(H=JU(H,n,i,w)),s&&(H=XU(H,s,o,w)),C-=W,w&&C<l){var Z=iD(H,z);return tD(r,e,Lv,x.placeholder,t,H,Z,a,u,l-C)}var j=g?t:this,V=b?j[r]:r;return C=H.length,a?H=nD(H,a):I&&C>1&&H.reverse(),h&&u<C&&(H.length=u),this&&this!==sD&&this instanceof x&&(V=S||Mv(V)),V.apply(j,H)}return x}var Uv=Lv,hD=ay(),dD=Qd,pD=Uv,gD=Cv,yD=Bv,mD=my,wD=Rn;function bD(r,e,t){var n=dD(r);function i(){for(var s=arguments.length,o=Array(s),a=s,u=yD(i);a--;)o[a]=arguments[a];var l=s<3&&o[0]!==u&&o[s-1]!==u?[]:mD(o,u);if(s-=l.length,s<t)return gD(r,e,pD,i.placeholder,void 0,o,l,void 0,void 0,t-s);var h=this&&this!==wD&&this instanceof i?n:r;return hD(h,this,o)}return i}var _D=bD,AD=ay(),vD=Qd,ED=Rn,xD=1;function RD(r,e,t,n){var i=e&xD,s=vD(r);function o(){for(var a=-1,u=arguments.length,l=-1,h=n.length,g=Array(h+u),b=this&&this!==ED&&this instanceof o?s:r;++l<h;)g[l]=n[l];for(;u--;)g[l++]=arguments[++a];return AD(b,i?t:this,g)}return o}var ID=RD,SD=pv,kD=gv,Dv=my,$v="__lodash_placeholder__",wy=1,TD=2,OD=4,Fv=8,mf=128,Hv=256,ND=Math.min;function CD(r,e){var t=r[1],n=e[1],i=t|n,s=i<(wy|TD|mf),o=n==mf&&t==Fv||n==mf&&t==Hv&&r[7].length<=e[8]||n==(mf|Hv)&&e[7].length<=e[8]&&t==Fv;if(!(s||o))return r;n&wy&&(r[2]=e[2],i|=t&wy?0:OD);var a=e[3];if(a){var u=r[3];r[3]=u?SD(u,a,e[4]):a,r[4]=u?Dv(r[3],$v):e[4]}return a=e[5],a&&(u=r[5],r[5]=u?kD(u,a,e[6]):a,r[6]=u?Dv(r[5],$v):e[6]),a=e[7],a&&(r[7]=a),n&mf&&(r[8]=r[8]==null?e[8]:ND(r[8],e[8])),r[9]==null&&(r[9]=e[9]),r[0]=e[0],r[1]=i,r}var BD=CD,PD=/\s/;function MD(r){for(var e=r.length;e--&&PD.test(r.charAt(e)););return e}var LD=MD,UD=LD,DD=/^\s+/;function $D(r){return r&&r.slice(0,UD(r)+1).replace(DD,"")}var FD=$D,HD=la,zD=ei,GD="[object Symbol]";function jD(r){return typeof r=="symbol"||zD(r)&&HD(r)==GD}var wf=jD,KD=FD,zv=yi(),VD=wf,Gv=NaN,WD=/^[-+]0x[0-9a-f]+$/i,qD=/^0b[01]+$/i,ZD=/^0o[0-7]+$/i,QD=parseInt;function YD(r){if(typeof r=="number")return r;if(VD(r))return Gv;if(zv(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=zv(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=KD(r);var t=qD.test(r);return t||ZD.test(r)?QD(r.slice(2),t?2:8):WD.test(r)?Gv:+r}var JD=YD,XD=JD,jv=1/0,e$=17976931348623157e292;function t$(r){if(!r)return r===0?r:0;if(r=XD(r),r===jv||r===-jv){var e=r<0?-1:1;return e*e$}return r===r?r:0}var r$=t$,n$=r$;function i$(r){var e=n$(r),t=e%1;return e===e?t?e-t:e:0}var Kv=i$,s$=fv,o$=rL,a$=_D,c$=Uv,u$=ID,l$=mv,f$=BD,h$=Ev,d$=Tv,Vv=Kv,p$="Expected a function",Wv=1,g$=2,by=8,_y=16,Ay=32,qv=64,Zv=Math.max;function y$(r,e,t,n,i,s,o,a){var u=e&g$;if(!u&&typeof r!="function")throw new TypeError(p$);var l=n?n.length:0;if(l||(e&=~(Ay|qv),n=i=void 0),o=o===void 0?o:Zv(Vv(o),0),a=a===void 0?a:Vv(a),l-=i?i.length:0,e&qv){var h=n,g=i;n=i=void 0}var b=u?void 0:l$(r),w=[r,e,t,n,i,h,g,s,o,a];if(b&&f$(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:Zv(w[9]-l,0),!a&&e&(by|_y)&&(e&=~(by|_y)),!e||e==Wv)var I=o$(r,e,t);else e==by||e==_y?I=a$(r,e,a):(e==Ay||e==(Wv|Ay))&&!i.length?I=u$(r,e,t,n):I=c$.apply(void 0,w);var S=b?s$:h$;return d$(S(I,w),r,e)}var vy=y$,m$=vy,w$=128;function b$(r,e,t){return e=t?void 0:e,e=r&&e==null?r.length:e,m$(r,w$,void 0,void 0,void 0,void 0,e)}var _$=b$,Ey,Qv;function xy(){if(Qv)return Ey;Qv=1;var r=Iv();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return Ey=e,Ey}var A$=xy(),v$=Zl,E$=Object.prototype,x$=E$.hasOwnProperty;function R$(r,e,t){var n=r[e];(!(x$.call(r,e)&&v$(n,t))||t===void 0&&!(e in r))&&A$(r,e,t)}var Yv=R$,I$=Yv,S$=xy();function k$(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?S$(t,a,u):I$(t,a,u)}return t}var bf=k$,T$=bf,O$=Ud;function N$(r,e){return r&&T$(e,O$(e),r)}var Jv=N$,Ry,Xv;function C$(){if(Xv)return Ry;Xv=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return Ry=r,Ry}var Iy,eE;function B$(){if(eE)return Iy;eE=1;var r=yi(),e=Ug,t=C$(),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 Iy=s,Iy}var Sy,tE;function _f(){if(tE)return Sy;tE=1;var r=yA,e=B$(),t=Ld;function n(i){return t(i)?r(i,!0):e(i)}return Sy=n,Sy}var P$=bf,M$=_f();function L$(r,e){return r&&P$(e,M$(e),r)}var U$=L$,Af={exports:{}};Af.exports;var rE;function nE(){return rE||(rE=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}(Af,Af.exports)),Af.exports}var D$=bf,$$=Og;function F$(r,e){return D$(r,$$(r),e)}var H$=F$,z$=mA,G$=z$(Object.getPrototypeOf,Object),ky=G$,j$=Tg,K$=ky,V$=Og,W$=lA,q$=Object.getOwnPropertySymbols,Z$=q$?function(r){for(var e=[];r;)j$(e,V$(r)),r=K$(r);return e}:W$,iE=Z$,Q$=bf,Y$=iE;function J$(r,e){return Q$(r,Y$(r),e)}var X$=J$,eF=uA,tF=iE,rF=_f();function nF(r){return eF(r,rF,tF)}var iF=nF,sF=Object.prototype,oF=sF.hasOwnProperty;function aF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&oF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var cF=aF,Ty,sE;function Oy(){if(sE)return Ty;sE=1;var r=sA;function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return Ty=e,Ty}var uF=Oy();function lF(r,e){var t=e?uF(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var fF=lF,hF=/\w*$/;function dF(r){var e=new r.constructor(r.source,hF.exec(r));return e.lastIndex=r.lastIndex,e}var pF=dF,oE=Dc,aE=oE?oE.prototype:void 0,cE=aE?aE.valueOf:void 0;function gF(r){return cE?Object(cE.call(r)):{}}var yF=gF,Ny,uE;function lE(){if(uE)return Ny;uE=1;var r=Oy();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return Ny=e,Ny}var mF=Oy(),wF=fF,bF=pF,_F=yF,AF=lE(),vF="[object Boolean]",EF="[object Date]",xF="[object Map]",RF="[object Number]",IF="[object RegExp]",SF="[object Set]",kF="[object String]",TF="[object Symbol]",OF="[object ArrayBuffer]",NF="[object DataView]",CF="[object Float32Array]",BF="[object Float64Array]",PF="[object Int8Array]",MF="[object Int16Array]",LF="[object Int32Array]",UF="[object Uint8Array]",DF="[object Uint8ClampedArray]",$F="[object Uint16Array]",FF="[object Uint32Array]";function HF(r,e,t){var n=r.constructor;switch(e){case OF:return mF(r);case vF:case EF:return new n(+r);case NF:return wF(r,t);case CF:case BF:case PF:case MF:case LF:case UF:case DF:case $F:case FF:return AF(r,t);case xF:return new n;case RF:case kF:return new n(r);case IF:return bF(r);case SF:return new n;case TF:return _F(r)}}var zF=HF,Cy,fE;function hE(){if(fE)return Cy;fE=1;var r=Zd(),e=ky,t=Ug;function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return Cy=n,Cy}var GF=Yl,jF=ei,KF="[object Map]";function VF(r){return jF(r)&&GF(r)==KF}var WF=VF,qF=WF,ZF=Pg,dE=Mg,pE=dE&&dE.isMap,QF=pE?ZF(pE):qF,YF=QF,JF=Yl,XF=ei,e9="[object Set]";function t9(r){return XF(r)&&JF(r)==e9}var r9=t9,n9=r9,i9=Pg,gE=Mg,yE=gE&&gE.isSet,s9=yE?i9(yE):n9,o9=s9,a9=Td,c9=yy,u9=Yv,l9=Jv,f9=U$,h9=nE(),d9=yf,p9=H$,g9=X$,y9=bA,m9=iF,w9=Yl,b9=cF,_9=zF,A9=hE(),v9=In,E9=Bd,x9=YF,R9=yi(),I9=o9,S9=Ud,k9=_f(),T9=1,O9=2,N9=4,mE="[object Arguments]",C9="[object Array]",B9="[object Boolean]",P9="[object Date]",M9="[object Error]",wE="[object Function]",L9="[object GeneratorFunction]",U9="[object Map]",D9="[object Number]",bE="[object Object]",$9="[object RegExp]",F9="[object Set]",H9="[object String]",z9="[object Symbol]",G9="[object WeakMap]",j9="[object ArrayBuffer]",K9="[object DataView]",V9="[object Float32Array]",W9="[object Float64Array]",q9="[object Int8Array]",Z9="[object Int16Array]",Q9="[object Int32Array]",Y9="[object Uint8Array]",J9="[object Uint8ClampedArray]",X9="[object Uint16Array]",eH="[object Uint32Array]",Ft={};Ft[mE]=Ft[C9]=Ft[j9]=Ft[K9]=Ft[B9]=Ft[P9]=Ft[V9]=Ft[W9]=Ft[q9]=Ft[Z9]=Ft[Q9]=Ft[U9]=Ft[D9]=Ft[bE]=Ft[$9]=Ft[F9]=Ft[H9]=Ft[z9]=Ft[Y9]=Ft[J9]=Ft[X9]=Ft[eH]=!0,Ft[M9]=Ft[wE]=Ft[G9]=!1;function e0(r,e,t,n,i,s){var o,a=e&T9,u=e&O9,l=e&N9;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!R9(r))return r;var h=v9(r);if(h){if(o=b9(r),!a)return d9(r,o)}else{var g=w9(r),b=g==wE||g==L9;if(E9(r))return h9(r,a);if(g==bE||g==mE||b&&!i){if(o=u||b?{}:A9(r),!a)return u?g9(r,f9(o,r)):p9(r,l9(o,r))}else{if(!Ft[g])return i?r:{};o=_9(r,g,a)}}s||(s=new a9);var w=s.get(r);if(w)return w;s.set(r,o),I9(r)?r.forEach(function(x){o.add(e0(x,e,t,x,r,s))}):x9(r)&&r.forEach(function(x,C){o.set(C,e0(x,e,t,C,r,s))});var I=l?u?m9:y9:u?k9:S9,S=h?void 0:I(r);return c9(S||r,function(x,C){S&&(C=x,x=r[C]),u9(o,C,e0(x,e,t,C,r,s))}),o}var _E=e0,tH=_E,rH=4;function nH(r){return tH(r,rH)}var iH=nH,sH=vy,oH=8;function By(r,e,t){e=t?void 0:e;var n=sH(r,oH,void 0,void 0,void 0,void 0,void 0,e);return n.placeholder=By.placeholder,n}By.placeholder={};var aH=By,cH=la,uH=ky,lH=ei,fH="[object Object]",hH=Function.prototype,dH=Object.prototype,AE=hH.toString,pH=dH.hasOwnProperty,gH=AE.call(Object);function yH(r){if(!lH(r)||cH(r)!=fH)return!1;var e=uH(r);if(e===null)return!0;var t=pH.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&AE.call(t)==gH}var vE=yH,mH=la,wH=ei,bH=vE,_H="[object DOMException]",AH="[object Error]";function vH(r){if(!wH(r))return!1;var e=mH(r);return e==AH||e==_H||typeof r.message=="string"&&typeof r.name=="string"&&!bH(r)}var EH=vH,xH=Yl,RH=ei,IH="[object WeakMap]";function SH(r){return RH(r)&&xH(r)==IH}var kH=SH,TH=Td,OH=jg,NH=1,CH=2;function BH(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 TH;if(n)var b=n(l,h,u,r,e,g);if(!(b===void 0?OH(h,l,NH|CH,n,g):b))return!1}}return!0}var PH=BH,MH=yi();function LH(r){return r===r&&!MH(r)}var EE=LH,UH=EE,DH=Ud;function $H(r){for(var e=DH(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,UH(i)]}return e}var FH=$H;function HH(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var xE=HH,zH=PH,GH=FH,jH=xE;function KH(r){var e=GH(r);return e.length==1&&e[0][2]?jH(e[0][0],e[0][1]):function(t){return t===r||zH(t,r,e)}}var VH=KH,WH=In,qH=wf,ZH=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,QH=/^\w*$/;function YH(r,e){if(WH(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||qH(r)?!0:QH.test(r)||!ZH.test(r)||e!=null&&r in Object(e)}var Py=YH,RE=Sg,JH="Expected a function";function My(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(JH);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(My.Cache||RE),t}My.Cache=RE;var XH=My,e7=XH,t7=500;function r7(r){var e=e7(r,function(n){return t.size===t7&&t.clear(),n}),t=e.cache;return e}var n7=r7,i7=n7,s7=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o7=/\\(\\)?/g,a7=i7(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(s7,function(t,n,i,s){e.push(i?s.replace(o7,"$1"):n||t)}),e}),IE=a7;function c7(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 SE=c7,kE=Dc,u7=SE,l7=In,f7=wf,h7=1/0,TE=kE?kE.prototype:void 0,OE=TE?TE.toString:void 0;function NE(r){if(typeof r=="string")return r;if(l7(r))return u7(r,NE)+"";if(f7(r))return OE?OE.call(r):"";var e=r+"";return e=="0"&&1/r==-h7?"-0":e}var d7=NE,p7=d7;function g7(r){return r==null?"":p7(r)}var CE=g7,y7=In,m7=Py,w7=IE,b7=CE;function _7(r,e){return y7(r)?r:m7(r,e)?[r]:w7(b7(r))}var BE=_7,A7=wf,v7=1/0;function E7(r){if(typeof r=="string"||A7(r))return r;var e=r+"";return e=="0"&&1/r==-v7?"-0":e}var vf=E7,x7=BE,R7=vf;function I7(r,e){e=x7(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[R7(e[t++])];return t&&t==n?r:void 0}var PE=I7,S7=PE;function k7(r,e,t){var n=r==null?void 0:S7(r,e);return n===void 0?t:n}var T7=k7;function O7(r,e){return r!=null&&e in Object(r)}var N7=O7,C7=BE,B7=Nd(),P7=In,M7=Pd,L7=Bg,U7=vf;function D7(r,e,t){e=C7(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=U7(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&&L7(i)&&M7(o,i)&&(P7(r)||B7(r)))}var $7=D7,F7=N7,H7=$7;function z7(r,e){return r!=null&&H7(r,e,F7)}var G7=z7,j7=jg,K7=T7,V7=G7,W7=Py,q7=EE,Z7=xE,Q7=vf,Y7=1,J7=2;function X7(r,e){return W7(r)&&q7(e)?Z7(Q7(r),e):function(t){var n=K7(t,r);return n===void 0&&n===e?V7(t,r):j7(e,n,Y7|J7)}}var ez=X7;function tz(r){return function(e){return e==null?void 0:e[r]}}var rz=tz,nz=PE;function iz(r){return function(e){return nz(e,r)}}var sz=iz,oz=rz,az=sz,cz=Py,uz=vf;function lz(r){return cz(r)?oz(uz(r)):az(r)}var fz=lz,hz=VH,dz=ez,pz=qd(),gz=In,yz=fz;function mz(r){return typeof r=="function"?r:r==null?pz:typeof r=="object"?gz(r)?dz(r[0],r[1]):hz(r):yz(r)}var wz=mz,bz=_E,_z=wz,Az=1;function vz(r){return _z(typeof r=="function"?r:bz(r,Az))}var Ez=vz,ME=Dc,xz=Nd(),Rz=In,LE=ME?ME.isConcatSpreadable:void 0;function Iz(r){return Rz(r)||xz(r)||!!(LE&&r&&r[LE])}var Sz=Iz,kz=Tg,Tz=Sz;function UE(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=Tz),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?UE(a,e-1,t,n,i):kz(i,a):n||(i[i.length]=a)}return i}var Oz=UE,Nz=Oz;function Cz(r){var e=r==null?0:r.length;return e?Nz(r,1):[]}var Bz=Cz,Ly,DE;function $E(){if(DE)return Ly;DE=1;var r=ay(),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 Ly=t,Ly}var Pz=Bz,Mz=$E(),Lz=gy();function Uz(r){return Lz(Mz(r,void 0,Pz),r+"")}var Dz=Uz,$z=vy,Fz=Dz,Hz=256,zz=Fz(function(r,e){return $z(r,Hz,void 0,void 0,void 0,e)}),Gz=zz,jz=SE,Kz=yf,Vz=In,Wz=wf,qz=IE,Zz=vf,Qz=CE;function Yz(r){return Vz(r)?jz(r,Zz):Wz(r)?[r]:Kz(qz(Qz(r)))}var Jz=Yz,Xz={ary:_$,assign:Jv,clone:iH,curry:aH,forEach:yy,isArray:In,isError:EH,isFunction:Id,isWeakMap:kH,iteratee:Ez,keys:wA,rearg:Gz,toInteger:Kv,toPath:Jz},eG=KM,tG=Xz;function rG(r,e,t){return eG(tG,r,e,t)}var nG=rG,Uy,FE;function HE(){if(FE)return Uy;FE=1;var r=xy(),e=Zl;function t(n,i,s){(s!==void 0&&!e(n[i],s)||s===void 0&&!(i in n))&&r(n,i,s)}return Uy=t,Uy}var Dy,zE;function iG(){if(zE)return Dy;zE=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 Dy=r,Dy}var $y,GE;function sG(){if(GE)return $y;GE=1;var r=iG(),e=r();return $y=e,$y}var Fy,jE;function oG(){if(jE)return Fy;jE=1;var r=Ld,e=ei;function t(n){return e(n)&&r(n)}return Fy=t,Fy}var Hy,KE;function VE(){if(KE)return Hy;KE=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return Hy=r,Hy}var zy,WE;function aG(){if(WE)return zy;WE=1;var r=bf,e=_f();function t(n){return r(n,e(n))}return zy=t,zy}var Gy,qE;function cG(){if(qE)return Gy;qE=1;var r=HE(),e=nE(),t=lE(),n=yf,i=hE(),s=Nd(),o=In,a=oG(),u=Bd,l=Id,h=yi(),g=vE,b=Lg,w=VE(),I=aG();function S(x,C,H,D,z,W,Z){var j=w(x,H),V=w(C,H),oe=Z.get(V);if(oe){r(x,H,oe);return}var ce=W?W(j,V,H+"",x,C,Z):void 0,ie=ce===void 0;if(ie){var ue=o(V),B=!ue&&u(V),p=!ue&&!B&&b(V);ce=V,ue||B||p?o(j)?ce=j:a(j)?ce=n(j):B?(ie=!1,ce=e(V,!0)):p?(ie=!1,ce=t(V,!0)):ce=[]:g(V)||s(V)?(ce=j,s(j)?ce=I(j):(!h(j)||l(j))&&(ce=i(V))):ie=!1}ie&&(Z.set(V,ce),z(ce,V,D,W,Z),Z.delete(V)),r(x,H,ce)}return Gy=S,Gy}var jy,ZE;function uG(){if(ZE)return jy;ZE=1;var r=Td,e=HE(),t=sG(),n=cG(),i=yi(),s=_f(),o=VE();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 jy=a,jy}var Ky,QE;function lG(){if(QE)return Ky;QE=1;var r=qd(),e=$E(),t=gy();function n(i,s){return t(e(i,s,r),i+"")}return Ky=n,Ky}var Vy,YE;function fG(){if(YE)return Vy;YE=1;var r=Zl,e=Ld,t=Pd,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 Vy=i,Vy}var Wy,JE;function hG(){if(JE)return Wy;JE=1;var r=lG(),e=fG();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 Wy=t,Wy}var qy,XE;function dG(){if(XE)return qy;XE=1;var r=uG(),e=hG(),t=e(function(n,i,s,o){r(n,i,s,o)});return qy=t,qy}var pG=nG,e2=pG("mergeWith",dG());e2.placeholder=iv();var gG=e2;const yG=xn(gG);class mG{constructor(e,t,n,i){this.userDetails=e,this.utils=t,this.chatSettings=n,this.emitter=i,this.mutex=new FM,this.logger=Ui.getInstance(),this.errorHandler=new $d,this.messagesQueue=new Wg({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||!(e!=null&&e.ref)){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),da(t.updater.toLowerCase())===da(this.userDetails.ownAddress.toLowerCase())&&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 ev({condition:()=>this.historyEntry.ref===e.ref,broadcast:()=>this.broadcastHistoryEntry(e)})}async broadcastHistoryEntry(e){try{await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({topic:this.chatSettings.chatTopic,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.uploadObjectToBee(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 NM(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),XA(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(Fn.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 yG((n,i)=>{if(!n)return i;if(!i)return n;const s=UA(n.events,i.events,a=>`${a.type}-${a.timestamp}`,(a,u)=>a.timestamp-u.timestamp),o=UA(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 Zc=globalThis||void 0||self;var Zy={},t0={};t0.byteLength=_G,t0.toByteArray=vG,t0.fromByteArray=RG;for(var Hi=[],ti=[],wG=typeof Uint8Array<"u"?Uint8Array:Array,Qy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qc=0,bG=Qy.length;Qc<bG;++Qc)Hi[Qc]=Qy[Qc],ti[Qy.charCodeAt(Qc)]=Qc;ti[45]=62,ti[95]=63;function t2(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 _G(r){var e=t2(r),t=e[0],n=e[1];return(t+n)*3/4-n}function AG(r,e,t){return(e+t)*3/4-t}function vG(r){var e,t=t2(r),n=t[0],i=t[1],s=new wG(AG(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 EG(r){return Hi[r>>18&63]+Hi[r>>12&63]+Hi[r>>6&63]+Hi[r&63]}function xG(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(EG(n));return i.join("")}function RG(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,a=t-n;o<a;o+=s)i.push(xG(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 Yy={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Yy.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)},Yy.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};/*!
|
|
1
|
+
(function(ue,xt){typeof exports=="object"&&typeof module<"u"?xt(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],xt):(ue=typeof globalThis<"u"?globalThis:ue||self,xt(ue.SwarmChatJs={},ue.BeeJs))})(this,function(ue,xt){"use strict";var DZ=Object.defineProperty;var JT=ue=>{throw TypeError(ue)};var FZ=(ue,xt,ae)=>xt in ue?DZ(ue,xt,{enumerable:!0,configurable:!0,writable:!0,value:ae}):ue[xt]=ae;var Z=(ue,xt,ae)=>FZ(ue,typeof xt!="symbol"?xt+"":xt,ae),xb=(ue,xt,ae)=>xt.has(ue)||JT("Cannot "+ae);var S=(ue,xt,ae)=>(xb(ue,xt,"read from private field"),ae?ae.call(ue):xt.get(ue)),Y=(ue,xt,ae)=>xt.has(ue)?JT("Cannot add the same private member more than once"):xt instanceof WeakSet?xt.add(ue):xt.set(ue,ae),F=(ue,xt,ae,Mr)=>(xb(ue,xt,"write to private field"),Mr?Mr.call(ue,ae):xt.set(ue,ae),ae),yt=(ue,xt,ae)=>(xb(ue,xt,"access private method"),ae);var ao=(ue,xt,ae,Mr)=>({set _(Lc){F(ue,xt,Lc,ae)},get _(){return S(ue,xt,Mr)}});var oi,Qu,Yu,Ho,kh,Ju,Th,ai,Xu,Ar,Oh,ci,tl,Vs,Nh,Mp,Ee,XT,tO,eO,nO,rO,ig,Rb,Ib,sg,iO,og,el,sc,zo,nl,rl,ki,Ks,il,sl,$n,jr,js,oc,ac,cc,ss,Ti,Go,uc,_d,Ch,Bh,Ph,Wr,ol,lc,al,Ws,fc,ul,ag,Br,Zr,hc,dc,Vo,pc,kb,aO,ll,fl,hl,gc,Zs,mc,os,dl,pl,gl,yl,ml,wl,bl,_l,Al,El,vl,wc,Ko,Qs,jo,xl,cg,Mh,Js,Rl,Up,cO,Jn,Ni,Lh,Tb,Il,ug,Wo,Jl,as,cs,us,or,ls,lg,fg,Xs,Uh,Zo,Sl,Dh,Fh,Vk,qo,_c,Qo,Xl,$p,uO,Hh,zh,Tl,Ol,Yo,to,fi,Jo,fs,Cl,hg,Ac,Ec,Xo,Bl,eo,Hp,Pl,no,Ml,Ll,ta,hi,zp,lO,ar,ea,cr,Ul,qr,vc,na,ro,Gh,di,Dl,Fl,se,Qr,Ob,Nb,Ad,Cb,Ed,dg,Er,hs,xc,ra,Rc,$l,ia,Bb,Pb,Ic,Sc,Hl,io,ds,Ci,pi,Pr,Vh,Mb,sa,zl,ps,Kh,oa,kc,aa,jh,Tc,Gl,ca,Oc,Bi;var ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Lc(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}function fO(){this.__data__=[],this.size=0}var hO=fO;function dO(n,t){return n===t||n!==n&&t!==t}var Lb=dO,pO=Lb;function gO(n,t){for(var e=n.length;e--;)if(pO(n[e][0],t))return e;return-1}var vd=gO,yO=vd,mO=Array.prototype,wO=mO.splice;function bO(n){var t=this.__data__,e=yO(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():wO.call(t,e,1),--this.size,!0}var _O=bO,AO=vd;function EO(n){var t=this.__data__,e=AO(t,n);return e<0?void 0:t[e][1]}var vO=EO,xO=vd;function RO(n){return xO(this.__data__,n)>-1}var IO=RO,SO=vd;function kO(n,t){var e=this.__data__,r=SO(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var TO=kO,OO=hO,NO=_O,CO=vO,BO=IO,PO=TO;function Uc(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Uc.prototype.clear=OO,Uc.prototype.delete=NO,Uc.prototype.get=CO,Uc.prototype.has=BO,Uc.prototype.set=PO;var xd=Uc,MO=xd;function LO(){this.__data__=new MO,this.size=0}var UO=LO;function DO(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var FO=DO;function $O(n){return this.__data__.get(n)}var HO=$O;function zO(n){return this.__data__.has(n)}var GO=zO,VO=typeof ae=="object"&&ae&&ae.Object===Object&&ae,Ub=VO,KO=Ub,jO=typeof self=="object"&&self&&self.Object===Object&&self,WO=KO||jO||Function("return this")(),ms=WO,ZO=ms,qO=ZO.Symbol,pg=qO,Db=pg,Fb=Object.prototype,QO=Fb.hasOwnProperty,YO=Fb.toString,tf=Db?Db.toStringTag:void 0;function JO(n){var t=QO.call(n,tf),e=n[tf];try{n[tf]=void 0;var r=!0}catch{}var i=YO.call(n);return r&&(t?n[tf]=e:delete n[tf]),i}var XO=JO,tN=Object.prototype,eN=tN.toString;function nN(n){return eN.call(n)}var rN=nN,$b=pg,iN=XO,sN=rN,oN="[object Null]",aN="[object Undefined]",Hb=$b?$b.toStringTag:void 0;function cN(n){return n==null?n===void 0?aN:oN:Hb&&Hb in Object(n)?iN(n):sN(n)}var Rd=cN;function uN(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var zb=uN,lN=Rd,fN=zb,hN="[object AsyncFunction]",dN="[object Function]",pN="[object GeneratorFunction]",gN="[object Proxy]";function yN(n){if(!fN(n))return!1;var t=lN(n);return t==dN||t==pN||t==hN||t==gN}var Gb=yN,mN=ms,wN=mN["__core-js_shared__"],bN=wN,gg=bN,Vb=function(){var n=/[^.]+$/.exec(gg&&gg.keys&&gg.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function _N(n){return!!Vb&&Vb in n}var AN=_N,EN=Function.prototype,vN=EN.toString;function xN(n){if(n!=null){try{return vN.call(n)}catch{}try{return n+""}catch{}}return""}var Kb=xN,RN=Gb,IN=AN,SN=zb,kN=Kb,TN=/[\\^$.*+?()[\]{}|]/g,ON=/^\[object .+?Constructor\]$/,NN=Function.prototype,CN=Object.prototype,BN=NN.toString,PN=CN.hasOwnProperty,MN=RegExp("^"+BN.call(PN).replace(TN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function LN(n){if(!SN(n)||IN(n))return!1;var t=RN(n)?MN:ON;return t.test(kN(n))}var UN=LN;function DN(n,t){return n==null?void 0:n[t]}var FN=DN,$N=UN,HN=FN;function zN(n,t){var e=HN(n,t);return $N(e)?e:void 0}var Dc=zN,GN=Dc,VN=ms,KN=GN(VN,"Map"),yg=KN,jN=Dc,WN=jN(Object,"create"),Id=WN,jb=Id;function ZN(){this.__data__=jb?jb(null):{},this.size=0}var qN=ZN;function QN(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var YN=QN,JN=Id,XN="__lodash_hash_undefined__",tC=Object.prototype,eC=tC.hasOwnProperty;function nC(n){var t=this.__data__;if(JN){var e=t[n];return e===XN?void 0:e}return eC.call(t,n)?t[n]:void 0}var rC=nC,iC=Id,sC=Object.prototype,oC=sC.hasOwnProperty;function aC(n){var t=this.__data__;return iC?t[n]!==void 0:oC.call(t,n)}var cC=aC,uC=Id,lC="__lodash_hash_undefined__";function fC(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=uC&&t===void 0?lC:t,this}var hC=fC,dC=qN,pC=YN,gC=rC,yC=cC,mC=hC;function Fc(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Fc.prototype.clear=dC,Fc.prototype.delete=pC,Fc.prototype.get=gC,Fc.prototype.has=yC,Fc.prototype.set=mC;var wC=Fc,Wb=wC,bC=xd,_C=yg;function AC(){this.size=0,this.__data__={hash:new Wb,map:new(_C||bC),string:new Wb}}var EC=AC;function vC(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var xC=vC,RC=xC;function IC(n,t){var e=n.__data__;return RC(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Sd=IC,SC=Sd;function kC(n){var t=SC(this,n).delete(n);return this.size-=t?1:0,t}var TC=kC,OC=Sd;function NC(n){return OC(this,n).get(n)}var CC=NC,BC=Sd;function PC(n){return BC(this,n).has(n)}var MC=PC,LC=Sd;function UC(n,t){var e=LC(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var DC=UC,FC=EC,$C=TC,HC=CC,zC=MC,GC=DC;function $c(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}$c.prototype.clear=FC,$c.prototype.delete=$C,$c.prototype.get=HC,$c.prototype.has=zC,$c.prototype.set=GC;var Zb=$c,VC=xd,KC=yg,jC=Zb,WC=200;function ZC(n,t){var e=this.__data__;if(e instanceof VC){var r=e.__data__;if(!KC||r.length<WC-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new jC(r)}return e.set(n,t),this.size=e.size,this}var qC=ZC,QC=xd,YC=UO,JC=FO,XC=HO,t6=GO,e6=qC;function Hc(n){var t=this.__data__=new QC(n);this.size=t.size}Hc.prototype.clear=YC,Hc.prototype.delete=JC,Hc.prototype.get=XC,Hc.prototype.has=t6,Hc.prototype.set=e6;var n6=Hc,r6="__lodash_hash_undefined__";function i6(n){return this.__data__.set(n,r6),this}var s6=i6;function o6(n){return this.__data__.has(n)}var a6=o6,c6=Zb,u6=s6,l6=a6;function kd(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new c6;++t<e;)this.add(n[t])}kd.prototype.add=kd.prototype.push=u6,kd.prototype.has=l6;var f6=kd;function h6(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var d6=h6;function p6(n,t){return n.has(t)}var g6=p6,y6=f6,m6=d6,w6=g6,b6=1,_6=2;function A6(n,t,e,r,i,s){var o=e&b6,a=n.length,u=t.length;if(a!=u&&!(o&&u>a))return!1;var f=s.get(n),h=s.get(t);if(f&&h)return f==t&&h==n;var y=-1,_=!0,w=e&_6?new y6:void 0;for(s.set(n,t),s.set(t,n);++y<a;){var R=n[y],T=t[y];if(r)var I=o?r(T,R,y,t,n,s):r(R,T,y,n,t,s);if(I!==void 0){if(I)continue;_=!1;break}if(w){if(!m6(t,function(B,H){if(!w6(w,H)&&(R===B||i(R,B,e,r,s)))return w.push(H)})){_=!1;break}}else if(!(R===T||i(R,T,e,r,s))){_=!1;break}}return s.delete(n),s.delete(t),_}var qb=A6,E6=ms,v6=E6.Uint8Array,x6=v6;function R6(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var I6=R6;function S6(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var k6=S6,Qb=pg,Yb=x6,T6=Lb,O6=qb,N6=I6,C6=k6,B6=1,P6=2,M6="[object Boolean]",L6="[object Date]",U6="[object Error]",D6="[object Map]",F6="[object Number]",$6="[object RegExp]",H6="[object Set]",z6="[object String]",G6="[object Symbol]",V6="[object ArrayBuffer]",K6="[object DataView]",Jb=Qb?Qb.prototype:void 0,mg=Jb?Jb.valueOf:void 0;function j6(n,t,e,r,i,s,o){switch(e){case K6:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case V6:return!(n.byteLength!=t.byteLength||!s(new Yb(n),new Yb(t)));case M6:case L6:case F6:return T6(+n,+t);case U6:return n.name==t.name&&n.message==t.message;case $6:case z6:return n==t+"";case D6:var a=N6;case H6:var u=r&B6;if(a||(a=C6),n.size!=t.size&&!u)return!1;var f=o.get(n);if(f)return f==t;r|=P6,o.set(n,t);var h=O6(a(n),a(t),r,i,s,o);return o.delete(n),h;case G6:if(mg)return mg.call(n)==mg.call(t)}return!1}var W6=j6;function Z6(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var q6=Z6,Q6=Array.isArray,wg=Q6,Y6=q6,J6=wg;function X6(n,t,e){var r=t(n);return J6(n)?r:Y6(r,e(n))}var t3=X6;function e3(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var n3=e3;function r3(){return[]}var i3=r3,s3=n3,o3=i3,a3=Object.prototype,c3=a3.propertyIsEnumerable,Xb=Object.getOwnPropertySymbols,u3=Xb?function(n){return n==null?[]:(n=Object(n),s3(Xb(n),function(t){return c3.call(n,t)}))}:o3,l3=u3;function f3(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var h3=f3;function d3(n){return n!=null&&typeof n=="object"}var Td=d3,p3=Rd,g3=Td,y3="[object Arguments]";function m3(n){return g3(n)&&p3(n)==y3}var w3=m3,t_=w3,b3=Td,e_=Object.prototype,_3=e_.hasOwnProperty,A3=e_.propertyIsEnumerable,E3=t_(function(){return arguments}())?t_:function(n){return b3(n)&&_3.call(n,"callee")&&!A3.call(n,"callee")},v3=E3,Od={exports:{}};function x3(){return!1}var R3=x3;Od.exports,function(n,t){var e=ms,r=R3,i=t&&!t.nodeType&&t,s=i&&!0&&n&&!n.nodeType&&n,o=s&&s.exports===i,a=o?e.Buffer:void 0,u=a?a.isBuffer:void 0,f=u||r;n.exports=f}(Od,Od.exports);var n_=Od.exports,I3=9007199254740991,S3=/^(?:0|[1-9]\d*)$/;function k3(n,t){var e=typeof n;return t=t??I3,!!t&&(e=="number"||e!="symbol"&&S3.test(n))&&n>-1&&n%1==0&&n<t}var T3=k3,O3=9007199254740991;function N3(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=O3}var r_=N3,C3=Rd,B3=r_,P3=Td,M3="[object Arguments]",L3="[object Array]",U3="[object Boolean]",D3="[object Date]",F3="[object Error]",$3="[object Function]",H3="[object Map]",z3="[object Number]",G3="[object Object]",V3="[object RegExp]",K3="[object Set]",j3="[object String]",W3="[object WeakMap]",Z3="[object ArrayBuffer]",q3="[object DataView]",Q3="[object Float32Array]",Y3="[object Float64Array]",J3="[object Int8Array]",X3="[object Int16Array]",tB="[object Int32Array]",eB="[object Uint8Array]",nB="[object Uint8ClampedArray]",rB="[object Uint16Array]",iB="[object Uint32Array]",Ke={};Ke[Q3]=Ke[Y3]=Ke[J3]=Ke[X3]=Ke[tB]=Ke[eB]=Ke[nB]=Ke[rB]=Ke[iB]=!0,Ke[M3]=Ke[L3]=Ke[Z3]=Ke[U3]=Ke[q3]=Ke[D3]=Ke[F3]=Ke[$3]=Ke[H3]=Ke[z3]=Ke[G3]=Ke[V3]=Ke[K3]=Ke[j3]=Ke[W3]=!1;function sB(n){return P3(n)&&B3(n.length)&&!!Ke[C3(n)]}var oB=sB;function aB(n){return function(t){return n(t)}}var cB=aB,Nd={exports:{}};Nd.exports,function(n,t){var e=Ub,r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s&&e.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();n.exports=a}(Nd,Nd.exports);var uB=Nd.exports,lB=oB,fB=cB,i_=uB,s_=i_&&i_.isTypedArray,hB=s_?fB(s_):lB,o_=hB,dB=h3,pB=v3,gB=wg,yB=n_,mB=T3,wB=o_,bB=Object.prototype,_B=bB.hasOwnProperty;function AB(n,t){var e=gB(n),r=!e&&pB(n),i=!e&&!r&&yB(n),s=!e&&!r&&!i&&wB(n),o=e||r||i||s,a=o?dB(n.length,String):[],u=a.length;for(var f in n)(t||_B.call(n,f))&&!(o&&(f=="length"||i&&(f=="offset"||f=="parent")||s&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||mB(f,u)))&&a.push(f);return a}var EB=AB,vB=Object.prototype;function xB(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||vB;return n===e}var RB=xB;function IB(n,t){return function(e){return n(t(e))}}var SB=IB,kB=SB,TB=kB(Object.keys,Object),OB=TB,NB=RB,CB=OB,BB=Object.prototype,PB=BB.hasOwnProperty;function MB(n){if(!NB(n))return CB(n);var t=[];for(var e in Object(n))PB.call(n,e)&&e!="constructor"&&t.push(e);return t}var LB=MB,UB=Gb,DB=r_;function FB(n){return n!=null&&DB(n.length)&&!UB(n)}var $B=FB,HB=EB,zB=LB,GB=$B;function VB(n){return GB(n)?HB(n):zB(n)}var KB=VB,jB=t3,WB=l3,ZB=KB;function qB(n){return jB(n,ZB,WB)}var QB=qB,a_=QB,YB=1,JB=Object.prototype,XB=JB.hasOwnProperty;function t8(n,t,e,r,i,s){var o=e&YB,a=a_(n),u=a.length,f=a_(t),h=f.length;if(u!=h&&!o)return!1;for(var y=u;y--;){var _=a[y];if(!(o?_ in t:XB.call(t,_)))return!1}var w=s.get(n),R=s.get(t);if(w&&R)return w==t&&R==n;var T=!0;s.set(n,t),s.set(t,n);for(var I=o;++y<u;){_=a[y];var B=n[_],H=t[_];if(r)var U=o?r(H,B,_,t,n,s):r(B,H,_,n,t,s);if(!(U===void 0?B===H||i(B,H,e,r,s):U)){T=!1;break}I||(I=_=="constructor")}if(T&&!I){var G=n.constructor,W=t.constructor;G!=W&&"constructor"in n&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof W=="function"&&W instanceof W)&&(T=!1)}return s.delete(n),s.delete(t),T}var e8=t8,n8=Dc,r8=ms,i8=n8(r8,"DataView"),s8=i8,o8=Dc,a8=ms,c8=o8(a8,"Promise"),u8=c8,l8=Dc,f8=ms,h8=l8(f8,"Set"),d8=h8,p8=Dc,g8=ms,y8=p8(g8,"WeakMap"),m8=y8,bg=s8,_g=yg,Ag=u8,Eg=d8,vg=m8,c_=Rd,zc=Kb,u_="[object Map]",w8="[object Object]",l_="[object Promise]",f_="[object Set]",h_="[object WeakMap]",d_="[object DataView]",b8=zc(bg),_8=zc(_g),A8=zc(Ag),E8=zc(Eg),v8=zc(vg),da=c_;(bg&&da(new bg(new ArrayBuffer(1)))!=d_||_g&&da(new _g)!=u_||Ag&&da(Ag.resolve())!=l_||Eg&&da(new Eg)!=f_||vg&&da(new vg)!=h_)&&(da=function(n){var t=c_(n),e=t==w8?n.constructor:void 0,r=e?zc(e):"";if(r)switch(r){case b8:return d_;case _8:return u_;case A8:return l_;case E8:return f_;case v8:return h_}return t});var x8=da,xg=n6,R8=qb,I8=W6,S8=e8,p_=x8,g_=wg,y_=n_,k8=o_,T8=1,m_="[object Arguments]",w_="[object Array]",Cd="[object Object]",O8=Object.prototype,b_=O8.hasOwnProperty;function N8(n,t,e,r,i,s){var o=g_(n),a=g_(t),u=o?w_:p_(n),f=a?w_:p_(t);u=u==m_?Cd:u,f=f==m_?Cd:f;var h=u==Cd,y=f==Cd,_=u==f;if(_&&y_(n)){if(!y_(t))return!1;o=!0,h=!1}if(_&&!h)return s||(s=new xg),o||k8(n)?R8(n,t,e,r,i,s):I8(n,t,u,e,r,i,s);if(!(e&T8)){var w=h&&b_.call(n,"__wrapped__"),R=y&&b_.call(t,"__wrapped__");if(w||R){var T=w?n.value():n,I=R?t.value():t;return s||(s=new xg),i(T,I,e,r,s)}}return _?(s||(s=new xg),S8(n,t,e,r,i,s)):!1}var C8=N8,B8=C8,__=Td;function A_(n,t,e,r,i){return n===t?!0:n==null||t==null||!__(n)&&!__(t)?n!==n&&t!==t:B8(n,t,e,r,A_,i)}var P8=A_,M8=P8;function L8(n,t){return M8(n,t)}var U8=L8;const D8=Mr(U8);var E_={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,_){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,y||u,_),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],w]:u._events[R].push(w):(u._events[R]=w,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},a.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,w=y.length,R=new Array(w);_<w;_++)R[_]=y[_].fn;return R},a.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},a.prototype.emit=function(f,h,y,_,w,R){var T=e?e+f:f;if(!this._events[T])return!1;var I=this._events[T],B=arguments.length,H,U;if(I.fn){switch(I.once&&this.removeListener(f,I.fn,void 0,!0),B){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,h),!0;case 3:return I.fn.call(I.context,h,y),!0;case 4:return I.fn.call(I.context,h,y,_),!0;case 5:return I.fn.call(I.context,h,y,_,w),!0;case 6:return I.fn.call(I.context,h,y,_,w,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];I.fn.apply(I.context,H)}else{var G=I.length,W;for(U=0;U<G;U++)switch(I[U].once&&this.removeListener(f,I[U].fn,void 0,!0),B){case 1:I[U].fn.call(I[U].context);break;case 2:I[U].fn.call(I[U].context,h);break;case 3:I[U].fn.call(I[U].context,h,y);break;case 4:I[U].fn.call(I[U].context,h,y,_);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];I[U].fn.apply(I[U].context,H)}}return!0},a.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},a.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},a.prototype.removeListener=function(f,h,y,_){var w=e?e+f:f;if(!this._events[w])return this;if(!h)return o(this,w),this;var R=this._events[w];if(R.fn)R.fn===h&&(!_||R.once)&&(!y||R.context===y)&&o(this,w);else{for(var T=0,I=[],B=R.length;T<B;T++)(R[T].fn!==h||_&&!R[T].once||y&&R[T].context!==y)&&I.push(R[T]);I.length?this._events[w]=I.length===1?I[0]:I:o(this,w)}return this},a.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(E_);var F8=E_.exports;const Rg=Mr(F8);class v_ extends Error{constructor(t){super(t),this.name="TimeoutError"}}class $8 extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const x_=n=>globalThis.DOMException===void 0?new $8(n):new DOMException(n),R_=n=>{const t=n.reason===void 0?x_("This operation was aborted."):n.reason;return t instanceof Error?t:x_(t)};function H8(n,t){const{milliseconds:e,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=t;let o,a;const f=new Promise((h,y)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){const{signal:w}=t;w.aborted&&y(R_(w)),a=()=>{y(R_(w))},w.addEventListener("abort",a,{once:!0})}if(e===Number.POSITIVE_INFINITY){n.then(h,y);return}const _=new v_;o=s.setTimeout.call(void 0,()=>{if(r){try{h(r())}catch(w){y(w)}return}typeof n.cancel=="function"&&n.cancel(),i===!1?h():i instanceof Error?y(i):(_.message=i??`Promise timed out after ${e} milliseconds`,y(_))},e),(async()=>{try{h(await n)}catch(w){y(w)}})()}).finally(()=>{f.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return f.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},f}function z8(n,t,e){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;e(n[o],t)<=0?(r=++o,i-=s+1):i=s}return r}class G8{constructor(){Y(this,oi,[])}enqueue(t,e){e={priority:0,...e};const r={priority:e.priority,id:e.id,run:t};if(this.size===0||S(this,oi)[this.size-1].priority>=e.priority){S(this,oi).push(r);return}const i=z8(S(this,oi),r,(s,o)=>o.priority-s.priority);S(this,oi).splice(i,0,r)}setPriority(t,e){const r=S(this,oi).findIndex(s=>s.id===t);if(r===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);const[i]=S(this,oi).splice(r,1);this.enqueue(i.run,{priority:e,id:t})}dequeue(){const t=S(this,oi).shift();return t==null?void 0:t.run}filter(t){return S(this,oi).filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return S(this,oi).length}}oi=new WeakMap;class I_ extends Rg{constructor(e){var r,i;super();Y(this,Ee);Y(this,Qu);Y(this,Yu);Y(this,Ho,0);Y(this,kh);Y(this,Ju);Y(this,Th,0);Y(this,ai);Y(this,Xu);Y(this,Ar);Y(this,Oh);Y(this,ci,0);Y(this,tl);Y(this,Vs);Y(this,Nh);Y(this,Mp,1n);Z(this,"timeout");if(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:G8,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((r=e.intervalCap)==null?void 0:r.toString())??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((i=e.interval)==null?void 0:i.toString())??""}\` (${typeof e.interval})`);F(this,Qu,e.carryoverConcurrencyCount),F(this,Yu,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0),F(this,kh,e.intervalCap),F(this,Ju,e.interval),F(this,Ar,new e.queueClass),F(this,Oh,e.queueClass),this.concurrency=e.concurrency,this.timeout=e.timeout,F(this,Nh,e.throwOnTimeout===!0),F(this,Vs,e.autoStart===!1)}get concurrency(){return S(this,tl)}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);F(this,tl,e),yt(this,Ee,sg).call(this)}setPriority(e,r){S(this,Ar).setPriority(e,r)}async add(e,r={}){return r.id??(r.id=(ao(this,Mp)._++).toString()),r={timeout:this.timeout,throwOnTimeout:S(this,Nh),...r},new Promise((i,s)=>{S(this,Ar).enqueue(async()=>{var o;ao(this,ci)._++,ao(this,Ho)._++;try{(o=r.signal)==null||o.throwIfAborted();let a=e({signal:r.signal});r.timeout&&(a=H8(Promise.resolve(a),{milliseconds:r.timeout})),r.signal&&(a=Promise.race([a,yt(this,Ee,iO).call(this,r.signal)]));const u=await a;i(u),this.emit("completed",u)}catch(a){if(a instanceof v_&&!r.throwOnTimeout){i();return}s(a),this.emit("error",a)}finally{yt(this,Ee,eO).call(this)}},r),this.emit("add"),yt(this,Ee,ig).call(this)})}async addAll(e,r){return Promise.all(e.map(async i=>this.add(i,r)))}start(){return S(this,Vs)?(F(this,Vs,!1),yt(this,Ee,sg).call(this),this):this}pause(){F(this,Vs,!0)}clear(){F(this,Ar,new(S(this,Oh)))}async onEmpty(){S(this,Ar).size!==0&&await yt(this,Ee,og).call(this,"empty")}async onSizeLessThan(e){S(this,Ar).size<e||await yt(this,Ee,og).call(this,"next",()=>S(this,Ar).size<e)}async onIdle(){S(this,ci)===0&&S(this,Ar).size===0||await yt(this,Ee,og).call(this,"idle")}get size(){return S(this,Ar).size}sizeBy(e){return S(this,Ar).filter(e).length}get pending(){return S(this,ci)}get isPaused(){return S(this,Vs)}}Qu=new WeakMap,Yu=new WeakMap,Ho=new WeakMap,kh=new WeakMap,Ju=new WeakMap,Th=new WeakMap,ai=new WeakMap,Xu=new WeakMap,Ar=new WeakMap,Oh=new WeakMap,ci=new WeakMap,tl=new WeakMap,Vs=new WeakMap,Nh=new WeakMap,Mp=new WeakMap,Ee=new WeakSet,XT=function(){return S(this,Yu)||S(this,Ho)<S(this,kh)},tO=function(){return S(this,ci)<S(this,tl)},eO=function(){ao(this,ci)._--,yt(this,Ee,ig).call(this),this.emit("next")},nO=function(){yt(this,Ee,Ib).call(this),yt(this,Ee,Rb).call(this),F(this,Xu,void 0)},rO=function(){const e=Date.now();if(S(this,ai)===void 0){const r=S(this,Th)-e;if(r<0)F(this,Ho,S(this,Qu)?S(this,ci):0);else return S(this,Xu)===void 0&&F(this,Xu,setTimeout(()=>{yt(this,Ee,nO).call(this)},r)),!0}return!1},ig=function(){if(S(this,Ar).size===0)return S(this,ai)&&clearInterval(S(this,ai)),F(this,ai,void 0),this.emit("empty"),S(this,ci)===0&&this.emit("idle"),!1;if(!S(this,Vs)){const e=!S(this,Ee,rO);if(S(this,Ee,XT)&&S(this,Ee,tO)){const r=S(this,Ar).dequeue();return r?(this.emit("active"),r(),e&&yt(this,Ee,Rb).call(this),!0):!1}}return!1},Rb=function(){S(this,Yu)||S(this,ai)!==void 0||(F(this,ai,setInterval(()=>{yt(this,Ee,Ib).call(this)},S(this,Ju))),F(this,Th,Date.now()+S(this,Ju)))},Ib=function(){S(this,Ho)===0&&S(this,ci)===0&&S(this,ai)&&(clearInterval(S(this,ai)),F(this,ai,void 0)),F(this,Ho,S(this,Qu)?S(this,ci):0),yt(this,Ee,sg).call(this)},sg=function(){for(;yt(this,Ee,ig).call(this););},iO=async function(e){return new Promise((r,i)=>{e.addEventListener("abort",()=>{i(e.reason)},{once:!0})})},og=async function(e,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(e,s),i())};this.on(e,s)})};const Gn=[];for(let n=0;n<256;++n)Gn.push((n+256).toString(16).slice(1));function V8(n,t=0){return(Gn[n[t+0]]+Gn[n[t+1]]+Gn[n[t+2]]+Gn[n[t+3]]+"-"+Gn[n[t+4]]+Gn[n[t+5]]+"-"+Gn[n[t+6]]+Gn[n[t+7]]+"-"+Gn[n[t+8]]+Gn[n[t+9]]+"-"+Gn[n[t+10]]+Gn[n[t+11]]+Gn[n[t+12]]+Gn[n[t+13]]+Gn[n[t+14]]+Gn[n[t+15]]).toLowerCase()}let Ig;const K8=new Uint8Array(16);function j8(){if(!Ig){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ig=crypto.getRandomValues.bind(crypto)}return Ig(K8)}const S_={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function W8(n,t,e){if(S_.randomUUID&&!t&&!n)return S_.randomUUID();n=n||{};const r=n.random||(n.rng||j8)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,V8(r)}function k_(n){return new Promise(t=>{setTimeout(t,n)})}function ef(n){return(n.startsWith("0x")?n.slice(2):n).toLowerCase()}class Mi{constructor(){}static getInstance(){return Mi.instance||(Mi.instance=new Mi),Mi.instance}formatMessage(t,...e){return`[${new Date().toISOString()}] [${t.toUpperCase()}] - ${e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...t){console.log(this.formatMessage("log",...t))}info(...t){console.info(this.formatMessage("info",...t))}warn(...t){console.warn(this.formatMessage("warn",...t))}error(...t){console.error(this.formatMessage("error",...t))}debug(...t){console.debug(this.formatMessage("debug",...t))}}class Sg{constructor(){this.logger=Mi.getInstance()}handleError(t,e){const r=t instanceof Error?t.message:"Unknown error occurred",i=t instanceof Error?t.stack:null;this.logger.error(`Error in ${e||"unknown context"}: ${r}`,{stack:i})}}let Z8=class{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}off(t,e){if(!this.events[t])return;const r=this.events[t].indexOf(e);r>-1&&this.events[t].splice(r,1)}cleanAll(){this.events={}}emit(t,e){this.events[t]&&this.events[t].forEach(r=>r(e))}};var T_={};(function(n){var t;Object.defineProperty(n,"__esModule",{value:!0}),n.Vector=n.Cache=n.Assertions=n.Strings=n.Types=n.Objects=n.Dates=n.Promises=n.Numbers=n.System=n.Arrays=n.Random=n.Elliptic=n.Binary=n.AsyncQueue=n.PubSubChannel=n.FixedPointNumber=n.MerkleTree=n.Chunk=n.Uint8ArrayWriter=n.Uint8ArrayReader=n.AsyncLazy=n.Lazy=n.Optional=void 0;async function e(c){return new Promise((l,d)=>c.then(d,l))}async function r(c){return e(Promise.all(c.map(e)))}async function i(c,l=1){const d=vT(c,l),g=[],x=d.map(async L=>{for(const Q of L)g.push(await Q())});return await Promise.all(x),g}async function s(c){return new Promise(l=>setTimeout(()=>{l(!0)},c))}function o(c,l=Math.random){for(let d=c.length-1;d>0;d--){const g=Math.floor(l()*(d+1)),x=c[d];c[d]=c[g],c[g]=x}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 f(c){return c.length>0?c[0]:null}function h(c){if(!c.length)throw Error("Received empty array");return c[0]}function y(c,l){const d=[];for(let g=0;g<c;g++)d.push(l(g));return d}function _(c){const l=[];for(let d=0;d<c[0].length;d++){l.push([]);for(let g=0;g<c.length;g++)l[d].push(c[g][d])}return l}function w(c,l,d){const g=[];for(let x=0;x<c;x++){g.push([]);for(let L=0;L<l;L++)g[x].push(d)}return g}function R(c,l,d,g){if(d<0||g<0||g+l[0].length>c[0].length||d+l.length>c.length)return!1;for(let x=0;x<l.length;x++)for(let L=0;L<l[x].length;L++)if(l[x][L]!==void 0&&c[d+x][g+L]!==l[x][L])return!1;return!0}function T(c,l,d=Math.random){return o(Kk(0,c.length-1),d).slice(0,l)}function I(c,l){return c.map(d=>d[l])}function B(c){let l=c,d=3405648695,g=3735928559;return function(){return l+=d,d^=l<<7,l*=g,g^=l<<13,l^=d^g,(l>>>0)/4294967296}}function H(c,l,d=Math.random){return Math.floor(d()*(l-c+1))+c}function U(c,l,d=Math.random){return d()*(l-c)+c}function G(){return Math.random()*2-1}function W(c,l,d){return l>=c.x&&l<c.x+c.width&&d>=c.y&&d<c.y+c.height}function X(c,l,d,g=Math.random){let x,L;do x=H(0,c-1,g),L=H(0,l-1,g);while(d&&W(d,x,L));return[x,L]}function j(c,l=Math.random){const d=Math.floor(c),g=c-d;return J(g,l)?d+1:d}function J(c,l=Math.random){return l()<c}function it(c,l=Math.random){return c[Math.floor(c.length*l())]}function ut(c,l,d=Math.random){if(l>c.length)throw new Error(`Count (${l}) is greater than array length (${c.length})`);return T(c,l,d).map(g=>c[g])}function rt(c,l,d,g=Math.random){if(l>c.length)throw new Error(`Count (${l}) is greater than array length (${c.length})`);const x=[];for(;x.length<l;){const L=it(c,g);x.some(Q=>d(Q,L))||x.push(L)}return x}function ot(c,l,d,g,x,L=Math.random){const Q=c.filter(at=>at!==l&&at!==d),lt=[];for(l!==null&<.push(l);Q.length&<.length<g;){const at=n.Random.intBetween(0,Q.length-1,L);x(Q[at],lt)&<.push(Q[at]),Q.splice(at,1)}return o(lt,L),{values:lt,indexOfGuaranteed:l!==null?lt.indexOf(l):-1}}function C(c){if(!c.length)throw Error("Received empty array");return c[c.length-1]}function p(c,l,d){return d(l.reduce((g,x)=>x(g),c))}function m(c,l){return d=>p(d,c,l)}function v(c,l,d){if(d===void 0&&(d=Math.random()),c.length!==l.length)throw new Error("Array length mismatch");let g=l.reduce((L,Q)=>L+Q,0);const x=d*g;for(let L=0;L<c.length-1;L++)if(g-=l[L],x>=g)return c[L];return C(c)}function k(c,l,d=Math.random){const g=l.map(L=>d()*L),x=[];for(let L=0;L<c.length;L++)x.push([c[L],g[L]]);return x.sort((L,Q)=>Q[1]-L[1]).map(L=>L[0])}function N(c,l){if(c==null)return null;const d=l.split(".");let g=c;for(const x of d){if(g[x]===null||g[x]===void 0)return null;g=g[x]}return g}function M(c,l,d){const g=l.split(/\.|\[/);let x=c;for(let L=0;L<g.length;L++){const Q=g[L],lt=L<g.length-1&&g[L+1].includes("]"),at=Q.includes("]")?Q.replace(/\[|\]/g,""):Q;if(L===g.length-1)return x[at]=d,d;sn(x[at])||(lt?x[at]=[]:x[at]={}),x=x[at]}return d}function z(c,l,d=1){const g=N(c,l)||0;return M(c,l,g+d),g}function P(c,l,d){return N(c,l)||M(c,l,d)}function A(c,l){const d=u1(l,"."),g=Wk(l,".");if(!d||!g)return;const x=N(c,d);delete x[g]}function $(c,l,d){const g=N(c,l);if(!g)throw new Error("Key '"+l+"' does not exist.");return M(c,l,d),g}function ct(c,l,d){for(const g of l){const x=N(c,g);if(x)return x}if(d){const g=Object.values(c);if(g.length)return g[0]}return null}async function dt(c,l,d){for(;;){try{await c()}catch(g){d&&d("Error in forever",g)}await s(l)}}function wt(c,l){c();const d=setInterval(()=>{c()},l);return()=>clearInterval(d)}function Gt(c){return c/1024/1024}function Ut(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 Lt(c){const l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c.toLowerCase());if(!l)throw new Error("Invalid hex color: "+c);return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}function Re(c){return"#"+c.map(l=>l.toString(16).padStart(2,"0")).join("")}function Kt(c,l,d,g){const x=c*Math.PI/180,L=d*Math.PI/180,Q=(d-c)*Math.PI/180,lt=(g-l)*Math.PI/180,at=Math.sin(Q/2)*Math.sin(Q/2)+Math.cos(x)*Math.cos(L)*Math.sin(lt/2)*Math.sin(lt/2);return 6371e3*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)))}function Ft(c,l){return Math.round(c/l)*l}function Te(c){return c>1e3?(c/1e3).toFixed(0)+" km":c>=500?Ft(c,100)+" m":c>=100?Ft(c,50)+" m":Ft(c,10)+" m"}function re(c){return c*(c+1)/2}function oe(c){const l=c.match(/-?\d+(\.\d+)?/);if(!l)throw Error("No float found in "+c);return parseFloat(l[0])}function sn(c,l=!0){return!c||l&&!Ie(c._readableState)||l&&c.constructor&&(c.constructor.isBuffer||c.constructor.name=="Uint8Array"||c.constructor.name==="ArrayBuffer"||c.constructor.name==="ReadableStream")?!1:typeof c=="object"}function fe(c){return sn(c)&&!Array.isArray(c)}function De(c){return Array.isArray(c)&&c.length===0}function ua(c){return fe(c)&&Object.keys(c).length===0}function Ie(c){return c===void 0}function Be(c){return Object.prototype.toString.call(c)==="[object Function]"||Object.prototype.toString.call(c)==="[object AsyncFunction]"}function kn(c){return Object.prototype.toString.call(c)==="[object String]"}function he(c){return typeof c=="number"&&isFinite(c)}function Se(c){return c===!0||c===!1}function on(c){return Object.prototype.toString.call(c)==="[object Date]"}function ve(c){return!kn(c)||c.trim().length===0}function Pe(c){return he(c)&&Number.isInteger(c)&&c>=1}function ur(c){return kn(c)&&c.match(/^-?\d+$/)!==null}function Fe(c){return kn(c)&&c.match(/^(0x)?[0-9a-f]+$/i)!==null}const O="!@#$%^&*()_+-=[]{}|;:<>?,./",b="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),E="abcdefghijklmnopqrstuvwxyz",D="ABCDEFGHIJKLMNOPQRSTUVWXYZ",V="1234567890",q=E+D+V,st=q+O,qt=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],Wt="0123456789abcdef";function jt(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=E[Math.floor(l()*E.length)];return d}function $e(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=q[Math.floor(l()*q.length)];return d}function Ht(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=st[Math.floor(l()*st.length)];return d}function fn(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=qt[Math.floor(l()*qt.length)];return d}function Gp(c,l){const d=new RegExp(`[0-9a-f]{${l}}`,"i"),g=c.match(d);return g?g[0]:null}function hn(c,l,d=b){const g=Zk(c,d);for(const x of g)if(l(x))return x;return null}function dn(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=Wt[Math.floor(l()*Wt.length)];return d}function Vp(c,l){if(!ur(c))throw new TypeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=BigInt(c);if(l&&(l.min&&d<l.min||l.max&&d>l.max))throw RangeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: `+d);return c}function an(c,l){if(ve(c))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);if(l&&(l.min!==void 0&&c.length<l.min||l.max!==void 0&&c.length>l.max))throw RangeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""} length in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${c.length}`);return c}function pn(c,l){if(!Fe(c))throw new TypeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=c.replace(/^0x/,"");if(l&&l.byteLength&&d.length!==l.byteLength*2)throw RangeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""} of byte length ${l.byteLength}; got: `+d);return d}function Kp(c,l){if(!an(c,l).split("").every(d=>d==="_"||ad(d)))throw new TypeError(`Expected safe string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function cn(c,l){if(l.min!==void 0&&c<l.min||l.max!==void 0&&c>l.max)throw RangeError(`Expected value${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${c}`)}function gn(c,l){if(!Be(c))throw new TypeError(`Expected function${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function Nc(c,l){if(he(c))return l&&cn(c,l),c;if(!kn(c)||!c.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=parseFloat(c);return l&&cn(d,l),d}function Je(c,l){return Nc(c,l)|0}function yn(c,l){if(c==="true")return!0;if(c==="false")return!1;if(!Se(c))throw new TypeError(`Expected boolean${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function jp(c,l){if(!on(c))throw new TypeError(`Expected date${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function mn(c){return ve(c)?null:c}function wn(c,l){if(!kn(c))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function Wp(c,l){if(Pe(c))return c;const d=parseInt(c,10);if(!Pe(d))throw new TypeError(`Expected id${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function bn(c,l){if(!kn(c))throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=c.split(":");if(d.length!==2)throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const g=parseInt(d[0],10),x=parseInt(d[1],10);if(!he(g)||!he(x)||g<0||g>23||x<0||x>59)throw new TypeError(`Expected time, got${l!=null&&l.name?` for ${l.name}`:""}: `+c);return`${String(g).padStart(2,"0")}:${String(x).padStart(2,"0")}`}function _n(c,l){if(!Array.isArray(c))throw new TypeError(`Expected array${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function Cc(c,l){if(!fe(c))throw new TypeError(`Expected object${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function An(c,l){return c===null?null:Cc(c,l)}function En(c,l){const d=Cc(c,l);for(const g of Object.keys(d))if(!kn(d[g]))throw new TypeError(`Expected string map${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function Wh(c,l){const d=Cc(c),g=Object.keys(d),x=Object.values(d);if(!g.every(kn)||!x.every(he))throw new TypeError(`Expected numeric dictionary${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function Vl(c){return kn(c)&&c.match(/^https?:\/\/.+/)!==null}function Zh(c,l){if(!Vl(c))throw new TypeError(`Expected url${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function qh(c,l){return l==null?!0:c(l)}function Qh(c,l){return l==null?null:c(l)}function Yh(c,l){return l==null?void 0:c(l)}function Kl(c,l){for(const[d,g]of Object.entries(l))if(!g(c[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(c))if(!l[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Jh(c,l){return c.every(d=>Kl(d,l))}function so(c,l="json",d=0){if(sn(c,!1)){if(d>1)return"[object Object]";if(l==="json"){if(Array.isArray(c)){const x=c.map(L=>so(L,"json",d+1));return d===0?JSON.stringify(x):x}const g={};c.message&&(g.message=so(c.message,"json",d+1));for(const[x,L]of Object.entries(c))g[x]=so(L,"json",d+1);return d===0?JSON.stringify(g):g}else if(l==="key-value"){const g=Object.keys(c);return c.message&&!g.includes("message")&&g.unshift("message"),g.map(x=>`${x}=${JSON.stringify(so(c[x],"json",d+1))}`).join(" ")}}return Ie(c)&&(c="undefined"),d===0?JSON.stringify(c):c}function Xh(c,l){if(kn(c))return c;const d=Object.keys(c);c.message&&!d.includes("message")&&d.push("message");const g=d.map(x=>`${x}: ${c[x]}`).join("; ");return l&&c.stack?g+`
|
|
2
|
+
`+c.stack:g}function Pi(c,l){if(fe(c)&&fe(l))for(const d in l)fe(l[d])?(c[d]||(c[d]={}),Pi(c[d],l[d])):Array.isArray(l[d])?c[d]=[...l[d]]:(l[d]!==null&&l[d]!==void 0||c[d]===null||c[d]===void 0)&&(c[d]=l[d]);return c}function td(c,l){const d={};return Pi(d,c),Pi(d,l),d}function ed(c,l,d){const g={};return Pi(g,c),Pi(g,l),Pi(g,d),g}function jl(c,l){const d={};for(const g of c)for(const x of Object.keys(g))d[x]?d[x]=l(d[x],g[x]):d[x]=g[x];return d}function nd(c){return jl(c,(l,d)=>l+d)}function rd(c,l,d){c[l]||(c[l]=[]),c[l].push(d)}function id(c,l,d){for(c.unshift(l);c.length>d;)c.pop()}function sd(c,l){let d=l%c.length;return d<0&&(d+=c.length),c[d]}function la(c,l){Array.prototype.push.apply(c,l)}function LV(c,l){Array.prototype.unshift.apply(c,l)}async function UV(c,l){const d=[];for(const g of c)d.push(await l(g));return d}function DV(c,l){const d=[];for(let g=0;g<c.length;g++)d.push(c[g]),g<c.length-1&&(Be(l)?d.push(l()):d.push(l));return d}function FV(c,l){if(c!==l)throw Error(`Expected [${c}] to equal [${l}]`);return[c,l]}function $V(c){if(c!==!0)throw Error(`Expected [true], got: [${c}]`);return c}function HV(c){if(!c)throw Error(`Expected truthy value, got: [${c}]`);return c}function zV(c){if(c!==!1)throw Error(`Expected [false], got: [${c}]`);return c}function GV(c){if(c)throw Error(`Expected falsy value, got: [${c}]`);return c}function VV(c,l){if(!l.includes(c))throw Error(`Expected any of [${l.join(", ")}], got: [${c}]`);return c}function KV(c,l){for(let d=0;d<c.length;d++){const g=c[d],x=l[d],L=Math.max(0,x.getTime()-Date.now());setTimeout(g,L)}}function jV(c,l,d){return c+(l-c)*d}function WV(c){return c.reduce((l,d)=>l+d,0)}function ZV(c){return c.reduce((l,d)=>l+d,0)/c.length}function qV(c){const l=[...c].sort((g,x)=>g-x),d=Math.floor(l.length/2);return l.length%2===0?(l[d]+l[d-1])/2:l[d]}function QV(c,l){return c-(l-1)/2}function Kk(c,l){const d=[];for(let g=c;g<=l;g++)d.push(g);return d}function YV(c,l){return l.some(d=>c.includes(d))}function JV(c){return/^[\u4E00-\u9FA5]+$/.test(c)}function a1(c,l=()=>!1){return c.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||l(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function XV(c){return a1(c).replaceAll("-","")}function tK(c){return qp(c.replace(/([A-Z])/g," $1"))}function eK(c){return c.split("-").map(qp).join(" ")}function nK(c){return Qk(c.split("-").map(qp).join(""))}function rK(c,l=", ",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(l)}${d}${c[c.length-1]}`}function iK(c,l){return l+c.split("").join(l)+l}function sK(c){return a1(c).replace(/-/g,"_").toUpperCase()}function Zp(c,l){if(l.length===0)return 0;const d=c.toLowerCase(),g=l.toLowerCase();return c===l?1e4:d.startsWith(g)?1e4-c.length:d.includes(g)?5e3-c.length:new RegExp(".*"+g.split("").join(".*")+".*").test(d)?1e3-c.length:0}function oK(c,l){return c.filter(d=>Zp(d,l)).sort((d,g)=>Zp(g,l)-Zp(d,l))}function aK(c){return c.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const cK={"&":"&",""":'"',"'":"'",">":">","<":"<"};function uK(c){let l=c.replace(/&#(\d+);/g,(d,g)=>String.fromCharCode(g)).replace(/&#x(\d+);/g,(d,g)=>String.fromCharCode(parseInt(g,16)));for(const[d,g]of Object.entries(cK))l=l.replaceAll(d,g);return l}function jk(c,l){const d=c.indexOf(l);return d===-1?null:c.slice(0,d)}function c1(c,l){const d=c.indexOf(l);return d===-1?null:c.slice(d+l.length)}function u1(c,l){const d=c.lastIndexOf(l);return d===-1?null:c.slice(0,d)}function Wk(c,l){const d=c.lastIndexOf(l);return d===-1?null:c.slice(d+l.length)}function lK(c,l,d){const g=u1(c,d);return g?c1(g,l):null}function fK(c,l,d){const g=c1(c,l);return g?jk(g,d):null}function l1(c,l,d=!1){const g=d?c.lastIndexOf(l):c.indexOf(l);return g===-1?d?[null,c]:[c,null]:[c.slice(0,g),c.slice(g+l.length)]}function Zk(c,l){let d=[c];for(const g of l)d=d.flatMap(x=>x.split(g));return d.filter(g=>g)}function f1(c){const l=C(c.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?"":l.slice(d+1)}function h1(c){const l=C(c.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?l:l.slice(0,d)}function hK(c){let[l,d]=c.split("@");l=od(l.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[g]=l.split("+");if(!g||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=od(d.toLowerCase()).replaceAll(" ",""),`${g}@${d}`}function dK(c){const l=h1(c),d=f1(c);return d?`${l}.${d}`:l}function pK(c){const l=h1(c),d=f1(c);return{basename:l,extension:d,filename:d?`${l}.${d}`:l}}function gK(c,l=Math.random){return c.replace(/\{(.+?)\}/g,(d,g)=>it(g.split("|"),l))}function qk(c){const l=/\{(.+?)\}/,d=c.match(l);if(!d||!d.index)return[c];const g=d[1].split(","),x=c.slice(0,d.index),L=c.slice(d.index+d[0].length);let Q=[];for(const lt of g){const at=qk(x+lt+L);Q=Q.concat(at)}return Q}function od(c){return c.split(`
|
|
3
|
+
`).map(l=>l.trim().replace(/\s+/g," ")).filter(l=>l.length>0).join(`
|
|
4
|
+
`)}function qp(c){return c.charAt(0).toUpperCase()+c.slice(1)}function Qk(c){return c.charAt(0).toLowerCase()+c.slice(1)}function Yk(c){if(!c)return!1;const l=c.charCodeAt(0);return l>=65&&l<=90||l>=97&&l<=122}function Jk(c){if(!c)return!1;const l=c.charCodeAt(0);return l>=48&&l<=57}function ad(c){return Yk(c)||Jk(c)}const yK=`
|
|
5
|
+
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function mK(c){return yK.includes(c)}function wK(c){return ad(c)||c==="."||c==="["||c==="]"||c==="_"}function bK(c,l,d,g,x){return c.slice(0,l)+g+c.slice(l,l+d)+x+c.slice(l+d)}function Xk(c,l,d=0){const g=l.exec(c.slice(d));return g?{index:g.index,match:g[0]}:null}function tT(c,l,d=!0){if(!d)return l.every(x=>x instanceof RegExp?x.test(c):c.indexOf(x,0)!==-1);let g=0;for(const x of l)if(x instanceof RegExp){const L=Xk(c,x,g);if(!L)return!1;g=L.index+L.match.length}else{const L=c.indexOf(x,g);if(L===-1)return!1;g=L+x.length}return!0}function _K(c,l,d=!0){let g=0;for(const x of l){let L=!1;for(;!L&&g<c.length;)tT(c[g],x,d)&&(L=!0),g++;if(!L)return!1}return!0}function AK(c){return c.match(/"|,/)?`"${c.replace(/"/g,'""')}"`:c}function Wl(c,l,d=0){let g=-1;for(const x of l){const L=c.indexOf(x,d);L!==-1&&(g===-1||L<g)&&(g=L)}return g}function EK(c,l=0){for(let d=l;d<c.length;d++)if(mK(c[d]))return d;return-1}function vK(c,l=0){for(let d=l;d<c.length;d++)if(c[d]==="#"&&ad(c[d+1]))return d;return-1}function eT(c,l,d=0){return c.slice(0,d).lastIndexOf(l)}function nT(c,l=0,d="{",g="}"){let x=1;for(let L=l;L<c.length;L++)if(c.slice(L,L+g.length)===g){if(--x===0)return L}else c.slice(L,L+d.length)===d&&x++;return-1}function rT(c,l){const d=l.wordBoundary?Wl(c,[`${l.opening} `,`${l.opening}
|
|
6
|
+
`],l.start||0):c.indexOf(l.opening,l.start||0);if(d===-1)return null;const g=nT(c,d+l.opening.length,l.opening,l.closing);return g===-1?null:l.exclusive?c.slice(d+l.opening.length,g):c.slice(d,g+l.closing.length)}function xK(c,l){const d=[];let g=l.wordBoundary?Wl(c,[`${l.opening} `,`${l.opening}
|
|
7
|
+
`],l.start||0):c.indexOf(l.opening,l.start||0);for(;;){if(g===-1)return d;const x=rT(c,{...l,start:g});if(!x)return d;d.push(x),g=l.wordBoundary?Wl(c,[`${l.opening} `,`${l.opening}
|
|
8
|
+
`],g+x.length):c.indexOf(l.opening,g+x.length)}}function RK(c,l,d){let g=0;for(;;){const x=n.Strings.extractBlock(c,{...d,start:g});if(!x)return c;const L=l(x);g=c.indexOf(x,g)+L.length,c=c.replace(x,L)}}function IK(c,l){const d=[];let g=0;for(;g<c.length;){const x=c.indexOf(l,g);if(x===-1){d.push({string:c.slice(g),symbol:null});break}const L=c.indexOf(l,x+l.length);if(x>g&&L!==-1&&d.push({string:c.slice(g,x),symbol:null}),L===-1){d.push({string:c.slice(g),symbol:null});break}d.push({string:c.slice(x+l.length,L),symbol:l}),g=L+l.length}return d}function SK(c){const l=[];let d=0;for(;d<c.length;){const g=vK(c,d);if(g===-1){l.push({string:c.slice(d),symbol:null});break}const x=EK(c,g+1);if(x===-1){l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g+1),symbol:"#"});break}g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g+1,x),symbol:"#"}),d=x}return l}function kK(c){const l=[];let d=0;for(;d<c.length;){const g=Wl(c,["http://","https://"],d);if(g===-1){l.push({string:c.slice(d),symbol:null});break}const x=Wl(c,[" ",`
|
|
9
|
+
`],g);if(x===-1){g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g),symbol:"http"});break}g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g,x),symbol:"http"}),d=x}return l}const iT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sT="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function TK(c){return oT(c,iT)}function OK(c){return aT(c,iT)}function NK(c){return oT(c,sT)}function CK(c){return aT(c,sT)}function oT(c,l){const d="=",g=l.length;let x=0,L=0;const Q=[];for(let lt=0;lt<c.length;lt++){const at=c[lt];if(at===d)break;const Pt=l.indexOf(at);if(Pt===-1)throw new Error(`Invalid character: ${at}`);L=L<<Math.log2(g)|Pt,x+=Math.log2(g),x>=8&&(x-=8,Q.push(L>>x&255))}return new Uint8Array(Q)}function aT(c,l){const d=l.length;let g=0,x=0,L="";for(let Q=0;Q<c.length;Q++)for(x=x<<8|c[Q],g+=8;g>=Math.log2(d);)g-=Math.log2(d),L+=l[x>>g&d-1];return g>0&&(L+=l[x<<Math.log2(d)-g&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function BK(c){c.startsWith("0x")&&(c=c.slice(2));const l=c.length/2,d=new Uint8Array(l);for(let g=0;g<l;g++){const x=parseInt(c.slice(g*2,g*2+2),16);d[g]=x}return d}function PK(c){return Array.from(c).map(l=>l.toString(16).padStart(2,"0")).join("")}function MK(c,l){const d=c.split("/").filter(L=>L),g=l.split("/").filter(L=>L);if(d.length!==g.length)return null;const x={};for(let L=0;L<d.length;L++){const Q=d[L];if(Q.startsWith(":"))x[Q.slice(1)]=g[L];else if(Q!==g[L])return null}return x}function d1(c,l,d){const g=[];for(const x of d)x!==l&&g.push(c.replace(l,x));return g}function LK(c,l,d,g=Math.random){const x=n.Arrays.shuffle(l.map(Q=>({variants:n.Arrays.shuffle(Q.variants.map(lt=>lt),g),avoid:Q.avoid})),g),L=[];for(const Q of x){const lt=Q.variants.filter(Pt=>Pt!==Q.avoid),at=lt.find(Pt=>c.includes(Pt));if(at&&(la(L,d1(c,at,lt)),L.length>=d))break}if(L.length<d)for(const Q of x){const lt=Q.variants.find(at=>c.includes(at));if(lt&&(la(L,d1(c,lt,Q.variants)),L.length>=d))break}return L.slice(0,d)}function UK(c,l,d,g=!1){const x=new RegExp(g?`(?<=\\s|^)${l}(?=\\s|$)`:`\\b${l}\\b`,"g");return c.replace(x,d)}function DK(c,l){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return c.replace(d,g=>g.toUpperCase()===g?g:l(g))}function FK(c){return c.replace(/<[^>]*>/g,"")}function cT(c){const l=c.lastIndexOf(" ");if(l===-1)return{line:c,rest:""};const d=c.slice(0,l),g=c.slice(l+1);return{line:d,rest:g}}function $K(c,l={}){return[...c].reduce((d,g)=>d+(l[g]||1),0)}function HK(c,l,d={}){const g=[];let x="",L=0;for(let Q=0;Q<c.length;Q++){const lt=c[Q],at=d[lt]||1;if(x+=lt,L+=at,L>l){const{line:Pt,rest:Ue}=cT(x);g.push(Pt),x=Ue,L=Ue.split("").map(zn=>d[zn]||1).reduce((zn,Yl)=>zn+Yl,0)}}return x&&g.push(x),g}function zK(c,l){const d=[];for(let g=0;g<=c.length;g++)d[g]=[g];for(let g=0;g<=l.length;g++)d[0][g]=g;for(let g=1;g<=c.length;g++)for(let x=1;x<=l.length;x++){const L=c[g-1]===l[x-1]?0:1;d[g][x]=Math.min(d[g-1][x]+1,d[g][x-1]+1,d[g-1][x-1]+L)}return d[c.length][l.length]}function p1(c,l){return new RegExp(`\\b${l}\\b`).test(c)}function GK(c,l,d){return d==="any"?l.some(g=>p1(c,g)):l.every(g=>p1(c,g))}function VK(c){const l={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const g of d){const[x,L]=l1(g,"=");l[x]=L.slice(1,L.length-1)}return l}function Qp(c,l,d=[]){let g="";for(;l<c.length&&(ad(c[l])||d.includes(c[l]));)g+=c[l++];return g}function KK(c,l,d="$",g=":"){for(const x in l)c=uT(c,x,l[x],d,g);return c=lT(c),c}function uT(c,l,d,g="$",x=":"){if(d==="")return c;let L=c.indexOf(`${g}${l}`);for(;L!==-1;){if(c[L+l.length+1]===x)if(c[L+l.length+2]===x)c=c.replace(`${g}${l}${x}${x}`,d);else{const Q=Qp(c,L+l.length+2,["_"]);c=c.replace(`${g}${l}${x}${Q}`,d)}else c=c.replace(`${g}${l}`,d);L=c.indexOf(`${g}${l}`,L+d.length)}return c}function lT(c,l="$",d=":"){let g=c.indexOf(l);for(;g!==-1;){const x=Qp(c,g+1);if(c[g+x.length+1]===d)if(c[g+x.length+2]===d)c=c.replace(`${l}${x}${d}${d}`,"");else{const L=Qp(c,g+x.length+2);c=c.replace(`${l}${x}${d}${L}`,L)}g=c.indexOf(l,g+1)}return c}function jK(c,l){let d=c.indexOf("](");for(;d!==-1;){const g=eT(c,"[",d),x=c.indexOf(")",d);if(g!==-1&&x!==-1){const[L,Q]=c.slice(g+1,x).split("]("),lt=l(L,Q);c=c.slice(0,g)+lt+c.slice(x+1)}d=c.indexOf("](",d+1)}return c}function fT(c,l=!0){const d=Object.entries(c).filter(([g,x])=>x!=null).map(([g,x])=>`${g}=${encodeURIComponent(x)}`).join("&");return d?(l?"?":"")+d:""}function WK(c){const l={},d=c.split("&");for(const g of d){const[x,L]=g.split("=");x&&L&&(l[x]=decodeURIComponent(L))}return l}function ZK(c,l){return Object.prototype.hasOwnProperty.call(c,l)}function qK(c,l){let d=null,g=-1/0;for(const[x,L]of Object.entries(c)){const Q=l(L);Q>g&&(g=Q,d=x)}return d?[d,c[d]]:null}function QK(c,l,d,g){const x=c.find(Q=>Q[l]===d),L=c.find(Q=>Q[l]===d+g);x&&L?(x[l]=d+g,L[l]=d):x&&(x[l]=d+g),c.sort((Q,lt)=>Nc(Q[l])-Nc(lt[l])),c.forEach((Q,lt)=>Q[l]=lt+1)}function YK(c){const l=Object.keys(c);if(l.length===1)return c[l[0]];throw new Error("Expected object to have a single key")}function JK(c,l=":"){return Object.fromEntries(c.map(d=>l1(d,l)).map(d=>d[0]&&d[1]?[od(d[0]),od(d[1])]:null).filter(d=>d))}function XK(c,l,d){return gT(c,l)+fT(d||{})}function tj(c,l=",",d='"'){const g=[];let x="",L=!1;const Q=c.split("");for(const lt of Q)lt===l&&!L?(g.push(x),x=""):lt===d&&(!x&&!L||L)?L=!L:x+=lt;return g.push(x),g}function ej(c){return`[${Math.floor(c.progress*100)}%] ${Yp(c.deltaMs)} out of ${Yp(c.totalTimeMs)} (${Yp(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function nj(c,l,d){for(let g=0;g<d;g++){try{if(await c())return!0}catch{}g<d-1&&await s(l)}return!1}function rj(c,l){const d=[];for(let g=c.length-1;g>=0;g--)l(c[g])&&d.push(c.splice(g,1)[0]);return d}function ij(c){return JSON.parse(JSON.stringify(c))}function sj(c){return Math.ceil((c||Date.now())/1e3)}function oj(c){return(c||new Date).toISOString().slice(0,10)}function aj(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function cj(c){const l=new Date(c);return new Date(l.getTime()-l.getTimezoneOffset()*6e4)}function uj(c){return new Date(c)}function gs(c){return String(Math.floor(c)).padStart(2,"0")}function lj(c){let[l,d]=c.split(":");he(parseInt(l,10))||(l="0"),he(parseInt(d,10))||(d="0");let g=b1(Je(l),0,23),x=b1(Je(d),0,59);return`${gs(g)}:${gs(x)}`}function Yp(c){const l=Math.floor(c/36e5);c=c%36e5;const d=Math.floor(c/6e4);c=c%6e4;const g=Math.floor(c/1e3);return l?`${gs(l)}:${gs(d)}:${gs(g)}`:`${gs(d)}:${gs(g)}`}function Bc(c){return Math.floor((on(c)?c.getTime():c)/864e5)}const fj={today:(c,l)=>gs(c)+":"+gs(l),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:c=>`${c}w`};function hj(c,l){const d=new Date((l==null?void 0:l.now)||Date.now()),g=(l==null?void 0:l.labels)||fj,x=on(c)?c:new Date(c);if(Bc(d)===Bc(x))return g.today(x.getUTCHours(),x.getUTCMinutes(),x.getUTCHours()>12);if(Bc(d)-Bc(x)===1)return g.yesterday();const L=y1(x);return Bc(d)-Bc(x)<7?g[L.day]():g.weeks(Math.round((d.getTime()-x.getTime())/6048e5))}const hT={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 dT(c,l){const d=(l==null?void 0:l.now)??Date.now(),g=(l==null?void 0:l.labels)||hT,x=n.Types.isDate(c)?c.getTime():c;let L=(d-x)/1e3;return L<10?g.now():L<120?g.seconds(Math.floor(L)):(L/=60,L<120?g.minutes(Math.floor(L)):(L/=60,L<48?g.hours(Math.floor(L)):(L/=24,L<14?g.days(Math.floor(L)):(L/=7,g.weeks(Math.floor(L))))))}function dj(c,l=hT){return dT(0,{now:c*1e3,labels:l})}function pj(c,l,d){const g=((d==null?void 0:d.now)??Date.now())-c,x=Math.floor(g/l),L=l/((d==null?void 0:d.precision)??1)-Math.ceil(g%l/((d==null?void 0:d.precision)??1));return{cycles:x,remaining:L}}const g1={};function gj(c,l){return!g1[c]||Date.now()>g1[c]?(g1[c]=Date.now()+l,!0):!1}const yj={s:1e3,m:6e4,h:36e5,d:864e5};function mj(c,l,d){return l=on(l)?l.getTime():l,d=d?on(d)?d.getTime():d:Date.now(),(d-l)/yj[c]}function wj(c,l,d,g){g||(g=Date.now());const x=l/d,L=g-c,Q=L/l,lt=Q*d,at=lt-L;return{deltaMs:L,progress:x,baseTimeMs:Q,totalTimeMs:lt,remainingTimeMs:at}}const bj={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function pT(c){return{zeroBasedIndex:c,day:bj[c]}}function y1(c){return pT(c.getDay())}function _j(c){return y1(new Date(c))}function Aj(c){return c*1e3}function Ej(c){return c*6e4}function vj(c){return c*36e5}function xj(c){return c*864e5}const Rj={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 Ij(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=Rj[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}const Sj={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 kj(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=Sj[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}function Tj(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const m1={};async function Oj(c,l,d){const g=Date.now(),x=m1[c];if(x&&x.validUntil>g)return x.value;const L=await d(),Q=g+l;return m1[c]={value:L,validUntil:Q},L}function Nj(c){delete m1[c]}function gT(...c){return c.filter(l=>l).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function Cj(c,l,d,g,x=!0){const L=c.indexOf(l),Q=c.indexOf(d,L+l.length);if(L===-1||Q===-1)throw Error("Start or end not found");return x?c.substring(0,L+l.length)+g+c.substring(Q):c.substring(0,L)+g+c.substring(Q+d.length)}function Bj(c){let l="p";c.startsWith("#")?(l="h1",c=c.slice(1).trim()):c.startsWith("-")&&(l="li",c=c.slice(1).trim());const d=c[0]===c[0].toUpperCase(),g=/[.?!]$/.test(c),x=/:$/.test(c);return{type:l,isCapitalized:d,hasPunctuation:g,endsWithColon:x}}function Pj(c,l="(",d=")"){let g=0,x=0;for(;x<c.length;)if(c.startsWith(l,x)?(g++,x+=l.length):c.startsWith(d,x)?(g--,x+=d.length):x++,g<0)return!1;return l===d?g%2===0:g===0}function Mj(c){c=c.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let l=c.length;for(;c=c.replace(/(\w+)[\s,']+\w+/g,"$1"),c.length!==l;)l=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 yT(c){const l=Object.keys(c).sort((g,x)=>g.localeCompare(x)),d={};for(const g of l)d[g]=Pc(c[g]);return d}function mT(c){const l=[];return c.sort((d,g)=>JSON.stringify(Pc(d)).localeCompare(JSON.stringify(Pc(g)))).forEach(d=>l.push(Pc(d))),l}function Pc(c){return Array.isArray(c)?mT(c):sn(c)?yT(c):c}function wT(c,l){return JSON.stringify(Pc(c))===JSON.stringify(Pc(l))}function Lj(...c){for(let l=1;l<c.length;l++)if(!wT(c[l-1],c[l]))return!1;return!0}function Uj(c){try{return JSON.parse(c)}catch{return null}}function Dj(){let c=0;return{next:()=>c++}}function Fj(c){let l=0;return{next:()=>c[l++%c.length]}}function $j(c){let l;return d=>{const g=d===c&&l!==c;return l=d,g}}function Hj(c,l,d,g,x){const L={};for(const Q of Object.keys(l))L[Q]=[];L[g]=[],x&&(c=c.sort(x));for(const Q of c){const lt=Q[d],at=l[lt]?lt:g;L[at].length>=l[at]?L[g].push(Q):L[at].push(Q)}return L}function zj(c,l){const d=Object.keys(c),g=Object.keys(l);return{uniqueToA:d.filter(x=>!g.includes(x)),uniqueToB:g.filter(x=>!d.includes(x))}}function bT(c){const l=Object.keys(c);return l[Math.floor(Math.random()*l.length)]}function Gj(c,l){const d=bT(c);return c[d]=l(c[d]),d}function Vj(c){return c=c.replace(/\r\n/g,`
|
|
10
|
+
`),c=c.replace(/(\w+)\((.+)\)/g,(l,d,g)=>`${d}(${g.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,(l,d,g)=>`: (${d.trim()} && ${g.trim()}) ||`),c=c.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),c=c.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(l,d,g,x)=>`"${d}":"${g.trim()}"${x}`),c=c.replace(/("'|'")/g,'"'),c=c.replaceAll(",",","),JSON.parse(c)}const fa=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],Kj=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],_T=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function jj(c,l,d){let g=c.length-l;if(g<=0)return"0."+"0".repeat(-g)+c+(d?" "+d:"");let x=c.substring(0,g),L=c.substring(g);return x===""&&(x="0"),x+"."+L+(d?" "+d:"")}function Wj(c,l){const d=(l==null?void 0:l.longForm)??!1,g=l!=null&&l.unit?` ${l.unit}`:"",x=d?Kj:_T,L=(l==null?void 0:l.precision)??1;if(c<fa[0])return`${c}${g}`;for(let Q=0;Q<fa.length-1;Q++)if(c<fa[Q+1])return`${(c/fa[Q]).toFixed(L)}${d?" ":""}${x[Q]}${g}`;return`${(c/fa[fa.length-1]).toFixed(L)}${d?" ":""}${x[fa.length-1]}${g}`}function w1(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),g=_T.findIndex(x=>x.toLowerCase()===d.toLowerCase());return g===-1?l:l*fa[g]}function b1(c,l,d){return c<l?l:c>d?d:c}function Zj(c,l,d){const g=c+l;return g>d?d:g}function qj(c,l,d){const g=c-l;return g<d?d:g}function Qj(c,l){return l(c),c}function Yj(c,l){c&&l(c)}function Jj(c,l){const d=Object.keys(l);for(const g of d)Array.isArray(l[g])&&Array.isArray(c[g])&&la(c[g],l[g])}function Xj(c){return c.splice(0,c.length),c}function tW(c){for(const l of Object.keys(c))(De(c[l])||Array.isArray(c[l])&&c[l].every(d=>d==null))&&delete c[l];return c}function eW(c){for(const l of Object.entries(c))(l[1]===null||l[1]===void 0||kn(l[1])&&ve(l[1]))&&delete c[l[0]];return c}function nW(c,l){const d={};for(const[g,x]of Object.entries(c))l(g)&&(d[g]=x);return d}function rW(c,l){const d={};for(const[g,x]of Object.entries(c))l(x)&&(d[g]=x);return d}function iW(c,l){const d={};for(const g of Object.entries(c))d[g[0]]=l(g[1]);return d}function sW(c,l){const d=[];let g=0;for(const x of c)d.push(l(x,g++));return d}async function oW(c,l){try{return await c()}catch{throw l}}function aW(c,l,d){d!=null&&(c[l]=d)}function cW(c,l,d,g){const x=N(d,g);x!=null&&M(c,l,x)}function uW(c){const l={};for(const[d,g]of Object.entries(c))l[g]=d;return l}function lW(c){const l=Object.keys(c),d=l.map(lt=>c[lt].length),g=d.reduce((lt,at)=>lt*=at);let x=1;const L=[1];for(let lt=0;lt<d.length-1;lt++)x*=d[lt],L.push(x);const Q=[];for(let lt=0;lt<g;lt++){const at={};for(let Pt=0;Pt<l.length;Pt++){const Ue=c[l[Pt]],zn=Math.floor(lt/L[Pt])%Ue.length;at[l[Pt]]=Ue[zn]}Q.push(at)}return Q}function fW(c){return Object.values(c).filter(l=>l).length}function hW(c,l,d){return c+(d?"["+l+"]":(c.length?".":"")+l)}function Jp(c,l,d,g,x){if(!sn(l))return l;for(const[L,Q]of Object.entries(l)){const lt=hW(d,L,g);Array.isArray(Q)?x?Jp(c,Q,lt,!0,x):c[lt]=Q.map(at=>Jp(Array.isArray(at)?[]:{},at,"",!1,x)):sn(Q)?Jp(c,Q,lt,!1,x):c[lt]=Q}return c}function dW(c,l=!1,d){return Jp({},c,d||"",!1,l)}function AT(c){if(!sn(c))return c;const l=Array.isArray(c)?[]:{};for(const[d,g]of Object.entries(c))Array.isArray(g)?M(l,d,g.map(x=>AT(x))):M(l,d,g);return l}function pW(c,l,d){return l[c]?l[c]:d}function ET(c,l){const d={};for(const g of c){const x=l(g);d[x]=g}return d}function gW(c,l){const d={};for(const g of c){const x=l(g);d[x]||(d[x]=[]),d[x].push(g)}return d}function yW(c,l){const d=[];for(let g=0;g<c.length;g+=l)d.push(c.slice(g,g+l));return d}function vT(c,l){const d=Math.ceil(c.length/l),g=[];for(let x=0;x<c.length;x+=d)g.push(c.slice(x,x+d));return g}function xT(c,l){const d=[],g=Math.ceil(c.length/l);for(let x=0;x<g;x++)d.push(c.slice(x*l,x*l+l));return d}function mW(c,l){const d=Math.ceil(c.length/l);return xT(c,d)}function wW(c,l){return Object.values(ET(c,l))}function bW(c,l,d,g,x){const L=l?c.map(l):c,Q={};for(const at of L)Q[at]=(Q[at]||0)+1;const lt=g?RT(Q,x?(at,Pt)=>at[1]-Pt[1]:(at,Pt)=>Pt[1]-at[1]):Q;return d?Object.keys(lt):lt}function RT(c,l){return Object.fromEntries(Object.entries(c).sort(l))}function _W(c){const l=[],d=Object.keys(c),g=c[d[0]].length;for(let x=0;x<g;x++){const L={};for(const Q of d)L[Q]=c[Q][x];l.push(L)}return l}function AW(c,l,d=1){for(const g of c)g[l]+=d}function EW(c,l,d){for(const g of c)g[l]=d}function _1(c,l){const d=[];let g=[];return c.forEach((x,L)=>{(L===0||!l(x,c[L-1]))&&(g=[],d.push(g)),g.push(x)}),d}function vW(){return{map:new Map,keys:[]}}function xW(){return{map:new Map,keys:[]}}function IT(c,l,d,g=100){if(c.map.has(l)){const x=c.keys.indexOf(l);c.keys.splice(x,1)}if(c.map.set(l,d),c.keys.push(l),c.keys.length>g){const x=c.keys.shift();x&&c.map.delete(x)}}function RW(c,l,d,g=100){if(c.map.has(l)){const x=c.keys.indexOf(l);c.keys.splice(x,1)}if(c.map.set(l,d),c.keys.unshift(l),c.keys.length>g){const x=c.keys.shift();x&&c.map.delete(x)}}function IW(c,l,d,g,x=100){IT(c,l,{validUntil:Date.now()+g,data:d},x)}function SW(c,l){const d=c.map.get(l);return d&&d.validUntil>Date.now()?d.data:null}class ha{constructor(l){this.value=l}static of(l){return new ha(l)}static empty(){return new ha(null)}map(l){return new ha(this.value!==null&&this.value!==void 0?l(this.value):null)}mapAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(d=>ha.of(d)):Promise.resolve(ha.empty())}ifPresent(l){return this.value!==null&&this.value!==void 0&&l(this.value),this}ifPresentAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(l){return(this.value===null||this.value===void 0)&&l(),this}ifAbsentAsync(l){return this.value===null||this.value===void 0?l().then(()=>this):Promise.resolve(this)}getOrFallback(l){return this.value??l()}getOrFallbackAsync(l){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):l()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}n.Optional=ha;class kW{constructor(l){this.supplier=l,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}n.Lazy=kW;class TW{constructor(l){this.supplier=l,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}n.AsyncLazy=TW;function OW(c){return()=>c.forEach(l=>l())}function NW(c,l){return c.reduce((d,g)=>l(d)>l(g)?d:g)}function CW(c,l){const d=c.find(g=>g instanceof l);return ha.of(d)}function BW(c,l){return c.filter(d=>d instanceof l)}function PW(c,l){const d=[],g=Math.max(c.length,l.length);for(let x=0;x<g;x++)c[x]&&d.push(c[x]),l[x]&&d.push(l[x]);return d}function MW(c,l){return c.includes(l)?c.filter(d=>d!==l):[...c,l]}class LW{constructor(l){this.value=l,this.children=[]}}function UW(c,l,d,g,x=!1){const L=new Map,Q=[];c.forEach(at=>{const Pt=new LW(at);L.set(at[l],Pt)}),c.forEach(at=>{const Pt=L.get(at[l]);if(!Pt)return;const Ue=at[d];if(Ue){const zn=L.get(Ue);zn&&zn.children.push(Pt)}else Q.push(Pt)});const lt=at=>{at.children.sort((Pt,Ue)=>{const zn=Pt.value[g],Yl=Ue.value[g];return x?Yl-zn:zn-Yl}),at.children.forEach(lt)};return Q.forEach(lt),Q}function ST(c,l){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 g=[];for(let x=0;x<d.length;x+=2){const L=d[x+1];g.push(l(d[x],L))}d=g}return d[0]}function Zl(...c){const l=c.reduce((x,L)=>x+L.length,0),d=new Uint8Array(l);let g=0;return c.forEach(x=>{d.set(x,g),g+=x.length}),d}function kT(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function TT(c){return c[0]===255&&c[1]===216}function OT(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function DW(c){return kT(c)||TT(c)||OT(c)}function FW(c){return new Uint8Array([c])}function $W(c){return c[0]}function HW(c,l){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,l==="LE"),new Uint8Array(d)}function zW(c,l){return new DataView(c.buffer).getUint16(c.byteOffset,l==="LE")}function GW(c,l){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,l==="LE"),new Uint8Array(d)}function VW(c,l){return new DataView(c.buffer).getUint32(c.byteOffset,l==="LE")}function A1(c,l){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),l==="LE"),new Uint8Array(d)}function KW(c,l){return new DataView(c.buffer).getBigUint64(c.byteOffset,l==="LE")}function ql(c,l){const d=new Uint8Array(32);let g=c;if(l==="LE"){for(let x=0;x<32;x++)d[x]=Number(g&0xffn),g>>=8n;return d}for(let x=31;x>=0;x--)d[x]=Number(g&0xffn),g>>=8n;return d}function Ql(c,l){let d=0n;if(l==="LE"){for(let g=31;g>=0;g--)d=d<<8n|BigInt(c[g]);return d}for(let g=0;g<32;g++)d=d<<8n|BigInt(c[g]);return d}function jW(c,l){const d=[];let g=0;for(const x of l)d.push(c.subarray(g,g+x)),g+=x;return d}function E1(c,l){const d=[];for(let g=0;g<c.length;g+=l)d.push(c.subarray(g,g+l));return d}const NT=[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 WW(c){for(let l=0;l<24;l++){const d=c[0]^c[10]^c[20]^c[30]^c[40],g=c[1]^c[11]^c[21]^c[31]^c[41],x=c[2]^c[12]^c[22]^c[32]^c[42],L=c[3]^c[13]^c[23]^c[33]^c[43],Q=c[4]^c[14]^c[24]^c[34]^c[44],lt=c[5]^c[15]^c[25]^c[35]^c[45],at=c[6]^c[16]^c[26]^c[36]^c[46],Pt=c[7]^c[17]^c[27]^c[37]^c[47],Ue=c[8]^c[18]^c[28]^c[38]^c[48],zn=c[9]^c[19]^c[29]^c[39]^c[49],Yl=x<<1|L>>>31,TZ=L<<1|x>>>31,ld=Ue^Yl,fd=zn^TZ,OZ=Q<<1|lt>>>31,NZ=lt<<1|Q>>>31,hd=d^OZ,dd=g^NZ,CZ=at<<1|Pt>>>31,BZ=Pt<<1|at>>>31,pd=x^CZ,gd=L^BZ,PZ=Ue<<1|zn>>>31,MZ=zn<<1|Ue>>>31,yd=Q^PZ,md=lt^MZ,LZ=d<<1|g>>>31,UZ=g<<1|d>>>31,wd=at^LZ,bd=Pt^UZ;c[0]^=ld,c[1]^=fd,c[2]^=hd,c[3]^=dd,c[4]^=pd,c[5]^=gd,c[6]^=yd,c[7]^=md,c[8]^=wd,c[9]^=bd,c[10]^=ld,c[11]^=fd,c[12]^=hd,c[13]^=dd,c[14]^=pd,c[15]^=gd,c[16]^=yd,c[17]^=md,c[18]^=wd,c[19]^=bd,c[20]^=ld,c[21]^=fd,c[22]^=hd,c[23]^=dd,c[24]^=pd,c[25]^=gd,c[26]^=yd,c[27]^=md,c[28]^=wd,c[29]^=bd,c[30]^=ld,c[31]^=fd,c[32]^=hd,c[33]^=dd,c[34]^=pd,c[35]^=gd,c[36]^=yd,c[37]^=md,c[38]^=wd,c[39]^=bd,c[40]^=ld,c[41]^=fd,c[42]^=hd,c[43]^=dd,c[44]^=pd,c[45]^=gd,c[46]^=yd,c[47]^=md,c[48]^=wd,c[49]^=bd;const k1=c[0],T1=c[1],O1=c[2]<<1|c[3]>>>31,N1=c[3]<<1|c[2]>>>31,C1=c[5]<<30|c[4]>>>2,B1=c[4]<<30|c[5]>>>2,P1=c[6]<<28|c[7]>>>4,M1=c[7]<<28|c[6]>>>4,L1=c[8]<<27|c[9]>>>5,U1=c[9]<<27|c[8]>>>5,D1=c[11]<<4|c[10]>>>28,F1=c[10]<<4|c[11]>>>28,$1=c[13]<<12|c[12]>>>20,H1=c[12]<<12|c[13]>>>20,z1=c[14]<<6|c[15]>>>26,G1=c[15]<<6|c[14]>>>26,V1=c[17]<<23|c[16]>>>9,K1=c[16]<<23|c[17]>>>9,j1=c[18]<<20|c[19]>>>12,W1=c[19]<<20|c[18]>>>12,Z1=c[20]<<3|c[21]>>>29,q1=c[21]<<3|c[20]>>>29,Q1=c[22]<<10|c[23]>>>22,Y1=c[23]<<10|c[22]>>>22,J1=c[25]<<11|c[24]>>>21,X1=c[24]<<11|c[25]>>>21,tb=c[26]<<25|c[27]>>>7,eb=c[27]<<25|c[26]>>>7,nb=c[29]<<7|c[28]>>>25,rb=c[28]<<7|c[29]>>>25,ib=c[31]<<9|c[30]>>>23,sb=c[30]<<9|c[31]>>>23,ob=c[33]<<13|c[32]>>>19,ab=c[32]<<13|c[33]>>>19,cb=c[34]<<15|c[35]>>>17,ub=c[35]<<15|c[34]>>>17,lb=c[36]<<21|c[37]>>>11,fb=c[37]<<21|c[36]>>>11,hb=c[38]<<8|c[39]>>>24,db=c[39]<<8|c[38]>>>24,pb=c[40]<<18|c[41]>>>14,gb=c[41]<<18|c[40]>>>14,yb=c[42]<<2|c[43]>>>30,mb=c[43]<<2|c[42]>>>30,wb=c[45]<<29|c[44]>>>3,bb=c[44]<<29|c[45]>>>3,_b=c[47]<<24|c[46]>>>8,Ab=c[46]<<24|c[47]>>>8,Eb=c[48]<<14|c[49]>>>18,vb=c[49]<<14|c[48]>>>18;c[0]=k1^~$1&J1,c[1]=T1^~H1&X1,c[2]=$1^~J1&lb,c[3]=H1^~X1&fb,c[4]=J1^~lb&Eb,c[5]=X1^~fb&vb,c[6]=lb^~Eb&k1,c[7]=fb^~vb&T1,c[8]=Eb^~k1&$1,c[9]=vb^~T1&H1,c[10]=P1^~j1&Z1,c[11]=M1^~W1&q1,c[12]=j1^~Z1&ob,c[13]=W1^~q1&ab,c[14]=Z1^~ob&wb,c[15]=q1^~ab&bb,c[16]=ob^~wb&P1,c[17]=ab^~bb&M1,c[18]=wb^~P1&j1,c[19]=bb^~M1&W1,c[20]=O1^~z1&tb,c[21]=N1^~G1&eb,c[22]=z1^~tb&hb,c[23]=G1^~eb&db,c[24]=tb^~hb&pb,c[25]=eb^~db&gb,c[26]=hb^~pb&O1,c[27]=db^~gb&N1,c[28]=pb^~O1&z1,c[29]=gb^~N1&G1,c[30]=L1^~D1&Q1,c[31]=U1^~F1&Y1,c[32]=D1^~Q1&cb,c[33]=F1^~Y1&ub,c[34]=Q1^~cb&_b,c[35]=Y1^~ub&Ab,c[36]=cb^~_b&L1,c[37]=ub^~Ab&U1,c[38]=_b^~L1&D1,c[39]=Ab^~U1&F1,c[40]=C1^~V1&nb,c[41]=B1^~K1&rb,c[42]=V1^~nb&ib,c[43]=K1^~rb&sb,c[44]=nb^~ib&yb,c[45]=rb^~sb&mb,c[46]=ib^~yb&C1,c[47]=sb^~mb&B1,c[48]=yb^~C1&V1,c[49]=mb^~B1&K1,c[0]^=NT[l*2],c[1]^=NT[l*2+1]}}function CT(c){const l=[];for(let d=0;d<c.length;d+=4)l.push(c[d]|c[d+1]<<8|c[d+2]<<16|c[d+3]<<24);return l}function BT(c,l){if(!c.length){const x=new Uint8Array(136);return x[0]=l,x[135]=128,[CT(x)]}const d=E1(c,136),g=d[d.length-1];if(g.length<136){const x=new Uint8Array(136);x.set(g),x[g.length]=l,x[135]|=128,d[d.length-1]=x}if(g.length===136){const x=new Uint8Array(136);x[0]=l,x[135]=128,d.push(x)}return d.map(CT)}function PT(c,l){for(const d of l){for(let g=0;g<34;g+=2)c[g]^=d[g+1],c[g+1]^=d[g];WW(c)}return c}function MT(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 MT(PT(new Array(50).fill(0),BT(c,1)))}function ZW(c){return MT(PT(new Array(50).fill(0),BT(c,6)))}function qW(c,l,d){const g=Math.min(c.length,l.length,d/8+1);for(let x=0;x<g;x++){const L=c[x]^l[x];for(let Q=0;Q<8;Q++)if(L>>7-Q&1)return x*8+Q}return d}function QW(c,l){const d=Math.min(c.length,l.length);for(let g=0;g<d;g++)if(c[g]!==l[g])return c.subarray(0,g);return c.subarray(0,d)}function YW(c,l,d,g){const x=Math.floor(l/8),L=l%8;d===1?c[x]|=1<<(g==="BE"?7-L:L):c[x]&=~(1<<(g==="BE"?7-L:L))}function JW(c,l,d){const g=Math.floor(l/8),x=l%8;return c[g]>>(d==="BE"?7-x:x)&1}function XW(c,l,d=0){for(let g=d;g<c.length;g++)for(let x=0;x<l.length&&c[g+x]===l[x];x++)if(x===l.length-1)return g;return-1}function LT(c,l,d=0){if(c.length>=l)return c;const g=new Uint8Array(l);return g.fill(d),g.set(c,l-c.length),g}function tZ(c,l,d=0){const g=c.length%l;return g===0?c:LT(c,c.length+l-g,d)}function UT(c,l,d=0){if(c.length>=l)return c;const g=new Uint8Array(l);return g.fill(d),g.set(c,0),g}function eZ(c,l,d=0){const g=c.length%l;return g===0?c:UT(c,c.length+l-g,d)}function nZ(c,l){const d=new Uint8Array(c.length);for(let g=0;g<c.length;g++)d[g]=c[g]^l[g%l.length];return d}function rZ(c,l){if(c.length!==l.length)return!1;for(let d=0;d<c.length;d++)if(c[d]!==l[d])return!1;return!0}function Ve(c,l){return(c%l+l)%l}function cd(c,l){c=Ve(c,l);let[d,g]=[0n,1n],[x,L]=[l,c];for(;L!==0n;){const Q=x/L;[d,g]=[g,d-Q*g],[x,L]=[L,x-Q*L]}if(x>1n)throw new Error("a is not invertible");return d<0n&&(d+=l),d}function iZ(c,l,d){let g=1n;for(c=Ve(c,d);l>0;)l%2n===1n&&(g=Ve(g*c,d)),c=Ve(c*c,d),l=l/2n;return g}function DT(c,l){return Ve(c,l)===0n?0n:l%4n===3n?iZ(c,(l+1n)/4n,l):null}const lr=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Hn=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Xp=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,tg=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function v1(c,l,d){if(l===0n)return[0n,0n];const g=Ve(3n*c*c*cd(2n*l,d),d),x=Ve(g*g-2n*c,d),L=Ve(g*(c-x)-l,d);return[x,L]}function eg(c,l,d,g,x){if(c===0n&&l===0n)return[d,g];if(d===0n&&g===0n)return[c,l];if(c===d&&l===Ve(-g,x))return[0n,0n];if(c===d&&l===g)return v1(c,l,x);const L=Ve((g-l)*cd(d-c,x),x),Q=Ve(L*L-c-d,x),lt=Ve(L*(c-Q)-l,x);return[Q,lt]}function sZ(c){if(c<=0n||c>=Hn)throw new Error("Invalid private key");return Mc(Xp,tg,c,lr)}function oZ(c){const l=c[1]%2n===0n?2:3;return new Uint8Array([l,...ql(c[0],"BE")])}function aZ(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const l=Ql(c.slice(1),"BE"),d=DT(Ve(l**3n+7n,lr),lr);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const g=Ve(-d,lr),x=d%2n===0n;return[l,c[0]===2?x?d:g:x?g:d]}function cZ(c){const l=new Uint8Array(20),d=oo(Zl(ql(c[0],"BE"),ql(c[1],"BE")));return l.set(d.subarray(12)),l}function uZ(c){const l=n.Binary.uint8ArrayToHex(c),d=n.Binary.uint8ArrayToHex(n.Binary.keccak256(new Uint8Array([...l].map(x=>x.charCodeAt(0)))));let g="0x";for(let x=0;x<l.length;x++)parseInt(d[x],16)>7?g+=l[x].toUpperCase():g+=l[x];return g}function Mc(c,l,d,g){let x=[0n,0n],L=[c,l];const Q=d.toString(2);for(const lt of Q)lt==="0"?(L=eg(x[0],x[1],L[0],L[1],g),x=v1(x[0],x[1],g)):(x=eg(x[0],x[1],L[0],L[1],g),L=v1(L[0],L[1],g));return x}function lZ(c,l,d){return FT(Ql(oo(c),"BE"),l,d)}function FT(c,l,d){if(l<=0n||l>=Hn)throw new Error("Invalid private key");if(d||(d=Ve(Ql(oo(Zl(oo(ql(l,"BE")),ql(c,"BE"))),"BE"),Hn)),d<=0n||d>=Hn)throw new Error("Invalid nonce");const g=Ve(c,Hn),x=Mc(Xp,tg,d,lr),L=Ve(x[0],Hn);let Q=Ve((g+Ve(L,Hn)*l)*cd(d,Hn),Hn);if(L===0n||Q===0n)throw new Error("Invalid r or s value");let lt=x[1]%2n===0n?27n:28n;return Q>Hn/2n&&(Q=Hn-Q,lt=lt===27n?28n:27n),[L,Q,lt]}function fZ(c,l,d,g){const x=DT(Ve(l**3n+7n,lr),lr);if(!x)throw new Error("Invalid r: does not correspond to a valid curve point");const L=g===27n?0n:1n,Q=x%2n===L?x:lr-x,lt=Ve(Ql(oo(c),"BE"),Hn),at=Mc(l,Q,d,lr),Pt=Mc(Xp,tg,lt,lr),Ue=eg(at[0],at[1],Pt[0],Ve(-Pt[1],lr),lr);return Mc(Ue[0],Ue[1],cd(l,Hn),lr)}function hZ(c,l,d,g){const x=Ve(Ql(oo(c),"BE"),Hn),L=cd(g,Hn),Q=Ve(x*L,Hn),lt=Ve(d*L,Hn),at=Mc(Xp,tg,Q,lr),Pt=Mc(l[0],l[1],lt,lr),Ue=eg(at[0],at[1],Pt[0],Pt[1],lr);return d===Ve(Ue[0],Hn)}class $T{constructor(l){this.cursor=0,this.buffer=l}read(l){const d=this.buffer.subarray(this.cursor,this.cursor+l);return this.cursor+=l,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayReader=$T;class HT{constructor(l){this.buffer=l,this.cursor=0}write(l){const d=Math.min(this.max(),l.max());return this.buffer.set(l.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayWriter=HT;class ng{constructor(l,d=0n){this.span=d,this.writer=new HT(new Uint8Array(l))}build(){return Zl(A1(this.span,"LE"),this.writer.buffer)}hash(){const l=ST(E1(this.writer.buffer,32),(d,g)=>oo(Zl(d,g)));return oo(Zl(A1(this.span,"LE"),l))}}n.Chunk=ng;class x1{constructor(l,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new ng(d)],this.onChunk=l}static async root(l,d=4096){const g=new t(t.NOOP,d);return await g.append(l),g.finalize()}async append(l,d=0,g=0n){const x=new $T(l);for(;x.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(x);g?this.chunks[d].span+=g:this.chunks[0].span+=BigInt(L)}}async elevate(l){this.counters[l]=++this.counters[l]%(this.capacity/32),this.chunks[l+1]||(this.chunks.push(new ng(this.capacity)),this.counters.push(1)),await this.append(this.chunks[l].hash(),l+1,this.chunks[l].span),await this.onChunk(this.chunks[l]),this.chunks[l]=new ng(this.capacity)}async finalize(l=0){return this.chunks[l+1]?this.counters[l]===1?(await this.elevate(l+1),this.chunks[l+1]=this.chunks[l],this.finalize(l+1)):(await this.elevate(l),this.finalize(l+1)):(await this.onChunk(this.chunks[l]),this.chunks[l])}}n.MerkleTree=x1,t=x1,x1.NOOP=async c=>{};class ys{constructor(l,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(l),this.scale=d}static fromDecimalString(l,d){let[g,x]=l.split(".");return x=(x||"").padEnd(d,"0").slice(0,d),new ys(BigInt(g+x),d)}add(l){return this.assertSameScale(l),new ys(this.value+l.value,this.scale)}subtract(l){return this.assertSameScale(l),new ys(this.value-l.value,this.scale)}multiply(l){return new ys(this.value*l,this.scale)}divmod(l){if(l===0n)throw new Error("Division by zero is not allowed");const d=this.value/l,g=this.value%l;return[new ys(d,this.scale),new ys(g,this.scale)]}exchange(l,d,g){if(l==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new ys(L,g)}this.assertSameScale(d);const x=this.value*10n**BigInt(g)/d.value;return new ys(x,g)}compare(l){return this.assertSameScale(l),this.value>l.value?1:this.value<l.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const l=this.value.toString(),d=l.slice(0,-this.scale)||"0",g=l.slice(-this.scale).padStart(this.scale,"0");return`${d}.${g}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(l){if(this.scale!==l.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${l.scale}`)}}n.FixedPointNumber=ys;function dZ(c){if(c.length===0)return null;const l=c[0];return l.ttlMax?--l.ttl<=0&&c.shift():l.ttlMax=l.ttl,{progress:(l.ttlMax-l.ttl)/l.ttlMax,data:l.data}}function rg(c,l,d,g){const x=c.findIndex(lt=>lt===`--${l}`||lt.startsWith(`--${l}=`)),L=c[x];if(!L)return(d||{})[g||l||""]||null;if(L.includes("="))return L.split("=")[1];const Q=c[x+1];return Q&&!Q.startsWith("-")?Q:(d||{})[g||l||""]||null}function pZ(c,l,d,g){const x=rg(c,l,d,g);if(!x)return null;try{return w1(x)}catch{throw new Error(`Invalid number argument ${l}: ${x}`)}}function gZ(c,l,d,g){const x=c.some(at=>at.endsWith("-"+l)),L=rg(c,l,d,g);if(!L&&x)return!0;if(!L&&!x)return null;const Q=["true","1","yes","y","on"],lt=["false","0","no","n","off"];if(Q.includes(L.toLowerCase()))return!0;if(lt.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${l}: ${L}`)}function zT(c,l,d,g){const x=rg(c,l,d,g);if(!x)throw new Error(`Missing argument ${l}`);return x}function yZ(c,l,d,g){const x=zT(c,l,d,g);try{return w1(x)}catch{throw new Error(`Invalid argument ${l}: ${x}`)}}function GT(c,l){const d=c[l];c.splice(l,1),c.unshift(d)}function mZ(c,l){const d=[...c];return GT(d,l),d}function VT(c,l){return{x:c.x+l.x,y:c.y+l.y}}function wZ(c,l){return{x:c.x-l.x,y:c.y-l.y}}function R1(c,l){return{x:c.x*l,y:c.y*l}}function bZ(c){const l=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/l,y:c.y/l}}function KT(c,l,d){return{x:c.x+Math.cos(l)*d,y:c.y+Math.sin(l)*d}}function jT(c,l){return Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2)}function ud(c,l,d="row-first"){const g=[];if(d==="column-first")for(let x=0;x<c.length;x++)for(let L=0;L<c[0].length;L++)l(x,L)&&g.push({x,y:L});else for(let x=0;x<c[0].length;x++)for(let L=0;L<c.length;L++)l(L,x)&&g.push({x:L,y:x});return g}function _Z(c,l,d){var g,x;return((g=c[l+1])==null?void 0:g[d])&&((x=c[l-1])==null?void 0:x[d])&&!c[l][d-1]&&!c[l][d+1]}function AZ(c,l,d){var g,x;return c[l][d+1]&&c[l][d-1]&&!((g=c[l-1])!=null&&g[d])&&!((x=c[l+1])!=null&&x[d])}function WT(c,l,d){var g;return!((g=c[l-1])!=null&&g[d])}function ZT(c,l,d){var g;return!((g=c[l+1])!=null&&g[d])}function qT(c,l,d){return!c[l][d-1]}function QT(c,l,d){return!c[l][d+1]}function EZ(c,l,d){var x,L,Q,lt,at,Pt,Ue,zn;const g=[];return c[l][d]?_Z(c,l,d)||AZ(c,l,d)?[]:(!((x=c[l-1])!=null&&x[d-1])&&WT(c,l,d)&&qT(c,l,d)&&g.push({x:l,y:d}),!((L=c[l+1])!=null&&L[d-1])&&ZT(c,l,d)&&qT(c,l,d)&&g.push({x:l+1,y:d}),!((Q=c[l-1])!=null&&Q[d+1])&&WT(c,l,d)&&QT(c,l,d)&&g.push({x:l,y:d+1}),!((lt=c[l+1])!=null&<[d+1])&&ZT(c,l,d)&&QT(c,l,d)&&g.push({x:l+1,y:d+1}),g):((at=c[l-1])!=null&&at[d]&&c[l][d-1]&&g.push({x:l,y:d}),(Pt=c[l+1])!=null&&Pt[d]&&c[l][d-1]&&g.push({x:l+1,y:d}),(Ue=c[l-1])!=null&&Ue[d]&&c[l][d+1]&&g.push({x:l,y:d+1}),(zn=c[l+1])!=null&&zn[d]&&c[l][d+1]&&g.push({x:l+1,y:d+1}),g)}function vZ(c,l,d,g){const x=[{x:0,y:0},{x:d,y:0},{x:0,y:g},{x:d,y:g}];for(let L=0;L<c.length;L++)for(let Q=0;Q<c[0].length;Q++){const lt=EZ(c,L,Q);for(const at of lt)x.some(Pt=>Pt.x===at.x&&Pt.y===at.y)||x.push(at)}return x.map(L=>({x:L.x*l,y:L.y*l}))}function xZ(c,l){const d=ud(c,(at,Pt)=>c[at][Pt]===0&&c[at][Pt+1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),g=ud(c,(at,Pt)=>c[at][Pt]===0&&c[at][Pt-1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),x=ud(c,(at,Pt)=>{var Ue;return c[at][Pt]===0&&((Ue=c[at-1])==null?void 0:Ue[Pt])!==0},"column-first").map(at=>({...at,dx:0,dy:1})),L=ud(c,(at,Pt)=>{var Ue;return c[at][Pt]===0&&((Ue=c[at+1])==null?void 0:Ue[Pt])!==0},"column-first").map(at=>({...at,dx:0,dy:1}));d.forEach(at=>at.y++),L.forEach(at=>at.x++);const Q=_1([...x,...L],(at,Pt)=>at.x===Pt.x&&at.y-1===Pt.y),lt=_1([...g,...d],(at,Pt)=>at.y===Pt.y&&at.x-1===Pt.x);return[...Q,...lt].map(at=>({start:at[0],end:C(at)})).map(at=>({start:R1(at.start,l),end:R1(VT(at.end,{x:at.start.dx,y:at.start.dy}),l)}))}function RZ(c,l){return Math.atan2(l.y-c.y,l.x-c.x)}function IZ(c,l){return l.map(d=>RZ(c,d)).sort((d,g)=>d-g)}function YT(c,l,d,g){const x=(g.y-d.y)*(l.x-c.x)-(g.x-d.x)*(l.y-c.y);if(x===0)return null;let L=c.y-d.y,Q=c.x-d.x;const lt=(g.x-d.x)*L-(g.y-d.y)*Q,at=(l.x-c.x)*L-(l.y-c.y)*Q;return L=lt/x,Q=at/x,L>0&&L<1&&Q>0&&Q<1?{x:c.x+L*(l.x-c.x),y:c.y+L*(l.y-c.y)}:null}function I1(c,l,d){const g=[],x=KT(c,d,1e4);for(const L of l){const Q=YT(c,x,L.start,L.end);Q&&g.push(Q)}return g.length?g.reduce((L,Q)=>{const lt=jT(c,Q),at=jT(c,L);return lt<at?Q:L}):null}function SZ(c,l,d){const g=IZ(c,d),x=[];for(const L of g){const Q=I1(c,l,L-.001),lt=I1(c,l,L+.001);Q&&x.push(Q),lt&&x.push(lt)}return x}class S1{constructor(){this.subscribers=[]}subscribe(l){return this.subscribers.push(l),()=>{this.subscribers=this.subscribers.filter(d=>d!==l)}}publish(l){this.subscribers.forEach(d=>d(l))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}n.PubSubChannel=S1;class kZ{constructor(l,d){this.queue=[],this.running=0,this.onProcessed=new S1,this.onDrained=new S1,this.concurrency=l,this.capacity=d}process(){if(this.running>=this.concurrency)return;const l=this.queue.shift();l&&(this.running++,l().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(l){if(this.queue.length<this.capacity)return this.queue.push(l),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(l),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(l=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),l()})})}}n.AsyncQueue=kZ,n.Binary={hexToUint8Array:BK,uint8ArrayToHex:PK,base64ToUint8Array:TK,uint8ArrayToBase64:OK,base32ToUint8Array:NK,uint8ArrayToBase32:CK,log2Reduce:ST,partition:E1,concatBytes:Zl,numberToUint8:FW,uint8ToNumber:$W,numberToUint16:HW,uint16ToNumber:zW,numberToUint32:GW,uint32ToNumber:VW,numberToUint64:A1,uint64ToNumber:KW,numberToUint256:ql,uint256ToNumber:Ql,sliceBytes:jW,keccak256:oo,sha3_256:ZW,proximity:qW,commonPrefix:QW,setBit:YW,getBit:JW,indexOf:XW,equals:rZ,padStart:LT,padStartToMultiple:tZ,padEnd:UT,padEndToMultiple:eZ,xorCypher:nZ},n.Elliptic={privateKeyToPublicKey:sZ,compressPublicKey:oZ,publicKeyFromCompressed:aZ,publicKeyToAddress:cZ,signMessage:lZ,signHash:FT,verifySignature:hZ,recoverPublicKey:fZ,checksumEncode:uZ},n.Random={intBetween:H,floatBetween:U,chance:J,signed:G,makeSeededRng:B,point:X,procs:j},n.Arrays={countUnique:bW,makeUnique:wW,splitBySize:yW,splitByCount:vT,index:ET,indexCollection:gW,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:f,shuffle:o,initialize:y,initialize2D:w,rotate2D:_,containsShape:R,glue:DV,pluck:I,pick:it,pickMany:ut,pickManyUnique:rt,pickWeighted:v,pickRandomIndices:T,pickGuaranteed:ot,last:C,pipe:p,makePipe:m,sortWeighted:k,pushAll:la,unshiftAll:LV,filterAndRemove:rj,merge:Jj,empty:Xj,pushToBucket:rd,unshiftAndLimit:id,atRolling:sd,group:_1,createOscillator:Fj,organiseWithLimits:Hj,tickPlaybook:dZ,getArgument:rg,getBooleanArgument:gZ,getNumberArgument:pZ,requireStringArgument:zT,requireNumberArgument:yZ,bringToFront:mZ,bringToFrontInPlace:GT,findInstance:CW,filterInstances:BW,interleave:PW,toggle:MW,createHierarchy:UW,multicall:OW,maxBy:NW},n.System={sleepMillis:s,forever:dt,scheduleMany:KV,waitFor:nj,expandError:Xh,runAndSetInterval:wt},n.Numbers={make:w1,sum:WV,average:ZV,median:qV,getDistanceFromMidpoint:QV,clamp:b1,range:Kk,interpolate:jV,createSequence:Dj,increment:Zj,decrement:qj,format:Wj,fromDecimals:jj,makeStorage:kj,asMegabytes:Gt,convertBytes:Ut,hexToRgb:Lt,rgbToHex:Re,haversineDistanceToMeters:Kt,roundToNearest:Ft,formatDistance:Te,triangularNumber:re,searchFloat:oe},n.Promises={raceFulfilled:r,invert:e,runInParallelBatches:i},n.Dates={getTimestamp:hj,getTimeDelta:dT,secondsToHumanTime:dj,countCycles:pj,isoDate:oj,throttle:gj,timeSince:mj,dateTimeSlug:aj,unixTimestamp:sj,fromUtcString:cj,fromMillis:uj,getProgress:wj,humanizeTime:Yp,humanizeProgress:ej,createTimeDigits:gs,mapDayNumber:pT,getDayInfoFromDate:y1,getDayInfoFromDateTimeString:_j,seconds:Aj,minutes:Ej,hours:vj,days:xj,make:Ij,normalizeTime:lj,absoluteDays:Bc},n.Objects={safeParse:Uj,deleteDeep:A,getDeep:N,setDeep:M,incrementDeep:z,ensureDeep:P,replaceDeep:$,getFirstDeep:ct,deepMergeInPlace:Pi,deepMerge2:td,deepMerge3:ed,mapAllAsync:UV,cloneWithJson:ij,sortObject:yT,sortArray:mT,sortAny:Pc,deepEquals:wT,deepEqualsEvery:Lj,runOn:Qj,ifPresent:Yj,zip:jl,zipSum:nd,removeEmptyArrays:tW,removeEmptyValues:eW,flatten:dW,unflatten:AT,match:pW,sort:RT,map:iW,mapIterable:sW,filterKeys:nW,filterValues:rW,rethrow:oW,setSomeOnObject:aW,setSomeDeep:cW,flip:uW,getAllPermutations:lW,countTruthyValues:fW,transformToArray:_W,setMulti:EW,incrementMulti:AW,createBidirectionalMap:vW,createTemporalBidirectionalMap:xW,pushToBidirectionalMap:IT,unshiftToBidirectionalMap:RW,addToTemporalBidirectionalMap:IW,getFromTemporalBidirectionalMap:SW,createStatefulToggle:$j,diffKeys:zj,pickRandomKey:bT,mapRandomKey:Gj,fromObjectString:Vj,toQueryString:fT,parseQueryString:WK,hasKey:ZK,selectMax:qK,reposition:QK,unwrapSingleKey:YK,parseKeyValues:JK},n.Types={isFunction:Be,isObject:sn,isStrictlyObject:fe,isEmptyArray:De,isEmptyObject:ua,isUndefined:Ie,isString:kn,isNumber:he,isBoolean:Se,isDate:on,isBlank:ve,isId:Pe,isIntegerString:ur,isHexString:Fe,isUrl:Vl,isNullable:qh,asString:an,asHexString:pn,asSafeString:Kp,asIntegerString:Vp,asNumber:Nc,asFunction:gn,asInteger:Je,asBoolean:yn,asDate:jp,asNullableString:mn,asEmptiableString:wn,asId:Wp,asTime:bn,asArray:_n,asObject:Cc,asNullableObject:An,asStringMap:En,asNumericDictionary:Wh,asUrl:Zh,asNullable:Qh,asOptional:Yh,enforceObjectShape:Kl,enforceArrayShape:Jh,isPng:kT,isJpg:TT,isWebp:OT,isImage:DW},n.Strings={tokenizeByCount:mW,tokenizeByLength:xT,searchHex:Gp,searchSubstring:hn,randomHex:dn,randomLetter:jt,randomAlphanumeric:$e,randomRichAscii:Ht,randomUnicode:fn,includesAny:YV,slugify:a1,normalForm:XV,enumify:sK,escapeHtml:aK,decodeHtmlEntities:uK,after:c1,afterLast:Wk,before:jk,beforeLast:u1,betweenWide:lK,betweenNarrow:fK,getPreLine:Tj,containsWord:p1,containsWords:GK,joinUrl:gT,getFuzzyMatchScore:Zp,sortByFuzzyScore:oK,splitOnce:l1,splitAll:Zk,randomize:gK,expand:qk,shrinkTrim:od,capitalize:qp,decapitalize:Qk,csvEscape:AK,parseCsv:tj,surroundInOut:iK,getExtension:f1,getBasename:h1,normalizeEmail:hK,normalizeFilename:dK,parseFilename:pK,camelToTitle:tK,slugToTitle:eK,slugToCamel:nK,joinHumanly:rK,findWeightedPair:nT,extractBlock:rT,extractAllBlocks:xK,replaceBlocks:RK,indexOfEarliest:Wl,lastIndexOfBefore:eT,parseHtmlAttributes:VK,readNextWord:Qp,resolveVariables:KK,resolveVariableWithDefaultSyntax:uT,resolveRemainingVariablesWithDefaults:lT,isLetter:Yk,isDigit:Jk,isLetterOrDigit:ad,isValidObjectPathCharacter:wK,insert:bK,indexOfRegex:Xk,lineMatches:tT,linesMatchInOrder:_K,represent:so,resolveMarkdownLinks:jK,buildUrl:XK,isChinese:JV,replaceBetweenStrings:Cj,describeMarkdown:Bj,isBalanced:Pj,textToFormat:Mj,splitFormatting:IK,splitHashtags:SK,splitUrls:kK,route:MK,explodeReplace:d1,generateVariants:LK,replaceWord:UK,replacePascalCaseWords:DK,stripHtml:FK,breakLine:cT,measureTextWidth:$K,toLines:HK,levenshteinDistance:zK},n.Assertions={asEqual:FV,asTrue:$V,asTruthy:HV,asFalse:zV,asFalsy:GV,asEither:VV},n.Cache={get:Oj,invalidate:Nj},n.Vector={addPoint:VT,subtractPoint:wZ,multiplyPoint:R1,normalizePoint:bZ,pushPoint:KT,filterCoordinates:ud,findCorners:vZ,findLines:xZ,raycast:I1,raycastCircle:SZ,getLineIntersectionPoint:YT}})(T_);const je=Mr(T_);je.Arrays,je.Assertions;const Xn=je.Binary;je.Cache,je.Dates,je.Elliptic,je.Numbers,je.Objects,je.Pagination,je.Promises,je.Random,je.Strings,je.System,je.Types,je.Optional,je.Vector,je.PubSubChannel,je.Chunk;const q8=je.MerkleTree;je.FixedPointNumber,je.Lazy,je.AsyncLazy,je.AsyncQueue,je.Uint8ArrayReader,je.Uint8ArrayWriter;var de;(function(n){n.assertEqual=i=>i;function t(i){}n.assertIs=t;function e(i){throw new Error}n.assertNever=e,n.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},n.getValidEnumValues=i=>{const s=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},n.find=(i,s)=>{for(const o of i)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(de||(de={}));var kg;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(kg||(kg={}));const It=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ws=n=>{switch(typeof n){case"undefined":return It.undefined;case"string":return It.string;case"number":return isNaN(n)?It.nan:It.number;case"boolean":return It.boolean;case"function":return It.function;case"bigint":return It.bigint;case"symbol":return It.symbol;case"object":return Array.isArray(n)?It.array:n===null?It.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?It.promise:typeof Map<"u"&&n instanceof Map?It.map:typeof Set<"u"&&n instanceof Set?It.set:typeof Date<"u"&&n instanceof Date?It.date:It.object;default:return It.unknown}},gt=de.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Q8=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class Lr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let a=r,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(a[f]=a[f]||{_errors:[]},a[f]._errors.push(e(o))):a[f]=a[f]||{_errors:[]},a=a[f],u++}}};return i(this),r}static assert(t){if(!(t instanceof Lr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}Lr.create=n=>new Lr(n);const Gc=(n,t)=>{let e;switch(n.code){case gt.invalid_type:n.received===It.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case gt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,de.jsonStringifyReplacer)}`;break;case gt.unrecognized_keys:e=`Unrecognized key(s) in object: ${de.joinValues(n.keys,", ")}`;break;case gt.invalid_union:e="Invalid input";break;case gt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${de.joinValues(n.options)}`;break;case gt.invalid_enum_value:e=`Invalid enum value. Expected ${de.joinValues(n.options)}, received '${n.received}'`;break;case gt.invalid_arguments:e="Invalid function arguments";break;case gt.invalid_return_type:e="Invalid function return type";break;case gt.invalid_date:e="Invalid date";break;case gt.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:de.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case gt.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case gt.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case gt.custom:e="Invalid input";break;case gt.invalid_intersection_types:e="Intersection results could not be merged";break;case gt.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case gt.not_finite:e="Number must be finite";break;default:e=t.defaultError,de.assertNever(n)}return{message:e}};let O_=Gc;function Y8(n){O_=n}function Bd(){return O_}const Pd=n=>{const{data:t,path:e,errorMaps:r,issueData:i}=n,s=[...e,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const u=r.filter(f=>!!f).slice().reverse();for(const f of u)a=f(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},J8=[];function At(n,t){const e=Bd(),r=Pd({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Gc?void 0:Gc].filter(i=>!!i)});n.common.issues.push(r)}class tr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const i of e){if(i.status==="aborted")return Vt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const i of e){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return tr.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const i of e){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Vt;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Vt=Object.freeze({status:"aborted"}),Vc=n=>({status:"dirty",value:n}),fr=n=>({status:"valid",value:n}),Tg=n=>n.status==="aborted",Og=n=>n.status==="dirty",pa=n=>n.status==="valid",nf=n=>typeof Promise<"u"&&n instanceof Promise;function Md(n,t,e,r){if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(n)}function N_(n,t,e,r,i){if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,e),e}typeof SuppressedError=="function"&&SuppressedError;var Bt;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Bt||(Bt={}));var rf,sf;class Li{constructor(t,e,r,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const C_=(n,t)=>{if(pa(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new Lr(n.common.issues);return this._error=e,this._error}}};function Qt(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:i}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{var u,f;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??a.defaultError}:typeof a.data>"u"?{message:(u=h??r)!==null&&u!==void 0?u:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(f=h??e)!==null&&f!==void 0?f:a.defaultError}},description:i}}class Jt{get description(){return this._def.description}_getType(t){return ws(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:ws(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new tr,ctx:{common:t.parent.common,data:t.data,parsedType:ws(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(nf(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;const i={common:{issues:[],async:(r=e==null?void 0:e.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ws(t)},s=this._parseSync({data:t,path:i.path,parent:i});return C_(i,s)}"~validate"(t){var e,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ws(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:i});return pa(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((r=(e=s==null?void 0:s.message)===null||e===void 0?void 0:e.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>pa(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ws(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(nf(i)?i:Promise.resolve(i));return C_(r,s)}refine(t,e){const r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:gt.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,e){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(t){return new mi({schema:this,typeName:zt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Di.create(this,this._def)}nullable(){return fo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return yi.create(this)}promise(){return Zc.create(this,this._def)}or(t){return uf.create([this,t],this._def)}and(t){return lf.create(this,t,this._def)}transform(t){return new mi({...Qt(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new gf({...Qt(this._def),innerType:this,defaultValue:e,typeName:zt.ZodDefault})}brand(){return new Bg({typeName:zt.ZodBranded,type:this,...Qt(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new yf({...Qt(this._def),innerType:this,catchValue:e,typeName:zt.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return mf.create(this,t)}readonly(){return wf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const X8=/^c[^\s-]{8,}$/i,t5=/^[0-9a-z]+$/,e5=/^[0-9A-HJKMNP-TV-Z]{26}$/i,n5=/^[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,r5=/^[a-z0-9_-]{21}$/i,i5=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,s5=/^[-+]?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)?)??$/,o5=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,a5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ng;const c5=/^(?:(?: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])$/,u5=/^(?:(?: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])$/,l5=/^(([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]))$/,f5=/^(([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])$/,h5=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,d5=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,B_="((\\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])))",p5=new RegExp(`^${B_}$`);function P_(n){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`),t}function g5(n){return new RegExp(`^${P_(n)}$`)}function M_(n){let t=`${B_}T${P_(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function y5(n,t){return!!((t==="v4"||!t)&&c5.test(n)||(t==="v6"||!t)&&l5.test(n))}function m5(n,t){if(!i5.test(n))return!1;try{const[e]=n.split("."),r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function w5(n,t){return!!((t==="v4"||!t)&&u5.test(n)||(t==="v6"||!t)&&f5.test(n))}class gi extends Jt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==It.string){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:It.string,received:s.parsedType}),Vt}const r=new tr;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")o5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"email",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ng||(Ng=new RegExp(a5,"u")),Ng.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"emoji",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")n5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"uuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")r5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"nanoid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")X8.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")t5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid2",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")e5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ulid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),At(i,{validation:"url",code:gt.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"regex",code:gt.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?M_(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?p5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?g5(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?s5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"duration",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?y5(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ip",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?m5(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"jwt",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?w5(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cidr",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?h5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?d5.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64url",code:gt.invalid_string,message:s.message}),r.dirty()):de.assertNever(s);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(i=>t.test(i),{validation:e,code:gt.invalid_string,...Bt.errToObj(r)})}_addCheck(t){return new gi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Bt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Bt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Bt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Bt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Bt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Bt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Bt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Bt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Bt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Bt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Bt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Bt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Bt.errToObj(t)})}datetime(t){var e,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(e=t==null?void 0:t.offset)!==null&&e!==void 0?e:!1,local:(r=t==null?void 0:t.local)!==null&&r!==void 0?r:!1,...Bt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Bt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Bt.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Bt.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Bt.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Bt.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Bt.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Bt.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Bt.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Bt.errToObj(e)})}nonempty(t){return this.min(1,Bt.errToObj(t))}trim(){return new gi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new gi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new gi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}gi.create=n=>{var t;return new gi({checks:[],typeName:zt.ZodString,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Qt(n)})};function b5(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=e>r?e:r,s=parseInt(n.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class co extends Jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==It.number){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:It.number,received:s.parsedType}),Vt}let r;const i=new tr;for(const s of this._def.checks)s.kind==="int"?de.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?b5(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_finite,message:s.message}),i.dirty()):de.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new co({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new co({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Bt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Bt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Bt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Bt.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&de.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}co.create=n=>new co({checks:[],typeName:zt.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Qt(n)});class uo extends Jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==It.bigint)return this._getInvalidInput(t);let r;const i=new tr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):de.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:It.bigint,received:e.parsedType}),Vt}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new uo({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new uo({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}uo.create=n=>{var t;return new uo({checks:[],typeName:zt.ZodBigInt,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Qt(n)})};class of extends Jt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==It.boolean){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.boolean,received:r.parsedType}),Vt}return fr(t.data)}}of.create=n=>new of({typeName:zt.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Qt(n)});class ga extends Jt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==It.date){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:It.date,received:s.parsedType}),Vt}if(isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_date}),Vt}const r=new tr;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):de.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ga({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Bt.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Bt.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}ga.create=n=>new ga({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:zt.ZodDate,...Qt(n)});class Ld extends Jt{_parse(t){if(this._getType(t)!==It.symbol){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.symbol,received:r.parsedType}),Vt}return fr(t.data)}}Ld.create=n=>new Ld({typeName:zt.ZodSymbol,...Qt(n)});class af extends Jt{_parse(t){if(this._getType(t)!==It.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.undefined,received:r.parsedType}),Vt}return fr(t.data)}}af.create=n=>new af({typeName:zt.ZodUndefined,...Qt(n)});class cf extends Jt{_parse(t){if(this._getType(t)!==It.null){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.null,received:r.parsedType}),Vt}return fr(t.data)}}cf.create=n=>new cf({typeName:zt.ZodNull,...Qt(n)});class Kc extends Jt{constructor(){super(...arguments),this._any=!0}_parse(t){return fr(t.data)}}Kc.create=n=>new Kc({typeName:zt.ZodAny,...Qt(n)});class ya extends Jt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fr(t.data)}}ya.create=n=>new ya({typeName:zt.ZodUnknown,...Qt(n)});class bs extends Jt{_parse(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:It.never,received:e.parsedType}),Vt}}bs.create=n=>new bs({typeName:zt.ZodNever,...Qt(n)});class Ud extends Jt{_parse(t){if(this._getType(t)!==It.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.void,received:r.parsedType}),Vt}return fr(t.data)}}Ud.create=n=>new Ud({typeName:zt.ZodVoid,...Qt(n)});class yi extends Jt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),i=this._def;if(e.parsedType!==It.array)return At(e,{code:gt.invalid_type,expected:It.array,received:e.parsedType}),Vt;if(i.exactLength!==null){const o=e.data.length>i.exactLength.value,a=e.data.length<i.exactLength.value;(o||a)&&(At(e,{code:o?gt.too_big:gt.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}),r.dirty())}if(i.minLength!==null&&e.data.length<i.minLength.value&&(At(e,{code:gt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&e.data.length>i.maxLength.value&&(At(e,{code:gt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,a)=>i.type._parseAsync(new Li(e,o,e.path,a)))).then(o=>tr.mergeArray(r,o));const s=[...e.data].map((o,a)=>i.type._parseSync(new Li(e,o,e.path,a)));return tr.mergeArray(r,s)}get element(){return this._def.type}min(t,e){return new yi({...this._def,minLength:{value:t,message:Bt.toString(e)}})}max(t,e){return new yi({...this._def,maxLength:{value:t,message:Bt.toString(e)}})}length(t,e){return new yi({...this._def,exactLength:{value:t,message:Bt.toString(e)}})}nonempty(t){return this.min(1,t)}}yi.create=(n,t)=>new yi({type:n,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Qt(t)});function jc(n){if(n instanceof Xe){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Di.create(jc(r))}return new Xe({...n._def,shape:()=>t})}else return n instanceof yi?new yi({...n._def,type:jc(n.element)}):n instanceof Di?Di.create(jc(n.unwrap())):n instanceof fo?fo.create(jc(n.unwrap())):n instanceof Ui?Ui.create(n.items.map(t=>jc(t))):n}class Xe extends Jt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=de.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==It.object){const f=this._getOrReturnCtx(t);return At(f,{code:gt.invalid_type,expected:It.object,received:f.parsedType}),Vt}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof bs&&this._def.unknownKeys==="strip"))for(const f in i.data)o.includes(f)||a.push(f);const u=[];for(const f of o){const h=s[f],y=i.data[f];u.push({key:{status:"valid",value:f},value:h._parse(new Li(i,y,i.path,f)),alwaysSet:f in i.data})}if(this._def.catchall instanceof bs){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of a)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(f==="strict")a.length>0&&(At(i,{code:gt.unrecognized_keys,keys:a}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of a){const y=i.data[h];u.push({key:{status:"valid",value:h},value:f._parse(new Li(i,y,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of u){const y=await h.key,_=await h.value;f.push({key:y,value:_,alwaysSet:h.alwaysSet})}return f}).then(f=>tr.mergeObjectSync(r,f)):tr.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Bt.errToObj,new Xe({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var i,s,o,a;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(a=Bt.errToObj(t).message)!==null&&a!==void 0?a:u}:{message:u}}}:{}})}strip(){return new Xe({...this._def,unknownKeys:"strip"})}passthrough(){return new Xe({...this._def,unknownKeys:"passthrough"})}extend(t){return new Xe({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Xe({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Xe({...this._def,catchall:t})}pick(t){const e={};return de.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new Xe({...this._def,shape:()=>e})}omit(t){const e={};return de.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new Xe({...this._def,shape:()=>e})}deepPartial(){return jc(this)}partial(t){const e={};return de.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?e[r]=i:e[r]=i.optional()}),new Xe({...this._def,shape:()=>e})}required(t){const e={};return de.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Di;)s=s._def.innerType;e[r]=s}}),new Xe({...this._def,shape:()=>e})}keyof(){return L_(de.objectKeys(this.shape))}}Xe.create=(n,t)=>new Xe({shape:()=>n,unknownKeys:"strip",catchall:bs.create(),typeName:zt.ZodObject,...Qt(t)}),Xe.strictCreate=(n,t)=>new Xe({shape:()=>n,unknownKeys:"strict",catchall:bs.create(),typeName:zt.ZodObject,...Qt(t)}),Xe.lazycreate=(n,t)=>new Xe({shape:n,unknownKeys:"strip",catchall:bs.create(),typeName:zt.ZodObject,...Qt(t)});class uf extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r=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 e.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Lr(a.ctx.common.issues));return At(e,{code:gt.invalid_union,unionErrors:o}),Vt}if(e.common.async)return Promise.all(r.map(async s=>{const o={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of r){const f={...e,common:{...e.common,issues:[]},parent:null},h=u._parseSync({data:e.data,path:e.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(u=>new Lr(u));return At(e,{code:gt.invalid_union,unionErrors:a}),Vt}}get options(){return this._def.options}}uf.create=(n,t)=>new uf({options:n,typeName:zt.ZodUnion,...Qt(t)});const _s=n=>n instanceof hf?_s(n.schema):n instanceof mi?_s(n.innerType()):n instanceof df?[n.value]:n instanceof lo?n.options:n instanceof pf?de.objectValues(n.enum):n instanceof gf?_s(n._def.innerType):n instanceof af?[void 0]:n instanceof cf?[null]:n instanceof Di?[void 0,..._s(n.unwrap())]:n instanceof fo?[null,..._s(n.unwrap())]:n instanceof Bg||n instanceof wf?_s(n.unwrap()):n instanceof yf?_s(n._def.innerType):[];class Dd extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==It.object)return At(e,{code:gt.invalid_type,expected:It.object,received:e.parsedType}),Vt;const r=this.discriminator,i=e.data[r],s=this.optionsMap.get(i);return s?e.common.async?s._parseAsync({data:e.data,path:e.path,parent:e}):s._parseSync({data:e.data,path:e.path,parent:e}):(At(e,{code:gt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){const i=new Map;for(const s of e){const o=_s(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Dd({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:i,...Qt(r)})}}function Cg(n,t){const e=ws(n),r=ws(t);if(n===t)return{valid:!0,data:n};if(e===It.object&&r===It.object){const i=de.objectKeys(t),s=de.objectKeys(n).filter(a=>i.indexOf(a)!==-1),o={...n,...t};for(const a of s){const u=Cg(n[a],t[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(e===It.array&&r===It.array){if(n.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<n.length;s++){const o=n[s],a=t[s],u=Cg(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return e===It.date&&r===It.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class lf extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(Tg(s)||Tg(o))return Vt;const a=Cg(s.value,o.value);return a.valid?((Og(s)||Og(o))&&e.dirty(),{status:e.value,value:a.data}):(At(r,{code:gt.invalid_intersection_types}),Vt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}lf.create=(n,t,e)=>new lf({left:n,right:t,typeName:zt.ZodIntersection,...Qt(e)});class Ui extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==It.array)return At(r,{code:gt.invalid_type,expected:It.array,received:r.parsedType}),Vt;if(r.data.length<this._def.items.length)return At(r,{code:gt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Vt;!this._def.rest&&r.data.length>this._def.items.length&&(At(r,{code:gt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const s=[...r.data].map((o,a)=>{const u=this._def.items[a]||this._def.rest;return u?u._parse(new Li(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>tr.mergeArray(e,o)):tr.mergeArray(e,s)}get items(){return this._def.items}rest(t){return new Ui({...this._def,rest:t})}}Ui.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ui({items:n,typeName:zt.ZodTuple,rest:null,...Qt(t)})};class ff extends Jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==It.object)return At(r,{code:gt.invalid_type,expected:It.object,received:r.parsedType}),Vt;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new Li(r,a,r.path,a)),value:o._parse(new Li(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?tr.mergeObjectAsync(e,i):tr.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof Jt?new ff({keyType:t,valueType:e,typeName:zt.ZodRecord,...Qt(r)}):new ff({keyType:gi.create(),valueType:t,typeName:zt.ZodRecord,...Qt(e)})}}class Fd extends Jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==It.map)return At(r,{code:gt.invalid_type,expected:It.map,received:r.parsedType}),Vt;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,u],f)=>({key:i._parse(new Li(r,a,r.path,[f,"key"])),value:s._parse(new Li(r,u,r.path,[f,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const u of o){const f=await u.key,h=await u.value;if(f.status==="aborted"||h.status==="aborted")return Vt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),a.set(f.value,h.value)}return{status:e.value,value:a}})}else{const a=new Map;for(const u of o){const f=u.key,h=u.value;if(f.status==="aborted"||h.status==="aborted")return Vt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),a.set(f.value,h.value)}return{status:e.value,value:a}}}}Fd.create=(n,t,e)=>new Fd({valueType:t,keyType:n,typeName:zt.ZodMap,...Qt(e)});class ma extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==It.set)return At(r,{code:gt.invalid_type,expected:It.set,received:r.parsedType}),Vt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(At(r,{code:gt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(At(r,{code:gt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());const s=this._def.valueType;function o(u){const f=new Set;for(const h of u){if(h.status==="aborted")return Vt;h.status==="dirty"&&e.dirty(),f.add(h.value)}return{status:e.value,value:f}}const a=[...r.data.values()].map((u,f)=>s._parse(new Li(r,u,r.path,f)));return r.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(t,e){return new ma({...this._def,minSize:{value:t,message:Bt.toString(e)}})}max(t,e){return new ma({...this._def,maxSize:{value:t,message:Bt.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}ma.create=(n,t)=>new ma({valueType:n,minSize:null,maxSize:null,typeName:zt.ZodSet,...Qt(t)});class Wc extends Jt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==It.function)return At(e,{code:gt.invalid_type,expected:It.function,received:e.parsedType}),Vt;function r(a,u){return Pd({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Bd(),Gc].filter(f=>!!f),issueData:{code:gt.invalid_arguments,argumentsError:u}})}function i(a,u){return Pd({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Bd(),Gc].filter(f=>!!f),issueData:{code:gt.invalid_return_type,returnTypeError:u}})}const s={errorMap:e.common.contextualErrorMap},o=e.data;if(this._def.returns instanceof Zc){const a=this;return fr(async function(...u){const f=new Lr([]),h=await a._def.args.parseAsync(u,s).catch(w=>{throw f.addIssue(r(u,w)),f}),y=await Reflect.apply(o,this,h);return await a._def.returns._def.type.parseAsync(y,s).catch(w=>{throw f.addIssue(i(y,w)),f})})}else{const a=this;return fr(function(...u){const f=a._def.args.safeParse(u,s);if(!f.success)throw new Lr([r(u,f.error)]);const h=Reflect.apply(o,this,f.data),y=a._def.returns.safeParse(h,s);if(!y.success)throw new Lr([i(h,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Wc({...this._def,args:Ui.create(t).rest(ya.create())})}returns(t){return new Wc({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new Wc({args:t||Ui.create([]).rest(ya.create()),returns:e||ya.create(),typeName:zt.ZodFunction,...Qt(r)})}}class hf extends Jt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}hf.create=(n,t)=>new hf({getter:n,typeName:zt.ZodLazy,...Qt(t)});class df extends Jt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return At(e,{received:e.data,code:gt.invalid_literal,expected:this._def.value}),Vt}return{status:"valid",value:t.data}}get value(){return this._def.value}}df.create=(n,t)=>new df({value:n,typeName:zt.ZodLiteral,...Qt(t)});function L_(n,t){return new lo({values:n,typeName:zt.ZodEnum,...Qt(t)})}class lo extends Jt{constructor(){super(...arguments),rf.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{expected:de.joinValues(r),received:e.parsedType,code:gt.invalid_type}),Vt}if(Md(this,rf)||N_(this,rf,new Set(this._def.values)),!Md(this,rf).has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{received:e.data,code:gt.invalid_enum_value,options:r}),Vt}return fr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return lo.create(t,{...this._def,...e})}exclude(t,e=this._def){return lo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}rf=new WeakMap,lo.create=L_;class pf extends Jt{constructor(){super(...arguments),sf.set(this,void 0)}_parse(t){const e=de.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==It.string&&r.parsedType!==It.number){const i=de.objectValues(e);return At(r,{expected:de.joinValues(i),received:r.parsedType,code:gt.invalid_type}),Vt}if(Md(this,sf)||N_(this,sf,new Set(de.getValidEnumValues(this._def.values))),!Md(this,sf).has(t.data)){const i=de.objectValues(e);return At(r,{received:r.data,code:gt.invalid_enum_value,options:i}),Vt}return fr(t.data)}get enum(){return this._def.values}}sf=new WeakMap,pf.create=(n,t)=>new pf({values:n,typeName:zt.ZodNativeEnum,...Qt(t)});class Zc extends Jt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==It.promise&&e.common.async===!1)return At(e,{code:gt.invalid_type,expected:It.promise,received:e.parsedType}),Vt;const r=e.parsedType===It.promise?e.data:Promise.resolve(e.data);return fr(r.then(i=>this._def.type.parseAsync(i,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Zc.create=(n,t)=>new Zc({type:n,typeName:zt.ZodPromise,...Qt(t)});class mi extends Jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{At(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(e.value==="aborted")return Vt;const u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?Vt:u.status==="dirty"||e.value==="dirty"?Vc(u.value):u});{if(e.value==="aborted")return Vt;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Vt:a.status==="dirty"||e.value==="dirty"?Vc(a.value):a}}if(i.type==="refinement"){const o=a=>{const u=i.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Vt:(a.status==="dirty"&&e.dirty(),o(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Vt:(a.status==="dirty"&&e.dirty(),o(a.value).then(()=>({status:e.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!pa(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:e.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>pa(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:e.value,value:a})):o);de.assertNever(i)}}mi.create=(n,t,e)=>new mi({schema:n,typeName:zt.ZodEffects,effect:t,...Qt(e)}),mi.createWithPreprocess=(n,t,e)=>new mi({schema:t,effect:{type:"preprocess",transform:n},typeName:zt.ZodEffects,...Qt(e)});class Di extends Jt{_parse(t){return this._getType(t)===It.undefined?fr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Di.create=(n,t)=>new Di({innerType:n,typeName:zt.ZodOptional,...Qt(t)});class fo extends Jt{_parse(t){return this._getType(t)===It.null?fr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}fo.create=(n,t)=>new fo({innerType:n,typeName:zt.ZodNullable,...Qt(t)});class gf extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===It.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}gf.create=(n,t)=>new gf({innerType:n,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Qt(t)});class yf extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return nf(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Lr(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Lr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}yf.create=(n,t)=>new yf({innerType:n,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Qt(t)});class $d extends Jt{_parse(t){if(this._getType(t)!==It.nan){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:It.nan,received:r.parsedType}),Vt}return{status:"valid",value:t.data}}}$d.create=n=>new $d({typeName:zt.ZodNaN,...Qt(n)});const _5=Symbol("zod_brand");class Bg extends Jt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class mf extends Jt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Vt:s.status==="dirty"?(e.dirty(),Vc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Vt:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,e){return new mf({in:t,out:e,typeName:zt.ZodPipeline})}}class wf extends Jt{_parse(t){const e=this._def.innerType._parse(t),r=i=>(pa(i)&&(i.value=Object.freeze(i.value)),i);return nf(e)?e.then(i=>r(i)):r(e)}unwrap(){return this._def.innerType}}wf.create=(n,t)=>new wf({innerType:n,typeName:zt.ZodReadonly,...Qt(t)});function U_(n,t={},e){return n?Kc.create().superRefine((r,i)=>{var s,o;if(!n(r)){const a=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(o=(s=a.fatal)!==null&&s!==void 0?s:e)!==null&&o!==void 0?o:!0,f=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...f,fatal:u})}}):Kc.create()}const A5={object:Xe.lazycreate};var zt;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(zt||(zt={}));const E5=(n,t={message:`Input not instance of ${n.name}`})=>U_(e=>e instanceof n,t),D_=gi.create,F_=co.create,v5=$d.create,x5=uo.create,$_=of.create,R5=ga.create,I5=Ld.create,S5=af.create,k5=cf.create,T5=Kc.create,O5=ya.create,N5=bs.create,C5=Ud.create,B5=yi.create,P5=Xe.create,M5=Xe.strictCreate,L5=uf.create,U5=Dd.create,D5=lf.create,F5=Ui.create,$5=ff.create,H5=Fd.create,z5=ma.create,G5=Wc.create,V5=hf.create,K5=df.create,j5=lo.create,W5=pf.create,Z5=Zc.create,H_=mi.create,q5=Di.create,Q5=fo.create,Y5=mi.createWithPreprocess,J5=mf.create;var ho=Object.freeze({__proto__:null,defaultErrorMap:Gc,setErrorMap:Y8,getErrorMap:Bd,makeIssue:Pd,EMPTY_PATH:J8,addIssueToContext:At,ParseStatus:tr,INVALID:Vt,DIRTY:Vc,OK:fr,isAborted:Tg,isDirty:Og,isValid:pa,isAsync:nf,get util(){return de},get objectUtil(){return kg},ZodParsedType:It,getParsedType:ws,ZodType:Jt,datetimeRegex:M_,ZodString:gi,ZodNumber:co,ZodBigInt:uo,ZodBoolean:of,ZodDate:ga,ZodSymbol:Ld,ZodUndefined:af,ZodNull:cf,ZodAny:Kc,ZodUnknown:ya,ZodNever:bs,ZodVoid:Ud,ZodArray:yi,ZodObject:Xe,ZodUnion:uf,ZodDiscriminatedUnion:Dd,ZodIntersection:lf,ZodTuple:Ui,ZodRecord:ff,ZodMap:Fd,ZodSet:ma,ZodFunction:Wc,ZodLazy:hf,ZodLiteral:df,ZodEnum:lo,ZodNativeEnum:pf,ZodPromise:Zc,ZodEffects:mi,ZodTransformer:mi,ZodOptional:Di,ZodNullable:fo,ZodDefault:gf,ZodCatch:yf,ZodNaN:$d,BRAND:_5,ZodBranded:Bg,ZodPipeline:mf,ZodReadonly:wf,custom:U_,Schema:Jt,ZodSchema:Jt,late:A5,get ZodFirstPartyTypeKind(){return zt},coerce:{string:n=>gi.create({...n,coerce:!0}),number:n=>co.create({...n,coerce:!0}),boolean:n=>of.create({...n,coerce:!0}),bigint:n=>uo.create({...n,coerce:!0}),date:n=>ga.create({...n,coerce:!0})},any:T5,array:B5,bigint:x5,boolean:$_,date:R5,discriminatedUnion:U5,effect:H_,enum:j5,function:G5,instanceof:E5,intersection:D5,lazy:V5,literal:K5,map:H5,nan:v5,nativeEnum:W5,never:N5,null:k5,nullable:Q5,number:F_,object:P5,oboolean:()=>$_().optional(),onumber:()=>F_().optional(),optional:q5,ostring:()=>D_().optional(),pipeline:J5,preprocess:Y5,promise:Z5,record:$5,set:z5,strictObject:M5,string:D_,symbol:I5,transformer:H_,tuple:F5,undefined:S5,union:L5,unknown:O5,void:C5,NEVER:Vt,ZodIssueCode:gt,quotelessJson:Q8,ZodError:Lr});const Pg=Mi.getInstance(),z_=ho.object({username:ho.string(),address:ho.string(),timestamp:ho.number(),index:ho.number(),signature:ho.string()}),X5=ho.object({topic:ho.string(),messageSender:z_});function tP(n){const t=X5.safeParse(n);return t.success?n.messageSender&&!eP(n.messageSender)?(console.warn("Invalid messageSender"),!1):!0:(Pg.warn(t.error.format()),!1)}function eP(n){const t=z_.safeParse(n);return t.success?nP(n):(Pg.warn(t.error.format()),!1)}function nP(n){try{const t={username:n.username,address:n.address,timestamp:n.timestamp},e=new TextEncoder,r=Xn.concatBytes(e.encode(`Ethereum Signed Message:
|
|
11
|
+
32`),Xn.keccak256(e.encode(JSON.stringify(t))));if(new xt.Signature(n.signature).isValid(r,n.address))throw new Error("Signature verification failed!");return!0}catch(t){return Pg.warn("Error in validateUserSignature",t),!1}}async function rP(n){const{condition:t,broadcast:e,maxRetries:r=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=n;return new Promise((a,u)=>{let f=0;const h=async()=>{await k_(i);for(let y=0;y<o;y++){if(await Promise.resolve(t()))return a();await k_(s)}if(++f>=r)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${f} of ${r}`),await e(),h()};console.log("Starting broadcast..."),e().then(()=>h()).catch(u)})}const Ur={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"},iP=1e3;class sP{constructor(t,e){this.utils=t,this.emitter=e,this.logger=Mi.getInstance(),this.errorHandler=new Sg,this.historyIndex=null}async init(){try{const t=await this.utils.fetchLatestChatMessage();this.historyIndex=t.index,await this.fetchPreviousMessages()}catch(t){this.errorHandler.handleError(t,"SwarmHistory.init")}}async fetchPreviousMessages(t=10){try{if(!this.historyIndex){this.logger.warn("History index is not set. Cannot fetch previous messages.");return}if(this.historyIndex.toBigInt()===0n){this.logger.warn("No previous messages to fetch.");return}const e=this.historyIndex.toBigInt(),r=e>BigInt(t)?e-BigInt(t):0n;for(let i=e-1n;i>=r;i--){const s=await this.utils.fetchChatMessage(xt.FeedIndex.fromBigInt(i));if(this.emitter.emit(Ur.MESSAGE_RECEIVED,s),this.historyIndex=xt.FeedIndex.fromBigInt(i),i===0n)break}}catch(e){this.errorHandler.handleError(e,"SwarmHistory.fetchPreviousMessages")}}}const qc=globalThis||void 0||self;var Mg={},Hd={};Hd.byteLength=cP,Hd.toByteArray=lP,Hd.fromByteArray=dP;for(var Fi=[],Yr=[],oP=typeof Uint8Array<"u"?Uint8Array:Array,Lg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qc=0,aP=Lg.length;Qc<aP;++Qc)Fi[Qc]=Lg[Qc],Yr[Lg.charCodeAt(Qc)]=Qc;Yr[45]=62,Yr[95]=63;function G_(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function cP(n){var t=G_(n),e=t[0],r=t[1];return(e+r)*3/4-r}function uP(n,t,e){return(t+e)*3/4-e}function lP(n){var t,e=G_(n),r=e[0],i=e[1],s=new oP(uP(n,r,i)),o=0,a=i>0?r-4:r,u;for(u=0;u<a;u+=4)t=Yr[n.charCodeAt(u)]<<18|Yr[n.charCodeAt(u+1)]<<12|Yr[n.charCodeAt(u+2)]<<6|Yr[n.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=Yr[n.charCodeAt(u)]<<2|Yr[n.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=Yr[n.charCodeAt(u)]<<10|Yr[n.charCodeAt(u+1)]<<4|Yr[n.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function fP(n){return Fi[n>>18&63]+Fi[n>>12&63]+Fi[n>>6&63]+Fi[n&63]}function hP(n,t,e){for(var r,i=[],s=t;s<e;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(fP(r));return i.join("")}function dP(n){for(var t,e=n.length,r=e%3,i=[],s=16383,o=0,a=e-r;o<a;o+=s)i.push(hP(n,o,o+s>a?a:o+s));return r===1?(t=n[e-1],i.push(Fi[t>>2]+Fi[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(Fi[t>>10]+Fi[t>>4&63]+Fi[t<<2&63]+"=")),i.join("")}var Ug={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Ug.read=function(n,t,e,r,i){var s,o,a=i*8-r-1,u=(1<<a)-1,f=u>>1,h=-7,y=e?i-1:0,_=e?-1:1,w=n[t+y];for(y+=_,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+n[t+y],y+=_,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=o*256+n[t+y],y+=_,h-=8);if(s===0)s=1-f;else{if(s===u)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-f}return(w?-1:1)*o*Math.pow(2,s-r)},Ug.write=function(n,t,e,r,i,s){var o,a,u,f=s*8-i-1,h=(1<<f)-1,y=h>>1,_=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=r?0:s-1,R=r?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+y>=1?t+=_/u:t+=_*Math.pow(2,1-y),t*u>=2&&(o++,u/=2),o+y>=h?(a=0,o=h):o+y>=1?(a=(t*u-1)*Math.pow(2,i),o=o+y):(a=t*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;n[e+w]=a&255,w+=R,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;n[e+w]=o&255,w+=R,o/=256,f-=8);n[e+w-R]|=T*128};/*!
|
|
14
12
|
* The buffer module from node.js, for the browser.
|
|
15
13
|
*
|
|
16
14
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
17
15
|
* @license MIT
|
|
18
|
-
*/(function(r){const e=t0,t=Yy,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 K=D(N);if(K)return K;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 K=$.write(N,_);return K!==v&&($=$.slice(0,K)),$}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,K=v.length;for(let Y=0,ae=Math.min($,K);Y<ae;++Y)if(_[Y]!==v[Y]){$=_[Y],K=v[Y];break}return $<K?-1:K<$?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 K=h.allocUnsafe(v);let Y=0;for($=0;$<_.length;++$){let ae=_[$];if(or(ae,s))Y+ae.length>K.length?(h.isBuffer(ae)||(ae=h.from(ae)),ae.copy(K,Y)):s.prototype.set.call(K,ae,Y);else if(h.isBuffer(ae))ae.copy(K,Y);else throw new TypeError('"list" argument must be an Array of Buffers');Y+=ae.length}return K};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 K=!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(K)return $?-1:It(N).length;_=(""+_).toLowerCase(),K=!0}}h.byteLength=Z;function j(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 V(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)V(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)V(this,v,v+3),V(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)V(this,v,v+7),V(this,v+1,v+6),V(this,v+2,v+5),V(this,v+3,v+4);return this},h.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?k(this,0,_):j.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,$,K,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),K===void 0&&(K=0),Y===void 0&&(Y=this.length),v<0||$>_.length||K<0||Y>this.length)throw new RangeError("out of range index");if(K>=Y&&v>=$)return 0;if(K>=Y)return-1;if(v>=$)return 1;if(v>>>=0,$>>>=0,K>>>=0,Y>>>=0,this===_)return 0;let ae=Y-K,Ye=$-v;const qe=Math.min(ae,Ye),We=this.slice(K,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,$,K){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=K?0:N.length-1),v<0&&(v=N.length+v),v>=N.length){if(K)return-1;v=N.length-1}else if(v<0)if(K)v=0;else return-1;if(typeof _=="string"&&(_=h.from(_,$)),h.isBuffer(_))return _.length===0?-1:ce(N,_,v,$,K);if(typeof _=="number")return _=_&255,typeof s.prototype.indexOf=="function"?K?s.prototype.indexOf.call(N,_,v):s.prototype.lastIndexOf.call(N,_,v):ce(N,[_],v,$,K);throw new TypeError("val must be string, number or Buffer")}function ce(N,_,v,$,K){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(K){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 K=N.length-v;$?($=Number($),$>K&&($=K)):$=K;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,$,K){if(v===void 0)K="utf8",$=this.length,v=0;else if($===void 0&&typeof v=="string")K=v,$=this.length,v=0;else if(isFinite(v))v=v>>>0,isFinite($)?($=$>>>0,K===void 0&&(K="utf8")):(K=$,$=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");K||(K="utf8");let ae=!1;for(;;)switch(K){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: "+K);K=(""+K).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 K=_;for(;K<v;){const Y=N[K];let ae=null,Ye=Y>239?4:Y>223?3:Y>191?2:1;if(K+Ye<=v){let qe,We,$t,Ge;switch(Ye){case 1:Y<128&&(ae=Y);break;case 2:qe=N[K+1],(qe&192)===128&&(Ge=(Y&31)<<6|qe&63,Ge>127&&(ae=Ge));break;case 3:qe=N[K+1],We=N[K+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[K+1],We=N[K+2],$t=N[K+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),K+=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 K=_;K<v;++K)$+=String.fromCharCode(N[K]&127);return $}function P(N,_,v){let $="";v=Math.min(N.length,v);for(let K=_;K<v;++K)$+=String.fromCharCode(N[K]);return $}function A(N,_,v){const $=N.length;(!_||_<0)&&(_=0),(!v||v<0||v>$)&&(v=$);let K="";for(let Y=_;Y<v;++Y)K+=Bt[N[Y]];return K}function U(N,_,v){const $=N.slice(_,v);let K="";for(let Y=0;Y<$.length-1;Y+=2)K+=String.fromCharCode($[Y]+$[Y+1]*256);return K}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 K=this.subarray(_,v);return Object.setPrototypeOf(K,h.prototype),K};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 K=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)K+=this[_+ae]*Y;return K},h.prototype.readUintBE=h.prototype.readUIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=this[_+--v],Y=1;for(;v>0&&(Y*=256);)K+=this[_+--v]*Y;return K},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 K=v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,Y=this[++_]+this[++_]*2**8+this[++_]*2**16+$*2**24;return BigInt(K)+(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 K=v*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],Y=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$;return(BigInt(K)<<BigInt(32))+BigInt(Y)}),h.prototype.readIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=this[_],Y=1,ae=0;for(;++ae<v&&(Y*=256);)K+=this[_+ae]*Y;return Y*=128,K>=Y&&(K-=Math.pow(2,8*v)),K},h.prototype.readIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let K=v,Y=1,ae=this[_+--K];for(;K>0&&(Y*=256);)ae+=this[_+--K]*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 K=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+($<<24);return(BigInt(K)<<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 K=(v<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(K)<<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,$,K,Y){if(!h.isBuffer(N))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>K||_<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,$,K){if(_=+_,v=v>>>0,$=$>>>0,!K){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,$,K){if(_=+_,v=v>>>0,$=$>>>0,!K){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,$,K){ot(_,$,K,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,$,K){ot(_,$,K,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,$,K){if(_=+_,v=v>>>0,!K){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,$,K){if(_=+_,v=v>>>0,!K){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,$,K,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,$,K){return _=+_,v=v>>>0,K||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 Ve(N,_,v,$,K){return _=+_,v=v>>>0,K||ye(N,_,v,8),t.write(N,_,v,$,52,8),v+8}h.prototype.writeDoubleLE=function(_,v,$){return Ve(this,_,v,!0,$)},h.prototype.writeDoubleBE=function(_,v,$){return Ve(this,_,v,!1,$)},h.prototype.copy=function(_,v,$,K){if(!h.isBuffer(_))throw new TypeError("argument should be a Buffer");if($||($=0),!K&&K!==0&&(K=this.length),v>=_.length&&(v=_.length),v||(v=0),K>0&&K<$&&(K=$),K===$||_.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(K<0)throw new RangeError("sourceEnd out of bounds");K>this.length&&(K=this.length),_.length-v<K-$&&(K=_.length-v+$);const Y=K-$;return this===_&&typeof s.prototype.copyWithin=="function"?this.copyWithin(v,$,K):s.prototype.set.call(_,this.subarray($,K),v),Y},h.prototype.fill=function(_,v,$,K){if(typeof _=="string"){if(typeof v=="string"?(K=v,v=0,$=this.length):typeof $=="string"&&(K=$,$=this.length),K!==void 0&&typeof K!="string")throw new TypeError("encoding must be a string");if(typeof K=="string"&&!h.isEncoding(K))throw new TypeError("Unknown encoding: "+K);if(_.length===1){const ae=_.charCodeAt(0);(K==="utf8"&&ae<128||K==="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(_,K),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(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,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.`,K=v;return Number.isInteger(v)&&Math.abs(v)>2**32?K=et(String(v)):typeof v=="bigint"&&(K=String(v),(v>BigInt(2)**BigInt(32)||v<-(BigInt(2)**BigInt(32)))&&(K=et(K)),K+="n"),$+=` It must be ${_}. Received ${K}`,$},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,$,K,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($,K,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 K=null;const Y=[];for(let ae=0;ae<$;++ae){if(v=N.charCodeAt(ae),v>55295&&v<57344){if(!K){if(v>56319){(_-=3)>-1&&Y.push(239,191,189);continue}else if(ae+1===$){(_-=3)>-1&&Y.push(239,191,189);continue}K=v;continue}if(v<56320){(_-=3)>-1&&Y.push(239,191,189),K=v;continue}v=(K-55296<<10|v-56320)+65536}else K&&(_-=3)>-1&&Y.push(239,191,189);if(K=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,$,K;const Y=[];for(let ae=0;ae<N.length&&!((_-=2)<0);++ae)v=N.charCodeAt(ae),$=v>>8,K=v%256,Y.push(K),Y.push($);return Y}function pt(N){return e.toByteArray(oa(N))}function St(N,_,v,$){let K;for(K=0;K<$&&!(K+v>=_.length||K>=N.length);++K)_[K+v]=N[K];return K}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 K=0;K<16;++K)_[$+K]=N[v]+N[K]}return _}();function fn(N){return typeof BigInt>"u"?Dt:N}function Dt(){throw new Error("BigInt not supported")}})(Zy);const Ze=Zy.Buffer,Ne=Zy.Buffer,IG=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Ne,default:Ze},Symbol.toStringTag,{value:"Module"}));var Jy={exports:{}};const Xy=Lc(IG);Jy.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=Xy.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,Ve=k[2]|0,Fe=Ve&8191,Be=Ve>>>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,K=O[0]|0,Y=K&8191,ae=K>>>13,Ye=O[1]|0,qe=Ye&8191,We=Ye>>>13,$t=O[2]|0,Ge=$t&8191,fr=$t>>>13,rg=O[3]|0,hr=rg&8191,dr=rg>>>13,ng=O[4]|0,ar=ng&8191,pr=ng>>>13,ig=O[5]|0,cr=ig&8191,gr=ig>>>13,Nc=O[6]|0,Xt=Nc&8191,yr=Nc>>>13,sg=O[7]|0,mr=sg&8191,wr=sg>>>13,og=O[8]|0,br=og&8191,_r=og>>>13,Cc=O[9]|0,Ar=Cc&8191,vr=Cc>>>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 Wh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Wh>>>26)|0,Wh&=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 $l=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+($l>>>26)|0,$l&=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 qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(qh>>>26)|0,qh&=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 Zh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Zh>>>26)|0,Zh&=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 Qh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Qh>>>26)|0,Qh&=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 Yh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Yh>>>26)|0,Yh&=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,Xt)|0,A=A+Math.imul(te,yr)|0,A=A+Math.imul(re,Xt)|0,U=U+Math.imul(re,yr)|0;var Fl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Fl>>>26)|0,Fl&=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,Xt)|0,A=A+Math.imul(ye,yr)|0,A=A+Math.imul(be,Xt)|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 Jh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Jh>>>26)|0,Jh&=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,Xt)|0,A=A+Math.imul(Fe,yr)|0,A=A+Math.imul(Be,Xt)|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,Xt)|0,A=A+Math.imul(Qe,yr)|0,A=A+Math.imul(ot,Xt)|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 Xh=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Xh>>>26)|0,Xh&=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,Xt)|0,A=A+Math.imul(dt,yr)|0,A=A+Math.imul(Ut,Xt)|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,Xt)|0,A=A+Math.imul(It,yr)|0,A=A+Math.imul(Ct,Xt)|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 ed=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ed>>>26)|0,ed&=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,Xt)|0,A=A+Math.imul(pt,yr)|0,A=A+Math.imul(St,Xt)|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 td=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(td>>>26)|0,td&=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,Xt)|0,A=A+Math.imul(xt,yr)|0,A=A+Math.imul(Bt,Xt)|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 Hl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Hl>>>26)|0,Hl&=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,Xt)|0,A=A+Math.imul(Dt,yr)|0,A=A+Math.imul(N,Xt)|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 rd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(rd>>>26)|0,rd&=67108863,P=Math.imul(v,Xt),A=Math.imul(v,yr),A=A+Math.imul($,Xt)|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 nd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(nd>>>26)|0,nd&=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 id=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(id>>>26)|0,id&=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 sd=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(sd>>>26)|0,sd&=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]=Wh,M[1]=$l,M[2]=qh,M[3]=Zh,M[4]=Qh,M[5]=Yh,M[6]=Fl,M[7]=Jh,M[8]=so,M[9]=Xh,M[10]=Li,M[11]=ed,M[12]=td,M[13]=Hl,M[14]=rd,M[15]=nd,M[16]=id,M[17]=sd,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 j(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,Z),j.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},j.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 V(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(V,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 j;else if(p==="p224")m=new V;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)}(Jy);var em=Jy.exports;const vs=xn(em);function r0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function SG(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ef(r,...e){if(!SG(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 kG(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");r0(r.outputLen),r0(r.blockLen)}function Yc(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 r2(r,e){Ef(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Jc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function TG(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function tm(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function zi(r,e){return r<<32-e|r>>>e}const n2=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function OG(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function i2(r){for(let e=0;e<r.length;e++)r[e]=OG(r[e])}function NG(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function n0(r){return typeof r=="string"&&(r=NG(r)),Ef(r),r}function CG(...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}let rm=class{clone(){return this._cloneInto()}};function nm(r){const e=n=>r().update(n0(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function s2(r=32){if(Jc&&typeof Jc.getRandomValues=="function")return Jc.getRandomValues(new Uint8Array(r));if(Jc&&typeof Jc.randomBytes=="function")return Jc.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function BG(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 PG(r,e,t){return r&e^~r&t}function MG(r,e,t){return r&e^r&t^e&t}class o2 extends rm{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=tm(this.buffer)}update(e){Yc(this);const{view:t,buffer:n,blockLen:i}=this;e=n0(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=tm(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){Yc(this),r2(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;BG(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=tm(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 i0=BigInt(2**32-1),im=BigInt(32);function a2(r,e=!1){return e?{h:Number(r&i0),l:Number(r>>im&i0)}:{h:Number(r>>im&i0)|0,l:Number(r&i0)|0}}function c2(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}=a2(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const LG=(r,e)=>BigInt(r>>>0)<<im|BigInt(e>>>0),UG=(r,e,t)=>r>>>t,DG=(r,e,t)=>r<<32-t|e>>>t,$G=(r,e,t)=>r>>>t|e<<32-t,FG=(r,e,t)=>r<<32-t|e>>>t,HG=(r,e,t)=>r<<64-t|e>>>t-32,zG=(r,e,t)=>r>>>t-32|e<<64-t,GG=(r,e)=>e,jG=(r,e)=>r,u2=(r,e,t)=>r<<t|e>>>32-t,l2=(r,e,t)=>e<<t|r>>>32-t,f2=(r,e,t)=>e<<t-32|r>>>64-t,h2=(r,e,t)=>r<<t-32|e>>>64-t;function KG(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:a2,split:c2,toBig:LG,shrSH:UG,shrSL:DG,rotrSH:$G,rotrSL:FG,rotrBH:HG,rotrBL:zG,rotr32H:GG,rotr32L:jG,rotlSH:u2,rotlSL:l2,rotlBH:f2,rotlBL:h2,add:KG,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)},[VG,WG]=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 qG=class extends o2{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),j=rt.rotrSL(z,W,1)^rt.rotrSL(z,W,8)^rt.shrSL(z,W,7),V=fo[D-2]|0,oe=ho[D-2]|0,ce=rt.rotrSH(V,oe,19)^rt.rotrBH(V,oe,61)^rt.shrSH(V,oe,6),ie=rt.rotrSL(V,oe,19)^rt.rotrBL(V,oe,61)^rt.shrSL(V,oe,6),ue=rt.add4L(j,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,j=b&I^~b&x,V=rt.add5L(H,W,j,WG[D],ho[D]),oe=rt.add5H(V,C,z,Z,VG[D],fo[D]),ce=V|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 ZG=nm(()=>new qG);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const s0=BigInt(0),o0=BigInt(1),QG=BigInt(2);function wa(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function xf(r){if(!wa(r))throw new Error("Uint8Array expected")}function Es(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}const YG=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ba(r){xf(r);let e="";for(let t=0;t<r.length;t++)e+=YG[r[t]];return e}function Xc(r){const e=r.toString(16);return e.length&1?"0"+e:e}function sm(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?s0:BigInt("0x"+r)}const xs={_0:48,_9:57,A:65,F:70,a:97,f:102};function d2(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 eu(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=d2(r.charCodeAt(s)),a=d2(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 _a(r){return sm(ba(r))}function tu(r){return xf(r),sm(ba(Uint8Array.from(r).reverse()))}function ru(r,e){return eu(r.toString(16).padStart(e*2,"0"))}function Rf(r,e){return ru(r,e).reverse()}function JG(r){return eu(Xc(r))}function Tr(r,e,t){let n;if(typeof e=="string")try{n=eu(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(wa(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 Aa(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];xf(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 XG(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 ej(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}const om=r=>typeof r=="bigint"&&s0<=r;function a0(r,e,t){return om(r)&&om(e)&&om(t)&&e<=r&&r<t}function ri(r,e,t,n){if(!a0(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function p2(r){let e;for(e=0;r>s0;r>>=o0,e+=1);return e}function tj(r,e){return r>>BigInt(e)&o0}function rj(r,e,t){return r|(t?o0:s0)<<BigInt(e)}const am=r=>(QG<<BigInt(r-1))-o0,cm=r=>new Uint8Array(r),g2=r=>Uint8Array.from(r);function y2(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=cm(r),i=cm(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=cm())=>{i=a(g2([0]),g),n=a(),g.length!==0&&(i=a(g2([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 Aa(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const nj={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"||wa(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 nu(r,e,t={}){const n=(i,s,o)=>{const a=nj[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 ij=()=>{throw new Error("not implemented")};function If(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 sj=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ri,abool:Es,abytes:xf,bitGet:tj,bitLen:p2,bitMask:am,bitSet:rj,bytesToHex:ba,bytesToNumberBE:_a,bytesToNumberLE:tu,concatBytes:Aa,createHmacDrbg:y2,ensureBytes:Tr,equalBytes:XG,hexToBytes:eu,hexToNumber:sm,inRange:a0,isBytes:wa,memoized:If,notImplemented:ij,numberToBytesBE:ru,numberToBytesLE:Rf,numberToHexUnpadded:Xc,numberToVarBytesBE:JG,utf8ToBytes:ej,validateObject:nu},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mr=BigInt(0),tr=BigInt(1),va=BigInt(2),oj=BigInt(3),um=BigInt(4),m2=BigInt(5),w2=BigInt(8);function Qt(r,e){const t=r%e;return t>=Mr?t:e+t}function aj(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 lm(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=Qt(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 Qt(i,e)}function cj(r){const e=(r-tr)/va;let t,n,i;for(t=r-tr,n=0;t%va===Mr;t/=va,n++);for(i=va;i<r&&aj(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)/um;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)/va;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 uj(r){if(r%um===oj){const e=(r+tr)/um;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%w2===m2){const e=(r-m2)/w2;return function(n,i){const s=n.mul(i,va),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,va),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 cj(r)}const lj=(r,e)=>(Qt(r,e)&tr)===tr,fj=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function hj(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=fj.reduce((n,i)=>(n[i]="function",n),e);return nu(r,t)}function dj(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 pj(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 b2(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function c0(r,e,t=!1,n={}){if(r<=Mr)throw new Error("invalid field: expected ORDER > 0, got "+r);const{nBitLength:i,nByteLength:s}=b2(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:am(i),ZERO:Mr,ONE:tr,create:u=>Qt(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=>Qt(-u,r),eql:(u,l)=>u===l,sqr:u=>Qt(u*u,r),add:(u,l)=>Qt(u+l,r),sub:(u,l)=>Qt(u-l,r),mul:(u,l)=>Qt(u*l,r),pow:(u,l)=>dj(a,u,l),div:(u,l)=>Qt(u*lm(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>lm(u,r),sqrt:n.sqrt||(u=>(o||(o=uj(r)),o(a,u))),invertBatch:u=>pj(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?Rf(u,s):ru(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?tu(u):_a(u)}});return Object.freeze(a)}function _2(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 A2(r){const e=_2(r);return e+Math.ceil(e/2)}function gj(r,e,t=!1){const n=r.length,i=_2(e),s=A2(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=t?tu(r):_a(r),a=Qt(o,e-tr)+tr;return t?Rf(a,i):ru(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const v2=BigInt(0),u0=BigInt(1);function fm(r,e){const t=e.negate();return r?t:e}function E2(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function hm(r,e){E2(r,e);const t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function yj(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 mj(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 dm=new WeakMap,x2=new WeakMap;function pm(r){return x2.get(r)||1}function R2(r,e){return{constTimeNegate:fm,hasPrecomputes(t){return pm(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>v2;)n&u0&&(i=i.add(s)),s=s.double(),n>>=u0;return i},precomputeWindow(t,n){const{windows:i,windowSize:s}=hm(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}=hm(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+=u0);const S=w,x=w+Math.abs(I)-1,C=b%2!==0,H=I<0;I===0?u=u.add(fm(C,n[S])):a=a.add(fm(H,n[x]))}return{p:a,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){const{windows:o,windowSize:a}=hm(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===v2)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=l,i+=u0),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=dm.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&dm.set(n,i(s))),s},wNAFCached(t,n,i){const s=pm(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){const o=pm(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){E2(n,e),x2.set(t,n),dm.delete(t)}}}function I2(r,e,t,n){if(yj(t,r),mj(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=r.ZERO,s=p2(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 gm(r){return hj(r.Fp),nu(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...b2(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),l0=BigInt(2),wj=BigInt(8),bj={zip215:!0};function _j(r){const e=gm(r);return nu(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Aj(r){const e=_j(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=e,l=l0<<BigInt(a*8)-Sn,h=t.create,g=c0(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=If((E,k)=>{const{ex:O,ey:M,ez:G}=E,P=E.is0();k==null&&(k=P?wj: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=If(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 Ve=h(M*G),Fe=h(P*A);if(Ve!==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 I2(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(l0*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,Ve=h(re*ye),Fe=h(he*be),Be=h(re*be),et=h(ye*he);return new D(Ve,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*l0*he),St=h(U*l0*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),Ve=h(U*M*he),Fe=h(A*re),Be=h((G+P)*(le+te)-ye-be),et=Fe-Ve,Qe=Fe+Ve,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=tu(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:Ve}=b(he,ye);if(!be)throw new Error("Point.fromHex: invalid y coordinate");const Fe=(Ve&Sn)===Sn,Be=(U&128)!==0;if(!O&&Ve===_i&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==Fe&&(Ve=h(-Ve)),D.fromAffine({x:Ve,y:le})}static fromPrivateKey(k){return oe(k).point}toRawBytes(){const{x:k,y:O}=this.toAffine(),M=Rf(O,t.BYTES);return M[M.length-1]|=k&Sn?128:0,M}toHex(){return ba(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=R2(D,a*8);function j(E){return Qt(E,n)}function V(E){return j(tu(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=V(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=Aa(...k);return V(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=j(A+le*G);ri("signature.s",te,_i,n);const re=Aa(U,Rf(te,t.BYTES));return Tr("result",re,t.BYTES*2)}const B=bj;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=tu(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 ym=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),S2=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const vj=BigInt(1),k2=BigInt(2);BigInt(3);const Ej=BigInt(5),xj=BigInt(8);function Rj(r){const e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=ym,a=r*r%s*r%s,u=ur(a,k2,s)*a%s,l=ur(u,vj,s)*r%s,h=ur(l,Ej,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,k2,s)*r%s,b2:a}}function Ij(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Sj(r,e){const t=ym,n=Qt(e*e*e,t),i=Qt(n*n*e,t),s=Rj(r*i).pow_p_5_8;let o=Qt(r*n*s,t);const a=Qt(e*o*o,t),u=o,l=Qt(o*S2,t),h=a===r,g=a===Qt(-r,t),b=a===Qt(-r*S2,t);return h&&(o=u),(g||b)&&(o=l),lj(o,t)&&(o=Qt(-o,t)),{isValid:h||g,value:o}}const kj=c0(ym,void 0,!0),Tj={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:kj,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xj,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ZG,randomBytes:s2,adjustScalarBytes:Ij,uvRatio:Sj},iu=Aj(Tj);var mm={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,e){var t=Xy,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)}})(mm,mm.exports);var Oj=mm.exports,f0=Oj.Buffer;function Nj(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=f0.from(w)),!f0.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 j=H-S;j!==H&&D[j]===0;)j++;for(var V=a.repeat(I);j<H;++j)V+=r.charAt(D[j]);return V}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return f0.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 j=C-x;j!==C&&H[j]===0;)j++;var V=f0.allocUnsafe(S+(C-j));V.fill(0,0,S);for(var oe=S;j!==C;)V[oe++]=H[j++];return V}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 Cj=Nj,Bj=Cj,Pj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",T2=Bj(Pj);const Or=xn(T2),Mj=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 Lj=class extends o2{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+PG(a,u,l)+Mj[g]+go[g]|0,S=(zi(n,2)^zi(n,13)^zi(n,22))+MG(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 wm=nm(()=>new Lj);var Kr={};function Rs(r,e,t){return e<=r&&r<=t}function h0(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function Uj(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 Dj(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 d0=-1;function bm(r){this.tokens=[].slice.call(r)}bm.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():d0},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 su=-1;function _m(r,e){if(r)throw TypeError("Decoder error");return e||65533}var p0="utf-8";function g0(r,e){if(!(this instanceof g0))return new g0(r,e);if(r=r!==void 0?String(r).toLowerCase():p0,r!==p0)throw new Error("Encoding not supported. Only utf-8 is supported");e=h0(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})}g0.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=h0(t),this._streaming||(this._decoder=new $j({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new bm(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==su);)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===su)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),Dj(s)}};function y0(r,e){if(!(this instanceof y0))return new y0(r,e);if(r=r!==void 0?String(r).toLowerCase():p0,r!==p0)throw new Error("Encoding not supported. Only utf-8 is supported");e=h0(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}y0.prototype={encode:function(e,t){e=e?String(e):"",t=h0(t),this._streaming||(this._encoder=new Fj(this._options)),this._streaming=!!t.stream;for(var n=[],i=new bm(Uj(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==su);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==su;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function $j(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===d0&&i!==0)return i=0,_m(e);if(u===d0)return su;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 _m(e);return t=t<<6*i,null}if(!Rs(u,s,o))return t=i=n=0,s=128,o=191,a.prepend(u),_m(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 Fj(r){r.fatal,this.handler=function(e,t){if(t===d0)return su;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 Hj=Lc(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:g0,TextEncoder:y0},Symbol.toStringTag,{value:"Module"})));var zj=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]}),Gj=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},jj=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)&&zj(e,r,t);return Gj(e,r),e},O2=ut&&ut.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Kr,"__esModule",{value:!0});var N2=Kr.deserializeUnchecked=U2=Kr.deserialize=L2=Kr.serialize=Kr.BinaryReader=Kr.BinaryWriter=Kr.BorshError=Kr.baseDecode=Kr.baseEncode=void 0;const yo=O2(em),C2=O2(T2),Kj=jj(Hj),Vj=typeof TextDecoder!="function"?Kj.TextDecoder:TextDecoder,Wj=new Vj("utf-8",{fatal:!0});function qj(r){return typeof r=="string"&&(r=Ze.from(r,"utf8")),C2.default.encode(Ze.from(r))}Kr.baseEncode=qj;function Zj(r){return Ze.from(C2.default.decode(r))}Kr.baseDecode=Zj;const Am=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(".")}}Kr.BorshError=pn;class B2{constructor(){this.buf=Ze.alloc(Am),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Ze.concat([this.buf,Ze.alloc(Am)]))}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(Am)]),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)}}Kr.BinaryWriter=B2;function ji(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 Hn{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 Wj.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([ji],Hn.prototype,"readU8",null),Gi([ji],Hn.prototype,"readU16",null),Gi([ji],Hn.prototype,"readU32",null),Gi([ji],Hn.prototype,"readU64",null),Gi([ji],Hn.prototype,"readU128",null),Gi([ji],Hn.prototype,"readU256",null),Gi([ji],Hn.prototype,"readU512",null),Gi([ji],Hn.prototype,"readString",null),Gi([ji],Hn.prototype,"readFixedArray",null),Gi([ji],Hn.prototype,"readArray",null),Kr.BinaryReader=Hn;function P2(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Ea(r,e,t,n,i){try{if(typeof n=="string")i[`write${P2(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++)Ea(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{Ea(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),Ea(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{Ea(r,e,o,n.key,i),Ea(r,e,s,n.value,i)});break}default:throw new pn(`FieldType ${n} unrecognized`)}else M2(r,t,i)}catch(s){throw s instanceof pn&&s.addToFieldPath(e),s}}function M2(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])=>{Ea(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),Ea(r,o,e[o],a,t);break}}}else throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function Qj(r,e,t=B2){const n=new t;return M2(r,e,n),n.toArray()}var L2=Kr.serialize=Qj;function xa(r,e,t,n){try{if(typeof t=="string")return n[`read${P2(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(xa(r,null,t[0],n));return i}else return n.readArray(()=>xa(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?xa(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=xa(r,e,t.key,n),u=xa(r,e,t.value,n);i.set(a,u)}return i}return vm(r,t,n)}catch(i){throw i instanceof pn&&i.addToFieldPath(e),i}}function vm(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]=xa(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=xa(r,s,o,t);return new e({[s]:a})}throw new pn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function Yj(r,e,t,n=Hn){const i=new n(t),s=vm(r,e,i);if(i.offset<t.length)throw new pn(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}var U2=Kr.deserialize=Yj;function Jj(r,e,t,n=Hn){const i=new n(t);return vm(r,e,i)}N2=Kr.deserializeUnchecked=Jj;var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.s16=ne.s8=ne.nu64be=ne.u48be=ne.u40be=ne.u32be=ne.u24be=ne.u16be=Vr=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=zn=ne.ns64=ne.s48=ne.s40=ne.s32=ne.s24=void 0;const Em=Xy;function ou(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ne.checkUint8Array=ou;function At(r){return ou(r),Em.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 xm(r,e){return e.property?r+"["+e.property+"]":r}ne.nameWithProperty=xm;function Xj(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=Xj;let kn=class extends Tt{isCount(){throw new Error("ExternalLayout is abstract")}};ne.ExternalLayout=kn;let D2=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){ou(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};ne.GreedyCount=D2;let Rm=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=Rm;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 Ra=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=Ra;let au=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=au;const Im=Math.pow(2,32);function m0(r){const e=Math.floor(r/Im),t=r-e*Im;return{hi32:e,lo32:t}}function w0(r,e){return r*Im+e}let $2=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 w0(s,i)}encode(e,t,n=0){const i=m0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};ne.NearUInt64=$2;let F2=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 w0(i,s)}encode(e,t,n=0){const i=m0(e),s=At(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearUInt64BE=F2;let H2=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 w0(s,i)}encode(e,t,n=0){const i=m0(e),s=At(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};ne.NearInt64=H2;let z2=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 w0(i,s)}encode(e,t,n=0){const i=m0(e),s=At(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ne.NearInt64BE=z2;let G2=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=G2;let j2=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=j2;let K2=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=K2;let V2=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=V2;let W2=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=W2;let q2=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){ou(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=q2;let Sm=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=Sm;let b0=class extends Sm{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=b0;let km=class extends Tt{constructor(e,t,n){let i;if(e instanceof ni||e instanceof Ai)i=new b0(new Rm(e));else if(e instanceof kn&&e.isCount())i=new b0(e);else if(e instanceof Sm)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 Z2(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=km;let Z2=class extends Tt{constructor(e,t,n,i){if(!(e instanceof km))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=Z2;function cu(r){return 0>r&&(r+=4294967296),r}let Tm=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=cu(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 Om(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new Q2(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=Tm;let Om=class{constructor(e,t,n){if(!(e instanceof Tm))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=cu(this.valueMask<<this.start),this.property=n}decode(e,t){const n=this.container._packedGetValue();return cu(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==cu(e&this.valueMask))throw new TypeError(xm("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=cu(e<<this.start);this.container._packedSetValue(cu(t&~this.wordMask)|n)}};ne.BitField=Om;let Q2=class extends Om{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=Q2;let Y2=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(xm("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=Y2;let J2=class extends Tt{constructor(e){super(-1,e)}getSpan(e,t=0){ou(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=Em.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=J2;let X2=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 ou(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=Em.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=X2;let ex=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=ex,ne.greedy=(r,e)=>new D2(r,e);var mo=ne.offset=(r,e,t)=>new Rm(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 Vr=ne.nu64=r=>new $2(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 F2(r),ne.s8=r=>new Ra(1,r),ne.s16=r=>new Ra(2,r),ne.s24=r=>new Ra(3,r),ne.s32=r=>new Ra(4,r),ne.s40=r=>new Ra(5,r),ne.s48=r=>new Ra(6,r);var zn=ne.ns64=r=>new H2(r);ne.s16be=r=>new au(2,r),ne.s24be=r=>new au(3,r),ne.s32be=r=>new au(4,r),ne.s40be=r=>new au(5,r),ne.s48be=r=>new au(6,r),ne.ns64be=r=>new z2(r),ne.f32=r=>new G2(r),ne.f32be=r=>new j2(r),ne.f64=r=>new K2(r),ne.f64be=r=>new V2(r);var Me=ne.struct=(r,e,t)=>new q2(r,e,t);ne.bits=(r,e,t)=>new Tm(r,e,t);var Wr=ne.seq=(r,e,t)=>new W2(r,e,t);ne.union=(r,e,t)=>new km(r,e,t),ne.unionLayoutDiscriminator=(r,e)=>new b0(r,e);var Wt=ne.blob=(r,e)=>new Y2(r,e);ne.cstr=r=>new J2(r),ne.utf8=(r,e)=>new X2(r,e),ne.constant=(r,e)=>new ex(r,e);var Sf={};Object.defineProperty(Sf,"__esModule",{value:!0});function eK(r){{const e=Ze.from(r);e.reverse();const t=e.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}var tK=Sf.toBigIntLE=eK;function rK(r){{const e=r.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}Sf.toBigIntBE=rK;function nK(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 tx=Sf.toBufferLE=nK;function iK(r,e){{const t=r.toString(16);return Ze.from(t.padStart(e*2,"0").slice(0,e*2),"hex")}}Sf.toBufferBE=iK;let sK=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 oK(r){return kf(r)&&typeof r[Symbol.iterator]=="function"}function kf(r){return typeof r=="object"&&r!=null}function _0(r){return kf(r)&&!Array.isArray(r)}function vi(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function aK(r){const{done:e,value:t}=r.next();return e?void 0:t}function cK(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*rx(r,e,t,n){oK(r)||(r=[r]);for(const i of r){const s=cK(i,e,t,n);s&&(yield s)}}function*Nm(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=Nm(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):kf(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 Ki=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 rx(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return rx(h,l,this,u)}:this.refiner=()=>[]}assert(e,t){return nx(e,this,t)}create(e,t){return Ae(e,this,t)}is(e){return ix(e,this)}mask(e,t){return uK(e,this,t)}validate(e,t={}){return Tf(e,this,t)}};function nx(r,e,t){const n=Tf(r,e,{message:t});if(n[0])throw n[0]}function Ae(r,e,t){const n=Tf(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function uK(r,e,t){const n=Tf(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function ix(r,e){return!Tf(r,e)[0]}function Tf(r,e,t={}){const n=Nm(r,e,t),i=aK(n);return i[0]?[new sK(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Ia(r,e){return new Ki({type:r,schema:null,validator:e})}function lK(){return Ia("any",()=>!0)}function Re(r){return new Ki({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 Vi(){return Ia("boolean",r=>typeof r=="boolean")}function Cm(r){return Ia("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 Ki({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 fK(){return Ia("never",()=>!1)}function Ie(r){return new Ki({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X(){return Ia("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${vi(r)}`)}function He(r){return new Ki({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function sx(r,e){return new Ki({type:"record",schema:null,*entries(t){if(kf(t))for(const n in t){const i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return _0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return _0(t)?{...t}:t}})}function _e(){return Ia("string",r=>typeof r=="string"||`Expected a string, but received: ${vi(r)}`)}function Bm(r){const e=fK();return new Ki({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 Ki({type:"type",schema:r,*entries(t){if(kf(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return _0(t)||`Expected an object, but received: ${vi(t)}`},coercer(t){return _0(t)?{...t}:t}})}function gn(r){const e=r.map(t=>t.type).join(" | ");return new Ki({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]=Nm(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 uu(){return Ia("unknown",()=>!0)}function Of(r,e,t){return new Ki({...r,coercer:(n,i)=>ix(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var A0,hK=new Uint8Array(16);function ox(){if(!A0&&(A0=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!A0))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return A0(hK)}const dK=/^(?:[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 v0(r){return typeof r=="string"&&dK.test(r)}for(var qr=[],Pm=0;Pm<256;++Pm)qr.push((Pm+256).toString(16).substr(1));function E0(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(!v0(t))throw TypeError("Stringified UUID is invalid");return t}var ax,Mm,Lm=0,Um=0;function pK(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||ax,o=r.clockseq!==void 0?r.clockseq:Mm;if(s==null||o==null){var a=r.random||(r.rng||ox)();s==null&&(s=ax=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Mm=(a[6]<<8|a[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),l=r.nsecs!==void 0?r.nsecs:Um+1,h=u-Lm+(l-Um)/1e4;if(h<0&&r.clockseq===void 0&&(o=o+1&16383),(h<0||u>Lm)&&r.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lm=u,Um=l,Mm=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||E0(i)}function cx(r){if(!v0(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 gK(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var yK="6ba7b810-9dad-11d1-80b4-00c04fd430c8",mK="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ux(r,e,t){function n(i,s,o,a){if(typeof i=="string"&&(i=gK(i)),typeof s=="string"&&(s=cx(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 E0(u)}try{n.name=r}catch{}return n.DNS=yK,n.URL=mK,n}function wK(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 bK(_K(AK(r),r.length*8))}function bK(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 lx(r){return(r+64>>>9<<4)+14+1}function _K(r,e){r[e>>5]|=128<<e%32,r[lx(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 AK(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(lx(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 vK(r,e){return r<<e|r>>>32-e}function x0(r,e,t,n,i,s){return wo(vK(wo(wo(e,r),wo(n,s)),i),t)}function rn(r,e,t,n,i,s,o){return x0(e&t|~e&n,r,e,i,s,o)}function nn(r,e,t,n,i,s,o){return x0(e&n|t&~n,r,e,i,s,o)}function sn(r,e,t,n,i,s,o){return x0(e^t^n,r,e,i,s,o)}function on(r,e,t,n,i,s,o){return x0(t^(e|~n),r,e,i,s,o)}var EK=ux("v3",48,wK);function xK(r,e,t){r=r||{};var n=r.random||(r.rng||ox)();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 E0(n)}function RK(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 Dm(r,e){return r<<e|r>>>32-e}function IK(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]=Dm(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=Dm(S,5)+RK(W,x,C,H)+D+e[W]+b[z]>>>0;D=H,H=C,C=Dm(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 SK=ux("v5",80,IK);const kK="00000000-0000-0000-0000-000000000000";function TK(r){if(!v0(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const fx=Lc(Object.freeze(Object.defineProperty({__proto__:null,NIL:kK,parse:cx,stringify:E0,v1:pK,v3:EK,v4:xK,v5:SK,validate:v0,version:TK},Symbol.toStringTag,{value:"Module"}))),OK=fx.v4;var NK=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 OK()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};const CK=fx.v4,BK=NK,Nf=function(r,e){if(!(this instanceof Nf))return new Nf(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 CK()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};var PK=Nf;Nf.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=BK(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},Nf.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 MK=xn(PK);var hx={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})(hx);var LK=hx.exports;const dx=xn(LK);var UK=class extends dx{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 DK(r,e){return new UK(r,e)}var $K=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},FK=class extends dx{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 $K,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 px=[],gx=[],yx=[],HK=BigInt(0),Cf=BigInt(1),zK=BigInt(2),GK=BigInt(7),jK=BigInt(256),KK=BigInt(113);for(let r=0,e=Cf,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],px.push(2*(5*n+t)),gx.push((r+1)*(r+2)/2%64);let i=HK;for(let s=0;s<7;s++)e=(e<<Cf^(e>>GK)*KK)%jK,e&zK&&(i^=Cf<<(Cf<<BigInt(s))-Cf);yx.push(i)}const[VK,WK]=c2(yx,!0),mx=(r,e,t)=>t>32?f2(r,e,t):u2(r,e,t),wx=(r,e,t)=>t>32?h2(r,e,t):l2(r,e,t);function qK(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=mx(l,h,1)^t[a],b=wx(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=gx[o],u=mx(i,s,a),l=wx(i,s,a),h=px[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]^=VK[n],r[1]^=WK[n]}t.fill(0)}let ZK=class d6 extends rm{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,r0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=TG(this.state)}keccak(){n2||i2(this.state32),qK(this.state32,this.rounds),n2||i2(this.state32),this.posOut=0,this.pos=0}update(e){Yc(this);const{blockLen:t,state:n}=this;e=n0(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){Yc(this,!1),Ef(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 r0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(r2(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 d6(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 bx=((r,e,t)=>nm(()=>new ZK(e,r,t)))(1,136,256/8);let _x=class extends rm{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,kG(e);const n=n0(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 Yc(this),this.iHash.update(e),this}digestInto(e){Yc(this),Ef(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 Ax=(r,e,t)=>new _x(r,e).update(t).digest();Ax.create=(r,e)=>new _x(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vx(r){r.lowS!==void 0&&Es("lowS",r.lowS),r.prehash!==void 0&&Es("prehash",r.prehash)}function QK(r){const e=gm(r);nu(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:YK,hexToBytes:JK}=sj;class XK extends Error{constructor(e=""){super(e)}}const Is={Err:XK,_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=Xc(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=n>127?Xc(i.length/2|128):"";return Xc(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=Xc(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 YK(r)}},toSig(r){const{Err:e,_int:t,_tlv:n}=Is,i=typeof r=="string"?JK(r):r;xf(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 Ex=BigInt(3);BigInt(4);function eV(r){const e=QK(r),{Fp:t}=e,n=c0(e.n,e.nBitLength),i=e.toBytes||((S,x,C)=>{const H=x.toAffine();return Aa(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 a0(S,Lr,e.n)}function u(S){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:H,n:D}=e;if(x&&typeof S!="bigint"){if(wa(S)&&(S=ba(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:_a(Tr("private key",S,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof S)}return H&&(z=Qt(z,D)),ri("private key",z,Lr,D),z}function l(S){if(!(S instanceof b))throw new Error("ProjectivePoint expected")}const h=If((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),j=t.mul(D,x);if(z)return{x:t.ZERO,y:t.ZERO};if(!t.eql(j,t.ONE))throw new Error("invZ was invalid");return{x:W,y:Z}}),g=If(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 I2(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,j=t.eql(t.mul(C,Z),t.mul(z,D)),V=t.eql(t.mul(H,Z),t.mul(W,D));return j&&V}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:x,b:C}=e,H=t.mul(C,Ex),{px:D,py:z,pz:W}=this;let Z=t.ZERO,j=t.ZERO,V=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),V=t.mul(D,W),V=t.add(V,V),Z=t.mul(x,V),j=t.mul(H,ie),j=t.add(Z,j),Z=t.sub(ce,j),j=t.add(ce,j),j=t.mul(Z,j),Z=t.mul(ue,Z),V=t.mul(H,V),ie=t.mul(x,ie),ue=t.sub(oe,ie),ue=t.mul(x,ue),ue=t.add(ue,V),V=t.add(oe,oe),oe=t.add(V,oe),oe=t.add(oe,ie),oe=t.mul(oe,ue),j=t.add(j,oe),ie=t.mul(z,W),ie=t.add(ie,ie),oe=t.mul(ie,ue),Z=t.sub(Z,oe),V=t.mul(ie,ce),V=t.add(V,V),V=t.add(V,V),new b(Z,j,V)}add(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:W,pz:Z}=x;let j=t.ZERO,V=t.ZERO,oe=t.ZERO;const ce=e.a,ie=t.mul(e.b,Ex);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),j=t.add(W,Z),k=t.mul(k,j),j=t.add(B,p),k=t.sub(k,j),oe=t.mul(ce,E),j=t.mul(ie,p),oe=t.add(j,oe),j=t.sub(B,oe),oe=t.add(B,oe),V=t.mul(j,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),V=t.add(V,ue),ue=t.mul(k,E),j=t.mul(m,j),j=t.sub(j,ue),ue=t.mul(m,B),oe=t.mul(k,oe),oe=t.add(oe,ue),new b(j,V,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:j}=C.splitScalar(x),V=D,oe=D,ce=this;for(;W>Ss||j>Ss;)W&Lr&&(V=V.add(ce)),j&Lr&&(oe=oe.add(ce)),ce=ce.double(),W>>=Lr,j>>=Lr;return z&&(V=V.negate()),Z&&(oe=oe.negate()),oe=new b(t.mul(oe.px,C.beta),oe.py,oe.pz),V.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:j,k2:V}=C.splitScalar(x);let{p:oe,f:ce}=this.wNAF(Z),{p:ie,f:ue}=this.wNAF(V);oe=I.constTimeNegate(W,oe),ie=I.constTimeNegate(j,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,j)=>j===Ss||j===Lr||!Z.equals(D)?Z.multiplyUnsafe(j):Z.multiply(j),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),ba(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=R2(b,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function tV(r){const e=gm(r);return nu(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function rV(r){const e=tV(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(p){return Qt(p,n)}function a(p){return lm(p,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:g}=eV({...e,toBytes(p,m,E){const k=m.toAffine(),O=t.toBytes(k.x),M=Aa;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=_a(k);if(!a0(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=>ba(ru(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)=>_a(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 eu(this.toDERHex())}toDERHex(){return Is.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return eu(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=A2(e.n);return gj(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=wa(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=_a(p),E=p.length*8-e.nBitLength;return E>0?m>>BigInt(E):m},Z=e.bits2int_modN||function(p){return o(W(p))},j=am(e.nBitLength);function V(p){return ri("num < 2^"+e.nBitLength,p,Ss,j),ru(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),vx(E),G&&(p=Tr("prehashed msgHash",k(p)));const A=Z(p),U=l(m),le=[V(U),V(A)];if(P!=null&&P!==!1){const ye=P===!0?O(t.BYTES):P;le.push(Tr("extraEntropy",ye))}const te=Aa(...le),re=A;function he(ye){const be=W(ye);if(!g(be))return;const Ve=a(be),Fe=u.BASE.multiply(be).toAffine(),Be=o(Fe.x);if(Be===Ss)return;const et=o(Ve*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 y2(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(vx(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"||wa(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),Ve=o(ye*be),Fe=o(re*be),Be=(Qe=u.BASE.multiplyAndAddUnsafe(te,Ve,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 nV(r){return{hash:r,hmac:(e,...t)=>Ax(r,e,CG(...t)),randomBytes:s2}}function iV(r,e){const t=n=>rV({...r,...nV(n)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xx=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Rx=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),sV=BigInt(1),$m=BigInt(2),Ix=(r,e)=>(r+e/$m)/e;function oV(r){const e=xx,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,$m,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,$m,e);if(!Fm.eql(Fm.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Fm=c0(xx,void 0,void 0,{sqrt:oV}),R0=iV({a:BigInt(0),b:BigInt(7),Fp:Fm,n:Rx,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Rx,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-sV*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=Ix(s*r,e),u=Ix(-n*r,e);let l=Qt(r-a*t-u*i,e),h=Qt(-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}}}},wm);BigInt(0),R0.ProjectivePoint;const aV=iu.utils.randomPrivateKey,Sx=()=>{const r=iu.utils.randomPrivateKey(),e=I0(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},I0=iu.getPublicKey;function kx(r){try{return iu.ExtendedPoint.fromHex(r),!0}catch{return!1}}const Hm=(r,e)=>iu.sign(r,e.slice(0,32)),cV=iu.verify,nt=r=>Ne.isBuffer(r)?r:r instanceof Uint8Array?Ne.from(r.buffer,r.byteOffset,r.byteLength):Ne.from(r);let zm=class{constructor(e){Object.assign(this,e)}encode(){return Ne.from(L2(Bf,this))}static decode(e){return U2(Bf,this,e)}static decodeUnchecked(e){return N2(Bf,this,e)}};class uV extends zm{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 Bf=new Map;var Tx;const Ox=32,Wi=32;function lV(r){return r._bn!==void 0}let Nx=1;class me extends zm{constructor(e){if(super({}),this._bn=void 0,lV(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(Nx);return Nx+=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=wm(i);return new me(s)}static createProgramAddressSync(e,t){let n=Ne.alloc(0);e.forEach(function(s){if(s.length>Ox)throw new TypeError("Max seed length exceeded");n=Ne.concat([n,nt(s)])}),n=Ne.concat([n,t.toBuffer(),Ne.from("ProgramDerivedAddress")]);const i=wm(n);if(kx(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 kx(t.toBytes())}}Tx=me,me.default=new Tx("11111111111111111111111111111111"),Bf.set(me,{kind:"struct",fields:[["_bn","u256"]]});class fV{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(aV()),this._publicKey=nt(I0(this._secretKey))}get publicKey(){return new me(this._publicKey)}get secretKey(){return Ne.concat([this._secretKey,this._publicKey],64)}}const hV=new me("BPFLoader1111111111111111111111111111111111"),bo=1232,S0=127,Pf=64;class Gm extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Gm.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class jm 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(jm.prototype,"name",{value:"TransactionExpiredTimeoutError"});class lu extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(lu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Mf{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),dV=(r="signature")=>Wt(64,r),Sa=(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},pV=(r="authorized")=>Me([lt("staker"),lt("withdrawer")],r),gV=(r="lockup")=>Me([zn("unixTimestamp"),zn("epoch"),lt("custodian")],r),yV=(r="voteInit")=>Me([lt("nodePubkey"),lt("authorizedVoter"),lt("authorizedWithdrawer"),bt("commission")],r),mV=(r="voteAuthorizeWithSeedArgs")=>Me([Pe("voteAuthorizationType"),lt("currentAuthorityDerivedKeyOwnerPubkey"),Sa("currentAuthorityDerivedKeySeed"),lt("newAuthorized")],r);function Cx(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 Cx({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 Gn(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 k0{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 k0(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 Bx="Reached end of buffer unexpectedly";function qi(r){if(r.length===0)throw new Error(Bx);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(Bx);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 Mf(this.staticAccountKeys)}static compile(e){const t=k0.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new Mf(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=[];Gn(t,e);const n=this.instructions.map(g=>{const{accounts:b,programIdIndex:w}=g,I=Array.from(Or.decode(g.data));let S=[];Gn(S,b.length);let x=[];return Gn(x,I.length),{programIdIndex:w,keyIndicesCount:Ne.from(S),keyIndices:b,dataLength:Ne.from(x),data:I}});let i=[];Gn(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&S0))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 ka{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 Mf(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=k0.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 Mf(a,i).compileInstructions(e.instructions);return new ka({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:l,addressTableLookups:n})}serialize(){const e=Array();Gn(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();Gn(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();Gn(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();Gn(i,n.accountKeyIndexes.length);const s=Array();Gn(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();Gn(i,n.writableIndexes.length);const s=Array();Gn(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&S0;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 ka({header:o,staticAccountKeys:a,recentBlockhash:l,compiledInstructions:g,addressTableLookups:w})}}const Km={deserializeMessageVersion(r){const e=r[0],t=e&S0;return t===e?"legacy":t},deserialize:r=>{const e=Km.deserializeMessageVersion(r);if(e==="legacy")return Ei.from(r);if(e===0)return ka.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 wV=Ne.alloc(Pf).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 $_{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=Hm(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):cV(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+=`
|
|
16
|
+
*/(function(n){const t=Hd,e=Ug,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=h,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer: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 O=new s(1),b={foo:function(){return 42}};return Object.setPrototypeOf(b,s.prototype),Object.setPrototypeOf(O,b),O.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function f(O){if(O>i)throw new RangeError('The value "'+O+'" is invalid for option "size"');const b=new s(O);return Object.setPrototypeOf(b,h.prototype),b}function h(O,b,E){if(typeof O=="number"){if(typeof b=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(O)}return y(O,b,E)}h.poolSize=8192;function y(O,b,E){if(typeof O=="string")return T(O,b);if(o.isView(O))return B(O);if(O==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O);if(on(O,o)||O&&on(O.buffer,o)||typeof a<"u"&&(on(O,a)||O&&on(O.buffer,a)))return H(O,b,E);if(typeof O=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=O.valueOf&&O.valueOf();if(D!=null&&D!==O)return h.from(D,b,E);const V=U(O);if(V)return V;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof O[Symbol.toPrimitive]=="function")return h.from(O[Symbol.toPrimitive]("string"),b,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O)}h.from=function(O,b,E){return y(O,b,E)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function _(O){if(typeof O!="number")throw new TypeError('"size" argument must be of type number');if(O<0)throw new RangeError('The value "'+O+'" is invalid for option "size"')}function w(O,b,E){return _(O),O<=0?f(O):b!==void 0?typeof E=="string"?f(O).fill(b,E):f(O).fill(b):f(O)}h.alloc=function(O,b,E){return w(O,b,E)};function R(O){return _(O),f(O<0?0:G(O)|0)}h.allocUnsafe=function(O){return R(O)},h.allocUnsafeSlow=function(O){return R(O)};function T(O,b){if((typeof b!="string"||b==="")&&(b="utf8"),!h.isEncoding(b))throw new TypeError("Unknown encoding: "+b);const E=X(O,b)|0;let D=f(E);const V=D.write(O,b);return V!==E&&(D=D.slice(0,V)),D}function I(O){const b=O.length<0?0:G(O.length)|0,E=f(b);for(let D=0;D<b;D+=1)E[D]=O[D]&255;return E}function B(O){if(on(O,s)){const b=new s(O);return H(b.buffer,b.byteOffset,b.byteLength)}return I(O)}function H(O,b,E){if(b<0||O.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(O.byteLength<b+(E||0))throw new RangeError('"length" is outside of buffer bounds');let D;return b===void 0&&E===void 0?D=new s(O):E===void 0?D=new s(O,b):D=new s(O,b,E),Object.setPrototypeOf(D,h.prototype),D}function U(O){if(h.isBuffer(O)){const b=G(O.length)|0,E=f(b);return E.length===0||O.copy(E,0,0,b),E}if(O.length!==void 0)return typeof O.length!="number"||ve(O.length)?f(0):I(O);if(O.type==="Buffer"&&Array.isArray(O.data))return I(O.data)}function G(O){if(O>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return O|0}function W(O){return+O!=O&&(O=0),h.alloc(+O)}h.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==h.prototype},h.compare=function(b,E){if(on(b,s)&&(b=h.from(b,b.offset,b.byteLength)),on(E,s)&&(E=h.from(E,E.offset,E.byteLength)),!h.isBuffer(b)||!h.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===E)return 0;let D=b.length,V=E.length;for(let q=0,st=Math.min(D,V);q<st;++q)if(b[q]!==E[q]){D=b[q],V=E[q];break}return D<V?-1:V<D?1:0},h.isEncoding=function(b){switch(String(b).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(b,E){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return h.alloc(0);let D;if(E===void 0)for(E=0,D=0;D<b.length;++D)E+=b[D].length;const V=h.allocUnsafe(E);let q=0;for(D=0;D<b.length;++D){let st=b[D];if(on(st,s))q+st.length>V.length?(h.isBuffer(st)||(st=h.from(st)),st.copy(V,q)):s.prototype.set.call(V,st,q);else if(h.isBuffer(st))st.copy(V,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=st.length}return V};function X(O,b){if(h.isBuffer(O))return O.length;if(o.isView(O)||on(O,o))return O.byteLength;if(typeof O!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof O);const E=O.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&E===0)return 0;let V=!1;for(;;)switch(b){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return Ie(O).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return he(O).length;default:if(V)return D?-1:Ie(O).length;b=(""+b).toLowerCase(),V=!0}}h.byteLength=X;function j(O,b,E){let D=!1;if((b===void 0||b<0)&&(b=0),b>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,b>>>=0,E<=b))return"";for(O||(O="utf8");;)switch(O){case"hex":return A(this,b,E);case"utf8":case"utf-8":return k(this,b,E);case"ascii":return z(this,b,E);case"latin1":case"binary":return P(this,b,E);case"base64":return v(this,b,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,b,E);default:if(D)throw new TypeError("Unknown encoding: "+O);O=(O+"").toLowerCase(),D=!0}}h.prototype._isBuffer=!0;function J(O,b,E){const D=O[b];O[b]=O[E],O[E]=D}h.prototype.swap16=function(){const b=this.length;if(b%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<b;E+=2)J(this,E,E+1);return this},h.prototype.swap32=function(){const b=this.length;if(b%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<b;E+=4)J(this,E,E+3),J(this,E+1,E+2);return this},h.prototype.swap64=function(){const b=this.length;if(b%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<b;E+=8)J(this,E,E+7),J(this,E+1,E+6),J(this,E+2,E+5),J(this,E+3,E+4);return this},h.prototype.toString=function(){const b=this.length;return b===0?"":arguments.length===0?k(this,0,b):j.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(b){if(!h.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?!0:h.compare(this,b)===0},h.prototype.inspect=function(){let b="";const E=n.INSPECT_MAX_BYTES;return b=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(b+=" ... "),"<Buffer "+b+">"},r&&(h.prototype[r]=h.prototype.inspect),h.prototype.compare=function(b,E,D,V,q){if(on(b,s)&&(b=h.from(b,b.offset,b.byteLength)),!h.isBuffer(b))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof b);if(E===void 0&&(E=0),D===void 0&&(D=b?b.length:0),V===void 0&&(V=0),q===void 0&&(q=this.length),E<0||D>b.length||V<0||q>this.length)throw new RangeError("out of range index");if(V>=q&&E>=D)return 0;if(V>=q)return-1;if(E>=D)return 1;if(E>>>=0,D>>>=0,V>>>=0,q>>>=0,this===b)return 0;let st=q-V,qt=D-E;const Wt=Math.min(st,qt),jt=this.slice(V,q),$e=b.slice(E,D);for(let Ht=0;Ht<Wt;++Ht)if(jt[Ht]!==$e[Ht]){st=jt[Ht],qt=$e[Ht];break}return st<qt?-1:qt<st?1:0};function it(O,b,E,D,V){if(O.length===0)return-1;if(typeof E=="string"?(D=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,ve(E)&&(E=V?0:O.length-1),E<0&&(E=O.length+E),E>=O.length){if(V)return-1;E=O.length-1}else if(E<0)if(V)E=0;else return-1;if(typeof b=="string"&&(b=h.from(b,D)),h.isBuffer(b))return b.length===0?-1:ut(O,b,E,D,V);if(typeof b=="number")return b=b&255,typeof s.prototype.indexOf=="function"?V?s.prototype.indexOf.call(O,b,E):s.prototype.lastIndexOf.call(O,b,E):ut(O,[b],E,D,V);throw new TypeError("val must be string, number or Buffer")}function ut(O,b,E,D,V){let q=1,st=O.length,qt=b.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(O.length<2||b.length<2)return-1;q=2,st/=2,qt/=2,E/=2}function Wt($e,Ht){return q===1?$e[Ht]:$e.readUInt16BE(Ht*q)}let jt;if(V){let $e=-1;for(jt=E;jt<st;jt++)if(Wt(O,jt)===Wt(b,$e===-1?0:jt-$e)){if($e===-1&&($e=jt),jt-$e+1===qt)return $e*q}else $e!==-1&&(jt-=jt-$e),$e=-1}else for(E+qt>st&&(E=st-qt),jt=E;jt>=0;jt--){let $e=!0;for(let Ht=0;Ht<qt;Ht++)if(Wt(O,jt+Ht)!==Wt(b,Ht)){$e=!1;break}if($e)return jt}return-1}h.prototype.includes=function(b,E,D){return this.indexOf(b,E,D)!==-1},h.prototype.indexOf=function(b,E,D){return it(this,b,E,D,!0)},h.prototype.lastIndexOf=function(b,E,D){return it(this,b,E,D,!1)};function rt(O,b,E,D){E=Number(E)||0;const V=O.length-E;D?(D=Number(D),D>V&&(D=V)):D=V;const q=b.length;D>q/2&&(D=q/2);let st;for(st=0;st<D;++st){const qt=parseInt(b.substr(st*2,2),16);if(ve(qt))return st;O[E+st]=qt}return st}function ot(O,b,E,D){return Se(Ie(b,O.length-E),O,E,D)}function C(O,b,E,D){return Se(Be(b),O,E,D)}function p(O,b,E,D){return Se(he(b),O,E,D)}function m(O,b,E,D){return Se(kn(b,O.length-E),O,E,D)}h.prototype.write=function(b,E,D,V){if(E===void 0)V="utf8",D=this.length,E=0;else if(D===void 0&&typeof E=="string")V=E,D=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(D)?(D=D>>>0,V===void 0&&(V="utf8")):(V=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-E;if((D===void 0||D>q)&&(D=q),b.length>0&&(D<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let st=!1;for(;;)switch(V){case"hex":return rt(this,b,E,D);case"utf8":case"utf-8":return ot(this,b,E,D);case"ascii":case"latin1":case"binary":return C(this,b,E,D);case"base64":return p(this,b,E,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,b,E,D);default:if(st)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),st=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(O,b,E){return b===0&&E===O.length?t.fromByteArray(O):t.fromByteArray(O.slice(b,E))}function k(O,b,E){E=Math.min(O.length,E);const D=[];let V=b;for(;V<E;){const q=O[V];let st=null,qt=q>239?4:q>223?3:q>191?2:1;if(V+qt<=E){let Wt,jt,$e,Ht;switch(qt){case 1:q<128&&(st=q);break;case 2:Wt=O[V+1],(Wt&192)===128&&(Ht=(q&31)<<6|Wt&63,Ht>127&&(st=Ht));break;case 3:Wt=O[V+1],jt=O[V+2],(Wt&192)===128&&(jt&192)===128&&(Ht=(q&15)<<12|(Wt&63)<<6|jt&63,Ht>2047&&(Ht<55296||Ht>57343)&&(st=Ht));break;case 4:Wt=O[V+1],jt=O[V+2],$e=O[V+3],(Wt&192)===128&&(jt&192)===128&&($e&192)===128&&(Ht=(q&15)<<18|(Wt&63)<<12|(jt&63)<<6|$e&63,Ht>65535&&Ht<1114112&&(st=Ht))}}st===null?(st=65533,qt=1):st>65535&&(st-=65536,D.push(st>>>10&1023|55296),st=56320|st&1023),D.push(st),V+=qt}return M(D)}const N=4096;function M(O){const b=O.length;if(b<=N)return String.fromCharCode.apply(String,O);let E="",D=0;for(;D<b;)E+=String.fromCharCode.apply(String,O.slice(D,D+=N));return E}function z(O,b,E){let D="";E=Math.min(O.length,E);for(let V=b;V<E;++V)D+=String.fromCharCode(O[V]&127);return D}function P(O,b,E){let D="";E=Math.min(O.length,E);for(let V=b;V<E;++V)D+=String.fromCharCode(O[V]);return D}function A(O,b,E){const D=O.length;(!b||b<0)&&(b=0),(!E||E<0||E>D)&&(E=D);let V="";for(let q=b;q<E;++q)V+=Pe[O[q]];return V}function $(O,b,E){const D=O.slice(b,E);let V="";for(let q=0;q<D.length-1;q+=2)V+=String.fromCharCode(D[q]+D[q+1]*256);return V}h.prototype.slice=function(b,E){const D=this.length;b=~~b,E=E===void 0?D:~~E,b<0?(b+=D,b<0&&(b=0)):b>D&&(b=D),E<0?(E+=D,E<0&&(E=0)):E>D&&(E=D),E<b&&(E=b);const V=this.subarray(b,E);return Object.setPrototypeOf(V,h.prototype),V};function ct(O,b,E){if(O%1!==0||O<0)throw new RangeError("offset is not uint");if(O+b>E)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[b+st]*q;return V},h.prototype.readUintBE=h.prototype.readUIntBE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b+--E],q=1;for(;E>0&&(q*=256);)V+=this[b+--E]*q;return V},h.prototype.readUint8=h.prototype.readUInt8=function(b,E){return b=b>>>0,E||ct(b,1,this.length),this[b]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(b,E){return b=b>>>0,E||ct(b,2,this.length),this[b]|this[b+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(b,E){return b=b>>>0,E||ct(b,2,this.length),this[b]<<8|this[b+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+this[b+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]*16777216+(this[b+1]<<16|this[b+2]<<8|this[b+3])},h.prototype.readBigUInt64LE=ur(function(b){b=b>>>0,sn(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&fe(b,this.length-8);const V=E+this[++b]*2**8+this[++b]*2**16+this[++b]*2**24,q=this[++b]+this[++b]*2**8+this[++b]*2**16+D*2**24;return BigInt(V)+(BigInt(q)<<BigInt(32))}),h.prototype.readBigUInt64BE=ur(function(b){b=b>>>0,sn(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&fe(b,this.length-8);const V=E*2**24+this[++b]*2**16+this[++b]*2**8+this[++b],q=this[++b]*2**24+this[++b]*2**16+this[++b]*2**8+D;return(BigInt(V)<<BigInt(32))+BigInt(q)}),h.prototype.readIntLE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[b+st]*q;return q*=128,V>=q&&(V-=Math.pow(2,8*E)),V},h.prototype.readIntBE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=E,q=1,st=this[b+--V];for(;V>0&&(q*=256);)st+=this[b+--V]*q;return q*=128,st>=q&&(st-=Math.pow(2,8*E)),st},h.prototype.readInt8=function(b,E){return b=b>>>0,E||ct(b,1,this.length),this[b]&128?(255-this[b]+1)*-1:this[b]},h.prototype.readInt16LE=function(b,E){b=b>>>0,E||ct(b,2,this.length);const D=this[b]|this[b+1]<<8;return D&32768?D|4294901760:D},h.prototype.readInt16BE=function(b,E){b=b>>>0,E||ct(b,2,this.length);const D=this[b+1]|this[b]<<8;return D&32768?D|4294901760:D},h.prototype.readInt32LE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},h.prototype.readInt32BE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},h.prototype.readBigInt64LE=ur(function(b){b=b>>>0,sn(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&fe(b,this.length-8);const V=this[b+4]+this[b+5]*2**8+this[b+6]*2**16+(D<<24);return(BigInt(V)<<BigInt(32))+BigInt(E+this[++b]*2**8+this[++b]*2**16+this[++b]*2**24)}),h.prototype.readBigInt64BE=ur(function(b){b=b>>>0,sn(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&fe(b,this.length-8);const V=(E<<24)+this[++b]*2**16+this[++b]*2**8+this[++b];return(BigInt(V)<<BigInt(32))+BigInt(this[++b]*2**24+this[++b]*2**16+this[++b]*2**8+D)}),h.prototype.readFloatLE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),e.read(this,b,!0,23,4)},h.prototype.readFloatBE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),e.read(this,b,!1,23,4)},h.prototype.readDoubleLE=function(b,E){return b=b>>>0,E||ct(b,8,this.length),e.read(this,b,!0,52,8)},h.prototype.readDoubleBE=function(b,E){return b=b>>>0,E||ct(b,8,this.length),e.read(this,b,!1,52,8)};function dt(O,b,E,D,V,q){if(!h.isBuffer(O))throw new TypeError('"buffer" argument must be a Buffer instance');if(b>V||b<q)throw new RangeError('"value" argument is out of bounds');if(E+D>O.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(b,E,D,V){if(b=+b,E=E>>>0,D=D>>>0,!V){const qt=Math.pow(2,8*D)-1;dt(this,b,E,D,qt,0)}let q=1,st=0;for(this[E]=b&255;++st<D&&(q*=256);)this[E+st]=b/q&255;return E+D},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(b,E,D,V){if(b=+b,E=E>>>0,D=D>>>0,!V){const qt=Math.pow(2,8*D)-1;dt(this,b,E,D,qt,0)}let q=D-1,st=1;for(this[E+q]=b&255;--q>=0&&(st*=256);)this[E+q]=b/st&255;return E+D},h.prototype.writeUint8=h.prototype.writeUInt8=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,1,255,0),this[E]=b&255,E+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,2,65535,0),this[E]=b&255,this[E+1]=b>>>8,E+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,2,65535,0),this[E]=b>>>8,this[E+1]=b&255,E+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,4,4294967295,0),this[E+3]=b>>>24,this[E+2]=b>>>16,this[E+1]=b>>>8,this[E]=b&255,E+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,4,4294967295,0),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=b&255,E+4};function wt(O,b,E,D,V){oe(b,D,V,O,E,7);let q=Number(b&BigInt(4294967295));O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q;let st=Number(b>>BigInt(32)&BigInt(4294967295));return O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,E}function Gt(O,b,E,D,V){oe(b,D,V,O,E,7);let q=Number(b&BigInt(4294967295));O[E+7]=q,q=q>>8,O[E+6]=q,q=q>>8,O[E+5]=q,q=q>>8,O[E+4]=q;let st=Number(b>>BigInt(32)&BigInt(4294967295));return O[E+3]=st,st=st>>8,O[E+2]=st,st=st>>8,O[E+1]=st,st=st>>8,O[E]=st,E+8}h.prototype.writeBigUInt64LE=ur(function(b,E=0){return wt(this,b,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=ur(function(b,E=0){return Gt(this,b,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(b,E,D,V){if(b=+b,E=E>>>0,!V){const Wt=Math.pow(2,8*D-1);dt(this,b,E,D,Wt-1,-Wt)}let q=0,st=1,qt=0;for(this[E]=b&255;++q<D&&(st*=256);)b<0&&qt===0&&this[E+q-1]!==0&&(qt=1),this[E+q]=(b/st>>0)-qt&255;return E+D},h.prototype.writeIntBE=function(b,E,D,V){if(b=+b,E=E>>>0,!V){const Wt=Math.pow(2,8*D-1);dt(this,b,E,D,Wt-1,-Wt)}let q=D-1,st=1,qt=0;for(this[E+q]=b&255;--q>=0&&(st*=256);)b<0&&qt===0&&this[E+q+1]!==0&&(qt=1),this[E+q]=(b/st>>0)-qt&255;return E+D},h.prototype.writeInt8=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,1,127,-128),b<0&&(b=255+b+1),this[E]=b&255,E+1},h.prototype.writeInt16LE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,2,32767,-32768),this[E]=b&255,this[E+1]=b>>>8,E+2},h.prototype.writeInt16BE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,2,32767,-32768),this[E]=b>>>8,this[E+1]=b&255,E+2},h.prototype.writeInt32LE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,4,2147483647,-2147483648),this[E]=b&255,this[E+1]=b>>>8,this[E+2]=b>>>16,this[E+3]=b>>>24,E+4},h.prototype.writeInt32BE=function(b,E,D){return b=+b,E=E>>>0,D||dt(this,b,E,4,2147483647,-2147483648),b<0&&(b=4294967295+b+1),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=b&255,E+4},h.prototype.writeBigInt64LE=ur(function(b,E=0){return wt(this,b,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=ur(function(b,E=0){return Gt(this,b,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ut(O,b,E,D,V,q){if(E+D>O.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function Lt(O,b,E,D,V){return b=+b,E=E>>>0,V||Ut(O,b,E,4),e.write(O,b,E,D,23,4),E+4}h.prototype.writeFloatLE=function(b,E,D){return Lt(this,b,E,!0,D)},h.prototype.writeFloatBE=function(b,E,D){return Lt(this,b,E,!1,D)};function Re(O,b,E,D,V){return b=+b,E=E>>>0,V||Ut(O,b,E,8),e.write(O,b,E,D,52,8),E+8}h.prototype.writeDoubleLE=function(b,E,D){return Re(this,b,E,!0,D)},h.prototype.writeDoubleBE=function(b,E,D){return Re(this,b,E,!1,D)},h.prototype.copy=function(b,E,D,V){if(!h.isBuffer(b))throw new TypeError("argument should be a Buffer");if(D||(D=0),!V&&V!==0&&(V=this.length),E>=b.length&&(E=b.length),E||(E=0),V>0&&V<D&&(V=D),V===D||b.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(D<0||D>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),b.length-E<V-D&&(V=b.length-E+D);const q=V-D;return this===b&&typeof s.prototype.copyWithin=="function"?this.copyWithin(E,D,V):s.prototype.set.call(b,this.subarray(D,V),E),q},h.prototype.fill=function(b,E,D,V){if(typeof b=="string"){if(typeof E=="string"?(V=E,E=0,D=this.length):typeof D=="string"&&(V=D,D=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!h.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(b.length===1){const st=b.charCodeAt(0);(V==="utf8"&&st<128||V==="latin1")&&(b=st)}}else typeof b=="number"?b=b&255:typeof b=="boolean"&&(b=Number(b));if(E<0||this.length<E||this.length<D)throw new RangeError("Out of range index");if(D<=E)return this;E=E>>>0,D=D===void 0?this.length:D>>>0,b||(b=0);let q;if(typeof b=="number")for(q=E;q<D;++q)this[q]=b;else{const st=h.isBuffer(b)?b:h.from(b,V),qt=st.length;if(qt===0)throw new TypeError('The value "'+b+'" is invalid for argument "value"');for(q=0;q<D-E;++q)this[q+E]=st[q%qt]}return this};const Kt={};function Ft(O,b,E){Kt[O]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:b.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${O}]`,this.stack,delete this.name}get code(){return O}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${O}]: ${this.message}`}}}Ft("ERR_BUFFER_OUT_OF_BOUNDS",function(O){return O?`${O} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ft("ERR_INVALID_ARG_TYPE",function(O,b){return`The "${O}" argument must be of type number. Received type ${typeof b}`},TypeError),Ft("ERR_OUT_OF_RANGE",function(O,b,E){let D=`The value of "${O}" is out of range.`,V=E;return Number.isInteger(E)&&Math.abs(E)>2**32?V=Te(String(E)):typeof E=="bigint"&&(V=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(V=Te(V)),V+="n"),D+=` It must be ${b}. Received ${V}`,D},RangeError);function Te(O){let b="",E=O.length;const D=O[0]==="-"?1:0;for(;E>=D+4;E-=3)b=`_${O.slice(E-3,E)}${b}`;return`${O.slice(0,E)}${b}`}function re(O,b,E){sn(b,"offset"),(O[b]===void 0||O[b+E]===void 0)&&fe(b,O.length-(E+1))}function oe(O,b,E,D,V,q){if(O>E||O<b){const st=typeof b=="bigint"?"n":"";let qt;throw b===0||b===BigInt(0)?qt=`>= 0${st} and < 2${st} ** ${(q+1)*8}${st}`:qt=`>= -(2${st} ** ${(q+1)*8-1}${st}) and < 2 ** ${(q+1)*8-1}${st}`,new Kt.ERR_OUT_OF_RANGE("value",qt,O)}re(D,V,q)}function sn(O,b){if(typeof O!="number")throw new Kt.ERR_INVALID_ARG_TYPE(b,"number",O)}function fe(O,b,E){throw Math.floor(O)!==O?(sn(O,E),new Kt.ERR_OUT_OF_RANGE("offset","an integer",O)):b<0?new Kt.ERR_BUFFER_OUT_OF_BOUNDS:new Kt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${b}`,O)}const De=/[^+/0-9A-Za-z-_]/g;function ua(O){if(O=O.split("=")[0],O=O.trim().replace(De,""),O.length<2)return"";for(;O.length%4!==0;)O=O+"=";return O}function Ie(O,b){b=b||1/0;let E;const D=O.length;let V=null;const q=[];for(let st=0;st<D;++st){if(E=O.charCodeAt(st),E>55295&&E<57344){if(!V){if(E>56319){(b-=3)>-1&&q.push(239,191,189);continue}else if(st+1===D){(b-=3)>-1&&q.push(239,191,189);continue}V=E;continue}if(E<56320){(b-=3)>-1&&q.push(239,191,189),V=E;continue}E=(V-55296<<10|E-56320)+65536}else V&&(b-=3)>-1&&q.push(239,191,189);if(V=null,E<128){if((b-=1)<0)break;q.push(E)}else if(E<2048){if((b-=2)<0)break;q.push(E>>6|192,E&63|128)}else if(E<65536){if((b-=3)<0)break;q.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((b-=4)<0)break;q.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return q}function Be(O){const b=[];for(let E=0;E<O.length;++E)b.push(O.charCodeAt(E)&255);return b}function kn(O,b){let E,D,V;const q=[];for(let st=0;st<O.length&&!((b-=2)<0);++st)E=O.charCodeAt(st),D=E>>8,V=E%256,q.push(V),q.push(D);return q}function he(O){return t.toByteArray(ua(O))}function Se(O,b,E,D){let V;for(V=0;V<D&&!(V+E>=b.length||V>=O.length);++V)b[V+E]=O[V];return V}function on(O,b){return O instanceof b||O!=null&&O.constructor!=null&&O.constructor.name!=null&&O.constructor.name===b.name}function ve(O){return O!==O}const Pe=function(){const O="0123456789abcdef",b=new Array(256);for(let E=0;E<16;++E){const D=E*16;for(let V=0;V<16;++V)b[D+V]=O[E]+O[V]}return b}();function ur(O){return typeof BigInt>"u"?Fe:O}function Fe(){throw new Error("BigInt not supported")}})(Mg);const Zt=Mg.Buffer,kt=Mg.Buffer,pP=Object.freeze(Object.defineProperty({__proto__:null,Buffer:kt,default:Zt},Symbol.toStringTag,{value:"Module"}));var Dg={exports:{}};const Fg=Lc(pP);Dg.exports,function(n){(function(t,e){function r(C,p){if(!C)throw new Error(p||"Assertion failed")}function i(C,p){C.super_=p;var m=function(){};m.prototype=p.prototype,C.prototype=new m,C.prototype.constructor=C}function s(C,p,m){if(s.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(C||0,p||10,m||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Fg.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,v){if(typeof p=="number")return this._initNumber(p,m,v);if(typeof p=="object")return this._initArray(p,m,v);m==="hex"&&(m=16),r(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var k=0;p[0]==="-"&&(k++,this.negative=1),k<p.length&&(m===16?this._parseHex(p,k,v):(this._parseBase(p,m,k),v==="le"&&this._initArray(this.toArray(),m,v)))},s.prototype._initNumber=function(p,m,v){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(r(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),m,v)},s.prototype._initArray=function(p,m,v){if(r(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var N,M,z=0;if(v==="be")for(k=p.length-1,N=0;k>=0;k-=3)M=p[k]|p[k-1]<<8|p[k-2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);else if(v==="le")for(k=0,N=0;k<p.length;k+=3)M=p[k]|p[k+1]<<8|p[k+2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);return this._strip()};function a(C,p){var m=C.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;r(!1,"Invalid character in "+C)}function u(C,p,m){var v=a(C,m);return m-1>=p&&(v|=a(C,m-1)<<4),v}s.prototype._parseHex=function(p,m,v){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var N=0,M=0,z;if(v==="be")for(k=p.length-1;k>=m;k-=2)z=u(p,m,k)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8;else{var P=p.length-m;for(k=P%2===0?m+1:m;k<p.length;k+=2)z=u(p,m,k)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8}this._strip()};function f(C,p,m,v){for(var k=0,N=0,M=Math.min(C.length,m),z=p;z<M;z++){var P=C.charCodeAt(z)-48;k*=v,P>=49?N=P-49+10:P>=17?N=P-17+10:N=P,r(P>=0&&N<v,"Invalid character"),k+=N}return k}s.prototype._parseBase=function(p,m,v){this.words=[0],this.length=1;for(var k=0,N=1;N<=67108863;N*=m)k++;k--,N=N/m|0;for(var M=p.length-v,z=M%k,P=Math.min(M,M-z)+v,A=0,$=v;$<P;$+=k)A=f(p,$,$+k,m),this.imuln(N),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A);if(z!==0){var ct=1;for(A=f(p,$,p.length,m),$=0;$<z;$++)ct*=m;this.imuln(ct),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(C,p){C.words=p.words,C.length=p.length,C.negative=p.negative,C.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var _=["","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],R=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var v;if(p===16||p==="hex"){v="";for(var k=0,N=0,M=0;M<this.length;M++){var z=this.words[M],P=((z<<k|N)&16777215).toString(16);N=z>>>24-k&16777215,k+=2,k>=26&&(k-=26,M--),N!==0||M!==this.length-1?v=_[6-P.length]+P+v:v=P+v}for(N!==0&&(v=N.toString(16)+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(p===(p|0)&&p>=2&&p<=36){var A=w[p],$=R[p];v="";var ct=this.clone();for(ct.negative=0;!ct.isZero();){var dt=ct.modrn($).toString(p);ct=ct.idivn($),ct.isZero()?v=dt+v:v=_[A-dt.length]+dt+v}for(this.isZero()&&(v="0"+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var T=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,v){this._strip();var k=this.byteLength(),N=v||Math.max(1,k);r(k<=N,"byte array longer than desired length"),r(N>0,"Requested array length <= 0");var M=T(p,N),z=m==="le"?"LE":"BE";return this["_toArrayLike"+z](M,k),M},s.prototype._toArrayLikeLE=function(p,m){for(var v=0,k=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|k;p[v++]=z&255,v<p.length&&(p[v++]=z>>8&255),v<p.length&&(p[v++]=z>>16&255),M===6?(v<p.length&&(p[v++]=z>>24&255),k=0,M=0):(k=z>>>24,M+=2)}if(v<p.length)for(p[v++]=k;v<p.length;)p[v++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var v=p.length-1,k=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|k;p[v--]=z&255,v>=0&&(p[v--]=z>>8&255),v>=0&&(p[v--]=z>>16&255),M===6?(v>=0&&(p[v--]=z>>24&255),k=0,M=0):(k=z>>>24,M+=2)}if(v>=0)for(p[v--]=k;v>=0;)p[v--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,v=0;return m>=4096&&(v+=13,m>>>=13),m>=64&&(v+=7,m>>>=7),m>=8&&(v+=4,m>>>=4),m>=2&&(v+=2,m>>>=2),v+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,v=0;return m&8191||(v+=13,m>>>=13),m&127||(v+=7,m>>>=7),m&15||(v+=4,m>>>=4),m&3||(v+=2,m>>>=2),m&1||v++,v},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function I(C){for(var p=new Array(C.bitLength()),m=0;m<p.length;m++){var v=m/26|0,k=m%26;p[m]=C.words[v]>>>k&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var v=this._zeroBits(this.words[m]);if(p+=v,v!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return r((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var v=0;v<m.length;v++)this.words[v]=this.words[v]&p.words[v];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return r((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,v;this.length>p.length?(m=this,v=p):(m=p,v=this);for(var k=0;k<v.length;k++)this.words[k]=m.words[k]^v.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 r((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){r(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,v=p%26;this._expand(m),v>0&&m--;for(var k=0;k<m;k++)this.words[k]=~this.words[k]&67108863;return v>0&&(this.words[k]=~this.words[k]&67108863>>26-v),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){r(typeof p=="number"&&p>=0);var v=p/26|0,k=p%26;return this._expand(v+1),m?this.words[v]=this.words[v]|1<<k:this.words[v]=this.words[v]&~(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 v,k;this.length>p.length?(v=this,k=p):(v=p,k=this);for(var N=0,M=0;M<k.length;M++)m=(v.words[M]|0)+(k.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;for(;N!==0&&M<v.length;M++)m=(v.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;if(this.length=v.length,N!==0)this.words[this.length]=N,this.length++;else if(v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var v=this.cmp(p);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,N;v>0?(k=this,N=p):(k=p,N=this);for(var M=0,z=0;z<N.length;z++)m=(k.words[z]|0)-(N.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;for(;M!==0&&z<k.length;z++)m=(k.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;if(M===0&&z<k.length&&k!==this)for(;z<k.length;z++)this.words[z]=k.words[z];return this.length=Math.max(this.length,z),k!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function B(C,p,m){m.negative=p.negative^C.negative;var v=C.length+p.length|0;m.length=v,v=v-1|0;var k=C.words[0]|0,N=p.words[0]|0,M=k*N,z=M&67108863,P=M/67108864|0;m.words[0]=z;for(var A=1;A<v;A++){for(var $=P>>>26,ct=P&67108863,dt=Math.min(A,p.length-1),wt=Math.max(0,A-C.length+1);wt<=dt;wt++){var Gt=A-wt|0;k=C.words[Gt]|0,N=p.words[wt]|0,M=k*N+ct,$+=M/67108864|0,ct=M&67108863}m.words[A]=ct|0,P=$|0}return P!==0?m.words[A]=P|0:m.length--,m._strip()}var H=function(p,m,v){var k=p.words,N=m.words,M=v.words,z=0,P,A,$,ct=k[0]|0,dt=ct&8191,wt=ct>>>13,Gt=k[1]|0,Ut=Gt&8191,Lt=Gt>>>13,Re=k[2]|0,Kt=Re&8191,Ft=Re>>>13,Te=k[3]|0,re=Te&8191,oe=Te>>>13,sn=k[4]|0,fe=sn&8191,De=sn>>>13,ua=k[5]|0,Ie=ua&8191,Be=ua>>>13,kn=k[6]|0,he=kn&8191,Se=kn>>>13,on=k[7]|0,ve=on&8191,Pe=on>>>13,ur=k[8]|0,Fe=ur&8191,O=ur>>>13,b=k[9]|0,E=b&8191,D=b>>>13,V=N[0]|0,q=V&8191,st=V>>>13,qt=N[1]|0,Wt=qt&8191,jt=qt>>>13,$e=N[2]|0,Ht=$e&8191,fn=$e>>>13,Gp=N[3]|0,hn=Gp&8191,dn=Gp>>>13,Vp=N[4]|0,an=Vp&8191,pn=Vp>>>13,Kp=N[5]|0,cn=Kp&8191,gn=Kp>>>13,Nc=N[6]|0,Je=Nc&8191,yn=Nc>>>13,jp=N[7]|0,mn=jp&8191,wn=jp>>>13,Wp=N[8]|0,bn=Wp&8191,_n=Wp>>>13,Cc=N[9]|0,An=Cc&8191,En=Cc>>>13;v.negative=p.negative^m.negative,v.length=19,P=Math.imul(dt,q),A=Math.imul(dt,st),A=A+Math.imul(wt,q)|0,$=Math.imul(wt,st);var Wh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Wh>>>26)|0,Wh&=67108863,P=Math.imul(Ut,q),A=Math.imul(Ut,st),A=A+Math.imul(Lt,q)|0,$=Math.imul(Lt,st),P=P+Math.imul(dt,Wt)|0,A=A+Math.imul(dt,jt)|0,A=A+Math.imul(wt,Wt)|0,$=$+Math.imul(wt,jt)|0;var Vl=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,P=Math.imul(Kt,q),A=Math.imul(Kt,st),A=A+Math.imul(Ft,q)|0,$=Math.imul(Ft,st),P=P+Math.imul(Ut,Wt)|0,A=A+Math.imul(Ut,jt)|0,A=A+Math.imul(Lt,Wt)|0,$=$+Math.imul(Lt,jt)|0,P=P+Math.imul(dt,Ht)|0,A=A+Math.imul(dt,fn)|0,A=A+Math.imul(wt,Ht)|0,$=$+Math.imul(wt,fn)|0;var Zh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Zh>>>26)|0,Zh&=67108863,P=Math.imul(re,q),A=Math.imul(re,st),A=A+Math.imul(oe,q)|0,$=Math.imul(oe,st),P=P+Math.imul(Kt,Wt)|0,A=A+Math.imul(Kt,jt)|0,A=A+Math.imul(Ft,Wt)|0,$=$+Math.imul(Ft,jt)|0,P=P+Math.imul(Ut,Ht)|0,A=A+Math.imul(Ut,fn)|0,A=A+Math.imul(Lt,Ht)|0,$=$+Math.imul(Lt,fn)|0,P=P+Math.imul(dt,hn)|0,A=A+Math.imul(dt,dn)|0,A=A+Math.imul(wt,hn)|0,$=$+Math.imul(wt,dn)|0;var qh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(qh>>>26)|0,qh&=67108863,P=Math.imul(fe,q),A=Math.imul(fe,st),A=A+Math.imul(De,q)|0,$=Math.imul(De,st),P=P+Math.imul(re,Wt)|0,A=A+Math.imul(re,jt)|0,A=A+Math.imul(oe,Wt)|0,$=$+Math.imul(oe,jt)|0,P=P+Math.imul(Kt,Ht)|0,A=A+Math.imul(Kt,fn)|0,A=A+Math.imul(Ft,Ht)|0,$=$+Math.imul(Ft,fn)|0,P=P+Math.imul(Ut,hn)|0,A=A+Math.imul(Ut,dn)|0,A=A+Math.imul(Lt,hn)|0,$=$+Math.imul(Lt,dn)|0,P=P+Math.imul(dt,an)|0,A=A+Math.imul(dt,pn)|0,A=A+Math.imul(wt,an)|0,$=$+Math.imul(wt,pn)|0;var Qh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Qh>>>26)|0,Qh&=67108863,P=Math.imul(Ie,q),A=Math.imul(Ie,st),A=A+Math.imul(Be,q)|0,$=Math.imul(Be,st),P=P+Math.imul(fe,Wt)|0,A=A+Math.imul(fe,jt)|0,A=A+Math.imul(De,Wt)|0,$=$+Math.imul(De,jt)|0,P=P+Math.imul(re,Ht)|0,A=A+Math.imul(re,fn)|0,A=A+Math.imul(oe,Ht)|0,$=$+Math.imul(oe,fn)|0,P=P+Math.imul(Kt,hn)|0,A=A+Math.imul(Kt,dn)|0,A=A+Math.imul(Ft,hn)|0,$=$+Math.imul(Ft,dn)|0,P=P+Math.imul(Ut,an)|0,A=A+Math.imul(Ut,pn)|0,A=A+Math.imul(Lt,an)|0,$=$+Math.imul(Lt,pn)|0,P=P+Math.imul(dt,cn)|0,A=A+Math.imul(dt,gn)|0,A=A+Math.imul(wt,cn)|0,$=$+Math.imul(wt,gn)|0;var Yh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Yh>>>26)|0,Yh&=67108863,P=Math.imul(he,q),A=Math.imul(he,st),A=A+Math.imul(Se,q)|0,$=Math.imul(Se,st),P=P+Math.imul(Ie,Wt)|0,A=A+Math.imul(Ie,jt)|0,A=A+Math.imul(Be,Wt)|0,$=$+Math.imul(Be,jt)|0,P=P+Math.imul(fe,Ht)|0,A=A+Math.imul(fe,fn)|0,A=A+Math.imul(De,Ht)|0,$=$+Math.imul(De,fn)|0,P=P+Math.imul(re,hn)|0,A=A+Math.imul(re,dn)|0,A=A+Math.imul(oe,hn)|0,$=$+Math.imul(oe,dn)|0,P=P+Math.imul(Kt,an)|0,A=A+Math.imul(Kt,pn)|0,A=A+Math.imul(Ft,an)|0,$=$+Math.imul(Ft,pn)|0,P=P+Math.imul(Ut,cn)|0,A=A+Math.imul(Ut,gn)|0,A=A+Math.imul(Lt,cn)|0,$=$+Math.imul(Lt,gn)|0,P=P+Math.imul(dt,Je)|0,A=A+Math.imul(dt,yn)|0,A=A+Math.imul(wt,Je)|0,$=$+Math.imul(wt,yn)|0;var Kl=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Kl>>>26)|0,Kl&=67108863,P=Math.imul(ve,q),A=Math.imul(ve,st),A=A+Math.imul(Pe,q)|0,$=Math.imul(Pe,st),P=P+Math.imul(he,Wt)|0,A=A+Math.imul(he,jt)|0,A=A+Math.imul(Se,Wt)|0,$=$+Math.imul(Se,jt)|0,P=P+Math.imul(Ie,Ht)|0,A=A+Math.imul(Ie,fn)|0,A=A+Math.imul(Be,Ht)|0,$=$+Math.imul(Be,fn)|0,P=P+Math.imul(fe,hn)|0,A=A+Math.imul(fe,dn)|0,A=A+Math.imul(De,hn)|0,$=$+Math.imul(De,dn)|0,P=P+Math.imul(re,an)|0,A=A+Math.imul(re,pn)|0,A=A+Math.imul(oe,an)|0,$=$+Math.imul(oe,pn)|0,P=P+Math.imul(Kt,cn)|0,A=A+Math.imul(Kt,gn)|0,A=A+Math.imul(Ft,cn)|0,$=$+Math.imul(Ft,gn)|0,P=P+Math.imul(Ut,Je)|0,A=A+Math.imul(Ut,yn)|0,A=A+Math.imul(Lt,Je)|0,$=$+Math.imul(Lt,yn)|0,P=P+Math.imul(dt,mn)|0,A=A+Math.imul(dt,wn)|0,A=A+Math.imul(wt,mn)|0,$=$+Math.imul(wt,wn)|0;var Jh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Jh>>>26)|0,Jh&=67108863,P=Math.imul(Fe,q),A=Math.imul(Fe,st),A=A+Math.imul(O,q)|0,$=Math.imul(O,st),P=P+Math.imul(ve,Wt)|0,A=A+Math.imul(ve,jt)|0,A=A+Math.imul(Pe,Wt)|0,$=$+Math.imul(Pe,jt)|0,P=P+Math.imul(he,Ht)|0,A=A+Math.imul(he,fn)|0,A=A+Math.imul(Se,Ht)|0,$=$+Math.imul(Se,fn)|0,P=P+Math.imul(Ie,hn)|0,A=A+Math.imul(Ie,dn)|0,A=A+Math.imul(Be,hn)|0,$=$+Math.imul(Be,dn)|0,P=P+Math.imul(fe,an)|0,A=A+Math.imul(fe,pn)|0,A=A+Math.imul(De,an)|0,$=$+Math.imul(De,pn)|0,P=P+Math.imul(re,cn)|0,A=A+Math.imul(re,gn)|0,A=A+Math.imul(oe,cn)|0,$=$+Math.imul(oe,gn)|0,P=P+Math.imul(Kt,Je)|0,A=A+Math.imul(Kt,yn)|0,A=A+Math.imul(Ft,Je)|0,$=$+Math.imul(Ft,yn)|0,P=P+Math.imul(Ut,mn)|0,A=A+Math.imul(Ut,wn)|0,A=A+Math.imul(Lt,mn)|0,$=$+Math.imul(Lt,wn)|0,P=P+Math.imul(dt,bn)|0,A=A+Math.imul(dt,_n)|0,A=A+Math.imul(wt,bn)|0,$=$+Math.imul(wt,_n)|0;var so=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(so>>>26)|0,so&=67108863,P=Math.imul(E,q),A=Math.imul(E,st),A=A+Math.imul(D,q)|0,$=Math.imul(D,st),P=P+Math.imul(Fe,Wt)|0,A=A+Math.imul(Fe,jt)|0,A=A+Math.imul(O,Wt)|0,$=$+Math.imul(O,jt)|0,P=P+Math.imul(ve,Ht)|0,A=A+Math.imul(ve,fn)|0,A=A+Math.imul(Pe,Ht)|0,$=$+Math.imul(Pe,fn)|0,P=P+Math.imul(he,hn)|0,A=A+Math.imul(he,dn)|0,A=A+Math.imul(Se,hn)|0,$=$+Math.imul(Se,dn)|0,P=P+Math.imul(Ie,an)|0,A=A+Math.imul(Ie,pn)|0,A=A+Math.imul(Be,an)|0,$=$+Math.imul(Be,pn)|0,P=P+Math.imul(fe,cn)|0,A=A+Math.imul(fe,gn)|0,A=A+Math.imul(De,cn)|0,$=$+Math.imul(De,gn)|0,P=P+Math.imul(re,Je)|0,A=A+Math.imul(re,yn)|0,A=A+Math.imul(oe,Je)|0,$=$+Math.imul(oe,yn)|0,P=P+Math.imul(Kt,mn)|0,A=A+Math.imul(Kt,wn)|0,A=A+Math.imul(Ft,mn)|0,$=$+Math.imul(Ft,wn)|0,P=P+Math.imul(Ut,bn)|0,A=A+Math.imul(Ut,_n)|0,A=A+Math.imul(Lt,bn)|0,$=$+Math.imul(Lt,_n)|0,P=P+Math.imul(dt,An)|0,A=A+Math.imul(dt,En)|0,A=A+Math.imul(wt,An)|0,$=$+Math.imul(wt,En)|0;var Xh=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Xh>>>26)|0,Xh&=67108863,P=Math.imul(E,Wt),A=Math.imul(E,jt),A=A+Math.imul(D,Wt)|0,$=Math.imul(D,jt),P=P+Math.imul(Fe,Ht)|0,A=A+Math.imul(Fe,fn)|0,A=A+Math.imul(O,Ht)|0,$=$+Math.imul(O,fn)|0,P=P+Math.imul(ve,hn)|0,A=A+Math.imul(ve,dn)|0,A=A+Math.imul(Pe,hn)|0,$=$+Math.imul(Pe,dn)|0,P=P+Math.imul(he,an)|0,A=A+Math.imul(he,pn)|0,A=A+Math.imul(Se,an)|0,$=$+Math.imul(Se,pn)|0,P=P+Math.imul(Ie,cn)|0,A=A+Math.imul(Ie,gn)|0,A=A+Math.imul(Be,cn)|0,$=$+Math.imul(Be,gn)|0,P=P+Math.imul(fe,Je)|0,A=A+Math.imul(fe,yn)|0,A=A+Math.imul(De,Je)|0,$=$+Math.imul(De,yn)|0,P=P+Math.imul(re,mn)|0,A=A+Math.imul(re,wn)|0,A=A+Math.imul(oe,mn)|0,$=$+Math.imul(oe,wn)|0,P=P+Math.imul(Kt,bn)|0,A=A+Math.imul(Kt,_n)|0,A=A+Math.imul(Ft,bn)|0,$=$+Math.imul(Ft,_n)|0,P=P+Math.imul(Ut,An)|0,A=A+Math.imul(Ut,En)|0,A=A+Math.imul(Lt,An)|0,$=$+Math.imul(Lt,En)|0;var Pi=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,P=Math.imul(E,Ht),A=Math.imul(E,fn),A=A+Math.imul(D,Ht)|0,$=Math.imul(D,fn),P=P+Math.imul(Fe,hn)|0,A=A+Math.imul(Fe,dn)|0,A=A+Math.imul(O,hn)|0,$=$+Math.imul(O,dn)|0,P=P+Math.imul(ve,an)|0,A=A+Math.imul(ve,pn)|0,A=A+Math.imul(Pe,an)|0,$=$+Math.imul(Pe,pn)|0,P=P+Math.imul(he,cn)|0,A=A+Math.imul(he,gn)|0,A=A+Math.imul(Se,cn)|0,$=$+Math.imul(Se,gn)|0,P=P+Math.imul(Ie,Je)|0,A=A+Math.imul(Ie,yn)|0,A=A+Math.imul(Be,Je)|0,$=$+Math.imul(Be,yn)|0,P=P+Math.imul(fe,mn)|0,A=A+Math.imul(fe,wn)|0,A=A+Math.imul(De,mn)|0,$=$+Math.imul(De,wn)|0,P=P+Math.imul(re,bn)|0,A=A+Math.imul(re,_n)|0,A=A+Math.imul(oe,bn)|0,$=$+Math.imul(oe,_n)|0,P=P+Math.imul(Kt,An)|0,A=A+Math.imul(Kt,En)|0,A=A+Math.imul(Ft,An)|0,$=$+Math.imul(Ft,En)|0;var td=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(td>>>26)|0,td&=67108863,P=Math.imul(E,hn),A=Math.imul(E,dn),A=A+Math.imul(D,hn)|0,$=Math.imul(D,dn),P=P+Math.imul(Fe,an)|0,A=A+Math.imul(Fe,pn)|0,A=A+Math.imul(O,an)|0,$=$+Math.imul(O,pn)|0,P=P+Math.imul(ve,cn)|0,A=A+Math.imul(ve,gn)|0,A=A+Math.imul(Pe,cn)|0,$=$+Math.imul(Pe,gn)|0,P=P+Math.imul(he,Je)|0,A=A+Math.imul(he,yn)|0,A=A+Math.imul(Se,Je)|0,$=$+Math.imul(Se,yn)|0,P=P+Math.imul(Ie,mn)|0,A=A+Math.imul(Ie,wn)|0,A=A+Math.imul(Be,mn)|0,$=$+Math.imul(Be,wn)|0,P=P+Math.imul(fe,bn)|0,A=A+Math.imul(fe,_n)|0,A=A+Math.imul(De,bn)|0,$=$+Math.imul(De,_n)|0,P=P+Math.imul(re,An)|0,A=A+Math.imul(re,En)|0,A=A+Math.imul(oe,An)|0,$=$+Math.imul(oe,En)|0;var ed=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(ed>>>26)|0,ed&=67108863,P=Math.imul(E,an),A=Math.imul(E,pn),A=A+Math.imul(D,an)|0,$=Math.imul(D,pn),P=P+Math.imul(Fe,cn)|0,A=A+Math.imul(Fe,gn)|0,A=A+Math.imul(O,cn)|0,$=$+Math.imul(O,gn)|0,P=P+Math.imul(ve,Je)|0,A=A+Math.imul(ve,yn)|0,A=A+Math.imul(Pe,Je)|0,$=$+Math.imul(Pe,yn)|0,P=P+Math.imul(he,mn)|0,A=A+Math.imul(he,wn)|0,A=A+Math.imul(Se,mn)|0,$=$+Math.imul(Se,wn)|0,P=P+Math.imul(Ie,bn)|0,A=A+Math.imul(Ie,_n)|0,A=A+Math.imul(Be,bn)|0,$=$+Math.imul(Be,_n)|0,P=P+Math.imul(fe,An)|0,A=A+Math.imul(fe,En)|0,A=A+Math.imul(De,An)|0,$=$+Math.imul(De,En)|0;var jl=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(jl>>>26)|0,jl&=67108863,P=Math.imul(E,cn),A=Math.imul(E,gn),A=A+Math.imul(D,cn)|0,$=Math.imul(D,gn),P=P+Math.imul(Fe,Je)|0,A=A+Math.imul(Fe,yn)|0,A=A+Math.imul(O,Je)|0,$=$+Math.imul(O,yn)|0,P=P+Math.imul(ve,mn)|0,A=A+Math.imul(ve,wn)|0,A=A+Math.imul(Pe,mn)|0,$=$+Math.imul(Pe,wn)|0,P=P+Math.imul(he,bn)|0,A=A+Math.imul(he,_n)|0,A=A+Math.imul(Se,bn)|0,$=$+Math.imul(Se,_n)|0,P=P+Math.imul(Ie,An)|0,A=A+Math.imul(Ie,En)|0,A=A+Math.imul(Be,An)|0,$=$+Math.imul(Be,En)|0;var nd=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(nd>>>26)|0,nd&=67108863,P=Math.imul(E,Je),A=Math.imul(E,yn),A=A+Math.imul(D,Je)|0,$=Math.imul(D,yn),P=P+Math.imul(Fe,mn)|0,A=A+Math.imul(Fe,wn)|0,A=A+Math.imul(O,mn)|0,$=$+Math.imul(O,wn)|0,P=P+Math.imul(ve,bn)|0,A=A+Math.imul(ve,_n)|0,A=A+Math.imul(Pe,bn)|0,$=$+Math.imul(Pe,_n)|0,P=P+Math.imul(he,An)|0,A=A+Math.imul(he,En)|0,A=A+Math.imul(Se,An)|0,$=$+Math.imul(Se,En)|0;var rd=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(rd>>>26)|0,rd&=67108863,P=Math.imul(E,mn),A=Math.imul(E,wn),A=A+Math.imul(D,mn)|0,$=Math.imul(D,wn),P=P+Math.imul(Fe,bn)|0,A=A+Math.imul(Fe,_n)|0,A=A+Math.imul(O,bn)|0,$=$+Math.imul(O,_n)|0,P=P+Math.imul(ve,An)|0,A=A+Math.imul(ve,En)|0,A=A+Math.imul(Pe,An)|0,$=$+Math.imul(Pe,En)|0;var id=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(id>>>26)|0,id&=67108863,P=Math.imul(E,bn),A=Math.imul(E,_n),A=A+Math.imul(D,bn)|0,$=Math.imul(D,_n),P=P+Math.imul(Fe,An)|0,A=A+Math.imul(Fe,En)|0,A=A+Math.imul(O,An)|0,$=$+Math.imul(O,En)|0;var sd=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(sd>>>26)|0,sd&=67108863,P=Math.imul(E,An),A=Math.imul(E,En),A=A+Math.imul(D,An)|0,$=Math.imul(D,En);var la=(z+P|0)+((A&8191)<<13)|0;return z=($+(A>>>13)|0)+(la>>>26)|0,la&=67108863,M[0]=Wh,M[1]=Vl,M[2]=Zh,M[3]=qh,M[4]=Qh,M[5]=Yh,M[6]=Kl,M[7]=Jh,M[8]=so,M[9]=Xh,M[10]=Pi,M[11]=td,M[12]=ed,M[13]=jl,M[14]=nd,M[15]=rd,M[16]=id,M[17]=sd,M[18]=la,z!==0&&(M[19]=z,v.length++),v};Math.imul||(H=B);function U(C,p,m){m.negative=p.negative^C.negative,m.length=C.length+p.length;for(var v=0,k=0,N=0;N<m.length-1;N++){var M=k;k=0;for(var z=v&67108863,P=Math.min(N,p.length-1),A=Math.max(0,N-C.length+1);A<=P;A++){var $=N-A,ct=C.words[$]|0,dt=p.words[A]|0,wt=ct*dt,Gt=wt&67108863;M=M+(wt/67108864|0)|0,Gt=Gt+z|0,z=Gt&67108863,M=M+(Gt>>>26)|0,k+=M>>>26,M&=67108863}m.words[N]=z,v=M,M=k}return v!==0?m.words[N]=v:m.length--,m._strip()}function G(C,p,m){return U(C,p,m)}s.prototype.mulTo=function(p,m){var v,k=this.length+p.length;return this.length===10&&p.length===10?v=H(this,p,m):k<63?v=B(this,p,m):k<1024?v=U(this,p,m):v=G(this,p,m),v},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),G(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),r(typeof p=="number"),r(p<67108864);for(var v=0,k=0;k<this.length;k++){var N=(this.words[k]|0)*p,M=(N&67108863)+(v&67108863);v>>=26,v+=N/67108864|0,v+=M>>>26,this.words[k]=M&67108863}return v!==0&&(this.words[k]=v,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=I(p);if(m.length===0)return new s(1);for(var v=this,k=0;k<m.length&&m[k]===0;k++,v=v.sqr());if(++k<m.length)for(var N=v.sqr();k<m.length;k++,N=N.sqr())m[k]!==0&&(v=v.mul(N));return v},s.prototype.iushln=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,k=67108863>>>26-m<<26-m,N;if(m!==0){var M=0;for(N=0;N<this.length;N++){var z=this.words[N]&k,P=(this.words[N]|0)-z<<m;this.words[N]=P|M,M=z>>>26-m}M&&(this.words[N]=M,this.length++)}if(v!==0){for(N=this.length-1;N>=0;N--)this.words[N+v]=this.words[N];for(N=0;N<v;N++)this.words[N]=0;this.length+=v}return this._strip()},s.prototype.ishln=function(p){return r(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,v){r(typeof p=="number"&&p>=0);var k;m?k=(m-m%26)/26:k=0;var N=p%26,M=Math.min((p-N)/26,this.length),z=67108863^67108863>>>N<<N,P=v;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 $=0;for(A=this.length-1;A>=0&&($!==0||A>=k);A--){var ct=this.words[A]|0;this.words[A]=$<<26-N|ct>>>N,$=ct&z}return P&&$!==0&&(P.words[P.length++]=$),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,v){return r(this.negative===0),this.iushrn(p,m,v)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,k=1<<m;if(this.length<=v)return!1;var N=this.words[v];return!!(N&k)},s.prototype.imaskn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(m!==0&&v++,this.length=Math.min(v,this.length),m!==0){var 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 r(typeof p=="number"),r(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(r(typeof p=="number"),r(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,v){var k=p.length+v,N;this._expand(k);var M,z=0;for(N=0;N<p.length;N++){M=(this.words[N+v]|0)+z;var P=(p.words[N]|0)*m;M-=P&67108863,z=(M>>26)-(P/67108864|0),this.words[N+v]=M&67108863}for(;N<this.length-v;N++)M=(this.words[N+v]|0)+z,z=M>>26,this.words[N+v]=M&67108863;if(z===0)return this._strip();for(r(z===-1),z=0,N=0;N<this.length;N++)M=-(this.words[N]|0)+z,z=M>>26,this.words[N]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var v=this.length-p.length,k=this.clone(),N=p,M=N.words[N.length-1]|0,z=this._countBits(M);v=26-z,v!==0&&(N=N.ushln(v),k.iushln(v),M=N.words[N.length-1]|0);var P=k.length-N.length,A;if(m!=="mod"){A=new s(null),A.length=P+1,A.words=new Array(A.length);for(var $=0;$<A.length;$++)A.words[$]=0}var ct=k.clone()._ishlnsubmul(N,1,P);ct.negative===0&&(k=ct,A&&(A.words[P]=1));for(var dt=P-1;dt>=0;dt--){var wt=(k.words[N.length+dt]|0)*67108864+(k.words[N.length+dt-1]|0);for(wt=Math.min(wt/M|0,67108863),k._ishlnsubmul(N,wt,dt);k.negative!==0;)wt--,k.negative=0,k._ishlnsubmul(N,1,dt),k.isZero()||(k.negative^=1);A&&(A.words[dt]=wt)}return A&&A._strip(),k._strip(),m!=="div"&&v!==0&&k.iushrn(v),{div:A||null,mod:k}},s.prototype.divmod=function(p,m,v){if(r(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,N,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(k=M.div.neg()),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.iadd(p)),{div:k,mod:N}):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"&&(N=M.mod.neg(),v&&N.negative!==0&&N.isub(p)),{div:M.div,mod:N}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var v=m.div.negative!==0?m.mod.isub(p):m.mod,k=p.ushrn(1),N=p.andln(1),M=v.cmp(k);return M<0||N===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=(1<<26)%p,k=0,N=this.length-1;N>=0;N--)k=(v*k+(this.words[N]|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),r(p<=67108863);for(var v=0,k=this.length-1;k>=0;k--){var N=(this.words[k]|0)+v*67108864;this.words[k]=N/p|0,v=N%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),N=new s(0),M=new s(0),z=new s(1),P=0;m.isEven()&&v.isEven();)m.iushrn(1),v.iushrn(1),++P;for(var A=v.clone(),$=m.clone();!m.isZero();){for(var ct=0,dt=1;!(m.words[0]&dt)&&ct<26;++ct,dt<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(k.isOdd()||N.isOdd())&&(k.iadd(A),N.isub($)),k.iushrn(1),N.iushrn(1);for(var wt=0,Gt=1;!(v.words[0]&Gt)&&wt<26;++wt,Gt<<=1);if(wt>0)for(v.iushrn(wt);wt-- >0;)(M.isOdd()||z.isOdd())&&(M.iadd(A),z.isub($)),M.iushrn(1),z.iushrn(1);m.cmp(v)>=0?(m.isub(v),k.isub(M),N.isub(z)):(v.isub(m),M.isub(k),z.isub(N))}return{a:M,b:z,gcd:v.iushln(P)}},s.prototype._invmp=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),N=new s(0),M=v.clone();m.cmpn(1)>0&&v.cmpn(1)>0;){for(var z=0,P=1;!(m.words[0]&P)&&z<26;++z,P<<=1);if(z>0)for(m.iushrn(z);z-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);for(var A=0,$=1;!(v.words[0]&$)&&A<26;++A,$<<=1);if(A>0)for(v.iushrn(A);A-- >0;)N.isOdd()&&N.iadd(M),N.iushrn(1);m.cmp(v)>=0?(m.isub(v),k.isub(N)):(v.isub(m),N.isub(k))}var ct;return m.cmpn(1)===0?ct=k:ct=N,ct.cmpn(0)<0&&ct.iadd(p),ct},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),v=p.clone();m.negative=0,v.negative=0;for(var k=0;m.isEven()&&v.isEven();k++)m.iushrn(1),v.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;v.isEven();)v.iushrn(1);var N=m.cmp(v);if(N<0){var M=m;m=v,v=M}else if(N===0||v.cmpn(1)===0)break;m.isub(v)}while(!0);return v.iushln(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){r(typeof p=="number");var m=p%26,v=(p-m)/26,k=1<<m;if(this.length<=v)return this._expand(v+1),this.words[v]|=k,this;for(var N=k,M=v;N!==0&&M<this.length;M++){var z=this.words[M]|0;z+=N,N=z>>>26,z&=67108863,this.words[M]=z}return N!==0&&(this.words[M]=N,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var v;if(this.length>1)v=1;else{m&&(p=-p),r(p<=67108863,"Number is too big");var k=this.words[0]|0;v=k===p?0:k<p?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,v=this.length-1;v>=0;v--){var k=this.words[v]|0,N=p.words[v]|0;if(k!==N){k<N?m=-1:k>N&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new rt(p)},s.prototype.toRed=function(p){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return r(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return r(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var W={k256:null,p224:null,p192:null,p25519:null};function X(C,p){this.name=C,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}X.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},X.prototype.ireduce=function(p){var m=p,v;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),v=m.bitLength();while(v>this.n);var k=v<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},X.prototype.split=function(p,m){p.iushrn(this.n,0,m)},X.prototype.imulK=function(p){return p.imul(this.k)};function j(){X.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,X),j.prototype.split=function(p,m){for(var v=4194303,k=Math.min(p.length,9),N=0;N<k;N++)m.words[N]=p.words[N];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&v,N=10;N<p.length;N++){var z=p.words[N]|0;p.words[N-10]=(z&v)<<4|M>>>22,M=z}M>>>=22,p.words[N-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},j.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,v=0;v<p.length;v++){var k=p.words[v]|0;m+=k*977,p.words[v]=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 J(){X.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(J,X);function it(){X.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(it,X);function ut(){X.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ut,X),ut.prototype.imulK=function(p){for(var m=0,v=0;v<p.length;v++){var k=(p.words[v]|0)*19+m,N=k&67108863;k>>>=26,p.words[v]=N,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 j;else if(p==="p224")m=new J;else if(p==="p192")m=new it;else if(p==="p25519")m=new ut;else throw new Error("Unknown prime "+p);return W[p]=m,m};function rt(C){if(typeof C=="string"){var p=s._prime(C);this.m=p.p,this.prime=p}else r(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}rt.prototype._verify1=function(p){r(p.negative===0,"red works only with positives"),r(p.red,"red works only with red numbers")},rt.prototype._verify2=function(p,m){r((p.negative|m.negative)===0,"red works only with positives"),r(p.red&&p.red===m.red,"red works only with red numbers")},rt.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},rt.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},rt.prototype.add=function(p,m){this._verify2(p,m);var v=p.add(m);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},rt.prototype.iadd=function(p,m){this._verify2(p,m);var v=p.iadd(m);return v.cmp(this.m)>=0&&v.isub(this.m),v},rt.prototype.sub=function(p,m){this._verify2(p,m);var v=p.sub(m);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},rt.prototype.isub=function(p,m){this._verify2(p,m);var v=p.isub(m);return v.cmpn(0)<0&&v.iadd(this.m),v},rt.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},rt.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},rt.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},rt.prototype.isqr=function(p){return this.imul(p,p.clone())},rt.prototype.sqr=function(p){return this.mul(p,p)},rt.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(r(m%2===1),m===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(p,v)}for(var k=this.m.subn(1),N=0;!k.isZero()&&k.andln(1)===0;)N++,k.iushrn(1);r(!k.isZero());var M=new s(1).toRed(this),z=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(z)!==0;)A.redIAdd(z);for(var $=this.pow(A,k),ct=this.pow(p,k.addn(1).iushrn(1)),dt=this.pow(p,k),wt=N;dt.cmp(M)!==0;){for(var Gt=dt,Ut=0;Gt.cmp(M)!==0;Ut++)Gt=Gt.redSqr();r(Ut<wt);var Lt=this.pow($,new s(1).iushln(wt-Ut-1));ct=ct.redMul(Lt),$=Lt.redSqr(),dt=dt.redMul($),wt=Ut}return ct},rt.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},rt.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var v=4,k=new Array(1<<v);k[0]=new s(1).toRed(this),k[1]=p;for(var N=2;N<k.length;N++)k[N]=this.mul(k[N-1],p);var M=k[0],z=0,P=0,A=m.bitLength()%26;for(A===0&&(A=26),N=m.length-1;N>=0;N--){for(var $=m.words[N],ct=A-1;ct>=0;ct--){var dt=$>>ct&1;if(M!==k[0]&&(M=this.sqr(M)),dt===0&&z===0){P=0;continue}z<<=1,z|=dt,P++,!(P!==v&&(N!==0||ct!==0))&&(M=this.mul(M,k[z]),P=0,z=0)}A=26}return M},rt.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},rt.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ot(p)};function ot(C){rt.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ot,rt),ot.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ot.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ot.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var v=p.imul(m),k=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(k).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var v=p.mul(m),k=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(k).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(n,ae)}(Dg);var $g=Dg.exports;const As=Mr($g);function zd(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function gP(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function bf(n,...t){if(!gP(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error("Uint8Array expected of length "+t+", got length="+n.length)}function yP(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");zd(n.outputLen),zd(n.blockLen)}function Yc(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function V_(n,t){bf(n);const e=t.outputLen;if(n.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}const Jc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mP(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}function Hg(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function $i(n,t){return n<<32-t|n>>>t}const K_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wP(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function j_(n){for(let t=0;t<n.length;t++)n[t]=wP(n[t])}function bP(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function Gd(n){return typeof n=="string"&&(n=bP(n)),bf(n),n}function _P(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];bf(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}let zg=class{clone(){return this._cloneInto()}};function Gg(n){const t=r=>n().update(Gd(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function W_(n=32){if(Jc&&typeof Jc.getRandomValues=="function")return Jc.getRandomValues(new Uint8Array(n));if(Jc&&typeof Jc.randomBytes=="function")return Jc.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}function AP(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),a=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,a,r)}function EP(n,t,e){return n&t^~n&e}function vP(n,t,e){return n&t^n&e^t&e}class Z_ extends zg{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Hg(this.buffer)}update(t){Yc(this);const{view:e,buffer:r,blockLen:i}=this;t=Gd(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Hg(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Yc(this),V_(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;AP(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Hg(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)a.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const Vd=BigInt(2**32-1),Vg=BigInt(32);function q_(n,t=!1){return t?{h:Number(n&Vd),l:Number(n>>Vg&Vd)}:{h:Number(n>>Vg&Vd)|0,l:Number(n&Vd)|0}}function Q_(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=q_(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const xP=(n,t)=>BigInt(n>>>0)<<Vg|BigInt(t>>>0),RP=(n,t,e)=>n>>>e,IP=(n,t,e)=>n<<32-e|t>>>e,SP=(n,t,e)=>n>>>e|t<<32-e,kP=(n,t,e)=>n<<32-e|t>>>e,TP=(n,t,e)=>n<<64-e|t>>>e-32,OP=(n,t,e)=>n>>>e-32|t<<64-e,NP=(n,t)=>t,CP=(n,t)=>n,Y_=(n,t,e)=>n<<e|t>>>32-e,J_=(n,t,e)=>t<<e|n>>>32-e,X_=(n,t,e)=>t<<e-32|n>>>64-e,tA=(n,t,e)=>n<<e-32|t>>>64-e;function BP(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const Xt={fromBig:q_,split:Q_,toBig:xP,shrSH:RP,shrSL:IP,rotrSH:SP,rotrSL:kP,rotrBH:TP,rotrBL:OP,rotr32H:NP,rotr32L:CP,rotlSH:Y_,rotlSL:J_,rotlBH:X_,rotlBL:tA,add:BP,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,add5H:(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,add5L:(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)},[PP,MP]=Xt.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),po=new Uint32Array(80),go=new Uint32Array(80);let LP=class extends Z_{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:f,El:h,Fh:y,Fl:_,Gh:w,Gl:R,Hh:T,Hl:I}=this;return[t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I]}set(t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=_|0,this.Gh=w|0,this.Gl=R|0,this.Hh=T|0,this.Hl=I|0}process(t,e){for(let U=0;U<16;U++,e+=4)po[U]=t.getUint32(e),go[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=po[U-15]|0,W=go[U-15]|0,X=Xt.rotrSH(G,W,1)^Xt.rotrSH(G,W,8)^Xt.shrSH(G,W,7),j=Xt.rotrSL(G,W,1)^Xt.rotrSL(G,W,8)^Xt.shrSL(G,W,7),J=po[U-2]|0,it=go[U-2]|0,ut=Xt.rotrSH(J,it,19)^Xt.rotrBH(J,it,61)^Xt.shrSH(J,it,6),rt=Xt.rotrSL(J,it,19)^Xt.rotrBL(J,it,61)^Xt.shrSL(J,it,6),ot=Xt.add4L(j,rt,go[U-7],go[U-16]),C=Xt.add4H(ot,X,ut,po[U-7],po[U-16]);po[U]=C|0,go[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:f,Dl:h,Eh:y,El:_,Fh:w,Fl:R,Gh:T,Gl:I,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=Xt.rotrSH(y,_,14)^Xt.rotrSH(y,_,18)^Xt.rotrBH(y,_,41),W=Xt.rotrSL(y,_,14)^Xt.rotrSL(y,_,18)^Xt.rotrBL(y,_,41),X=y&w^~y&T,j=_&R^~_&I,J=Xt.add5L(H,W,j,MP[U],go[U]),it=Xt.add5H(J,B,G,X,PP[U],po[U]),ut=J|0,rt=Xt.rotrSH(r,i,28)^Xt.rotrBH(r,i,34)^Xt.rotrBH(r,i,39),ot=Xt.rotrSL(r,i,28)^Xt.rotrBL(r,i,34)^Xt.rotrBL(r,i,39),C=r&s^r&a^s&a,p=i&o^i&u^o&u;B=T|0,H=I|0,T=w|0,I=R|0,w=y|0,R=_|0,{h:y,l:_}=Xt.add(f|0,h|0,it|0,ut|0),f=a|0,h=u|0,a=s|0,u=o|0,s=r|0,o=i|0;const m=Xt.add3L(ut,ot,p);r=Xt.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=Xt.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Xt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=Xt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=Xt.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:_}=Xt.add(this.Eh|0,this.El|0,y|0,_|0),{h:w,l:R}=Xt.add(this.Fh|0,this.Fl|0,w|0,R|0),{h:T,l:I}=Xt.add(this.Gh|0,this.Gl|0,T|0,I|0),{h:B,l:H}=Xt.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H)}roundClean(){po.fill(0),go.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 UP=Gg(()=>new LP);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kd=BigInt(0),jd=BigInt(1),DP=BigInt(2);function wa(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function _f(n){if(!wa(n))throw new Error("Uint8Array expected")}function Es(n,t){if(typeof t!="boolean")throw new Error(n+" boolean expected, got "+t)}const FP=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function ba(n){_f(n);let t="";for(let e=0;e<n.length;e++)t+=FP[n[e]];return t}function Xc(n){const t=n.toString(16);return t.length&1?"0"+t:t}function Kg(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?Kd:BigInt("0x"+n)}const vs={_0:48,_9:57,A:65,F:70,a:97,f:102};function eA(n){if(n>=vs._0&&n<=vs._9)return n-vs._0;if(n>=vs.A&&n<=vs.F)return n-(vs.A-10);if(n>=vs.a&&n<=vs.f)return n-(vs.a-10)}function tu(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){const o=eA(n.charCodeAt(s)),a=eA(n.charCodeAt(s+1));if(o===void 0||a===void 0){const u=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}r[i]=o*16+a}return r}function _a(n){return Kg(ba(n))}function eu(n){return _f(n),Kg(ba(Uint8Array.from(n).reverse()))}function nu(n,t){return tu(n.toString(16).padStart(t*2,"0"))}function Af(n,t){return nu(n,t).reverse()}function $P(n){return tu(Xc(n))}function Tn(n,t,e){let r;if(typeof t=="string")try{r=tu(t)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(wa(t))r=Uint8Array.from(t);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(n+" of length "+e+" expected, got "+i);return r}function Aa(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];_f(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}function HP(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function zP(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}const jg=n=>typeof n=="bigint"&&Kd<=n;function Wd(n,t,e){return jg(n)&&jg(t)&&jg(e)&&t<=n&&n<e}function Jr(n,t,e,r){if(!Wd(t,e,r))throw new Error("expected valid "+n+": "+e+" <= n < "+r+", got "+t)}function nA(n){let t;for(t=0;n>Kd;n>>=jd,t+=1);return t}function GP(n,t){return n>>BigInt(t)&jd}function VP(n,t,e){return n|(e?jd:Kd)<<BigInt(t)}const Wg=n=>(DP<<BigInt(n-1))-jd,Zg=n=>new Uint8Array(n),rA=n=>Uint8Array.from(n);function iA(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=Zg(n),i=Zg(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...y)=>e(i,r,...y),u=(y=Zg())=>{i=a(rA([0]),y),r=a(),y.length!==0&&(i=a(rA([1]),y),r=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const _=[];for(;y<t;){r=a();const w=r.slice();_.push(w),y+=r.length}return Aa(..._)};return(y,_)=>{o(),u(y);let w;for(;!(w=_(f()));)u();return o(),w}}const KP={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||wa(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function ru(n,t,e={}){const r=(i,s,o)=>{const a=KP[s];if(typeof a!="function")throw new Error("invalid validator function");const u=n[i];if(!(o&&u===void 0)&&!a(u,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const jP=()=>{throw new Error("not implemented")};function Ef(n){const t=new WeakMap;return(e,...r)=>{const i=t.get(e);if(i!==void 0)return i;const s=n(e,...r);return t.set(e,s),s}}const WP=Object.freeze(Object.defineProperty({__proto__:null,aInRange:Jr,abool:Es,abytes:_f,bitGet:GP,bitLen:nA,bitMask:Wg,bitSet:VP,bytesToHex:ba,bytesToNumberBE:_a,bytesToNumberLE:eu,concatBytes:Aa,createHmacDrbg:iA,ensureBytes:Tn,equalBytes:HP,hexToBytes:tu,hexToNumber:Kg,inRange:Wd,isBytes:wa,memoized:Ef,notImplemented:jP,numberToBytesBE:nu,numberToBytesLE:Af,numberToHexUnpadded:Xc,numberToVarBytesBE:$P,utf8ToBytes:zP,validateObject:ru},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pn=BigInt(0),tn=BigInt(1),Ea=BigInt(2),ZP=BigInt(3),qg=BigInt(4),sA=BigInt(5),oA=BigInt(8);function qe(n,t){const e=n%t;return e>=Pn?e:t+e}function qP(n,t,e){if(t<Pn)throw new Error("invalid exponent, negatives unsupported");if(e<=Pn)throw new Error("invalid modulus");if(e===tn)return Pn;let r=tn;for(;t>Pn;)t&tn&&(r=r*n%e),n=n*n%e,t>>=tn;return r}function un(n,t,e){let r=n;for(;t-- >Pn;)r*=r,r%=e;return r}function Qg(n,t){if(n===Pn)throw new Error("invert: expected non-zero number");if(t<=Pn)throw new Error("invert: expected positive modulus, got "+t);let e=qe(n,t),r=t,i=Pn,s=tn;for(;e!==Pn;){const a=r/e,u=r%e,f=i-s*a;r=e,e=u,i=s,s=f}if(r!==tn)throw new Error("invert: does not exist");return qe(i,t)}function QP(n){const t=(n-tn)/Ea;let e,r,i;for(e=n-tn,r=0;e%Ea===Pn;e/=Ea,r++);for(i=Ea;i<n&&qP(i,t,n)!==n-tn;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(n+tn)/qg;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+tn)/Ea;return function(a,u){if(a.pow(u,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=r,h=a.pow(a.mul(a.ONE,i),e),y=a.pow(u,s),_=a.pow(u,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let w=1;for(let T=a.sqr(_);w<f&&!a.eql(T,a.ONE);w++)T=a.sqr(T);const R=a.pow(h,tn<<BigInt(f-w-1));h=a.sqr(R),y=a.mul(y,R),_=a.mul(_,h),f=w}return y}}function YP(n){if(n%qg===ZP){const t=(n+tn)/qg;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%oA===sA){const t=(n-sA)/oA;return function(r,i){const s=r.mul(i,Ea),o=r.pow(s,t),a=r.mul(i,o),u=r.mul(r.mul(a,Ea),o),f=r.mul(a,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return QP(n)}const JP=(n,t)=>(qe(n,t)&tn)===tn,XP=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function t4(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=XP.reduce((r,i)=>(r[i]="function",r),t);return ru(n,e)}function e4(n,t,e){if(e<Pn)throw new Error("invalid exponent, negatives unsupported");if(e===Pn)return n.ONE;if(e===tn)return t;let r=n.ONE,i=t;for(;e>Pn;)e&tn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=tn;return r}function n4(n,t){const e=new Array(t.length),r=t.reduce((s,o,a)=>n.is0(o)?s:(e[a]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,a)=>n.is0(o)?s:(e[a]=n.mul(s,e[a]),n.mul(s,o)),i),e}function aA(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Zd(n,t,e=!1,r={}){if(n<=Pn)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=aA(n,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:n,isLE:e,BITS:i,BYTES:s,MASK:Wg(i),ZERO:Pn,ONE:tn,create:u=>qe(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Pn<=u&&u<n},is0:u=>u===Pn,isOdd:u=>(u&tn)===tn,neg:u=>qe(-u,n),eql:(u,f)=>u===f,sqr:u=>qe(u*u,n),add:(u,f)=>qe(u+f,n),sub:(u,f)=>qe(u-f,n),mul:(u,f)=>qe(u*f,n),pow:(u,f)=>e4(a,u,f),div:(u,f)=>qe(u*Qg(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Qg(u,n),sqrt:r.sqrt||(u=>(o||(o=YP(n)),o(a,u))),invertBatch:u=>n4(a,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?Af(u,s):nu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return e?eu(u):_a(u)}});return Object.freeze(a)}function cA(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function uA(n){const t=cA(n);return t+Math.ceil(t/2)}function r4(n,t,e=!1){const r=n.length,i=cA(t),s=uA(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=e?eu(n):_a(n),a=qe(o,t-tn)+tn;return e?Af(a,i):nu(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const lA=BigInt(0),qd=BigInt(1);function Yg(n,t){const e=t.negate();return n?e:t}function fA(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function Jg(n,t){fA(n,t);const e=Math.ceil(t/n)+1,r=2**(n-1);return{windows:e,windowSize:r}}function i4(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function s4(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const Xg=new WeakMap,hA=new WeakMap;function ty(n){return hA.get(n)||1}function dA(n,t){return{constTimeNegate:Yg,hasPrecomputes(e){return ty(e)!==1},unsafeLadder(e,r,i=n.ZERO){let s=e;for(;r>lA;)r&qd&&(i=i.add(s)),s=s.double(),r>>=qd;return i},precomputeWindow(e,r){const{windows:i,windowSize:s}=Jg(r,t),o=[];let a=e,u=a;for(let f=0;f<i;f++){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(e,r,i){const{windows:s,windowSize:o}=Jg(e,t);let a=n.ZERO,u=n.BASE;const f=BigInt(2**e-1),h=2**e,y=BigInt(e);for(let _=0;_<s;_++){const w=_*o;let R=Number(i&f);i>>=y,R>o&&(R-=h,i+=qd);const T=w,I=w+Math.abs(R)-1,B=_%2!==0,H=R<0;R===0?u=u.add(Yg(B,r[T])):a=a.add(Yg(H,r[I]))}return{p:a,f:u}},wNAFUnsafe(e,r,i,s=n.ZERO){const{windows:o,windowSize:a}=Jg(e,t),u=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let y=0;y<o;y++){const _=y*a;if(i===lA)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=f,i+=qd),w===0)continue;let R=r[_+Math.abs(w)-1];w<0&&(R=R.negate()),s=s.add(R)}return s},getPrecomputes(e,r,i){let s=Xg.get(r);return s||(s=this.precomputeWindow(r,e),e!==1&&Xg.set(r,i(s))),s},wNAFCached(e,r,i){const s=ty(e);return this.wNAF(s,this.getPrecomputes(s,e,i),r)},wNAFCachedUnsafe(e,r,i,s){const o=ty(e);return o===1?this.unsafeLadder(e,r,s):this.wNAFUnsafe(o,this.getPrecomputes(o,e,i),r,s)},setWindowSize(e,r){fA(r,t),hA.set(e,r),Xg.delete(e)}}}function pA(n,t,e,r){if(i4(e,n),s4(r,t),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=n.ZERO,s=nA(BigInt(e.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,u=new Array(a+1).fill(i),f=Math.floor((t.BITS-1)/o)*o;let h=i;for(let y=f;y>=0;y-=o){u.fill(i);for(let w=0;w<r.length;w++){const R=r[w],T=Number(R>>BigInt(y)&BigInt(a));u[T]=u[T].add(e[w])}let _=i;for(let w=u.length-1,R=i;w>0;w--)R=R.add(u[w]),_=_.add(R);if(h=h.add(_),y!==0)for(let w=0;w<o;w++)h=h.double()}return h}function ey(n){return t4(n.Fp),ru(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...aA(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wi=BigInt(0),vr=BigInt(1),Qd=BigInt(2),o4=BigInt(8),a4={zip215:!0};function c4(n){const t=ey(n);return ru(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function u4(n){const t=c4(n),{Fp:e,n:r,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=t,f=Qd<<BigInt(a*8)-vr,h=e.create,y=Zd(t.n,t.nBitLength),_=t.uvRatio||((v,k)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(k))}}catch{return{isValid:!1,value:wi}}}),w=t.adjustScalarBytes||(v=>v),R=t.domain||((v,k,N)=>{if(Es("phflag",N),k.length||N)throw new Error("Contexts/pre-hash are not supported");return v});function T(v,k){Jr("coordinate "+v,k,wi,f)}function I(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const B=Ef((v,k)=>{const{ex:N,ey:M,ez:z}=v,P=v.is0();k==null&&(k=P?o4:e.inv(z));const A=h(N*k),$=h(M*k),ct=h(z*k);if(P)return{x:wi,y:vr};if(ct!==vr)throw new Error("invZ was invalid");return{x:A,y:$}}),H=Ef(v=>{const{a:k,d:N}=t;if(v.is0())throw new Error("bad point: ZERO");const{ex:M,ey:z,ez:P,et:A}=v,$=h(M*M),ct=h(z*z),dt=h(P*P),wt=h(dt*dt),Gt=h($*k),Ut=h(dt*h(Gt+ct)),Lt=h(wt+h(N*h($*ct)));if(Ut!==Lt)throw new Error("bad point: equation left != right (1)");const Re=h(M*z),Kt=h(P*A);if(Re!==Kt)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(k,N,M,z){this.ex=k,this.ey=N,this.ez=M,this.et=z,T("x",k),T("y",N),T("z",M),T("t",z),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof U)throw new Error("extended point not allowed");const{x:N,y:M}=k||{};return T("x",N),T("y",M),new U(N,M,vr,h(N*M))}static normalizeZ(k){const N=e.invertBatch(k.map(M=>M.ez));return k.map((M,z)=>M.toAffine(N[z])).map(U.fromAffine)}static msm(k,N){return pA(U,y,k,N)}_setWindowSize(k){X.setWindowSize(this,k)}assertValidity(){H(this)}equals(k){I(k);const{ex:N,ey:M,ez:z}=this,{ex:P,ey:A,ez:$}=k,ct=h(N*$),dt=h(P*z),wt=h(M*$),Gt=h(A*z);return ct===dt&&wt===Gt}is0(){return this.equals(U.ZERO)}negate(){return new U(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:k}=t,{ex:N,ey:M,ez:z}=this,P=h(N*N),A=h(M*M),$=h(Qd*h(z*z)),ct=h(k*P),dt=N+M,wt=h(h(dt*dt)-P-A),Gt=ct+A,Ut=Gt-$,Lt=ct-A,Re=h(wt*Ut),Kt=h(Gt*Lt),Ft=h(wt*Lt),Te=h(Ut*Gt);return new U(Re,Kt,Te,Ft)}add(k){I(k);const{a:N,d:M}=t,{ex:z,ey:P,ez:A,et:$}=this,{ex:ct,ey:dt,ez:wt,et:Gt}=k;if(N===BigInt(-1)){const Ie=h((P-z)*(dt+ct)),Be=h((P+z)*(dt-ct)),kn=h(Be-Ie);if(kn===wi)return this.double();const he=h(A*Qd*Gt),Se=h($*Qd*wt),on=Se+he,ve=Be+Ie,Pe=Se-he,ur=h(on*kn),Fe=h(ve*Pe),O=h(on*Pe),b=h(kn*ve);return new U(ur,Fe,b,O)}const Ut=h(z*ct),Lt=h(P*dt),Re=h($*M*Gt),Kt=h(A*wt),Ft=h((z+P)*(ct+dt)-Ut-Lt),Te=Kt-Re,re=Kt+Re,oe=h(Lt-N*Ut),sn=h(Ft*Te),fe=h(re*oe),De=h(Ft*oe),ua=h(Te*re);return new U(sn,fe,ua,De)}subtract(k){return this.add(k.negate())}wNAF(k){return X.wNAFCached(this,k,U.normalizeZ)}multiply(k){const N=k;Jr("scalar",N,vr,r);const{p:M,f:z}=this.wNAF(N);return U.normalizeZ([M,z])[0]}multiplyUnsafe(k,N=U.ZERO){const M=k;return Jr("scalar",M,wi,r),M===wi?W:this.is0()||M===vr?this:X.wNAFCachedUnsafe(this,M,U.normalizeZ,N)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return X.unsafeLadder(this,r).is0()}toAffine(k){return B(this,k)}clearCofactor(){const{h:k}=t;return k===vr?this:this.multiplyUnsafe(k)}static fromHex(k,N=!1){const{d:M,a:z}=t,P=e.BYTES;k=Tn("pointHex",k,P),Es("zip215",N);const A=k.slice(),$=k[P-1];A[P-1]=$&-129;const ct=eu(A),dt=N?f:e.ORDER;Jr("pointHex.y",ct,wi,dt);const wt=h(ct*ct),Gt=h(wt-vr),Ut=h(M*wt-z);let{isValid:Lt,value:Re}=_(Gt,Ut);if(!Lt)throw new Error("Point.fromHex: invalid y coordinate");const Kt=(Re&vr)===vr,Ft=($&128)!==0;if(!N&&Re===wi&&Ft)throw new Error("Point.fromHex: x=0 and x_0=1");return Ft!==Kt&&(Re=h(-Re)),U.fromAffine({x:Re,y:ct})}static fromPrivateKey(k){return it(k).point}toRawBytes(){const{x:k,y:N}=this.toAffine(),M=Af(N,e.BYTES);return M[M.length-1]|=k&vr?128:0,M}toHex(){return ba(this.toRawBytes())}}U.BASE=new U(t.Gx,t.Gy,vr,h(t.Gx*t.Gy)),U.ZERO=new U(wi,vr,vr,wi);const{BASE:G,ZERO:W}=U,X=dA(U,a*8);function j(v){return qe(v,r)}function J(v){return j(eu(v))}function it(v){const k=e.BYTES;v=Tn("private key",v,k);const N=Tn("hashed private key",s(v),2*k),M=w(N.slice(0,k)),z=N.slice(k,2*k),P=J(M),A=G.multiply(P),$=A.toRawBytes();return{head:M,prefix:z,scalar:P,point:A,pointBytes:$}}function ut(v){return it(v).pointBytes}function rt(v=new Uint8Array,...k){const N=Aa(...k);return J(s(R(N,Tn("context",v),!!i)))}function ot(v,k,N={}){v=Tn("message",v),i&&(v=i(v));const{prefix:M,scalar:z,pointBytes:P}=it(k),A=rt(N.context,M,v),$=G.multiply(A).toRawBytes(),ct=rt(N.context,$,P,v),dt=j(A+ct*z);Jr("signature.s",dt,wi,r);const wt=Aa($,Af(dt,e.BYTES));return Tn("result",wt,e.BYTES*2)}const C=a4;function p(v,k,N,M=C){const{context:z,zip215:P}=M,A=e.BYTES;v=Tn("signature",v,2*A),k=Tn("message",k),N=Tn("publicKey",N,A),P!==void 0&&Es("zip215",P),i&&(k=i(k));const $=eu(v.slice(A,2*A));let ct,dt,wt;try{ct=U.fromHex(N,P),dt=U.fromHex(v.slice(0,A),P),wt=G.multiplyUnsafe($)}catch{return!1}if(!P&&ct.isSmallOrder())return!1;const Gt=rt(z,dt.toRawBytes(),ct.toRawBytes(),k);return dt.add(ct.multiplyUnsafe(Gt)).subtract(wt).clearCofactor().equals(U.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:ut,sign:ot,verify:p,ExtendedPoint:U,utils:{getExtendedPublicKey:it,randomPrivateKey:()=>o(e.BYTES),precompute(v=8,k=U.BASE){return k._setWindowSize(v),k.multiply(BigInt(3)),k}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ny=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),gA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const l4=BigInt(1),yA=BigInt(2);BigInt(3);const f4=BigInt(5),h4=BigInt(8);function d4(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),i=BigInt(80),s=ny,a=n*n%s*n%s,u=un(a,yA,s)*a%s,f=un(u,l4,s)*n%s,h=un(f,f4,s)*f%s,y=un(h,t,s)*h%s,_=un(y,e,s)*y%s,w=un(_,r,s)*_%s,R=un(w,i,s)*w%s,T=un(R,i,s)*w%s,I=un(T,t,s)*h%s;return{pow_p_5_8:un(I,yA,s)*n%s,b2:a}}function p4(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function g4(n,t){const e=ny,r=qe(t*t*t,e),i=qe(r*r*t,e),s=d4(n*i).pow_p_5_8;let o=qe(n*r*s,e);const a=qe(t*o*o,e),u=o,f=qe(o*gA,e),h=a===n,y=a===qe(-n,e),_=a===qe(-n*gA,e);return h&&(o=u),(y||_)&&(o=f),JP(o,e)&&(o=qe(-o,e)),{isValid:h||y,value:o}}const y4=Zd(ny,void 0,!0),m4={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:y4,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:h4,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:UP,randomBytes:W_,adjustScalarBytes:p4,uvRatio:g4},iu=u4(m4);var ry={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=Fg,r=e.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(i(e,t),t.Buffer=s);function s(o,a,u){return r(o,a,u)}s.prototype=Object.create(r.prototype),i(r,s),s.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,u)},s.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=r(o);return a!==void 0?typeof u=="string"?f.fill(a,u):f.fill(a):f.fill(0),f},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(ry,ry.exports);var w4=ry.exports,Yd=w4.Buffer;function b4(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=r}var o=n.length,a=n.charAt(0),u=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function h(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=Yd.from(w)),!Yd.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var R=0,T=0,I=0,B=w.length;I!==B&&w[I]===0;)I++,R++;for(var H=(B-I)*f+1>>>0,U=new Uint8Array(H);I!==B;){for(var G=w[I],W=0,X=H-1;(G!==0||W<T)&&X!==-1;X--,W++)G+=256*U[X]>>>0,U[X]=G%o>>>0,G=G/o>>>0;if(G!==0)throw new Error("Non-zero carry");T=W,I++}for(var j=H-T;j!==H&&U[j]===0;)j++;for(var J=a.repeat(R);j<H;++j)J+=n.charAt(U[j]);return J}function y(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return Yd.alloc(0);for(var R=0,T=0,I=0;w[R]===a;)T++,R++;for(var B=(w.length-R)*u+1>>>0,H=new Uint8Array(B);R<w.length;){var U=w.charCodeAt(R);if(U>255)return;var G=t[U];if(G===255)return;for(var W=0,X=B-1;(G!==0||W<I)&&X!==-1;X--,W++)G+=o*H[X]>>>0,H[X]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");I=W,R++}for(var j=B-I;j!==B&&H[j]===0;)j++;var J=Yd.allocUnsafe(T+(B-j));J.fill(0,0,T);for(var it=T;j!==B;)J[it++]=H[j++];return J}function _(w){var R=y(w);if(R)return R;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:y,decode:_}}var _4=b4,A4=_4,E4="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",mA=A4(E4);const On=Mr(mA),v4=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]),yo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mo=new Uint32Array(64);let x4=class extends Z_{constructor(){super(64,32,8,!1),this.A=yo[0]|0,this.B=yo[1]|0,this.C=yo[2]|0,this.D=yo[3]|0,this.E=yo[4]|0,this.F=yo[5]|0,this.G=yo[6]|0,this.H=yo[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:a,H:u}=this;return[t,e,r,i,s,o,a,u]}set(t,e,r,i,s,o,a,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)mo[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const _=mo[y-15],w=mo[y-2],R=$i(_,7)^$i(_,18)^_>>>3,T=$i(w,17)^$i(w,19)^w>>>10;mo[y]=T+mo[y-7]+R+mo[y-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const _=$i(a,6)^$i(a,11)^$i(a,25),w=h+_+EP(a,u,f)+v4[y]+mo[y]|0,T=($i(r,2)^$i(r,13)^$i(r,22))+vP(r,i,s)|0;h=f,f=u,u=a,a=o+w|0,o=s,s=i,i=r,r=w+T|0}r=r+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,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,a,u,f,h)}roundClean(){mo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const iy=Gg(()=>new x4);var Vn={};function xs(n,t,e){return t<=n&&n<=e}function Jd(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function R4(n){for(var t=String(n),e=t.length,r=0,i=[];r<e;){var s=t.charCodeAt(r);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(r===e-1)i.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=s&1023,u=o&1023;i.push(65536+(a<<10)+u),r+=1}else i.push(65533)}r+=1}return i}function I4(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var Xd=-1;function sy(n){this.tokens=[].slice.call(n)}sy.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Xd},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var su=-1;function oy(n,t){if(n)throw TypeError("Decoder error");return t||65533}var t0="utf-8";function e0(n,t){if(!(this instanceof e0))return new e0(n,t);if(n=n!==void 0?String(n).toLowerCase():t0,n!==t0)throw new Error("Encoding not supported. Only utf-8 is supported");t=Jd(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}e0.prototype={decode:function(t,e){var r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=Jd(e),this._streaming||(this._decoder=new S4({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var i=new sy(r),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==su);)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===su)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),I4(s)}};function n0(n,t){if(!(this instanceof n0))return new n0(n,t);if(n=n!==void 0?String(n).toLowerCase():t0,n!==t0)throw new Error("Encoding not supported. Only utf-8 is supported");t=Jd(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}n0.prototype={encode:function(t,e){t=t?String(t):"",e=Jd(e),this._streaming||(this._encoder=new k4(this._options)),this._streaming=!!e.stream;for(var r=[],i=new sy(R4(t)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==su);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==su;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)}};function S4(n){var t=n.fatal,e=0,r=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===Xd&&i!==0)return i=0,oy(t);if(u===Xd)return su;if(i===0){if(xs(u,0,127))return u;if(xs(u,194,223))i=1,e=u-192;else if(xs(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,e=u-224;else if(xs(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,e=u-240;else return oy(t);return e=e<<6*i,null}if(!xs(u,s,o))return e=i=r=0,s=128,o=191,a.prepend(u),oy(t);if(s=128,o=191,r+=1,e+=u-128<<6*(i-r),r!==i)return null;var f=e;return e=i=r=0,f}}function k4(n){n.fatal,this.handler=function(t,e){if(e===Xd)return su;if(xs(e,0,127))return e;var r,i;xs(e,128,2047)?(r=1,i=192):xs(e,2048,65535)?(r=2,i=224):xs(e,65536,1114111)&&(r=3,i=240);for(var s=[(e>>6*r)+i];r>0;){var o=e>>6*(r-1);s.push(128|o&63),r-=1}return s}}const T4=Lc(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:e0,TextEncoder:n0},Symbol.toStringTag,{value:"Module"})));var O4=ae&&ae.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),N4=ae&&ae.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),Hi=ae&&ae.__decorate||function(n,t,e,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},C4=ae&&ae.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&O4(t,n,e);return N4(t,n),t},wA=ae&&ae.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Vn,"__esModule",{value:!0});var bA=Vn.deserializeUnchecked=RA=Vn.deserialize=xA=Vn.serialize=Vn.BinaryReader=Vn.BinaryWriter=Vn.BorshError=Vn.baseDecode=Vn.baseEncode=void 0;const wo=wA($g),_A=wA(mA),B4=C4(T4),P4=typeof TextDecoder!="function"?B4.TextDecoder:TextDecoder,M4=new P4("utf-8",{fatal:!0});function L4(n){return typeof n=="string"&&(n=Zt.from(n,"utf8")),_A.default.encode(Zt.from(n))}Vn.baseEncode=L4;function U4(n){return Zt.from(_A.default.decode(n))}Vn.baseDecode=U4;const ay=1024;class hr extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Vn.BorshError=hr;class AA{constructor(){this.buf=Zt.alloc(ay),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Zt.concat([this.buf,Zt.alloc(ay)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Zt.from(new wo.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Zt.from(new wo.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Zt.from(new wo.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Zt.from(new wo.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Zt.concat([Zt.from(this.buf.subarray(0,this.length)),t,Zt.alloc(ay)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Zt.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Zt.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}Vn.BinaryWriter=AA;function zi(n,t,e){const r=e.value;e.value=function(...i){try{return r.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new hr("Reached the end of buffer when deserializing")}throw s}}}class Dr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new wo.default(t,"le")}readU128(){const t=this.readBuffer(16);return new wo.default(t,"le")}readU256(){const t=this.readBuffer(32);return new wo.default(t,"le")}readU512(){const t=this.readBuffer(64);return new wo.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new hr(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return M4.decode(e)}catch(r){throw new hr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let i=0;i<e;++i)r.push(t());return r}}Hi([zi],Dr.prototype,"readU8",null),Hi([zi],Dr.prototype,"readU16",null),Hi([zi],Dr.prototype,"readU32",null),Hi([zi],Dr.prototype,"readU64",null),Hi([zi],Dr.prototype,"readU128",null),Hi([zi],Dr.prototype,"readU256",null),Hi([zi],Dr.prototype,"readU512",null),Hi([zi],Dr.prototype,"readString",null),Hi([zi],Dr.prototype,"readFixedArray",null),Hi([zi],Dr.prototype,"readArray",null),Vn.BinaryReader=Dr;function EA(n){return n.charAt(0).toUpperCase()+n.slice(1)}function va(n,t,e,r,i){try{if(typeof r=="string")i[`write${EA(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new hr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);i.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new hr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let s=0;s<r[1];s++)va(n,null,e[s],r[0],i)}else i.writeArray(e,s=>{va(n,t,s,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?i.writeU8(0):(i.writeU8(1),va(n,t,e,r.type,i));break}case"map":{i.writeU32(e.size),e.forEach((s,o)=>{va(n,t,o,r.key,i),va(n,t,s,r.value,i)});break}default:throw new hr(`FieldType ${r} unrecognized`)}else vA(n,e,i)}catch(s){throw s instanceof hr&&s.addToFieldPath(t),s}}function vA(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new hr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([i,s])=>{va(n,i,t[i],s,e)});else if(r.kind==="enum"){const i=t[r.field];for(let s=0;s<r.values.length;++s){const[o,a]=r.values[s];if(o===i){e.writeU8(s),va(n,o,t[o],a,e);break}}}else throw new hr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function D4(n,t,e=AA){const r=new e;return vA(n,t,r),r.toArray()}var xA=Vn.serialize=D4;function xa(n,t,e,r){try{if(typeof e=="string")return r[`read${EA(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const i=[];for(let s=0;s<e[1];s++)i.push(xa(n,null,e[0],r));return i}else return r.readArray(()=>xa(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?xa(n,t,e.type,r):void 0;if(e.kind==="map"){let i=new Map;const s=r.readU32();for(let o=0;o<s;o++){const a=xa(n,t,e.key,r),u=xa(n,t,e.value,r);i.set(a,u)}return i}return cy(n,e,r)}catch(i){throw i instanceof hr&&i.addToFieldPath(t),i}}function cy(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new hr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const i={};for(const[s,o]of n.get(t).fields)i[s]=xa(n,s,o,e);return new t(i)}if(r.kind==="enum"){const i=e.readU8();if(i>=r.values.length)throw new hr(`Enum index: ${i} is out of range`);const[s,o]=r.values[i],a=xa(n,s,o,e);return new t({[s]:a})}throw new hr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function F4(n,t,e,r=Dr){const i=new r(e),s=cy(n,t,i);if(i.offset<e.length)throw new hr(`Unexpected ${e.length-i.offset} bytes after deserialized data`);return s}var RA=Vn.deserialize=F4;function $4(n,t,e,r=Dr){const i=new r(e);return cy(n,t,i)}bA=Vn.deserializeUnchecked=$4;var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.s16=nt.s8=nt.nu64be=nt.u48be=nt.u40be=nt.u32be=nt.u24be=nt.u16be=Kn=nt.nu64=nt.u48=nt.u40=Ot=nt.u32=nt.u24=ti=nt.u16=me=nt.u8=bo=nt.offset=nt.greedy=nt.Constant=nt.UTF8=nt.CString=nt.Blob=nt.Boolean=nt.BitField=nt.BitStructure=nt.VariantLayout=nt.Union=nt.UnionLayoutDiscriminator=nt.UnionDiscriminator=nt.Structure=nt.Sequence=nt.DoubleBE=nt.Double=nt.FloatBE=nt.Float=nt.NearInt64BE=nt.NearInt64=nt.NearUInt64BE=nt.NearUInt64=nt.IntBE=nt.Int=nt.UIntBE=nt.UInt=nt.OffsetLayout=nt.GreedyCount=nt.ExternalLayout=nt.bindConstructorLayout=nt.nameWithProperty=nt.Layout=nt.uint8ArrayToBuffer=nt.checkUint8Array=void 0,nt.constant=nt.utf8=nt.cstr=We=nt.blob=nt.unionLayoutDiscriminator=nt.union=jn=nt.seq=nt.bits=Nt=nt.struct=nt.f64be=nt.f64=nt.f32be=nt.f32=nt.ns64be=nt.s48be=nt.s40be=nt.s32be=nt.s24be=nt.s16be=Fr=nt.ns64=nt.s48=nt.s40=nt.s32=nt.s24=void 0;const uy=Fg;function ou(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}nt.checkUint8Array=ou;function be(n){return ou(n),uy.Buffer.from(n.buffer,n.byteOffset,n.length)}nt.uint8ArrayToBuffer=be;let Oe=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};nt.Layout=Oe;function ly(n,t){return t.property?n+"["+t.property+"]":n}nt.nameWithProperty=ly;function H4(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Oe))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}nt.bindConstructorLayout=H4;let xr=class extends Oe{isCount(){throw new Error("ExternalLayout is abstract")}};nt.ExternalLayout=xr;let IA=class extends xr{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){ou(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}};nt.GreedyCount=IA;let fy=class extends xr{constructor(t,e=0,r){if(!(t instanceof Oe))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Xr||this.layout instanceof bi}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}};nt.OffsetLayout=fy;let Xr=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntLE(t,r,this.span),this.span}};nt.UInt=Xr;let bi=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntBE(t,r,this.span),this.span}};nt.UIntBE=bi;let Ra=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeIntLE(t,r,this.span),this.span}};nt.Int=Ra;let au=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeIntBE(t,r,this.span),this.span}};nt.IntBE=au;const hy=Math.pow(2,32);function r0(n){const t=Math.floor(n/hy),e=n-t*hy;return{hi32:t,lo32:e}}function i0(n,t){return n*hy+t}let SA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32LE(e),s=r.readUInt32LE(e+4);return i0(s,i)}encode(t,e,r=0){const i=r0(t),s=be(e);return s.writeUInt32LE(i.lo32,r),s.writeUInt32LE(i.hi32,r+4),8}};nt.NearUInt64=SA;let kA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32BE(e),s=r.readUInt32BE(e+4);return i0(i,s)}encode(t,e,r=0){const i=r0(t),s=be(e);return s.writeUInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};nt.NearUInt64BE=kA;let TA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readUInt32LE(e),s=r.readInt32LE(e+4);return i0(s,i)}encode(t,e,r=0){const i=r0(t),s=be(e);return s.writeUInt32LE(i.lo32,r),s.writeInt32LE(i.hi32,r+4),8}};nt.NearInt64=TA;let OA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),i=r.readInt32BE(e),s=r.readUInt32BE(e+4);return i0(i,s)}encode(t,e,r=0){const i=r0(t),s=be(e);return s.writeInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};nt.NearInt64BE=OA;let NA=class extends Oe{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatLE(e)}encode(t,e,r=0){return be(e).writeFloatLE(t,r),4}};nt.Float=NA;let CA=class extends Oe{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatBE(e)}encode(t,e,r=0){return be(e).writeFloatBE(t,r),4}};nt.FloatBE=CA;let BA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleLE(e)}encode(t,e,r=0){return be(e).writeDoubleLE(t,r),8}};nt.Double=BA;let PA=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleBE(e)}encode(t,e,r=0){return be(e).writeDoubleBE(t,r),8}};nt.DoubleBE=PA;let MA=class extends Oe{constructor(t,e,r){if(!(t instanceof Oe))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof xr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof xr)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,i=this.count;if(i instanceof xr&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e=0){const r=[];let i=0,s=this.count;for(s instanceof xr&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r=0){const i=this.elementLayout,s=t.reduce((o,a)=>o+i.encode(a,e,r+o),0);return this.count instanceof xr&&this.count.encode(t.length,e,r),s}};nt.Sequence=MA;let LA=class extends Oe{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Oe,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){ou(t);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}};nt.Structure=LA;let dy=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}};nt.UnionDiscriminator=dy;let s0=class extends dy{constructor(t,e){if(!(t instanceof xr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}};nt.UnionLayoutDiscriminator=s0;let py=class extends Oe{constructor(t,e,r){let i;if(t instanceof Xr||t instanceof bi)i=new s0(new fy(t));else if(t instanceof xr&&t.isCount())i=new s0(t);else if(t instanceof dy)i=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Oe))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof Xr||t instanceof bi)&&(s+=i.layout.span)),super(s,r),this.discriminator=i,this.usesPrefixDiscriminator=t instanceof Xr||t instanceof bi,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const i=this.discriminator,s=i.decode(t,e),o=this.registry[s];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[a.property]=a.decode(t,e+u)}else r=o.decode(t,e);return r}encode(t,e,r=0){const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new UA(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}};nt.Union=py;let UA=class extends Oe{constructor(t,e,r,i){if(!(t instanceof py))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Oe))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(t,e+r)),r+i}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};nt.VariantLayout=UA;function cu(n){return 0>n&&(n+=4294967296),n}let gy=class extends Oe{constructor(t,e,r){if(!(t instanceof Xr||t instanceof bi))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=cu(s),this},this._packedGetValue=function(){return i}}decode(t,e=0){const r=this.makeDestinationObject(),i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(t));return r}encode(t,e,r=0){const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new yy(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new DA(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}};nt.BitStructure=gy;let yy=class{constructor(t,e,r){if(!(t instanceof gy))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,a)=>o+a.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=cu(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return cu(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==cu(t&this.valueMask))throw new TypeError(ly("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=cu(t<<this.start);this.container._packedSetValue(cu(e&~this.wordMask)|r)}};nt.BitField=yy;let DA=class extends yy{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};nt.Boolean=DA;let FA=class extends Oe{constructor(t,e){if(!(t instanceof xr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof xr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),be(t).slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof xr&&(i=t.length),!(t instanceof Uint8Array&&i===t.length))throw new TypeError(ly("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(r+i>e.length)throw new RangeError("encoding overruns Uint8Array");const s=be(t);return be(e).write(s.toString("hex"),r,i,"hex"),this.length instanceof xr&&this.length.encode(i,e,r),i}};nt.Blob=FA;let $A=class extends Oe{constructor(t){super(-1,t)}getSpan(t,e=0){ou(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return be(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=uy.Buffer.from(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");const o=be(e);return i.copy(o,r),o[r+s]=0,s+1}};nt.CString=$A;let HA=class extends Oe{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return ou(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return be(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=uy.Buffer.from(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(be(e),r),s}};nt.UTF8=HA;let zA=class extends Oe{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}};nt.Constant=zA,nt.greedy=(n,t)=>new IA(n,t);var bo=nt.offset=(n,t,e)=>new fy(n,t,e),me=nt.u8=n=>new Xr(1,n),ti=nt.u16=n=>new Xr(2,n);nt.u24=n=>new Xr(3,n);var Ot=nt.u32=n=>new Xr(4,n);nt.u40=n=>new Xr(5,n),nt.u48=n=>new Xr(6,n);var Kn=nt.nu64=n=>new SA(n);nt.u16be=n=>new bi(2,n),nt.u24be=n=>new bi(3,n),nt.u32be=n=>new bi(4,n),nt.u40be=n=>new bi(5,n),nt.u48be=n=>new bi(6,n),nt.nu64be=n=>new kA(n),nt.s8=n=>new Ra(1,n),nt.s16=n=>new Ra(2,n),nt.s24=n=>new Ra(3,n),nt.s32=n=>new Ra(4,n),nt.s40=n=>new Ra(5,n),nt.s48=n=>new Ra(6,n);var Fr=nt.ns64=n=>new TA(n);nt.s16be=n=>new au(2,n),nt.s24be=n=>new au(3,n),nt.s32be=n=>new au(4,n),nt.s40be=n=>new au(5,n),nt.s48be=n=>new au(6,n),nt.ns64be=n=>new OA(n),nt.f32=n=>new NA(n),nt.f32be=n=>new CA(n),nt.f64=n=>new BA(n),nt.f64be=n=>new PA(n);var Nt=nt.struct=(n,t,e)=>new LA(n,t,e);nt.bits=(n,t,e)=>new gy(n,t,e);var jn=nt.seq=(n,t,e)=>new MA(n,t,e);nt.union=(n,t,e)=>new py(n,t,e),nt.unionLayoutDiscriminator=(n,t)=>new s0(n,t);var We=nt.blob=(n,t)=>new FA(n,t);nt.cstr=n=>new $A(n),nt.utf8=(n,t)=>new HA(n,t),nt.constant=(n,t)=>new zA(n,t);var vf={};Object.defineProperty(vf,"__esModule",{value:!0});function z4(n){{const t=Zt.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var G4=vf.toBigIntLE=z4;function V4(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}vf.toBigIntBE=V4;function K4(n,t){{const e=n.toString(16),r=Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var GA=vf.toBufferLE=K4;function j4(n,t){{const e=n.toString(16);return Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}vf.toBufferBE=j4;let W4=class extends TypeError{constructor(t,e){let r;const{message:i,explanation:s,...o}=t,{path:a}=t,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=()=>r??(r=[t,...e()])}};function Z4(n){return xf(n)&&typeof n[Symbol.iterator]=="function"}function xf(n){return typeof n=="object"&&n!=null}function o0(n){return xf(n)&&!Array.isArray(n)}function _i(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function q4(n){const{done:t,value:e}=n.next();return t?void 0:e}function Q4(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${_i(r)}\``}=n;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*VA(n,t,e,r){Z4(n)||(n=[n]);for(const i of n){const s=Q4(i,t,e,r);s&&(yield s)}}function*my(n,t,e={}){const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,a={path:r,branch:i,mask:o};s&&(n=t.coercer(n,a));let u="valid";for(const f of t.validator(n,a))f.explanation=e.message,u="not_valid",yield[f,void 0];for(let[f,h,y]of t.entries(n,a)){const _=my(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o,message:e.message});for(const w of _)w[0]?(u=w[0].refinement!=null?"not_refined":"not_valid",yield[w[0],void 0]):s&&(h=w[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):xf(n)&&(h!==void 0||f in n)&&(n[f]=h))}if(u!=="not_valid")for(const f of t.refiner(n,a))f.explanation=e.message,u="not_refined",yield[f,void 0];u==="valid"&&(yield[void 0,n])}let Gi=class{constructor(t){const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return VA(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return VA(h,f,this,u)}:this.refiner=()=>[]}assert(t,e){return KA(t,this,e)}create(t,e){return bt(t,this,e)}is(t){return jA(t,this)}mask(t,e){return Y4(t,this,e)}validate(t,e={}){return Rf(t,this,e)}};function KA(n,t,e){const r=Rf(n,t,{message:e});if(r[0])throw r[0]}function bt(n,t,e){const r=Rf(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function Y4(n,t,e){const r=Rf(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function jA(n,t){return!Rf(n,t)[0]}function Rf(n,t,e={}){const r=my(n,t,e),i=q4(r);return i[0]?[new W4(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Ia(n,t){return new Gi({type:n,schema:null,validator:t})}function J4(){return Ia("any",()=>!0)}function Et(n){return new Gi({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${_i(t)}`}})}function Vi(){return Ia("boolean",n=>typeof n=="boolean")}function wy(n){return Ia("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${_i(t)}`)}function en(n){const t=_i(n),e=typeof n;return new Gi({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${_i(r)}`}})}function X4(){return Ia("never",()=>!1)}function vt(n){return new Gi({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function tt(){return Ia("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${_i(n)}`)}function Dt(n){return new Gi({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function WA(n,t){return new Gi({type:"record",schema:null,*entries(e){if(xf(e))for(const r in e){const i=e[r];yield[r,r,n],yield[r,i,t]}},validator(e){return o0(e)||`Expected an object, but received: ${_i(e)}`},coercer(e){return o0(e)?{...e}:e}})}function mt(){return Ia("string",n=>typeof n=="string"||`Expected a string, but received: ${_i(n)}`)}function by(n){const t=X4();return new Gi({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let i=0;i<r;i++)yield[i,e[i],n[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${_i(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ft(n){const t=Object.keys(n);return new Gi({type:"type",schema:n,*entries(e){if(xf(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return o0(e)||`Expected an object, but received: ${_i(e)}`},coercer(e){return o0(e)?{...e}:e}})}function dr(n){const t=n.map(e=>e.type).join(" | ");return new Gi({type:"union",schema:null,coercer(e,r){for(const i of n){const[s,o]=i.validate(e,{coerce:!0,mask:r.mask});if(!s)return o}return e},validator(e,r){const i=[];for(const s of n){const[...o]=my(e,s,r),[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 \`${t}\`, but received: ${_i(e)}`,...i]}})}function uu(){return Ia("unknown",()=>!0)}function If(n,t,e){return new Gi({...n,coercer:(r,i)=>jA(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}var a0,tM=new Uint8Array(16);function ZA(){if(!a0&&(a0=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!a0))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a0(tM)}const eM=/^(?:[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 c0(n){return typeof n=="string"&&eM.test(n)}for(var Wn=[],_y=0;_y<256;++_y)Wn.push((_y+256).toString(16).substr(1));function u0(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(Wn[n[t+0]]+Wn[n[t+1]]+Wn[n[t+2]]+Wn[n[t+3]]+"-"+Wn[n[t+4]]+Wn[n[t+5]]+"-"+Wn[n[t+6]]+Wn[n[t+7]]+"-"+Wn[n[t+8]]+Wn[n[t+9]]+"-"+Wn[n[t+10]]+Wn[n[t+11]]+Wn[n[t+12]]+Wn[n[t+13]]+Wn[n[t+14]]+Wn[n[t+15]]).toLowerCase();if(!c0(e))throw TypeError("Stringified UUID is invalid");return e}var qA,Ay,Ey=0,vy=0;function nM(n,t,e){var r=t&&e||0,i=t||new Array(16);n=n||{};var s=n.node||qA,o=n.clockseq!==void 0?n.clockseq:Ay;if(s==null||o==null){var a=n.random||(n.rng||ZA)();s==null&&(s=qA=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Ay=(a[6]<<8|a[7])&16383)}var u=n.msecs!==void 0?n.msecs:Date.now(),f=n.nsecs!==void 0?n.nsecs:vy+1,h=u-Ey+(f-vy)/1e4;if(h<0&&n.clockseq===void 0&&(o=o+1&16383),(h<0||u>Ey)&&n.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ey=u,vy=f,Ay=o,u+=122192928e5;var y=((u&268435455)*1e4+f)%4294967296;i[r++]=y>>>24&255,i[r++]=y>>>16&255,i[r++]=y>>>8&255,i[r++]=y&255;var _=u/4294967296*1e4&268435455;i[r++]=_>>>8&255,i[r++]=_&255,i[r++]=_>>>24&15|16,i[r++]=_>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var w=0;w<6;++w)i[r+w]=s[w];return t||u0(i)}function QA(n){if(!c0(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function rM(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var iM="6ba7b810-9dad-11d1-80b4-00c04fd430c8",sM="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function YA(n,t,e){function r(i,s,o,a){if(typeof i=="string"&&(i=rM(i)),typeof s=="string"&&(s=QA(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){a=a||0;for(var f=0;f<16;++f)o[a+f]=u[f];return o}return u0(u)}try{r.name=n}catch{}return r.DNS=iM,r.URL=sM,r}function oM(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return aM(cM(uM(n),n.length*8))}function aM(n){for(var t=[],e=n.length*32,r="0123456789abcdef",i=0;i<e;i+=8){var s=n[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);t.push(o)}return t}function JA(n){return(n+64>>>9<<4)+14+1}function cM(n,t){n[t>>5]|=128<<t%32,n[JA(t)-1]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var a=e,u=r,f=i,h=s;e=er(e,r,i,s,n[o],7,-680876936),s=er(s,e,r,i,n[o+1],12,-389564586),i=er(i,s,e,r,n[o+2],17,606105819),r=er(r,i,s,e,n[o+3],22,-1044525330),e=er(e,r,i,s,n[o+4],7,-176418897),s=er(s,e,r,i,n[o+5],12,1200080426),i=er(i,s,e,r,n[o+6],17,-1473231341),r=er(r,i,s,e,n[o+7],22,-45705983),e=er(e,r,i,s,n[o+8],7,1770035416),s=er(s,e,r,i,n[o+9],12,-1958414417),i=er(i,s,e,r,n[o+10],17,-42063),r=er(r,i,s,e,n[o+11],22,-1990404162),e=er(e,r,i,s,n[o+12],7,1804603682),s=er(s,e,r,i,n[o+13],12,-40341101),i=er(i,s,e,r,n[o+14],17,-1502002290),r=er(r,i,s,e,n[o+15],22,1236535329),e=nr(e,r,i,s,n[o+1],5,-165796510),s=nr(s,e,r,i,n[o+6],9,-1069501632),i=nr(i,s,e,r,n[o+11],14,643717713),r=nr(r,i,s,e,n[o],20,-373897302),e=nr(e,r,i,s,n[o+5],5,-701558691),s=nr(s,e,r,i,n[o+10],9,38016083),i=nr(i,s,e,r,n[o+15],14,-660478335),r=nr(r,i,s,e,n[o+4],20,-405537848),e=nr(e,r,i,s,n[o+9],5,568446438),s=nr(s,e,r,i,n[o+14],9,-1019803690),i=nr(i,s,e,r,n[o+3],14,-187363961),r=nr(r,i,s,e,n[o+8],20,1163531501),e=nr(e,r,i,s,n[o+13],5,-1444681467),s=nr(s,e,r,i,n[o+2],9,-51403784),i=nr(i,s,e,r,n[o+7],14,1735328473),r=nr(r,i,s,e,n[o+12],20,-1926607734),e=rr(e,r,i,s,n[o+5],4,-378558),s=rr(s,e,r,i,n[o+8],11,-2022574463),i=rr(i,s,e,r,n[o+11],16,1839030562),r=rr(r,i,s,e,n[o+14],23,-35309556),e=rr(e,r,i,s,n[o+1],4,-1530992060),s=rr(s,e,r,i,n[o+4],11,1272893353),i=rr(i,s,e,r,n[o+7],16,-155497632),r=rr(r,i,s,e,n[o+10],23,-1094730640),e=rr(e,r,i,s,n[o+13],4,681279174),s=rr(s,e,r,i,n[o],11,-358537222),i=rr(i,s,e,r,n[o+3],16,-722521979),r=rr(r,i,s,e,n[o+6],23,76029189),e=rr(e,r,i,s,n[o+9],4,-640364487),s=rr(s,e,r,i,n[o+12],11,-421815835),i=rr(i,s,e,r,n[o+15],16,530742520),r=rr(r,i,s,e,n[o+2],23,-995338651),e=ir(e,r,i,s,n[o],6,-198630844),s=ir(s,e,r,i,n[o+7],10,1126891415),i=ir(i,s,e,r,n[o+14],15,-1416354905),r=ir(r,i,s,e,n[o+5],21,-57434055),e=ir(e,r,i,s,n[o+12],6,1700485571),s=ir(s,e,r,i,n[o+3],10,-1894986606),i=ir(i,s,e,r,n[o+10],15,-1051523),r=ir(r,i,s,e,n[o+1],21,-2054922799),e=ir(e,r,i,s,n[o+8],6,1873313359),s=ir(s,e,r,i,n[o+15],10,-30611744),i=ir(i,s,e,r,n[o+6],15,-1560198380),r=ir(r,i,s,e,n[o+13],21,1309151649),e=ir(e,r,i,s,n[o+4],6,-145523070),s=ir(s,e,r,i,n[o+11],10,-1120210379),i=ir(i,s,e,r,n[o+2],15,718787259),r=ir(r,i,s,e,n[o+9],21,-343485551),e=_o(e,a),r=_o(r,u),i=_o(i,f),s=_o(s,h)}return[e,r,i,s]}function uM(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(JA(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function _o(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function lM(n,t){return n<<t|n>>>32-t}function l0(n,t,e,r,i,s){return _o(lM(_o(_o(t,n),_o(r,s)),i),e)}function er(n,t,e,r,i,s,o){return l0(t&e|~t&r,n,t,i,s,o)}function nr(n,t,e,r,i,s,o){return l0(t&r|e&~r,n,t,i,s,o)}function rr(n,t,e,r,i,s,o){return l0(t^e^r,n,t,i,s,o)}function ir(n,t,e,r,i,s,o){return l0(e^(t|~r),n,t,i,s,o)}var fM=YA("v3",48,oM);function hM(n,t,e){n=n||{};var r=n.random||(n.rng||ZA)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var i=0;i<16;++i)t[e+i]=r[i];return t}return u0(r)}function dM(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function xy(n,t){return n<<t|n>>>32-t}function pM(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var i=0;i<r.length;++i)n.push(r.charCodeAt(i))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var s=n.length/4+2,o=Math.ceil(s/16),a=new Array(o),u=0;u<o;++u){for(var f=new Uint32Array(16),h=0;h<16;++h)f[h]=n[u*64+h*4]<<24|n[u*64+h*4+1]<<16|n[u*64+h*4+2]<<8|n[u*64+h*4+3];a[u]=f}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var y=0;y<o;++y){for(var _=new Uint32Array(80),w=0;w<16;++w)_[w]=a[y][w];for(var R=16;R<80;++R)_[R]=xy(_[R-3]^_[R-8]^_[R-14]^_[R-16],1);for(var T=e[0],I=e[1],B=e[2],H=e[3],U=e[4],G=0;G<80;++G){var W=Math.floor(G/20),X=xy(T,5)+dM(W,I,B,H)+U+t[W]+_[G]>>>0;U=H,H=B,B=xy(I,30)>>>0,I=T,T=X}e[0]=e[0]+T>>>0,e[1]=e[1]+I>>>0,e[2]=e[2]+B>>>0,e[3]=e[3]+H>>>0,e[4]=e[4]+U>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var gM=YA("v5",80,pM);const yM="00000000-0000-0000-0000-000000000000";function mM(n){if(!c0(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const XA=Lc(Object.freeze(Object.defineProperty({__proto__:null,NIL:yM,parse:QA,stringify:u0,v1:nM,v3:fM,v4:hM,v5:gM,validate:c0,version:mM},Symbol.toStringTag,{value:"Module"}))),wM=XA.v4;var bM=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:n};if(i===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return wM()};s.id=o(s,r)}else i===2&&e===null?r.notificationIdNull&&(s.id=null):s.id=e;return s};const _M=XA.v4,AM=bM,Sf=function(n,t){if(!(this instanceof Sf))return new Sf(n,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return _M()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var EM=Sf;Sf.prototype.request=function(n,t,e,r){const i=this;let s=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,s=n;else{typeof e=="function"&&(r=e,e=void 0);const f=typeof r=="function";try{s=AM(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(f)return r(h);throw h}if(!f)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(f){return r(f)}return this.callServer(u,function(f,h){i._parseResponse(f,h,r)}),s},Sf.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(i){return e(i)}if(e.length===3)if(Array.isArray(r)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return e(null,r.filter(i),r.filter(s))}else return e(null,r.error,r.result);e(null,r)};const vM=Mr(EM);var xM=class extends Rg{constructor(t,e,r){super();Z(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(t,e,r){const i=r||e;try{this.socket.send(t),i()}catch(s){i(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function RM(n,t){return new xM(n,t)}var IM=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},SM=class extends Rg{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...a}={},u,f){super();Z(this,"address");Z(this,"rpc_id");Z(this,"queue");Z(this,"options");Z(this,"autoconnect");Z(this,"ready");Z(this,"reconnect");Z(this,"reconnect_timer_id");Z(this,"reconnect_interval");Z(this,"max_reconnects");Z(this,"rest_options");Z(this,"current_reconnects");Z(this,"generate_request_id");Z(this,"socket");Z(this,"webSocketFactory");Z(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),f?this.dataPack=f:this.dataPack=new IM,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,r,i){return!i&&typeof r=="object"&&(i=r,r=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,f=>{if(f)return o(f);this.queue[a]={promise:[s,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((r,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);r()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=kt.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const i=[r.notification];if(r.params.constructor===Object)i.push(r.params);else for(let s=0;s<r.params.length;s++)i.push(r.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",r,i),0),this.ready=!1,this.socket=void 0,r!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const tE=[],eE=[],nE=[],kM=BigInt(0),kf=BigInt(1),TM=BigInt(2),OM=BigInt(7),NM=BigInt(256),CM=BigInt(113);for(let n=0,t=kf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],tE.push(2*(5*r+e)),eE.push((n+1)*(n+2)/2%64);let i=kM;for(let s=0;s<7;s++)t=(t<<kf^(t>>OM)*CM)%NM,t&TM&&(i^=kf<<(kf<<BigInt(s))-kf);nE.push(i)}const[BM,PM]=Q_(nE,!0),rE=(n,t,e)=>e>32?X_(n,t,e):Y_(n,t,e),iE=(n,t,e)=>e>32?tA(n,t,e):J_(n,t,e);function MM(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=rE(f,h,1)^e[a],_=iE(f,h,1)^e[a+1];for(let w=0;w<50;w+=10)n[o+w]^=y,n[o+w+1]^=_}let i=n[2],s=n[3];for(let o=0;o<24;o++){const a=eE[o],u=rE(i,s,a),f=iE(i,s,a),h=tE[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=BM[r],n[1]^=PM[r]}e.fill(0)}let LM=class sO extends zg{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,zd(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=mP(this.state)}keccak(){K_||j_(this.state32),MM(this.state32,this.rounds),K_||j_(this.state32),this.posOut=0,this.pos=0}update(t){Yc(this);const{blockLen:e,state:r}=this;t=Gd(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Yc(this,!1),bf(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return zd(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(V_(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new sO(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const sE=((n,t,e)=>Gg(()=>new LM(t,n,e)))(1,136,256/8);let oE=class extends zg{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,yP(t);const r=Gd(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return Yc(this),this.iHash.update(t),this}digestInto(t){Yc(this),bf(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const aE=(n,t,e)=>new oE(n,t).update(e).digest();aE.create=(n,t)=>new oE(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function cE(n){n.lowS!==void 0&&Es("lowS",n.lowS),n.prehash!==void 0&&Es("prehash",n.prehash)}function UM(n){const t=ey(n);ru(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:DM,hexToBytes:FM}=WP;class $M extends Error{constructor(t=""){super(t)}}const Rs={Err:$M,_tlv:{encode:(n,t)=>{const{Err:e}=Rs;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const r=t.length/2,i=Xc(r);if(i.length/2&128)throw new e("tlv.encode: long form length too big");const s=r>127?Xc(i.length/2|128):"";return Xc(n)+s+i+t},decode(n,t){const{Err:e}=Rs;let r=0;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[r++]!==n)throw new e("tlv.decode: wrong tlv");const i=t[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new e("tlv.decode(long): indefinite length not supported");if(u>4)throw new e("tlv.decode(long): byte length is too big");const f=t.subarray(r,r+u);if(f.length!==u)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const h of f)o=o<<8|h;if(r+=u,o<128)throw new e("tlv.decode(long): not minimal encoding")}const a=t.subarray(r,r+o);if(a.length!==o)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+o)}}},_int:{encode(n){const{Err:t}=Rs;if(n<Is)throw new t("integer: negative integers are not allowed");let e=Xc(n);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(n){const{Err:t}=Rs;if(n[0]&128)throw new t("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return DM(n)}},toSig(n){const{Err:t,_int:e,_tlv:r}=Rs,i=typeof n=="string"?FM(n):n;_f(i);const{v:s,l:o}=r.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:u}=r.decode(2,s),{v:f,l:h}=r.decode(2,u);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(f)}},hexFromSig(n){const{_tlv:t,_int:e}=Rs,r=t.encode(2,e.encode(n.r)),i=t.encode(2,e.encode(n.s)),s=r+i;return t.encode(48,s)}},Is=BigInt(0),Mn=BigInt(1);BigInt(2);const uE=BigInt(3);BigInt(4);function HM(n){const t=UM(n),{Fp:e}=t,r=Zd(t.n,t.nBitLength),i=t.toBytes||((T,I,B)=>{const H=I.toAffine();return Aa(Uint8Array.from([4]),e.toBytes(H.x),e.toBytes(H.y))}),s=t.fromBytes||(T=>{const I=T.subarray(1),B=e.fromBytes(I.subarray(0,e.BYTES)),H=e.fromBytes(I.subarray(e.BYTES,2*e.BYTES));return{x:B,y:H}});function o(T){const{a:I,b:B}=t,H=e.sqr(T),U=e.mul(H,T);return e.add(e.add(U,e.mul(T,I)),B)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(T){return Wd(T,Mn,t.n)}function u(T){const{allowedPrivateKeyLengths:I,nByteLength:B,wrapPrivateKey:H,n:U}=t;if(I&&typeof T!="bigint"){if(wa(T)&&(T=ba(T)),typeof T!="string"||!I.includes(T.length))throw new Error("invalid private key");T=T.padStart(B*2,"0")}let G;try{G=typeof T=="bigint"?T:_a(Tn("private key",T,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof T)}return H&&(G=qe(G,U)),Jr("private key",G,Mn,U),G}function f(T){if(!(T instanceof _))throw new Error("ProjectivePoint expected")}const h=Ef((T,I)=>{const{px:B,py:H,pz:U}=T;if(e.eql(U,e.ONE))return{x:B,y:H};const G=T.is0();I==null&&(I=G?e.ONE:e.inv(U));const W=e.mul(B,I),X=e.mul(H,I),j=e.mul(U,I);if(G)return{x:e.ZERO,y:e.ZERO};if(!e.eql(j,e.ONE))throw new Error("invZ was invalid");return{x:W,y:X}}),y=Ef(T=>{if(T.is0()){if(t.allowInfinityPoint&&!e.is0(T.py))return;throw new Error("bad point: ZERO")}const{x:I,y:B}=T.toAffine();if(!e.isValid(I)||!e.isValid(B))throw new Error("bad point: x or y not FE");const H=e.sqr(B),U=o(I);if(!e.eql(H,U))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(I,B,H){if(this.px=I,this.py=B,this.pz=H,I==null||!e.isValid(I))throw new Error("x required");if(B==null||!e.isValid(B))throw new Error("y required");if(H==null||!e.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(I){const{x:B,y:H}=I||{};if(!I||!e.isValid(B)||!e.isValid(H))throw new Error("invalid affine point");if(I instanceof _)throw new Error("projective point not allowed");const U=G=>e.eql(G,e.ZERO);return U(B)&&U(H)?_.ZERO:new _(B,H,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(I){const B=e.invertBatch(I.map(H=>H.pz));return I.map((H,U)=>H.toAffine(B[U])).map(_.fromAffine)}static fromHex(I){const B=_.fromAffine(s(Tn("pointHex",I)));return B.assertValidity(),B}static fromPrivateKey(I){return _.BASE.multiply(u(I))}static msm(I,B){return pA(_,r,I,B)}_setWindowSize(I){R.setWindowSize(this,I)}assertValidity(){y(this)}hasEvenY(){const{y:I}=this.toAffine();if(e.isOdd)return!e.isOdd(I);throw new Error("Field doesn't support isOdd")}equals(I){f(I);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:X}=I,j=e.eql(e.mul(B,X),e.mul(G,U)),J=e.eql(e.mul(H,X),e.mul(W,U));return j&&J}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){const{a:I,b:B}=t,H=e.mul(B,uE),{px:U,py:G,pz:W}=this;let X=e.ZERO,j=e.ZERO,J=e.ZERO,it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(W,W),ot=e.mul(U,G);return ot=e.add(ot,ot),J=e.mul(U,W),J=e.add(J,J),X=e.mul(I,J),j=e.mul(H,rt),j=e.add(X,j),X=e.sub(ut,j),j=e.add(ut,j),j=e.mul(X,j),X=e.mul(ot,X),J=e.mul(H,J),rt=e.mul(I,rt),ot=e.sub(it,rt),ot=e.mul(I,ot),ot=e.add(ot,J),J=e.add(it,it),it=e.add(J,it),it=e.add(it,rt),it=e.mul(it,ot),j=e.add(j,it),rt=e.mul(G,W),rt=e.add(rt,rt),it=e.mul(rt,ot),X=e.sub(X,it),J=e.mul(rt,ut),J=e.add(J,J),J=e.add(J,J),new _(X,j,J)}add(I){f(I);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:X}=I;let j=e.ZERO,J=e.ZERO,it=e.ZERO;const ut=t.a,rt=e.mul(t.b,uE);let ot=e.mul(B,G),C=e.mul(H,W),p=e.mul(U,X),m=e.add(B,H),v=e.add(G,W);m=e.mul(m,v),v=e.add(ot,C),m=e.sub(m,v),v=e.add(B,U);let k=e.add(G,X);return v=e.mul(v,k),k=e.add(ot,p),v=e.sub(v,k),k=e.add(H,U),j=e.add(W,X),k=e.mul(k,j),j=e.add(C,p),k=e.sub(k,j),it=e.mul(ut,v),j=e.mul(rt,p),it=e.add(j,it),j=e.sub(C,it),it=e.add(C,it),J=e.mul(j,it),C=e.add(ot,ot),C=e.add(C,ot),p=e.mul(ut,p),v=e.mul(rt,v),C=e.add(C,p),p=e.sub(ot,p),p=e.mul(ut,p),v=e.add(v,p),ot=e.mul(C,v),J=e.add(J,ot),ot=e.mul(k,v),j=e.mul(m,j),j=e.sub(j,ot),ot=e.mul(m,C),it=e.mul(k,it),it=e.add(it,ot),new _(j,J,it)}subtract(I){return this.add(I.negate())}is0(){return this.equals(_.ZERO)}wNAF(I){return R.wNAFCached(this,I,_.normalizeZ)}multiplyUnsafe(I){const{endo:B,n:H}=t;Jr("scalar",I,Is,H);const U=_.ZERO;if(I===Is)return U;if(this.is0()||I===Mn)return this;if(!B||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,I,_.normalizeZ);let{k1neg:G,k1:W,k2neg:X,k2:j}=B.splitScalar(I),J=U,it=U,ut=this;for(;W>Is||j>Is;)W&Mn&&(J=J.add(ut)),j&Mn&&(it=it.add(ut)),ut=ut.double(),W>>=Mn,j>>=Mn;return G&&(J=J.negate()),X&&(it=it.negate()),it=new _(e.mul(it.px,B.beta),it.py,it.pz),J.add(it)}multiply(I){const{endo:B,n:H}=t;Jr("scalar",I,Mn,H);let U,G;if(B){const{k1neg:W,k1:X,k2neg:j,k2:J}=B.splitScalar(I);let{p:it,f:ut}=this.wNAF(X),{p:rt,f:ot}=this.wNAF(J);it=R.constTimeNegate(W,it),rt=R.constTimeNegate(j,rt),rt=new _(e.mul(rt.px,B.beta),rt.py,rt.pz),U=it.add(rt),G=ut.add(ot)}else{const{p:W,f:X}=this.wNAF(I);U=W,G=X}return _.normalizeZ([U,G])[0]}multiplyAndAddUnsafe(I,B,H){const U=_.BASE,G=(X,j)=>j===Is||j===Mn||!X.equals(U)?X.multiplyUnsafe(j):X.multiply(j),W=G(this,B).add(G(I,H));return W.is0()?void 0:W}toAffine(I){return h(this,I)}isTorsionFree(){const{h:I,isTorsionFree:B}=t;if(I===Mn)return!0;if(B)return B(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:I,clearCofactor:B}=t;return I===Mn?this:B?B(_,this):this.multiplyUnsafe(t.h)}toRawBytes(I=!0){return Es("isCompressed",I),this.assertValidity(),i(_,this,I)}toHex(I=!0){return Es("isCompressed",I),ba(this.toRawBytes(I))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);const w=t.nBitLength,R=dA(_,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function zM(n){const t=ey(n);return ru(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function GM(n){const t=zM(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(p){return qe(p,r)}function a(p){return Qg(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:y}=HM({...t,toBytes(p,m,v){const k=m.toAffine(),N=e.toBytes(k.x),M=Aa;return Es("isCompressed",v),v?M(Uint8Array.from([m.hasEvenY()?2:3]),N):M(Uint8Array.from([4]),N,e.toBytes(k.y))},fromBytes(p){const m=p.length,v=p[0],k=p.subarray(1);if(m===i&&(v===2||v===3)){const N=_a(k);if(!Wd(N,Mn,e.ORDER))throw new Error("Point is not on curve");const M=h(N);let z;try{z=e.sqrt(M)}catch($){const ct=$ instanceof Error?": "+$.message:"";throw new Error("Point is not on curve"+ct)}const P=(z&Mn)===Mn;return(v&1)===1!==P&&(z=e.neg(z)),{x:N,y:z}}else if(m===s&&v===4){const N=e.fromBytes(k.subarray(0,e.BYTES)),M=e.fromBytes(k.subarray(e.BYTES,2*e.BYTES));return{x:N,y:M}}else{const N=i,M=s;throw new Error("invalid Point, expected length of "+N+", or uncompressed "+M+", got "+m)}}}),_=p=>ba(nu(p,t.nByteLength));function w(p){const m=r>>Mn;return p>m}function R(p){return w(p)?o(-p):p}const T=(p,m,v)=>_a(p.slice(m,v));class I{constructor(m,v,k){this.r=m,this.s=v,this.recovery=k,this.assertValidity()}static fromCompact(m){const v=t.nByteLength;return m=Tn("compactSignature",m,v*2),new I(T(m,0,v),T(m,v,2*v))}static fromDER(m){const{r:v,s:k}=Rs.toSig(Tn("DER",m));return new I(v,k)}assertValidity(){Jr("r",this.r,Mn,r),Jr("s",this.s,Mn,r)}addRecoveryBit(m){return new I(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:k,recovery:N}=this,M=X(Tn("msgHash",m));if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");const z=N===2||N===3?v+t.n:v;if(z>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=N&1?"03":"02",A=u.fromHex(P+_(z)),$=a(z),ct=o(-M*$),dt=o(k*$),wt=u.BASE.multiplyAndAddUnsafe(A,ct,dt);if(!wt)throw new Error("point at infinify");return wt.assertValidity(),wt}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return tu(this.toDERHex())}toDERHex(){return Rs.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return tu(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}const B={isValidPrivateKey(p){try{return f(p),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const p=uA(t.n);return r4(t.randomBytes(p),t.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function U(p){const m=wa(p),v=typeof p=="string",k=(m||v)&&p.length;return m?k===i||k===s:v?k===2*i||k===2*s:p instanceof u}function G(p,m,v=!0){if(U(p))throw new Error("first arg must be private key");if(!U(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(f(p)).toRawBytes(v)}const W=t.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=_a(p),v=p.length*8-t.nBitLength;return v>0?m>>BigInt(v):m},X=t.bits2int_modN||function(p){return o(W(p))},j=Wg(t.nBitLength);function J(p){return Jr("num < 2^"+t.nBitLength,p,Is,j),nu(p,t.nByteLength)}function it(p,m,v=ut){if(["recovered","canonical"].some(Ut=>Ut in v))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:N}=t;let{lowS:M,prehash:z,extraEntropy:P}=v;M==null&&(M=!0),p=Tn("msgHash",p),cE(v),z&&(p=Tn("prehashed msgHash",k(p)));const A=X(p),$=f(m),ct=[J($),J(A)];if(P!=null&&P!==!1){const Ut=P===!0?N(e.BYTES):P;ct.push(Tn("extraEntropy",Ut))}const dt=Aa(...ct),wt=A;function Gt(Ut){const Lt=W(Ut);if(!y(Lt))return;const Re=a(Lt),Kt=u.BASE.multiply(Lt).toAffine(),Ft=o(Kt.x);if(Ft===Is)return;const Te=o(Re*o(wt+Ft*$));if(Te===Is)return;let re=(Kt.x===Ft?0:2)|Number(Kt.y&Mn),oe=Te;return M&&w(Te)&&(oe=R(Te),re^=1),new I(Ft,oe,re)}return{seed:dt,k2sig:Gt}}const ut={lowS:t.lowS,prehash:!1},rt={lowS:t.lowS,prehash:!1};function ot(p,m,v=ut){const{seed:k,k2sig:N}=it(p,m,v),M=t;return iA(M.hash.outputLen,M.nByteLength,M.hmac)(k,N)}u.BASE._setWindowSize(8);function C(p,m,v,k=rt){var re;const N=p;m=Tn("msgHash",m),v=Tn("publicKey",v);const{lowS:M,prehash:z,format:P}=k;if(cE(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 N=="string"||wa(N),$=!A&&!P&&typeof N=="object"&&N!==null&&typeof N.r=="bigint"&&typeof N.s=="bigint";if(!A&&!$)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let ct,dt;try{if($&&(ct=new I(N.r,N.s)),A){try{P!=="compact"&&(ct=I.fromDER(N))}catch(oe){if(!(oe instanceof Rs.Err))throw oe}!ct&&P!=="der"&&(ct=I.fromCompact(N))}dt=u.fromHex(v)}catch{return!1}if(!ct||M&&ct.hasHighS())return!1;z&&(m=t.hash(m));const{r:wt,s:Gt}=ct,Ut=X(m),Lt=a(Gt),Re=o(Ut*Lt),Kt=o(wt*Lt),Ft=(re=u.BASE.multiplyAndAddUnsafe(dt,Re,Kt))==null?void 0:re.toAffine();return Ft?o(Ft.x)===wt:!1}return{CURVE:t,getPublicKey:H,getSharedSecret:G,sign:ot,verify:C,ProjectivePoint:u,Signature:I,utils:B}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function VM(n){return{hash:n,hmac:(t,...e)=>aE(n,t,_P(...e)),randomBytes:W_}}function KM(n,t){const e=r=>GM({...n,...VM(r)});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const lE=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),fE=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),jM=BigInt(1),Ry=BigInt(2),hE=(n,t)=>(n+t/Ry)/t;function WM(n){const t=lE,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=un(h,e,t)*h%t,_=un(y,e,t)*h%t,w=un(_,Ry,t)*f%t,R=un(w,i,t)*w%t,T=un(R,s,t)*R%t,I=un(T,a,t)*T%t,B=un(I,u,t)*I%t,H=un(B,a,t)*T%t,U=un(H,e,t)*h%t,G=un(U,o,t)*R%t,W=un(G,r,t)*f%t,X=un(W,Ry,t);if(!Iy.eql(Iy.sqr(X),n))throw new Error("Cannot find square root");return X}const Iy=Zd(lE,void 0,void 0,{sqrt:WM}),f0=KM({a:BigInt(0),b:BigInt(7),Fp:Iy,n:fE,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=fE,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-jM*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),a=hE(s*n,t),u=hE(-r*n,t);let f=qe(n-a*e-u*i,t),h=qe(-a*r-u*s,t);const y=f>o,_=h>o;if(y&&(f=t-f),_&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:_,k2:h}}}},iy);BigInt(0),f0.ProjectivePoint;const ZM=iu.utils.randomPrivateKey,dE=()=>{const n=iu.utils.randomPrivateKey(),t=h0(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},h0=iu.getPublicKey;function pE(n){try{return iu.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Sy=(n,t)=>iu.sign(n,t.slice(0,32)),qM=iu.verify,te=n=>kt.isBuffer(n)?n:n instanceof Uint8Array?kt.from(n.buffer,n.byteOffset,n.byteLength):kt.from(n);let ky=class{constructor(t){Object.assign(this,t)}encode(){return kt.from(xA(Tf,this))}static decode(t){return RA(Tf,this,t)}static decodeUnchecked(t){return bA(Tf,this,t)}};class QM extends ky{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const Tf=new Map;var gE;const yE=32,Ki=32;function YM(n){return n._bn!==void 0}let mE=1;class pt extends ky{constructor(t){if(super({}),this._bn=void 0,YM(t))this._bn=t._bn;else{if(typeof t=="string"){const e=On.decode(t);if(e.length!=Ki)throw new Error("Invalid public key input");this._bn=new As(e)}else this._bn=new As(t);if(this._bn.byteLength()>Ki)throw new Error("Invalid public key input")}}static unique(){const t=new pt(mE);return mE+=1,new pt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return On.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(kt);if(t.length===Ki)return t;const e=kt.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=kt.concat([t.toBuffer(),kt.from(e),r.toBuffer()]),s=iy(i);return new pt(s)}static createProgramAddressSync(t,e){let r=kt.alloc(0);t.forEach(function(s){if(s.length>yE)throw new TypeError("Max seed length exceeded");r=kt.concat([r,te(s)])}),r=kt.concat([r,e.toBuffer(),kt.from("ProgramDerivedAddress")]);const i=iy(r);if(pE(i))throw new Error("Invalid seeds, address must fall off the curve");return new pt(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,i;for(;r!=0;){try{const s=t.concat(kt.from([r]));i=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new pt(t);return pE(e.toBytes())}}gE=pt,pt.default=new gE("11111111111111111111111111111111"),Tf.set(pt,{kind:"struct",fields:[["_bn","u256"]]});class JM{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=te(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=te(ZM()),this._publicKey=te(h0(this._secretKey))}get publicKey(){return new pt(this._publicKey)}get secretKey(){return kt.concat([this._secretKey,this._publicKey],64)}}const XM=new pt("BPFLoader1111111111111111111111111111111111"),Ao=1232,d0=127,Of=64;class Ty extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Ty.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Oy extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Oy.prototype,"name",{value:"TransactionExpiredTimeoutError"});class lu extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(lu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Nf{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((s,o)=>{r.set(s.toBase58(),o)});const i=s=>{const o=r.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const ce=(n="publicKey")=>We(32,n),tL=(n="signature")=>We(64,n),Sa=(n="string")=>{const t=Nt([Ot("length"),Ot("lengthPadding"),We(bo(Ot(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(s,o)=>e(s,o).chars.toString(),i.encode=(s,o,a)=>{const u={chars:kt.from(s,"utf8")};return r(u,o,a)},i.alloc=s=>Ot().span+Ot().span+kt.from(s,"utf8").length,i},eL=(n="authorized")=>Nt([ce("staker"),ce("withdrawer")],n),nL=(n="lockup")=>Nt([Fr("unixTimestamp"),Fr("epoch"),ce("custodian")],n),rL=(n="voteInit")=>Nt([ce("nodePubkey"),ce("authorizedVoter"),ce("authorizedWithdrawer"),me("commission")],n),iL=(n="voteAuthorizeWithSeedArgs")=>Nt([Ot("voteAuthorizationType"),ce("currentAuthorityDerivedKeyOwnerPubkey"),Sa("currentAuthorityDerivedKeySeed"),ce("newAuthorized")],n);function wE(n,t){const e=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(t[i.property]);if("count"in i&&"elementLayout"in i){const s=t[i.property];if(Array.isArray(s))return s.length*e(i.elementLayout)}else if("fields"in i)return wE({layout:i},t[i.property]);return 0};let r=0;return n.layout.fields.forEach(i=>{r+=e(i)}),r}function Rr(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function $r(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function _e(n,t){if(!n)throw new Error(t||"Assertion failed")}class p0{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,i=o=>{const a=o.toBase58();let u=r.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,u)),u},s=i(e);s.isSigner=!0,s.isWritable=!0;for(const o of t){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 p0(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];_e(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),r=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),s=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{_e(e.length>0,"Expected at least one writable signer key");const[u]=e[0];_e(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([u])=>new pt(u)),...r.map(([u])=>new pt(u)),...i.map(([u])=>new pt(u)),...s.map(([u])=>new pt(u))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(t,e){const r=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(e(o)){const a=new pt(s),u=t.findIndex(f=>f.equals(a));u>=0&&(_e(u<256,"Max lookup table index exceeded"),r.push(u),i.push(a),this.keyMetaMap.delete(s))}return[r,i]}}const bE="Reached end of buffer unexpectedly";function ji(n){if(n.length===0)throw new Error(bE);return n.shift()}function Ir(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(bE);return n.splice(...t)}class Ai{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new pt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:On.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Nf(this.staticAccountKeys)}static compile(t){const e=p0.compile(t.instructions,t.payerKey),[r,i]=e.getMessageComponents(),o=new Nf(i).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:On.encode(a.data)}));return new Ai({header:r,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<s}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];$r(e,t);const r=this.instructions.map(y=>{const{accounts:_,programIdIndex:w}=y,R=Array.from(On.decode(y.data));let T=[];$r(T,_.length);let I=[];return $r(I,R.length),{programIdIndex:w,keyIndicesCount:kt.from(T),keyIndices:_,dataLength:kt.from(I),data:R}});let i=[];$r(i,r.length);let s=kt.alloc(Ao);kt.from(i).copy(s);let o=i.length;r.forEach(y=>{const w=Nt([me("programIdIndex"),We(y.keyIndicesCount.length,"keyIndicesCount"),jn(me("keyIndex"),y.keyIndices.length,"keyIndices"),We(y.dataLength.length,"dataLength"),jn(me("userdatum"),y.data.length,"data")]).encode(y,s,o);o+=w}),s=s.slice(0,o);const a=Nt([We(1,"numRequiredSignatures"),We(1,"numReadonlySignedAccounts"),We(1,"numReadonlyUnsignedAccounts"),We(e.length,"keyCount"),jn(ce("key"),t,"keys"),ce("recentBlockhash")]),u={numRequiredSignatures:kt.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:kt.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:kt.from([this.header.numReadonlyUnsignedAccounts]),keyCount:kt.from(e),keys:this.accountKeys.map(y=>te(y.toBytes())),recentBlockhash:On.decode(this.recentBlockhash)};let f=kt.alloc(2048);const h=a.encode(u,f);return s.copy(f,h),f.slice(0,h+s.length)}static from(t){let e=[...t];const r=ji(e);if(r!==(r&d0))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=ji(e),s=ji(e),o=Rr(e);let a=[];for(let _=0;_<o;_++){const w=Ir(e,0,Ki);a.push(new pt(kt.from(w)))}const u=Ir(e,0,Ki),f=Rr(e);let h=[];for(let _=0;_<f;_++){const w=ji(e),R=Rr(e),T=Ir(e,0,R),I=Rr(e),B=Ir(e,0,I),H=On.encode(kt.from(B));h.push({programIdIndex:w,accounts:T,data:H})}const y={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:On.encode(kt.from(u)),accountKeys:a,instructions:h};return new Ai(y)}}class ka{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Nf(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const i=t-r,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=t.find(s=>s.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const s of r.writableIndexes)if(s<i.state.addresses.length)e.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(const s of r.readonlyIndexes)if(s<i.state.addresses.length)e.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=p0.compile(t.instructions,t.payerKey),r=new Array,i={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const h of s){const y=e.extractTableLookup(h);if(y!==void 0){const[_,{writable:w,readonly:R}]=y;r.push(_),i.writable.push(...w),i.readonly.push(...R)}}const[o,a]=e.getMessageComponents(),f=new Nf(a,i).compileInstructions(t.instructions);return new ka({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:f,addressTableLookups:r})}serialize(){const t=Array();$r(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();$r(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();$r(s,this.addressTableLookups.length);const o=Nt([me("prefix"),Nt([me("numRequiredSignatures"),me("numReadonlySignedAccounts"),me("numReadonlyUnsignedAccounts")],"header"),We(t.length,"staticAccountKeysLength"),jn(ce(),this.staticAccountKeys.length,"staticAccountKeys"),ce("recentBlockhash"),We(r.length,"instructionsLength"),We(e.length,"serializedInstructions"),We(s.length,"addressTableLookupsLength"),We(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(Ao),f=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:On.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,f)}serializeInstructions(){let t=0;const e=new Uint8Array(Ao);for(const r of this.compiledInstructions){const i=Array();$r(i,r.accountKeyIndexes.length);const s=Array();$r(s,r.data.length);const o=Nt([me("programIdIndex"),We(i.length,"encodedAccountKeyIndexesLength"),jn(me(),r.accountKeyIndexes.length,"accountKeyIndexes"),We(s.length,"encodedDataLength"),We(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Ao);for(const r of this.addressTableLookups){const i=Array();$r(i,r.writableIndexes.length);const s=Array();$r(s,r.readonlyIndexes.length);const o=Nt([ce("accountKey"),We(i.length,"encodedWritableIndexesLength"),jn(me(),r.writableIndexes.length,"writableIndexes"),We(s.length,"encodedReadonlyIndexesLength"),jn(me(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=ji(e),i=r&d0;_e(r!==i,"Expected versioned message but received legacy message");const s=i;_e(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:ji(e),numReadonlySignedAccounts:ji(e),numReadonlyUnsignedAccounts:ji(e)},a=[],u=Rr(e);for(let R=0;R<u;R++)a.push(new pt(Ir(e,0,Ki)));const f=On.encode(Ir(e,0,Ki)),h=Rr(e),y=[];for(let R=0;R<h;R++){const T=ji(e),I=Rr(e),B=Ir(e,0,I),H=Rr(e),U=new Uint8Array(Ir(e,0,H));y.push({programIdIndex:T,accountKeyIndexes:B,data:U})}const _=Rr(e),w=[];for(let R=0;R<_;R++){const T=new pt(Ir(e,0,Ki)),I=Rr(e),B=Ir(e,0,I),H=Rr(e),U=Ir(e,0,H);w.push({accountKey:T,writableIndexes:B,readonlyIndexes:U})}return new ka({header:o,staticAccountKeys:a,recentBlockhash:f,compiledInstructions:y,addressTableLookups:w})}}const Ny={deserializeMessageVersion(n){const t=n[0],e=t&d0;return e===t?"legacy":e},deserialize:n=>{const t=Ny.deserializeMessageVersion(n);if(t==="legacy")return Ai.from(n);if(t===0)return ka.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let Ss=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const sL=kt.alloc(Of).fill(0);class Me{constructor(t){this.keys=void 0,this.programId=void 0,this.data=kt.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}let Ne=class Sb{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Me(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let T=0;T<e.length;T++)if(e[T].programId===void 0)throw new Error(`Transaction instruction index ${T} has undefined program id`);const i=[],s=[];e.forEach(T=>{T.keys.forEach(B=>{s.push({...B})});const I=T.programId.toString();i.includes(I)||i.push(I)}),i.forEach(T=>{s.push({pubkey:new pt(T),isSigner:!1,isWritable:!1})});const o=[];s.forEach(T=>{const I=T.pubkey.toString(),B=o.findIndex(H=>H.pubkey.toString()===I);B>-1?(o[B].isWritable=o[B].isWritable||T.isWritable,o[B].isSigner=o[B].isSigner||T.isSigner):o.push(T)}),o.sort(function(T,I){if(T.isSigner!==I.isSigner)return T.isSigner?-1:1;if(T.isWritable!==I.isWritable)return T.isWritable?-1:1;const B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return T.pubkey.toBase58().localeCompare(I.pubkey.toBase58(),"en",B)});const a=o.findIndex(T=>T.pubkey.equals(r));if(a>-1){const[T]=o.splice(a,1);T.isSigner=!0,T.isWritable=!0,o.unshift(T)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const T of this.signatures){const I=o.findIndex(B=>B.pubkey.equals(T.publicKey));if(I>-1)o[I].isSigner||(o[I].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: ${T.publicKey.toString()}`)}let u=0,f=0,h=0;const y=[],_=[];o.forEach(({pubkey:T,isSigner:I,isWritable:B})=>{I?(y.push(T.toString()),u+=1,B||(f+=1)):(_.push(T.toString()),B||(h+=1))});const w=y.concat(_),R=e.map(T=>{const{data:I,programId:B}=T;return{programIdIndex:w.indexOf(B.toString()),accounts:T.keys.map(H=>w.indexOf(H.pubkey.toString())),data:On.encode(I)}});return R.forEach(T=>{_e(T.programIdIndex>=0),T.accounts.forEach(I=>_e(I>=0))}),new Ai({header:{numRequiredSignatures:u,numReadonlySignedAccounts:f,numReadonlyUnsignedAccounts:h},accountKeys:w,recentBlockhash:t,instructions:R})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,s)=>e[s].equals(i.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(r=>{const i=r.toString();return e.has(i)?!1:(e.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}const i=this._compile();this._partialSign(i,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(i=>{const s=Sy(r,i.secretKey);this._addSignature(i.publicKey,te(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){_e(e.length===64);const r=this.signatures.findIndex(i=>t.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=kt.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:i,publicKey:s}of this.signatures)i===null?e&&(r.missing||(r.missing=[])).push(s):qM(i,t,s.toBytes())||(r.invalid||(r.invalid=[])).push(s);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(r){const s=this._getMessageSignednessErrors(i,e);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
|
|
19
17
|
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(
|
|
21
|
-
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(
|
|
22
|
-
${
|
|
23
|
-
Message: ${
|
|
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 xV={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 qm(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 Ta(r){return new Promise(e=>setTimeout(e,r))}function yt(r,e){const t=r.layout.span>=0?r.layout.span:Cx(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 Mx=Vr("lamportsPerSignature"),Lx=Me([Pe("version"),Pe("state"),lt("authorizedPubkey"),lt("nonce"),Me([Mx],"feeCalculator")]),Zm=Lx.span;class N0{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=Lx.decode(nt(e),0);return new N0({authorizedPubkey:new me(t.authorizedPubkey),nonce:new me(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const RV=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},hu=(r=>e=>{const t=Wt(r,e),{encode:n,decode:i}=RV(t),s=t;return s.decode=(o,a)=>{const u=i(o,a);return tK(Ne.from(u))},s.encode=(o,a,u)=>{const l=tx(o,r);return n(l,a,u)},s})(8);class IV{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"),zn("lamports"),zn("space"),lt("programId")])},Assign:{index:1,layout:Me([Pe("instruction"),lt("programId")])},Transfer:{index:2,layout:Me([Pe("instruction"),hu("lamports")])},CreateWithSeed:{index:3,layout:Me([Pe("instruction"),lt("base"),Sa("seed"),zn("lamports"),zn("space"),lt("programId")])},AdvanceNonceAccount:{index:4,layout:Me([Pe("instruction")])},WithdrawNonceAccount:{index:5,layout:Me([Pe("instruction"),zn("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"),zn("space")])},AllocateWithSeed:{index:9,layout:Me([Pe("instruction"),lt("base"),Sa("seed"),zn("space"),lt("programId")])},AssignWithSeed:{index:10,layout:Me([Pe("instruction"),lt("base"),Sa("seed"),lt("programId")])},TransferWithSeed:{index:11,layout:Me([Pe("instruction"),hu("lamports"),Sa("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:Zm,programId:this.programId})):t.add(Br.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Zm,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:T0,isSigner:!1,isWritable:!1},{pubkey:fu,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:T0,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:T0,isSigner:!1,isWritable:!1},{pubkey:fu,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 SV=bo-300;class Oa{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Oa.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 qm(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=Oa.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(qm(e,w,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Ta(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:fu,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(Px/2)))}}return!0}}Oa.chunkSize=SV;const kV=new me("BPFLoader2111111111111111111111111111111111");class TV{static getMinNumSignatures(e){return Oa.getMinNumSignatures(e)}static load(e,t,n,i,s){return Oa.load(e,t,n,s,i)}}function OV(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qm,Ux;function NV(){if(Ux)return Qm;Ux=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 Qm=function(n){var i=t(n,!1);if(i!==void 0)return""+i},Qm}var CV=NV(),Dx=OV(CV);const Lf=32;function Ym(r){let e=0;for(;r>1;)r/=2,e++;return e}function BV(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 $x{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=Ym(BV(e+Lf+1))-Ym(Lf)-1,n=this.getSlotsInEpoch(t),i=e-(n-Lf);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)*Lf:(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+Ym(Lf)):this.slotsPerEpoch}}var PV=globalThis.fetch;class MV extends FK{constructor(e,t,n){const i=s=>{const o=DK(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 LV(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 Fx=56;class Jm{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=LV(UV,e),n=e.length-Fx;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(Fx));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 UV={index:1,layout:Me([Pe("typeIndex"),hu("deactivationSlot"),Vr("lastExtendedSlot"),bt("lastExtendedStartIndex"),bt(),Wr(lt(),mo(bt(),-1),"authority")])},DV=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function $V(r){const e=r.match(DV);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=Of(Cm(me),_e(),r=>new me(r)),Hx=Bm([_e(),rr("base64")]),Xm=Of(Cm(Ne),Hx,r=>Ne.from(r[0],"base64")),zx=30*1e3;function FV(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 Gx(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function jx(r){return gn([pe({jsonrpc:rr("2.0"),id:_e(),result:r}),pe({jsonrpc:rr("2.0"),id:_e(),error:pe({code:uu(),message:_e(),data:He(lK())})})])}const HV=jx(uu());function it(r){return Of(jx(r),HV,e=>"error"in e?e:{...e,result:Ae(e.result,r)})}function Er(r){return it(pe({context:pe({slot:X()}),value:r}))}function C0(r){return pe({context:pe({slot:X()}),value:r})}function e1(r,e){return r===0?new ka({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 zV=pe({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),GV=it(Re(Ie(pe({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:He(Ie(X()))})))),jV=Re(pe({slot:X(),prioritizationFee:X()})),KV=pe({total:X(),validator:X(),foundation:X(),epoch:X()}),VV=pe({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:He(X()),transactionCount:He(X())}),WV=pe({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:Vi(),firstNormalEpoch:X(),firstNormalSlot:X()}),qV=sx(_e(),Re(X())),Na=Ie(gn([pe({}),_e()])),ZV=pe({err:Na}),QV=rr("receivedSignature"),YV=pe({"solana-core":_e(),"feature-set":He(X())}),JV=pe({program:_e(),programId:nr,parsed:uu()}),XV=pe({programId:nr,accounts:Re(nr),data:_e()}),Kx=Er(pe({err:Ie(gn([pe({}),_e()])),logs:Ie(Re(_e())),accounts:He(Ie(Re(Ie(pe({executable:Vi(),owner:_e(),lamports:X(),data:Re(_e()),rentEpoch:He(X())}))))),unitsConsumed:He(X()),returnData:He(Ie(pe({programId:_e(),data:Bm([_e(),rr("base64")])}))),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(gn([JV,XV]))}))))})),eW=Er(pe({byIdentity:sx(_e(),Re(X())),range:pe({firstSlot:X(),lastSlot:X()})}));function tW(r,e,t,n,i,s){const o=t||PV;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 MK(async(h,g)=>{const b={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},tq)};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 Ta(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 rW(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function nW(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 iW=it(zV),sW=it(KV),oW=it(jV),aW=it(VV),cW=it(WV),uW=it(qV),lW=it(X()),fW=Er(pe({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Re(nr)})),t1=pe({amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}),hW=Er(Re(pe({address:nr,amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:He(_e())}))),dW=Er(Re(pe({pubkey:nr,account:pe({executable:Vi(),owner:nr,lamports:X(),data:Xm,rentEpoch:X()})}))),r1=pe({program:_e(),parsed:uu(),space:X()}),pW=Er(Re(pe({pubkey:nr,account:pe({executable:Vi(),owner:nr,lamports:X(),data:r1,rentEpoch:X()})}))),gW=Er(Re(pe({lamports:X(),address:nr}))),Uf=pe({executable:Vi(),owner:nr,lamports:X(),data:Xm,rentEpoch:X()}),yW=pe({pubkey:nr,account:Uf}),mW=Of(gn([Cm(Ne),r1]),gn([Hx,r1]),r=>Array.isArray(r)?Ae(r,Xm):r),n1=pe({executable:Vi(),owner:nr,lamports:X(),data:mW,rentEpoch:X()}),wW=pe({pubkey:nr,account:n1}),bW=pe({state:gn([rr("active"),rr("inactive"),rr("activating"),rr("deactivating")]),active:X(),inactive:X()}),_W=it(Re(pe({signature:_e(),slot:X(),err:Na,memo:Ie(_e()),blockTime:He(Ie(X()))}))),AW=it(Re(pe({signature:_e(),slot:X(),err:Na,memo:Ie(_e()),blockTime:He(Ie(X()))}))),vW=pe({subscription:X(),result:C0(Uf)}),EW=pe({pubkey:nr,account:Uf}),xW=pe({subscription:X(),result:C0(EW)}),RW=pe({parent:X(),slot:X(),root:X()}),IW=pe({subscription:X(),result:RW}),SW=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()})]),kW=pe({subscription:X(),result:SW}),TW=pe({subscription:X(),result:C0(gn([ZV,QV]))}),OW=pe({subscription:X(),result:X()}),NW=pe({pubkey:_e(),gossip:Ie(_e()),tpu:Ie(_e()),rpc:Ie(_e()),version:Ie(_e())}),Vx=pe({votePubkey:_e(),nodePubkey:_e(),activatedStake:X(),epochVoteAccount:Vi(),epochCredits:Re(Bm([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:Ie(X())}),CW=it(pe({current:Re(Vx),delinquent:Re(Vx)})),BW=gn([rr("processed"),rr("confirmed"),rr("finalized")]),PW=pe({slot:X(),confirmations:Ie(X()),err:Na,confirmationStatus:He(BW)}),MW=Er(Re(Ie(PW))),LW=it(X()),Wx=pe({accountKey:nr,writableIndexes:Re(X()),readonlyIndexes:Re(X())}),i1=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(Wx))})}),qx=pe({pubkey:nr,signer:Vi(),writable:Vi(),source:He(gn([rr("transaction"),rr("lookupTable")]))}),Zx=pe({accountKeys:Re(qx),signatures:Re(_e())}),Qx=pe({parsed:uu(),program:_e(),programId:nr}),Yx=pe({accounts:Re(nr),data:_e(),programId:nr}),UW=gn([Yx,Qx]),DW=gn([pe({parsed:uu(),program:_e(),programId:_e()}),pe({accounts:Re(_e()),data:_e(),programId:_e()})]),Jx=Of(UW,DW,r=>"accounts"in r?Ae(r,Yx):Ae(r,Qx)),Xx=pe({signatures:Re(_e()),message:pe({accountKeys:Re(qx),instructions:Re(Jx),recentBlockhash:_e(),addressTableLookups:He(Ie(Re(Wx)))})}),B0=pe({accountIndex:X(),mint:_e(),owner:He(_e()),programId:He(_e()),uiTokenAmount:t1}),eR=pe({writable:Re(nr),readonly:Re(nr)}),P0=pe({err:Na,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(B0))),postTokenBalances:He(Ie(Re(B0))),loadedAddresses:He(eR),computeUnitsConsumed:He(X())}),s1=pe({err:Na,fee:X(),innerInstructions:He(Ie(Re(pe({index:X(),instructions:Re(Jx)})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:He(Ie(Re(_e()))),preTokenBalances:He(Ie(Re(B0))),postTokenBalances:He(Ie(Re(B0))),loadedAddresses:He(eR),computeUnitsConsumed:He(X())}),du=gn([rr(0),rr("legacy")]),Ca=pe({pubkey:_e(),lamports:X(),postBalance:Ie(X()),rewardType:Ie(_e()),commission:He(Ie(X()))}),$W=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:i1,meta:Ie(P0),version:He(du)})),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),FW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),HW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Zx,meta:Ie(P0),version:He(du)})),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),zW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Xx,meta:Ie(s1),version:He(du)})),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),GW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:Zx,meta:Ie(s1),version:He(du)})),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),jW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:He(Re(Ca)),blockTime:Ie(X()),blockHeight:Ie(X())}))),KW=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(pe({transaction:i1,meta:Ie(P0)})),rewards:He(Re(Ca)),blockTime:Ie(X())}))),tR=it(Ie(pe({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),signatures:Re(_e()),blockTime:Ie(X())}))),o1=it(Ie(pe({slot:X(),meta:Ie(P0),blockTime:He(Ie(X())),transaction:i1,version:He(du)}))),M0=it(Ie(pe({slot:X(),transaction:Xx,meta:Ie(s1),blockTime:He(Ie(X())),version:He(du)}))),VW=Er(pe({blockhash:_e(),lastValidBlockHeight:X()})),WW=Er(Vi()),qW=pe({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),ZW=it(Re(qW)),QW=Er(Ie(pe({feeCalculator:pe({lamportsPerSignature:X()})}))),YW=it(_e()),JW=it(_e()),XW=pe({err:Na,logs:Re(_e()),signature:_e()}),eq=pe({result:C0(XW),subscription:X()}),tq={"solana-client":"js/1.0.0-maintenance"};class rR{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=Dx(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=FV(e),this._rpcWsEndpoint=n||$V(e),this._rpcClient=tW(e,i,s,o,a,u),this._rpcRequest=rW(this._rpcClient),this._rpcBatchRequest=nW(this._rpcClient),this._rpcWebSocket=new MV(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,lW);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,fW);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(t1));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(t1));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,dW);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,pW);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,gW);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,hW);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(Uf)));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(n1)));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(n1))));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(Uf))));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(bW));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:Gx(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),l=Re(yW),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(wW)));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 Ta(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 Gm(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 Ta(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 Ta(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 lu(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new lu(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new lu(o);break;default:}b={context:I.context,value:{err:I.value.err}}}else throw new lu(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 jm(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Ae(e,it(Re(NW)));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,CW);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,MW);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,iW);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,GV);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,sW);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,aW);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,cW);if("error"in t)throw new $e(t.error,"failed to get epoch schedule");const n=t.result;return new $x(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Ae(e,uW);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,LW);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,ZW);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,QW);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,oW);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,VW);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,WW);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(YV));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,HW);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,FW);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,$W);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:e1(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,GW);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,zW);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,eW);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,o1);if("error"in a)throw new $e(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:e1(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,M0);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,M0);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,o1);if("error"in l)throw new $e(l.error,"failed to get transactions");const h=l.result;return h&&{...h,transaction:{...h.transaction,message:e1(h.version,h.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=Ae(i,KW);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,tR);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,tR);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,o1);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,M0);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,M0);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,_W);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,AW);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 Jm({key:e,state:Jm.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=N0.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,YW);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 Ta(100);const n=Date.now()-this._blockhashInfo.lastFetch>=zx;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 Ta(Px/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,Kx);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,Kx);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,JW);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,vW);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,i=Dx([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,xW);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:Gx(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,eq);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Ae(e,IW);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,kW);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,TW);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,OW);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 Ba{constructor(e){this._keypair=void 0,this._keypair=e??Sx()}static generate(){return new Ba(Sx())}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=I0(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new Ba({publicKey:n,secretKey:e})}static fromSeed(e){const t=I0(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new Ba({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"),hu("recentSlot"),bt("bumpSeed")])},FreezeLookupTable:{index:1,layout:Me([Pe("instruction")])},ExtendLookupTable:{index:2,layout:Me([Pe("instruction"),hu(),Wr(lt(),mo(Pe(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Me([Pe("instruction")])},CloseLookupTable:{index:4,layout:Me([Pe("instruction")])}});class rq{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(a1.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 a1{constructor(){}static createLookupTable(e){const[t,n]=me.findProgramAddressSync([e.authority.toBuffer(),tx(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})}}a1.programId=new me("AddressLookupTab1e1111111111111111111111111");class nq{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(c1.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"),hu("microLamports")])}});class c1{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})}}c1.programId=new me("ComputeBudget111111111111111111111111111111");const nR=64,iR=32,sR=64,oR=Me([bt("numSignatures"),bt("padding"),ii("signatureOffset"),ii("signatureInstructionIndex"),ii("publicKeyOffset"),ii("publicKeyInstructionIndex"),ii("messageDataOffset"),ii("messageDataSize"),ii("messageInstructionIndex")]);class L0{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;vt(t.length===iR,`Public Key must be ${iR} bytes but received ${t.length} bytes`),vt(i.length===sR,`Signature must be ${sR} bytes but received ${i.length} bytes`);const o=oR.span,a=o+t.length,u=a+i.length,l=1,h=Ne.alloc(u+n.length),g=s??65535;return oR.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:L0.programId,data:h})}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=Ba.fromSecretKey(t),o=s.publicKey.toBytes(),a=Hm(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}L0.programId=new me("Ed25519SigVerify111111111111111111111111111");const iq=(r,e)=>{const t=R0.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};R0.utils.isValidPrivateKey;const sq=R0.getPublicKey,aR=32,u1=20,cR=64,oq=11,l1=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 pu{constructor(){}static publicKeyToEthAddress(e){vt(e.length===cR,`Public key must be ${cR} bytes but received ${e.length} bytes`);try{return Ne.from(bx(nt(e))).slice(-u1)}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 pu.createInstructionWithEthAddress({ethAddress:pu.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===u1,`Address must be ${u1} bytes but received ${a.length} bytes`);const u=1+oq,l=u,h=u+a.length,g=h+i.length+1,b=1,w=Ne.alloc(l1.span+n.length);return l1.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),l1.span),new Pt({keys:[],programId:pu.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;vt(t.length===aR,`Private key must be ${aR} bytes but received ${t.length} bytes`);try{const s=nt(t),o=sq(s,!1).slice(1),a=Ne.from(bx(nt(n))),[u,l]=iq(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:l,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}pu.programId=new me("KeccakSecp256k11111111111111111111111111111");var uR;const lR=new me("StakeConfig11111111111111111111111111111111");class fR{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class Df{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}}uR=Df,Df.default=new uR(0,0,me.default);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(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 fR(new me(t.staker),new me(t.withdrawer)),lockup:new Df(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(U0.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"),pV(),gV()])},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"),zn("lamports")])},Withdraw:{index:4,layout:Me([Pe("instruction"),zn("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"),Sa("authoritySeed"),lt("authorityOwner")])}}),cq=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class U0{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:i}=e,s=i||Df.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:fu,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:O0,isSigner:!1,isWritable:!1},{pubkey:lR,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:O0,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:O0,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})}}U0.programId=new me("Stake11111111111111111111111111111111111111"),U0.space=200;class hR{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 uq{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 hR(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(gu.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"),yV()])},Authorize:{index:1,layout:Me([Pe("instruction"),lt("newAuthorized"),Pe("voteAuthorizationType")])},Withdraw:{index:3,layout:Me([Pe("instruction"),zn("lamports")])},UpdateValidatorIdentity:{index:4,layout:Me([Pe("instruction")])},AuthorizeWithSeed:{index:10,layout:Me([Pe("instruction"),mV()])}}),lq=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class gu{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:fu,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 gu.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})}}gu.programId=new me("Vote111111111111111111111111111111111111111"),gu.space=3762;const dR=new me("Va1idator1nfo111111111111111111111111111111"),fq=pe({name:_e(),website:He(_e()),details:He(_e()),iconUrl:He(_e()),keybaseUsername:He(_e())});class f1{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(dR)&&i[1].isSigner){const s=Sa().decode(Ne.from(t)),o=JSON.parse(s);return nx(o,fq),new f1(i[1].publicKey,o)}return null}}const hq=new me("Vote111111111111111111111111111111111111111"),dq=Me([lt("nodePubkey"),lt("authorizedWithdrawer"),bt("commission"),Vr(),Wr(Me([Vr("slot"),Pe("confirmationCount")]),mo(Pe(),-8),"votes"),bt("rootSlotValid"),Vr("rootSlot"),Vr(),Wr(Me([Vr("epoch"),lt("authorizedVoter")]),mo(Pe(),-8),"authorizedVoters"),Me([Wr(Me([lt("authorizedPubkey"),Vr("epochOfLastAuthorizedSwitch"),Vr("targetEpoch")]),32,"buf"),Vr("idx"),bt("isEmpty")],"priorVoters"),Vr(),Wr(Me([Vr("epoch"),Vr("credits"),Vr("prevCredits")]),mo(Pe(),-8),"epochCredits"),Me([Vr("slot"),Vr("timestamp")],"lastTimestamp")]);class h1{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=dq.decode(nt(e),4);let i=n.rootSlot;return n.rootSlotValid||(i=null),new h1({nodePubkey:new me(n.nodePubkey),authorizedWithdrawer:new me(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:i,authorizedVoters:n.authorizedVoters.map(pq),priorVoters:gq(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function pq({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new me(r)}}function pR({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new me(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function gq({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(pR),...r.slice(0,e).map(pR)]}const gR={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 yq(r,e){const t=e===!1?"http":"https";if(!r)return gR[t].devnet;const n=gR[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function mq(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 wq=Object.freeze(Object.defineProperty({__proto__:null,Account:fV,AddressLookupTableAccount:Jm,AddressLookupTableInstruction:rq,AddressLookupTableProgram:a1,Authorized:fR,BLOCKHASH_CACHE_TIMEOUT_MS:zx,BPF_LOADER_DEPRECATED_PROGRAM_ID:hV,BPF_LOADER_PROGRAM_ID:kV,BpfLoader:TV,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qi,ComputeBudgetInstruction:nq,ComputeBudgetProgram:c1,Connection:rR,Ed25519Program:L0,Enum:uV,EpochSchedule:$x,FeeCalculatorLayout:Mx,Keypair:Ba,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ts,Loader:Oa,Lockup:Df,MAX_SEED_LENGTH:Ox,Message:Ei,MessageAccountKeys:Mf,MessageV0:ka,NONCE_ACCOUNT_LENGTH:Zm,NonceAccount:N0,PACKET_DATA_SIZE:bo,PUBLIC_KEY_LENGTH:Wi,PublicKey:me,SIGNATURE_LENGTH_IN_BYTES:Pf,SOLANA_SCHEMA:Bf,STAKE_CONFIG_ID:lR,STAKE_INSTRUCTION_LAYOUTS:Ur,SYSTEM_INSTRUCTION_LAYOUTS:Ht,SYSVAR_CLOCK_PUBKEY:Zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:bV,SYSVAR_INSTRUCTIONS_PUBKEY:_V,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:T0,SYSVAR_RENT_PUBKEY:fu,SYSVAR_REWARDS_PUBKEY:AV,SYSVAR_SLOT_HASHES_PUBKEY:vV,SYSVAR_SLOT_HISTORY_PUBKEY:EV,SYSVAR_STAKE_HISTORY_PUBKEY:O0,Secp256k1Program:pu,SendTransactionError:_o,SolanaJSONRPCError:$e,SolanaJSONRPCErrorCode:xV,StakeAuthorizationLayout:cq,StakeInstruction:aq,StakeProgram:U0,Struct:zm,SystemInstruction:IV,SystemProgram:Br,Transaction:Ot,TransactionExpiredBlockheightExceededError:Gm,TransactionExpiredNonceInvalidError:lu,TransactionExpiredTimeoutError:jm,TransactionInstruction:Pt,TransactionMessage:Vm,TransactionStatus:ks,VALIDATOR_INFO_KEY:dR,VERSION_PREFIX_MASK:S0,VOTE_PROGRAM_ID:hq,ValidatorInfo:f1,VersionedMessage:Km,VersionedTransaction:Wm,VoteAccount:h1,VoteAuthorizationLayout:lq,VoteInit:hR,VoteInstruction:uq,VoteProgram:gu,clusterApiUrl:yq,sendAndConfirmRawTransaction:mq,sendAndConfirmTransaction:qm},Symbol.toStringTag,{value:"Module"}));var d1={exports:{}};const bq=/[\p{Lu}]/u,_q=/[\p{Ll}]/u,yR=/^[\p{Lu}](?![\p{Lu}])/gu,mR=/([\p{Alpha}\p{N}_]|$)/u,wR=/[_.\- ]+/,Aq=new RegExp("^"+wR.source),bR=new RegExp(wR.source+mR.source,"gu"),_R=new RegExp("\\d+"+mR.source,"gu"),vq=(r,e,t)=>{let n=!1,i=!1,s=!1;for(let o=0;o<r.length;o++){const a=r[o];n&&bq.test(a)?(r=r.slice(0,o)+"-"+r.slice(o),n=!1,s=i,i=!0,o++):i&&s&&_q.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},Eq=(r,e)=>(yR.lastIndex=0,r.replace(yR,t=>e(t))),xq=(r,e)=>(bR.lastIndex=0,_R.lastIndex=0,r.replace(bR,(t,n)=>e(n)).replace(_R,t=>e(t))),AR=(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=vq(r,t,n)),r=r.replace(Aq,""),e.preserveConsecutiveUppercase?r=Eq(r,t):r=t(r),e.pascalCase&&(r=n(r.charAt(0))+r.slice(1)),xq(r,n))};d1.exports=AR,d1.exports.default=AR;var Rq=d1.exports;const Iq=xn(Rq);var Xe={},ke={};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){}};ke.Layout=Nt;function p1(r,e){return e.property?r+"["+e.property+"]":r}ke.nameWithProperty=p1;function Sq(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})}ke.bindConstructorLayout=Sq;let Nn=class extends Nt{isCount(){throw new Error("ExternalLayout is abstract")}};class vR 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 g1=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 Pa 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 yu 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 y1=Math.pow(2,32);function D0(r){const e=Math.floor(r/y1),t=r-e*y1;return{hi32:e,lo32:t}}function $0(r,e){return r*y1+e}let kq=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 $0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=D0(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}};class Tq 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 $0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=D0(e);return t.writeUInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}let Oq=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 $0(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=D0(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}};class Nq 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 $0(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=D0(e);return t.writeInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}class ER 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 xR 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 RR 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 IR 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 SR 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 kR=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)}}},m1=class{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},F0=class extends m1{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)}},w1=class extends Nt{constructor(e,t,n){const i=e instanceof Ji||e instanceof Os;if(i)e=new F0(new g1(e));else if(e instanceof Nn&&e.isCount())e=new F0(e);else if(!(e instanceof m1))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 TR(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]}},TR=class extends Nt{constructor(e,t,n,i){if(!(e instanceof w1))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 mu(r){return 0>r&&(r+=4294967296),r}class b1 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=mu(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 $f(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new OR(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 $f{constructor(e,t,n){if(!(e instanceof b1))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=mu(this.valueMask<<this.start),this.property=n}decode(){const e=this.container._packedGetValue();return mu(e&this.wordMask)>>>this.start}encode(e){if(!Number.isInteger(e)||e!==mu(e&this.valueMask))throw new TypeError(p1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=mu(e<<this.start);this.container._packedSetValue(mu(t&~this.wordMask)|n)}}let OR=class extends $f{constructor(e,t){super(e,1,t)}decode(e,t){return!!$f.prototype.decode.call(this,e,t)}encode(e){return typeof e=="boolean"&&(e=+e),$f.prototype.encode.call(this,e)}},NR=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(p1("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 CR 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 BR 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 PR extends Nt{constructor(e,t){super(0,t),this.value=e}decode(e,t,n){return this.value}encode(e,t,n){return 0}}ke.ExternalLayout=Nn,ke.GreedyCount=vR,ke.OffsetLayout=g1,ke.UInt=Ji,ke.UIntBE=Os,ke.Int=Pa,ke.IntBE=yu,ke.Float=ER,ke.FloatBE=xR,ke.Double=RR,ke.DoubleBE=IR,ke.Sequence=SR,ke.Structure=kR,ke.UnionDiscriminator=m1,ke.UnionLayoutDiscriminator=F0,ke.Union=w1,ke.VariantLayout=TR,ke.BitStructure=b1,ke.BitField=$f,ke.Boolean=OR,ke.Blob=NR,ke.CString=CR,ke.UTF8=BR,ke.Constant=PR,ke.greedy=(r,e)=>new vR(r,e),ke.offset=(r,e,t)=>new g1(r,e,t),ke.u8=r=>new Ji(1,r),ke.u16=r=>new Ji(2,r),ke.u24=r=>new Ji(3,r),ke.u32=r=>new Ji(4,r),ke.u40=r=>new Ji(5,r),ke.u48=r=>new Ji(6,r),ke.nu64=r=>new kq(r),ke.u16be=r=>new Os(2,r),ke.u24be=r=>new Os(3,r),ke.u32be=r=>new Os(4,r),ke.u40be=r=>new Os(5,r),ke.u48be=r=>new Os(6,r),ke.nu64be=r=>new Tq(r),ke.s8=r=>new Pa(1,r),ke.s16=r=>new Pa(2,r),ke.s24=r=>new Pa(3,r),ke.s32=r=>new Pa(4,r),ke.s40=r=>new Pa(5,r),ke.s48=r=>new Pa(6,r),ke.ns64=r=>new Oq(r),ke.s16be=r=>new yu(2,r),ke.s24be=r=>new yu(3,r),ke.s32be=r=>new yu(4,r),ke.s40be=r=>new yu(5,r),ke.s48be=r=>new yu(6,r),ke.ns64be=r=>new Nq(r),ke.f32=r=>new ER(r),ke.f32be=r=>new xR(r),ke.f64=r=>new RR(r),ke.f64be=r=>new IR(r),ke.struct=(r,e,t)=>new kR(r,e,t),ke.bits=(r,e,t)=>new b1(r,e,t),ke.seq=(r,e,t)=>new SR(r,e,t),ke.union=(r,e,t)=>new w1(r,e,t),ke.unionLayoutDiscriminator=(r,e)=>new F0(r,e),ke.blob=(r,e)=>new NR(r,e),ke.cstr=r=>new CR(r),ke.utf8=(r,e)=>new BR(r,e),ke.const=(r,e)=>new PR(r,e);const Cq=Lc(wq);(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=j,r.rustEnum=V,r.array=oe,r.map=ie;const t=ke,n=Cq,i=e(em);var s=ke;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 j(ue){return new w(Z(),B=>B.toString("utf-8"),B=>Ze.from(B,"utf-8"),ue)}function V(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 Bq=4,MR=0,LR=1,Pq=2;function wu(r){let e=r.length;for(;--e>=0;)r[e]=0}const Mq=0,UR=1,Lq=2,Uq=3,Dq=258,_1=29,Ff=256,Hf=Ff+1+_1,bu=30,A1=19,DR=2*Hf+1,Ma=15,v1=16,$q=7,E1=256,$R=16,FR=17,HR=18,x1=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),H0=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Fq=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),zR=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hq=512,Ns=new Array((Hf+2)*2);wu(Ns);const zf=new Array(bu*2);wu(zf);const Gf=new Array(Hq);wu(Gf);const jf=new Array(Dq-Uq+1);wu(jf);const R1=new Array(_1);wu(R1);const z0=new Array(bu);wu(z0);function I1(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 GR,jR,KR;function S1(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}const VR=r=>r<256?Gf[r]:Gf[256+(r>>>7)],Kf=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Cn=(r,e,t)=>{r.bi_valid>v1-t?(r.bi_buf|=e<<r.bi_valid&65535,Kf(r,r.bi_buf),r.bi_buf=e>>v1-r.bi_valid,r.bi_valid+=t-v1):(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])},WR=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},zq=r=>{r.bi_valid===16?(Kf(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)},Gq=(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<=Ma;b++)r.bl_count[b]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<DR;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--)}},qR=(r,e,t)=>{const n=new Array(Ma+1);let i=0,s,o;for(s=1;s<=Ma;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]=WR(n[a]++,a))}},jq=()=>{let r,e,t,n,i;const s=new Array(Ma+1);for(t=0,n=0;n<_1-1;n++)for(R1[n]=t,r=0;r<1<<x1[n];r++)jf[t++]=n;for(jf[t-1]=n,i=0,n=0;n<16;n++)for(z0[n]=i,r=0;r<1<<H0[n];r++)Gf[i++]=n;for(i>>=7;n<bu;n++)for(z0[n]=i<<7,r=0;r<1<<H0[n]-7;r++)Gf[256+i++]=n;for(e=0;e<=Ma;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(qR(Ns,Hf+1,s),r=0;r<bu;r++)zf[r*2+1]=5,zf[r*2]=WR(r,5);GR=new I1(Ns,x1,Ff+1,Hf,Ma),jR=new I1(zf,H0,0,bu,Ma),KR=new I1(new Array(0),Fq,0,A1,$q)},ZR=r=>{let e;for(e=0;e<Hf;e++)r.dyn_ltree[e*2]=0;for(e=0;e<bu;e++)r.dyn_dtree[e*2]=0;for(e=0;e<A1;e++)r.bl_tree[e*2]=0;r.dyn_ltree[E1*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},QR=r=>{r.bi_valid>8?Kf(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},YR=(r,e,t,n)=>{const i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},k1=(r,e,t)=>{const n=r.heap[t];let i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&YR(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!YR(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},JR=(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=jf[i],Xi(r,o+Ff+1,e),a=x1[o],a!==0&&(i-=R1[o],Cn(r,i,a)),n--,o=VR(n),Xi(r,o,t),a=H0[o],a!==0&&(n-=z0[o],Cn(r,n,a)));while(s<r.sym_next);Xi(r,E1,e)},T1=(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=DR,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--)k1(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],k1(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++,k1(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Gq(r,e),qR(t,u,r.bl_count)},XR=(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[$R*2]++):a<=10?r.bl_tree[FR*2]++:r.bl_tree[HR*2]++,a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4))},eI=(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,$R,r.bl_tree),Cn(r,a-3,2)):a<=10?(Xi(r,FR,r.bl_tree),Cn(r,a-3,3)):(Xi(r,HR,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)}},Kq=r=>{let e;for(XR(r,r.dyn_ltree,r.l_desc.max_code),XR(r,r.dyn_dtree,r.d_desc.max_code),T1(r,r.bl_desc),e=A1-1;e>=3&&r.bl_tree[zR[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},Vq=(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[zR[i]*2+1],3);eI(r,r.dyn_ltree,e-1),eI(r,r.dyn_dtree,t-1)},Wq=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return MR;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return LR;for(t=32;t<Ff;t++)if(r.dyn_ltree[t*2]!==0)return LR;return MR};let tI=!1;const qq=r=>{tI||(jq(),tI=!0),r.l_desc=new S1(r.dyn_ltree,GR),r.d_desc=new S1(r.dyn_dtree,jR),r.bl_desc=new S1(r.bl_tree,KR),r.bi_buf=0,r.bi_valid=0,ZR(r)},rI=(r,e,t,n)=>{Cn(r,(Mq<<1)+(n?1:0),3),QR(r),Kf(r,t),Kf(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},Zq=r=>{Cn(r,UR<<1,3),Xi(r,E1,Ns),zq(r)},Qq=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===Pq&&(r.strm.data_type=Wq(r)),T1(r,r.l_desc),T1(r,r.d_desc),o=Kq(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?rI(r,e,t,n):r.strategy===Bq||s===i?(Cn(r,(UR<<1)+(n?1:0),3),JR(r,Ns,zf)):(Cn(r,(Lq<<1)+(n?1:0),3),Vq(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),JR(r,r.dyn_ltree,r.dyn_dtree)),ZR(r),n&&QR(r)},Yq=(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[(jf[t]+Ff+1)*2]++,r.dyn_dtree[VR(e)*2]++),r.sym_next===r.sym_end);var Jq=qq,Xq=rI,eZ=Qq,tZ=Yq,rZ=Zq,nZ={_tr_init:Jq,_tr_stored_block:Xq,_tr_flush_block:eZ,_tr_tally:tZ,_tr_align:rZ},Vf=(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 iZ=()=>{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},sZ=new Uint32Array(iZ());var Dr=(r,e,t,n)=>{const i=sZ,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},_u={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"},Wf={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:oZ,_tr_stored_block:O1,_tr_flush_block:aZ,_tr_tally:Ao,_tr_align:cZ}=nZ,{Z_NO_FLUSH:vo,Z_PARTIAL_FLUSH:uZ,Z_FULL_FLUSH:lZ,Z_FINISH:si,Z_BLOCK:nI,Z_OK:Zr,Z_STREAM_END:iI,Z_STREAM_ERROR:es,Z_DATA_ERROR:fZ,Z_BUF_ERROR:N1,Z_DEFAULT_COMPRESSION:hZ,Z_FILTERED:dZ,Z_HUFFMAN_ONLY:G0,Z_RLE:pZ,Z_FIXED:gZ,Z_DEFAULT_STRATEGY:yZ,Z_UNKNOWN:mZ,Z_DEFLATED:j0}=Wf,wZ=9,bZ=15,_Z=8,C1=256+1+29,AZ=30,vZ=19,EZ=2*C1+1,xZ=15,ht=3,Eo=258,ts=Eo+ht+1,RZ=32,Au=42,B1=57,P1=69,M1=73,L1=91,U1=103,La=113,qf=666,yn=1,vu=2,Ua=3,Eu=4,IZ=3,Da=(r,e)=>(r.msg=_u[e],e),sI=r=>r*2-(r>4?9:0),xo=r=>{let e=r.length;for(;--e>=0;)r[e]=0},SZ=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 jn=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))},Kn=(r,e)=>{aZ(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,jn(r.strm)},Rt=(r,e)=>{r.pending_buf[r.pending++]=e},Zf=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},D1=(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=Vf(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)},oI=(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},xu=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),SZ(r),n+=e),r.strm.avail_in===0)break;if(t=D1(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)},aI=(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,O1(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,jn(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&&(D1(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?Eu:e!==vo&&e!==si&&r.strm.avail_in===0&&r.strstart===r.block_start?vu:(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&&(D1(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,O1(r,r.block_start,n,o),r.block_start+=n,jn(r.strm)),o?Ua:yn)},$1=(r,e)=>{let t,n;for(;;){if(r.lookahead<ts){if(xu(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=oI(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&&(Kn(r,!1),r.strm.avail_out===0))return yn}return r.insert=r.strstart<ht-1?r.strstart:ht-1,e===si?(Kn(r,!0),r.strm.avail_out===0?Ua:Eu):r.sym_next&&(Kn(r,!1),r.strm.avail_out===0)?yn:vu},Ru=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<ts){if(xu(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=oI(r,t),r.match_length<=5&&(r.strategy===dZ||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&&(Kn(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&&Kn(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?(Kn(r,!0),r.strm.avail_out===0?Ua:Eu):r.sym_next&&(Kn(r,!1),r.strm.avail_out===0)?yn:vu},kZ=(r,e)=>{let t,n,i,s;const o=r.window;for(;;){if(r.lookahead<=Eo){if(xu(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&&(Kn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(Kn(r,!0),r.strm.avail_out===0?Ua:Eu):r.sym_next&&(Kn(r,!1),r.strm.avail_out===0)?yn:vu},TZ=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(xu(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&&(Kn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===si?(Kn(r,!0),r.strm.avail_out===0?Ua:Eu):r.sym_next&&(Kn(r,!1),r.strm.avail_out===0)?yn:vu};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 Qf=[new rs(0,0,0,0,aI),new rs(4,4,8,4,$1),new rs(4,5,16,8,$1),new rs(4,6,32,32,$1),new rs(4,4,16,16,Ru),new rs(8,16,32,32,Ru),new rs(8,16,128,128,Ru),new rs(8,32,128,256,Ru),new rs(32,128,258,1024,Ru),new rs(32,258,258,4096,Ru)],OZ=r=>{r.window_size=2*r.w_size,xo(r.head),r.max_lazy_match=Qf[r.level].max_lazy,r.good_match=Qf[r.level].good_length,r.nice_match=Qf[r.level].nice_length,r.max_chain_length=Qf[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 NZ(){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=j0,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(EZ*2),this.dyn_dtree=new Uint16Array((2*AZ+1)*2),this.bl_tree=new Uint16Array((2*vZ+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(xZ+1),this.heap=new Uint16Array(2*C1+1),xo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*C1+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 Yf=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.status!==Au&&e.status!==B1&&e.status!==P1&&e.status!==M1&&e.status!==L1&&e.status!==U1&&e.status!==La&&e.status!==qf?1:0},cI=r=>{if(Yf(r))return Da(r,es);r.total_in=r.total_out=0,r.data_type=mZ;const e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?B1:e.wrap?Au:La,r.adler=e.wrap===2?0:1,e.last_flush=-2,oZ(e),Zr},uI=r=>{const e=cI(r);return e===Zr&&OZ(r.state),e},CZ=(r,e)=>Yf(r)||r.state.wrap!==2?es:(r.state.gzhead=e,Zr),lI=(r,e,t,n,i,s)=>{if(!r)return es;let o=1;if(e===hZ&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>wZ||t!==j0||n<8||n>15||e<0||e>9||s<0||s>gZ||n===8&&o!==1)return Da(r,es);n===8&&(n=9);const a=new NZ;return r.state=a,a.strm=r,a.status=Au,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,uI(r)},BZ=(r,e)=>lI(r,e,j0,bZ,_Z,yZ),PZ=(r,e)=>{if(Yf(r)||e>nI||e<0)return r?Da(r,es):es;const t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===qf&&e!==si)return Da(r,r.avail_out===0?N1:es);const n=t.last_flush;if(t.last_flush=e,t.pending!==0){if(jn(r),r.avail_out===0)return t.last_flush=-1,Zr}else if(r.avail_in===0&&sI(e)<=sI(n)&&e!==si)return Da(r,N1);if(t.status===qf&&r.avail_in!==0)return Da(r,N1);if(t.status===Au&&t.wrap===0&&(t.status=La),t.status===Au){let i=j0+(t.w_bits-8<<4)<<8,s=-1;if(t.strategy>=G0||t.level<2?s=0:t.level<6?s=1:t.level===6?s=2:s=3,i|=s<<6,t.strstart!==0&&(i|=RZ),i+=31-i%31,Zf(t,i),t.strstart!==0&&(Zf(t,r.adler>>>16),Zf(t,r.adler&65535)),r.adler=1,t.status=La,jn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===B1){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>=G0||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=P1;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>=G0||t.level<2?4:0),Rt(t,IZ),t.status=La,jn(r),t.pending!==0)return t.last_flush=-1,Zr}if(t.status===P1){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,jn(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=M1}if(t.status===M1){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)),jn(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=L1}if(t.status===L1){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)),jn(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=U1}if(t.status===U1){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(jn(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=La,jn(r),t.pending!==0)return t.last_flush=-1,Zr}if(r.avail_in!==0||t.lookahead!==0||e!==vo&&t.status!==qf){let i=t.level===0?aI(t,e):t.strategy===G0?TZ(t,e):t.strategy===pZ?kZ(t,e):Qf[t.level].func(t,e);if((i===Ua||i===Eu)&&(t.status=qf),i===yn||i===Ua)return r.avail_out===0&&(t.last_flush=-1),Zr;if(i===vu&&(e===uZ?cZ(t):e!==nI&&(O1(t,0,0,!1),e===lZ&&(xo(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),jn(r),r.avail_out===0))return t.last_flush=-1,Zr}return e!==si?Zr:t.wrap<=0?iI:(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)):(Zf(t,r.adler>>>16),Zf(t,r.adler&65535)),jn(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Zr:iI)},MZ=r=>{if(Yf(r))return es;const e=r.state.status;return r.state=null,e===La?Da(r,fZ):Zr},LZ=(r,e)=>{let t=e.length;if(Yf(r))return es;const n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==Au||n.lookahead)return es;if(i===1&&(r.adler=Vf(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,xu(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,xu(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 UZ=BZ,DZ=lI,$Z=uI,FZ=cI,HZ=CZ,zZ=PZ,GZ=MZ,jZ=LZ,KZ="pako deflate (from Nodeca project)",Jf={deflateInit:UZ,deflateInit2:DZ,deflateReset:$Z,deflateResetKeep:FZ,deflateSetHeader:HZ,deflate:zZ,deflateEnd:GZ,deflateSetDictionary:jZ,deflateInfo:KZ};const VZ=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);var WZ=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)VZ(t,n)&&(r[n]=t[n])}}return r},qZ=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},K0={assign:WZ,flattenChunks:qZ};let fI=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{fI=!1}const Xf=new Uint8Array(256);for(let r=0;r<256;r++)Xf[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Xf[254]=Xf[254]=1;var ZZ=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 QZ=(r,e)=>{if(e<65534&&r.subarray&&fI)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 YZ=(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=Xf[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 QZ(s,i)},JZ=(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+Xf[r[t]]>e?t:e},eh={string2buf:ZZ,buf2string:YZ,utf8border:JZ};function XZ(){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 hI=XZ;const dI=Object.prototype.toString,{Z_NO_FLUSH:eQ,Z_SYNC_FLUSH:tQ,Z_FULL_FLUSH:rQ,Z_FINISH:nQ,Z_OK:V0,Z_STREAM_END:iQ,Z_DEFAULT_COMPRESSION:sQ,Z_DEFAULT_STRATEGY:oQ,Z_DEFLATED:aQ}=Wf;function F1(r){this.options=K0.assign({level:sQ,method:aQ,chunkSize:16384,windowBits:15,memLevel:8,strategy:oQ},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 hI,this.strm.avail_out=0;let t=Jf.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==V0)throw new Error(_u[t]);if(e.header&&Jf.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=eh.string2buf(e.dictionary):dI.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=Jf.deflateSetDictionary(this.strm,n),t!==V0)throw new Error(_u[t]);this._dict_set=!0}}F1.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?nQ:eQ,typeof r=="string"?t.input=eh.string2buf(r):dI.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===tQ||s===rQ)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=Jf.deflate(t,s),i===iQ)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=Jf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===V0;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},F1.prototype.onData=function(r){this.chunks.push(r)},F1.prototype.onEnd=function(r){r===V0&&(this.result=K0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};const W0=16209,cQ=16191;var uQ=function(e,t){let n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H,D,z,W,Z,j,V,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=W0;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=W0;break e}if(j=0,V=b,g===0){if(j+=l-z,z<W){W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}}else if(g<z){if(j+=l+g-z,z-=g,z<W){W-=z;do ce[s++]=b[j++];while(--z);if(j=0,g<W){z=g,W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}}}else if(j+=g-z,z<W){W-=z;do ce[s++]=b[j++];while(--z);j=s-Z,V=ce}for(;W>2;)ce[s++]=V[j++],ce[s++]=V[j++],ce[s++]=V[j++],W-=3;W&&(ce[s++]=V[j++],W>1&&(ce[s++]=V[j++]))}else{j=s-Z;do ce[s++]=ce[j++],ce[s++]=ce[j++],ce[s++]=ce[j++],W-=3;while(W>2);W&&(ce[s++]=ce[j++],W>1&&(ce[s++]=ce[j++]))}}else if(z&64){e.msg="invalid distance code",ie.mode=W0;break e}else{D=x[(D&65535)+(w&(1<<z)-1)];continue r}break}}else if(z&64)if(z&32){ie.mode=cQ;break e}else{e.msg="invalid literal/length code",ie.mode=W0;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 Iu=15,pI=852,gI=592,yI=0,H1=1,mI=2,lQ=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]),fQ=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]),hQ=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]),dQ=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 th=(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,j,V=null,oe;const ce=new Uint16Array(Iu+1),ie=new Uint16Array(Iu+1);let ue=null,B,p,m;for(l=0;l<=Iu;l++)ce[l]=0;for(h=0;h<n;h++)ce[e[t+h]]++;for(w=u,b=Iu;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<=Iu;l++)if(x<<=1,x-=ce[l],x<0)return-1;if(x>0&&(r===yI||b!==1))return-1;for(ie[1]=0,l=1;l<Iu;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===yI?(V=ue=o,oe=20):r===H1?(V=lQ,ue=fQ,oe=257):(V=hQ,ue=dQ,oe=0),H=0,h=0,l=g,j=s,I=w,S=0,W=-1,C=1<<w,Z=C-1,r===H1&&C>pI||r===mI&&C>gI)return 1;for(;;){B=l-S,o[h]+1<oe?(p=0,m=o[h]):o[h]>=oe?(p=ue[o[h]-oe],m=V[o[h]-oe]):(p=96,m=0),D=1<<l-S,z=1<<I,g=z;do z-=D,i[j+(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),j+=g,I=l-S,x=1<<I;I+S<b&&(x-=ce[I+S],!(x<=0));)I++,x<<=1;if(C+=1<<I,r===H1&&C>pI||r===mI&&C>gI)return 1;W=H&Z,i[W]=w<<24|I<<16|j-s|0}}return H!==0&&(i[j+H]=l-S<<24|64<<16|0),a.bits=w,0};const pQ=0,wI=1,bI=2,{Z_FINISH:_I,Z_BLOCK:gQ,Z_TREES:q0,Z_OK:$a,Z_STREAM_END:yQ,Z_NEED_DICT:mQ,Z_STREAM_ERROR:oi,Z_DATA_ERROR:AI,Z_MEM_ERROR:vI,Z_BUF_ERROR:wQ,Z_DEFLATED:EI}=Wf,Z0=16180,xI=16181,RI=16182,II=16183,SI=16184,kI=16185,TI=16186,OI=16187,NI=16188,CI=16189,Q0=16190,Cs=16191,z1=16192,BI=16193,G1=16194,PI=16195,MI=16196,LI=16197,UI=16198,Y0=16199,J0=16200,DI=16201,$I=16202,FI=16203,HI=16204,zI=16205,j1=16206,GI=16207,jI=16208,Yt=16209,KI=16210,VI=16211,bQ=852,_Q=592,AQ=15,WI=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function vQ(){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 Fa=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.mode<Z0||e.mode>VI?1:0},qI=r=>{if(Fa(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=Z0,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(bQ),e.distcode=e.distdyn=new Int32Array(_Q),e.sane=1,e.back=-1,$a},ZI=r=>{if(Fa(r))return oi;const e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,qI(r)},QI=(r,e)=>{let t;if(Fa(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,ZI(r))},YI=(r,e)=>{if(!r)return oi;const t=new vQ;r.state=t,t.strm=r,t.window=null,t.mode=Z0;const n=QI(r,e);return n!==$a&&(r.state=null),n},EQ=r=>YI(r,AQ);let JI=!0,K1,V1;const xQ=r=>{if(JI){K1=new Int32Array(512),V1=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(th(wI,r.lens,0,288,K1,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;th(bI,r.lens,0,32,V1,0,r.work,{bits:5}),JI=!1}r.lencode=K1,r.lenbits=9,r.distcode=V1,r.distbits=5},XI=(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},RQ=(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,j,V;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(Fa(r)||!r.output||!r.input&&r.avail_in!==0)return oi;t=r.state,t.mode===Cs&&(t.mode=z1),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,V=$a;e:for(;;)switch(t.mode){case Z0:if(t.wrap===0){t.mode=z1;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=xI;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=Yt;break}if((l&15)!==EI){r.msg="unknown compression method",t.mode=Yt;break}if(l>>>=4,h-=4,j=(l&15)+8,t.wbits===0&&(t.wbits=j),j>15||j>t.wbits){r.msg="invalid window size",t.mode=Yt;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=l&512?CI:Cs,l=0,h=0;break;case xI:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==EI){r.msg="unknown compression method",t.mode=Yt;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=Yt;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=RI;case RI: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=II;case II: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=SI;case SI: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=kI;case kI:if(t.flags&1024&&(w=t.length,w>a&&(w=a),w&&(t.head&&(j=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),j)),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=TI;case TI:if(t.flags&2048){if(a===0)break e;w=0;do j=n[s+w++],t.head&&j&&t.length<65536&&(t.head.name+=String.fromCharCode(j));while(j&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,j)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=OI;case OI:if(t.flags&4096){if(a===0)break e;w=0;do j=n[s+w++],t.head&&j&&t.length<65536&&(t.head.comment+=String.fromCharCode(j));while(j&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Dr(t.check,n,w,s)),a-=w,s+=w,j)break e}else t.head&&(t.head.comment=null);t.mode=NI;case NI: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=Yt;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 CI:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}r.adler=t.check=WI(l),l=0,h=0,t.mode=Q0;case Q0: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,mQ;r.adler=t.check=1,t.mode=Cs;case Cs:if(e===gQ||e===q0)break e;case z1:if(t.last){l>>>=h&7,h-=h&7,t.mode=j1;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=BI;break;case 1:if(xQ(t),t.mode=Y0,e===q0){l>>>=2,h-=2;break e}break;case 2:t.mode=MI;break;case 3:r.msg="invalid block type",t.mode=Yt}l>>>=2,h-=2;break;case BI: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=Yt;break}if(t.length=l&65535,l=0,h=0,t.mode=G1,e===q0)break e;case G1:t.mode=PI;case PI: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 MI: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=Yt;break}t.have=0,t.mode=LI;case LI: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},V=th(pQ,t.lens,0,19,t.lencode,0,t.work,ce),t.lenbits=ce.bits,V){r.msg="invalid code lengths set",t.mode=Yt;break}t.have=0,t.mode=UI;case UI: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=Yt;break}j=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,j=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,j=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=Yt;break}for(;w--;)t.lens[t.have++]=j}}if(t.mode===Yt)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=Yt;break}if(t.lenbits=9,ce={bits:t.lenbits},V=th(wI,t.lens,0,t.nlen,t.lencode,0,t.work,ce),t.lenbits=ce.bits,V){r.msg="invalid literal/lengths set",t.mode=Yt;break}if(t.distbits=6,t.distcode=t.distdyn,ce={bits:t.distbits},V=th(bI,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,ce),t.distbits=ce.bits,V){r.msg="invalid distances set",t.mode=Yt;break}if(t.mode=Y0,e===q0)break e;case Y0:t.mode=J0;case J0: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,uQ(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=zI;break}if(H&32){t.back=-1,t.mode=Cs;break}if(H&64){r.msg="invalid literal/length code",t.mode=Yt;break}t.extra=H&15,t.mode=DI;case DI: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=$I;case $I: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=Yt;break}t.offset=D,t.extra=H&15,t.mode=FI;case FI: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=Yt;break}t.mode=HI;case HI: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=Yt;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=J0);break;case zI:if(u===0)break e;i[o++]=t.length,u--,t.mode=J0;break;case j1: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):Vf(t.check,i,b,o-b)),b=u,t.wrap&4&&(t.flags?l:WI(l))!==t.check){r.msg="incorrect data check",t.mode=Yt;break}l=0,h=0}t.mode=GI;case GI: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=Yt;break}l=0,h=0}t.mode=jI;case jI:V=yQ;break e;case Yt:V=AI;break e;case KI:return vI;case VI: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<Yt&&(t.mode<j1||e!==_I))&&XI(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):Vf(t.check,i,b,r.next_out-b)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Cs?128:0)+(t.mode===Y0||t.mode===G1?256:0),(g===0&&b===0||e===_I)&&V===$a&&(V=wQ),V},IQ=r=>{if(Fa(r))return oi;let e=r.state;return e.window&&(e.window=null),r.state=null,$a},SQ=(r,e)=>{if(Fa(r))return oi;const t=r.state;return t.wrap&2?(t.head=e,e.done=!1,$a):oi},kQ=(r,e)=>{const t=e.length;let n,i,s;return Fa(r)||(n=r.state,n.wrap!==0&&n.mode!==Q0)?oi:n.mode===Q0&&(i=1,i=Vf(i,e,t,0),i!==n.check)?AI:(s=XI(r,e,t,t),s?(n.mode=KI,vI):(n.havedict=1,$a))};var TQ=ZI,OQ=QI,NQ=qI,CQ=EQ,BQ=YI,PQ=RQ,MQ=IQ,LQ=SQ,UQ=kQ,DQ="pako inflate (from Nodeca project)",Bs={inflateReset:TQ,inflateReset2:OQ,inflateResetKeep:NQ,inflateInit:CQ,inflateInit2:BQ,inflate:PQ,inflateEnd:MQ,inflateGetHeader:LQ,inflateSetDictionary:UQ,inflateInfo:DQ};function $Q(){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 FQ=$Q;const eS=Object.prototype.toString,{Z_NO_FLUSH:HQ,Z_FINISH:zQ,Z_OK:rh,Z_STREAM_END:W1,Z_NEED_DICT:q1,Z_STREAM_ERROR:GQ,Z_DATA_ERROR:tS,Z_MEM_ERROR:jQ}=Wf;function nh(r){this.options=K0.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 hI,this.strm.avail_out=0;let t=Bs.inflateInit2(this.strm,e.windowBits);if(t!==rh)throw new Error(_u[t]);if(this.header=new FQ,Bs.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=eh.string2buf(e.dictionary):eS.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Bs.inflateSetDictionary(this.strm,e.dictionary),t!==rh)))throw new Error(_u[t])}nh.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?zQ:HQ,eS.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===q1&&i&&(s=Bs.inflateSetDictionary(t,i),s===rh?s=Bs.inflate(t,o):s===tS&&(s=q1));t.avail_in>0&&s===W1&&t.state.wrap>0&&r[t.next_in]!==0;)Bs.inflateReset(t),s=Bs.inflate(t,o);switch(s){case GQ:case tS:case q1:case jQ:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===W1))if(this.options.to==="string"){let u=eh.utf8border(t.output,t.next_out),l=t.next_out-u,h=eh.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===rh&&a===0)){if(s===W1)return s=Bs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},nh.prototype.onData=function(r){this.chunks.push(r)},nh.prototype.onEnd=function(r){r===rh&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=K0.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Z1(r,e){const t=new nh(e);if(t.push(r),t.err)throw t.msg||_u[t.err];return t.result}function KQ(r,e){return e=e||{},e.raw=!0,Z1(r,e)}var VQ=nh,WQ=Z1,qQ=KQ,ZQ=Z1,QQ=Wf,YQ={Inflate:VQ,inflate:WQ,inflateRaw:qQ,ungzip:ZQ,constants:QQ};const{Inflate:Sae,inflate:JQ,inflateRaw:kae,ungzip:Tae}=YQ;var XQ=JQ,rS={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})(rS);var eY=rS.exports;const tY=xn(eY);function rY(r,e){return Array.apply(0,new Array(Math.ceil(r.length/e))).map((t,n)=>r.slice(n*e,(n+1)*e))}const Ha=r=>"version"in r;function nY(r){return new TextDecoder("utf-8").decode(r)}function nS(r){return Or.encode(r)}function iS(r){return Ne.from(r,"base64")}function Io(r){return"accounts"in r}async function iY(r){const e=(await me.findProgramAddress([],r))[0];return await me.createWithSeed(e,sY(),r)}function sY(){return"anchor:idl"}const oY=Xe.struct([Xe.publicKey("authority"),Xe.vecU8("data")]);function aY(r){return oY.decode(r)}function cY(r){const e=["name","path","account","relations","generic"],t=s=>s.split(".").map(Iq).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 Su(r,e,t,n){return r!=null&&r.length?r[0].name?t(r):n(r):e()}function uY(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 lY(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 sS(r,e={}){r.forEach(t=>{if(Io(t))sS(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 fY 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 hY(r){return ku(r)&&typeof r[Symbol.iterator]=="function"}function ku(r){return typeof r=="object"&&r!=null}function So(r){return typeof r=="string"?JSON.stringify(r):""+r}function dY(r){const{done:e,value:t}=r.next();return e?void 0:t}function pY(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*oS(r,e,t,n){hY(r)||(r=[r]);for(const i of r){const s=pY(i,e,t,n);s&&(yield s)}}function*Q1(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"&&ku(e.schema)&&ku(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=Q1(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):ku(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 oS(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return oS(h,l,this,u)}:this.refiner=()=>[]}assert(e){return gY(e,this)}create(e){return Y1(e,this)}is(e){return aS(e,this)}mask(e){return yY(e,this)}validate(e,t){return t===void 0&&(t={}),ih(e,this,t)}}function gY(r,e){const t=ih(r,e);if(t[0])throw t[0]}function Y1(r,e){const t=ih(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function yY(r,e){const t=ih(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function aS(r,e){return!ih(r,e)[0]}function ih(r,e,t){t===void 0&&(t={});const n=Q1(r,e,t),i=dY(n);return i[0]?[new fY(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function sh(r,e){return new ko({type:r,schema:null,validator:e})}function mY(){return sh("any",()=>!0)}function J1(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 wY(){return sh("boolean",r=>typeof r=="boolean")}function cS(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 X0(r){return new ko({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function ep(){return sh("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+So(r))}function tp(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 za(){return sh("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(ku(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return ku(t)||"Expected an object, but received: "+So(t)}})}function uS(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})||X1()).coercer(t,n)},validator(t,n){const i=[];for(const s of r){const[...o]=Q1(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 X1(){return sh("unknown",()=>!0)}function bY(r,e,t){return new ko({...r,coercer:(n,i)=>aS(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}const lS=99;async function _Y(r,e,t){if(e.length<=lS)return await fS(r,e,t);{const n=rY(e,lS);return(await Promise.all(n.map(s=>fS(r,s,t)))).flat()}}async function fS(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 AY(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=Y1(b,RY);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 vY(r){return bY(hS(r),EY,e=>"error"in e?e:{...e,result:Y1(e.result,r)})}const EY=hS(X1());function hS(r){return uS([To({jsonrpc:cS("2.0"),id:za(),result:r}),To({jsonrpc:cS("2.0"),id:za(),error:To({code:X1(),message:za(),data:tp(mY())})})])}function xY(r){return vY(To({context:To({slot:ep()}),value:r}))}const RY=xY(To({err:X0(uS([To({}),za()])),logs:X0(J1(za())),accounts:tp(X0(J1(X0(To({executable:wY(),owner:za(),lamports:ep(),data:J1(za()),rentEpoch:tp(ep())}))))),unitsConsumed:tp(ep())}));class oh{constructor(e,t,n=oh.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=oh.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),Ha(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 dS(this.connection,u,n)}catch(l){if(l instanceof ew){const h=nS(Ha(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=Ha(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(Ha(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 dS(this.connection,b,t))}catch(w){if(w instanceof ew){const I=nS(Ha(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=Ha(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(Ha(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 AY(this.connection,e,t,n,i)),o.value.err)throw new IY(o.value);return o.value}}class IY extends Error{constructor(e,t){super(t),this.simulationResponse=e}}async function dS(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 ew(`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 ew extends Error{constructor(e){super(e)}}function tw(){return oh.local()}var SY=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Zc<"u"?Zc:typeof self<"u"?self:{},ee={};Object.defineProperty(ee,"__esModule",{value:!0});var pS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=lk=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=uk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=ck=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=ak=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=ok=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=WS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=KS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=jS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=GS=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=HS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=FS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=$S=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=DS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=US=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=LS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=MS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=PS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=BS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=CS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=NS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=OS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=TS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=kS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=SS=ee.ANCHOR_ERROR__CONSTRAINT_RAW=IS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=RS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=xS=ee.ANCHOR_ERROR__CONSTRAINT_MUT=ES=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=vS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=AS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=_S=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=bS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=wS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=mS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=yS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,gS=ee.ANCHOR_ERROR__DEPRECATED=Lk=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=Mk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=Pk=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=Bk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=Ck=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=Nk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=Ok=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=Tk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=kk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=Sk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=Rk=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=xk=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=Ek=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=Ak=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=_k=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=bk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=wk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=mk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=yk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=gk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=pk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=dk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=hk=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=fk=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,yS=ee.ANCHOR_ERROR__INSTRUCTION_MISSING=100,mS=ee.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,wS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,bS=ee.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,_S=ee.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,AS=ee.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,vS=ee.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,ES=ee.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,xS=ee.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,RS=ee.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,IS=ee.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,SS=ee.ANCHOR_ERROR__CONSTRAINT_RAW=2003,kS=ee.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,TS=ee.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,OS=ee.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,NS=ee.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,CS=ee.ANCHOR_ERROR__CONSTRAINT_STATE=2008,BS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,PS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,MS=ee.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,LS=ee.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,US=ee.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,DS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,$S=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,FS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,HS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,zS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,GS=ee.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,jS=ee.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,KS=ee.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,VS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,WS=ee.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,qS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,ZS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,QS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,YS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,JS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,XS=ee.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,ek=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,tk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,rk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,nk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,ik=ee.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,sk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,ok=ee.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,ak=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,ck=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,uk=ee.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,lk=ee.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;pS=ee.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var fk=ee.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,hk=ee.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,dk=ee.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,pk=ee.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,gk=ee.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,yk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,mk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,wk=ee.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,bk=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,_k=ee.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,Ak=ee.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,vk=ee.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,Ek=ee.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,xk=ee.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,Rk=ee.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,Ik=ee.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,Sk=ee.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,kk=ee.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,Tk=ee.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,Ok=ee.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,Nk=ee.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,Ck=ee.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,Bk=ee.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,Pk=ee.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,Mk=ee.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,Lk=ee.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;gS=ee.ANCHOR_ERROR__DEPRECATED=5e3;const kY=new Map;function Uk(r){return kY.get(r)!==void 0}class Oo extends Error{constructor(e){super(e),this.name="IdlError"}}class ah{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 ah(s)}}class ch 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=ah.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 ch(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 ch(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 ch(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 rp extends Error{constructor(e,t,n){super(),this.code=e,this.msg=t,this.logs=n,n&&(this._programErrorStack=ah.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 rp(s,o,e.logs):(o=TY.get(s),o!==void 0?new rp(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 Dk(r,e){Uk("debug-logs")&&console.log("Translating error:",r);const t=ch.parse(r.logs);if(t)return t;const n=rp.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=ah.parse(r.logs),new Proxy(r,i)}return r}const ve={InstructionMissing:yS,InstructionFallbackNotFound:mS,InstructionDidNotDeserialize:wS,InstructionDidNotSerialize:bS,IdlInstructionStub:_S,IdlInstructionInvalidProgram:AS,IdlAccountNotEmpty:vS,EventInstructionStub:ES,ConstraintMut:xS,ConstraintHasOne:RS,ConstraintSigner:IS,ConstraintRaw:SS,ConstraintOwner:kS,ConstraintRentExempt:TS,ConstraintSeeds:OS,ConstraintExecutable:NS,ConstraintState:CS,ConstraintAssociated:BS,ConstraintAssociatedInit:PS,ConstraintClose:MS,ConstraintAddress:LS,ConstraintZero:US,ConstraintTokenMint:DS,ConstraintTokenOwner:$S,ConstraintMintMintAuthority:FS,ConstraintMintFreezeAuthority:HS,ConstraintMintDecimals:zS,ConstraintSpace:GS,ConstraintAccountIsNone:jS,ConstraintTokenTokenProgram:KS,ConstraintMintTokenProgram:VS,ConstraintAssociatedTokenTokenProgram:WS,ConstraintMintGroupPointerExtension:qS,ConstraintMintGroupPointerExtensionAuthority:ZS,ConstraintMintGroupPointerExtensionGroupAddress:QS,ConstraintMintGroupMemberPointerExtension:YS,ConstraintMintGroupMemberPointerExtensionAuthority:JS,ConstraintMintGroupMemberPointerExtensionMemberAddress:XS,ConstraintMintMetadataPointerExtension:ek,ConstraintMintMetadataPointerExtensionAuthority:tk,ConstraintMintMetadataPointerExtensionMetadataAddress:rk,ConstraintMintCloseAuthorityExtension:nk,ConstraintMintCloseAuthorityExtensionAuthority:ik,ConstraintMintPermanentDelegateExtension:sk,ConstraintMintPermanentDelegateExtensionDelegate:ok,ConstraintMintTransferHookExtension:ak,ConstraintMintTransferHookExtensionAuthority:ck,ConstraintMintTransferHookExtensionProgramId:uk,RequireViolated:lk,RequireEqViolated:pS,RequireKeysEqViolated:fk,RequireNeqViolated:hk,RequireKeysNeqViolated:dk,RequireGtViolated:pk,RequireGteViolated:gk,AccountDiscriminatorAlreadySet:yk,AccountDiscriminatorNotFound:mk,AccountDiscriminatorMismatch:wk,AccountDidNotDeserialize:bk,AccountDidNotSerialize:_k,AccountNotEnoughKeys:Ak,AccountNotMutable:vk,AccountOwnedByWrongProgram:Ek,InvalidProgramId:xk,InvalidProgramExecutable:Rk,AccountNotSigner:Ik,AccountNotSystemOwned:Sk,AccountNotInitialized:kk,AccountNotProgramData:Tk,AccountNotAssociatedTokenAccount:Ok,AccountSysvarMismatch:Nk,AccountReallocExceedsLimit:Ck,AccountDuplicateReallocs:Bk,DeclaredProgramIdMismatch:Pk,TryingToInitPayerAsProgramAccount:Mk,InvalidNumericConversion:Lk,Deprecated:gS},TY=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=Su(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=Su(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 Su(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=>Su(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 OY{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 Vn.format(e,t,this.idl)}}class Vn{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:Vn.formatIdlType(u.type),data:Vn.formatIdlData(u,e.data[u.name],n.types)})),o=Vn.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 Vn.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 Vn.formatIdlDataDefined(s,t,n)}return"unknown"}static formatIdlDataDefined(e,t,n){switch(e.type.kind){case"struct":return"{ "+Su(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+": "+Vn.formatIdlData(a,o,n)}).join(", "),i=>Object.entries(t).map(([s,o])=>s+": "+Vn.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 Su(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+": "+Vn.formatIdlData(g,h,n)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([l,h])=>l+": "+Vn.formatIdlData({name:"",type:a[l]},h,n)).join(", ");return`${i} { ${u} }`})}case"type":return Vn.formatIdlType(e.type.alias)}}static flattenIdlAccounts(e,t){return e.map(n=>{const i=NY(n.name);if(n.hasOwnProperty("accounts")){const s=t?`${t} > ${i}`:i;return Vn.flattenIdlAccounts(n.accounts,s)}else return{...n,name:t?`${t} > ${i}`:i}}).flat()}}function NY(r){const e=r.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}class CY{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 BY{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=iS(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 PY{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 $k{constructor(e){this.instruction=new OY(e),this.accounts=new CY(e),this.events=new BY(e),this.types=new PY(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 np=Bn;function MY(r,e){return e.property?r+"["+e.property+"]":r}class Ga extends Bn{isCount(){throw new Error("ExternalLayout is abstract")}}class Fk extends Ga{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 ip||this.layout instanceof Hk}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 ip 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 Hk 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 rw=Math.pow(2,32);function zk(r){const e=Math.floor(r/rw),t=r-e*rw;return{hi32:e,lo32:t}}function Gk(r,e){return r*rw+e}class LY 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 Gk(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=zk(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}}class UY 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 Gk(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=zk(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}}class DY 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 jk{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Kk extends jk{constructor(e,t){if(!(e instanceof Ga&&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 Vk extends Bn{constructor(e,t,n){const i=e instanceof ip||e instanceof Hk;if(i)e=new Kk(new Fk(e));else if(e instanceof Ga&&e.isCount())e=new Kk(e);else if(!(e instanceof jk))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 $Y(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 $Y extends Bn{constructor(e,t,n,i){if(!(e instanceof Vk))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 FY extends Bn{constructor(e,t){if(!(e instanceof Ga&&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 Ga||(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 Ga&&(i=e.length),!(Ze.isBuffer(e)&&i===e.length))throw new TypeError(MY("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 Ga&&this.length.encode(i,t,n),i}}var HY=(r,e,t)=>new Fk(r,e,t),zY=r=>new ip(1,r),Ps=r=>new ip(4,r),GY=r=>new LY(r),Ms=r=>new UY(r),Pr=(r,e,t)=>new DY(r,e,t),Wk=(r,e,t)=>new Vk(r,e,t),uh=(r,e)=>new FY(r,e);class jY extends np{constructor(e){super(-1,e),this.property=e,this.layout=Pr([Ps("length"),Ps("lengthPadding"),uh(HY(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 sp(r){return new jY(r)}function ai(r){return uh(32,r)}const Wn=Wk(Ps("instruction"));Wn.addVariant(0,Pr([Ms("lamports"),Ms("space"),ai("owner")]),"createAccount"),Wn.addVariant(1,Pr([ai("owner")]),"assign"),Wn.addVariant(2,Pr([Ms("lamports")]),"transfer"),Wn.addVariant(3,Pr([ai("base"),sp("seed"),Ms("lamports"),Ms("space"),ai("owner")]),"createAccountWithSeed"),Wn.addVariant(4,Pr([ai("authorized")]),"advanceNonceAccount"),Wn.addVariant(5,Pr([Ms("lamports")]),"withdrawNonceAccount"),Wn.addVariant(6,Pr([ai("authorized")]),"initializeNonceAccount"),Wn.addVariant(7,Pr([ai("authorized")]),"authorizeNonceAccount"),Wn.addVariant(8,Pr([Ms("space")]),"allocate"),Wn.addVariant(9,Pr([ai("base"),sp("seed"),Ms("space"),ai("owner")]),"allocateWithSeed"),Wn.addVariant(10,Pr([ai("base"),sp("seed"),ai("owner")]),"assignWithSeed"),Wn.addVariant(11,Pr([Ms("lamports"),sp("seed"),ai("owner")]),"transferWithSeed"),Math.max(...Object.values(Wn.registry).map(r=>r.span));class KY extends np{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 qk(r){return new KY(uh(32),e=>new me(e),e=>e.toBuffer(),r)}Pr([Ps("version"),Ps("state"),qk("authorizedPubkey"),qk("nonce"),Pr([GY("lamportsPerSignature")],"feeCalculator")]),new me("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new me("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var Zk={exports:{}};(function(r,e){var t=typeof self<"u"?self:SY,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 j(p){var m=p.toUpperCase();return Z.indexOf(m)>-1?m:p}function V(p,m){m=m||{};var E=m.body;if(p instanceof V){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=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&E)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(E)}V.prototype.clone=function(){return new V(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(V.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 V(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=V,s.Response=ie),o.Headers=I,o.Request=V,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})(Zk,Zk.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 nw="Program log: ",Qk="Program data: ",VY=nw.length,WY=Qk.length;class qY{constructor(e,t,n){this._programId=e,this._provider=t,this._eventParser=new Yk(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 Yk{constructor(e,t){this.coder=t,this.programId=e}*parseLogs(e,t=!1){const n=new QY(e),i=new ZY;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(nw)||e.startsWith(Qk)){const n=e.startsWith(nw)?e.slice(VY):e.slice(WY),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 ZY{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 QY{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 op(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 ap{static build(e,t,n){if(e.name==="_inner")throw new Oo("the _inner name is reserved");const i=(...s)=>{const[o,a]=op(e,[...s]);sS(e.accounts,a.accounts),YY(e,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),Uk("debug-logs")&&console.log("Outgoing account metas:",u),new Pt({keys:u,programId:n,data:t(e.name,lY(e,...o))})};return i.accounts=s=>ap.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 ap.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 YY(r,...e){}class JY{static build(e,t){return(...i)=>{var s,o,a;const[,u]=op(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 XY{static build(e,t,n,i){return async(...o)=>{var a;const u=t(...o),[,l]=op(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 Dk(h,n)}}}}class eJ{static build(e,t,n,i){var s;return((s=e.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new tJ(e,a,n,i,t),o),{})}}class tJ{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??tw(),this._coder=s??new $k(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 _Y(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=lh.get(e.toString());if(n)return n.ee;const i=new tY;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 lh.set(e.toString(),{ee:i,listener:s}),i}async unsubscribe(e){let t=lh.get(e.toString());if(!t){console.warn("Address is not subscribed");return}lh&&await this._provider.connection.removeAccountChangeListener(t.listener).then(()=>{lh.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 lh=new Map;class rJ{static build(e,t,n,i,s,o,a){return async(...l)=>{var h;const g=t(...l),[,b]=op(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 Dk(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 Yk(o,s);for(const C of x.parseLogs(I))S.push(C)}return{events:S,raw:I}}}}function iw(r){return new Jk(uh(8),e=>iJ.fromBuffer(e),e=>e.toBuffer(),r)}function cp(r){return new Jk(uh(32),e=>new me(e),e=>e.toBuffer(),r)}function sw(r,e){return new nJ(r,e)}class Jk extends np{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 nJ extends np{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 iJ=class p6 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 p6([...e].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}};const sJ=Pr([cp("mint"),cp("owner"),iw("amount"),sw(cp(),"delegate"),(r=>{const e=Wk(zY("discriminator"),null,r);return e.addVariant(0,Pr([]),"uninitialized"),e.addVariant(1,Pr([]),"initialized"),e.addVariant(2,Pr([]),"frozen"),e})("state"),sw(iw(),"isNative"),iw("delegatedAmount"),sw(cp(),"closeAuthority")]);function oJ(r){return sJ.decode(r)}class aJ{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 cJ(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&&(Xk(o)?Io(i)?n[s]=this.resolveOptionalsHelper(o,i.accounts):n[s]=eT(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 cJ{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=oJ(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 Tu.fetchIdl(e,this._provider);if(n){const i=new Tu(n,this._provider);this._idls[t]=i.account}}return this._idls[t]}}class uJ{static build(e,t,n,i,s,o,a,u,l,h,g){return(...b)=>new lJ(b,i,s,o,a,u,e,t,n,l,h,g)}}function Xk(r){return typeof r=="object"&&r!==null&&!("_bn"in r)}function eT(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]=Xk(i)?eT(i):xi(i)}return t}class lJ{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 aJ(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 fJ{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=iS(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 hJ{static build(e,t,n,i,s){const o={},a={},u={},l={},h={},g={},b=uY(e),w=e.accounts?eJ.build(e,t,n,i):{};return e.instructions.forEach(I=>{const S=ap.build(I,(Z,j)=>t.instruction.encode(Z,j),n),x=JY.build(I,S),C=XY.build(I,x,b,i),H=rJ.build(I,x,b,i,t,n,e),D=fJ.build(n,I,H,e),z=uJ.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 Tu{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=tw(),n,i){this._idl=cY(e),this._rawIdl=e,this._provider=t,this._programId=xi(e.address),this._coder=n??new $k(this._idl),this._events=new qY(this._programId,t,this._coder);const[s,o,a,u,l,h,g]=hJ.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 Tu.fetchIdl(n,t);if(!i)throw new Error(`IDL not found for program: ${e.toString()}`);return new Tu(i,t)}static async fetchIdl(e,t){t=t??tw();const n=xi(e),i=await iY(n),s=await t.connection.getAccountInfo(i);if(!s)return null;let o=aY(s.data.slice(8));const a=XQ(o.data);return JSON.parse(nY(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 dJ="6.13.5";function pJ(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&&pJ(i,s,n),Object.defineProperty(r,n,{enumerable:!0,value:i,writable:!1})}}function Ou(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(Ou).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 Ou(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=>`${Ou(t)}: ${Ou(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Qr(r,e){return r&&r.code===e}function ow(r){return Qr(r,"CALL_EXCEPTION")}function Jt(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: ${Ou(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];s.push(o+"="+Ou(a))}}s.push(`code=${e}`),s.push(`version=${dJ}`),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 Jt(e,t,n)}function q(r,e,t,n){ge(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function tT(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 up(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 rT(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 rT(r,e,!1)}function wn(r,e){return rT(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 aw(r){return Gt(r,!0)||r instanceof Uint8Array}const nT="0123456789abcdef";function Ce(r){const e=_t(r);let t="0x";for(let n=0;n<e.length;n++){const i=e[n];t+=nT[(i&240)>>4]+nT[i&15]}return t}function xr(r){return"0x"+r.map(e=>Ce(e).substring(2)).join("")}function Nu(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 iT(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 ja(r,e){return iT(r,e,!0)}function gJ(r,e){return iT(r,e,!1)}const lp=BigInt(0),Ri=BigInt(1),Cu=9007199254740991;function yJ(r,e){const t=fp(r,"value"),n=BigInt(at(e,"width"));if(ge(t>>n===lp,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ri){const i=(Ri<<n)-Ri;return-((~t&i)+Ri)}return t}function sT(r,e){let t=Le(r,"value");const n=BigInt(at(e,"width")),i=Ri<<n-Ri;if(t<lp){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 fh(r,e){const t=fp(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>=-Cu&&r<=Cu,"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 fp(r,e){const t=Le(r,e);return ge(t>=lp,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const oT="0123456789abcdef";function cw(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=oT[t>>4],e+=oT[t&15];return BigInt(e)}return Le(r)}function at(r,e){switch(typeof r){case"bigint":return q(r>=-Cu&&r<=Cu,"overflow",e||"value",r),Number(r);case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-Cu&&r<=Cu,"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 mJ(r){return at(cw(r))}function No(r,e){let n=fp(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=fp(r,"value");if(e===lp)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 Bu(r){let e=Ce(aw(r)?r:bn(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const aT="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const cT=BigInt(58);function wJ(r){const e=_t(r);let t=cw(e),n="";for(;t;)n=aT[Number(t%cT)]+n,t/=cT;for(let i=0;i<e.length&&!e[i];i++)n=aT[0]+n;return n}function bJ(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 _J(r){const e=_t(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}class uT{constructor(e,t,n){Q(this,"filter");Q(this,"emitter");se(this,Qu);F(this,Qu,t),ze(this,{emitter:e,filter:n})}async removeListener(){T(this,Qu)!=null&&await this.emitter.off(this.filter,T(this,Qu))}}Qu=new WeakMap;function AJ(r,e,t,n,i){q(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function lT(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 vJ(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),lT(r,e,t))}const EJ=Object.freeze({error:AJ,ignore:lT,replace:vJ});function xJ(r,e){e==null&&(e=EJ.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 RJ(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function hp(r,e){return RJ(xJ(r,e))}function fT(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=Jt("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{s=Jt("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 IJ=12,SJ=250;let hT=fT();const kJ=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),TJ=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let uw=!1;async function dT(r,e){try{const t=r.match(kJ);if(!t)throw new Error("invalid data");return new Co(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?bJ(t[3]):NJ(t[3]))}catch{return new Co(599,"BAD REQUEST (invalid data: URI)",{},null,new Us(r))}}function pT(r){async function e(t,n){try{const i=t.match(TJ);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 dp={data:dT,ipfs:pT("https://gateway.ipfs.io/ipfs/")},gT=new WeakMap;class OJ{constructor(e){se(this,sc);se(this,$o);F(this,sc,[]),F(this,$o,!1),gT.set(e,()=>{if(!T(this,$o)){F(this,$o,!0);for(const t of T(this,sc))setTimeout(()=>{t()},0);F(this,sc,[])}})}addListener(e){ge(!T(this,$o),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,sc).push(e)}get cancelled(){return T(this,$o)}checkSignal(){ge(!this.cancelled,"cancelled","CANCELLED",{})}}sc=new WeakMap,$o=new WeakMap;function pp(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}const Zp=class Zp{constructor(e){se(this,uc);se(this,Yu);se(this,Ju);se(this,Oi);se(this,Ks);se(this,Xu);se(this,el);se(this,Hr);se(this,Zn);se(this,Vs);se(this,oc);se(this,ac);se(this,cc);se(this,as);se(this,Ni);se(this,Fo);F(this,el,String(e)),F(this,Yu,!1),F(this,Ju,!0),F(this,Oi,{}),F(this,Ks,""),F(this,Xu,3e5),F(this,Ni,{slotInterval:SJ,maxAttempts:IJ}),F(this,Fo,null)}get url(){return T(this,el)}set url(e){F(this,el,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,Zn,void 0);else if(typeof e=="string")F(this,Hr,Ls(e)),F(this,Zn,"text/plain");else if(e instanceof Uint8Array)F(this,Hr,e),F(this,Zn,"application/octet-stream");else if(typeof e=="object")F(this,Hr,Ls(JSON.stringify(e))),F(this,Zn,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Hr)!=null}get method(){return T(this,Ks)?T(this,Ks):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),F(this,Ks,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,Oi));return T(this,Vs)&&(e.authorization=`Basic ${_J(Ls(T(this,Vs)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,Zn)&&(e["content-type"]=T(this,Zn)),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,Vs)||null}setCredentials(e,t){q(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,Vs,`${e}:${t}`)}get allowGzip(){return T(this,Ju)}set allowGzip(e){F(this,Ju,!!e)}get allowInsecureAuthentication(){return!!T(this,Yu)}set allowInsecureAuthentication(e){F(this,Yu,!!e)}get timeout(){return T(this,Xu)}set timeout(e){q(e>=0,"timeout must be non-zero","timeout",e),F(this,Xu,e)}get preflightFunc(){return T(this,oc)||null}set preflightFunc(e){F(this,oc,e)}get processFunc(){return T(this,ac)||null}set processFunc(e){F(this,ac,e)}get retryFunc(){return T(this,cc)||null}set retryFunc(e){F(this,cc,e)}get getUrlFunc(){return T(this,Fo)||hT}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 OJ(this)),Ee(this,uc,Ad).call(this,0,yT()+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=gT.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 Zp(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,Zn,T(this,Zn)),i}clone(){const e=new Zp(this.url);return F(e,Ks,T(this,Ks)),T(this,Hr)&&F(e,Hr,T(this,Hr)),F(e,Zn,T(this,Zn)),F(e,Oi,Object.assign({},T(this,Oi))),F(e,Vs,T(this,Vs)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),F(e,oc,T(this,oc)),F(e,ac,T(this,ac)),F(e,cc,T(this,cc)),F(e,Ni,Object.assign({},T(this,Ni))),F(e,Fo,T(this,Fo)),e}static lockConfig(){uw=!0}static getGateway(e){return dp[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(uw)throw new Error("gateways locked");dp[e]=t}static registerGetUrl(e){if(uw)throw new Error("gateways locked");hT=e}static createGetUrlFunc(e){return fT()}static createDataGateway(){return dT}static createIpfsGatewayFunc(e){return pT(e)}};Yu=new WeakMap,Ju=new WeakMap,Oi=new WeakMap,Ks=new WeakMap,Xu=new WeakMap,el=new WeakMap,Hr=new WeakMap,Zn=new WeakMap,Vs=new WeakMap,oc=new WeakMap,ac=new WeakMap,cc=new WeakMap,as=new WeakMap,Ni=new WeakMap,Fo=new WeakMap,uc=new WeakSet,Ad=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(yT()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),n>0&&await CJ(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in dp){const w=await dp[a](o.url,pp(T(i,as)));if(w instanceof Co){let I=w;if(this.processFunc){pp(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,pp(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),uc,Ad).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(),uc,Ad).call(g,e+1,t,I,i,l)}if(this.processFunc){pp(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(),uc,Ad).call(b,e+1,t,I,i,l)}}return l};let Us=Zp;const wb=class wb{constructor(e,t,n,i,s){se(this,Ch);se(this,Bh);se(this,Ph);se(this,Qn);se(this,tl);se(this,lc);F(this,Ch,e),F(this,Bh,t),F(this,Ph,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),F(this,Qn,i==null?null:new Uint8Array(i)),F(this,tl,s||null),F(this,lc,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,Qn)?Ce(T(this,Qn)):"null"}>`}get statusCode(){return T(this,Ch)}get statusMessage(){return T(this,Bh)}get headers(){return Object.assign({},T(this,Ph))}get body(){return T(this,Qn)==null?null:new Uint8Array(T(this,Qn))}get bodyText(){try{return T(this,Qn)==null?"":hp(T(this,Qn))}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 wb(599,n,this.headers,this.body,T(this,tl)||void 0);return F(i,lc,{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,Qn)!=null}get request(){return T(this,tl)}ok(){return T(this,lc).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,lc);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let i=null;try{T(this,Qn)&&(i=hp(T(this,Qn)))}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}`}})}};Ch=new WeakMap,Bh=new WeakMap,Ph=new WeakMap,Qn=new WeakMap,tl=new WeakMap,lc=new WeakMap;let Co=wb;function yT(){return new Date().getTime()}function NJ(r){return Ls(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function CJ(r){return new Promise(e=>setTimeout(e,r))}function BJ(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function mT(r,e,t){let n=0;for(let i=0;i<t;i++)n=n*256+r[e+i];return n}function wT(r,e,t,n){const i=[];for(;t<e+1+n;){const s=bT(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 bT(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=mT(r,e+1,n);return t(e+1+n+i),wT(r,e,e+1+n,n+i)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),wT(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const i=mT(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:BJ(r[e])}}function gp(r){const e=_t(r,"data"),t=bT(e,0);return q(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function _T(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function AT(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(s){n=n.concat(AT(s))}),n.length<=55)return n.unshift(192+n.length),n;const i=_T(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=_T(e.length);return t.unshift(183+t.length),t.concat(e)}const vT="0123456789abcdef";function Ka(r){let e="0x";for(const t of AT(r))e+=vT[t>>4],e+=vT[t&15];return e}const _n=32,lw=new Uint8Array(_n),PJ=["then"],yp={},ET=new WeakMap;function Va(r){return ET.get(r)}function xT(r,e){ET.set(r,e)}function hh(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function fw(r,e,t){return r.indexOf(null)>=0?e.map((n,i)=>n instanceof Pu?fw(Va(n),n,t):n):r.reduce((n,i,s)=>{let o=e.getValue(i);return i in n||(t&&o instanceof Pu&&(o=fw(Va(o),o,t)),n[i]=o),n},{})}const nl=class nl extends Array{constructor(...t){const n=t[0];let i=t[1],s=(t[2]||[]).slice(),o=!0;n!==yp&&(i=t,s=[],o=!1);super(i.length);se(this,rl);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(xT(this,Object.freeze(i.map((l,h)=>{const g=s[h];return g!=null&&a.get(g)===1?g:null}))),F(this,rl,[]),T(this,rl)==null&&T(this,rl),!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&&hh(`index ${w}`,I),I}if(PJ.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 xT(u,Va(this)),u}toArray(t){const n=[];return this.forEach((i,s)=>{i instanceof Error&&hh(`index ${s}`,i),t&&i instanceof nl&&(i=i.toArray(t)),n.push(i)}),n}toObject(t){const n=Va(this);return n.reduce((i,s,o)=>(ge(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),fw(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=Va(this),s=[],o=[];for(let a=t;a<n;a++)s.push(this[a]),o.push(i[a]);return new nl(yp,s,o)}filter(t,n){const i=Va(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&hh(`index ${a}`,u),t.call(n,u,a,this)&&(s.push(u),o.push(i[a]))}return new nl(yp,s,o)}map(t,n){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&hh(`index ${s}`,o),i.push(t.call(n,o,s,this))}return i}getValue(t){const n=Va(this).indexOf(t);if(n===-1)return;const i=this[n];return i instanceof Error&&hh(`property ${JSON.stringify(t)}`,i.error),i}static fromItems(t,n){return new nl(yp,t,n)}};rl=new WeakMap;let Pu=nl;function RT(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([lw.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 hw{constructor(){se(this,il);se(this,Ws);se(this,fc);F(this,Ws,[]),F(this,fc,0)}get data(){return xr(T(this,Ws))}get length(){return T(this,fc)}appendWriter(e){return Ee(this,il,mg).call(this,wn(e.data))}writeBytes(e){let t=wn(e);const n=t.length%_n;return n&&(t=wn(xr([t,lw.slice(n)]))),Ee(this,il,mg).call(this,t)}writeValue(e){return Ee(this,il,mg).call(this,RT(e))}writeUpdatableValue(){const e=T(this,Ws).length;return T(this,Ws).push(lw),F(this,fc,T(this,fc)+_n),t=>{T(this,Ws)[e]=RT(t)}}}Ws=new WeakMap,fc=new WeakMap,il=new WeakSet,mg=function(e){return T(this,Ws).push(e),F(this,fc,T(this,fc)+e.length),e.length};const bb=class bb{constructor(e,t,n){se(this,pc);Q(this,"allowLoose");se(this,Un);se(this,Yn);se(this,hc);se(this,dc);se(this,Ho);ze(this,{allowLoose:!!t}),F(this,Un,wn(e)),F(this,hc,0),F(this,dc,null),F(this,Ho,n??1024),F(this,Yn,0)}get data(){return Ce(T(this,Un))}get dataLength(){return T(this,Un).length}get consumed(){return T(this,Yn)}get bytes(){return new Uint8Array(T(this,Un))}subReader(e){const t=new bb(T(this,Un).slice(T(this,Yn)+e),this.allowLoose,T(this,Ho));return F(t,dc,this),t}readBytes(e,t){let n=Ee(this,pc,g6).call(this,0,e,!!t);return Ee(this,pc,F_).call(this,e),F(this,Yn,T(this,Yn)+n.length),n.slice(0,e)}readValue(){return cw(this.readBytes(_n))}readIndex(){return mJ(this.readBytes(_n))}};Un=new WeakMap,Yn=new WeakMap,hc=new WeakMap,dc=new WeakMap,Ho=new WeakMap,pc=new WeakSet,F_=function(e){var t;if(T(this,dc))return Ee(t=T(this,dc),pc,F_).call(t,e);F(this,hc,T(this,hc)+e),ge(T(this,Ho)<1||T(this,hc)<=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,Yn),length:e,info:{bytesRead:T(this,hc),dataLength:this.dataLength}})},g6=function(e,t,n){let i=Math.ceil(t/_n)*_n;return T(this,Yn)+i>T(this,Un).length&&(this.allowLoose&&n&&T(this,Yn)+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,Yn)+i})),T(this,Un).slice(T(this,Yn),T(this,Yn)+i)};let dw=bb;function mp(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function pw(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 MJ(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");mp(r.outputLen),mp(r.blockLen)}function Mu(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 IT(r,e){pw(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const gw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ST=r=>r instanceof Uint8Array,LJ=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),yw=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 UJ(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function wp(r){if(typeof r=="string"&&(r=UJ(r)),!ST(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function DJ(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!ST(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class mw{clone(){return this._cloneInto()}}function ww(r){const e=n=>r().update(wp(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function $J(r=32){if(gw&&typeof gw.getRandomValues=="function")return gw.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class kT extends mw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,MJ(e);const n=wp(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 Mu(this),this.iHash.update(e),this}digestInto(e){Mu(this),pw(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 TT=(r,e,t)=>new kT(r,e).update(t).digest();TT.create=(r,e)=>new kT(r,e);function FJ(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 OT extends mw{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=yw(this.buffer)}update(e){Mu(this);const{view:t,buffer:n,blockLen:i}=this;e=wp(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=yw(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){Mu(this),IT(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;FJ(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=yw(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 HJ=(r,e,t)=>r&e^~r&t,zJ=(r,e,t)=>r&e^r&t^e&t,GJ=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 jJ extends OT{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+HJ(a,u,l)+GJ[g]+Po[g]|0,S=(ns(n,2)^ns(n,13)^ns(n,22))+zJ(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 NT=ww(()=>new jJ),bp=BigInt(2**32-1),bw=BigInt(32);function CT(r,e=!1){return e?{h:Number(r&bp),l:Number(r>>bw&bp)}:{h:Number(r>>bw&bp)|0,l:Number(r&bp)|0}}function BT(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}=CT(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const KJ=(r,e)=>BigInt(r>>>0)<<bw|BigInt(e>>>0),VJ=(r,e,t)=>r>>>t,WJ=(r,e,t)=>r<<32-t|e>>>t,qJ=(r,e,t)=>r>>>t|e<<32-t,ZJ=(r,e,t)=>r<<32-t|e>>>t,QJ=(r,e,t)=>r<<64-t|e>>>t-32,YJ=(r,e,t)=>r>>>t-32|e<<64-t,JJ=(r,e)=>e,XJ=(r,e)=>r,PT=(r,e,t)=>r<<t|e>>>32-t,MT=(r,e,t)=>e<<t|r>>>32-t,LT=(r,e,t)=>e<<t-32|r>>>64-t,UT=(r,e,t)=>r<<t-32|e>>>64-t;function eX(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:CT,split:BT,toBig:KJ,shrSH:VJ,shrSL:WJ,rotrSH:qJ,rotrSL:ZJ,rotrBH:QJ,rotrBL:YJ,rotr32H:JJ,rotr32L:XJ,rotlSH:PT,rotlSL:MT,rotlBH:LT,rotlBL:UT,add:eX,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)},[tX,rX]=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 nX extends OT{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),j=st.rotrSL(z,W,1)^st.rotrSL(z,W,8)^st.shrSL(z,W,7),V=Mo[D-2]|0,oe=Lo[D-2]|0,ce=st.rotrSH(V,oe,19)^st.rotrBH(V,oe,61)^st.shrSH(V,oe,6),ie=st.rotrSL(V,oe,19)^st.rotrBL(V,oe,61)^st.shrSL(V,oe,6),ue=st.add4L(j,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,j=b&I^~b&x,V=st.add5L(H,W,j,rX[D],Lo[D]),oe=st.add5H(V,C,z,Z,tX[D],Mo[D]),ce=V|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 iX=ww(()=>new nX);function sX(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Zc<"u")return Zc;throw new Error("unable to locate global object")}const DT=sX();DT.crypto||DT.msCrypto;function oX(r){switch(r){case"sha256":return NT.create();case"sha512":return iX.create()}q(!1,"invalid hashing algorithm name","algorithm",r)}const[$T,FT,HT]=[[],[],[]],aX=BigInt(0),dh=BigInt(1),cX=BigInt(2),uX=BigInt(7),lX=BigInt(256),fX=BigInt(113);for(let r=0,e=dh,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],$T.push(2*(5*n+t)),FT.push((r+1)*(r+2)/2%64);let i=aX;for(let s=0;s<7;s++)e=(e<<dh^(e>>uX)*fX)%lX,e&cX&&(i^=dh<<(dh<<BigInt(s))-dh);HT.push(i)}const[hX,dX]=BT(HT,!0),zT=(r,e,t)=>t>32?LT(r,e,t):PT(r,e,t),GT=(r,e,t)=>t>32?UT(r,e,t):MT(r,e,t);function pX(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=zT(l,h,1)^t[a],b=GT(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=FT[o],u=zT(i,s,a),l=GT(i,s,a),h=$T[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]^=hX[n],r[1]^=dX[n]}t.fill(0)}class _w extends mw{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,mp(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=LJ(this.state)}keccak(){pX(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Mu(this);const{blockLen:t,state:n}=this;e=wp(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){Mu(this,!1),pw(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 mp(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(IT(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 _w(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)=>ww(()=>new _w(e,r,t)))(1,136,256/8);let jT=!1;const KT=function(r){return gX(r)};let VT=KT;function Nr(r){const e=_t(r,"data");return Ce(VT(e))}Nr._=KT,Nr.lock=function(){jT=!0},Nr.register=function(r){if(jT)throw new TypeError("keccak256 is locked");VT=r},Object.freeze(Nr);const WT=function(r){return oX("sha256").update(r).digest()};let qT=WT,ZT=!1;function Lu(r){const e=_t(r,"data");return Ce(qT(e))}Lu._=WT,Lu.lock=function(){ZT=!0},Lu.register=function(r){if(ZT)throw new Error("sha256 is locked");qT=r},Object.freeze(Lu),Object.freeze(Lu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const QT=BigInt(0),_p=BigInt(1),yX=BigInt(2),Ap=r=>r instanceof Uint8Array,mX=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Uu(r){if(!Ap(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=mX[r[t]];return e}function YT(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function Aw(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Du(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 Wa(r){return Aw(Uu(r))}function vw(r){if(!Ap(r))throw new Error("Uint8Array expected");return Aw(Uu(Uint8Array.from(r).reverse()))}function $u(r,e){return Du(r.toString(16).padStart(e*2,"0"))}function Ew(r,e){return $u(r,e).reverse()}function wX(r){return Du(YT(r))}function Ii(r,e,t){let n;if(typeof e=="string")try{n=Du(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Ap(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 ph(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!Ap(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function bX(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 _X(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function AX(r){let e;for(e=0;r>QT;r>>=_p,e+=1);return e}function vX(r,e){return r>>BigInt(e)&_p}const EX=(r,e,t)=>r|(t?_p:QT)<<BigInt(e),xw=r=>(yX<<BigInt(r-1))-_p,Rw=r=>new Uint8Array(r),JT=r=>Uint8Array.from(r);function XT(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=Rw(r),i=Rw(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=Rw())=>{i=a(JT([0]),g),n=a(),g.length!==0&&(i=a(JT([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 ph(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const xX={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 gh(r,e,t={}){const n=(i,s,o)=>{const a=xX[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 RX=Object.freeze(Object.defineProperty({__proto__:null,bitGet:vX,bitLen:AX,bitMask:xw,bitSet:EX,bytesToHex:Uu,bytesToNumberBE:Wa,bytesToNumberLE:vw,concatBytes:ph,createHmacDrbg:XT,ensureBytes:Ii,equalBytes:bX,hexToBytes:Du,hexToNumber:Aw,numberToBytesBE:$u,numberToBytesLE:Ew,numberToHexUnpadded:YT,numberToVarBytesBE:wX,utf8ToBytes:_X,validateObject:gh},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),Rr=BigInt(1),qa=BigInt(2),IX=BigInt(3),Iw=BigInt(4),eO=BigInt(5),tO=BigInt(8);BigInt(9),BigInt(16);function Pn(r,e){const t=r%e;return t>=$r?t:e+t}function SX(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 Sw(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 kX(r){const e=(r-Rr)/qa;let t,n,i;for(t=r-Rr,n=0;t%qa===$r;t/=qa,n++);for(i=qa;i<r&&SX(i,e,r)!==r-Rr;i++);if(n===1){const o=(r+Rr)/Iw;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)/qa;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 TX(r){if(r%Iw===IX){const e=(r+Rr)/Iw;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%tO===eO){const e=(r-eO)/tO;return function(n,i){const s=n.mul(i,qa),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,qa),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 kX(r)}const OX=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function NX(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=OX.reduce((n,i)=>(n[i]="function",n),e);return gh(r,t)}function CX(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 BX(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 rO(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function PX(r,e,t=!1,n={}){if(r<=$r)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:i,nByteLength:s}=rO(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=TX(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:xw(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)=>CX(a,u,l),div:(u,l)=>Pn(u*Sw(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>Sw(u,r),sqrt:n.sqrt||(u=>o(a,u)),invertBatch:u=>BX(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?Ew(u,s):$u(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return t?vw(u):Wa(u)}});return Object.freeze(a)}function nO(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 iO(r){const e=nO(r);return e+Math.ceil(e/2)}function MX(r,e,t=!1){const n=r.length,i=nO(e),s=iO(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=t?Wa(r):vw(r),a=Pn(o,e-Rr)+Rr;return t?Ew(a,i):$u(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const LX=BigInt(0),kw=BigInt(1);function UX(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>LX;)s&kw&&(o=o.add(a)),a=a.double(),s>>=kw;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+=kw);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 sO(r){return NX(r.Fp),gh(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rO(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function DX(r){const e=sO(r);gh(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:$X,hexToBytes:FX}=RX,Za={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=Za;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:$X(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=Za,t=typeof r=="string"?FX(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}=Za._parseInt(t.subarray(2)),{d:o,l:a}=Za._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 oO=BigInt(3);BigInt(4);function HX(r){const e=DX(r),{Fp:t}=e,n=e.toBytes||((I,S,x)=>{const C=S.toAffine();return ph(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=Uu(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:Wa(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)),j=t.eql(t.mul(C,W),t.mul(z,H));return Z&&j}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:S,b:x}=e,C=t.mul(x,oO),{px:H,py:D,pz:z}=this;let W=t.ZERO,Z=t.ZERO,j=t.ZERO,V=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),j=t.mul(H,z),j=t.add(j,j),W=t.mul(S,j),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),j=t.mul(C,j),ce=t.mul(S,ce),ie=t.sub(V,ce),ie=t.mul(S,ie),ie=t.add(ie,j),j=t.add(V,V),V=t.add(j,V),V=t.add(V,ce),V=t.mul(V,ie),Z=t.add(Z,V),ce=t.mul(D,z),ce=t.add(ce,ce),V=t.mul(ce,ie),W=t.sub(W,V),j=t.mul(ce,oe),j=t.add(j,j),j=t.add(j,j),new g(W,Z,j)}add(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:W}=S;let Z=t.ZERO,j=t.ZERO,V=t.ZERO;const oe=e.a,ce=t.mul(e.b,oO);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),V=t.mul(oe,m),Z=t.mul(ce,B),V=t.add(Z,V),Z=t.sub(ue,V),V=t.add(ue,V),j=t.mul(Z,V),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),j=t.add(j,ie),ie=t.mul(E,m),Z=t.mul(p,Z),Z=t.sub(Z,ie),ie=t.mul(p,ue),V=t.mul(E,V),V=t.add(V,ie),new g(Z,j,V)}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,j=x,V=this;for(;D>$s||W>$s;)D&ui&&(Z=Z.add(V)),W&ui&&(j=j.add(V)),V=V.double(),D>>=ui,W>>=ui;return H&&(Z=Z.negate()),z&&(j=j.negate()),j=new g(t.mul(j.px,C.beta),j.py,j.pz),Z.add(j)}multiply(S){a(S);let x=S,C,H;const{endo:D}=e;if(D){const{k1neg:z,k1:W,k2neg:Z,k2:j}=D.splitScalar(x);let{p:V,f:oe}=this.wNAF(W),{p:ce,f:ie}=this.wNAF(j);V=w.constTimeNegate(z,V),ce=w.constTimeNegate(Z,ce),ce=new g(t.mul(ce.px,D.beta),ce.py,ce.pz),C=V.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 Uu(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=UX(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function zX(r){const e=sO(r);return gh(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function GX(r){const e=zX(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 Sw(m,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:g,isWithinCurveOrder:b}=HX({...e,toBytes(m,E,k){const O=E.toAffine(),M=t.toBytes(O.x),G=ph;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=Wa(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=>Uu($u(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)=>Wa(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}=Za.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=j(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 Du(this.toDERHex())}toDERHex(){return Za.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Du(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=iO(e.n);return MX(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=Wa(m),k=m.length*8-e.nBitLength;return k>0?E>>BigInt(k):E},j=e.bits2int_modN||function(m){return a(Z(m))},V=xw(e.nBitLength);function oe(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!($s<=m&&m<V))throw new Error(`bigint expected < 2^${e.nBitLength}`);return $u(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=j(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=ph(...te),he=U;function ye(be){const Ve=Z(be);if(!b(Ve))return;const Fe=u(Ve),Be=l.BASE.multiply(Ve).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 XT(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 Za.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=j(E),he=u(te),ye=a(re*he),be=a(le*he),Ve=(Be=l.BASE.multiplyAndAddUnsafe(U,ye,be))==null?void 0:Be.toAffine();return Ve?a(Ve.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 jX(r){return{hash:r,hmac:(e,...t)=>TT(r,e,DJ(...t)),randomBytes:$J}}function KX(r,e){const t=n=>GX({...r,...jX(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const aO=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),cO=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),VX=BigInt(1),Tw=BigInt(2),uO=(r,e)=>(r+e/Tw)/e;function WX(r){const e=aO,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,Tw,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,Tw,e);if(!Ow.eql(Ow.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Ow=PX(aO,void 0,void 0,{sqrt:WX}),Uo=KX({a:BigInt(0),b:BigInt(7),Fp:Ow,n:cO,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=cO,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-VX*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=uO(s*r,e),u=uO(-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}}}},NT);BigInt(0),Uo.ProjectivePoint;const yh="0x0000000000000000000000000000000000000000",lO="0x0000000000000000000000000000000000000000000000000000000000000000",fO=BigInt(0),hO=BigInt(1),dO=BigInt(2),pO=BigInt(27),gO=BigInt(28),vp=BigInt(35),Fu={};function yO(r){return ja(bn(r),32)}const Ci=class Ci{constructor(e,t,n,i){se(this,sl);se(this,ol);se(this,al);se(this,gc);up(e,Fu,"Signature"),F(this,sl,t),F(this,ol,n),F(this,al,i),F(this,gc,null)}get r(){return T(this,sl)}set r(e){q(Nu(e)===32,"invalid r","value",e),F(this,sl,Ce(e))}get s(){return T(this,ol)}set s(e){q(Nu(e)===32,"invalid s","value",e);const t=Ce(e);q(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),F(this,ol,t)}get v(){return T(this,al)}set v(e){const t=at(e,"value");q(t===27||t===28,"invalid v","v",e),F(this,al,t)}get networkV(){return T(this,gc)}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(Fu,this.r,this.s,this.v);return this.networkV&&F(e,gc,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==pO||t==gO?fO:(q(t>=vp,"invalid EIP-155 v","v",e),(t-vp)/dO)}static getChainIdV(e,t){return Le(e)*dO+BigInt(35+t-27)}static getNormalizedV(e){const t=Le(e);return t===fO||t===pO?27:t===hO||t===gO?28:(q(t>=vp,"invalid v","v",e),t&hO?27:28)}static from(e){function t(l,h){q(l,h,"signature",e)}if(e==null)return new Ci(Fu,lO,lO,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(Fu,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(Fu,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=yO(n),s=function(l,h){if(l!=null)return yO(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>=vp?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(Fu,i,s,a);return o&&F(u,gc,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}};sl=new WeakMap,ol=new WeakMap,al=new WeakMap,gc=new WeakMap;let Si=Ci;const yc=class yc{constructor(e){se(this,qs);q(Nu(e)===32,"invalid private key","privateKey","[REDACTED]"),F(this,qs,Ce(e))}get privateKey(){return T(this,qs)}get publicKey(){return yc.computePublicKey(T(this,qs))}get compressedPublicKey(){return yc.computePublicKey(T(this,qs),!0)}sign(e){q(Nu(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=yc.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(Nu(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(yc.computePublicKey(e).substring(2)),s=Uo.ProjectivePoint.fromHex(yc.computePublicKey(t).substring(2));return"0x"+i.add(s).toHex(!!n)}};qs=new WeakMap;let mh=yc;const qX=BigInt(0),ZX=BigInt(36);function mO(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 Nw={};for(let r=0;r<10;r++)Nw[String(r)]=String(r);for(let r=0;r<26;r++)Nw[String.fromCharCode(65+r)]=String(10+r);const wO=15;function QX(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>Nw[n]).join("");for(;e.length>=wO;){let n=e.substring(0,wO);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 YX=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function JX(r){r=r.toLowerCase();let e=qX;for(let t=0;t<r.length;t++)e=e*ZX+YX[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=mO(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)===QX(r),"bad icap checksum","address",r);let e=JX(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return mO("0x"+e)}q(!1,"invalid address","address",r)}function XX(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(Ka([e,n])),12))}function bO(r){return r&&typeof r.getAddress=="function"}async function Cw(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"}),Cw(r,e.resolveName(r)));if(bO(r))return Cw(r,r.getAddress());if(r&&typeof r.then=="function")return Cw(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 _O=Symbol.for("_ethers_typed"),Zs=class Zs{constructor(e,t,n,i){Q(this,"type");Q(this,"value");se(this,mc);Q(this,"_typedSymbol");i==null&&(i=null),up(Fs,e,"Typed"),ze(this,{_typedSymbol:_O,type:t,value:n}),F(this,mc,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,mc)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,mc)===!0?-1:T(this,mc)===!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===_O}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}};mc=new WeakMap;let an=Zs;class eee 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 tee 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 AO(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 hw,s=new hw,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 vO(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)}),Pu.fromItems(t,n)}class ree 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)),tT(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return AO(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 tee(this.coder));return vO(t,i)}}class nee 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 EO 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 iee extends EO{constructor(e){super("bytes",e)}decode(e){return Ce(super.decode(e))}}class see 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 oee=new Uint8Array([]);class aee extends Ds{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(oee)}decode(e){return e.readBytes(0),null}}const cee=BigInt(0),uee=BigInt(1),lee=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class fee 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=fh(lee,_n*8);if(this.signed){let o=fh(s,this.size*8-1);(i>o||i<-(o+uee))&&this._throwError("value out-of-bounds",n),i=sT(i,8*_n)}else(i<cee||i>fh(s,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(i)}decode(t){let n=fh(t.readValue(),this.size*8);return this.signed&&(n=yJ(n,this.size*8)),n}}class hee extends EO{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Ls(an.dereference(t,"string")))}decode(e){return hp(super.decode(e))}}class Ep 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 AO(t,this.coders,i)}decode(t){return vO(t,this.coders)}}function Qa(r){return Nr(Ls(r))}var dee="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 xO=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),RO=4;function pee(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,j=n;for(;j-Z>1;){let ce=Z+j>>>1;W<s[ce]?j=ce:Z=ce}if(Z==0)break;C.push(Z);let V=H+Math.floor(D*s[Z]/i),oe=H+Math.floor(D*s[Z+1]/i)-1;for(;!((V^oe)&w);)x=x<<1&S|h(),V=V<<1&S,oe=oe<<1&S|1;for(;V&~oe&I;)x=x&w|x<<1&S>>>1|h(),V=V<<1^w,oe=(oe^w)<<1|w|1;H=V,D=1+oe-V}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 gee(r){let e=0;return()=>r[e++]}function IO(r){return gee(pee(yee(r)))}function yee(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 mee(r){return r&1?~r>>1:r>>1}function wee(r,e){let t=Array(r);for(let n=0,i=0;n<r;n++)t[n]=i+=mee(e());return t}function wh(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 SO(r){return bh(()=>{let e=wh(r);if(e.length)return e})}function kO(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(bee(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(_ee(t,r))}return e.flat()}function bh(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function TO(r,e,t){let n=Array(r).fill().map(()=>[]);for(let i=0;i<e;i++)wee(r,t).forEach((s,o)=>n[o].push(s));return n}function bee(r,e){let t=1+e(),n=e(),i=bh(e);return TO(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 _ee(r,e){let t=1+e();return TO(t,1+r,e).map(i=>[i[0],i.slice(1)])}function Aee(r){let e=[],t=wh(r);return i(n([]),[]),e;function n(s){let o=r(),a=bh(()=>{let u=wh(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 vee(r){return r.toString(16).toUpperCase().padStart(2,"0")}function OO(r){return`{${vee(r)}}`}function Eee(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 Hu(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 xee(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 Ree="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 _h=44032,xp=4352,Rp=4449,Ip=4519,NO=19,CO=21,zu=28,Sp=CO*zu,Iee=NO*Sp,See=_h+Iee,kee=xp+NO,Tee=Rp+CO,Oee=Ip+zu;function Ah(r){return r>>24&255}function BO(r){return r&16777215}let Bw,PO,Pw,kp;function Nee(){let r=IO(Ree);Bw=new Map(SO(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),PO=new Set(wh(r)),Pw=new Map,kp=new Map;for(let[e,t]of kO(r)){if(!PO.has(e)&&t.length==2){let[n,i]=t,s=kp.get(n);s||(s=new Map,kp.set(n,s)),s.set(i,e)}Pw.set(e,t.reverse())}}function MO(r){return r>=_h&&r<See}function Cee(r,e){if(r>=xp&&r<kee&&e>=Rp&&e<Tee)return _h+(r-xp)*Sp+(e-Rp)*zu;if(MO(r)&&e>Ip&&e<Oee&&(r-_h)%zu==0)return r+(e-Ip);{let t=kp.get(r);return t&&(t=t.get(e),t)?t:-1}}function LO(r){Bw||Nee();let e=[],t=[],n=!1;function i(s){let o=Bw.get(s);o&&(n=!0,s|=o),e.push(s)}for(let s of r)for(;;){if(s<128)e.push(s);else if(MO(s)){let o=s-_h,a=o/Sp|0,u=o%Sp/zu|0,l=o%zu;i(xp+a),i(Rp+u),l>0&&i(Ip+l)}else{let o=Pw.get(s);o?t.push(...o):i(s)}if(!t.length)break;s=t.pop()}if(n&&e.length>1){let s=Ah(e[0]);for(let o=1;o<e.length;o++){let a=Ah(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=Ah(e[--u]),s<=a))break}s=Ah(e[o])}}return e}function Bee(r){let e=[],t=[],n=-1,i=0;for(let s of r){let o=Ah(s),a=BO(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=Cee(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 UO(r){return LO(r).map(BO)}function Pee(r){return Bee(LO(r))}const DO=45,$O=".",FO=65039,HO=1,Tp=r=>Array.from(r);function vh(r,e){return r.P.has(e)||r.Q.has(e)}class Mee extends Array{get is_emoji(){return!0}}let Mw,zO,Ya,Lw,GO,Gu,Uw,ju,Ja,jO,Dw;function $w(){if(Mw)return;let r=IO(dee);const e=()=>wh(r),t=()=>new Set(e()),n=(h,g)=>g.forEach(b=>h.add(b));Mw=new Map(kO(r)),zO=t(),Ya=e(),Lw=new Set(e().map(h=>Ya[h])),Ya=new Set(Ya),GO=t(),t();let i=SO(r),s=r();const o=()=>{let h=new Set;return e().forEach(g=>n(h,i[g])),n(h,e()),h};Gu=bh(h=>{let g=bh(r).map(b=>b+96);if(g.length){let b=h>=s;g[0]-=32,g=Hu(g),b&&(g=`Restricted[${g}]`);let w=o(),I=o(),S=!r();return{N:g,P:w,Q:I,M:S,R:b}}}),Uw=t(),ju=new Map;let a=e().concat(Tp(Uw)).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),Uw.has(h)||ju.set(h,w)});for(let{V:h,M:g}of new Set(ju.values())){let b=[];for(let I of h){let S=Gu.filter(C=>vh(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=>Tp(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)}}Ja=new Set;let u=new Set;const l=h=>Ja.has(h)?u.add(h):Ja.add(h);for(let h of Gu){for(let g of h.P)l(g);for(let g of h.Q)l(g)}for(let h of Ja)!ju.has(h)&&!u.has(h)&&ju.set(h,HO);n(Ja,UO(Ja)),jO=Aee(r).map(h=>Mee.from(h)).sort(xee),Dw=new Map;for(let h of jO){let g=[Dw];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===FO?g.push(...w):g=w}for(let b of g)b.V=h}}function Fw(r){return(KO(r)?"":`${Hw(Op([r]))} `)+OO(r)}function Hw(r){return`"${r}"`}function Lee(r){if(r.length>=4&&r[2]==DO&&r[3]==DO)throw new Error(`invalid label extension: "${Hu(r.slice(0,4))}"`)}function Uee(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function Dee(r){let e=r[0],t=xO.get(e);if(t)throw Eh(`leading ${t}`);let n=r.length,i=-1;for(let s=1;s<n;s++){e=r[s];let o=xO.get(e);if(o){if(i==s)throw Eh(`${t} + ${o}`);i=s+1,t=o}}if(i==n)throw Eh(`trailing ${t}`)}function Op(r,e=1/0,t=OO){let n=[];$ee(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];KO(a)&&(n.push(Hu(r.slice(i,o))),n.push(t(a)),i=o+1)}return n.push(Hu(r.slice(i,s))),n.join("")}function $ee(r){return $w(),Ya.has(r)}function KO(r){return $w(),GO.has(r)}function Fee(r){return jee(Hee(r,Pee,Wee))}function Hee(r,e,t){if(!r)return[];$w();let n=0;return r.split($O).map(i=>{let s=Eee(i),o={input:s,offset:n};n+=s.length+1;try{let a=o.tokens=Vee(s,e,t),u=a.length,l;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(Uee(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(b=>b<128))Lee(h),l="ASCII";else{let b=a.flatMap(w=>w.is_emoji?[]:w);if(!b.length)l="Emoji";else{if(Ya.has(h[0]))throw Eh("leading combining mark");for(let S=1;S<u;S++){let x=a[S];if(!x.is_emoji&&Ya.has(x[0]))throw Eh(`emoji + combining mark: "${Hu(a[S-1])} + ${Op([x[0]])}"`)}Dee(h);let w=Tp(new Set(b)),[I]=Gee(w);Kee(I,b),zee(I,w),l=I.N}}o.type=l}catch(a){o.error=a}return o})}function zee(r,e){let t,n=[];for(let i of e){let s=ju.get(i);if(s===HO)return;if(s){let o=s.M.get(i);if(t=t?t.filter(a=>o.has(a)):Tp(o),!t.length)return}else n.push(i)}if(t){for(let i of t)if(n.every(s=>vh(i,s)))throw new Error(`whole-script confusable: ${r.N}/${i.N}`)}}function Gee(r){let e=Gu;for(let t of r){let n=e.filter(i=>vh(i,t));if(!n.length)throw Gu.some(i=>vh(i,t))?WO(e[0],t):VO(t);if(e=n,n.length==1)break}return e}function jee(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 ${Hw(Op(e,63))}: ${i}`)}return Hu(n)}).join($O)}function VO(r){return new Error(`disallowed character: ${Fw(r)}`)}function WO(r,e){let t=Fw(e),n=Gu.find(i=>i.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function Eh(r){return new Error(`illegal placement: ${r}`)}function Kee(r,e){for(let t of e)if(!vh(r,t))throw WO(r,t);if(r.M){let t=UO(e);for(let n=1,i=t.length;n<i;n++)if(Lw.has(t[n])){let s=n+1;for(let o;s<i&&Lw.has(o=t[s]);s++)for(let a=n;a<s;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${Fw(o)}`);if(s-n>RO)throw new Error(`excessive non-spacing marks: ${Hw(Op(t.slice(n-1,s)))} (${s-n}/${RO})`);n=s}}}function Vee(r,e,t){let n=[],i=[];for(r=r.slice().reverse();r.length;){let s=qee(r);if(s)i.length&&(n.push(e(i)),i=[]),n.push(t(s));else{let o=r.pop();if(Ja.has(o))i.push(o);else{let a=Mw.get(o);if(a)i.push(...a);else if(!zO.has(o))throw VO(o)}}}return i.length&&n.push(e(i)),n}function Wee(r){return r.filter(e=>e!=FO)}function qee(r,e){let t=Dw,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 qO=new Uint8Array(32);qO.fill(0);function ZO(r){return q(r.length!==0,"invalid ENS name; empty component","comp",r),r}function QO(r){const e=Ls(Zee(r)),t=[];if(r.length===0)return t;let n=0;for(let i=0;i<e.length;i++)e[i]===46&&(t.push(ZO(e.slice(n,i))),n=i+1);return q(n<e.length,"invalid ENS name; empty component","name",r),t.push(ZO(e.slice(n))),t}function Zee(r){try{if(r.length===0)throw new Error("empty label");return Fee(r)}catch(e){q(!1,`invalid ENS name (${e.message})`,"name",r)}}function zw(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=qO;const t=QO(r);for(;t.length;)e=Nr(xr([e,Nr(t.pop())]));return Ce(e)}function Qee(r,e){const t=e;return q(t<=255,"DNS encoded label cannot exceed 255","length",t),Ce(xr(QO(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 Gw(r,e){return{address:Mt(r),storageKeys:e.map((t,n)=>(q(Gt(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function Xa(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(q(t.length===2,"invalid slot set",`value[${n}]`,t),Gw(t[0],t[1])):(q(t!=null&&typeof t=="object","invalid address-slot set","value",r),Gw(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 Gw(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function Yee(r){let e;return typeof r=="string"?e=mh.computePublicKey(r,!1):e=r.publicKey,Mt(Nr("0x"+e.substring(4)).substring(26))}function Jee(r,e){return Yee(mh.recoverPublicKey(r,e))}const Fr=BigInt(0),Xee=BigInt(2),ete=BigInt(27),tte=BigInt(28),rte=BigInt(35),nte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),jw=4096*32;function YO(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=Lu(e).substring(4),"0x"+t}function Np(r){return r==="0x"?null:Mt(r)}function Kw(r,e){try{return Xa(r)}catch(t){q(!1,t.message,e,r)}}function xh(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<=nte,"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 Vw(r){return Xa(r).map(e=>[e.address,e.storageKeys])}function ite(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 ste(r){const e=gp(r);q(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:xh(e[0],"nonce"),gasPrice:Ir(e[1],"gasPrice"),gasLimit:Ir(e[2],"gasLimit"),to:Np(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-rte)/Xee;o<Fr&&(o=Fr),t.chainId=o,q(o!==Fr||n===ete||n===tte,"non-canonical legacy v","v",e[6]),t.signature=Si.from({r:ja(e[7],32),s:ja(e[8],32),v:n})}return t}function ote(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")),Ka(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)),Ka(t)}function Ww(r,e){let t;try{if(t=xh(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{q(!1,"invalid yParity","yParity",e[0])}const n=ja(e[1],32),i=ja(e[2],32),s=Si.from({r:n,s:i,yParity:t});r.signature=s}function ate(r){const e=gp(_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:xh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Np(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:Kw(e[8],"accessList")};return e.length===9||Ww(t,e.slice(9)),t}function cte(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,Vw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"yParity")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x02",Ka(t)])}function ute(r){const e=gp(_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:xh(e[1],"nonce"),gasPrice:Ir(e[2],"gasPrice"),gasLimit:Ir(e[3],"gasLimit"),to:Np(e[4]),value:Ir(e[5],"value"),data:Ce(e[6]),accessList:Kw(e[7],"accessList")};return e.length===8||Ww(t,e.slice(8)),t}function lte(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,Vw(r.accessList||[])];return e&&(t.push(qt(e.yParity,"recoveryParam")),t.push(bn(e.r)),t.push(bn(e.s))),xr(["0x01",Ka(t)])}function fte(r){let e=gp(_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:xh(e[1],"nonce"),maxPriorityFeePerGas:Ir(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ir(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ir(e[4],"gasLimit"),to:Np(e[5]),value:Ir(e[6],"value"),data:Ce(e[7]),accessList:Kw(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||Ww(i,e.slice(11)),i}function hte(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||yh,qt(r.value,"value"),r.data,Vw(r.accessList||[]),qt(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),ite(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(qt(e.yParity,"yParity")),n.push(bn(e.r)),n.push(bn(e.s)),t)?xr(["0x03",Ka([n,t.map(i=>i.data),t.map(i=>i.commitment),t.map(i=>i.proof)])]):xr(["0x03",Ka(n)])}const Ys=class Ys{constructor(){se(this,bl);se(this,cs);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,wl);se(this,wc);se(this,zo);se(this,Qs);se(this,Go);F(this,cs,null),F(this,cl,null),F(this,ll,0),F(this,fl,Fr),F(this,hl,null),F(this,dl,null),F(this,pl,null),F(this,ul,"0x"),F(this,gl,Fr),F(this,yl,Fr),F(this,ml,null),F(this,wl,null),F(this,wc,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,cl);return e==null&&this.type===3?yh:e}set to(e){F(this,cl,e==null?null:Mt(e))}get nonce(){return T(this,ll)}set nonce(e){F(this,ll,at(e,"value"))}get gasLimit(){return T(this,fl)}set gasLimit(e){F(this,fl,Le(e))}get gasPrice(){const e=T(this,hl);return e==null&&(this.type===0||this.type===1)?Fr:e}set gasPrice(e){F(this,hl,e==null?null:Le(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,dl);return e??(this.type===2||this.type===3?Fr:null)}set maxPriorityFeePerGas(e){F(this,dl,e==null?null:Le(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,pl);return e??(this.type===2||this.type===3?Fr:null)}set maxFeePerGas(e){F(this,pl,e==null?null:Le(e,"maxFeePerGas"))}get data(){return T(this,ul)}set data(e){F(this,ul,Ce(e))}get value(){return T(this,gl)}set value(e){F(this,gl,Le(e,"value"))}get chainId(){return T(this,yl)}set chainId(e){F(this,yl,Le(e))}get signature(){return T(this,ml)||null}set signature(e){F(this,ml,e==null?null:Si.from(e))}get accessList(){const e=T(this,wl)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){F(this,wl,e==null?null:Xa(e))}get maxFeePerBlobGas(){const e=T(this,wc);return e==null&&this.type===3?Fr:e}set maxFeePerBlobGas(e){F(this,wc,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(aw(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<=jw,"blob is too large",`blobs[${i}]`,s),o.length!==jw){const l=new Uint8Array(jw);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(YO(1,a))}else{const o=Ce(s.commitment);t.push({data:Ce(s.data),commitment:o,proof:Ce(s.proof)}),n.push(YO(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,bl,wg).call(this,!0,!1))}get unsignedHash(){return Nr(this.unsignedSerialized)}get from(){return this.signature==null?null:Jee(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:mh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return Ee(this,bl,wg).call(this,!0,!0)}get unsignedSerialized(){return Ee(this,bl,wg).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,wc)!=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(ste(n));switch(n[0]){case 1:return Ys.from(ute(n));case 2:return Ys.from(ate(n));case 3:return Ys.from(fte(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,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,wl=new WeakMap,wc=new WeakMap,zo=new WeakMap,Qs=new WeakMap,Go=new WeakMap,bl=new WeakSet,wg=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 ote(this,n);case 1:return lte(this,n);case 2:return cte(this,n);case 3:return hte(this,n,t?this.blobs:null)}ge(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Cp=Ys;const JO=new Uint8Array(32);JO.fill(0);const dte=BigInt(-1),XO=BigInt(0),eN=BigInt(1),pte=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function gte(r){const e=_t(r),t=e.length%32;return t?xr([e,JO.slice(t)]):Ce(e)}const yte=No(eN,32),mte=No(XO,32),tN={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},qw=["name","version","chainId","verifyingContract","salt"];function rN(r){return function(e){return q(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const wte={name:rN("name"),version:rN("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):Bu(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 Zw(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=fh(pte,t?n-1:n),s=t?(i+eN)*dte:XO;return function(o){const a=Le(o,"value");return q(a>=s&&a<=i,`value out-of-bounds for ${r}`,"value",a),No(t?sT(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),gte(n)}}}switch(r){case"address":return function(e){return ja(Mt(e),32)};case"bool":return function(e){return e?yte:mte};case"bytes":return function(e){return Nr(e)};case"string":return function(e){return Qa(e)}}return null}function nN(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Bp(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,Qp);Q(this,"primaryType");se(this,Mh);se(this,Js);se(this,_l);F(this,Js,new Map),F(this,_l,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}=Bp(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,Mh,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=Bp(h.type).base;q(g!==u,`circular type reference to ${JSON.stringify(g)}`,"types",e),!Zw(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,nN(u,s[u])+h.map(g=>nN(g,s[g])).join(""))}}get types(){return JSON.parse(T(this,Mh))}getEncoder(e){let t=T(this,_l).get(e);return t||(t=Ee(this,Qp,y6).call(this,e),T(this,_l).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(Zw(e))return n(e,t);const i=Bp(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=tN[n];q(i,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:i})}return t.sort((n,i)=>qw.indexOf(n.name)-qw.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=[];qw.forEach(u=>{const l=e[u];l!=null&&(i[u]=wte[u](l),s.push({name:u,type:tN[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)})}}};Mh=new WeakMap,Js=new WeakMap,_l=new WeakMap,Qp=new WeakSet,y6=function(e){{const i=Zw(e);if(i)return i}const t=Bp(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=Qa(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 Pp=li;function vn(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const bte=vn("external public payable override".split(" ")),iN="constant external internal payable private public pure view override",_te=vn(iN.split(" ")),sN="constructor error event fallback function receive struct",oN=vn(sN.split(" ")),aN="calldata memory storage payable indexed",Ate=vn(aN.split(" ")),vte=[sN,aN,"tuple returns",iN].join(" "),Ete=vn(vte.split(" ")),xte={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Rte=new RegExp("^(\\s*)"),Ite=new RegExp("^([0-9]+)"),Ste=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),cN=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),uN=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Yp=class Yp{constructor(e){se(this,Lh);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 Yp(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,Lh,H_).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,Lh,H_).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 _d(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,Lh=new WeakSet,H_=function(e=0,t=0){return new Yp(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=Yp;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(Rte);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=xte[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(Ste),a){if(u.text=a[1],s+=u.text.length,Ete.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(uN)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(Ite),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 lN(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 Mp(r,e){if(e.peekKeyword(oN)){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 fN(r){let e=Hs(r,_te);return lN(e,vn("constant payable nonpayable".split(" "))),lN(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 hN(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return Le(r.pop().text);throw new Error("invalid gas")}return null}function ec(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const kte=new RegExp(/^(.*)\[([0-9]*)\]$/);function dN(r){const e=r.match(uN);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"),pN="_ParamTypeInternal",gN="_ErrorInternal",yN="_EventInternal",mN="_ConstructorInternal",wN="_FallbackInternal",bN="_FunctionInternal",_N="_StructInternal",fi=class fi{constructor(e,t,n,i,s,o,a,u){se(this,Al);Q(this,"name");Q(this,"type");Q(this,"baseType");Q(this,"indexed");Q(this,"components");Q(this,"arrayLength");Q(this,"arrayChildren");if(up(e,ir,"ParamType"),Object.defineProperty(this,Mn,{value:pN}),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,Al,bg).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=dN(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,Ate).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(cN),"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(kte);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=dN(e.type),new fi(ir,n||"",s,s,i,null,null,null)}static isParamType(e){return e&&e[Mn]===pN}};Al=new WeakSet,bg=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,Al,bg).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],Al,bg).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 tc{constructor(e,t,n){Q(this,"type");Q(this,"inputs");up(e,ir,"Fragment"),n=Object.freeze(n.slice()),ze(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{tc.from(JSON.parse(e))}catch{}return tc.from(Do(e))}if(e instanceof ki)switch(e.peekKeyword(oN)){case"constructor":return Gs.from(e);case"error":return Ln.from(e);case"event":return is.from(e);case"fallback":case"receive":return js.from(e);case"function":return ss.from(e);case"struct":return rc.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 js.from(e);case"function":return ss.from(e);case"struct":return rc.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 rc.isFragment(e)}}class Lp extends tc{constructor(t,n,i,s){super(t,n,s);Q(this,"name");q(typeof i=="string"&&i.match(cN),"invalid identifier","name",i),s=Object.freeze(s.slice()),ze(this,{name:i})}}function Rh(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Ln extends Lp{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Mn,{value:gN})}get selector(){return Qa(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+Rh(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=Mp("error",e),n=zs(e);return ec(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]===gN}}class is extends Lp{constructor(t,n,i,s){super(t,"event",n,i);Q(this,"anonymous");Object.defineProperty(this,Mn,{value:yN}),ze(this,{anonymous:s})}get topicHash(){return Qa(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+Rh(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=Mp("event",t),i=zs(t,!0),s=!!Hs(t,vn(["anonymous"])).has("anonymous");return ec(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]===yN}}class Gs extends tc{constructor(t,n,i,s,o){super(t,n,i);Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Mn,{value:mN}),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${Rh(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,bte).has("payable"),s=hN(t);return ec(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]===mN}}class js extends tc{constructor(t,n,i){super(t,"fallback",n);Q(this,"payable");Object.defineProperty(this,Mn,{value:wN}),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(js.isFragment(t))return t;if(typeof t=="string")try{return js.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"])),ec(t),new js(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=fN(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 ec(t),new js(ir,o,a==="payable")}if(t.type==="receive")return new js(ir,[],!0);if(t.type==="fallback"){const n=[Yr.from("bytes")],i=t.stateMutability==="payable";return new js(ir,n,i)}q(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Mn]===wN}}class ss extends Lp{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:bN}),o=Object.freeze(o.slice()),ze(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return Qa(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+Rh(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(Rh(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=Mp("function",t),s=zs(t),o=fN(t);let a=[];Hs(t,vn(["returns"])).has("returns")&&(a=zs(t));const u=hN(t);return ec(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]===bN}}class rc extends Lp{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Mn,{value:_N})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return rc.from(Do(e))}catch{q(!1,"invalid struct fragment","obj",e)}else if(e instanceof ki){const t=Mp("struct",e),n=zs(e);return ec(e),new rc(ir,t,n)}return new rc(ir,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Mn]===_N}}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 Tte=new RegExp(/^bytes([0-9]*)$/),Ote=new RegExp(/^(u?int)([0-9]*)$/);let Qw=null,AN=1024;function Nte(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)),Jt(i,"CALL_EXCEPTION",{action:r,data:t,reason:s,transaction:u,invocation:o,revert:a})}const Jp=class Jp{constructor(){se(this,jo)}getDefaultValue(e){const t=e.map(i=>Ee(this,jo,Wl).call(this,Yr.from(i)));return new Ep(t,"_").defaultValue()}encode(e,t){tT(t.length,e.length,"types/values length mismatch");const n=e.map(o=>Ee(this,jo,Wl).call(this,Yr.from(o))),i=new Ep(n,"_"),s=new hw;return i.encode(s,t),s.data}decode(e,t,n){const i=e.map(o=>Ee(this,jo,Wl).call(this,Yr.from(o)));return new Ep(i,"_").decode(new dw(t,n,AN))}static _setDefaultMaxInflation(e){q(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),AN=e}static defaultAbiCoder(){return Qw==null&&(Qw=new Jp),Qw}static getBuiltinCallException(e,t,n){return Nte(e,t,n,Jp.defaultAbiCoder())}};jo=new WeakSet,Wl=function(e){if(e.isArray())return new ree(Ee(this,jo,Wl).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Ep(e.components.map(n=>Ee(this,jo,Wl).call(this,n)),e.name);switch(e.baseType){case"address":return new eee(e.name);case"bool":return new nee(e.name);case"string":return new hee(e.name);case"bytes":return new iee(e.name);case"":return new aee(e.name)}let t=e.type.match(Ote);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 fee(n/8,t[1]==="int",e.name)}if(t=e.type.match(Tte),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,"invalid bytes length","param",e),new see(n,e.name)}q(!1,"invalid type","type",e.type)};let Ih=Jp;class Cte{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 Bte{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 Pte{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 vN{constructor(e){Q(this,"hash");Q(this,"_isIndexed");ze(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const EN={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"},xN={"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&&EN[r.toString()]&&(e=EN[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}},bc=class bc{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(tc.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 Ih.defaultAbiCoder()}getFunctionName(e){const t=Ee(this,hs,_g).call(this,e,null,!1);return q(t,"no matching function","key",e),t.name}hasFunction(e){return!!Ee(this,hs,_g).call(this,e,null,!1)}getFunction(e,t){return Ee(this,hs,_g).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,Ag).call(this,e,null,!1);return q(t,"no matching event","key",e),t.name}hasEvent(e){return!!Ee(this,hs,Ag).call(this,e,null,!1)}getEvent(e,t){return Ee(this,hs,Ag).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(xN[i])return Ln.from(xN[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=Ih.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"?Qa(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=gJ(o,32):s.type==="address"&&T(this,cn).encode(["address"],[o]),ja(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(Qa(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 vN(null);else if(o[I])S=new vN(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)}),Pu.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 Bte(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 Cte(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 Pte(n,n.selector,i)}static from(e){return e instanceof bc?e:typeof e=="string"?new bc(JSON.parse(e)):typeof e.formatJson=="function"?new bc(e.formatJson()):typeof e.format=="function"?new bc(e.format("json")):new bc(e)}};us=new WeakMap,ls=new WeakMap,fs=new WeakMap,cn=new WeakMap,hs=new WeakSet,_g=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},Ag=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 Yw=bc;const RN=BigInt(0);function Ku(r){return r??null}function Sr(r){return r==null?null:r.toString()}class IN{constructor(e,t,n){Q(this,"gasPrice");Q(this,"maxFeePerGas");Q(this,"maxPriorityFeePerGas");ze(this,{gasPrice:Ku(e),maxFeePerGas:Ku(t),maxPriorityFeePerGas:Ku(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Sr(e),maxFeePerGas:Sr(t),maxPriorityFeePerGas:Sr(n)}}}function Up(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=Xa(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=>aw(i)?Ce(i):Object.assign({},i))),e}class Mte{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 kh(n,t):n)),ze(this,{provider:t,hash:Ku(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:Ku(e.prevRandao),extraData:e.extraData,baseFeePerGas:Ku(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 Lte(this)}}Xs=new WeakMap;class Sh{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 Ute(this)}}class SN{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,Uh);F(this,Uh,Object.freeze(e.logs.map(i=>new Sh(i,t))));let n=RN;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,Uh)}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 TN(this)}reorderedEvent(e){return ge(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),kN(this,e)}}Uh=new WeakMap;const _b=class _b{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,Ko);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,Ko,-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,Ko),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,Ko)&&(o=T(this,Ko)));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===RN&&(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(Jt("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()"}),TN(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()"}),kN(this,e)}replaceableTransaction(e){q(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new _b(this,this.provider);return F(t,Ko,e),t}};Ko=new WeakMap;let kh=_b;function Lte(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function kN(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function TN(r){return{orphan:"drop-transaction",tx:r}}function Ute(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 Jw extends Sh{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 ON extends Sh{constructor(t,n){super(t,t.provider);Q(this,"error");ze(this,{error:n})}}class Dte extends SN{constructor(t,n,i){super(i,n);se(this,vl);F(this,vl,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?T(this,vl).getEvent(t.topics[0]):null;if(n)try{return new Jw(t,T(this,vl),n)}catch(i){return new ON(t,i)}return t})}}vl=new WeakMap;class Xw extends kh{constructor(t,n,i){super(i,n);se(this,Dh);F(this,Dh,t)}async wait(t,n){const i=await super.wait(t,n);return i==null?null:new Dte(T(this,Dh),this.provider,i)}}Dh=new WeakMap;class NN extends uT{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 $te extends NN{constructor(e,t,n,i,s){super(e,t,n,new Jw(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 CN=BigInt(0);function BN(r){return r&&typeof r.call=="function"}function PN(r){return r&&typeof r.estimateGas=="function"}function Dp(r){return r&&typeof r.resolveName=="function"}function MN(r){return r&&typeof r.sendTransaction=="function"}function LN(r){if(r!=null){if(Dp(r))return r;if(r.provider)return r.provider}}class Fte{constructor(e,t,n){se(this,$h);Q(this,"fragment");if(ze(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const i=nc(e.runner,"resolveName"),s=Dp(i)?i:null;F(this,$h,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,$h)}}$h=new WeakMap;function nc(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function ic(r){return r==null?null:r.provider||null}async function UN(r,e){const t=an.dereference(r,"overrides");q(typeof t=="object","invalid overrides parameter","overrides",r);const n=Up(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 Hte(r,e,t){const n=nc(r,"resolveName"),i=Dp(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 zte(r){const e=async function(o){const a=await UN(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await An(a.from,LN(r.runner)));const u=r.interface,l=Le(a.value||CN,"overrides.value")===CN,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=nc(r.runner,"call");ge(BN(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 ow(l)&&l.data?r.interface.makeError(l.data,u):l}},n=async function(o){const a=r.runner;ge(MN(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await e(o)),l=ic(r.runner);return new Xw(r.interface,l,u)},i=async function(o){const a=nc(r.runner,"estimateGas");return ge(PN(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 Gte(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 UN(l.pop()),g.from&&(g.from=await An(g.from,LN(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const b=await Hte(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(MN(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const g=await h.sendTransaction(await n(...l)),b=ic(r.runner);return new Xw(r.interface,b,g)},o=async function(...l){const h=nc(r.runner,"estimateGas");return ge(PN(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=nc(r.runner,"call");ge(BN(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 ow(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 jte(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 Fte(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 $p=Symbol.for("_ethersInternal_contract"),DN=new WeakMap;function Kte(r,e){DN.set(r[$p],e)}function qn(r){return DN.get(r[$p])}function Vte(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function eb(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]):Vte(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 Th(r,e){const{subs:t}=qn(r);return t.get((await eb(r,e)).tag)||null}async function $N(r,e,t){const n=ic(r.runner);ge(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=await eb(r,t),{addr:a,subs:u}=qn(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):[];rb(r,t,D,z=>new $te(r,z,t,H,x))}else rb(r,t,[],H=>new NN(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 tb=Promise.resolve();async function Wte(r,e,t,n){await tb;const i=await Th(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(),qn(r).subs.delete(i.tag)),s>0}async function rb(r,e,t,n){try{await tb}catch{}const i=Wte(r,e,t,n);return tb=i,await i}const Fp=["then"];iC=$p;const Fh=class Fh{constructor(e,t,n,i){Q(this,"target");Q(this,"interface");Q(this,"runner");Q(this,"filters");Q(this,iC);Q(this,"fallback");q(typeof e=="string"||bO(e),"invalid value for Contract target","target",e),n==null&&(n=null);const s=Yw.from(t);ze(this,{target:e,runner:n,interface:s}),Object.defineProperty(this,$p,{value:{}});let o,a=null,u=null;if(i){const g=ic(n);u=new Xw(this.interface,g,i)}let l=new Map;if(typeof e=="string")if(Gt(e))a=e,o=Promise.resolve(e);else{const g=nc(n,"resolveName");if(!Dp(g))throw Jt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=g.resolveName(e).then(b=>{if(b==null)throw Jt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return qn(this).addr=b,b})}else o=e.getAddress().then(g=>{if(g==null)throw new Error("TODO");return qn(this).addr=g,g});Kte(this,{addrPromise:o,addr:a,deployTx:u,subs:l});const h=new Proxy({},{get:(g,b,w)=>{if(typeof b=="symbol"||Fp.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)=>Fp.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?zte(this):null}),new Proxy(this,{get:(g,b,w)=>{if(typeof b=="symbol"||b in g||Fp.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||Fp.indexOf(b)>=0?Reflect.has(g,b):g.interface.hasFunction(b)})}connect(e){return new Fh(this.target,this.interface,e)}attach(e){return new Fh(e,this.interface,this.runner)}async getAddress(){return await qn(this).addrPromise}async getDeployedCode(){const e=ic(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=ic(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 qn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),Gte(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),jte(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}=qn(this),o=i||await s,{fragment:a,topics:u}=await eb(this,e),l={address:o,topics:u,fromBlock:t,toBlock:n},h=ic(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 Jw(g,this.interface,b)}catch(w){return new ON(g,w)}return new Sh(g,h)})}async on(e,t){const n=await $N(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await $N(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await rb(this,e,t,null)}async listenerCount(e){if(e){const i=await Th(this,e);return i?i.listeners.length:0}const{subs:t}=qn(this);let n=0;for(const{listeners:i}of t.values())n+=i.length;return n}async listeners(e){if(e){const i=await Th(this,e);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:t}=qn(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 Th(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(),qn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await Th(this,e);if(!t)return this;t.stop(),qn(this).subs.delete(t.tag)}else{const{subs:t}=qn(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 Fh{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 nb=Fh;function qte(){return nb}class Vu extends qte(){}function ib(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 Zte{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 FN=new RegExp("^(ipfs)://(.*)$","i"),HN=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),FN,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],El=class El{constructor(e,t,n){se(this,Wo);Q(this,"provider");Q(this,"address");Q(this,"name");se(this,Vo);se(this,_c);ze(this,{provider:e,address:t,name:n}),F(this,Vo,null),F(this,_c,new Vu(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,Vo)==null&&F(this,Vo,(async()=>{try{return await T(this,_c).supportsInterface("0x9061b923")}catch(e){if(Qr(e,"CALL_EXCEPTION"))return!1;throw F(this,Vo,null),e}})()),await T(this,Vo)}async getAddress(e){if(e==null&&(e=60),e===60)try{const s=await Ee(this,Wo,ql).call(this,"addr(bytes32)");return s==null||s===yh?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,ql).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 Zte&&s.supportsCoinType(e)){t=s;break}if(t==null)return null;const n=await Ee(this,Wo,ql).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,ql).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await Ee(this,Wo,ql).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}://${wJ("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<HN.length;n++){const i=t.match(HN[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=ib(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 Vu(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=ib(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(FN)==null)return e.push({type:"!imageUrl-ipfs",value:I}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:I}),I=ib(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=El,Xp,m6).call(i,e,n);if(s!=null){const o=new El(e,s,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Vo=new WeakMap,_c=new WeakMap,Wo=new WeakSet,ql=async function(e,t){t=(t||[]).slice();const n=T(this,_c).interface;t.unshift(zw(this.name));let i=null;await this.supportsWildcard()&&(i=n.getFunction(e),ge(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[Qee(this.name,255),n.encodeFunctionData(i,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const s=await T(this,_c)[e](...t);return i?n.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Qr(s,"CALL_EXCEPTION"))throw s}return null},Xp=new WeakSet,m6=async function(e,t){const n=await El.getEnsAddress(e);try{const s=await new Vu(n,["function resolver(bytes32) view returns (address)"],e).resolver(zw(t),{enableCcipRead:!0});return s===yh?null:s}catch(i){throw i}return null},se(El,Xp);let Hp=El;const zN=BigInt(0);function wt(r,e){return function(t){return t==null?e:r(t)}}function zp(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 Oh(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 Qte(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 Wu(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 Yte=Oh({address:Mt,blockHash:Jr,blockNumber:at,data:Wu,index:at,removed:wt(Qte,!1),topics:zp(Jr),transactionHash:Jr,transactionIndex:at},{index:["logIndex"]});function Jte(r){return Yte(r)}const Xte=Oh({hash:wt(Jr),parentHash:Jr,parentBeaconBlockRoot:wt(Jr,null),number:at,timestamp:at,nonce:wt(Wu),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:Wu,baseFeePerGas:wt(Le)},{prevRandao:["mixHash"]});function ere(r){const e=Xte(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:GN(t)),e}const tre=Oh({transactionIndex:at,blockNumber:at,transactionHash:Jr,address:Mt,topics:zp(Jr),data:Wu,index:at,blockHash:Jr},{index:["logIndex"]});function rre(r){return tre(r)}const nre=Oh({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(Wu),blockHash:Jr,hash:Jr,logs:zp(rre),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 ire(r){return nre(r)}function GN(r){r.to&&Le(r.to)===zN&&(r.to="0x0000000000000000000000000000000000000000");const e=Oh({hash:Jr,index:wt(at,void 0),type:t=>t==="0x"||t==null?0:at(t),accessList:wt(Xa,null),blobVersionedHashes:wt(zp(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:Wu,creates:wt(Mt,null),chainId:wt(Le,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=XX(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)===zN&&(e.blockHash=null),e}const sre="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Nh{constructor(e){Q(this,"name");ze(this,{name:e})}clone(){return new Nh(this.name)}}class Gp extends Nh{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 Gp(this.effectiveBlock,this)}}class jp extends Nh{constructor(t,n){super("org.ethers.plugins.network.Ens");Q(this,"address");Q(this,"targetNetwork");ze(this,{address:t||sre,targetNetwork:n??1})}clone(){return new jp(this.address,this.targetNetwork)}}class ore extends Nh{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");se(this,Hh);se(this,zh);F(this,Hh,t),F(this,zh,n)}get url(){return T(this,Hh)}get processFunc(){return T(this,zh)}clone(){return this}}Hh=new WeakMap,zh=new WeakMap;const sb=new Map,Il=class Il{constructor(e,t){se(this,xl);se(this,Rl);se(this,qo);F(this,xl,e),F(this,Rl,Le(t)),F(this,qo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,xl)}set name(e){F(this,xl,e)}get chainId(){return T(this,Rl)}set chainId(e){F(this,Rl,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 Il(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 Gp;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=Xa(e.accessList);for(const s in i)n+=t.txAccessListAddress+t.txAccessListStorageKey*i[s].storageKeys.length}return n}static from(e){if(are(),e==null)return Il.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=sb.get(e);if(t)return t();if(typeof e=="bigint")return new Il("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 Il(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new jp(e.ensAddress,e.ensNetwork)),t}q(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=sb.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),sb.set(e,t)}};xl=new WeakMap,Rl=new WeakMap,qo=new WeakMap;let os=Il;function jN(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 KN(r){return new ore(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:jN(a.maxFee,9),maxPriorityFeePerGas:jN(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 VN=!1;function are(){if(VN)return;VN=!0;function r(e,t,n){const i=function(){const s=new os(e,t);return n.ensNetwork!=null&&s.attachPlugin(new jp(null,n.ensNetwork)),s.attachPlugin(new Gp),(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:[KN("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[KN("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 ob(r){return JSON.parse(JSON.stringify(r))}class cre{constructor(e){se(this,Sl);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,Sl,vg).bind(this),T(this,Zo))),Ee(this,Sl,vg).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,Sl=new WeakSet,vg=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,Sl,vg).bind(this),T(this,Zo)))};class ab{constructor(e){se(this,Ac);se(this,vc);se(this,Qo);F(this,Ac,e),F(this,Qo,!1),F(this,vc,t=>{this._poll(t,T(this,Ac))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Qo)||(F(this,Qo,!0),T(this,vc).call(this,-2),T(this,Ac).on("block",T(this,vc)))}stop(){T(this,Qo)&&(F(this,Qo,!1),T(this,Ac).off("block",T(this,vc)))}pause(e){this.stop()}resume(){this.start()}}Ac=new WeakMap,vc=new WeakMap,Qo=new WeakMap;class ure extends ab{constructor(t,n){super(t);se(this,kl);se(this,to);F(this,kl,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,kl));i!=null&&(T(this,to)===-2?F(this,to,i.number):i.number>T(this,to)&&(n.emit(T(this,kl),i.number),F(this,to,i.number)))}}kl=new WeakMap,to=new WeakMap;class lre extends ab{constructor(t,n){super(t);se(this,eg);F(this,eg,ob(n))}async _poll(t,n){throw new Error("@TODO")}}eg=new WeakMap;class fre extends ab{constructor(t,n){super(t);se(this,Tl);F(this,Tl,n)}async _poll(t,n){const i=await n.getTransactionReceipt(T(this,Tl));i&&n.emit(T(this,Tl),i)}}Tl=new WeakMap;class cb{constructor(e,t){se(this,tg);se(this,ro);se(this,Ol);se(this,Nl);se(this,Yo);se(this,di);F(this,ro,e),F(this,Ol,ob(t)),F(this,Nl,Ee(this,tg,w6).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,Nl)))}stop(){T(this,Yo)&&(F(this,Yo,!1),T(this,ro).off("block",T(this,Nl)))}pause(e){this.stop(),e&&F(this,di,-2)}resume(){this.start()}}ro=new WeakMap,Ol=new WeakMap,Nl=new WeakMap,Yo=new WeakMap,di=new WeakMap,tg=new WeakSet,w6=async function(e){if(T(this,di)===-2)return;const t=ob(T(this,Ol));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,Ol),i),F(this,di,i.blockNumber)};const hre=BigInt(2),dre=10;function Kp(r){return r&&typeof r.then=="function"}function Vp(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 Wp{constructor(e){Q(this,"name");ze(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function pre(r){return JSON.parse(JSON.stringify(r))}function ub(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function lb(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:Vp("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:Vp("orphan",t),filter:pre(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(i=>i==null?null:Array.isArray(i)?ub(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=ub(i.map(a=>a.toLowerCase()))}return{filter:n,tag:Vp("event",n),type:"event"}}q(!1,"unknown ProviderEvent","event",r)}function fb(){return new Date().getTime()}const gre={cacheTimeout:250,pollingInterval:4e3};class yre{constructor(e,t){se(this,ct);se(this,un);se(this,Jo);se(this,ln);se(this,Cl);se(this,Jn);se(this,Ec);se(this,Xo);se(this,no);se(this,Gh);se(this,pi);se(this,Bl);se(this,Pl);if(F(this,Pl,Object.assign({},gre,t||{})),e==="any")F(this,Ec,!0),F(this,Jn,null);else if(e){const n=os.from(e);F(this,Ec,!1),F(this,Jn,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else F(this,Ec,!1),F(this,Jn,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,Cl,!1),F(this,Gh,1),F(this,pi,new Map),F(this,Bl,!1)}get pollingInterval(){return T(this,Pl).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,Bl)}set disableCcipRead(e){F(this,Bl,!!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 Mte(ere(e),this)}_wrapLog(e,t){return new Sh(Jte(e),this)}_wrapTransactionReceipt(e,t){return new SN(ire(e),this)}_wrapTransactionResponse(e,t){return new kh(GN(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,Xn).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:Bu(e);if(typeof e=="bigint"&&(e=at(e,"blockTag")),typeof e=="number")return e>=0?Bu(e):T(this,no)>=0?Bu(T(this,no)+e):this.getBlockNumber().then(t=>Bu(t+e));q(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(u=>u==null?null:Array.isArray(u)?ub(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=Up(e),n=[];if(["to","from"].forEach(i=>{if(t[i]==null)return;const s=An(t[i],this);Kp(s)?n.push(async function(){t[i]=await s}()):t[i]=s}),t.blockTag!=null){const i=this._getBlockTag(t.blockTag);Kp(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,Jn)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,Jn)===i&&F(this,Jn,null),s}})();return F(this,Jn,i),(await i).clone()}const e=T(this,Jn),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(T(this,Ec)?(this.emit("network",n,t),T(this,Jn)===e&&F(this,Jn,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,j_).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await Ee(this,ct,Xn).call(this,{method:"getGasPrice"});return Le(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await Ee(this,ct,Xn).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*hre+u),new IN(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 IN(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Kp(t)&&(t=await t),Le(await Ee(this,ct,Xn).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,G_).call(this,Ee(this,ct,z_).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return Le(await Ee(this,ct,vd).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return at(await Ee(this,ct,vd).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return Ce(await Ee(this,ct,vd).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const i=Le(t,"position");return Ce(await Ee(this,ct,vd).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=Cp.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,j_).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,Xn).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,Xn).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const i=await Ee(this,ct,Xn).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,Xn).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:Ce(t)}async getLogs(e){let t=this._getFilter(e);Kp(t)&&(t=await t);const{network:n,params:i}=await mn({network:this.getNetwork(),params:Ee(this,ct,Xn).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 Hp.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=zw(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Hp.getEnsAddress(this),s=await new Vu(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(s==null||s===yh)return null;const a=await new Vu(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(Jt("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=_d(this,Gh)._++,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:fb()})}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 Wp(e.type);case"block":{const t=new cre(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new ure(this,e.type);case"event":return new cb(this,e.filter);case"transaction":return new fre(this,e.hash);case"orphan":return new lre(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,Eg).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,Eg).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,Ed).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 uT(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,Ed).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,Ed).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,Ed).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,Eg).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,Cl)}destroy(){this.removeAllListeners();for(const e of T(this,pi).keys())this._clearTimeout(e);F(this,Cl,!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=fb()-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=fb(),setTimeout(e.func,t)}}}}un=new WeakMap,Jo=new WeakMap,ln=new WeakMap,Cl=new WeakMap,Jn=new WeakMap,Ec=new WeakMap,Xo=new WeakMap,no=new WeakMap,Gh=new WeakMap,pi=new WeakMap,Bl=new WeakMap,Pl=new WeakMap,ct=new WeakSet,Xn=async function(e){const t=T(this,Pl).cacheTimeout;if(t<0)return await this._perform(e);const n=Vp(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},z_=async function(e,t,n){ge(n<dre,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const i=Up(e);try{return Ce(await this._perform({method:"call",transaction:i,blockTag:t}))}catch(s){if(!this.disableCcipRead&&ow(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=Are(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,_re([l,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const g=await Ee(this,ct,z_).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}},G_=async function(e){const{value:t}=await mn({network:this.getNetwork(),value:e});return t},vd=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,G_).call(this,Ee(this,ct,Xn).call(this,Object.assign(e,{address:i,blockTag:s})))},j_=async function(e,t){if(Gt(e,32))return await Ee(this,ct,Xn).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await Ee(this,ct,Xn).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},Ed=async function(e,t){let n=await lb(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await lb({orphan:"drop-log",log:t[0]},this)),T(this,un).get(n.tag)||null},Eg=async function(e){const t=await lb(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 mre(r,e){try{const t=hb(r,e);if(t)return hp(t)}catch{}return null}function hb(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 WN(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 wre(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const bre=new Uint8Array([]);function _re(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(bre),t+=32;for(let n=0;n<r.length;n++){const i=_t(r[n]);e[n]=WN(t),e.push(WN(i.length)),e.push(wre(i)),t+=32+Math.ceil(i.length/32)*32}return xr(e)}const qN="0x0000000000000000000000000000000000000000000000000000000000000000";function Are(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ge(Nu(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=lr(r,0,32);ge(lr(t,0,12)===lr(qN,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=mre(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=hb(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(qN,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=lr(r,96,100);try{const n=hb(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 qu(r,e){if(r.provider)return r.provider;ge(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function ZN(r,e){let t=Up(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 vre{constructor(e){Q(this,"provider");ze(this,{provider:e||null})}async getNonce(e){return qu(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await ZN(this,e)}async populateTransaction(e){const t=qu(this,"populateTransaction"),n=await ZN(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 qu(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return qu(this,"call").call(await this.populateCall(e))}async resolveName(e){return await qu(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=qu(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const i=Cp.from(n);return await t.broadcastTransaction(await this.signTransaction(i))}}function Ere(r){return JSON.parse(JSON.stringify(r))}class QN{constructor(e){se(this,ta);se(this,En);se(this,ps);se(this,xc);se(this,ea);se(this,Rc);se(this,Ml);F(this,En,e),F(this,ps,null),F(this,xc,Ee(this,ta,K_).bind(this)),F(this,ea,!1),F(this,Rc,null),F(this,Ml,!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,K_).call(this,-2))}stop(){T(this,ea)&&(F(this,ea,!1),F(this,Ml,!0),Ee(this,ta,V_).call(this),T(this,En).off("block",T(this,xc)))}pause(e){e&&Ee(this,ta,V_).call(this),T(this,En).off("block",T(this,xc))}resume(){this.start()}}En=new WeakMap,ps=new WeakMap,xc=new WeakMap,ea=new WeakMap,Rc=new WeakMap,Ml=new WeakMap,ta=new WeakSet,K_=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,Rc)||F(this,Rc,n),T(this,Rc).chainId!==n.chainId)throw new Error("chaid changed");if(T(this,Ml))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,xc))},V_=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 xre extends QN{constructor(t,n){super(t);se(this,Ic);F(this,Ic,Ere(n))}_recover(t){return new cb(t,T(this,Ic))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,Ic)])}async _emitResults(t,n){for(const i of n)t.emit(T(this,Ic),t._wrapLog(i,t._network))}}Ic=new WeakMap;class Rre extends QN{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const Ire="bigint,boolean,function,number,string,symbol".split(/,/g);function qp(r){if(r==null||Ire.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(qp);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 Sre(r){return new Promise(e=>{setTimeout(e,r)})}function Zu(r){return r&&r.toLowerCase()}function YN(r){return r&&typeof r.pollingInterval=="number"}const JN={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class db extends vre{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=qp(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",Jt("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=qp(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=qp(i),o=await Pp.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(Pp.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 XN extends yre{constructor(t,n){super(t,n);se(this,jh);se(this,Sc);se(this,Ll);se(this,io);se(this,gs);se(this,Pi);se(this,gi);se(this,Dn);F(this,Ll,1),F(this,Sc,Object.assign({},JN,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,Sc)[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:_d(this,Ll)._++,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",Jt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await Sre(1e3)}Ee(this,jh,W_).call(this)})())}async _waitUntilReady(){if(T(this,Pi)!=null)return await T(this,Pi).promise}_getSubscriber(t){return t.type==="pending"?new Rre(this):t.type==="event"?this._getOption("polling")?new cb(this,t.filter):new xre(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Wp("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]=Bu(Le(t[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{t[i]!=null&&(n[i]=Ce(t[i]))}),t.accessList&&(n.accessList=Xa(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:[Zu(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Zu(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Zu(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Zu(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(Zu):t.filter.address=Zu(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 Jt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=pb(s),l=Ih.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(Ore(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Jt("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 Jt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Jt("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Jt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Jt("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?Jt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:s,payload:t}}):Jt("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(Jt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const i=_d(this,Ll)._++,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,jh,W_).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 db(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 db(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new db(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(Jt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));F(this,io,[]),super.destroy()}}Sc=new WeakMap,Ll=new WeakMap,io=new WeakMap,gs=new WeakMap,Pi=new WeakMap,gi=new WeakMap,Dn=new WeakMap,jh=new WeakSet,W_=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,Sc).batchMaxCount;)if(i.push(n.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,Sc).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(Jt("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=Jt("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 kre extends XN{constructor(t,n){super(t,n);se(this,ra);let i=this._getOption("pollingInterval");i==null&&(i=JN.pollingInterval),F(this,ra,i)}_getSubscriber(t){const n=super._getSubscriber(t);return YN(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=>{YN(n)&&(n.pollingInterval=T(this,ra))})}}ra=new WeakMap;class Tre extends kre{constructor(t,n,i){t==null&&(t="http://localhost:8545");super(n,i);se(this,Ul);typeof t=="string"?F(this,Ul,new Us(t)):F(this,Ul,t.clone())}_getConnection(){return T(this,Ul).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}}Ul=new WeakMap;function pb(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=pb(r[e]);if(t)return t}return null}if(typeof r=="string")try{return pb(JSON.parse(r))}catch{}return null}function gb(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)gb(r[t],e);if(typeof r=="string")try{return gb(JSON.parse(r),e)}catch{}}}function Ore(r){const e=[];return gb(r,e),e}function Nre(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Zc<"u")return Zc;throw new Error("unable to locate global object")}const Cre=Nre().WebSocket;class yb{constructor(e,t){se(this,ys);se(this,Kh);se(this,na);se(this,kc);se(this,ia);F(this,ys,e),F(this,Kh,JSON.stringify(t)),F(this,na,null),F(this,kc,null),F(this,ia,null)}get filter(){return JSON.parse(T(this,Kh))}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,kc,!!e)}resume(){F(this,kc,null)}_handleMessage(e){if(T(this,na)!=null&&T(this,kc)===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,Kh=new WeakMap,na=new WeakMap,kc=new WeakMap,ia=new WeakMap;class Bre extends yb{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class Pre extends yb{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class Mre extends yb{constructor(t,n){super(t,["logs",n]);se(this,Vh);F(this,Vh,JSON.stringify(n))}get logFilter(){return JSON.parse(T(this,Vh))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}Vh=new WeakMap;class Lre extends XN{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,Tc);se(this,Dl);se(this,sa);F(this,Tc,new Map),F(this,Dl,new Map),F(this,sa,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Wp("close");case"block":return new Bre(this);case"pending":return new Pre(this);case"event":return new Mre(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Wp("drop-log")}return super._getSubscriber(t)}_register(t,n){T(this,Dl).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,Tc).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,Tc).get(n.id);if(i==null){this.emit("error",Jt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}T(this,Tc).delete(n.id),i.resolve(n)}else if(n&&n.method==="eth_subscription"){const i=n.params.subscription,s=T(this,Dl).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",Jt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}Tc=new WeakMap,Dl=new WeakMap,sa=new WeakMap;class Ure extends Lre{constructor(t,n,i){super(n,i);se(this,Oc);se(this,Mi);typeof t=="string"?(F(this,Oc,()=>new Cre(t)),F(this,Mi,T(this,Oc).call(this))):typeof t=="function"?(F(this,Oc,t),F(this,Mi,t())):(F(this,Oc,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()}}Oc=new WeakMap,Mi=new WeakMap;const Dre={_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:{}},$re={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 Fre{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 Ure(e):new Tre(e),i=new Vu(t,Dre.abi,n);this.evm={provider:n,contract:i}}initSvm(){const e=new rR(this.settings.rpcUrl,"confirmed"),t=Ba.generate(),n={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:t.publicKey},i=new oh(e,n,{}),s=new Tu($re,i);this.svm={provider:e,program:s}}async onMessageFrom(e,t){this.settings.chainType==="EVM"?this.listenToEvm(e,t):this.settings.chainType==="SVM"&&await this.listenToSvm(e,t)}listenToEvm(e,t){var n;(n=this.evm)==null||n.contract.on("MessageLogged",(i,s)=>{const[o,a]=s.split("_");da(i.toLowerCase())===da(this.settings.swarmEmitterAddress.toLowerCase())&&o===e&&t(i,s)})}async listenToSvm(e,t){var i;const n=(i=this.svm)==null?void 0:i.program.addEventListener("messageLogged",s=>{const{sender:o,message:a}=s,[u,l]=a.split("_");o.toBase58()===this.settings.swarmEmitterAddress&&u===e&&t(o.toBase58(),a)});this.svm&&n!==void 0&&(this.svm.listenerId=n)}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 Hre=new TextEncoder,eC=1,tC=4096,mb=4096,zre=32;function Gre(r,e){return e=typeof e=="number"?Se.FeedIndex.fromBigInt(BigInt(e)):e,new Se.Identifier(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function jre(r){const e=r.slice(0,Se.Span.LENGTH),t=r.slice(Se.Span.LENGTH),n=Kre(t),i=en.keccak256(en.concatBytes(e,n));return new Se.Reference(i)}function Kre(r){if(r.length>mb)throw new Se.BeeArgumentError(`payload size ${r.length} exceeds maximum chunk payload size ${mb}`,r);const e=new Uint8Array(mb);return e.set(r),en.log2Reduce(en.partition(e,zre),(t,n)=>en.keccak256(en.concatBytes(t,n)))}function rC(r){if(r instanceof Uint8Array||(r=Hre.encode(r)),r.length<eC||r.length>tC)throw new RangeError(`payload size ${r.length} exceeds limits [${eC}, ${tC}]`);const e=Se.Span.fromBigInt(BigInt(r.length)),t=en.concatBytes(e.toUint8Array(),r);return{data:t,span:e,payload:Se.Bytes.fromSlice(t,Se.Span.LENGTH),address:jre(t)}}function Vre(r,e){return new Se.Reference(en.keccak256(en.concatBytes(r.toUint8Array(),e.toUint8Array())))}function nC(r,e,t){e=new Se.Identifier(e),t=new Se.PrivateKey(t);const n=Vre(e,t.publicKey().address()),i=t.sign(en.concatBytes(e.toUint8Array(),r.address.toUint8Array())),s=en.concatBytes(e.toUint8Array(),i.toUint8Array(),r.data),o=Se.Span.fromSlice(r.data,0),a=Se.Bytes.fromSlice(r.data,Se.Span.LENGTH);return{data:s,identifier:e,signature:i,span:o,payload:a,address:n,owner:t.publicKey().address()}}class Wre{constructor(e,t){this.userDetails=e,this.swarmSettings=t,this.depth=24,this.logger=Ui.getInstance(),this.errorHandler=new $d,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(e,t){const{enveloped:n,stamp:i}=this.swarmSettings;if(!n)await this.writeOwnFeedDataByIndexOwned(e,t);else if(i)await this.writeOwnFeedDataByIndexEnvelope(e,t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),l=Se.Topic.fromString(u);console.log("DEBUG: feedID write",l.toString(),a,e,u),await n.makeFeedWriter(l,new Se.PrivateKey(o)).uploadPayload(i,JSON.stringify(t),{index:e})}async writeOwnFeedDataByIndexEnvelope(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new Se.PrivateKey(o),l=Se.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),g=Se.Topic.fromString(h),b=Gre(g,e),w=rC(t),I=nC(w,b,u),S={hash:()=>I.address.toUint8Array()},x=l.stamp(S),{upload:C}=n.makeSOCWriter(u),H=Se.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=Se.Topic.fromString(a);return console.log("DEBUG: feedID read",u.toString(),e,t,a),(await i.makeFeedReader(u,e,{timeout:o}).downloadPayload({index:t})).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){const{enveloped:t,stamp:n}=this.swarmSettings;if(t){if(n)return this.uploadObjectToBeeEnvelope(e);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(e)}async uploadObjectToBeeOwn(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.reference.toString()}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(e){try{const{bee:t,stamp:n}=this.swarmSettings,{privateKey:i}=this.userDetails,s=Se.Stamper.fromBlank(i,n,this.depth),o=Se.Bytes.fromUtf8(JSON.stringify(e)),a=new E4(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=Se.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(Se.Topic.fromString(t),da(n)).downloadPayload()).payload.toJSON()}async fetchChatMessage(e){const{bee:t,chatTopic:n,chatAddress:i}=this.swarmSettings;return(await t.makeFeedReader(Se.Topic.fromString(n),da(i)).downloadPayload({index:Se.FeedIndex.fromBigInt(BigInt(`0x${e}`))})).payload.toJSON()}async sendMessageToGsoc(e){const{enveloped:t,stamp:n}=this.swarmSettings;if(!t)await this.sendMessageToGsocOwn(e);else if(n)await this.sendMessageToGsocEnvelope(e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new Se.PrivateKey(s),a=Se.Identifier.fromString(i),u=Se.Bytes.fromUtf8(e),{upload:l}=t.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await l(n,a,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=Se.Stamper.fromBlank(o,n,this.depth),u=new Se.PrivateKey(s),l=Se.Identifier.fromString(i),h=Se.Bytes.fromUtf8(e),g=rC(h.toUint8Array()),b=nC(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 qre{constructor(e){var n,i,s;this.logger=Ui.getInstance(),this.errorHandler=new $d,this.messagesQueue=new Wg({clearWaitTime:200}),this.gsocListenerQueue=new Wg({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const t=new Se.PrivateKey(da(e.user.privateKey));this.userDetails={privateKey:e.user.privateKey,ownAddress:t.publicKey().address().toString(),nickname:e.user.nickname,ownIndex:-1},this.swarmSettings={bee:new Se.Bee(e.infra.swarm.beeUrl),stamp:e.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:e.infra.swarm.enveloped,customGsocCallback:e.infra.swarm.customGsocCallback,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 v4,this.utils=new Wre(this.userDetails,this.swarmSettings),this.history=new mG(this.userDetails,this.utils,this.swarmSettings,this.emitter),this.swarmEventEmitterReader=new Fre(e.infra.chain)}start(){this.init(),this.swarmSettings.customGsocCallback||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||A4(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:n,message:e};try{this.emitter.emit(Fn.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(n,JSON.stringify(i)),this.userDetails.ownIndex=n,this.emitter.emit(Fn.MESSAGE_REQUEST_UPLOADED,i),await this.broadcastUserMessage()}catch(s){this.emitter.emit(Fn.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Fn.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages({preDownloadHistory:!0})}finally{this.emitter.emit(Fn.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(e){this.sendMessage(e.message,e.id)}async retryBroadcastUserMessage(e){this.broadcastUserMessage()}async init(){try{this.emitter.emit(Fn.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(Fn.LOADING_INIT,!1)}catch(e){this.errorHandler.handleError(e,"Chat.initSelfState"),this.emitter.emit(Fn.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(this.swarmSettings.chatTopic,(e,t)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t)))}catch(e){this.errorHandler.handleError(e,"Chat.subscribeToGSOCEvent"),this.emitter.emit(Fn.CRITICAL_ERROR,e)}}callbackProcessGsocEvent(e){try{this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(e))}catch(t){this.errorHandler.handleError(t,"Chat.callbackProcessGsocEvent"),this.emitter.emit(Fn.CRITICAL_ERROR,t)}}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),!XA(i)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",i),m4(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 ev({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({topic:this.swarmSettings.chatTopic,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 Se.EthAddress(e).toString(),s=new Se.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(Fn.MESSAGE_RECEIVED,JSON.parse(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*PM&&delete this.activeUsers[t.address]}updateActiveUsers(e){this.activeUsers[e.address]=e}}ft.EVENTS=Fn,ft.SwarmChat=qre,Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"})});
|
|
18
|
+
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(t){const{signatures:e}=this,r=[];$r(r,e.length);const i=r.length+e.length*64+t.length,s=kt.alloc(i);return _e(e.length<256),kt.from(r).copy(s,0),e.forEach(({signature:o},a)=>{o!==null&&(_e(o.length===64,"signature has invalid length"),kt.from(o).copy(s,r.length+a*64))}),t.copy(s,r.length+e.length*64),_e(s.length<=Ao,`Transaction too large: ${s.length} > ${Ao}`),s}get keys(){return _e(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return _e(this.instructions.length===1),this.instructions[0].programId}get data(){return _e(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=Rr(e);let i=[];for(let s=0;s<r;s++){const o=Ir(e,0,Of);i.push(On.encode(kt.from(o)))}return Sb.populate(Ai.from(e),i)}static populate(t,e=[]){const r=new Sb;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((i,s)=>{const o={signature:i==On.encode(sL)?null:On.decode(i),publicKey:t.accountKeys[s]};r.signatures.push(o)}),t.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(u=>u.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Me({keys:s,programId:t.accountKeys[i.programIdIndex],data:On.decode(i.data)}))}),r._message=t,r._json=r.toJSON(),r}};class Cy{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:r,compiledInstructions:i,recentBlockhash:s}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=r,f=o-a;_e(f>0,"Message header is invalid");const h=t.staticAccountKeys.length-o-u;_e(h>=0,"Message header is invalid");const y=t.getAccountKeys(e),_=y.get(0);if(_===void 0)throw new Error("Failed to decompile message because no account keys were found");const w=[];for(const R of i){const T=[];for(const B of R.accountKeyIndexes){const H=y.get(B);if(H===void 0)throw new Error(`Failed to find key for account key index ${B}`);const U=B<o;let G;U?G=B<f:B<y.staticAccountKeys.length?G=B-o<h:G=B-y.staticAccountKeys.length<y.accountKeysFromLookups.writable.length,T.push({pubkey:H,isSigner:B<r.numRequiredSignatures,isWritable:G})}const I=y.get(R.programIdIndex);if(I===void 0)throw new Error(`Failed to find program id for program id index ${R.programIdIndex}`);w.push(new Me({programId:I,data:te(R.data),keys:T}))}return new Cy({payerKey:_,instructions:w,recentBlockhash:s})}compileToLegacyMessage(){return Ai.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return ka.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class By{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)_e(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const r=[];for(let i=0;i<t.header.numRequiredSignatures;i++)r.push(new Uint8Array(Of));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();$r(e,this.signatures.length);const r=Nt([We(e.length,"encodedSignaturesLength"),jn(tL(),this.signatures.length,"signatures"),We(t.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},i);return i.slice(0,s)}static deserialize(t){let e=[...t];const r=[],i=Rr(e);for(let o=0;o<i;o++)r.push(new Uint8Array(Ir(e,0,Of)));const s=Ny.deserialize(new Uint8Array(e));return new By(s,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of t){const s=r.findIndex(o=>o.equals(i.publicKey));_e(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Sy(e,i.secretKey)}}addSignature(t,e){_e(e.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(t));_e(i>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=e}}const _E=1e3/(160/64),Wi=new pt("SysvarC1ock11111111111111111111111111111111"),oL=new pt("SysvarEpochSchedu1e111111111111111111111111"),aL=new pt("Sysvar1nstructions1111111111111111111111111"),g0=new pt("SysvarRecentB1ockHashes11111111111111111111"),fu=new pt("SysvarRent111111111111111111111111111111111"),cL=new pt("SysvarRewards111111111111111111111111111111"),uL=new pt("SysvarS1otHashes111111111111111111111111111"),lL=new pt("SysvarS1otHistory11111111111111111111111111"),y0=new pt("SysvarStakeHistory1111111111111111111111111");class Eo extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:i}){const s=i?`Logs:
|
|
19
|
+
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(t){case"send":a=`Transaction ${e} resulted in an error.
|
|
20
|
+
${r}. `+s+o;break;case"simulate":a=`Simulation failed.
|
|
21
|
+
Message: ${r}.
|
|
22
|
+
`+s+o;break;default:a=`Unknown action '${(u=>u)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,r)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,e(s)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const fL={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Mt extends Error{constructor({code:t,message:e,data:r},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function Py(n,t,e,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await n.sendTransaction(t,e,i);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,u=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:t.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else(r==null?void 0:r.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await n.confirmTransaction(s,r&&r.commitment)).value;if(o.err)throw s!=null?new Eo({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function Ta(n){return new Promise(t=>setTimeout(t,n))}function pe(n,t){const e=n.layout.span>=0?n.layout.span:wE(n,t),r=kt.alloc(e),i=Object.assign({instruction:n.index},t);return n.layout.encode(i,r),r}function ke(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const AE=Kn("lamportsPerSignature"),EE=Nt([Ot("version"),Ot("state"),ce("authorizedPubkey"),ce("nonce"),Nt([AE],"feeCalculator")]),My=EE.span;class m0{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=EE.decode(te(t),0);return new m0({authorizedPubkey:new pt(e.authorizedPubkey),nonce:new pt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const hL=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},hu=(n=>t=>{const e=We(n,t),{encode:r,decode:i}=hL(e),s=e;return s.decode=(o,a)=>{const u=i(o,a);return G4(kt.from(u))},s.encode=(o,a,u)=>{const f=GA(o,n);return r(f,a,u)},s})(8);class dL{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(He))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:i}=ke(He.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new pt(i)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=ke(He.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:i}=ke(He.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new pt(i)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=ke(He.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:i,programId:s}=ke(He.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,space:i,programId:new pt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=ke(He.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new pt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:i}=ke(He.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,programId:new pt(i)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:i,space:s,programId:o}=ke(He.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new pt(e),seed:r,lamports:i,space:s,programId:new pt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=ke(He.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new pt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),ke(He.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=ke(He.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=ke(He.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new pt(e)}}static checkProgramId(t){if(!t.equals(Cn.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const He=Object.freeze({Create:{index:0,layout:Nt([Ot("instruction"),Fr("lamports"),Fr("space"),ce("programId")])},Assign:{index:1,layout:Nt([Ot("instruction"),ce("programId")])},Transfer:{index:2,layout:Nt([Ot("instruction"),hu("lamports")])},CreateWithSeed:{index:3,layout:Nt([Ot("instruction"),ce("base"),Sa("seed"),Fr("lamports"),Fr("space"),ce("programId")])},AdvanceNonceAccount:{index:4,layout:Nt([Ot("instruction")])},WithdrawNonceAccount:{index:5,layout:Nt([Ot("instruction"),Fr("lamports")])},InitializeNonceAccount:{index:6,layout:Nt([Ot("instruction"),ce("authorized")])},AuthorizeNonceAccount:{index:7,layout:Nt([Ot("instruction"),ce("authorized")])},Allocate:{index:8,layout:Nt([Ot("instruction"),Fr("space")])},AllocateWithSeed:{index:9,layout:Nt([Ot("instruction"),ce("base"),Sa("seed"),Fr("space"),ce("programId")])},AssignWithSeed:{index:10,layout:Nt([Ot("instruction"),ce("base"),Sa("seed"),ce("programId")])},TransferWithSeed:{index:11,layout:Nt([Ot("instruction"),hu("lamports"),Sa("seed"),ce("programId")])},UpgradeNonceAccount:{index:12,layout:Nt([Ot("instruction")])}});class Cn{constructor(){}static createAccount(t){const e=He.Create,r=pe(e,{lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});return new Me({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const i=He.TransferWithSeed;e=pe(i,{lamports:BigInt(t.lamports),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=He.Transfer;e=pe(i,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Me({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const i=He.AssignWithSeed;e=pe(i,{base:te(t.basePubkey.toBuffer()),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=He.Assign;e=pe(i,{programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Me({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=He.CreateWithSeed,r=pe(e,{base:te(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});let i=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||i.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Me({keys:i,programId:this.programId,data:r})}static createNonceAccount(t){const e=new Ne;"basePubkey"in t&&"seed"in t?e.add(Cn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:My,programId:this.programId})):e.add(Cn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:My,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=He.InitializeNonceAccount,r=pe(e,{authorized:te(t.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:g0,isSigner:!1,isWritable:!1},{pubkey:fu,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Me(i)}static nonceAdvance(t){const e=He.AdvanceNonceAccount,r=pe(e),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:g0,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Me(i)}static nonceWithdraw(t){const e=He.WithdrawNonceAccount,r=pe(e,{lamports:t.lamports});return new Me({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:g0,isSigner:!1,isWritable:!1},{pubkey:fu,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=He.AuthorizeNonceAccount,r=pe(e,{authorized:te(t.newAuthorizedPubkey.toBuffer())});return new Me({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const i=He.AllocateWithSeed;e=pe(i,{base:te(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=He.Allocate;e=pe(i,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Me({keys:r,programId:this.programId,data:e})}}Cn.programId=new pt("11111111111111111111111111111111");const pL=Ao-300;class Oa{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Oa.chunkSize)+1+1)}static async load(t,e,r,i,s){{const y=await t.getMinimumBalanceForRentExemption(s.length),_=await t.getAccountInfo(r.publicKey,"confirmed");let w=null;if(_!==null){if(_.executable)return console.error("Program load failed, account is already executable"),!1;_.data.length!==s.length&&(w=w||new Ne,w.add(Cn.allocate({accountPubkey:r.publicKey,space:s.length}))),_.owner.equals(i)||(w=w||new Ne,w.add(Cn.assign({accountPubkey:r.publicKey,programId:i}))),_.lamports<y&&(w=w||new Ne,w.add(Cn.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:y-_.lamports})))}else w=new Ne().add(Cn.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:y>0?y:1,space:s.length,programId:i}));w!==null&&await Py(t,w,[e,r],{commitment:"confirmed"})}const o=Nt([Ot("instruction"),Ot("offset"),Ot("bytesLength"),Ot("bytesLengthPadding"),jn(me("byte"),bo(Ot(),-8),"bytes")]),a=Oa.chunkSize;let u=0,f=s,h=[];for(;f.length>0;){const y=f.slice(0,a),_=kt.alloc(a+16);o.encode({instruction:0,offset:u,bytes:y,bytesLength:0,bytesLengthPadding:0},_);const w=new Ne().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:_});h.push(Py(t,w,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Ta(1e3/4),u+=a,f=f.slice(a)}await Promise.all(h);{const y=Nt([Ot("instruction")]),_=kt.alloc(y.span);y.encode({instruction:1},_);const w=new Ne().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:fu,isSigner:!1,isWritable:!1}],programId:i,data:_}),R="processed",T=await t.sendTransaction(w,[e,r],{preflightCommitment:R}),{context:I,value:B}=await t.confirmTransaction({signature:T,lastValidBlockHeight:w.lastValidBlockHeight,blockhash:w.recentBlockhash},R);if(B.err)throw new Error(`Transaction ${T} failed (${JSON.stringify(B)})`);for(;;){try{if(await t.getSlot({commitment:R})>I.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(_E/2)))}}return!0}}Oa.chunkSize=pL;const gL=new pt("BPFLoader2111111111111111111111111111111111");class yL{static getMinNumSignatures(t){return Oa.getMinNumSignatures(t)}static load(t,e,r,i,s){return Oa.load(t,e,r,s,i)}}function mL(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ly,vE;function wL(){if(vE)return Ly;vE=1;var n=Object.prototype.toString,t=Object.keys||function(r){var i=[];for(var s in r)i.push(s);return i};function e(r,i){var s,o,a,u,f,h,y;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return e(r.toJSON(),i);if(y=n.call(r),y==="[object Array]"){for(a="[",o=r.length-1,s=0;s<o;s++)a+=e(r[s],!0)+",";return o>-1&&(a+=e(r[s],!0)),a+"]"}else if(y==="[object Object]"){for(u=t(r).sort(),o=u.length,a="",s=0;s<o;)f=u[s],h=e(r[f],!1),h!==void 0&&(a&&(a+=","),a+=JSON.stringify(f)+":"+h),s++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ly=function(r){var i=e(r,!1);if(i!==void 0)return""+i},Ly}var bL=wL(),xE=mL(bL);const Cf=32;function Uy(n){let t=0;for(;n>1;)n/=2,t++;return t}function _L(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class RE{constructor(t,e,r,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Uy(_L(t+Cf+1))-Uy(Cf)-1,r=this.getSlotsInEpoch(e),i=t-(r-Cf);return[e,i]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+r,s=e%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*Cf:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+Uy(Cf)):this.slotsPerEpoch}}var AL=globalThis.fetch;class EL extends SM{constructor(t,e,r){const i=s=>{const o=RM(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function vL(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const IE=56;class Dy{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=vL(xL,t),r=t.length-IE;_e(r>=0,"lookup table is invalid"),_e(r%32===0,"lookup table is invalid");const i=r/32,{addresses:s}=Nt([jn(ce(),i,"addresses")]).decode(t.slice(IE));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new pt(e.authority[0]):void 0,addresses:s.map(o=>new pt(o))}}}const xL={index:1,layout:Nt([Ot("typeIndex"),hu("deactivationSlot"),Kn("lastExtendedSlot"),me("lastExtendedStartIndex"),me(),jn(ce(),bo(me(),-1),"authority")])},RL=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function IL(n){const t=n.match(RL);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,i,s]=t,o=n.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${r}${u}${s}`}const nn=If(wy(pt),mt(),n=>new pt(n)),SE=by([mt(),en("base64")]),Fy=If(wy(kt),SE,n=>kt.from(n[0],"base64")),kE=30*1e3;function SL(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function ze(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...i}=n;t=r,e=i}return{commitment:t,config:e}}function TE(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function OE(n){return dr([ft({jsonrpc:en("2.0"),id:mt(),result:n}),ft({jsonrpc:en("2.0"),id:mt(),error:ft({code:uu(),message:mt(),data:Dt(J4())})})])}const kL=OE(uu());function ee(n){return If(OE(n),kL,t=>"error"in t?t:{...t,result:bt(t.result,n)})}function vn(n){return ee(ft({context:ft({slot:tt()}),value:n}))}function w0(n){return ft({context:ft({slot:tt()}),value:n})}function $y(n,t){return n===0?new ka({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new pt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:On.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ai(t)}const TL=ft({foundation:tt(),foundationTerm:tt(),initial:tt(),taper:tt(),terminal:tt()}),OL=ee(Et(vt(ft({epoch:tt(),effectiveSlot:tt(),amount:tt(),postBalance:tt(),commission:Dt(vt(tt()))})))),NL=Et(ft({slot:tt(),prioritizationFee:tt()})),CL=ft({total:tt(),validator:tt(),foundation:tt(),epoch:tt()}),BL=ft({epoch:tt(),slotIndex:tt(),slotsInEpoch:tt(),absoluteSlot:tt(),blockHeight:Dt(tt()),transactionCount:Dt(tt())}),PL=ft({slotsPerEpoch:tt(),leaderScheduleSlotOffset:tt(),warmup:Vi(),firstNormalEpoch:tt(),firstNormalSlot:tt()}),ML=WA(mt(),Et(tt())),Na=vt(dr([ft({}),mt()])),LL=ft({err:Na}),UL=en("receivedSignature"),DL=ft({"solana-core":mt(),"feature-set":Dt(tt())}),FL=ft({program:mt(),programId:nn,parsed:uu()}),$L=ft({programId:nn,accounts:Et(nn),data:mt()}),NE=vn(ft({err:vt(dr([ft({}),mt()])),logs:vt(Et(mt())),accounts:Dt(vt(Et(vt(ft({executable:Vi(),owner:mt(),lamports:tt(),data:Et(mt()),rentEpoch:Dt(tt())}))))),unitsConsumed:Dt(tt()),returnData:Dt(vt(ft({programId:mt(),data:by([mt(),en("base64")])}))),innerInstructions:Dt(vt(Et(ft({index:tt(),instructions:Et(dr([FL,$L]))}))))})),HL=vn(ft({byIdentity:WA(mt(),Et(tt())),range:ft({firstSlot:tt(),lastSlot:tt()})}));function zL(n,t,e,r,i,s){const o=e||AL;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 r&&(u=async(h,y)=>{const _=await new Promise((w,R)=>{try{r(h,y,(T,I)=>w([T,I]))}catch(T){R(T)}});return await o(..._)}),new vM(async(h,y)=>{const _={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},zU)};try{let w=5,R,T=500;for(;u?R=await u(n,_):R=await o(n,_),!(R.status!==429||i===!0||(w-=1,w===0));)console.error(`Server responded with ${R.status} ${R.statusText}. Retrying after ${T}ms delay...`),await Ta(T),T*=2;const I=await R.text();R.ok?y(null,I):y(new Error(`${R.status} ${R.statusText}: ${I}`))}catch(w){w instanceof Error&&y(w)}},{})}function GL(n){return(t,e)=>new Promise((r,i)=>{n.request(t,e,(s,o)=>{if(s){i(s);return}r(o)})})}function VL(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const i=t.map(s=>n.request(s.methodName,s.args));n.request(i,(s,o)=>{if(s){r(s);return}e(o)})})}const KL=ee(TL),jL=ee(CL),WL=ee(NL),ZL=ee(BL),qL=ee(PL),QL=ee(ML),YL=ee(tt()),JL=vn(ft({total:tt(),circulating:tt(),nonCirculating:tt(),nonCirculatingAccounts:Et(nn)})),Hy=ft({amount:mt(),uiAmount:vt(tt()),decimals:tt(),uiAmountString:Dt(mt())}),XL=vn(Et(ft({address:nn,amount:mt(),uiAmount:vt(tt()),decimals:tt(),uiAmountString:Dt(mt())}))),tU=vn(Et(ft({pubkey:nn,account:ft({executable:Vi(),owner:nn,lamports:tt(),data:Fy,rentEpoch:tt()})}))),zy=ft({program:mt(),parsed:uu(),space:tt()}),eU=vn(Et(ft({pubkey:nn,account:ft({executable:Vi(),owner:nn,lamports:tt(),data:zy,rentEpoch:tt()})}))),nU=vn(Et(ft({lamports:tt(),address:nn}))),Bf=ft({executable:Vi(),owner:nn,lamports:tt(),data:Fy,rentEpoch:tt()}),rU=ft({pubkey:nn,account:Bf}),iU=If(dr([wy(kt),zy]),dr([SE,zy]),n=>Array.isArray(n)?bt(n,Fy):n),Gy=ft({executable:Vi(),owner:nn,lamports:tt(),data:iU,rentEpoch:tt()}),sU=ft({pubkey:nn,account:Gy}),oU=ft({state:dr([en("active"),en("inactive"),en("activating"),en("deactivating")]),active:tt(),inactive:tt()}),aU=ee(Et(ft({signature:mt(),slot:tt(),err:Na,memo:vt(mt()),blockTime:Dt(vt(tt()))}))),cU=ee(Et(ft({signature:mt(),slot:tt(),err:Na,memo:vt(mt()),blockTime:Dt(vt(tt()))}))),uU=ft({subscription:tt(),result:w0(Bf)}),lU=ft({pubkey:nn,account:Bf}),fU=ft({subscription:tt(),result:w0(lU)}),hU=ft({parent:tt(),slot:tt(),root:tt()}),dU=ft({subscription:tt(),result:hU}),pU=dr([ft({type:dr([en("firstShredReceived"),en("completed"),en("optimisticConfirmation"),en("root")]),slot:tt(),timestamp:tt()}),ft({type:en("createdBank"),parent:tt(),slot:tt(),timestamp:tt()}),ft({type:en("frozen"),slot:tt(),timestamp:tt(),stats:ft({numTransactionEntries:tt(),numSuccessfulTransactions:tt(),numFailedTransactions:tt(),maxTransactionsPerEntry:tt()})}),ft({type:en("dead"),slot:tt(),timestamp:tt(),err:mt()})]),gU=ft({subscription:tt(),result:pU}),yU=ft({subscription:tt(),result:w0(dr([LL,UL]))}),mU=ft({subscription:tt(),result:tt()}),wU=ft({pubkey:mt(),gossip:vt(mt()),tpu:vt(mt()),rpc:vt(mt()),version:vt(mt())}),CE=ft({votePubkey:mt(),nodePubkey:mt(),activatedStake:tt(),epochVoteAccount:Vi(),epochCredits:Et(by([tt(),tt(),tt()])),commission:tt(),lastVote:tt(),rootSlot:vt(tt())}),bU=ee(ft({current:Et(CE),delinquent:Et(CE)})),_U=dr([en("processed"),en("confirmed"),en("finalized")]),AU=ft({slot:tt(),confirmations:vt(tt()),err:Na,confirmationStatus:Dt(_U)}),EU=vn(Et(vt(AU))),vU=ee(tt()),BE=ft({accountKey:nn,writableIndexes:Et(tt()),readonlyIndexes:Et(tt())}),Vy=ft({signatures:Et(mt()),message:ft({accountKeys:Et(mt()),header:ft({numRequiredSignatures:tt(),numReadonlySignedAccounts:tt(),numReadonlyUnsignedAccounts:tt()}),instructions:Et(ft({accounts:Et(tt()),data:mt(),programIdIndex:tt()})),recentBlockhash:mt(),addressTableLookups:Dt(Et(BE))})}),PE=ft({pubkey:nn,signer:Vi(),writable:Vi(),source:Dt(dr([en("transaction"),en("lookupTable")]))}),ME=ft({accountKeys:Et(PE),signatures:Et(mt())}),LE=ft({parsed:uu(),program:mt(),programId:nn}),UE=ft({accounts:Et(nn),data:mt(),programId:nn}),xU=dr([UE,LE]),RU=dr([ft({parsed:uu(),program:mt(),programId:mt()}),ft({accounts:Et(mt()),data:mt(),programId:mt()})]),DE=If(xU,RU,n=>"accounts"in n?bt(n,UE):bt(n,LE)),FE=ft({signatures:Et(mt()),message:ft({accountKeys:Et(PE),instructions:Et(DE),recentBlockhash:mt(),addressTableLookups:Dt(vt(Et(BE)))})}),b0=ft({accountIndex:tt(),mint:mt(),owner:Dt(mt()),programId:Dt(mt()),uiTokenAmount:Hy}),$E=ft({writable:Et(nn),readonly:Et(nn)}),_0=ft({err:Na,fee:tt(),innerInstructions:Dt(vt(Et(ft({index:tt(),instructions:Et(ft({accounts:Et(tt()),data:mt(),programIdIndex:tt()}))})))),preBalances:Et(tt()),postBalances:Et(tt()),logMessages:Dt(vt(Et(mt()))),preTokenBalances:Dt(vt(Et(b0))),postTokenBalances:Dt(vt(Et(b0))),loadedAddresses:Dt($E),computeUnitsConsumed:Dt(tt())}),Ky=ft({err:Na,fee:tt(),innerInstructions:Dt(vt(Et(ft({index:tt(),instructions:Et(DE)})))),preBalances:Et(tt()),postBalances:Et(tt()),logMessages:Dt(vt(Et(mt()))),preTokenBalances:Dt(vt(Et(b0))),postTokenBalances:Dt(vt(Et(b0))),loadedAddresses:Dt($E),computeUnitsConsumed:Dt(tt())}),du=dr([en(0),en("legacy")]),Ca=ft({pubkey:mt(),lamports:tt(),postBalance:vt(tt()),rewardType:vt(mt()),commission:Dt(vt(tt()))}),IU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(ft({transaction:Vy,meta:vt(_0),version:Dt(du)})),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),SU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),kU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(ft({transaction:ME,meta:vt(_0),version:Dt(du)})),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),TU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(ft({transaction:FE,meta:vt(Ky),version:Dt(du)})),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),OU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(ft({transaction:ME,meta:vt(Ky),version:Dt(du)})),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),NU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),rewards:Dt(Et(Ca)),blockTime:vt(tt()),blockHeight:vt(tt())}))),CU=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(ft({transaction:Vy,meta:vt(_0)})),rewards:Dt(Et(Ca)),blockTime:vt(tt())}))),HE=ee(vt(ft({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),signatures:Et(mt()),blockTime:vt(tt())}))),jy=ee(vt(ft({slot:tt(),meta:vt(_0),blockTime:Dt(vt(tt())),transaction:Vy,version:Dt(du)}))),A0=ee(vt(ft({slot:tt(),transaction:FE,meta:vt(Ky),blockTime:Dt(vt(tt())),version:Dt(du)}))),BU=vn(ft({blockhash:mt(),lastValidBlockHeight:tt()})),PU=vn(Vi()),MU=ft({slot:tt(),numTransactions:tt(),numSlots:tt(),samplePeriodSecs:tt()}),LU=ee(Et(MU)),UU=vn(vt(ft({feeCalculator:ft({lamportsPerSignature:tt()})}))),DU=ee(mt()),FU=ee(mt()),$U=ft({err:Na,logs:Et(mt()),signature:mt()}),HU=ft({result:w0($U),subscription:tt()}),zU={"solana-client":"js/1.0.0-maintenance"};class zE{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const f={};return async h=>{const{commitment:y,config:_}=ze(h),w=this._buildArgs([],y,void 0,_),R=xE(w);return f[R]=f[R]??(async()=>{try{const T=await this._rpcRequest("getBlockHeight",w),I=bt(T,ee(tt()));if("error"in I)throw new Mt(I.error,"failed to get block height information");return I.result}finally{delete f[R]}})(),await f[R]}})();let r,i,s,o,a,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,i=e.httpHeaders,s=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=SL(t),this._rpcWsEndpoint=r||IL(t),this._rpcClient=zL(t,i,s,o,a,u),this._rpcRequest=GL(this._rpcClient),this._rpcBatchRequest=VL(this._rpcClient),this._rpcWebSocket=new EL(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgs([t.toBase58()],r,void 0,i),o=await this._rpcRequest("getBalance",s),a=bt(o,vn(tt()));if("error"in a)throw new Mt(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=bt(e,ee(vt(tt())));if("error"in r)throw new Mt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=bt(t,ee(tt()));if("error"in e)throw new Mt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=bt(t,YL);if("error"in e)throw new Mt(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[e]),i=bt(r,JL);if("error"in i)throw new Mt(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",r),s=bt(i,vn(Hy));if("error"in s)throw new Mt(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",r),s=bt(i,vn(Hy));if("error"in s)throw new Mt(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,r){const{commitment:i,config:s}=ze(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",a),f=bt(u,tU);if("error"in f)throw new Mt(f.error,`failed to get token accounts owned by account ${t.toBase58()}`);return f.result}async getParsedTokenAccountsByOwner(t,e,r){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const s=this._buildArgs(i,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),a=bt(o,eU);if("error"in a)throw new Mt(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",r),s=bt(i,nU);if("error"in s)throw new Mt(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",r),s=bt(i,XL);if("error"in s)throw new Mt(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgs([t.toBase58()],r,"base64",i),o=await this._rpcRequest("getAccountInfo",s),a=bt(o,vn(vt(Bf)));if("error"in a)throw new Mt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),a=bt(o,vn(vt(Gy)));if("error"in a)throw new Mt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:i}=ze(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=bt(a,vn(Et(vt(Gy))));if("error"in u)throw new Mt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:i}=ze(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=bt(a,vn(Et(vt(Bf))));if("error"in u)throw new Mt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:i,config:s}=ze(e),o=this._buildArgs([t.toBase58()],i,void 0,{...s,epoch:r??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=bt(a,ee(oU));if("error"in u)throw new Mt(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:r,config:i}=ze(e),{encoding:s,...o}=i||{},a=this._buildArgs([t.toBase58()],r,s||"base64",{...o,...o.filters?{filters:TE(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),f=Et(rU),h=o.withContext===!0?bt(u,vn(f)):bt(u,ee(f));if("error"in h)throw new Mt(h.error,`failed to get accounts owned by program ${t.toBase58()}`);return h.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),a=bt(o,ee(Et(sU)));if("error"in a)throw new Mt(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var s;let r;if(typeof t=="string")r=t;else{const o=t;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let i;try{i=On.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return _e(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,i,s=!1;const o=new Promise((u,f)=>{try{r=this.onSignature(e,(y,_)=>{r=void 0;const w={context:_,value:y};u({__type:Ss.PROCESSED,response:w})},t);const h=new Promise(y=>{r==null?y():i=this._onSubscriptionStateChange(r,_=>{_==="subscribed"&&y()})});(async()=>{if(await h,s)return;const y=await this.getSignatureStatus(e);if(s||y==null)return;const{context:_,value:w}=y;if(w!=null)if(w!=null&&w.err)f(w.err);else{switch(t){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:Ss.PROCESSED,response:{context:_,value:w}})}})()}catch(h){f(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:i}}){let s=!1;const o=new Promise(y=>{const _=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let w=await _();if(!s){for(;w<=r;)if(await Ta(1e3),s||(w=await _(),s))return;y({__type:Ss.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),f=this.getCancellationPromise(e);let h;try{const y=await Promise.race([f,u,o]);if(y.__type===Ss.PROCESSED)h=y.response;else throw new Ty(i)}finally{s=!0,a()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let a=!1;const u=new Promise(w=>{let R=s,T=null;const I=async()=>{try{const{context:B,value:H}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:r});return T=B.slot,H==null?void 0:H.nonce}catch{return R}};(async()=>{if(R=await I(),!a)for(;;){if(s!==R){w({__type:Ss.NONCE_INVALID,slotInWhichNonceDidAdvance:T});return}if(await Ta(2e3),a||(R=await I(),a))return}})()}),{abortConfirmation:f,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),y=this.getCancellationPromise(e);let _;try{const w=await Promise.race([y,h,u]);if(w.__type===Ss.PROCESSED)_=w.response;else{let R;for(;;){const T=await this.getSignatureStatus(o);if(T==null)break;if(T.context.slot<(w.slotInWhichNonceDidAdvance??r)){await Ta(400);continue}R=T;break}if(R!=null&&R.value){const T=t||"finalized",{confirmationStatus:I}=R.value;switch(T){case"processed":case"recent":if(I!=="processed"&&I!=="confirmed"&&I!=="finalized")throw new lu(o);break;case"confirmed":case"single":case"singleGossip":if(I!=="confirmed"&&I!=="finalized")throw new lu(o);break;case"finalized":case"max":case"root":if(I!=="finalized")throw new lu(o);break;default:}_={context:R.context,value:{err:R.value.err}}}else throw new lu(o)}}finally{a=!0,f()}return _}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const i=new Promise(u=>{let f=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{f=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>u({__type:Ss.TIMED_OUT,timeoutMs:f}),f)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const u=await Promise.race([o,i]);if(u.__type===Ss.PROCESSED)a=u.response;else throw new Oy(e,u.timeoutMs/1e3)}finally{clearTimeout(r),s()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=bt(t,ee(Et(wU)));if("error"in e)throw new Mt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),i=bt(r,bU);if("error"in i)throw new Mt(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlot",i),o=bt(s,ee(tt()));if("error"in o)throw new Mt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlotLeader",i),o=bt(s,ee(mt()));if("error"in o)throw new Mt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],i=await this._rpcRequest("getSlotLeaders",r),s=bt(i,ee(Et(nn)));if("error"in s)throw new Mt(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:r,value:i}=await this.getSignatureStatuses([t],e);_e(i.length===1);const s=i[0];return{context:r,value:s}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const i=await this._rpcRequest("getSignatureStatuses",r),s=bt(i,EU);if("error"in s)throw new Mt(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getTransactionCount",i),o=bt(s,ee(tt()));if("error"in o)throw new Mt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),i=bt(r,KL);if("error"in i)throw new Mt(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,r){const{commitment:i,config:s}=ze(r),o=this._buildArgs([t.map(f=>f.toBase58())],i,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=bt(a,OL);if("error"in u)throw new Mt(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=bt(t,jL);if("error"in e)throw new Mt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getEpochInfo",i),o=bt(s,ZL);if("error"in o)throw new Mt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=bt(t,qL);if("error"in e)throw new Mt(e.error,"failed to get epoch schedule");const r=e.result;return new RE(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=bt(t,QL);if("error"in e)throw new Mt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=bt(i,vU);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=bt(e,LU);if("error"in r)throw new Mt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=bt(i,UU);if("error"in s)throw new Mt(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(t,e){const r=te(t.serialize()).toString("base64"),i=this._buildArgs([r],e),s=await this._rpcRequest("getFeeForMessage",i),o=bt(s,vn(vt(tt())));if("error"in o)throw new Mt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=bt(i,WL);if("error"in s)throw new Mt(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),o=bt(s,BU);if("error"in o)throw new Mt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgs([t],r,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),a=bt(o,PU);if("error"in a)throw new Mt(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=bt(t,ee(DL));if("error"in e)throw new Mt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=bt(t,ee(mt()));if("error"in e)throw new Mt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=bt(o,kU);if("error"in a)throw a.error;return a.result}case"none":{const a=bt(o,SU);if("error"in a)throw a.error;return a.result}default:{const a=bt(o,IU);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:f,meta:h,version:y})=>({meta:h,transaction:{...f,message:$y(y,f.message)},version:y}))}:null}}}catch(a){throw new Mt(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=bt(o,OU);if("error"in a)throw a.error;return a.result}case"none":{const a=bt(o,NU);if("error"in a)throw a.error;return a.result}default:{const a=bt(o,TU);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Mt(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...u}=t;r=a,e=u}const i=this._buildArgs([],r,"base64",e),s=await this._rpcRequest("getBlockProduction",i),o=bt(s,HL);if("error"in o)throw new Mt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getTransaction",s),a=bt(o,jy);if("error"in a)throw new Mt(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:$y(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:i}=ze(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),a=bt(o,A0);if("error"in a)throw new Mt(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:i}=ze(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=bt(u,A0);if("error"in f)throw new Mt(f.error,"failed to get transactions");return f.result})}async getTransactions(t,e){const{commitment:r,config:i}=ze(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=bt(u,jy);if("error"in f)throw new Mt(f.error,"failed to get transactions");const h=f.result;return h&&{...h,transaction:{...h.transaction,message:$y(h.version,h.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",r),s=bt(i,CU);if("error"in s)throw new Mt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:f})=>{const h=new Ai(u.message);return{meta:f,transaction:{...u,message:h}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:f})=>({meta:f,transaction:Ne.populate(u.message,u.signatures)}))}}async getBlocks(t,e,r){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),s=await this._rpcRequest("getBlocks",i),o=bt(s,ee(Et(tt())));if("error"in o)throw new Mt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=bt(i,HE);if("error"in s)throw new Mt(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=bt(i,HE);if("error"in s)throw new Mt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",r),s=bt(i,jy);if("error"in s)throw new Mt(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const a=new Ai(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Ne.populate(a,u)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=bt(i,A0);if("error"in s)throw new Mt(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=bt(o,A0);if("error"in a)throw new Mt(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<s));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(r++,!(r>o));)try{const u=await this.getConfirmedBlockSignatures(r);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=bt(s,aU);if("error"in o)throw new Mt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",i),o=bt(s,cU);if("error"in o)throw new Mt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=new Dy({key:t,state:Dy.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=m0.fromAccountData(i.data)),{context:r,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=bt(r,DU);if("error"in i)throw new Mt(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Ta(100);const r=Date.now()-this._blockhashInfo.lastFetch>=kE;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(r!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Ta(_E/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=ze(t),i=this._buildArgs([],e,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=bt(s,vn(tt()));if("error"in o)throw new Mt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const T=t.serialize(),I=kt.from(T).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const B=e||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(B.innerInstructions=e.innerInstructions);const H=[I,B],U=await this._rpcRequest("simulateTransaction",H),G=bt(U,NE);if("error"in G)throw new Error("failed to simulate transaction: "+G.error.message);return G.result}let i;if(t instanceof Ne){let R=t;i=new Ne,i.feePayer=R.feePayer,i.instructions=t.instructions,i.nonceInfo=R.nonceInfo,i.signatures=R.signatures}else i=Ne.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(i.nonceInfo&&s)i.sign(...s);else{let R=this._disableBlockhashCaching;for(;;){const T=await this._blockhashWithExpiryBlockHeight(R);if(i.lastValidBlockHeight=T.lastValidBlockHeight,i.recentBlockhash=T.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const I=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(I)&&!this._blockhashInfo.transactionSignatures.includes(I)){this._blockhashInfo.simulatedSignatures.push(I);break}else R=!0}}const o=i._compile(),a=o.serialize(),f=i._serialize(a).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(r){const R=(Array.isArray(r)?r:o.nonProgramIds()).map(T=>T.toBase58());h.accounts={encoding:"base64",addresses:R}}s&&(h.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(h.innerInstructions=e.innerInstructions);const y=[f,h],_=await this._rpcRequest("simulateTransaction",y),w=bt(_,NE);if("error"in w){let R;if("data"in w.error&&(R=w.error.data.logs,R&&Array.isArray(R))){const T=`
|
|
23
|
+
`,I=T+R.join(T);console.error(w.error.message,I)}throw new Eo({action:"simulate",signature:"",transactionMessage:w.error.message,logs:R})}return w.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=t.serialize();return await this.sendRawTransaction(s,r)}async sendRawTransaction(t,e){const r=te(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},i=e&&e.skipPreflight,s=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),i&&(r.skipPreflight=i),s&&(r.preflightCommitment=s);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),u=bt(a,FU);if("error"in u){let f;throw"data"in u.error&&(f=u.error.data.logs),new Eo({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:f})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var i;const r=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[r]||(s[r]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,s);this._setSubscription(r,{...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}),!e())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(i=>{try{i(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=bt(t,uU);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,i=xE([t.method,e]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[i];_e(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:i,config:s}=ze(r),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=bt(t,fU);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,i){const{commitment:s,config:o}=ze(r),a=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:TE(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=bt(t,HU);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=bt(t,dU);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=bt(t,gU);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,i){const s=e||this._commitment;if(s||r||i){let o={};r&&(o.encoding=r),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,i){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,i)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=bt(t,yU);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const i=this._buildArgs([t],r||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(t,e,r){const{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,s),a=this._makeSubscription({callback:(u,f)=>{e(u,f);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=bt(t,mU);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Ba{constructor(t){this._keypair=void 0,this._keypair=t??dE()}static generate(){return new Ba(dE())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const i=t.slice(0,32),s=h0(i);for(let o=0;o<32;o++)if(r[o]!==s[o])throw new Error("provided secretKey is invalid")}return new Ba({publicKey:r,secretKey:t})}static fromSeed(t){const e=h0(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Ba({publicKey:e,secretKey:r})}get publicKey(){return new pt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const ks=Object.freeze({CreateLookupTable:{index:0,layout:Nt([Ot("instruction"),hu("recentSlot"),me("bumpSeed")])},FreezeLookupTable:{index:1,layout:Nt([Ot("instruction")])},ExtendLookupTable:{index:2,layout:Nt([Ot("instruction"),hu(),jn(ce(),bo(Ot(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Nt([Ot("instruction")])},CloseLookupTable:{index:4,layout:Nt([Ot("instruction")])}});class GU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(ks))if(o.index==r){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=ke(ks.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=ke(ks.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(r=>new pt(r))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Wy.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class Wy{constructor(){}static createLookupTable(t){const[e,r]=pt.findProgramAddressSync([t.authority.toBuffer(),GA(BigInt(t.recentSlot),8)],this.programId),i=ks.CreateLookupTable,s=pe(i,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Cn.programId,isSigner:!1,isWritable:!1}];return[new Me({programId:this.programId,keys:o,data:s}),e]}static freezeLookupTable(t){const e=ks.FreezeLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Me({programId:this.programId,keys:i,data:r})}static extendLookupTable(t){const e=ks.ExtendLookupTable,r=pe(e,{addresses:t.addresses.map(s=>s.toBytes())}),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&i.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Cn.programId,isSigner:!1,isWritable:!1}),new Me({programId:this.programId,keys:i,data:r})}static deactivateLookupTable(t){const e=ks.DeactivateLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Me({programId:this.programId,keys:i,data:r})}static closeLookupTable(t){const e=ks.CloseLookupTable,r=pe(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Me({programId:this.programId,keys:i,data:r})}}Wy.programId=new pt("AddressLookupTab1e1111111111111111111111111");class VU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=me("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Zi))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=ke(Zi.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=ke(Zi.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=ke(Zi.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=ke(Zi.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Zy.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Zi=Object.freeze({RequestUnits:{index:0,layout:Nt([me("instruction"),Ot("units"),Ot("additionalFee")])},RequestHeapFrame:{index:1,layout:Nt([me("instruction"),Ot("bytes")])},SetComputeUnitLimit:{index:2,layout:Nt([me("instruction"),Ot("units")])},SetComputeUnitPrice:{index:3,layout:Nt([me("instruction"),hu("microLamports")])}});class Zy{constructor(){}static requestUnits(t){const e=Zi.RequestUnits,r=pe(e,t);return new Me({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Zi.RequestHeapFrame,r=pe(e,t);return new Me({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Zi.SetComputeUnitLimit,r=pe(e,t);return new Me({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Zi.SetComputeUnitPrice,r=pe(e,{microLamports:BigInt(t.microLamports)});return new Me({keys:[],programId:this.programId,data:r})}}Zy.programId=new pt("ComputeBudget111111111111111111111111111111");const GE=64,VE=32,KE=64,jE=Nt([me("numSignatures"),me("padding"),ti("signatureOffset"),ti("signatureInstructionIndex"),ti("publicKeyOffset"),ti("publicKeyInstructionIndex"),ti("messageDataOffset"),ti("messageDataSize"),ti("messageInstructionIndex")]);class E0{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:s}=t;_e(e.length===VE,`Public Key must be ${VE} bytes but received ${e.length} bytes`),_e(i.length===KE,`Signature must be ${KE} bytes but received ${i.length} bytes`);const o=jE.span,a=o+e.length,u=a+i.length,f=1,h=kt.alloc(u+r.length),y=s??65535;return jE.encode({numSignatures:f,padding:0,signatureOffset:a,signatureInstructionIndex:y,publicKeyOffset:o,publicKeyInstructionIndex:y,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:y},h),h.fill(e,o),h.fill(i,a),h.fill(r,u),new Me({keys:[],programId:E0.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;_e(e.length===GE,`Private key must be ${GE} bytes but received ${e.length} bytes`);try{const s=Ba.fromSecretKey(e),o=s.publicKey.toBytes(),a=Sy(r,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}E0.programId=new pt("Ed25519SigVerify111111111111111111111111111");const KU=(n,t)=>{const e=f0.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};f0.utils.isValidPrivateKey;const jU=f0.getPublicKey,WE=32,qy=20,ZE=64,WU=11,Qy=Nt([me("numSignatures"),ti("signatureOffset"),me("signatureInstructionIndex"),ti("ethAddressOffset"),me("ethAddressInstructionIndex"),ti("messageDataOffset"),ti("messageDataSize"),me("messageInstructionIndex"),We(20,"ethAddress"),We(64,"signature"),me("recoveryId")]);class pu{constructor(){}static publicKeyToEthAddress(t){_e(t.length===ZE,`Public key must be ${ZE} bytes but received ${t.length} bytes`);try{return kt.from(sE(te(t))).slice(-qy)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,recoveryId:s,instructionIndex:o}=t;return pu.createInstructionWithEthAddress({ethAddress:pu.publicKeyToEthAddress(e),message:r,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:s,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=kt.from(e.substr(2),"hex"):a=kt.from(e,"hex"):a=e,_e(a.length===qy,`Address must be ${qy} bytes but received ${a.length} bytes`);const u=1+WU,f=u,h=u+a.length,y=h+i.length+1,_=1,w=kt.alloc(Qy.span+r.length);return Qy.encode({numSignatures:_,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:f,ethAddressInstructionIndex:o,messageDataOffset:y,messageDataSize:r.length,messageInstructionIndex:o,signature:te(i),ethAddress:te(a),recoveryId:s},w),w.fill(te(r),Qy.span),new Me({keys:[],programId:pu.programId,data:w})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;_e(e.length===WE,`Private key must be ${WE} bytes but received ${e.length} bytes`);try{const s=te(e),o=jU(s,!1).slice(1),a=kt.from(sE(te(r))),[u,f]=KU(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,recoveryId:f,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}pu.programId=new pt("KeccakSecp256k11111111111111111111111111111");var qE;const QE=new pt("StakeConfig11111111111111111111111111111111");class YE{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Pf{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}qE=Pf,Pf.default=new qE(0,0,pt.default);class ZU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Ln))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=ke(Ln.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new YE(new pt(e.staker),new pt(e.withdrawer)),lockup:new Pf(r.unixTimestamp,r.epoch,new pt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),ke(Ln.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=ke(Ln.Authorize,t.data),i={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(i.custodianPubkey=t.keys[3].pubkey),i}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:i,authorityOwner:s}=ke(Ln.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:i,authorityOwner:new pt(s),newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=ke(Ln.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),ke(Ln.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=ke(Ln.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),ke(Ln.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(v0.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Ln=Object.freeze({Initialize:{index:0,layout:Nt([Ot("instruction"),eL(),nL()])},Authorize:{index:1,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("stakeAuthorizationType")])},Delegate:{index:2,layout:Nt([Ot("instruction")])},Split:{index:3,layout:Nt([Ot("instruction"),Fr("lamports")])},Withdraw:{index:4,layout:Nt([Ot("instruction"),Fr("lamports")])},Deactivate:{index:5,layout:Nt([Ot("instruction")])},Merge:{index:7,layout:Nt([Ot("instruction")])},AuthorizeWithSeed:{index:8,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("stakeAuthorizationType"),Sa("authoritySeed"),ce("authorityOwner")])}}),qU=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class v0{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:i}=t,s=i||Pf.default,o=Ln.Initialize,a=pe(o,{authorized:{staker:te(r.staker.toBuffer()),withdrawer:te(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:te(s.custodian.toBuffer())}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:fu,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Me(u)}static createAccountWithSeed(t){const e=new Ne;e.add(Cn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(t){const e=new Ne;e.add(Cn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:i}=t,s=Ln.Delegate,o=pe(s);return new Ne().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:y0,isSigner:!1,isWritable:!1},{pubkey:QE,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=t,a=Ln.Authorize,u=pe(a,{newAuthorized:te(i.toBuffer()),stakeAuthorizationType:s.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ne().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:u}=t,f=Ln.AuthorizeWithSeed,h=pe(f,{newAuthorized:te(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:te(s.toBuffer())}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1}];return u&&y.push({pubkey:u,isSigner:!0,isWritable:!1}),new Ne().add({keys:y,programId:this.programId,data:h})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=t,o=Ln.Split,a=pe(o,{lamports:s});return new Me({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new Ne;return r.add(Cn.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:a,lamports:u}=t,f=new Ne;return f.add(Cn.allocate({accountPubkey:s,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&f.add(Cn.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),f.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:i}=t,s=Ln.Merge,o=pe(s);return new Ne().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:y0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:o}=t,a=Ln.Withdraw,u=pe(a,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:y0,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Ne().add({keys:f,programId:this.programId,data:u})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,i=Ln.Deactivate,s=pe(i);return new Ne().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}v0.programId=new pt("Stake11111111111111111111111111111111111111"),v0.space=200;class JE{constructor(t,e,r,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=i}}class QU{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Ot("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(qi))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=ke(qi.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new JE(new pt(e.nodePubkey),new pt(e.authorizedVoter),new pt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=ke(qi.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:i,voteAuthorizationType:s}}=ke(qi.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new pt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new pt(i),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=ke(qi.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(gu.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const qi=Object.freeze({InitializeAccount:{index:0,layout:Nt([Ot("instruction"),rL()])},Authorize:{index:1,layout:Nt([Ot("instruction"),ce("newAuthorized"),Ot("voteAuthorizationType")])},Withdraw:{index:3,layout:Nt([Ot("instruction"),Fr("lamports")])},UpdateValidatorIdentity:{index:4,layout:Nt([Ot("instruction")])},AuthorizeWithSeed:{index:10,layout:Nt([Ot("instruction"),iL()])}}),YU=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class gu{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:i}=t,s=qi.InitializeAccount,o=pe(s,{voteInit:{nodePubkey:te(i.nodePubkey.toBuffer()),authorizedVoter:te(i.authorizedVoter.toBuffer()),authorizedWithdrawer:te(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:fu,isSigner:!1,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Me(a)}static createAccount(t){const e=new Ne;return e.add(Cn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:s}=t,o=qi.Authorize,a=pe(o,{newAuthorized:te(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Ne().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:a}=t,u=qi.AuthorizeWithSeed,f=pe(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:te(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:te(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Ne().add({keys:h,programId:this.programId,data:f})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=t,o=qi.Withdraw,a=pe(o,{lamports:i}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Ne().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return gu.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:i}=t,s=qi.UpdateValidatorIdentity,o=pe(s),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Ne().add({keys:a,programId:this.programId,data:o})}}gu.programId=new pt("Vote111111111111111111111111111111111111111"),gu.space=3762;const XE=new pt("Va1idator1nfo111111111111111111111111111111"),JU=ft({name:mt(),website:Dt(mt()),details:Dt(mt()),iconUrl:Dt(mt()),keybaseUsername:Dt(mt())});class Yy{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Rr(e)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new pt(Ir(e,0,Ki)),a=ji(e)===1;i.push({publicKey:o,isSigner:a})}if(i[0].publicKey.equals(XE)&&i[1].isSigner){const s=Sa().decode(kt.from(e)),o=JSON.parse(s);return KA(o,JU),new Yy(i[1].publicKey,o)}return null}}const XU=new pt("Vote111111111111111111111111111111111111111"),tD=Nt([ce("nodePubkey"),ce("authorizedWithdrawer"),me("commission"),Kn(),jn(Nt([Kn("slot"),Ot("confirmationCount")]),bo(Ot(),-8),"votes"),me("rootSlotValid"),Kn("rootSlot"),Kn(),jn(Nt([Kn("epoch"),ce("authorizedVoter")]),bo(Ot(),-8),"authorizedVoters"),Nt([jn(Nt([ce("authorizedPubkey"),Kn("epochOfLastAuthorizedSwitch"),Kn("targetEpoch")]),32,"buf"),Kn("idx"),me("isEmpty")],"priorVoters"),Kn(),jn(Nt([Kn("epoch"),Kn("credits"),Kn("prevCredits")]),bo(Ot(),-8),"epochCredits"),Nt([Kn("slot"),Kn("timestamp")],"lastTimestamp")]);class Jy{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const r=tD.decode(te(t),4);let i=r.rootSlot;return r.rootSlotValid||(i=null),new Jy({nodePubkey:new pt(r.nodePubkey),authorizedWithdrawer:new pt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:i,authorizedVoters:r.authorizedVoters.map(eD),priorVoters:nD(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function eD({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new pt(n)}}function tv({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new pt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function nD({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(tv),...n.slice(0,t).map(tv)]}const ev={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 rD(n,t){const e=t===!1?"http":"https";if(!n)return ev[e].devnet;const r=ev[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function iD(n,t,e,r){let i,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(i=e,s=r):s=e;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},a=await n.sendRawTransaction(t,o),u=s&&s.commitment,h=(await(i?n.confirmTransaction(i,u):n.confirmTransaction(a,u))).value;if(h.err)throw a!=null?new Eo({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 sD=Object.freeze(Object.defineProperty({__proto__:null,Account:JM,AddressLookupTableAccount:Dy,AddressLookupTableInstruction:GU,AddressLookupTableProgram:Wy,Authorized:YE,BLOCKHASH_CACHE_TIMEOUT_MS:kE,BPF_LOADER_DEPRECATED_PROGRAM_ID:XM,BPF_LOADER_PROGRAM_ID:gL,BpfLoader:yL,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Zi,ComputeBudgetInstruction:VU,ComputeBudgetProgram:Zy,Connection:zE,Ed25519Program:E0,Enum:QM,EpochSchedule:RE,FeeCalculatorLayout:AE,Keypair:Ba,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:ks,Loader:Oa,Lockup:Pf,MAX_SEED_LENGTH:yE,Message:Ai,MessageAccountKeys:Nf,MessageV0:ka,NONCE_ACCOUNT_LENGTH:My,NonceAccount:m0,PACKET_DATA_SIZE:Ao,PUBLIC_KEY_LENGTH:Ki,PublicKey:pt,SIGNATURE_LENGTH_IN_BYTES:Of,SOLANA_SCHEMA:Tf,STAKE_CONFIG_ID:QE,STAKE_INSTRUCTION_LAYOUTS:Ln,SYSTEM_INSTRUCTION_LAYOUTS:He,SYSVAR_CLOCK_PUBKEY:Wi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:oL,SYSVAR_INSTRUCTIONS_PUBKEY:aL,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:g0,SYSVAR_RENT_PUBKEY:fu,SYSVAR_REWARDS_PUBKEY:cL,SYSVAR_SLOT_HASHES_PUBKEY:uL,SYSVAR_SLOT_HISTORY_PUBKEY:lL,SYSVAR_STAKE_HISTORY_PUBKEY:y0,Secp256k1Program:pu,SendTransactionError:Eo,SolanaJSONRPCError:Mt,SolanaJSONRPCErrorCode:fL,StakeAuthorizationLayout:qU,StakeInstruction:ZU,StakeProgram:v0,Struct:ky,SystemInstruction:dL,SystemProgram:Cn,Transaction:Ne,TransactionExpiredBlockheightExceededError:Ty,TransactionExpiredNonceInvalidError:lu,TransactionExpiredTimeoutError:Oy,TransactionInstruction:Me,TransactionMessage:Cy,TransactionStatus:Ss,VALIDATOR_INFO_KEY:XE,VERSION_PREFIX_MASK:d0,VOTE_PROGRAM_ID:XU,ValidatorInfo:Yy,VersionedMessage:Ny,VersionedTransaction:By,VoteAccount:Jy,VoteAuthorizationLayout:YU,VoteInit:JE,VoteInstruction:QU,VoteProgram:gu,clusterApiUrl:rD,sendAndConfirmRawTransaction:iD,sendAndConfirmTransaction:Py},Symbol.toStringTag,{value:"Module"}));var Xy={exports:{}};const oD=/[\p{Lu}]/u,aD=/[\p{Ll}]/u,nv=/^[\p{Lu}](?![\p{Lu}])/gu,rv=/([\p{Alpha}\p{N}_]|$)/u,iv=/[_.\- ]+/,cD=new RegExp("^"+iv.source),sv=new RegExp(iv.source+rv.source,"gu"),ov=new RegExp("\\d+"+rv.source,"gu"),uD=(n,t,e)=>{let r=!1,i=!1,s=!1;for(let o=0;o<n.length;o++){const a=n[o];r&&oD.test(a)?(n=n.slice(0,o)+"-"+n.slice(o),r=!1,s=i,i=!0,o++):i&&s&&aD.test(a)?(n=n.slice(0,o-1)+"-"+n.slice(o-1),s=i,i=!1,r=!0):(r=t(a)===a&&e(a)!==a,s=i,i=e(a)===a&&t(a)!==a)}return n},lD=(n,t)=>(nv.lastIndex=0,n.replace(nv,e=>t(e))),fD=(n,t)=>(sv.lastIndex=0,ov.lastIndex=0,n.replace(sv,(e,r)=>t(r)).replace(ov,e=>t(e))),av=(n,t)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";const e=t.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(t.locale),r=t.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(t.locale);return n.length===1?t.pascalCase?r(n):e(n):(n!==e(n)&&(n=uD(n,e,r)),n=n.replace(cD,""),t.preserveConsecutiveUppercase?n=lD(n,e):n=e(n),t.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),fD(n,r))};Xy.exports=av,Xy.exports.default=av;var hD=Xy.exports;const dD=Mr(hD);var Yt={},Rt={};let Ce=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};Rt.Layout=Ce;function tm(n,t){return t.property?n+"["+t.property+"]":n}Rt.nameWithProperty=tm;function pD(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(n.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Ce))throw new TypeError("layout must be a Layout");if(t.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value:function(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value:function(e,r){return t.decode(e,r)},writable:!0})}Rt.bindConstructorLayout=pD;let Sr=class extends Ce{isCount(){throw new Error("ExternalLayout is abstract")}};class cv extends Sr{constructor(t,e){if(t===void 0&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){e===void 0&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}let em=class extends Sr{constructor(t,e,r){if(!(t instanceof Ce))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Qi||this.layout instanceof Ts}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}},Qi=class extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}},Ts=class extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}};class Pa extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class yu extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const nm=Math.pow(2,32);function x0(n){const t=Math.floor(n/nm),e=n-t*nm;return{hi32:t,lo32:e}}function R0(n,t){return n*nm+t}let gD=class extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return R0(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=x0(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}};class yD extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return R0(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=x0(t);return e.writeUInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}let mD=class extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return R0(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=x0(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}};class wD extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readInt32BE(e),i=t.readUInt32BE(e+4);return R0(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=x0(t);return e.writeInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}class uv extends Ce{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatLE(t,r),4}}class lv extends Ce{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatBE(t,r),4}}class fv extends Ce{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleLE(t,r),8}}class hv extends Ce{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleBE(t,r),8}}class dv extends Ce{constructor(t,e,r){if(!(t instanceof Ce))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Sr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Sr)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0,i=this.count;if(i instanceof Sr&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e){e===void 0&&(e=0);const r=[];let i=0,s=this.count;for(s instanceof Sr&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r){r===void 0&&(r=0);const i=this.elementLayout,s=t.reduce((o,a)=>o+i.encode(a,e,r+o),0);return this.count instanceof Sr&&this.count.encode(t.length,e,r),s}}let pv=class extends Ce{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ce,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}},rm=class{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},I0=class extends rm{constructor(t,e){if(!(t instanceof Sr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}},im=class extends Ce{constructor(t,e,r){const i=t instanceof Qi||t instanceof Ts;if(i)t=new I0(new em(t));else if(t instanceof Sr&&t.isCount())t=new I0(t);else if(!(t instanceof rm))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ce))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+a)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new gv(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}},gv=class extends Ce{constructor(t,e,r,i){if(!(t instanceof im))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ce))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};function mu(n){return 0>n&&(n+=4294967296),n}class sm extends Ce{constructor(t,e,r){if(!(t instanceof Qi||t instanceof Ts))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=mu(s),this},this._packedGetValue=function(){return i}}decode(t,e){const r=this.makeDestinationObject();e===void 0&&(e=0);const i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(i));return r}encode(t,e,r){r===void 0&&(r=0);const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Mf(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new yv(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class Mf{constructor(t,e,r){if(!(t instanceof sm))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,a)=>o+a.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=mu(this.valueMask<<this.start),this.property=r}decode(){const t=this.container._packedGetValue();return mu(t&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==mu(t&this.valueMask))throw new TypeError(tm("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=mu(t<<this.start);this.container._packedSetValue(mu(e&~this.wordMask)|r)}}let yv=class extends Mf{constructor(t,e){super(t,1,e)}decode(t,e){return!!Mf.prototype.decode.call(this,t,e)}encode(t){return typeof t=="boolean"&&(t=+t),Mf.prototype.encode.call(this,t)}},mv=class extends Ce{constructor(t,e){if(!(t instanceof Sr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Sr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Sr&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(tm("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Sr&&this.length.encode(i,e,r),i}};class wv extends Ce{constructor(t){super(-1,t)}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");e===void 0&&(e=0);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);return t.slice(e,e+i-1).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),e[r+s]=0,s+1}}class bv extends Ce{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");return e===void 0&&(e=0),t.length-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+i).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),s}}class _v extends Ce{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}Rt.ExternalLayout=Sr,Rt.GreedyCount=cv,Rt.OffsetLayout=em,Rt.UInt=Qi,Rt.UIntBE=Ts,Rt.Int=Pa,Rt.IntBE=yu,Rt.Float=uv,Rt.FloatBE=lv,Rt.Double=fv,Rt.DoubleBE=hv,Rt.Sequence=dv,Rt.Structure=pv,Rt.UnionDiscriminator=rm,Rt.UnionLayoutDiscriminator=I0,Rt.Union=im,Rt.VariantLayout=gv,Rt.BitStructure=sm,Rt.BitField=Mf,Rt.Boolean=yv,Rt.Blob=mv,Rt.CString=wv,Rt.UTF8=bv,Rt.Constant=_v,Rt.greedy=(n,t)=>new cv(n,t),Rt.offset=(n,t,e)=>new em(n,t,e),Rt.u8=n=>new Qi(1,n),Rt.u16=n=>new Qi(2,n),Rt.u24=n=>new Qi(3,n),Rt.u32=n=>new Qi(4,n),Rt.u40=n=>new Qi(5,n),Rt.u48=n=>new Qi(6,n),Rt.nu64=n=>new gD(n),Rt.u16be=n=>new Ts(2,n),Rt.u24be=n=>new Ts(3,n),Rt.u32be=n=>new Ts(4,n),Rt.u40be=n=>new Ts(5,n),Rt.u48be=n=>new Ts(6,n),Rt.nu64be=n=>new yD(n),Rt.s8=n=>new Pa(1,n),Rt.s16=n=>new Pa(2,n),Rt.s24=n=>new Pa(3,n),Rt.s32=n=>new Pa(4,n),Rt.s40=n=>new Pa(5,n),Rt.s48=n=>new Pa(6,n),Rt.ns64=n=>new mD(n),Rt.s16be=n=>new yu(2,n),Rt.s24be=n=>new yu(3,n),Rt.s32be=n=>new yu(4,n),Rt.s40be=n=>new yu(5,n),Rt.s48be=n=>new yu(6,n),Rt.ns64be=n=>new wD(n),Rt.f32=n=>new uv(n),Rt.f32be=n=>new lv(n),Rt.f64=n=>new fv(n),Rt.f64be=n=>new hv(n),Rt.struct=(n,t,e)=>new pv(n,t,e),Rt.bits=(n,t,e)=>new sm(n,t,e),Rt.seq=(n,t,e)=>new dv(n,t,e),Rt.union=(n,t,e)=>new im(n,t,e),Rt.unionLayoutDiscriminator=(n,t)=>new I0(n,t),Rt.blob=(n,t)=>new mv(n,t),Rt.cstr=n=>new wv(n),Rt.utf8=(n,t)=>new bv(n,t),Rt.const=(n,t)=>new _v(n,t);const bD=Lc(sD);(function(n){var t=ae&&ae.__importDefault||function(ot){return ot&&ot.__esModule?ot:{default:ot}};Object.defineProperty(n,"__esModule",{value:!0}),n.struct=n.f64=n.f32=n.i32=n.u32=n.i16=n.u16=n.i8=n.u8=void 0,n.u64=a,n.i64=u,n.u128=f,n.i128=h,n.u256=y,n.i256=_,n.publicKey=R,n.option=I,n.bool=B,n.vec=G,n.tagged=W,n.vecU8=X,n.str=j,n.rustEnum=J,n.array=it,n.map=rt;const e=Rt,r=bD,i=t($g);var s=Rt;Object.defineProperty(n,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(n,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(n,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(n,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(n,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(n,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(n,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(n,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(n,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends e.Layout{constructor(C,p,m){super(C,m),this.blob=(0,e.blob)(C),this.signed=p}decode(C,p=0){const m=new i.default(this.blob.decode(C,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(C,p,m=0){return this.signed&&(C=C.toTwos(this.span*8)),this.blob.encode(C.toArrayLike(Zt,"le",this.span),p,m)}}function a(ot){return new o(8,!1,ot)}function u(ot){return new o(8,!0,ot)}function f(ot){return new o(16,!1,ot)}function h(ot){return new o(16,!0,ot)}function y(ot){return new o(32,!1,ot)}function _(ot){return new o(32,!0,ot)}class w extends e.Layout{constructor(C,p,m,v){super(C.span,v),this.layout=C,this.decoder=p,this.encoder=m}decode(C,p){return this.decoder(this.layout.decode(C,p))}encode(C,p,m){return this.layout.encode(this.encoder(C),p,m)}getSpan(C,p){return this.layout.getSpan(C,p)}}function R(ot){return new w((0,e.blob)(32),C=>new r.PublicKey(C),C=>C.toBuffer(),ot)}class T extends e.Layout{constructor(C,p){super(-1,p),this.layout=C,this.discriminator=(0,e.u8)()}encode(C,p,m=0){return C==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(C,p,m+1)+1)}decode(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return null;if(m===1)return this.layout.decode(C,p+1);throw new Error("Invalid option "+this.property)}getSpan(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(C,p+1)+1;throw new Error("Invalid option "+this.property)}}function I(ot,C){return new T(ot,C)}function B(ot){return new w((0,e.u8)(),H,U,ot)}function H(ot){if(ot===0)return!1;if(ot===1)return!0;throw new Error("Invalid bool: "+ot)}function U(ot){return ot?1:0}function G(ot,C){const p=(0,e.u32)("length"),m=(0,e.struct)([p,(0,e.seq)(ot,(0,e.offset)(p,-p.span),"values")]);return new w(m,({values:v})=>v,v=>({values:v}),C)}function W(ot,C,p){const m=(0,e.struct)([a("tag"),C.replicate("data")]);function v({tag:k,data:N}){if(!k.eq(ot))throw new Error("Invalid tag, expected: "+ot.toString("hex")+", got: "+k.toString("hex"));return N}return new w(m,v,k=>({tag:ot,data:k}),p)}function X(ot){const C=(0,e.u32)("length"),p=(0,e.struct)([C,(0,e.blob)((0,e.offset)(C,-C.span),"data")]);return new w(p,({data:m})=>m,m=>({data:m}),ot)}function j(ot){return new w(X(),C=>C.toString("utf-8"),C=>Zt.from(C,"utf-8"),ot)}function J(ot,C,p){const m=(0,e.union)(p??(0,e.u8)(),C);return ot.forEach((v,k)=>m.addVariant(k,v,v.property)),m}function it(ot,C,p){const m=(0,e.struct)([(0,e.seq)(ot,C,"values")]);return new w(m,({values:v})=>v,v=>({values:v}),p)}class ut extends e.Layout{constructor(C,p,m){super(C.span+p.span,m),this.keyLayout=C,this.valueLayout=p}decode(C,p){p=p||0;const m=this.keyLayout.decode(C,p),v=this.valueLayout.decode(C,p+this.keyLayout.getSpan(C,p));return[m,v]}encode(C,p,m){m=m||0;const v=this.keyLayout.encode(C[0],p,m),k=this.valueLayout.encode(C[1],p,m+v);return v+k}getSpan(C,p){return this.keyLayout.getSpan(C,p)+this.valueLayout.getSpan(C,p)}}function rt(ot,C,p){const m=(0,e.u32)("length"),v=(0,e.struct)([m,(0,e.seq)(new ut(ot,C),(0,e.offset)(m,-m.span),"values")]);return new w(v,({values:k})=>new Map(k),k=>({values:Array.from(k.entries())}),p)}})(Yt);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const _D=4,Av=0,Ev=1,AD=2;function wu(n){let t=n.length;for(;--t>=0;)n[t]=0}const ED=0,vv=1,vD=2,xD=3,RD=258,om=29,Lf=256,Uf=Lf+1+om,bu=30,am=19,xv=2*Uf+1,Ma=15,cm=16,ID=7,um=256,Rv=16,Iv=17,Sv=18,lm=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]),S0=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]),SD=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),kv=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kD=512,Os=new Array((Uf+2)*2);wu(Os);const Df=new Array(bu*2);wu(Df);const Ff=new Array(kD);wu(Ff);const $f=new Array(RD-xD+1);wu($f);const fm=new Array(om);wu(fm);const k0=new Array(bu);wu(k0);function hm(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let Tv,Ov,Nv;function dm(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const Cv=n=>n<256?Ff[n]:Ff[256+(n>>>7)],Hf=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},kr=(n,t,e)=>{n.bi_valid>cm-e?(n.bi_buf|=t<<n.bi_valid&65535,Hf(n,n.bi_buf),n.bi_buf=t>>cm-n.bi_valid,n.bi_valid+=e-cm):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},Yi=(n,t,e)=>{kr(n,e[t*2],e[t*2+1])},Bv=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},TD=n=>{n.bi_valid===16?(Hf(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},OD=(n,t)=>{const e=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,u=t.stat_desc.max_length;let f,h,y,_,w,R,T=0;for(_=0;_<=Ma;_++)n.bl_count[_]=0;for(e[n.heap[n.heap_max]*2+1]=0,f=n.heap_max+1;f<xv;f++)h=n.heap[f],_=e[e[h*2+1]*2+1]+1,_>u&&(_=u,T++),e[h*2+1]=_,!(h>r)&&(n.bl_count[_]++,w=0,h>=a&&(w=o[h-a]),R=e[h*2],n.opt_len+=R*(_+w),s&&(n.static_len+=R*(i[h*2+1]+w)));if(T!==0){do{for(_=u-1;n.bl_count[_]===0;)_--;n.bl_count[_]--,n.bl_count[_+1]+=2,n.bl_count[u]--,T-=2}while(T>0);for(_=u;_!==0;_--)for(h=n.bl_count[_];h!==0;)y=n.heap[--f],!(y>r)&&(e[y*2+1]!==_&&(n.opt_len+=(_-e[y*2+1])*e[y*2],e[y*2+1]=_),h--)}},Pv=(n,t,e)=>{const r=new Array(Ma+1);let i=0,s,o;for(s=1;s<=Ma;s++)i=i+e[s-1]<<1,r[s]=i;for(o=0;o<=t;o++){let a=n[o*2+1];a!==0&&(n[o*2]=Bv(r[a]++,a))}},ND=()=>{let n,t,e,r,i;const s=new Array(Ma+1);for(e=0,r=0;r<om-1;r++)for(fm[r]=e,n=0;n<1<<lm[r];n++)$f[e++]=r;for($f[e-1]=r,i=0,r=0;r<16;r++)for(k0[r]=i,n=0;n<1<<S0[r];n++)Ff[i++]=r;for(i>>=7;r<bu;r++)for(k0[r]=i<<7,n=0;n<1<<S0[r]-7;n++)Ff[256+i++]=r;for(t=0;t<=Ma;t++)s[t]=0;for(n=0;n<=143;)Os[n*2+1]=8,n++,s[8]++;for(;n<=255;)Os[n*2+1]=9,n++,s[9]++;for(;n<=279;)Os[n*2+1]=7,n++,s[7]++;for(;n<=287;)Os[n*2+1]=8,n++,s[8]++;for(Pv(Os,Uf+1,s),n=0;n<bu;n++)Df[n*2+1]=5,Df[n*2]=Bv(n,5);Tv=new hm(Os,lm,Lf+1,Uf,Ma),Ov=new hm(Df,S0,0,bu,Ma),Nv=new hm(new Array(0),SD,0,am,ID)},Mv=n=>{let t;for(t=0;t<Uf;t++)n.dyn_ltree[t*2]=0;for(t=0;t<bu;t++)n.dyn_dtree[t*2]=0;for(t=0;t<am;t++)n.bl_tree[t*2]=0;n.dyn_ltree[um*2]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},Lv=n=>{n.bi_valid>8?Hf(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},Uv=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]<n[s]||n[i]===n[s]&&r[t]<=r[e]},pm=(n,t,e)=>{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i<n.heap_len&&Uv(t,n.heap[i+1],n.heap[i],n.depth)&&i++,!Uv(t,r,n.heap[i],n.depth));)n.heap[e]=n.heap[i],e=i,i<<=1;n.heap[e]=r},Dv=(n,t,e)=>{let r,i,s=0,o,a;if(n.sym_next!==0)do r=n.pending_buf[n.sym_buf+s++]&255,r+=(n.pending_buf[n.sym_buf+s++]&255)<<8,i=n.pending_buf[n.sym_buf+s++],r===0?Yi(n,i,t):(o=$f[i],Yi(n,o+Lf+1,t),a=lm[o],a!==0&&(i-=fm[o],kr(n,i,a)),r--,o=Cv(r),Yi(n,o,e),a=S0[o],a!==0&&(r-=k0[o],kr(n,r,a)));while(s<n.sym_next);Yi(n,um,t)},gm=(n,t)=>{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,u=-1,f;for(n.heap_len=0,n.heap_max=xv,o=0;o<s;o++)e[o*2]!==0?(n.heap[++n.heap_len]=u=o,n.depth[o]=0):e[o*2+1]=0;for(;n.heap_len<2;)f=n.heap[++n.heap_len]=u<2?++u:0,e[f*2]=1,n.depth[f]=0,n.opt_len--,i&&(n.static_len-=r[f*2+1]);for(t.max_code=u,o=n.heap_len>>1;o>=1;o--)pm(n,e,o);f=s;do o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],pm(n,e,1),a=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=a,e[f*2]=e[o*2]+e[a*2],n.depth[f]=(n.depth[o]>=n.depth[a]?n.depth[o]:n.depth[a])+1,e[o*2+1]=e[a*2+1]=f,n.heap[1]=f++,pm(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],OD(n,t),Pv(e,u,n.bl_count)},Fv=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],a=0,u=7,f=4;for(o===0&&(u=138,f=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=o,o=t[(r+1)*2+1],!(++a<u&&s===o)&&(a<f?n.bl_tree[s*2]+=a:s!==0?(s!==i&&n.bl_tree[s*2]++,n.bl_tree[Rv*2]++):a<=10?n.bl_tree[Iv*2]++:n.bl_tree[Sv*2]++,a=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4))},$v=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],a=0,u=7,f=4;for(o===0&&(u=138,f=3),r=0;r<=e;r++)if(s=o,o=t[(r+1)*2+1],!(++a<u&&s===o)){if(a<f)do Yi(n,s,n.bl_tree);while(--a!==0);else s!==0?(s!==i&&(Yi(n,s,n.bl_tree),a--),Yi(n,Rv,n.bl_tree),kr(n,a-3,2)):a<=10?(Yi(n,Iv,n.bl_tree),kr(n,a-3,3)):(Yi(n,Sv,n.bl_tree),kr(n,a-11,7));a=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4)}},CD=n=>{let t;for(Fv(n,n.dyn_ltree,n.l_desc.max_code),Fv(n,n.dyn_dtree,n.d_desc.max_code),gm(n,n.bl_desc),t=am-1;t>=3&&n.bl_tree[kv[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},BD=(n,t,e,r)=>{let i;for(kr(n,t-257,5),kr(n,e-1,5),kr(n,r-4,4),i=0;i<r;i++)kr(n,n.bl_tree[kv[i]*2+1],3);$v(n,n.dyn_ltree,t-1),$v(n,n.dyn_dtree,e-1)},PD=n=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return Av;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return Ev;for(e=32;e<Lf;e++)if(n.dyn_ltree[e*2]!==0)return Ev;return Av};let Hv=!1;const MD=n=>{Hv||(ND(),Hv=!0),n.l_desc=new dm(n.dyn_ltree,Tv),n.d_desc=new dm(n.dyn_dtree,Ov),n.bl_desc=new dm(n.bl_tree,Nv),n.bi_buf=0,n.bi_valid=0,Mv(n)},zv=(n,t,e,r)=>{kr(n,(ED<<1)+(r?1:0),3),Lv(n),Hf(n,e),Hf(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},LD=n=>{kr(n,vv<<1,3),Yi(n,um,Os),TD(n)},UD=(n,t,e,r)=>{let i,s,o=0;n.level>0?(n.strm.data_type===AD&&(n.strm.data_type=PD(n)),gm(n,n.l_desc),gm(n,n.d_desc),o=CD(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?zv(n,t,e,r):n.strategy===_D||s===i?(kr(n,(vv<<1)+(r?1:0),3),Dv(n,Os,Df)):(kr(n,(vD<<1)+(r?1:0),3),BD(n,n.l_desc.max_code+1,n.d_desc.max_code+1,o+1),Dv(n,n.dyn_ltree,n.dyn_dtree)),Mv(n),r&&Lv(n)},DD=(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[($f[e]+Lf+1)*2]++,n.dyn_dtree[Cv(t)*2]++),n.sym_next===n.sym_end);var FD=MD,$D=zv,HD=UD,zD=DD,GD=LD,VD={_tr_init:FD,_tr_stored_block:$D,_tr_flush_block:HD,_tr_tally:zD,_tr_align:GD},zf=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,o=0;for(;e!==0;){o=e>2e3?2e3:e,e-=o;do i=i+t[r++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};const KD=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},jD=new Uint32Array(KD());var Un=(n,t,e,r)=>{const i=jD,s=r+e;n^=-1;for(let o=r;o<s;o++)n=n>>>8^i[(n^t[o])&255];return n^-1},_u={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"},Gf={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:WD,_tr_stored_block:ym,_tr_flush_block:ZD,_tr_tally:vo,_tr_align:qD}=VD,{Z_NO_FLUSH:xo,Z_PARTIAL_FLUSH:QD,Z_FULL_FLUSH:YD,Z_FINISH:ei,Z_BLOCK:Gv,Z_OK:Zn,Z_STREAM_END:Vv,Z_STREAM_ERROR:Ji,Z_DATA_ERROR:JD,Z_BUF_ERROR:mm,Z_DEFAULT_COMPRESSION:XD,Z_FILTERED:t9,Z_HUFFMAN_ONLY:T0,Z_RLE:e9,Z_FIXED:n9,Z_DEFAULT_STRATEGY:r9,Z_UNKNOWN:i9,Z_DEFLATED:O0}=Gf,s9=9,o9=15,a9=8,wm=256+1+29,c9=30,u9=19,l9=2*wm+1,f9=15,le=3,Ro=258,Xi=Ro+le+1,h9=32,Au=42,bm=57,_m=69,Am=73,Em=91,vm=103,La=113,Vf=666,pr=1,Eu=2,Ua=3,vu=4,d9=3,Da=(n,t)=>(n.msg=_u[t],t),Kv=n=>n*2-(n>4?9:0),Io=n=>{let t=n.length;for(;--t>=0;)n[t]=0},p9=n=>{let t,e,r,i=n.w_size;t=n.hash_size,r=t;do e=n.head[--r],n.head[r]=e>=i?e-i:0;while(--t);t=i,r=t;do e=n.prev[--r],n.prev[r]=e>=i?e-i:0;while(--t)};let So=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask;const Hr=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},zr=(n,t)=>{ZD(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Hr(n.strm)},xe=(n,t)=>{n.pending_buf[n.pending++]=t},Kf=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},xm=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=zf(n.adler,t,i,e):n.state.wrap===2&&(n.adler=Un(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},jv=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,o=n.prev_length,a=n.nice_match;const u=n.strstart>n.w_size-Xi?n.strstart-(n.w_size-Xi):0,f=n.window,h=n.w_mask,y=n.prev,_=n.strstart+Ro;let w=f[r+o-1],R=f[r+o];n.prev_length>=n.good_match&&(e>>=2),a>n.lookahead&&(a=n.lookahead);do if(i=t,!(f[i+o]!==R||f[i+o-1]!==w||f[i]!==f[r]||f[++i]!==f[r+1])){r+=2,i++;do;while(f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&r<_);if(s=Ro-(_-r),r=_-Ro,s>o){if(n.match_start=t,o=s,s>=a)break;w=f[r+o-1],R=f[r+o]}}while((t=y[t&h])>u&&--e!==0);return o<=n.lookahead?o:n.lookahead},xu=n=>{const t=n.w_size;let e,r,i;do{if(r=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-Xi)&&(n.window.set(n.window.subarray(t,t+t-r),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),p9(n),r+=t),n.strm.avail_in===0)break;if(e=xm(n.strm,n.window,n.strstart+n.lookahead,r),n.lookahead+=e,n.lookahead+n.insert>=le)for(i=n.strstart-n.insert,n.ins_h=n.window[i],n.ins_h=So(n,n.ins_h,n.window[i+1]);n.insert&&(n.ins_h=So(n,n.ins_h,n.window[i+le-1]),n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,n.insert--,!(n.lookahead+n.insert<le)););}while(n.lookahead<Xi&&n.strm.avail_in!==0)},Wv=(n,t)=>{let e=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,r,i,s,o=0,a=n.strm.avail_in;do{if(r=65535,s=n.bi_valid+42>>3,n.strm.avail_out<s||(s=n.strm.avail_out-s,i=n.strstart-n.block_start,r>i+n.strm.avail_in&&(r=i+n.strm.avail_in),r>s&&(r=s),r<e&&(r===0&&t!==ei||t===xo||r!==i+n.strm.avail_in)))break;o=t===ei&&r===i+n.strm.avail_in?1:0,ym(n,0,0,o),n.pending_buf[n.pending-4]=r,n.pending_buf[n.pending-3]=r>>8,n.pending_buf[n.pending-2]=~r,n.pending_buf[n.pending-1]=~r>>8,Hr(n.strm),i&&(i>r&&(i=r),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+i),n.strm.next_out),n.strm.next_out+=i,n.strm.avail_out-=i,n.strm.total_out+=i,n.block_start+=i,r-=i),r&&(xm(n.strm,n.strm.output,n.strm.next_out,r),n.strm.next_out+=r,n.strm.avail_out-=r,n.strm.total_out+=r)}while(o===0);return a-=n.strm.avail_in,a&&(a>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=a&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-a,n.strm.next_in),n.strstart),n.strstart+=a,n.insert+=a>n.w_size-n.insert?n.w_size-n.insert:a),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),o?vu:t!==xo&&t!==ei&&n.strm.avail_in===0&&n.strstart===n.block_start?Eu:(s=n.window_size-n.strstart,n.strm.avail_in>s&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,s+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),s>n.strm.avail_in&&(s=n.strm.avail_in),s&&(xm(n.strm,n.window,n.strstart,s),n.strstart+=s,n.insert+=s>n.w_size-n.insert?n.w_size-n.insert:s),n.high_water<n.strstart&&(n.high_water=n.strstart),s=n.bi_valid+42>>3,s=n.pending_buf_size-s>65535?65535:n.pending_buf_size-s,e=s>n.w_size?n.w_size:s,i=n.strstart-n.block_start,(i>=e||(i||t===ei)&&t!==xo&&n.strm.avail_in===0&&i<=s)&&(r=i>s?s:i,o=t===ei&&n.strm.avail_in===0&&r===i?1:0,ym(n,n.block_start,r,o),n.block_start+=r,Hr(n.strm)),o?Ua:pr)},Rm=(n,t)=>{let e,r;for(;;){if(n.lookahead<Xi){if(xu(n),n.lookahead<Xi&&t===xo)return pr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=So(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-Xi&&(n.match_length=jv(n,e)),n.match_length>=le)if(r=vo(n,n.strstart-n.match_start,n.match_length-le),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=le){n.match_length--;do n.strstart++,n.ins_h=So(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=So(n,n.ins_h,n.window[n.strstart+1]);else r=vo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(zr(n,!1),n.strm.avail_out===0))return pr}return n.insert=n.strstart<le-1?n.strstart:le-1,t===ei?(zr(n,!0),n.strm.avail_out===0?Ua:vu):n.sym_next&&(zr(n,!1),n.strm.avail_out===0)?pr:Eu},Ru=(n,t)=>{let e,r,i;for(;;){if(n.lookahead<Xi){if(xu(n),n.lookahead<Xi&&t===xo)return pr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=So(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=le-1,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-Xi&&(n.match_length=jv(n,e),n.match_length<=5&&(n.strategy===t9||n.match_length===le&&n.strstart-n.match_start>4096)&&(n.match_length=le-1)),n.prev_length>=le&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-le,r=vo(n,n.strstart-1-n.prev_match,n.prev_length-le),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=So(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=le-1,n.strstart++,r&&(zr(n,!1),n.strm.avail_out===0))return pr}else if(n.match_available){if(r=vo(n,0,n.window[n.strstart-1]),r&&zr(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return pr}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=vo(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<le-1?n.strstart:le-1,t===ei?(zr(n,!0),n.strm.avail_out===0?Ua:vu):n.sym_next&&(zr(n,!1),n.strm.avail_out===0)?pr:Eu},g9=(n,t)=>{let e,r,i,s;const o=n.window;for(;;){if(n.lookahead<=Ro){if(xu(n),n.lookahead<=Ro&&t===xo)return pr;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=le&&n.strstart>0&&(i=n.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){s=n.strstart+Ro;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<s);n.match_length=Ro-(s-i),n.match_length>n.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=le?(e=vo(n,1,n.match_length-le),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=vo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(zr(n,!1),n.strm.avail_out===0))return pr}return n.insert=0,t===ei?(zr(n,!0),n.strm.avail_out===0?Ua:vu):n.sym_next&&(zr(n,!1),n.strm.avail_out===0)?pr:Eu},y9=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(xu(n),n.lookahead===0)){if(t===xo)return pr;break}if(n.match_length=0,e=vo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(zr(n,!1),n.strm.avail_out===0))return pr}return n.insert=0,t===ei?(zr(n,!0),n.strm.avail_out===0?Ua:vu):n.sym_next&&(zr(n,!1),n.strm.avail_out===0)?pr:Eu};function ts(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const jf=[new ts(0,0,0,0,Wv),new ts(4,4,8,4,Rm),new ts(4,5,16,8,Rm),new ts(4,6,32,32,Rm),new ts(4,4,16,16,Ru),new ts(8,16,32,32,Ru),new ts(8,16,128,128,Ru),new ts(8,32,128,256,Ru),new ts(32,128,258,1024,Ru),new ts(32,258,258,4096,Ru)],m9=n=>{n.window_size=2*n.w_size,Io(n.head),n.max_lazy_match=jf[n.level].max_lazy,n.good_match=jf[n.level].good_length,n.nice_match=jf[n.level].nice_length,n.max_chain_length=jf[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=le-1,n.match_available=0,n.ins_h=0};function w9(){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=O0,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(l9*2),this.dyn_dtree=new Uint16Array((2*c9+1)*2),this.bl_tree=new Uint16Array((2*u9+1)*2),Io(this.dyn_ltree),Io(this.dyn_dtree),Io(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(f9+1),this.heap=new Uint16Array(2*wm+1),Io(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*wm+1),Io(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 Wf=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==Au&&t.status!==bm&&t.status!==_m&&t.status!==Am&&t.status!==Em&&t.status!==vm&&t.status!==La&&t.status!==Vf?1:0},Zv=n=>{if(Wf(n))return Da(n,Ji);n.total_in=n.total_out=0,n.data_type=i9;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?bm:t.wrap?Au:La,n.adler=t.wrap===2?0:1,t.last_flush=-2,WD(t),Zn},qv=n=>{const t=Zv(n);return t===Zn&&m9(n.state),t},b9=(n,t)=>Wf(n)||n.state.wrap!==2?Ji:(n.state.gzhead=t,Zn),Qv=(n,t,e,r,i,s)=>{if(!n)return Ji;let o=1;if(t===XD&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>s9||e!==O0||r<8||r>15||t<0||t>9||s<0||s>n9||r===8&&o!==1)return Da(n,Ji);r===8&&(r=9);const a=new w9;return n.state=a,a.strm=n,a.status=Au,a.wrap=o,a.gzhead=null,a.w_bits=r,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+le-1)/le),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=t,a.strategy=s,a.method=e,qv(n)},_9=(n,t)=>Qv(n,t,O0,o9,a9,r9),A9=(n,t)=>{if(Wf(n)||t>Gv||t<0)return n?Da(n,Ji):Ji;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===Vf&&t!==ei)return Da(n,n.avail_out===0?mm:Ji);const r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Hr(n),n.avail_out===0)return e.last_flush=-1,Zn}else if(n.avail_in===0&&Kv(t)<=Kv(r)&&t!==ei)return Da(n,mm);if(e.status===Vf&&n.avail_in!==0)return Da(n,mm);if(e.status===Au&&e.wrap===0&&(e.status=La),e.status===Au){let i=O0+(e.w_bits-8<<4)<<8,s=-1;if(e.strategy>=T0||e.level<2?s=0:e.level<6?s=1:e.level===6?s=2:s=3,i|=s<<6,e.strstart!==0&&(i|=h9),i+=31-i%31,Kf(e,i),e.strstart!==0&&(Kf(e,n.adler>>>16),Kf(e,n.adler&65535)),n.adler=1,e.status=La,Hr(n),e.pending!==0)return e.last_flush=-1,Zn}if(e.status===bm){if(n.adler=0,xe(e,31),xe(e,139),xe(e,8),e.gzhead)xe(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),xe(e,e.gzhead.time&255),xe(e,e.gzhead.time>>8&255),xe(e,e.gzhead.time>>16&255),xe(e,e.gzhead.time>>24&255),xe(e,e.level===9?2:e.strategy>=T0||e.level<2?4:0),xe(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(xe(e,e.gzhead.extra.length&255),xe(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=Un(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=_m;else if(xe(e,0),xe(e,0),xe(e,0),xe(e,0),xe(e,0),xe(e,e.level===9?2:e.strategy>=T0||e.level<2?4:0),xe(e,d9),e.status=La,Hr(n),e.pending!==0)return e.last_flush=-1,Zn}if(e.status===_m){if(e.gzhead.extra){let i=e.pending,s=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let a=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+a),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex+=a,Hr(n),e.pending!==0)return e.last_flush=-1,Zn;i=0,s-=a}let o=new Uint8Array(e.gzhead.extra);e.pending_buf.set(o.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=Am}if(e.status===Am){if(e.gzhead.name){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i)),Hr(n),e.pending!==0)return e.last_flush=-1,Zn;i=0}e.gzindex<e.gzhead.name.length?s=e.gzhead.name.charCodeAt(e.gzindex++)&255:s=0,xe(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=Em}if(e.status===Em){if(e.gzhead.comment){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i)),Hr(n),e.pending!==0)return e.last_flush=-1,Zn;i=0}e.gzindex<e.gzhead.comment.length?s=e.gzhead.comment.charCodeAt(e.gzindex++)&255:s=0,xe(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Un(n.adler,e.pending_buf,e.pending-i,i))}e.status=vm}if(e.status===vm){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Hr(n),e.pending!==0))return e.last_flush=-1,Zn;xe(e,n.adler&255),xe(e,n.adler>>8&255),n.adler=0}if(e.status=La,Hr(n),e.pending!==0)return e.last_flush=-1,Zn}if(n.avail_in!==0||e.lookahead!==0||t!==xo&&e.status!==Vf){let i=e.level===0?Wv(e,t):e.strategy===T0?y9(e,t):e.strategy===e9?g9(e,t):jf[e.level].func(e,t);if((i===Ua||i===vu)&&(e.status=Vf),i===pr||i===Ua)return n.avail_out===0&&(e.last_flush=-1),Zn;if(i===Eu&&(t===QD?qD(e):t!==Gv&&(ym(e,0,0,!1),t===YD&&(Io(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Hr(n),n.avail_out===0))return e.last_flush=-1,Zn}return t!==ei?Zn:e.wrap<=0?Vv:(e.wrap===2?(xe(e,n.adler&255),xe(e,n.adler>>8&255),xe(e,n.adler>>16&255),xe(e,n.adler>>24&255),xe(e,n.total_in&255),xe(e,n.total_in>>8&255),xe(e,n.total_in>>16&255),xe(e,n.total_in>>24&255)):(Kf(e,n.adler>>>16),Kf(e,n.adler&65535)),Hr(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Zn:Vv)},E9=n=>{if(Wf(n))return Ji;const t=n.state.status;return n.state=null,t===La?Da(n,JD):Zn},v9=(n,t)=>{let e=t.length;if(Wf(n))return Ji;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==Au||r.lookahead)return Ji;if(i===1&&(n.adler=zf(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(Io(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(t.subarray(e-r.w_size,e),0),t=u,e=r.w_size}const s=n.avail_in,o=n.next_in,a=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,xu(r);r.lookahead>=le;){let u=r.strstart,f=r.lookahead-(le-1);do r.ins_h=So(r,r.ins_h,r.window[u+le-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--f);r.strstart=u,r.lookahead=le-1,xu(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=le-1,r.match_available=0,n.next_in=o,n.input=a,n.avail_in=s,r.wrap=i,Zn};var x9=_9,R9=Qv,I9=qv,S9=Zv,k9=b9,T9=A9,O9=E9,N9=v9,C9="pako deflate (from Nodeca project)",Zf={deflateInit:x9,deflateInit2:R9,deflateReset:I9,deflateResetKeep:S9,deflateSetHeader:k9,deflate:T9,deflateEnd:O9,deflateSetDictionary:N9,deflateInfo:C9};const B9=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var P9=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)B9(e,r)&&(n[r]=e[r])}}return n},M9=n=>{let t=0;for(let r=0,i=n.length;r<i;r++)t+=n[r].length;const e=new Uint8Array(t);for(let r=0,i=0,s=n.length;r<s;r++){let o=n[r];e.set(o,i),i+=o.length}return e},N0={assign:P9,flattenChunks:M9};let Yv=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Yv=!1}const qf=new Uint8Array(256);for(let n=0;n<256;n++)qf[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;qf[254]=qf[254]=1;var L9=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,o=n.length,a=0;for(i=0;i<o;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),a+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(a),s=0,i=0;s<a;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const U9=(n,t)=>{if(t<65534&&n.subarray&&Yv)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(n[r]);return e};var D9=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*2);for(i=0,r=0;r<e;){let o=n[r++];if(o<128){s[i++]=o;continue}let a=qf[o];if(a>4){s[i++]=65533,r+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&r<e;)o=o<<6|n[r++]&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 U9(s,i)},F9=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+qf[n[e]]>t?e:t},Qf={string2buf:L9,buf2string:D9,utf8border:F9};function $9(){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 Jv=$9;const Xv=Object.prototype.toString,{Z_NO_FLUSH:H9,Z_SYNC_FLUSH:z9,Z_FULL_FLUSH:G9,Z_FINISH:V9,Z_OK:C0,Z_STREAM_END:K9,Z_DEFAULT_COMPRESSION:j9,Z_DEFAULT_STRATEGY:W9,Z_DEFLATED:Z9}=Gf;function Im(n){this.options=N0.assign({level:j9,method:Z9,chunkSize:16384,windowBits:15,memLevel:8,strategy:W9},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jv,this.strm.avail_out=0;let e=Zf.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==C0)throw new Error(_u[e]);if(t.header&&Zf.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=Qf.string2buf(t.dictionary):Xv.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=Zf.deflateSetDictionary(this.strm,r),e!==C0)throw new Error(_u[e]);this._dict_set=!0}}Im.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?V9:H9,typeof n=="string"?e.input=Qf.string2buf(n):Xv.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===z9||s===G9)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=Zf.deflate(e,s),i===K9)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=Zf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===C0;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0},Im.prototype.onData=function(n){this.chunks.push(n)},Im.prototype.onEnd=function(n){n===C0&&(this.result=N0.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};const B0=16209,q9=16191;var Q9=function(t,e){let r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H,U,G,W,X,j,J,it,ut;const rt=t.state;r=t.next_in,it=t.input,i=r+(t.avail_in-5),s=t.next_out,ut=t.output,o=s-(e-t.avail_out),a=s+(t.avail_out-257),u=rt.dmax,f=rt.wsize,h=rt.whave,y=rt.wnext,_=rt.window,w=rt.hold,R=rt.bits,T=rt.lencode,I=rt.distcode,B=(1<<rt.lenbits)-1,H=(1<<rt.distbits)-1;t:do{R<15&&(w+=it[r++]<<R,R+=8,w+=it[r++]<<R,R+=8),U=T[w&B];e:for(;;){if(G=U>>>24,w>>>=G,R-=G,G=U>>>16&255,G===0)ut[s++]=U&65535;else if(G&16){W=U&65535,G&=15,G&&(R<G&&(w+=it[r++]<<R,R+=8),W+=w&(1<<G)-1,w>>>=G,R-=G),R<15&&(w+=it[r++]<<R,R+=8,w+=it[r++]<<R,R+=8),U=I[w&H];n:for(;;){if(G=U>>>24,w>>>=G,R-=G,G=U>>>16&255,G&16){if(X=U&65535,G&=15,R<G&&(w+=it[r++]<<R,R+=8,R<G&&(w+=it[r++]<<R,R+=8)),X+=w&(1<<G)-1,X>u){t.msg="invalid distance too far back",rt.mode=B0;break t}if(w>>>=G,R-=G,G=s-o,X>G){if(G=X-G,G>h&&rt.sane){t.msg="invalid distance too far back",rt.mode=B0;break t}if(j=0,J=_,y===0){if(j+=f-G,G<W){W-=G;do ut[s++]=_[j++];while(--G);j=s-X,J=ut}}else if(y<G){if(j+=f+y-G,G-=y,G<W){W-=G;do ut[s++]=_[j++];while(--G);if(j=0,y<W){G=y,W-=G;do ut[s++]=_[j++];while(--G);j=s-X,J=ut}}}else if(j+=y-G,G<W){W-=G;do ut[s++]=_[j++];while(--G);j=s-X,J=ut}for(;W>2;)ut[s++]=J[j++],ut[s++]=J[j++],ut[s++]=J[j++],W-=3;W&&(ut[s++]=J[j++],W>1&&(ut[s++]=J[j++]))}else{j=s-X;do ut[s++]=ut[j++],ut[s++]=ut[j++],ut[s++]=ut[j++],W-=3;while(W>2);W&&(ut[s++]=ut[j++],W>1&&(ut[s++]=ut[j++]))}}else if(G&64){t.msg="invalid distance code",rt.mode=B0;break t}else{U=I[(U&65535)+(w&(1<<G)-1)];continue n}break}}else if(G&64)if(G&32){rt.mode=q9;break t}else{t.msg="invalid literal/length code",rt.mode=B0;break t}else{U=T[(U&65535)+(w&(1<<G)-1)];continue e}break}}while(r<i&&s<a);W=R>>3,r-=W,R-=W<<3,w&=(1<<R)-1,t.next_in=r,t.next_out=s,t.avail_in=r<i?5+(i-r):5-(r-i),t.avail_out=s<a?257+(a-s):257-(s-a),rt.hold=w,rt.bits=R};const Iu=15,tx=852,ex=592,nx=0,Sm=1,rx=2,Y9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),J9=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]),X9=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]),tF=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 Yf=(n,t,e,r,i,s,o,a)=>{const u=a.bits;let f=0,h=0,y=0,_=0,w=0,R=0,T=0,I=0,B=0,H=0,U,G,W,X,j,J=null,it;const ut=new Uint16Array(Iu+1),rt=new Uint16Array(Iu+1);let ot=null,C,p,m;for(f=0;f<=Iu;f++)ut[f]=0;for(h=0;h<r;h++)ut[t[e+h]]++;for(w=u,_=Iu;_>=1&&ut[_]===0;_--);if(w>_&&(w=_),_===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(y=1;y<_&&ut[y]===0;y++);for(w<y&&(w=y),I=1,f=1;f<=Iu;f++)if(I<<=1,I-=ut[f],I<0)return-1;if(I>0&&(n===nx||_!==1))return-1;for(rt[1]=0,f=1;f<Iu;f++)rt[f+1]=rt[f]+ut[f];for(h=0;h<r;h++)t[e+h]!==0&&(o[rt[t[e+h]]++]=h);if(n===nx?(J=ot=o,it=20):n===Sm?(J=Y9,ot=J9,it=257):(J=X9,ot=tF,it=0),H=0,h=0,f=y,j=s,R=w,T=0,W=-1,B=1<<w,X=B-1,n===Sm&&B>tx||n===rx&&B>ex)return 1;for(;;){C=f-T,o[h]+1<it?(p=0,m=o[h]):o[h]>=it?(p=ot[o[h]-it],m=J[o[h]-it]):(p=96,m=0),U=1<<f-T,G=1<<R,y=G;do G-=U,i[j+(H>>T)+G]=C<<24|p<<16|m|0;while(G!==0);for(U=1<<f-1;H&U;)U>>=1;if(U!==0?(H&=U-1,H+=U):H=0,h++,--ut[f]===0){if(f===_)break;f=t[e+o[h]]}if(f>w&&(H&X)!==W){for(T===0&&(T=w),j+=y,R=f-T,I=1<<R;R+T<_&&(I-=ut[R+T],!(I<=0));)R++,I<<=1;if(B+=1<<R,n===Sm&&B>tx||n===rx&&B>ex)return 1;W=H&X,i[W]=w<<24|R<<16|j-s|0}}return H!==0&&(i[j+H]=f-T<<24|64<<16|0),a.bits=w,0};const eF=0,ix=1,sx=2,{Z_FINISH:ox,Z_BLOCK:nF,Z_TREES:P0,Z_OK:Fa,Z_STREAM_END:rF,Z_NEED_DICT:iF,Z_STREAM_ERROR:ni,Z_DATA_ERROR:ax,Z_MEM_ERROR:cx,Z_BUF_ERROR:sF,Z_DEFLATED:ux}=Gf,M0=16180,lx=16181,fx=16182,hx=16183,dx=16184,px=16185,gx=16186,yx=16187,mx=16188,wx=16189,L0=16190,Ns=16191,km=16192,bx=16193,Tm=16194,_x=16195,Ax=16196,Ex=16197,vx=16198,U0=16199,D0=16200,xx=16201,Rx=16202,Ix=16203,Sx=16204,kx=16205,Om=16206,Tx=16207,Ox=16208,Qe=16209,Nx=16210,Cx=16211,oF=852,aF=592,cF=15,Bx=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function uF(){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=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<M0||t.mode>Cx?1:0},Px=n=>{if($a(n))return ni;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=M0,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(oF),t.distcode=t.distdyn=new Int32Array(aF),t.sane=1,t.back=-1,Fa},Mx=n=>{if($a(n))return ni;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,Px(n)},Lx=(n,t)=>{let e;if($a(n))return ni;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ni:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,Mx(n))},Ux=(n,t)=>{if(!n)return ni;const e=new uF;n.state=e,e.strm=n,e.window=null,e.mode=M0;const r=Lx(n,t);return r!==Fa&&(n.state=null),r},lF=n=>Ux(n,cF);let Dx=!0,Nm,Cm;const fF=n=>{if(Dx){Nm=new Int32Array(512),Cm=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Yf(ix,n.lens,0,288,Nm,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Yf(sx,n.lens,0,32,Cm,0,n.work,{bits:5}),Dx=!1}n.lencode=Nm,n.lenbits=9,n.distcode=Cm,n.distbits=5},Fx=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},hF=(n,t)=>{let e,r,i,s,o,a,u,f,h,y,_,w,R,T,I=0,B,H,U,G,W,X,j,J;const it=new Uint8Array(4);let ut,rt;const ot=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($a(n)||!n.output||!n.input&&n.avail_in!==0)return ni;e=n.state,e.mode===Ns&&(e.mode=km),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,a=n.avail_in,f=e.hold,h=e.bits,y=a,_=u,J=Fa;t:for(;;)switch(e.mode){case M0:if(e.wrap===0){e.mode=km;break}for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&2&&f===35615){e.wbits===0&&(e.wbits=15),e.check=0,it[0]=f&255,it[1]=f>>>8&255,e.check=Un(e.check,it,2,0),f=0,h=0,e.mode=lx;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((f&255)<<8)+(f>>8))%31){n.msg="incorrect header check",e.mode=Qe;break}if((f&15)!==ux){n.msg="unknown compression method",e.mode=Qe;break}if(f>>>=4,h-=4,j=(f&15)+8,e.wbits===0&&(e.wbits=j),j>15||j>e.wbits){n.msg="invalid window size",e.mode=Qe;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=f&512?wx:Ns,f=0,h=0;break;case lx:for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.flags=f,(e.flags&255)!==ux){n.msg="unknown compression method",e.mode=Qe;break}if(e.flags&57344){n.msg="unknown header flags set",e.mode=Qe;break}e.head&&(e.head.text=f>>8&1),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Un(e.check,it,2,0)),f=0,h=0,e.mode=fx;case fx:for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.head&&(e.head.time=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,it[2]=f>>>16&255,it[3]=f>>>24&255,e.check=Un(e.check,it,4,0)),f=0,h=0,e.mode=hx;case hx:for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.head&&(e.head.xflags=f&255,e.head.os=f>>8),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Un(e.check,it,2,0)),f=0,h=0,e.mode=dx;case dx:if(e.flags&1024){for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.length=f,e.head&&(e.head.extra_len=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Un(e.check,it,2,0)),f=0,h=0}else e.head&&(e.head.extra=null);e.mode=px;case px:if(e.flags&1024&&(w=e.length,w>a&&(w=a),w&&(e.head&&(j=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+w),j)),e.flags&512&&e.wrap&4&&(e.check=Un(e.check,r,w,s)),a-=w,s+=w,e.length-=w),e.length))break t;e.length=0,e.mode=gx;case gx:if(e.flags&2048){if(a===0)break t;w=0;do j=r[s+w++],e.head&&j&&e.length<65536&&(e.head.name+=String.fromCharCode(j));while(j&&w<a);if(e.flags&512&&e.wrap&4&&(e.check=Un(e.check,r,w,s)),a-=w,s+=w,j)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=yx;case yx:if(e.flags&4096){if(a===0)break t;w=0;do j=r[s+w++],e.head&&j&&e.length<65536&&(e.head.comment+=String.fromCharCode(j));while(j&&w<a);if(e.flags&512&&e.wrap&4&&(e.check=Un(e.check,r,w,s)),a-=w,s+=w,j)break t}else e.head&&(e.head.comment=null);e.mode=mx;case mx:if(e.flags&512){for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.check&65535)){n.msg="header crc mismatch",e.mode=Qe;break}f=0,h=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=Ns;break;case wx:for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}n.adler=e.check=Bx(f),f=0,h=0,e.mode=L0;case L0:if(e.havedict===0)return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,iF;n.adler=e.check=1,e.mode=Ns;case Ns:if(t===nF||t===P0)break t;case km:if(e.last){f>>>=h&7,h-=h&7,e.mode=Om;break}for(;h<3;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}switch(e.last=f&1,f>>>=1,h-=1,f&3){case 0:e.mode=bx;break;case 1:if(fF(e),e.mode=U0,t===P0){f>>>=2,h-=2;break t}break;case 2:e.mode=Ax;break;case 3:n.msg="invalid block type",e.mode=Qe}f>>>=2,h-=2;break;case bx:for(f>>>=h&7,h-=h&7;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if((f&65535)!==(f>>>16^65535)){n.msg="invalid stored block lengths",e.mode=Qe;break}if(e.length=f&65535,f=0,h=0,e.mode=Tm,t===P0)break t;case Tm:e.mode=_x;case _x:if(w=e.length,w){if(w>a&&(w=a),w>u&&(w=u),w===0)break t;i.set(r.subarray(s,s+w),o),a-=w,s+=w,u-=w,o+=w,e.length-=w;break}e.mode=Ns;break;case Ax:for(;h<14;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.nlen=(f&31)+257,f>>>=5,h-=5,e.ndist=(f&31)+1,f>>>=5,h-=5,e.ncode=(f&15)+4,f>>>=4,h-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=Qe;break}e.have=0,e.mode=Ex;case Ex:for(;e.have<e.ncode;){for(;h<3;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.lens[ot[e.have++]]=f&7,f>>>=3,h-=3}for(;e.have<19;)e.lens[ot[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,ut={bits:e.lenbits},J=Yf(eF,e.lens,0,19,e.lencode,0,e.work,ut),e.lenbits=ut.bits,J){n.msg="invalid code lengths set",e.mode=Qe;break}e.have=0,e.mode=vx;case vx:for(;e.have<e.nlen+e.ndist;){for(;I=e.lencode[f&(1<<e.lenbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(U<16)f>>>=B,h-=B,e.lens[e.have++]=U;else{if(U===16){for(rt=B+2;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(f>>>=B,h-=B,e.have===0){n.msg="invalid bit length repeat",e.mode=Qe;break}j=e.lens[e.have-1],w=3+(f&3),f>>>=2,h-=2}else if(U===17){for(rt=B+3;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,w=3+(f&7),f>>>=3,h-=3}else{for(rt=B+7;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,w=11+(f&127),f>>>=7,h-=7}if(e.have+w>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=Qe;break}for(;w--;)e.lens[e.have++]=j}}if(e.mode===Qe)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=Qe;break}if(e.lenbits=9,ut={bits:e.lenbits},J=Yf(ix,e.lens,0,e.nlen,e.lencode,0,e.work,ut),e.lenbits=ut.bits,J){n.msg="invalid literal/lengths set",e.mode=Qe;break}if(e.distbits=6,e.distcode=e.distdyn,ut={bits:e.distbits},J=Yf(sx,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,ut),e.distbits=ut.bits,J){n.msg="invalid distances set",e.mode=Qe;break}if(e.mode=U0,t===P0)break t;case U0:e.mode=D0;case D0:if(a>=6&&u>=258){n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,Q9(n,_),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,a=n.avail_in,f=e.hold,h=e.bits,e.mode===Ns&&(e.back=-1);break}for(e.back=0;I=e.lencode[f&(1<<e.lenbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(H&&!(H&240)){for(G=B,W=H,X=U;I=e.lencode[X+((f&(1<<G+W)-1)>>G)],B=I>>>24,H=I>>>16&255,U=I&65535,!(G+B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,e.length=U,H===0){e.mode=kx;break}if(H&32){e.back=-1,e.mode=Ns;break}if(H&64){n.msg="invalid literal/length code",e.mode=Qe;break}e.extra=H&15,e.mode=xx;case xx:if(e.extra){for(rt=e.extra;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.length+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=Rx;case Rx:for(;I=e.distcode[f&(1<<e.distbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(!(H&240)){for(G=B,W=H,X=U;I=e.distcode[X+((f&(1<<G+W)-1)>>G)],B=I>>>24,H=I>>>16&255,U=I&65535,!(G+B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,H&64){n.msg="invalid distance code",e.mode=Qe;break}e.offset=U,e.extra=H&15,e.mode=Ix;case Ix:if(e.extra){for(rt=e.extra;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.offset+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=Qe;break}e.mode=Sx;case Sx:if(u===0)break t;if(w=_-u,e.offset>w){if(w=e.offset-w,w>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=Qe;break}w>e.wnext?(w-=e.wnext,R=e.wsize-w):R=e.wnext-w,w>e.length&&(w=e.length),T=e.window}else T=i,R=o-e.offset,w=e.length;w>u&&(w=u),u-=w,e.length-=w;do i[o++]=T[R++];while(--w);e.length===0&&(e.mode=D0);break;case kx:if(u===0)break t;i[o++]=e.length,u--,e.mode=D0;break;case Om:if(e.wrap){for(;h<32;){if(a===0)break t;a--,f|=r[s++]<<h,h+=8}if(_-=u,n.total_out+=_,e.total+=_,e.wrap&4&&_&&(n.adler=e.check=e.flags?Un(e.check,i,_,o-_):zf(e.check,i,_,o-_)),_=u,e.wrap&4&&(e.flags?f:Bx(f))!==e.check){n.msg="incorrect data check",e.mode=Qe;break}f=0,h=0}e.mode=Tx;case Tx:if(e.wrap&&e.flags){for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.total&4294967295)){n.msg="incorrect length check",e.mode=Qe;break}f=0,h=0}e.mode=Ox;case Ox:J=rF;break t;case Qe:J=ax;break t;case Nx:return cx;case Cx:default:return ni}return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,(e.wsize||_!==n.avail_out&&e.mode<Qe&&(e.mode<Om||t!==ox))&&Fx(n,n.output,n.next_out,_-n.avail_out),y-=n.avail_in,_-=n.avail_out,n.total_in+=y,n.total_out+=_,e.total+=_,e.wrap&4&&_&&(n.adler=e.check=e.flags?Un(e.check,i,_,n.next_out-_):zf(e.check,i,_,n.next_out-_)),n.data_type=e.bits+(e.last?64:0)+(e.mode===Ns?128:0)+(e.mode===U0||e.mode===Tm?256:0),(y===0&&_===0||t===ox)&&J===Fa&&(J=sF),J},dF=n=>{if($a(n))return ni;let t=n.state;return t.window&&(t.window=null),n.state=null,Fa},pF=(n,t)=>{if($a(n))return ni;const e=n.state;return e.wrap&2?(e.head=t,t.done=!1,Fa):ni},gF=(n,t)=>{const e=t.length;let r,i,s;return $a(n)||(r=n.state,r.wrap!==0&&r.mode!==L0)?ni:r.mode===L0&&(i=1,i=zf(i,t,e,0),i!==r.check)?ax:(s=Fx(n,t,e,e),s?(r.mode=Nx,cx):(r.havedict=1,Fa))};var yF=Mx,mF=Lx,wF=Px,bF=lF,_F=Ux,AF=hF,EF=dF,vF=pF,xF=gF,RF="pako inflate (from Nodeca project)",Cs={inflateReset:yF,inflateReset2:mF,inflateResetKeep:wF,inflateInit:bF,inflateInit2:_F,inflate:AF,inflateEnd:EF,inflateGetHeader:vF,inflateSetDictionary:xF,inflateInfo:RF};function IF(){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 SF=IF;const $x=Object.prototype.toString,{Z_NO_FLUSH:kF,Z_FINISH:TF,Z_OK:Jf,Z_STREAM_END:Bm,Z_NEED_DICT:Pm,Z_STREAM_ERROR:OF,Z_DATA_ERROR:Hx,Z_MEM_ERROR:NF}=Gf;function Xf(n){this.options=N0.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jv,this.strm.avail_out=0;let e=Cs.inflateInit2(this.strm,t.windowBits);if(e!==Jf)throw new Error(_u[e]);if(this.header=new SF,Cs.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Qf.string2buf(t.dictionary):$x.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Cs.inflateSetDictionary(this.strm,t.dictionary),e!==Jf)))throw new Error(_u[e])}Xf.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?TF:kF,$x.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=Cs.inflate(e,o),s===Pm&&i&&(s=Cs.inflateSetDictionary(e,i),s===Jf?s=Cs.inflate(e,o):s===Hx&&(s=Pm));e.avail_in>0&&s===Bm&&e.state.wrap>0&&n[e.next_in]!==0;)Cs.inflateReset(e),s=Cs.inflate(e,o);switch(s){case OF:case Hx:case Pm:case NF:return this.onEnd(s),this.ended=!0,!1}if(a=e.avail_out,e.next_out&&(e.avail_out===0||s===Bm))if(this.options.to==="string"){let u=Qf.utf8border(e.output,e.next_out),f=e.next_out-u,h=Qf.buf2string(e.output,u);e.next_out=f,e.avail_out=r-f,f&&e.output.set(e.output.subarray(u,u+f),0),this.onData(h)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===Jf&&a===0)){if(s===Bm)return s=Cs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0},Xf.prototype.onData=function(n){this.chunks.push(n)},Xf.prototype.onEnd=function(n){n===Jf&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=N0.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Mm(n,t){const e=new Xf(t);if(e.push(n),e.err)throw e.msg||_u[e.err];return e.result}function CF(n,t){return t=t||{},t.raw=!0,Mm(n,t)}var BF=Xf,PF=Mm,MF=CF,LF=Mm,UF=Gf,DF={Inflate:BF,inflate:PF,inflateRaw:MF,ungzip:LF,constants:UF};const{Inflate:pq,inflate:FF,inflateRaw:gq,ungzip:yq}=DF;var $F=FF,zx={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,_){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,y||u,_),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],w]:u._events[R].push(w):(u._events[R]=w,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},a.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,w=y.length,R=new Array(w);_<w;_++)R[_]=y[_].fn;return R},a.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},a.prototype.emit=function(f,h,y,_,w,R){var T=e?e+f:f;if(!this._events[T])return!1;var I=this._events[T],B=arguments.length,H,U;if(I.fn){switch(I.once&&this.removeListener(f,I.fn,void 0,!0),B){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,h),!0;case 3:return I.fn.call(I.context,h,y),!0;case 4:return I.fn.call(I.context,h,y,_),!0;case 5:return I.fn.call(I.context,h,y,_,w),!0;case 6:return I.fn.call(I.context,h,y,_,w,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];I.fn.apply(I.context,H)}else{var G=I.length,W;for(U=0;U<G;U++)switch(I[U].once&&this.removeListener(f,I[U].fn,void 0,!0),B){case 1:I[U].fn.call(I[U].context);break;case 2:I[U].fn.call(I[U].context,h);break;case 3:I[U].fn.call(I[U].context,h,y);break;case 4:I[U].fn.call(I[U].context,h,y,_);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];I[U].fn.apply(I[U].context,H)}}return!0},a.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},a.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},a.prototype.removeListener=function(f,h,y,_){var w=e?e+f:f;if(!this._events[w])return this;if(!h)return o(this,w),this;var R=this._events[w];if(R.fn)R.fn===h&&(!_||R.once)&&(!y||R.context===y)&&o(this,w);else{for(var T=0,I=[],B=R.length;T<B;T++)(R[T].fn!==h||_&&!R[T].once||y&&R[T].context!==y)&&I.push(R[T]);I.length?this._events[w]=I.length===1?I[0]:I:o(this,w)}return this},a.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(zx);var HF=zx.exports;const zF=Mr(HF);function GF(n,t){return Array.apply(0,new Array(Math.ceil(n.length/t))).map((e,r)=>n.slice(r*t,(r+1)*t))}const Ha=n=>"version"in n;function VF(n){return new TextDecoder("utf-8").decode(n)}function Gx(n){return On.encode(n)}function Vx(n){return kt.from(n,"base64")}function ko(n){return"accounts"in n}async function KF(n){const t=(await pt.findProgramAddress([],n))[0];return await pt.createWithSeed(t,jF(),n)}function jF(){return"anchor:idl"}const WF=Yt.struct([Yt.publicKey("authority"),Yt.vecU8("data")]);function ZF(n){return WF.decode(n)}function qF(n){const t=["name","path","account","relations","generic"],e=s=>s.split(".").map(dD).join("."),r=s=>{for(const o in s){const a=s[o];t.includes(o)?s[o]=Array.isArray(a)?a.map(e):e(a):typeof a=="object"&&r(a)}},i=structuredClone(n);return r(i),i}function Su(n,t,e,r){return n!=null&&n.length?n[0].name?e(n):r(n):t()}function QF(n){const t=new Map;return n.errors&&n.errors.forEach(e=>{var r;let i=(r=e.msg)!==null&&r!==void 0?r:e.name;t.set(e.code,i)}),t}function YF(n,...t){if(n.args.length!=t.length)throw new Error("Invalid argument length");const e={};let r=0;return n.args.forEach(i=>{e[i.name]=t[r],r+=1}),e}function Kx(n,t={}){n.forEach(e=>{if(ko(e))Kx(e.accounts,t[e.name]);else if(!t[e.name])throw new Error(`Account \`${e.name}\` not provided.`)})}function Ei(n){return n instanceof pt?n:new pt(n)}class JF extends TypeError{constructor(t,e){let r;const{message:i,...s}=t,{path:o}=t,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=r)!=null?u:r=[t,...e()]}}}function XF(n){return ku(n)&&typeof n[Symbol.iterator]=="function"}function ku(n){return typeof n=="object"&&n!=null}function To(n){return typeof n=="string"?JSON.stringify(n):""+n}function t7(n){const{done:t,value:e}=n.next();return t?void 0:e}function e7(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:a,message:u="Expected a value of type `"+o+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+To(r)+"`"}=n;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*jx(n,t,e,r){XF(n)||(n=[n]);for(const i of n){const s=e7(i,t,e,r);s&&(yield s)}}function*Lm(n,t,e){e===void 0&&(e={});const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,a={path:r,branch:i};if(s&&(n=t.coercer(n,a),o&&t.type!=="type"&&ku(t.schema)&&ku(n)&&!Array.isArray(n)))for(const f in n)t.schema[f]===void 0&&delete n[f];let u=!0;for(const f of t.validator(n,a))u=!1,yield[f,void 0];for(let[f,h,y]of t.entries(n,a)){const _=Lm(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o});for(const w of _)w[0]?(u=!1,yield[w[0],void 0]):s&&(h=w[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):ku(n)&&(n[f]=h))}if(u)for(const f of t.refiner(n,a))u=!1,yield[f,void 0];u&&(yield[void 0,n])}class Oo{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return jx(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return jx(h,f,this,u)}:this.refiner=()=>[]}assert(t){return n7(t,this)}create(t){return Um(t,this)}is(t){return Wx(t,this)}mask(t){return r7(t,this)}validate(t,e){return e===void 0&&(e={}),th(t,this,e)}}function n7(n,t){const e=th(n,t);if(e[0])throw e[0]}function Um(n,t){const e=th(n,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function r7(n,t){const e=th(n,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function Wx(n,t){return!th(n,t)[0]}function th(n,t,e){e===void 0&&(e={});const r=Lm(n,t,e),i=t7(r);return i[0]?[new JF(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function eh(n,t){return new Oo({type:n,schema:null,validator:t})}function i7(){return eh("any",()=>!0)}function Dm(n){return new Oo({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+To(t)}})}function s7(){return eh("boolean",n=>typeof n=="boolean")}function Zx(n){const t=To(n);return new Oo({type:"literal",schema:n,validator(e){return e===n||"Expected the literal `"+t+"`, but received: "+To(e)}})}function F0(n){return new Oo({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function $0(){return eh("number",n=>typeof n=="number"&&!isNaN(n)||"Expected a number, but received: "+To(n))}function H0(n){return new Oo({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function za(){return eh("string",n=>typeof n=="string"||"Expected a string, but received: "+To(n))}function No(n){const t=Object.keys(n);return new Oo({type:"type",schema:n,*entries(e){if(ku(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return ku(e)||"Expected an object, but received: "+To(e)}})}function qx(n){const t=n.map(e=>e.type).join(" | ");return new Oo({type:"union",schema:null,coercer(e,r){return(n.find(s=>{const[o]=s.validate(e,{coerce:!0});return!o})||Fm()).coercer(e,r)},validator(e,r){const i=[];for(const s of n){const[...o]=Lm(e,s,r),[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 `"+t+"`, but received: "+To(e),...i]}})}function Fm(){return eh("unknown",()=>!0)}function o7(n,t,e){return new Oo({...n,coercer:(r,i)=>Wx(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}const Qx=99;async function a7(n,t,e){if(t.length<=Qx)return await Yx(n,t,e);{const r=GF(t,Qx);return(await Promise.all(r.map(s=>Yx(n,s,e)))).flat()}}async function Yx(n,t,e){const r=e??n.commitment,{value:i,context:s}=await n.getMultipleAccountsInfoAndContext(t,r);return i.map((a,u)=>a===null?null:{publicKey:t[u],account:a,context:s})}async function c7(n,t,e,r,i){var s;e&&e.length>0&&t.sign(...e);const o=t._compile(),a=o.serialize(),f=t._serialize(a).toString("base64"),h={encoding:"base64",commitment:r??n.commitment};if(i){const R=(Array.isArray(i)?i:o.nonProgramIds()).map(T=>T.toBase58());h.accounts={encoding:"base64",addresses:R}}e&&e.length>0&&(h.sigVerify=!0);const y=[f,h],_=await n._rpcRequest("simulateTransaction",y),w=Um(_,h7);if("error"in w){let R;if("data"in w.error&&(R=(s=w.error.data)===null||s===void 0?void 0:s.logs,R&&Array.isArray(R))){const T=`
|
|
24
|
+
`,I=T+R.join(T);console.error(w.error.message,I)}throw new Eo("failed to simulate transaction: "+w.error.message,R)}return w.result}function u7(n){return o7(Jx(n),l7,t=>"error"in t?t:{...t,result:Um(t.result,n)})}const l7=Jx(Fm());function Jx(n){return qx([No({jsonrpc:Zx("2.0"),id:za(),result:n}),No({jsonrpc:Zx("2.0"),id:za(),error:No({code:Fm(),message:za(),data:H0(i7())})})])}function f7(n){return u7(No({context:No({slot:$0()}),value:n}))}const h7=f7(No({err:F0(qx([No({}),za()])),logs:F0(Dm(za())),accounts:H0(F0(Dm(F0(No({executable:s7(),owner:za(),lamports:$0(),data:Dm(za()),rentEpoch:H0($0())}))))),unitsConsumed:H0($0())}));class nh{constructor(t,e,r=nh.defaultOptions()){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=e==null?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e=nh.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var i,s,o,a;if(r===void 0&&(r=this.opts),Ha(t))e&&t.sign(e);else if(t.feePayer=(i=t.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const f of e)t.partialSign(f);t=await this.wallet.signTransaction(t);const u=t.serialize();try{return await Xx(this.connection,u,r)}catch(f){if(f instanceof $m){const h=Gx(Ha(t)?((s=t.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=t.signature)!==null&&o!==void 0?o:new Uint8Array),y=Ha(t)?0:void 0,_=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:y});if(_){const w=(a=_.meta)===null||a===void 0?void 0:a.logMessages;throw w?new Eo(f.message,w):f}else throw f}else throw f}}async sendAll(t,e){var r,i,s;e===void 0&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let a=t.map(h=>{var y,_;if(Ha(h.tx)){let w=h.tx;return h.signers&&w.sign(h.signers),w}else{let w=h.tx,R=(y=h.signers)!==null&&y!==void 0?y:[];return w.feePayer=(_=w.feePayer)!==null&&_!==void 0?_:this.wallet.publicKey,w.recentBlockhash=o,R.forEach(T=>{w.partialSign(T)}),w}});const u=await this.wallet.signAllTransactions(a),f=[];for(let h=0;h<a.length;h+=1){const y=u[h],_=y.serialize();try{f.push(await Xx(this.connection,_,e))}catch(w){if(w instanceof $m){const R=Gx(Ha(y)?((r=y.signatures)===null||r===void 0?void 0:r[0])||new Uint8Array:(i=y.signature)!==null&&i!==void 0?i:new Uint8Array),T=Ha(y)?0:void 0,I=await this.connection.getTransaction(R,{commitment:"confirmed",maxSupportedTransactionVersion:T});if(I){const B=(s=I.meta)===null||s===void 0?void 0:s.logMessages;throw B?new Eo(w.message,B):w}else throw w}else throw w}}return f}async simulate(t,e,r,i){let s=(await this.connection.getLatestBlockhash(r??this.connection.commitment)).blockhash,o;if(Ha(t)?(e&&e.length>0&&(t.sign(e),t=await this.wallet.signTransaction(t)),o=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=s,e&&e.length>0&&(t=await this.wallet.signTransaction(t)),o=await c7(this.connection,t,e,r,i)),o.value.err)throw new d7(o.value);return o.value}}class d7 extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function Xx(n,t,e){const r=e?{skipPreflight:e.skipPreflight,preflightCommitment:e.preflightCommitment||e.commitment,maxRetries:e.maxRetries,minContextSlot:e.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await n.sendRawTransaction(t,r);if(e!=null&&e.blockhash)if(r.maxRetries===0){const a=AbortSignal.timeout(15e3);i=(await n.confirmTransaction({abortSignal:a,signature:o,...e.blockhash},e&&e.commitment)).value}else i=(await n.confirmTransaction({signature:o,...e.blockhash},e&&e.commitment)).value;else i=(await n.confirmTransaction(o,e&&e.commitment)).value;if(i.err)throw new $m(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class $m extends Error{constructor(t){super(t)}}function Hm(){return nh.local()}var p7=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof qc<"u"?qc:typeof self<"u"?self:{},et={};Object.defineProperty(et,"__esModule",{value:!0});var t2=et.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=Q2=et.ANCHOR_ERROR__REQUIRE_VIOLATED=q2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=Z2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=W2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=j2=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=K2=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=V2=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=G2=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=z2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=H2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=$2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=F2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=D2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=U2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=L2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=M2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=P2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=B2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=C2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=N2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=O2=et.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=T2=et.ANCHOR_ERROR__CONSTRAINT_SPACE=k2=et.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=S2=et.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=I2=et.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=R2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=x2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=v2=et.ANCHOR_ERROR__CONSTRAINT_ZERO=E2=et.ANCHOR_ERROR__CONSTRAINT_ADDRESS=A2=et.ANCHOR_ERROR__CONSTRAINT_CLOSE=_2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=b2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=w2=et.ANCHOR_ERROR__CONSTRAINT_STATE=m2=et.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=y2=et.ANCHOR_ERROR__CONSTRAINT_SEEDS=g2=et.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=p2=et.ANCHOR_ERROR__CONSTRAINT_OWNER=d2=et.ANCHOR_ERROR__CONSTRAINT_RAW=h2=et.ANCHOR_ERROR__CONSTRAINT_SIGNER=f2=et.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=l2=et.ANCHOR_ERROR__CONSTRAINT_MUT=u2=et.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=c2=et.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=a2=et.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=o2=et.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=s2=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=i2=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=r2=et.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=n2=et.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,e2=et.ANCHOR_ERROR__DEPRECATED=ER=et.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=AR=et.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=_R=et.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=bR=et.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=wR=et.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=mR=et.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=yR=et.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=gR=et.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=pR=et.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=dR=et.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=hR=et.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=fR=et.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=lR=et.ANCHOR_ERROR__INVALID_PROGRAM_ID=uR=et.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=cR=et.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=aR=et.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=oR=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=sR=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=iR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=rR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=nR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=eR=et.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=tR=et.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=X2=et.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=J2=et.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=Y2=et.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,n2=et.ANCHOR_ERROR__INSTRUCTION_MISSING=100,r2=et.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,i2=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,s2=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,o2=et.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,a2=et.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,c2=et.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,u2=et.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,l2=et.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,f2=et.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,h2=et.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,d2=et.ANCHOR_ERROR__CONSTRAINT_RAW=2003,p2=et.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,g2=et.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,y2=et.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,m2=et.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,w2=et.ANCHOR_ERROR__CONSTRAINT_STATE=2008,b2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,_2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,A2=et.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,E2=et.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,v2=et.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,x2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,R2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,I2=et.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,S2=et.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,k2=et.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,T2=et.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,O2=et.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,N2=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,C2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,B2=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,P2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,M2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,L2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,U2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,D2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,F2=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,$2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,H2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,z2=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,G2=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,V2=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,K2=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,j2=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,W2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,Z2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,q2=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,Q2=et.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;t2=et.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var Y2=et.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,J2=et.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,X2=et.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,tR=et.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,eR=et.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,nR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,rR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,iR=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,sR=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,oR=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,aR=et.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,cR=et.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,uR=et.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,lR=et.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,fR=et.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,hR=et.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,dR=et.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,pR=et.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,gR=et.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,yR=et.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,mR=et.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,wR=et.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,bR=et.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,_R=et.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,AR=et.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,ER=et.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;e2=et.ANCHOR_ERROR__DEPRECATED=5e3;const g7=new Map;function vR(n){return g7.get(n)!==void 0}class Co extends Error{constructor(t){super(t),this.name="IdlError"}}class rh{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<t.length;o++){if(i.exec(t[o])){s.pop();continue}const a=(e=r.exec(t[o]))===null||e===void 0?void 0:e[1];a&&s.push(new pt(a))}return new rh(s)}}class ih extends Error{constructor(t,e,r,i,s,o){super(r.join(`
|
|
25
|
+
`).replace("Program log: ","")),this.errorLogs=r,this.logs=i,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:s},this._programErrorStack=rh.parse(i)}static parse(t){if(!t)return null;const e=t.findIndex(_=>_.startsWith("Program log: AnchorError"));if(e===-1)return null;const r=t[e],i=[r];let s;if(e+1<t.length){if(t[e+1]==="Program log: Left:"){const _=/^Program log: (.*)$/,w=_.exec(t[e+2])[1],R=_.exec(t[e+4])[1];s=[new pt(w),new pt(R)],i.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const _=/^Program log: (Left|Right): (.*)$/,w=_.exec(t[e+1])[2],R=_.exec(t[e+2])[2];i.push(...t.slice(e+1,e+3)),s=[w,R]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),f=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),y=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(a){const[_,w,R]=a.slice(1,4),T={code:_,number:parseInt(w)};return new ih(T,R,i,t,void 0,s)}else if(f){const[_,w,R,T,I]=f.slice(1,6),B={code:R,number:parseInt(T)},H={file:_,line:parseInt(w)};return new ih(B,I,i,t,H,s)}else if(y){const[_,w,R,T]=y.slice(1,5),I=_,B={code:w,number:parseInt(R)};return new ih(B,T,i,t,I,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 z0 extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=rh.parse(r))}static parse(t,e){const r=t.toString();let i;if(r.includes("custom program error:")){let a=r.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=r.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=e.get(s);return o!==void 0?new z0(s,o,t.logs):(o=y7.get(s),o!==void 0?new z0(s,o,t.logs):null)}get program(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack}toString(){return this.msg}}function xR(n,t){vR("debug-logs")&&console.log("Translating error:",n);const e=ih.parse(n.logs);if(e)return e;const r=z0.parse(n,t);if(r)return r;if(n.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[n.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return n.programErrorStack=rh.parse(n.logs),new Proxy(n,i)}return n}const _t={InstructionMissing:n2,InstructionFallbackNotFound:r2,InstructionDidNotDeserialize:i2,InstructionDidNotSerialize:s2,IdlInstructionStub:o2,IdlInstructionInvalidProgram:a2,IdlAccountNotEmpty:c2,EventInstructionStub:u2,ConstraintMut:l2,ConstraintHasOne:f2,ConstraintSigner:h2,ConstraintRaw:d2,ConstraintOwner:p2,ConstraintRentExempt:g2,ConstraintSeeds:y2,ConstraintExecutable:m2,ConstraintState:w2,ConstraintAssociated:b2,ConstraintAssociatedInit:_2,ConstraintClose:A2,ConstraintAddress:E2,ConstraintZero:v2,ConstraintTokenMint:x2,ConstraintTokenOwner:R2,ConstraintMintMintAuthority:I2,ConstraintMintFreezeAuthority:S2,ConstraintMintDecimals:k2,ConstraintSpace:T2,ConstraintAccountIsNone:O2,ConstraintTokenTokenProgram:N2,ConstraintMintTokenProgram:C2,ConstraintAssociatedTokenTokenProgram:B2,ConstraintMintGroupPointerExtension:P2,ConstraintMintGroupPointerExtensionAuthority:M2,ConstraintMintGroupPointerExtensionGroupAddress:L2,ConstraintMintGroupMemberPointerExtension:U2,ConstraintMintGroupMemberPointerExtensionAuthority:D2,ConstraintMintGroupMemberPointerExtensionMemberAddress:F2,ConstraintMintMetadataPointerExtension:$2,ConstraintMintMetadataPointerExtensionAuthority:H2,ConstraintMintMetadataPointerExtensionMetadataAddress:z2,ConstraintMintCloseAuthorityExtension:G2,ConstraintMintCloseAuthorityExtensionAuthority:V2,ConstraintMintPermanentDelegateExtension:K2,ConstraintMintPermanentDelegateExtensionDelegate:j2,ConstraintMintTransferHookExtension:W2,ConstraintMintTransferHookExtensionAuthority:Z2,ConstraintMintTransferHookExtensionProgramId:q2,RequireViolated:Q2,RequireEqViolated:t2,RequireKeysEqViolated:Y2,RequireNeqViolated:J2,RequireKeysNeqViolated:X2,RequireGtViolated:tR,RequireGteViolated:eR,AccountDiscriminatorAlreadySet:nR,AccountDiscriminatorNotFound:rR,AccountDiscriminatorMismatch:iR,AccountDidNotDeserialize:sR,AccountDidNotSerialize:oR,AccountNotEnoughKeys:aR,AccountNotMutable:cR,AccountOwnedByWrongProgram:uR,InvalidProgramId:lR,InvalidProgramExecutable:fR,AccountNotSigner:hR,AccountNotSystemOwned:dR,AccountNotInitialized:pR,AccountNotProgramData:gR,AccountNotAssociatedTokenAccount:yR,AccountSysvarMismatch:mR,AccountReallocExceedsLimit:wR,AccountDuplicateReallocs:bR,DeclaredProgramIdMismatch:_R,TryingToInitPayerAsProgramAccount:AR,InvalidNumericConversion:ER,Deprecated:e2},y7=new Map([[_t.InstructionMissing,"Instruction discriminator not provided"],[_t.InstructionFallbackNotFound,"Fallback functions are not supported"],[_t.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[_t.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[_t.IdlInstructionStub,"The program was compiled without idl instructions"],[_t.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[_t.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[_t.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[_t.ConstraintMut,"A mut constraint was violated"],[_t.ConstraintHasOne,"A has one constraint was violated"],[_t.ConstraintSigner,"A signer constraint was violated"],[_t.ConstraintRaw,"A raw constraint was violated"],[_t.ConstraintOwner,"An owner constraint was violated"],[_t.ConstraintRentExempt,"A rent exemption constraint was violated"],[_t.ConstraintSeeds,"A seeds constraint was violated"],[_t.ConstraintExecutable,"An executable constraint was violated"],[_t.ConstraintState,"Deprecated Error, feel free to replace with something else"],[_t.ConstraintAssociated,"An associated constraint was violated"],[_t.ConstraintAssociatedInit,"An associated init constraint was violated"],[_t.ConstraintClose,"A close constraint was violated"],[_t.ConstraintAddress,"An address constraint was violated"],[_t.ConstraintZero,"Expected zero account discriminant"],[_t.ConstraintTokenMint,"A token mint constraint was violated"],[_t.ConstraintTokenOwner,"A token owner constraint was violated"],[_t.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[_t.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[_t.ConstraintMintDecimals,"A mint decimals constraint was violated"],[_t.ConstraintSpace,"A space constraint was violated"],[_t.ConstraintAccountIsNone,"A required account for the constraint is None"],[_t.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[_t.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[_t.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[_t.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[_t.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[_t.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[_t.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[_t.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[_t.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[_t.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[_t.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[_t.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[_t.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[_t.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[_t.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[_t.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[_t.RequireViolated,"A require expression was violated"],[_t.RequireEqViolated,"A require_eq expression was violated"],[_t.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[_t.RequireNeqViolated,"A require_neq expression was violated"],[_t.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[_t.RequireGtViolated,"A require_gt expression was violated"],[_t.RequireGteViolated,"A require_gte expression was violated"],[_t.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[_t.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[_t.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[_t.AccountDidNotDeserialize,"Failed to deserialize the account"],[_t.AccountDidNotSerialize,"Failed to serialize the account"],[_t.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[_t.AccountNotMutable,"The given account is not mutable"],[_t.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[_t.InvalidProgramId,"Program ID was not as expected"],[_t.InvalidProgramExecutable,"Program account is not executable"],[_t.AccountNotSigner,"The given account did not sign"],[_t.AccountNotSystemOwned,"The given account is not owned by the system program"],[_t.AccountNotInitialized,"The program expected this account to be already initialized"],[_t.AccountNotProgramData,"The given account is not a program data account"],[_t.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[_t.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[_t.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[_t.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[_t.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[_t.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[_t.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[_t.Deprecated,"The API being used is deprecated and should no longer be used"]]);class ge{static fieldLayout(t,e=[],r){const i=t.name;switch(t.type){case"bool":return Yt.bool(i);case"u8":return Yt.u8(i);case"i8":return Yt.i8(i);case"u16":return Yt.u16(i);case"i16":return Yt.i16(i);case"u32":return Yt.u32(i);case"i32":return Yt.i32(i);case"f32":return Yt.f32(i);case"u64":return Yt.u64(i);case"i64":return Yt.i64(i);case"f64":return Yt.f64(i);case"u128":return Yt.u128(i);case"i128":return Yt.i128(i);case"u256":return Yt.u256(i);case"i256":return Yt.i256(i);case"bytes":return Yt.vecU8(i);case"string":return Yt.str(i);case"pubkey":return Yt.publicKey(i);default:{if("option"in t.type)return Yt.option(ge.fieldLayout({type:t.type.option},e,r),i);if("vec"in t.type)return Yt.vec(ge.fieldLayout({type:t.type.vec},e,r),i);if("array"in t.type){let[s,o]=t.type.array;return o=ge.resolveArrayLen(o,r),Yt.array(ge.fieldLayout({type:s},e,r),o,i)}if("defined"in t.type){if(!e)throw new Co("User defined types not provided");const s=t.type.defined.name,o=e.find(a=>a.name===s);if(!o)throw new Co(`Type not found: ${t.name}`);return ge.typeDefLayout({typeDef:o,types:e,genericArgs:r??t.type.defined.generics,name:i})}if("generic"in t.type){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new Co(`Invalid generic field: ${t.name}`);return ge.fieldLayout({...t,type:s.type},e)}throw new Co(`Not yet implemented: ${JSON.stringify(t.type)}`)}}}static typeDefLayout({typeDef:t,types:e,name:r,genericArgs:i}){switch(t.type.kind){case"struct":{const s=Su(t.type.fields,()=>[],o=>o.map(a=>{const u=i&&ge.resolveGenericArgs({type:a.type,typeDef:t,genericArgs:i});return ge.fieldLayout(a,e,u)}),o=>o.map((a,u)=>{const f=i&&ge.resolveGenericArgs({type:a,typeDef:t,genericArgs:i});return ge.fieldLayout({name:u.toString(),type:a},e,f)}));return Yt.struct(s,r)}case"enum":{const s=t.type.variants.map(o=>{const a=Su(o.fields,()=>[],u=>u.map(f=>{const h=i&&ge.resolveGenericArgs({type:f.type,typeDef:t,genericArgs:i});return ge.fieldLayout(f,e,h)}),u=>u.map((f,h)=>{const y=i&&ge.resolveGenericArgs({type:f,typeDef:t,genericArgs:i});return ge.fieldLayout({name:h.toString(),type:f},e,y)}));return Yt.struct(a,o.name)});return r!==void 0?Yt.rustEnum(s).replicate(r):Yt.rustEnum(s,r)}case"type":return ge.fieldLayout({type:t.type.alias,name:r},e)}}static typeSize(t,e,r){var i;switch(t){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in t)return 1+ge.typeSize(t.option,e,r);if("coption"in t)return 4+ge.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[s,o]=t.array;return o=ge.resolveArrayLen(o,r),ge.typeSize(s,e,r)*o}if("defined"in t){const s=(i=e.types)===null||i===void 0?void 0:i.find(a=>a.name===t.defined.name);if(!s)throw new Co(`Type not found: ${JSON.stringify(t)}`);const o=a=>{const u=r??t.defined.generics,f=u&&ge.resolveGenericArgs({type:a,typeDef:s,genericArgs:u});return ge.typeSize(a,e,f)};switch(s.type.kind){case"struct":return Su(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=>Su(u.fields,()=>[0],f=>f.map(h=>o(h.type)),f=>f.map(h=>o(h))).reduce((f,h)=>f+h,0));return Math.max(...a)+1}case"type":return ge.typeSize(s.type.alias,e,r)}}if("generic"in t){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new Co(`Invalid generic: ${t.generic}`);return ge.typeSize(s.type,e,r)}throw new Error(`Invalid type ${JSON.stringify(t)}`)}}static resolveArrayLen(t,e){if(typeof t=="number")return t;if(e){const r=e.find(i=>i.kind==="const");(r==null?void 0:r.kind)==="const"&&(t=+r.value)}if(typeof t!="number")throw new Co("Generic array length did not resolve");return t}static resolveGenericArgs({type:t,typeDef:e,genericArgs:r,isDefined:i}){if(typeof t!="object")return null;for(const s in e.generics){const o=e.generics[s];if("generic"in t&&o.name===t.generic)return[r[s]];if("option"in t){const a=ge.resolveGenericArgs({type:t.option,typeDef:e,genericArgs:r,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{option:a[0].type}}]}if("vec"in t){const a=ge.resolveGenericArgs({type:t.vec,typeDef:e,genericArgs:r,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{vec:a[0].type}}]}if("array"in t){const[a,u]=t.array,f=typeof u=="object",h=ge.resolveGenericArgs({type:a,typeDef:e,genericArgs:r,isDefined:i});if(h){for(const y in e.generics.slice(+s)){const _=+s+ +y;f&&e.generics[_].name===u.generic&&h.push(r[_])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(f&&o.name===u.generic){const y=r[s];return i?[{kind:"type",type:{array:[a,+y.value]}}]:[y]}return null}if("defined"in t)return t.defined.generics?t.defined.generics.flatMap(a=>{switch(a.kind){case"type":return ge.resolveGenericArgs({type:a.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[a]}}).filter(a=>a!==null):null}return null}}class m7{constructor(t){this.idl=t;const e=t.instructions.map(r=>{const i=r.name,s=r.args.map(a=>ge.fieldLayout(a,t.types)),o=Yt.struct(s,i);return[i,{discriminator:r.discriminator,layout:o}]});this.ixLayouts=new Map(e)}encode(t,e){const r=kt.alloc(1e3),i=this.ixLayouts.get(t);if(!i)throw new Error(`Unknown method: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s);return kt.concat([kt.from(i.discriminator),o])}decode(t,e="hex"){typeof t=="string"&&(t=e==="hex"?kt.from(t,"hex"):On.decode(t));for(const[r,i]of this.ixLayouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(kt.from(i.discriminator)))return{name:r,data:i.layout.decode(t.subarray(s.length))}}return null}format(t,e){return Gr.format(t,e,this.idl)}}class Gr{static format(t,e,r){const i=r.instructions.find(u=>t.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Gr.formatIdlType(u.type),data:Gr.formatIdlData(u,t.data[u.name],r.types)})),o=Gr.flattenIdlAccounts(i.accounts),a=e.map((u,f)=>f<o.length?{name:o[f].name,...u}:{name:void 0,...u});return{args:s,accounts:a}}static formatIdlType(t){if(typeof t=="string")return t;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("coption"in t)return`COption<${this.formatIdlType(t.coption)}>`;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;if("defined"in t){const e=t.defined.name;if(t.defined.generics){const r=t.defined.generics.map(i=>{switch(i.kind){case"type":return Gr.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${e}<${r}>`}return e}throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if(typeof t.type=="string")return e.toString();if("vec"in t.type)return"["+e.map(i=>this.formatIdlData({name:"",type:t.type.vec},i,r)).join(", ")+"]";if("option"in t.type)return e===null?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if("defined"in t.type){if(!r)throw new Error("User defined types not provided");const i=t.type.defined.name,s=r.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Gr.formatIdlDataDefined(s,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+Su(t.type.fields,()=>"",i=>Object.entries(e).map(([s,o])=>{const a=i.find(u=>u.name===s);if(!a)throw new Error(`Field not found: ${s}`);return s+": "+Gr.formatIdlData(a,o,r)}).join(", "),i=>Object.entries(e).map(([s,o])=>s+": "+Gr.formatIdlData({name:"",type:i[s]},o,r)).join(", "))+" }";case"enum":{const i=Object.keys(e)[0],s=t.type.variants.find(a=>a.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=e[i];return Su(s.fields,()=>i,a=>{const u=Object.keys(o).map(f=>{const h=o[f],y=a.find(_=>_.name===f);if(!y)throw new Error(`Field not found: ${f}`);return f+": "+Gr.formatIdlData(y,h,r)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([f,h])=>f+": "+Gr.formatIdlData({name:"",type:a[f]},h,r)).join(", ");return`${i} { ${u} }`})}case"type":return Gr.formatIdlType(t.type.alias)}}static flattenIdlAccounts(t,e){return t.map(r=>{const i=w7(r.name);if(r.hasOwnProperty("accounts")){const s=e?`${e} > ${i}`:i;return Gr.flattenIdlAccounts(r.accounts,s)}else return{...r,name:e?`${e} > ${i}`:i}}).flat()}}function w7(n){const t=n.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}class b7{constructor(t){if(this.idl=t,!t.accounts){this.accountLayouts=new Map;return}const e=t.types;if(!e)throw new Error("Accounts require `idl.types`");const r=t.accounts.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:ge.typeDefLayout({typeDef:s,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){const r=kt.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s),a=this.accountDiscriminator(t);return kt.concat([a,o])}decode(t,e){const r=this.accountDiscriminator(t);if(r.compare(e.slice(0,r.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){for(const[e,r]of this.accountLayouts)if(t.subarray(0,r.discriminator.length).equals(kt.from(r.discriminator)))return this.decodeUnchecked(e,t);throw new Error("Account not found")}decodeUnchecked(t,e){const r=this.accountDiscriminator(t),i=e.subarray(r.length),s=this.accountLayouts.get(t);if(!s)throw new Error(`Unknown account: ${t}`);return s.layout.decode(i)}memcmp(t,e){const r=this.accountDiscriminator(t);return{offset:0,bytes:On.encode(e?kt.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+ge.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;const r=(e=this.idl.accounts)===null||e===void 0?void 0:e.find(i=>i.name===t);if(!r)throw new Error(`Account not found: ${t}`);return kt.from(r.discriminator)}}class _7{constructor(t){if(!t.events){this.layouts=new Map;return}const e=t.types;if(!e)throw new Error("Events require `idl.types`");const r=t.events.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:ge.typeDefLayout({typeDef:s,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=Vx(t)}catch{return null}for(const[r,i]of this.layouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(kt.from(i.discriminator)))return{name:r,data:i.layout.decode(e.subarray(s.length))}}return null}}class A7{constructor(t){const e=t.types;if(!e){this.typeLayouts=new Map;return}const r=e.filter(i=>!i.generics).map(i=>[i.name,ge.typeDefLayout({typeDef:i,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){const r=kt.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const s=i.encode(e,r);return r.slice(0,s)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class RR{constructor(t){this.instruction=new m7(t),this.accounts=new b7(t),this.events=new _7(t),this.types=new A7(t)}}class Tr{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var G0=Tr;function E7(n,t){return t.property?n+"["+t.property+"]":n}class Ga extends Tr{isCount(){throw new Error("ExternalLayout is abstract")}}class IR extends Ga{constructor(t,e,r){if(!(t instanceof Tr))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof V0||this.layout instanceof SR}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}}class V0 extends Tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class SR extends Tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const zm=Math.pow(2,32);function kR(n){const t=Math.floor(n/zm),e=n-t*zm;return{hi32:t,lo32:e}}function TR(n,t){return n*zm+t}class v7 extends Tr{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return TR(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=kR(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}}class x7 extends Tr{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return TR(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=kR(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}}class R7 extends Tr{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Tr,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class OR{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class NR extends OR{constructor(t,e){if(!(t instanceof Ga&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class CR extends Tr{constructor(t,e,r){const i=t instanceof V0||t instanceof SR;if(i)t=new NR(new IR(t));else if(t instanceof Ga&&t.isCount())t=new NR(t);else if(!(t instanceof OR))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Tr))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+a)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new I7(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class I7 extends Tr{constructor(t,e,r,i){if(!(t instanceof CR))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Tr))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class S7 extends Tr{constructor(t,e){if(!(t instanceof Ga&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ga||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Ga&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(E7("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Ga&&this.length.encode(i,e,r),i}}var k7=(n,t,e)=>new IR(n,t,e),T7=n=>new V0(1,n),Bs=n=>new V0(4,n),O7=n=>new v7(n),Ps=n=>new x7(n),Bn=(n,t,e)=>new R7(n,t,e),BR=(n,t,e)=>new CR(n,t,e),sh=(n,t)=>new S7(n,t);class N7 extends G0{constructor(t){super(-1,t),this.property=t,this.layout=Bn([Bs("length"),Bs("lengthPadding"),sh(k7(Bs(),-8),"chars")],this.property)}encode(t,e,r=0){if(t==null)return this.layout.span;const i={chars:Zt.from(t,"utf8")};return this.layout.encode(i,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return Bs().span+Bs().span+new As(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function K0(n){return new N7(n)}function ri(n){return sh(32,n)}const Vr=BR(Bs("instruction"));Vr.addVariant(0,Bn([Ps("lamports"),Ps("space"),ri("owner")]),"createAccount"),Vr.addVariant(1,Bn([ri("owner")]),"assign"),Vr.addVariant(2,Bn([Ps("lamports")]),"transfer"),Vr.addVariant(3,Bn([ri("base"),K0("seed"),Ps("lamports"),Ps("space"),ri("owner")]),"createAccountWithSeed"),Vr.addVariant(4,Bn([ri("authorized")]),"advanceNonceAccount"),Vr.addVariant(5,Bn([Ps("lamports")]),"withdrawNonceAccount"),Vr.addVariant(6,Bn([ri("authorized")]),"initializeNonceAccount"),Vr.addVariant(7,Bn([ri("authorized")]),"authorizeNonceAccount"),Vr.addVariant(8,Bn([Ps("space")]),"allocate"),Vr.addVariant(9,Bn([ri("base"),K0("seed"),Ps("space"),ri("owner")]),"allocateWithSeed"),Vr.addVariant(10,Bn([ri("base"),K0("seed"),ri("owner")]),"assignWithSeed"),Vr.addVariant(11,Bn([Ps("lamports"),K0("seed"),ri("owner")]),"transferWithSeed"),Math.max(...Object.values(Vr.registry).map(n=>n.span));class C7 extends G0{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function PR(n){return new C7(sh(32),t=>new pt(t),t=>t.toBuffer(),n)}Bn([Bs("version"),Bs("state"),PR("authorizedPubkey"),PR("nonce"),Bn([O7("lamportsPerSignature")],"feeCalculator")]),new pt("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new pt("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var MR={exports:{}};(function(n,t){var e=typeof self<"u"?self:p7,r=function(){function s(){this.fetch=!1,this.DOMException=e.DOMException}return s.prototype=e,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 f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&f.indexOf(Object.prototype.toString.call(p))>-1};function y(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function _(p){return typeof p!="string"&&(p=String(p)),p}function w(p){var m={next:function(){var v=p.shift();return{done:v===void 0,value:v}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function R(p){this.map={},p instanceof R?p.forEach(function(m,v){this.append(v,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}R.prototype.append=function(p,m){p=y(p),m=_(m);var v=this.map[p];this.map[p]=v?v+", "+m:m},R.prototype.delete=function(p){delete this.map[y(p)]},R.prototype.get=function(p){return p=y(p),this.has(p)?this.map[p]:null},R.prototype.has=function(p){return this.map.hasOwnProperty(y(p))},R.prototype.set=function(p,m){this.map[y(p)]=_(m)},R.prototype.forEach=function(p,m){for(var v in this.map)this.map.hasOwnProperty(v)&&p.call(m,this.map[v],v,this)},R.prototype.keys=function(){var p=[];return this.forEach(function(m,v){p.push(v)}),w(p)},R.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),w(p)},R.prototype.entries=function(){var p=[];return this.forEach(function(m,v){p.push([v,m])}),w(p)},a.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function T(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function I(p){return new Promise(function(m,v){p.onload=function(){m(p.result)},p.onerror=function(){v(p.error)}})}function B(p){var m=new FileReader,v=I(m);return m.readAsArrayBuffer(p),v}function H(p){var m=new FileReader,v=I(m);return m.readAsText(p),v}function U(p){for(var m=new Uint8Array(p),v=new Array(m.length),k=0;k<m.length;k++)v[k]=String.fromCharCode(m[k]);return v.join("")}function G(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function W(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p: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=G(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=G(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):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=T(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?T(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var p=T(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(U(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(it)}),this.json=function(){return this.text().then(JSON.parse)},this}var X=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(p){var m=p.toUpperCase();return X.indexOf(m)>-1?m:p}function J(p,m){m=m||{};var v=m.body;if(p instanceof J){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new R(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!v&&p._bodyInit!=null&&(v=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new R(m.headers)),this.method=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&v)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(v)}J.prototype.clone=function(){return new J(this,{body:this._bodyInit})};function it(p){var m=new FormData;return p.trim().split("&").forEach(function(v){if(v){var k=v.split("="),N=k.shift().replace(/\+/g," "),M=k.join("=").replace(/\+/g," ");m.append(decodeURIComponent(N),decodeURIComponent(M))}}),m}function ut(p){var m=new R,v=p.replace(/\r?\n[\t ]+/g," ");return v.split(/\r?\n/).forEach(function(k){var N=k.split(":"),M=N.shift().trim();if(M){var z=N.join(":").trim();m.append(M,z)}}),m}W.call(J.prototype);function rt(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new R(m.headers),this.url=m.url||"",this._initBody(p)}W.call(rt.prototype),rt.prototype.clone=function(){return new rt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},rt.error=function(){var p=new rt(null,{status:0,statusText:""});return p.type="error",p};var ot=[301,302,303,307,308];rt.redirect=function(p,m){if(ot.indexOf(m)===-1)throw new RangeError("Invalid status code");return new rt(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,v){this.message=m,this.name=v;var k=Error(m);this.stack=k.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function C(p,m){return new Promise(function(v,k){var N=new J(p,m);if(N.signal&&N.signal.aborted)return k(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function z(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ut(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var A="response"in M?M.response:M.responseText;v(new rt(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(N.method,N.url,!0),N.credentials==="include"?M.withCredentials=!0:N.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),N.headers.forEach(function(P,A){M.setRequestHeader(A,P)}),N.signal&&(N.signal.addEventListener("abort",z),M.onreadystatechange=function(){M.readyState===4&&N.signal.removeEventListener("abort",z)}),M.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return C.polyfill=!0,s.fetch||(s.fetch=C,s.Headers=R,s.Request=J,s.Response=rt),o.Headers=R,o.Request=J,o.Response=rt,o.fetch=C,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,n.exports=t})(MR,MR.exports),Yt.rustEnum([Yt.struct([],"uninitialized"),Yt.struct([Yt.option(Yt.publicKey(),"authorityAddress")],"buffer"),Yt.struct([Yt.publicKey("programdataAddress")],"program"),Yt.struct([Yt.u64("slot"),Yt.option(Yt.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,Yt.u32());const Gm="Program log: ",LR="Program data: ",B7=Gm.length,P7=LR.length;class M7{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new UR(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e,r){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,((i=this._eventListeners.get(t))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[t,e]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,a)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const f=this._eventListeners.get(u.name);f&&f.forEach(h=>{const y=this._eventCallbacks.get(h);if(y){const[,_]=y;_(u.data,a.slot,o.signature)}})}},r)),s}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let i=this._eventListeners.get(r);if(!i)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),i=i.filter(s=>s!==t),this._eventListeners.set(r,i),i.length===0&&this._eventListeners.delete(r),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class UR{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new U7(t),i=new L7;let s=r.next();for(;s!==null;){let[o,a,u]=this.handleLog(i,s,e);o&&(yield o),a&&i.push(a),u&&i.pop(),s=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(Gm)||t.startsWith(LR)){const r=t.startsWith(Gm)?t.slice(B7):t.slice(P7),i=this.coder.events.decode(r);if(e&&i===null)throw new Error(`Unable to decode event ${r}`);return[i,null,!1]}else return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return e.match(/^Program (.*) success/g)!==null?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class L7{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class U7{constructor(t){this.logs=t}next(){if(this.logs.length===0)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}function j0(n,t){var e,r;let i={};const s=n.args?n.args.length:0;if(t.length>s){if(t.length!==s+1)throw new Error(`provided too many arguments ${t} to instruction ${n==null?void 0:n.name} expecting: ${(r=(e=n.args)===null||e===void 0?void 0:e.map(o=>o.name))!==null&&r!==void 0?r:[]}`);i=t.pop()}return[t,i]}class W0{static build(t,e,r){if(t.name==="_inner")throw new Co("the _inner name is reserved");const i=(...s)=>{const[o,a]=j0(t,[...s]);Kx(t.accounts,a.accounts),D7(t,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),vR("debug-logs")&&console.log("Outgoing account metas:",u),new Me({keys:u,programId:r,data:e(t.name,YF(t,...o))})};return i.accounts=s=>W0.accountsArray(s,t.accounts,r,t.name),i}static accountsArray(t,e,r,i){return t?e.map(s=>{if(ko(s)){const h=t[s.name];return W0.accountsArray(h,s.accounts,r,i).flat()}let o;try{o=Ei(t[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const a=s.optional&&o.equals(r),u=!!(s.writable&&!a),f=!!(s.signer&&!a);return{pubkey:o,isWritable:u,isSigner:f}}).flat():[]}}function D7(n,...t){}class F7{static build(t,e){return(...i)=>{var s,o,a;const[,u]=j0(t,[...i]),f=new Ne;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>f.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>f.add(h)),f.add(e(...i)),(a=u.postInstructions)===null||a===void 0||a.forEach(h=>f.add(h)),f}}}class $7{static build(t,e,r,i){return async(...o)=>{var a;const u=e(...o),[,f]=j0(t,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(a=f.signers)!==null&&a!==void 0?a:[],f.options)}catch(h){throw xR(h,r)}}}}class H7{static build(t,e,r,i){var s;return((s=t.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new z7(t,a,r,i,e),o),{})}}class z7{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(t,e,r,i,s){this._idlAccount=e,this._programId=r,this._provider=i??Hm(),this._coder=s??new RR(t),this._size=this._coder.accounts.size(e.name)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:i,context:s}=r;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:i}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:i}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(i=>i?i.data:null)}async fetchMultipleAndContext(t,e){return(await a7(this._provider.connection,t.map(i=>Ei(i)),e)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Zt?t:void 0),r=[];return(e==null?void 0:e.offset)!=null&&(e==null?void 0:e.bytes)!=null&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(e==null?void 0:e.dataSize)!=null&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(t,e){const r=oh.get(t.toString());if(r)return r.ee;const i=new zF;t=Ei(t);const s=this._provider.connection.onAccountChange(t,o=>{const a=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",a)},e);return oh.set(t.toString(),{ee:i,listener:s}),i}async unsubscribe(t){let e=oh.get(t.toString());if(!e){console.warn("Address is not subscribed");return}oh&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{oh.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){const r=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Cn.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:e??r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(e??r),programId:this._programId})}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(Ei(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(Ei(t),e)}}const oh=new Map;class G7{static build(t,e,r,i,s,o,a){return async(...f)=>{var h;const y=e(...f),[,_]=j0(t,[...f]);let w;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{w=await i.simulate(y,_.signers,(h=_.options)===null||h===void 0?void 0:h.commitment)}catch(I){throw xR(I,r)}if(w===void 0)throw new Error("Unable to simulate transaction");const R=w.logs;if(!R)throw new Error("Simulated logs not found");const T=[];if(a.events){let I=new UR(o,s);for(const B of I.parseLogs(R))T.push(B)}return{events:T,raw:R}}}}function Vm(n){return new DR(sh(8),t=>K7.fromBuffer(t),t=>t.toBuffer(),n)}function Z0(n){return new DR(sh(32),t=>new pt(t),t=>t.toBuffer(),n)}function Km(n,t){return new V7(n,t)}class DR extends G0{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class V7 extends G0{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=Bs()}encode(t,e,r=0){return t==null?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(r===0)return null;if(r===1)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}let K7=class oO extends As{toBuffer(){const t=super.toArray().reverse(),e=Zt.from(t);if(e.length===8)return e;if(e.length>=8)throw new Error("u64 too large");const r=Zt.alloc(8);return e.copy(r),r}static fromBuffer(t){if(t.length!==8)throw new Error(`Invalid buffer length: ${t.length}`);return new oO([...t].reverse().map(e=>`00${e.toString(16)}`.slice(-2)).join(""),16)}};const j7=Bn([Z0("mint"),Z0("owner"),Vm("amount"),Km(Z0(),"delegate"),(n=>{const t=BR(T7("discriminator"),null,n);return t.addVariant(0,Bn([]),"uninitialized"),t.addVariant(1,Bn([]),"initialized"),t.addVariant(2,Bn([]),"frozen"),t})("state"),Km(Vm(),"isNative"),Vm("delegatedAmount"),Km(Z0(),"closeAuthority")]);function W7(n){return j7.decode(n)}class Z7{constructor(t,e,r,i,s,o,a,u){this._args=t,this._accounts=e,this._provider=r,this._programId=i,this._idlIx=s,this._idlTypes=a,this._customResolver=u,this._accountStore=new q7(r,o,i)}args(t){this._args=t}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let t=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(t++,t===16){const e=o=>ko(o)?o.accounts.some(e):!!(o.address||o.pda||o.relations),r=(o,a=[],u=[])=>{for(const f of o)ko(f)?u.push(...r(f.accounts,[...a,f.name])):u.push([...a,f.name]);return u},i=this._idlIx.accounts.filter(e),s=r(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(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce((r,i)=>r&&r[i],this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach((i,s)=>{var o;s===t.length-1&&(r[i]=e),r[i]=(o=r[i])!==null&&o!==void 0?o:{},r=r[i]})}resolveOptionalsHelper(t,e){const r={};for(const i of e){const s=i.name,o=t[s];o!==void 0&&(FR(o)?ko(i)?r[s]=this.resolveOptionalsHelper(o,i.accounts):r[s]=$R(o):o!==null?r[s]=Ei(o):i.optional&&(r[s]=this._programId))}return r}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveEventCpi(t,e=[]){for(const r in t){const i=t[r];ko(i)&&this.resolveEventCpi(i.accounts,[...e,i.name]);const s=+r+1;if(s===t.length)return;const o=t[r].name,a=t[s].name;if(o==="eventAuthority"&&a==="program"){const u=[...e,o],f=[...e,a];this.get(u)||this.set(u,pt.findProgramAddressSync([Zt.from("__event_authority")],this._programId)[0]),this.get(f)||this.set(f,this._programId);return}}}resolveConst(t,e=[]){for(const r of t){const i=r.name;if(ko(r))this.resolveConst(r.accounts,[...e,i]);else{const s=r;if((s.signer||s.address)&&!this.get([...e,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...e,i],this._provider.wallet.publicKey)}s.address&&this.set([...e,i],Ei(s.address))}}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(const i of t){const s=i.name;if(ko(i))r+=await this.resolvePdasAndRelations(i.accounts,[...e,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...e,s])){r++;try{if(o.pda){const a=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,e)));if(a.some(h=>!h))continue;const u=await this.parseProgramId(o,e),[f]=pt.findProgramAddressSync(a,u);this.set([...e,s],f)}}catch{}try{if(o.relations){const a=this.get([...e,o.relations[0]]);if(a){const u=await this._accountStore.fetchAccount({publicKey:a});this.set([...e,s],u[s])}}}catch{}}}}return r}async parseProgramId(t,e=[]){var r;if(!(!((r=t.pda)===null||r===void 0)&&r.program))return this._programId;const i=await this.toBuffer(t.pda.program,e);if(!i)throw new Error(`Program seed not resolved: ${t.name}`);return new pt(i)}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed: ${t}`)}}toBufferConst(t){return this.toBufferValue("bytes",t.value)}async toBufferArg(t){const[e,...r]=t.path.split("."),i=this._idlIx.args.findIndex(a=>a.name===e);if(i===-1)throw new Error(`Unable to find argument for seed: ${e}`);const s=r.reduce((a,u)=>(a??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,r);return this.toBufferValue(o,s)}async toBufferAccount(t,e=[]){const[r,...i]=t.path.split("."),s=this.get([...e,r]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!t.account)throw new Error(`Seed account is required in order to resolve type: ${t.path}`);let a=await this._accountStore.fetchAccount({publicKey:s,name:t.account}),u=i;for(;u.length>0;)a=a[u[0]],u=u.slice(1);if(a===void 0)return;const f=this.getType({defined:{name:t.account}},i);return this.toBufferValue(f,a)}toBufferValue(t,e){switch(t){case"u8":case"i8":return Zt.from([e]);case"u16":case"i16":return new As(e).toArrayLike(Zt,"le",2);case"u32":case"i32":return new As(e).toArrayLike(Zt,"le",4);case"u64":case"i64":return new As(e).toArrayLike(Zt,"le",8);case"u128":case"i128":return new As(e).toArrayLike(Zt,"le",16);case"u256":case"i256":return new As(e).toArrayLike(Zt,"le",32);case"string":return Zt.from(e);case"pubkey":return e.toBuffer();case"bytes":return Zt.from(e);default:if(t!=null&&t.array)return Zt.from(e);throw new Error(`Unexpected seed type: ${t}`)}}getType(t,e=[]){var r;const i=(r=t==null?void 0:t.defined)===null||r===void 0?void 0:r.name;if(i){if(i==="tokenAccount")switch(e.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${e}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...a]=e,f=s.type.fields.find(h=>h.name===o);if(!f)throw new Error(`Field not found: ${o}`);return this.getType(f.type,a)}return t}}class q7{constructor(t,e,r){this._provider=t,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async fetchAccount({publicKey:t,name:e}){const r=t.toBase58();if(!this._cache.has(r)){const i=await this._provider.connection.getAccountInfo(t);if(i===null)throw new Error(`Account not found: ${r}`);if(e==="tokenAccount"){const s=W7(i.data);this._cache.set(r,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const a=o.coder.accounts.decodeAny(i.data);this._cache.set(r,a)}}}}return this._cache.get(r)}async getAccountsNs(t){const e=t.toBase58();if(!this._idls[e]){const r=await Tu.fetchIdl(t,this._provider);if(r){const i=new Tu(r,this._provider);this._idls[e]=i.account}}return this._idls[e]}}class Q7{static build(t,e,r,i,s,o,a,u,f,h,y){return(..._)=>new Y7(_,i,s,o,a,u,t,e,r,f,h,y)}}function FR(n){return typeof n=="object"&&n!==null&&!("_bn"in n)}function $R(n,t){const e={};for(const r in n){const i=n[r];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");e[r]=FR(i)?$R(i):Ei(i)}return e}class Y7{constructor(t,e,r,i,s,o,a,u,f,h,y,_){this._args=t,this._ixFn=e,this._txFn=r,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new Z7(t,this._accounts,a,u,f,h,y,_)}args(t){this._args=t,this._accountsResolver.args(t)}accounts(t){return this.accountsPartial(t)}accountsPartial(t){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t,e=!1){return e?this._preInstructions=t.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async view(t){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpc(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{signature:await this.rpc(t),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class J7{static build(t,e,r,i){const s=e.accounts.find(u=>u.writable),o=!!e.returns;return s||!o?void 0:async(...u)=>{let f=await r(...u);const h=`Program return: ${t} `;let y=f.raw.find(T=>T.startsWith(h));if(!y)throw new Error("View expected return log");let _=Vx(y.slice(h.length)),w=e.returns;if(!w)throw new Error("View expected return type");return ge.fieldLayout({type:w},i.types).decode(_)}}}class X7{static build(t,e,r,i,s){const o={},a={},u={},f={},h={},y={},_=QF(t),w=t.accounts?H7.build(t,e,r,i):{};return t.instructions.forEach(R=>{const T=W0.build(R,(X,j)=>e.instruction.encode(X,j),r),I=F7.build(R,T),B=$7.build(R,I,_,i),H=G7.build(R,I,_,i,e,r,t),U=J7.build(r,R,H,t),G=Q7.build(i,r,R,T,I,B,H,U,w,t.types||[],s==null?void 0:s(R)),W=R.name;a[W]=T,u[W]=I,o[W]=B,f[W]=H,h[W]=G,U&&(y[W]=U)}),[o,a,u,w,f,h,y]}}class Tu{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e=Hm(),r,i){this._idl=qF(t),this._rawIdl=t,this._provider=e,this._programId=Ei(t.address),this._coder=r??new RR(this._idl),this._events=new M7(this._programId,e,this._coder);const[s,o,a,u,f,h,y]=X7.build(this._idl,this._coder,this._programId,e,i);this.rpc=s,this.instruction=o,this.transaction=a,this.account=u,this.simulate=f,this.methods=h,this.views=y}static async at(t,e){const r=Ei(t),i=await Tu.fetchIdl(r,e);if(!i)throw new Error(`IDL not found for program: ${t.toString()}`);return new Tu(i,e)}static async fetchIdl(t,e){e=e??Hm();const r=Ei(t),i=await KF(r),s=await e.connection.getAccountInfo(i);if(!s)return null;let o=ZF(s.data.slice(8));const a=$F(o.data);return JSON.parse(VF(a))}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new pt("11111111111111111111111111111111");const t$="6.13.5";function e$(n,t,e){const r=t.split("|").map(s=>s.trim());for(let s=0;s<r.length;s++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===t)return}const i=new Error(`invalid value for type ${t}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${e}`,i.value=n,i}async function gr(n){const t=Object.keys(n);return(await Promise.all(t.map(r=>Promise.resolve(n[r])))).reduce((r,i,s)=>(r[t[s]]=i,r),{})}function $t(n,t,e){for(let r in t){let i=t[r];const s=e?e[r]:null;s&&e$(i,s,r),Object.defineProperty(n,r,{enumerable:!0,value:i,writable:!1})}}function Ou(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ou).join(", ")+" ]";if(n instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let r=0;r<n.length;r++)e+=t[n[r]>>4],e+=t[n[r]&15];return e}if(typeof n=="object"&&typeof n.toJSON=="function")return Ou(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const t=Object.keys(n);return t.sort(),"{ "+t.map(e=>`${Ou(e)}: ${Ou(n[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function qn(n,t){return n&&n.code===t}function jm(n){return qn(n,"CALL_EXCEPTION")}function Ye(n,t,e){let r=n;{const s=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${Ou(e)}`);for(const o in e){if(o==="shortMessage")continue;const a=e[o];s.push(o+"="+Ou(a))}}s.push(`code=${t}`),s.push(`version=${t$}`),s.length&&(n+=" ("+s.join(", ")+")")}let i;switch(t){case"INVALID_ARGUMENT":i=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(n);break;default:i=new Error(n)}return $t(i,{code:t}),e&&Object.assign(i,e),i.shortMessage==null&&$t(i,{shortMessage:r}),i}function ht(n,t,e,r){if(!n)throw Ye(t,e,r)}function K(n,t,e,r){ht(n,t,"INVALID_ARGUMENT",{argument:e,value:r})}function HR(n,t,e){e==null&&(e=""),e&&(e=": "+e),ht(n>=t,"missing argument"+e,"MISSING_ARGUMENT",{count:n,expectedCount:t}),ht(n<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((n,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(t)}catch{}return n},[]);function q0(n,t,e){if(e==null&&(e=""),n!==t){let r=e,i="new";e&&(r+=".",i+=" "+e),ht(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function zR(n,t,e){if(n instanceof Uint8Array)return e?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let i=2;for(let s=0;s<r.length;s++)r[s]=parseInt(n.substring(i,i+2),16),i+=2;return r}K(!1,"invalid BytesLike value",t||"value",n)}function we(n,t){return zR(n,t,!1)}function yr(n,t){return zR(n,t,!0)}function Ge(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&n.length!==2+2*t||t===!0&&n.length%2!==0)}function Wm(n){return Ge(n,!0)||n instanceof Uint8Array}const GR="0123456789abcdef";function Tt(n){const t=we(n);let e="0x";for(let r=0;r<t.length;r++){const i=t[r];e+=GR[(i&240)>>4]+GR[i&15]}return e}function xn(n){return"0x"+n.map(t=>Tt(t).substring(2)).join("")}function Nu(n){return Ge(n,!0)?(n.length-2)/2:we(n).length}function ln(n,t,e){const r=we(n);return e!=null&&e>r.length&&ht(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:e}),Tt(r.slice(t??0,e??r.length))}function VR(n,t,e){const r=we(n);ht(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),e?i.set(r,t-r.length):i.set(r,0),Tt(i)}function Va(n,t){return VR(n,t,!0)}function n$(n,t){return VR(n,t,!1)}const Q0=BigInt(0),vi=BigInt(1),Cu=9007199254740991;function r$(n,t){const e=Y0(n,"value"),r=BigInt(ie(t,"width"));if(ht(e>>r===Q0,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),e>>r-vi){const i=(vi<<r)-vi;return-((~e&i)+vi)}return e}function KR(n,t){let e=Ct(n,"value");const r=BigInt(ie(t,"width")),i=vi<<r-vi;if(e<Q0){e=-e,ht(e<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const s=(vi<<r)-vi;return(~e&s)+vi}else ht(e<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return e}function ah(n,t){const e=Y0(n,"value"),r=BigInt(ie(t,"bits"));return e&(vi<<r)-vi}function Ct(n,t){switch(typeof n){case"bigint":return n;case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-Cu&&n<=Cu,"overflow",t||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(e){K(!1,`invalid BigNumberish string: ${e.message}`,t||"value",n)}}K(!1,"invalid BigNumberish value",t||"value",n)}function Y0(n,t){const e=Ct(n,t);return ht(e>=Q0,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),e}const jR="0123456789abcdef";function Zm(n){if(n instanceof Uint8Array){let t="0x0";for(const e of n)t+=jR[e>>4],t+=jR[e&15];return BigInt(t)}return Ct(n)}function ie(n,t){switch(typeof n){case"bigint":return K(n>=-Cu&&n<=Cu,"overflow",t||"value",n),Number(n);case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-Cu&&n<=Cu,"overflow",t||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return ie(BigInt(n),t)}catch(e){K(!1,`invalid numeric string: ${e.message}`,t||"value",n)}}K(!1,"invalid numeric value",t||"value",n)}function i$(n){return ie(Zm(n))}function Bo(n,t){let r=Y0(n,"value").toString(16);if(t==null)r.length%2&&(r="0"+r);else{const i=ie(t,"width");for(ht(i*2>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<i*2;)r="0"+r}return"0x"+r}function mr(n){const t=Y0(n,"value");if(t===Q0)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const r=new Uint8Array(e.length/2);for(let i=0;i<r.length;i++){const s=i*2;r[i]=parseInt(e.substring(s,s+2),16)}return r}function Bu(n){let t=Tt(Wm(n)?n:mr(n)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}const WR="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const ZR=BigInt(58);function s$(n){const t=we(n);let e=Zm(t),r="";for(;e;)r=WR[Number(e%ZR)]+r,e/=ZR;for(let i=0;i<t.length&&!t[i];i++)r=WR[0]+r;return r}function o$(n){n=atob(n);const t=new Uint8Array(n.length);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return we(t)}function a$(n){const t=we(n);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}class qR{constructor(t,e,r){Z(this,"filter");Z(this,"emitter");Y(this,el);F(this,el,e),$t(this,{emitter:t,filter:r})}async removeListener(){S(this,el)!=null&&await this.emitter.off(this.filter,S(this,el))}}el=new WeakMap;function c$(n,t,e,r,i){K(!1,`invalid codepoint at offset ${t}; ${n}`,"bytes",e)}function QR(n,t,e,r,i){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let s=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)s++;return s}return n==="OVERRUN"?e.length-t-1:0}function u$(n,t,e,r,i){return n==="OVERLONG"?(K(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),QR(n,t,e))}const l$=Object.freeze({error:c$,ignore:QR,replace:u$});function f$(n,t){t==null&&(t=l$.error);const e=we(n,"bytes"),r=[];let i=0;for(;i<e.length;){const s=e[i++];if(!(s>>7)){r.push(s);continue}let o=null,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+=t("UNEXPECTED_CONTINUE",i-1,e,r):i+=t("BAD_PREFIX",i-1,e,r);continue}if(i-1+o>=e.length){i+=t("OVERRUN",i-1,e,r);continue}let u=s&(1<<8-o-1)-1;for(let f=0;f<o;f++){let h=e[i];if((h&192)!=128){i+=t("MISSING_CONTINUE",i,e,r),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=t("OUT_OF_RANGE",i-1-o,e,r,u);continue}if(u>=55296&&u<=57343){i+=t("UTF16_SURROGATE",i-1-o,e,r,u);continue}if(u<=a){i+=t("OVERLONG",i-1-o,e,r,u);continue}r.push(u)}}return r}function Ms(n,t){K(typeof n=="string","invalid string value","str",n);let e=[];for(let r=0;r<n.length;r++){const i=n.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);K(r<n.length&&(s&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((i&1023)<<10)+(s&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return new Uint8Array(e)}function h$(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function J0(n,t){return h$(f$(n,t))}function YR(n){async function t(e,r){ht(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const i=e.url.split(":")[0].toLowerCase();ht(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ht(i==="https"||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,a=setTimeout(()=>{s=Ye("request timeout","TIMEOUT"),o.abort()},e.timeout);r&&r.addListener(()=>{s=Ye("request cancelled","CANCELLED"),o.abort()});const u={method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:o.signal};let f;try{f=await fetch(e.url,u)}catch(w){throw clearTimeout(a),s||w}clearTimeout(a);const h={};f.headers.forEach((w,R)=>{h[R.toLowerCase()]=w});const y=await f.arrayBuffer(),_=y==null?null:new Uint8Array(y);return{statusCode:f.status,statusMessage:f.statusText,headers:h,body:_}}return t}const d$=12,p$=250;let JR=YR();const g$=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),y$=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let qm=!1;async function XR(n,t){try{const e=n.match(g$);if(!e)throw new Error("invalid data");return new Po(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?o$(e[3]):w$(e[3]))}catch{return new Po(599,"BAD REQUEST (invalid data: URI)",{},null,new Ls(n))}}function tI(n){async function t(e,r){try{const i=e.match(y$);if(!i)throw new Error("invalid link");return new Ls(`${n}${i[2]}`)}catch{return new Po(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ls(e))}}return t}const X0={data:XR,ipfs:tI("https://gateway.ipfs.io/ipfs/")},eI=new WeakMap;class m${constructor(t){Y(this,sc);Y(this,zo);F(this,sc,[]),F(this,zo,!1),eI.set(t,()=>{if(!S(this,zo)){F(this,zo,!0);for(const e of S(this,sc))setTimeout(()=>{e()},0);F(this,sc,[])}})}addListener(t){ht(!S(this,zo),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),S(this,sc).push(t)}get cancelled(){return S(this,zo)}checkSignal(){ht(!this.cancelled,"cancelled","CANCELLED",{})}}sc=new WeakMap,zo=new WeakMap;function tp(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const Lp=class Lp{constructor(t){Y(this,uc);Y(this,nl);Y(this,rl);Y(this,ki);Y(this,Ks);Y(this,il);Y(this,sl);Y(this,$n);Y(this,jr);Y(this,js);Y(this,oc);Y(this,ac);Y(this,cc);Y(this,ss);Y(this,Ti);Y(this,Go);F(this,sl,String(t)),F(this,nl,!1),F(this,rl,!0),F(this,ki,{}),F(this,Ks,""),F(this,il,3e5),F(this,Ti,{slotInterval:p$,maxAttempts:d$}),F(this,Go,null)}get url(){return S(this,sl)}set url(t){F(this,sl,String(t))}get body(){return S(this,$n)==null?null:new Uint8Array(S(this,$n))}set body(t){if(t==null)F(this,$n,void 0),F(this,jr,void 0);else if(typeof t=="string")F(this,$n,Ms(t)),F(this,jr,"text/plain");else if(t instanceof Uint8Array)F(this,$n,t),F(this,jr,"application/octet-stream");else if(typeof t=="object")F(this,$n,Ms(JSON.stringify(t))),F(this,jr,"application/json");else throw new Error("invalid body")}hasBody(){return S(this,$n)!=null}get method(){return S(this,Ks)?S(this,Ks):this.hasBody()?"POST":"GET"}set method(t){t==null&&(t=""),F(this,Ks,String(t).toUpperCase())}get headers(){const t=Object.assign({},S(this,ki));return S(this,js)&&(t.authorization=`Basic ${a$(Ms(S(this,js)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),t["content-type"]==null&&S(this,jr)&&(t["content-type"]=S(this,jr)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){S(this,ki)[String(t).toLowerCase()]=String(e)}clearHeaders(){F(this,ki,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return S(this,js)||null}setCredentials(t,e){K(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,js,`${t}:${e}`)}get allowGzip(){return S(this,rl)}set allowGzip(t){F(this,rl,!!t)}get allowInsecureAuthentication(){return!!S(this,nl)}set allowInsecureAuthentication(t){F(this,nl,!!t)}get timeout(){return S(this,il)}set timeout(t){K(t>=0,"timeout must be non-zero","timeout",t),F(this,il,t)}get preflightFunc(){return S(this,oc)||null}set preflightFunc(t){F(this,oc,t)}get processFunc(){return S(this,ac)||null}set processFunc(t){F(this,ac,t)}get retryFunc(){return S(this,cc)||null}set retryFunc(t){F(this,cc,t)}get getUrlFunc(){return S(this,Go)||JR}set getUrlFunc(t){F(this,Go,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${S(this,$n)?Tt(S(this,$n)):"null"}>`}setThrottleParams(t){t.slotInterval!=null&&(S(this,Ti).slotInterval=t.slotInterval),t.maxAttempts!=null&&(S(this,Ti).maxAttempts=t.maxAttempts)}send(){return ht(S(this,ss)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),F(this,ss,new m$(this)),yt(this,uc,_d).call(this,0,nI()+this.timeout,0,this,new Po(0,"",{},null,this))}cancel(){ht(S(this,ss)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=eI.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();ht(this.method==="GET"&&(e!=="https"||r!=="http")&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new Lp(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,F(i,ki,Object.assign({},S(this,ki))),S(this,$n)&&F(i,$n,new Uint8Array(S(this,$n))),F(i,jr,S(this,jr)),i}clone(){const t=new Lp(this.url);return F(t,Ks,S(this,Ks)),S(this,$n)&&F(t,$n,S(this,$n)),F(t,jr,S(this,jr)),F(t,ki,Object.assign({},S(this,ki))),F(t,js,S(this,js)),this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),F(t,oc,S(this,oc)),F(t,ac,S(this,ac)),F(t,cc,S(this,cc)),F(t,Ti,Object.assign({},S(this,Ti))),F(t,Go,S(this,Go)),t}static lockConfig(){qm=!0}static getGateway(t){return X0[t.toLowerCase()]||null}static registerGateway(t,e){if(t=t.toLowerCase(),t==="http"||t==="https")throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(qm)throw new Error("gateways locked");X0[t]=e}static registerGetUrl(t){if(qm)throw new Error("gateways locked");JR=t}static createGetUrlFunc(t){return YR()}static createDataGateway(){return XR}static createIpfsGatewayFunc(t){return tI(t)}};nl=new WeakMap,rl=new WeakMap,ki=new WeakMap,Ks=new WeakMap,il=new WeakMap,sl=new WeakMap,$n=new WeakMap,jr=new WeakMap,js=new WeakMap,oc=new WeakMap,ac=new WeakMap,cc=new WeakMap,ss=new WeakMap,Ti=new WeakMap,Go=new WeakMap,uc=new WeakSet,_d=async function(t,e,r,i,s){var h,y,_;if(t>=S(this,Ti).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ht(nI()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),r>0&&await b$(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in X0){const w=await X0[a](o.url,tp(S(i,ss)));if(w instanceof Po){let R=w;if(this.processFunc){tp(S(i,ss));try{R=await this.processFunc(o,R)}catch(T){(T.throttle==null||typeof T.stall!="number")&&R.makeServerError("error in post-processing function",T).assertOk()}}return R}o=w}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,tp(S(i,ss)));let f=new Po(u.statusCode,u.statusMessage,u.headers,u.body,i);if(f.statusCode===301||f.statusCode===302){try{const w=f.headers.location||"";return yt(h=o.redirect(w),uc,_d).call(h,t+1,e,0,i,f)}catch{}return f}else if(f.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,f,t))){const w=f.headers["retry-after"];let R=S(this,Ti).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return typeof w=="string"&&w.match(/^[1-9][0-9]*$/)&&(R=parseInt(w)),yt(y=o.clone(),uc,_d).call(y,t+1,e,R,i,f)}if(this.processFunc){tp(S(i,ss));try{f=await this.processFunc(o,f)}catch(w){(w.throttle==null||typeof w.stall!="number")&&f.makeServerError("error in post-processing function",w).assertOk();let R=S(this,Ti).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return w.stall>=0&&(R=w.stall),yt(_=o.clone(),uc,_d).call(_,t+1,e,R,i,f)}}return f};let Ls=Lp;const i1=class i1{constructor(t,e,r,i,s){Y(this,Ch);Y(this,Bh);Y(this,Ph);Y(this,Wr);Y(this,ol);Y(this,lc);F(this,Ch,t),F(this,Bh,e),F(this,Ph,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),F(this,Wr,i==null?null:new Uint8Array(i)),F(this,ol,s||null),F(this,lc,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${S(this,Wr)?Tt(S(this,Wr)):"null"}>`}get statusCode(){return S(this,Ch)}get statusMessage(){return S(this,Bh)}get headers(){return Object.assign({},S(this,Ph))}get body(){return S(this,Wr)==null?null:new Uint8Array(S(this,Wr))}get bodyText(){try{return S(this,Wr)==null?"":J0(S(this,Wr))}catch{ht(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ht(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(t,e){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);const i=new i1(599,r,this.headers,this.body,S(this,ol)||void 0);return F(i,lc,{message:t,error:e}),i}throwThrottleError(t,e){e==null?e=-1:K(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $t(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return S(this,Wr)!=null}get request(){return S(this,ol)}ok(){return S(this,lc).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=S(this,lc);t===""&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let i=null;try{S(this,Wr)&&(i=J0(S(this,Wr)))}catch{}ht(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Ch=new WeakMap,Bh=new WeakMap,Ph=new WeakMap,Wr=new WeakMap,ol=new WeakMap,lc=new WeakMap;let Po=i1;function nI(){return new Date().getTime()}function w$(n){return Ms(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function b$(n){return new Promise(t=>setTimeout(t,n))}function _$(n){let t=n.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function rI(n,t,e){let r=0;for(let i=0;i<e;i++)r=r*256+n[t+i];return r}function iI(n,t,e,r){const i=[];for(;e<t+1+r;){const s=sI(n,e);i.push(s.result),e+=s.consumed,ht(e<=t+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:t})}return{consumed:1+r,result:i}}function sI(n,t){ht(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const e=r=>{ht(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[t]>=248){const r=n[t]-247;e(t+1+r);const i=rI(n,t+1,r);return e(t+1+r+i),iI(n,t,t+1+r,r+i)}else if(n[t]>=192){const r=n[t]-192;return e(t+1+r),iI(n,t,t+1,r)}else if(n[t]>=184){const r=n[t]-183;e(t+1+r);const i=rI(n,t+1,r);e(t+1+r+i);const s=Tt(n.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:s}}else if(n[t]>=128){const r=n[t]-128;e(t+1+r);const i=Tt(n.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:_$(n[t])}}function ep(n){const t=we(n,"data"),e=sI(t,0);return K(e.consumed===t.length,"unexpected junk after rlp payload","data",n),e.result}function oI(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function aI(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(s){r=r.concat(aI(s))}),r.length<=55)return r.unshift(192+r.length),r;const i=oI(r.length);return i.unshift(247+i.length),i.concat(r)}const t=Array.prototype.slice.call(we(n,"object"));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const e=oI(t.length);return e.unshift(183+e.length),e.concat(t)}const cI="0123456789abcdef";function Ka(n){let t="0x";for(const e of aI(n))t+=cI[e>>4],t+=cI[e&15];return t}const wr=32,Qm=new Uint8Array(wr),A$=["then"],np={},uI=new WeakMap;function ja(n){return uI.get(n)}function lI(n,t){uI.set(n,t)}function ch(n,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw e.error=t,e}function Ym(n,t,e){return n.indexOf(null)>=0?t.map((r,i)=>r instanceof Pu?Ym(ja(r),r,e):r):n.reduce((r,i,s)=>{let o=t.getValue(i);return i in r||(e&&o instanceof Pu&&(o=Ym(ja(o),o,e)),r[i]=o),r},{})}const cl=class cl extends Array{constructor(...e){const r=e[0];let i=e[1],s=(e[2]||[]).slice(),o=!0;r!==np&&(i=e,s=[],o=!1);super(i.length);Y(this,al);i.forEach((f,h)=>{this[h]=f});const a=s.reduce((f,h)=>(typeof h=="string"&&f.set(h,(f.get(h)||0)+1),f),new Map);if(lI(this,Object.freeze(i.map((f,h)=>{const y=s[h];return y!=null&&a.get(y)===1?y:null}))),F(this,al,[]),S(this,al)==null&&S(this,al),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(f,h,y)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const w=ie(h,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const R=f[w];return R instanceof Error&&ch(`index ${w}`,R),R}if(A$.indexOf(h)>=0)return Reflect.get(f,h,y);const _=f[h];if(_ instanceof Function)return function(...w){return _.apply(this===y?f:this,w)};if(!(h in f))return f.getValue.apply(this===y?f:this,[h])}return Reflect.get(f,h,y)}});return lI(u,ja(this)),u}toArray(e){const r=[];return this.forEach((i,s)=>{i instanceof Error&&ch(`index ${s}`,i),e&&i instanceof cl&&(i=i.toArray(e)),r.push(i)}),r}toObject(e){const r=ja(this);return r.reduce((i,s,o)=>(ht(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Ym(r,this,e)),{})}slice(e,r){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const i=ja(this),s=[],o=[];for(let a=e;a<r;a++)s.push(this[a]),o.push(i[a]);return new cl(np,s,o)}filter(e,r){const i=ja(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&ch(`index ${a}`,u),e.call(r,u,a,this)&&(s.push(u),o.push(i[a]))}return new cl(np,s,o)}map(e,r){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&ch(`index ${s}`,o),i.push(e.call(r,o,s,this))}return i}getValue(e){const r=ja(this).indexOf(e);if(r===-1)return;const i=this[r];return i instanceof Error&&ch(`property ${JSON.stringify(e)}`,i.error),i}static fromItems(e,r){return new cl(np,e,r)}};al=new WeakMap;let Pu=cl;function fI(n){let t=mr(n);return ht(t.length<=wr,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:wr,offset:t.length}),t.length!==wr&&(t=yr(xn([Qm.slice(t.length%wr),t]))),t}class Us{constructor(t,e,r,i){Z(this,"name");Z(this,"type");Z(this,"localName");Z(this,"dynamic");$t(this,{name:t,type:e,localName:r,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){K(!1,t,this.localName,e)}}class Jm{constructor(){Y(this,ul);Y(this,Ws);Y(this,fc);F(this,Ws,[]),F(this,fc,0)}get data(){return xn(S(this,Ws))}get length(){return S(this,fc)}appendWriter(t){return yt(this,ul,ag).call(this,yr(t.data))}writeBytes(t){let e=yr(t);const r=e.length%wr;return r&&(e=yr(xn([e,Qm.slice(r)]))),yt(this,ul,ag).call(this,e)}writeValue(t){return yt(this,ul,ag).call(this,fI(t))}writeUpdatableValue(){const t=S(this,Ws).length;return S(this,Ws).push(Qm),F(this,fc,S(this,fc)+wr),e=>{S(this,Ws)[t]=fI(e)}}}Ws=new WeakMap,fc=new WeakMap,ul=new WeakSet,ag=function(t){return S(this,Ws).push(t),F(this,fc,S(this,fc)+t.length),t.length};const s1=class s1{constructor(t,e,r){Y(this,pc);Z(this,"allowLoose");Y(this,Br);Y(this,Zr);Y(this,hc);Y(this,dc);Y(this,Vo);$t(this,{allowLoose:!!e}),F(this,Br,yr(t)),F(this,hc,0),F(this,dc,null),F(this,Vo,r??1024),F(this,Zr,0)}get data(){return Tt(S(this,Br))}get dataLength(){return S(this,Br).length}get consumed(){return S(this,Zr)}get bytes(){return new Uint8Array(S(this,Br))}subReader(t){const e=new s1(S(this,Br).slice(S(this,Zr)+t),this.allowLoose,S(this,Vo));return F(e,dc,this),e}readBytes(t,e){let r=yt(this,pc,aO).call(this,0,t,!!e);return yt(this,pc,kb).call(this,t),F(this,Zr,S(this,Zr)+r.length),r.slice(0,t)}readValue(){return Zm(this.readBytes(wr))}readIndex(){return i$(this.readBytes(wr))}};Br=new WeakMap,Zr=new WeakMap,hc=new WeakMap,dc=new WeakMap,Vo=new WeakMap,pc=new WeakSet,kb=function(t){var e;if(S(this,dc))return yt(e=S(this,dc),pc,kb).call(e,t);F(this,hc,S(this,hc)+t),ht(S(this,Vo)<1||S(this,hc)<=S(this,Vo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${S(this,Vo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:yr(S(this,Br)),offset:S(this,Zr),length:t,info:{bytesRead:S(this,hc),dataLength:this.dataLength}})},aO=function(t,e,r){let i=Math.ceil(e/wr)*wr;return S(this,Zr)+i>S(this,Br).length&&(this.allowLoose&&r&&S(this,Zr)+e<=S(this,Br).length?i=e:ht(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:yr(S(this,Br)),length:S(this,Br).length,offset:S(this,Zr)+i})),S(this,Br).slice(S(this,Zr),S(this,Zr)+i)};let Xm=s1;function rp(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function tw(n,...t){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(n.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${n.length}`)}function E$(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rp(n.outputLen),rp(n.blockLen)}function Mu(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function hI(n,t){tw(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const ew=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dI=n=>n instanceof Uint8Array,v$=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),nw=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),es=(n,t)=>n<<32-t|n>>>t;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function x$(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function ip(n){if(typeof n=="string"&&(n=x$(n)),!dI(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function R$(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!dI(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}class rw{clone(){return this._cloneInto()}}function iw(n){const t=r=>n().update(ip(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function I$(n=32){if(ew&&typeof ew.getRandomValues=="function")return ew.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class pI extends rw{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,E$(t);const r=ip(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return Mu(this),this.iHash.update(t),this}digestInto(t){Mu(this),tw(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const gI=(n,t,e)=>new pI(n,t).update(e).digest();gI.create=(n,t)=>new pI(n,t);function S$(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),a=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,a,r)}class yI extends rw{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=nw(this.buffer)}update(t){Mu(this);const{view:e,buffer:r,blockLen:i}=this;t=ip(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=nw(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Mu(this),hI(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;S$(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=nw(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)a.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const k$=(n,t,e)=>n&t^~n&e,T$=(n,t,e)=>n&t^n&e^t&e,O$=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]),Mo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lo=new Uint32Array(64);class N$ extends yI{constructor(){super(64,32,8,!1),this.A=Mo[0]|0,this.B=Mo[1]|0,this.C=Mo[2]|0,this.D=Mo[3]|0,this.E=Mo[4]|0,this.F=Mo[5]|0,this.G=Mo[6]|0,this.H=Mo[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:a,H:u}=this;return[t,e,r,i,s,o,a,u]}set(t,e,r,i,s,o,a,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)Lo[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const _=Lo[y-15],w=Lo[y-2],R=es(_,7)^es(_,18)^_>>>3,T=es(w,17)^es(w,19)^w>>>10;Lo[y]=T+Lo[y-7]+R+Lo[y-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const _=es(a,6)^es(a,11)^es(a,25),w=h+_+k$(a,u,f)+O$[y]+Lo[y]|0,T=(es(r,2)^es(r,13)^es(r,22))+T$(r,i,s)|0;h=f,f=u,u=a,a=o+w|0,o=s,s=i,i=r,r=w+T|0}r=r+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,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,a,u,f,h)}roundClean(){Lo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const mI=iw(()=>new N$),sp=BigInt(2**32-1),sw=BigInt(32);function wI(n,t=!1){return t?{h:Number(n&sp),l:Number(n>>sw&sp)}:{h:Number(n>>sw&sp)|0,l:Number(n&sp)|0}}function bI(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=wI(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const C$=(n,t)=>BigInt(n>>>0)<<sw|BigInt(t>>>0),B$=(n,t,e)=>n>>>e,P$=(n,t,e)=>n<<32-e|t>>>e,M$=(n,t,e)=>n>>>e|t<<32-e,L$=(n,t,e)=>n<<32-e|t>>>e,U$=(n,t,e)=>n<<64-e|t>>>e-32,D$=(n,t,e)=>n>>>e-32|t<<64-e,F$=(n,t)=>t,$$=(n,t)=>n,_I=(n,t,e)=>n<<e|t>>>32-e,AI=(n,t,e)=>t<<e|n>>>32-e,EI=(n,t,e)=>t<<e-32|n>>>64-e,vI=(n,t,e)=>n<<e-32|t>>>64-e;function H$(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const ne={fromBig:wI,split:bI,toBig:C$,shrSH:B$,shrSL:P$,rotrSH:M$,rotrSL:L$,rotrBH:U$,rotrBL:D$,rotr32H:F$,rotr32L:$$,rotlSH:_I,rotlSL:AI,rotlBH:EI,rotlBL:vI,add:H$,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,add5H:(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,add5L:(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)},[z$,G$]=ne.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Uo=new Uint32Array(80),Do=new Uint32Array(80);class V$ extends yI{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:f,El:h,Fh:y,Fl:_,Gh:w,Gl:R,Hh:T,Hl:I}=this;return[t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I]}set(t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=_|0,this.Gh=w|0,this.Gl=R|0,this.Hh=T|0,this.Hl=I|0}process(t,e){for(let U=0;U<16;U++,e+=4)Uo[U]=t.getUint32(e),Do[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=Uo[U-15]|0,W=Do[U-15]|0,X=ne.rotrSH(G,W,1)^ne.rotrSH(G,W,8)^ne.shrSH(G,W,7),j=ne.rotrSL(G,W,1)^ne.rotrSL(G,W,8)^ne.shrSL(G,W,7),J=Uo[U-2]|0,it=Do[U-2]|0,ut=ne.rotrSH(J,it,19)^ne.rotrBH(J,it,61)^ne.shrSH(J,it,6),rt=ne.rotrSL(J,it,19)^ne.rotrBL(J,it,61)^ne.shrSL(J,it,6),ot=ne.add4L(j,rt,Do[U-7],Do[U-16]),C=ne.add4H(ot,X,ut,Uo[U-7],Uo[U-16]);Uo[U]=C|0,Do[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:f,Dl:h,Eh:y,El:_,Fh:w,Fl:R,Gh:T,Gl:I,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=ne.rotrSH(y,_,14)^ne.rotrSH(y,_,18)^ne.rotrBH(y,_,41),W=ne.rotrSL(y,_,14)^ne.rotrSL(y,_,18)^ne.rotrBL(y,_,41),X=y&w^~y&T,j=_&R^~_&I,J=ne.add5L(H,W,j,G$[U],Do[U]),it=ne.add5H(J,B,G,X,z$[U],Uo[U]),ut=J|0,rt=ne.rotrSH(r,i,28)^ne.rotrBH(r,i,34)^ne.rotrBH(r,i,39),ot=ne.rotrSL(r,i,28)^ne.rotrBL(r,i,34)^ne.rotrBL(r,i,39),C=r&s^r&a^s&a,p=i&o^i&u^o&u;B=T|0,H=I|0,T=w|0,I=R|0,w=y|0,R=_|0,{h:y,l:_}=ne.add(f|0,h|0,it|0,ut|0),f=a|0,h=u|0,a=s|0,u=o|0,s=r|0,o=i|0;const m=ne.add3L(ut,ot,p);r=ne.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=ne.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=ne.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=ne.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=ne.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:_}=ne.add(this.Eh|0,this.El|0,y|0,_|0),{h:w,l:R}=ne.add(this.Fh|0,this.Fl|0,w|0,R|0),{h:T,l:I}=ne.add(this.Gh|0,this.Gl|0,T|0,I|0),{h:B,l:H}=ne.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H)}roundClean(){Uo.fill(0),Do.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 K$=iw(()=>new V$);function j$(){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 xI=j$();xI.crypto||xI.msCrypto;function W$(n){switch(n){case"sha256":return mI.create();case"sha512":return K$.create()}K(!1,"invalid hashing algorithm name","algorithm",n)}const[RI,II,SI]=[[],[],[]],Z$=BigInt(0),uh=BigInt(1),q$=BigInt(2),Q$=BigInt(7),Y$=BigInt(256),J$=BigInt(113);for(let n=0,t=uh,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],RI.push(2*(5*r+e)),II.push((n+1)*(n+2)/2%64);let i=Z$;for(let s=0;s<7;s++)t=(t<<uh^(t>>Q$)*J$)%Y$,t&q$&&(i^=uh<<(uh<<BigInt(s))-uh);SI.push(i)}const[X$,tH]=bI(SI,!0),kI=(n,t,e)=>e>32?EI(n,t,e):_I(n,t,e),TI=(n,t,e)=>e>32?vI(n,t,e):AI(n,t,e);function eH(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=kI(f,h,1)^e[a],_=TI(f,h,1)^e[a+1];for(let w=0;w<50;w+=10)n[o+w]^=y,n[o+w+1]^=_}let i=n[2],s=n[3];for(let o=0;o<24;o++){const a=II[o],u=kI(i,s,a),f=TI(i,s,a),h=RI[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=X$[r],n[1]^=tH[r]}e.fill(0)}class ow extends rw{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rp(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=v$(this.state)}keccak(){eH(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Mu(this);const{blockLen:e,state:r}=this;t=ip(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Mu(this,!1),tw(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return rp(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hI(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new ow(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const nH=((n,t,e)=>iw(()=>new ow(t,n,e)))(1,136,256/8);let OI=!1;const NI=function(n){return nH(n)};let CI=NI;function Nn(n){const t=we(n,"data");return Tt(CI(t))}Nn._=NI,Nn.lock=function(){OI=!0},Nn.register=function(n){if(OI)throw new TypeError("keccak256 is locked");CI=n},Object.freeze(Nn);const BI=function(n){return W$("sha256").update(n).digest()};let PI=BI,MI=!1;function Lu(n){const t=we(n,"data");return Tt(PI(t))}Lu._=BI,Lu.lock=function(){MI=!0},Lu.register=function(n){if(MI)throw new Error("sha256 is locked");PI=n},Object.freeze(Lu),Object.freeze(Lu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const LI=BigInt(0),op=BigInt(1),rH=BigInt(2),ap=n=>n instanceof Uint8Array,iH=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function Uu(n){if(!ap(n))throw new Error("Uint8Array expected");let t="";for(let e=0;e<n.length;e++)t+=iH[n[e]];return t}function UI(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function aw(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Du(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const e=new Uint8Array(t/2);for(let r=0;r<e.length;r++){const i=r*2,s=n.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function Wa(n){return aw(Uu(n))}function cw(n){if(!ap(n))throw new Error("Uint8Array expected");return aw(Uu(Uint8Array.from(n).reverse()))}function Fu(n,t){return Du(n.toString(16).padStart(t*2,"0"))}function uw(n,t){return Fu(n,t).reverse()}function sH(n){return Du(UI(n))}function xi(n,t,e){let r;if(typeof t=="string")try{r=Du(t)}catch(s){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ap(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(`${n} expected ${e} bytes, got ${i}`);return r}function lh(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!ap(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}function oH(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}function aH(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function cH(n){let t;for(t=0;n>LI;n>>=op,t+=1);return t}function uH(n,t){return n>>BigInt(t)&op}const lH=(n,t,e)=>n|(e?op:LI)<<BigInt(t),lw=n=>(rH<<BigInt(n-1))-op,fw=n=>new Uint8Array(n),DI=n=>Uint8Array.from(n);function FI(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=fw(n),i=fw(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...y)=>e(i,r,...y),u=(y=fw())=>{i=a(DI([0]),y),r=a(),y.length!==0&&(i=a(DI([1]),y),r=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const _=[];for(;y<t;){r=a();const w=r.slice();_.push(w),y+=r.length}return lh(..._)};return(y,_)=>{o(),u(y);let w;for(;!(w=_(f()));)u();return o(),w}}const fH={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function fh(n,t,e={}){const r=(i,s,o)=>{const a=fH[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=n[i];if(!(o&&u===void 0)&&!a(u,n))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const hH=Object.freeze(Object.defineProperty({__proto__:null,bitGet:uH,bitLen:cH,bitMask:lw,bitSet:lH,bytesToHex:Uu,bytesToNumberBE:Wa,bytesToNumberLE:cw,concatBytes:lh,createHmacDrbg:FI,ensureBytes:xi,equalBytes:oH,hexToBytes:Du,hexToNumber:aw,numberToBytesBE:Fu,numberToBytesLE:uw,numberToHexUnpadded:UI,numberToVarBytesBE:sH,utf8ToBytes:aH,validateObject:fh},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Dn=BigInt(0),Rn=BigInt(1),Za=BigInt(2),dH=BigInt(3),hw=BigInt(4),$I=BigInt(5),HI=BigInt(8);BigInt(9),BigInt(16);function Or(n,t){const e=n%t;return e>=Dn?e:t+e}function pH(n,t,e){if(e<=Dn||t<Dn)throw new Error("Expected power/modulo > 0");if(e===Rn)return Dn;let r=Rn;for(;t>Dn;)t&Rn&&(r=r*n%e),n=n*n%e,t>>=Rn;return r}function ii(n,t,e){let r=n;for(;t-- >Dn;)r*=r,r%=e;return r}function dw(n,t){if(n===Dn||t<=Dn)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Or(n,t),r=t,i=Dn,s=Rn;for(;e!==Dn;){const a=r/e,u=r%e,f=i-s*a;r=e,e=u,i=s,s=f}if(r!==Rn)throw new Error("invert: does not exist");return Or(i,t)}function gH(n){const t=(n-Rn)/Za;let e,r,i;for(e=n-Rn,r=0;e%Za===Dn;e/=Za,r++);for(i=Za;i<n&&pH(i,t,n)!==n-Rn;i++);if(r===1){const o=(n+Rn)/hw;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+Rn)/Za;return function(a,u){if(a.pow(u,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=r,h=a.pow(a.mul(a.ONE,i),e),y=a.pow(u,s),_=a.pow(u,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let w=1;for(let T=a.sqr(_);w<f&&!a.eql(T,a.ONE);w++)T=a.sqr(T);const R=a.pow(h,Rn<<BigInt(f-w-1));h=a.sqr(R),y=a.mul(y,R),_=a.mul(_,h),f=w}return y}}function yH(n){if(n%hw===dH){const t=(n+Rn)/hw;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%HI===$I){const t=(n-$I)/HI;return function(r,i){const s=r.mul(i,Za),o=r.pow(s,t),a=r.mul(i,o),u=r.mul(r.mul(a,Za),o),f=r.mul(a,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return gH(n)}const mH=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wH(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=mH.reduce((r,i)=>(r[i]="function",r),t);return fh(n,e)}function bH(n,t,e){if(e<Dn)throw new Error("Expected power > 0");if(e===Dn)return n.ONE;if(e===Rn)return t;let r=n.ONE,i=t;for(;e>Dn;)e&Rn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=Rn;return r}function _H(n,t){const e=new Array(t.length),r=t.reduce((s,o,a)=>n.is0(o)?s:(e[a]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,a)=>n.is0(o)?s:(e[a]=n.mul(s,e[a]),n.mul(s,o)),i),e}function zI(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function AH(n,t,e=!1,r={}){if(n<=Dn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:i,nByteLength:s}=zI(n,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=yH(n),a=Object.freeze({ORDER:n,BITS:i,BYTES:s,MASK:lw(i),ZERO:Dn,ONE:Rn,create:u=>Or(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Dn<=u&&u<n},is0:u=>u===Dn,isOdd:u=>(u&Rn)===Rn,neg:u=>Or(-u,n),eql:(u,f)=>u===f,sqr:u=>Or(u*u,n),add:(u,f)=>Or(u+f,n),sub:(u,f)=>Or(u-f,n),mul:(u,f)=>Or(u*f,n),pow:(u,f)=>bH(a,u,f),div:(u,f)=>Or(u*dw(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>dw(u,n),sqrt:r.sqrt||(u=>o(a,u)),invertBatch:u=>_H(a,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?uw(u,s):Fu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?cw(u):Wa(u)}});return Object.freeze(a)}function GI(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function VI(n){const t=GI(n);return t+Math.ceil(t/2)}function EH(n,t,e=!1){const r=n.length,i=GI(t),s=VI(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=e?Wa(n):cw(n),a=Or(o,t-Rn)+Rn;return e?uw(a,i):Fu(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vH=BigInt(0),pw=BigInt(1);function xH(n,t){const e=(i,s)=>{const o=s.negate();return i?o:s},r=i=>{const s=Math.ceil(t/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:e,unsafeLadder(i,s){let o=n.ZERO,a=i;for(;s>vH;)s&pw&&(o=o.add(a)),a=a.double(),s>>=pw;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=r(s),u=[];let f=i,h=f;for(let y=0;y<o;y++){h=f,u.push(h);for(let _=1;_<a;_++)h=h.add(f),u.push(h);f=h.double()}return u},wNAF(i,s,o){const{windows:a,windowSize:u}=r(i);let f=n.ZERO,h=n.BASE;const y=BigInt(2**i-1),_=2**i,w=BigInt(i);for(let R=0;R<a;R++){const T=R*u;let I=Number(o&y);o>>=w,I>u&&(I-=_,o+=pw);const B=T,H=T+Math.abs(I)-1,U=R%2!==0,G=I<0;I===0?h=h.add(e(U,s[B])):f=f.add(e(G,s[H]))}return{p:f,f:h}},wNAFCached(i,s,o,a){const u=i._WINDOW_SIZE||1;let f=s.get(i);return f||(f=this.precomputeWindow(i,u),u!==1&&s.set(i,a(f))),this.wNAF(u,f,o)}}}function KI(n){return wH(n.Fp),fh(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zI(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function RH(n){const t=KI(n);fh(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:IH,hexToBytes:SH}=hH,qa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=qa;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:IH(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=qa,e=typeof n=="string"?SH(n):n;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=qa._parseInt(e.subarray(2)),{d:o,l:a}=qa._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(n){const t=f=>Number.parseInt(f[0],16)&8?"00"+f:f,e=f=>{const h=f.toString(16);return h.length&1?`0${h}`:h},r=t(e(n.s)),i=t(e(n.r)),s=r.length/2,o=i.length/2,a=e(s),u=e(o);return`30${e(o+s+4)}02${u}${i}02${a}${r}`}},Ds=BigInt(0),si=BigInt(1);BigInt(2);const jI=BigInt(3);BigInt(4);function kH(n){const t=RH(n),{Fp:e}=t,r=t.toBytes||((R,T,I)=>{const B=T.toAffine();return lh(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(R=>{const T=R.subarray(1),I=e.fromBytes(T.subarray(0,e.BYTES)),B=e.fromBytes(T.subarray(e.BYTES,2*e.BYTES));return{x:I,y:B}});function s(R){const{a:T,b:I}=t,B=e.sqr(R),H=e.mul(B,R);return e.add(e.add(H,e.mul(R,T)),I)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(R){return typeof R=="bigint"&&Ds<R&&R<t.n}function a(R){if(!o(R))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(R){const{allowedPrivateKeyLengths:T,nByteLength:I,wrapPrivateKey:B,n:H}=t;if(T&&typeof R!="bigint"){if(R instanceof Uint8Array&&(R=Uu(R)),typeof R!="string"||!T.includes(R.length))throw new Error("Invalid key");R=R.padStart(I*2,"0")}let U;try{U=typeof R=="bigint"?R:Wa(xi("private key",R,I))}catch{throw new Error(`private key must be ${I} bytes, hex or bigint, not ${typeof R}`)}return B&&(U=Or(U,H)),a(U),U}const f=new Map;function h(R){if(!(R instanceof y))throw new Error("ProjectivePoint expected")}class y{constructor(T,I,B){if(this.px=T,this.py=I,this.pz=B,T==null||!e.isValid(T))throw new Error("x required");if(I==null||!e.isValid(I))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required")}static fromAffine(T){const{x:I,y:B}=T||{};if(!T||!e.isValid(I)||!e.isValid(B))throw new Error("invalid affine point");if(T instanceof y)throw new Error("projective point not allowed");const H=U=>e.eql(U,e.ZERO);return H(I)&&H(B)?y.ZERO:new y(I,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){const I=e.invertBatch(T.map(B=>B.pz));return T.map((B,H)=>B.toAffine(I[H])).map(y.fromAffine)}static fromHex(T){const I=y.fromAffine(i(xi("pointHex",T)));return I.assertValidity(),I}static fromPrivateKey(T){return y.BASE.multiply(u(T))}_setWindowSize(T){this._WINDOW_SIZE=T,f.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:T,y:I}=this.toAffine();if(!e.isValid(T)||!e.isValid(I))throw new Error("bad point: x or y not FE");const B=e.sqr(I),H=s(T);if(!e.eql(B,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:T}=this.toAffine();if(e.isOdd)return!e.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){h(T);const{px:I,py:B,pz:H}=this,{px:U,py:G,pz:W}=T,X=e.eql(e.mul(I,W),e.mul(U,H)),j=e.eql(e.mul(B,W),e.mul(G,H));return X&&j}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){const{a:T,b:I}=t,B=e.mul(I,jI),{px:H,py:U,pz:G}=this;let W=e.ZERO,X=e.ZERO,j=e.ZERO,J=e.mul(H,H),it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(H,U);return rt=e.add(rt,rt),j=e.mul(H,G),j=e.add(j,j),W=e.mul(T,j),X=e.mul(B,ut),X=e.add(W,X),W=e.sub(it,X),X=e.add(it,X),X=e.mul(W,X),W=e.mul(rt,W),j=e.mul(B,j),ut=e.mul(T,ut),rt=e.sub(J,ut),rt=e.mul(T,rt),rt=e.add(rt,j),j=e.add(J,J),J=e.add(j,J),J=e.add(J,ut),J=e.mul(J,rt),X=e.add(X,J),ut=e.mul(U,G),ut=e.add(ut,ut),J=e.mul(ut,rt),W=e.sub(W,J),j=e.mul(ut,it),j=e.add(j,j),j=e.add(j,j),new y(W,X,j)}add(T){h(T);const{px:I,py:B,pz:H}=this,{px:U,py:G,pz:W}=T;let X=e.ZERO,j=e.ZERO,J=e.ZERO;const it=t.a,ut=e.mul(t.b,jI);let rt=e.mul(I,U),ot=e.mul(B,G),C=e.mul(H,W),p=e.add(I,B),m=e.add(U,G);p=e.mul(p,m),m=e.add(rt,ot),p=e.sub(p,m),m=e.add(I,H);let v=e.add(U,W);return m=e.mul(m,v),v=e.add(rt,C),m=e.sub(m,v),v=e.add(B,H),X=e.add(G,W),v=e.mul(v,X),X=e.add(ot,C),v=e.sub(v,X),J=e.mul(it,m),X=e.mul(ut,C),J=e.add(X,J),X=e.sub(ot,J),J=e.add(ot,J),j=e.mul(X,J),ot=e.add(rt,rt),ot=e.add(ot,rt),C=e.mul(it,C),m=e.mul(ut,m),ot=e.add(ot,C),C=e.sub(rt,C),C=e.mul(it,C),m=e.add(m,C),rt=e.mul(ot,m),j=e.add(j,rt),rt=e.mul(v,m),X=e.mul(p,X),X=e.sub(X,rt),rt=e.mul(p,ot),J=e.mul(v,J),J=e.add(J,rt),new y(X,j,J)}subtract(T){return this.add(T.negate())}is0(){return this.equals(y.ZERO)}wNAF(T){return w.wNAFCached(this,f,T,I=>{const B=e.invertBatch(I.map(H=>H.pz));return I.map((H,U)=>H.toAffine(B[U])).map(y.fromAffine)})}multiplyUnsafe(T){const I=y.ZERO;if(T===Ds)return I;if(a(T),T===si)return this;const{endo:B}=t;if(!B)return w.unsafeLadder(this,T);let{k1neg:H,k1:U,k2neg:G,k2:W}=B.splitScalar(T),X=I,j=I,J=this;for(;U>Ds||W>Ds;)U&si&&(X=X.add(J)),W&si&&(j=j.add(J)),J=J.double(),U>>=si,W>>=si;return H&&(X=X.negate()),G&&(j=j.negate()),j=new y(e.mul(j.px,B.beta),j.py,j.pz),X.add(j)}multiply(T){a(T);let I=T,B,H;const{endo:U}=t;if(U){const{k1neg:G,k1:W,k2neg:X,k2:j}=U.splitScalar(I);let{p:J,f:it}=this.wNAF(W),{p:ut,f:rt}=this.wNAF(j);J=w.constTimeNegate(G,J),ut=w.constTimeNegate(X,ut),ut=new y(e.mul(ut.px,U.beta),ut.py,ut.pz),B=J.add(ut),H=it.add(rt)}else{const{p:G,f:W}=this.wNAF(I);B=G,H=W}return y.normalizeZ([B,H])[0]}multiplyAndAddUnsafe(T,I,B){const H=y.BASE,U=(W,X)=>X===Ds||X===si||!W.equals(H)?W.multiplyUnsafe(X):W.multiply(X),G=U(this,I).add(U(T,B));return G.is0()?void 0:G}toAffine(T){const{px:I,py:B,pz:H}=this,U=this.is0();T==null&&(T=U?e.ONE:e.inv(H));const G=e.mul(I,T),W=e.mul(B,T),X=e.mul(H,T);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(X,e.ONE))throw new Error("invZ was invalid");return{x:G,y:W}}isTorsionFree(){const{h:T,isTorsionFree:I}=t;if(T===si)return!0;if(I)return I(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:T,clearCofactor:I}=t;return T===si?this:I?I(y,this):this.multiplyUnsafe(t.h)}toRawBytes(T=!0){return this.assertValidity(),r(y,this,T)}toHex(T=!0){return Uu(this.toRawBytes(T))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);const _=t.nBitLength,w=xH(y,t.endo?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function TH(n){const t=KI(n);return fh(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function OH(n){const t=TH(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(m){return Ds<m&&m<e.ORDER}function a(m){return Or(m,r)}function u(m){return dw(m,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:h,weierstrassEquation:y,isWithinCurveOrder:_}=kH({...t,toBytes(m,v,k){const N=v.toAffine(),M=e.toBytes(N.x),z=lh;return k?z(Uint8Array.from([v.hasEvenY()?2:3]),M):z(Uint8Array.from([4]),M,e.toBytes(N.y))},fromBytes(m){const v=m.length,k=m[0],N=m.subarray(1);if(v===i&&(k===2||k===3)){const M=Wa(N);if(!o(M))throw new Error("Point is not on curve");const z=y(M);let P=e.sqrt(z);const A=(P&si)===si;return(k&1)===1!==A&&(P=e.neg(P)),{x:M,y:P}}else if(v===s&&k===4){const M=e.fromBytes(N.subarray(0,e.BYTES)),z=e.fromBytes(N.subarray(e.BYTES,2*e.BYTES));return{x:M,y:z}}else throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=m=>Uu(Fu(m,t.nByteLength));function R(m){const v=r>>si;return m>v}function T(m){return R(m)?a(-m):m}const I=(m,v,k)=>Wa(m.slice(v,k));class B{constructor(v,k,N){this.r=v,this.s=k,this.recovery=N,this.assertValidity()}static fromCompact(v){const k=t.nByteLength;return v=xi("compactSignature",v,k*2),new B(I(v,0,k),I(v,k,2*k))}static fromDER(v){const{r:k,s:N}=qa.toSig(xi("DER",v));return new B(k,N)}assertValidity(){if(!_(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!_(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(v){return new B(this.r,this.s,v)}recoverPublicKey(v){const{r:k,s:N,recovery:M}=this,z=j(xi("msgHash",v));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?k+t.n:k;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=M&1?"03":"02",$=f.fromHex(A+w(P)),ct=u(P),dt=a(-z*ct),wt=a(N*ct),Gt=f.BASE.multiplyAndAddUnsafe($,dt,wt);if(!Gt)throw new Error("point at infinify");return Gt.assertValidity(),Gt}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Du(this.toDERHex())}toDERHex(){return qa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Du(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=VI(t.n);return EH(t.randomBytes(m),t.n)},precompute(m=8,v=f.BASE){return v._setWindowSize(m),v.multiply(BigInt(3)),v}};function U(m,v=!0){return f.fromPrivateKey(m).toRawBytes(v)}function G(m){const v=m instanceof Uint8Array,k=typeof m=="string",N=(v||k)&&m.length;return v?N===i||N===s:k?N===2*i||N===2*s:m instanceof f}function W(m,v,k=!0){if(G(m))throw new Error("first arg must be private key");if(!G(v))throw new Error("second arg must be public key");return f.fromHex(v).multiply(h(m)).toRawBytes(k)}const X=t.bits2int||function(m){const v=Wa(m),k=m.length*8-t.nBitLength;return k>0?v>>BigInt(k):v},j=t.bits2int_modN||function(m){return a(X(m))},J=lw(t.nBitLength);function it(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(Ds<=m&&m<J))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Fu(m,t.nByteLength)}function ut(m,v,k=rt){if(["recovered","canonical"].some(Lt=>Lt in k))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:M}=t;let{lowS:z,prehash:P,extraEntropy:A}=k;z==null&&(z=!0),m=xi("msgHash",m),P&&(m=xi("prehashed msgHash",N(m)));const $=j(m),ct=h(v),dt=[it(ct),it($)];if(A!=null){const Lt=A===!0?M(e.BYTES):A;dt.push(xi("extraEntropy",Lt))}const wt=lh(...dt),Gt=$;function Ut(Lt){const Re=X(Lt);if(!_(Re))return;const Kt=u(Re),Ft=f.BASE.multiply(Re).toAffine(),Te=a(Ft.x);if(Te===Ds)return;const re=a(Kt*a(Gt+Te*ct));if(re===Ds)return;let oe=(Ft.x===Te?0:2)|Number(Ft.y&si),sn=re;return z&&R(re)&&(sn=T(re),oe^=1),new B(Te,sn,oe)}return{seed:wt,k2sig:Ut}}const rt={lowS:t.lowS,prehash:!1},ot={lowS:t.lowS,prehash:!1};function C(m,v,k=rt){const{seed:N,k2sig:M}=ut(m,v,k),z=t;return FI(z.hash.outputLen,z.nByteLength,z.hmac)(N,M)}f.BASE._setWindowSize(8);function p(m,v,k,N=ot){var Ft;const M=m;if(v=xi("msgHash",v),k=xi("publicKey",k),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:P}=N;let A,$;try{if(typeof M=="string"||M instanceof Uint8Array)try{A=B.fromDER(M)}catch(Te){if(!(Te instanceof qa.Err))throw Te;A=B.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:Te,s:re}=M;A=new B(Te,re)}else throw new Error("PARSE");$=f.fromHex(k)}catch(Te){if(Te.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&A.hasHighS())return!1;P&&(v=t.hash(v));const{r:ct,s:dt}=A,wt=j(v),Gt=u(dt),Ut=a(wt*Gt),Lt=a(ct*Gt),Re=(Ft=f.BASE.multiplyAndAddUnsafe($,Ut,Lt))==null?void 0:Ft.toAffine();return Re?a(Re.x)===ct:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:W,sign:C,verify:p,ProjectivePoint:f,Signature:B,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function NH(n){return{hash:n,hmac:(t,...e)=>gI(n,t,R$(...e)),randomBytes:I$}}function CH(n,t){const e=r=>OH({...n,...NH(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const WI=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ZI=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),BH=BigInt(1),gw=BigInt(2),qI=(n,t)=>(n+t/gw)/t;function PH(n){const t=WI,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=ii(h,e,t)*h%t,_=ii(y,e,t)*h%t,w=ii(_,gw,t)*f%t,R=ii(w,i,t)*w%t,T=ii(R,s,t)*R%t,I=ii(T,a,t)*T%t,B=ii(I,u,t)*I%t,H=ii(B,a,t)*T%t,U=ii(H,e,t)*h%t,G=ii(U,o,t)*R%t,W=ii(G,r,t)*f%t,X=ii(W,gw,t);if(!yw.eql(yw.sqr(X),n))throw new Error("Cannot find square root");return X}const yw=AH(WI,void 0,void 0,{sqrt:PH}),Fo=CH({a:BigInt(0),b:BigInt(7),Fp:yw,n:ZI,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=ZI,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-BH*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),a=qI(s*n,t),u=qI(-r*n,t);let f=Or(n-a*e-u*i,t),h=Or(-a*r-u*s,t);const y=f>o,_=h>o;if(y&&(f=t-f),_&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:_,k2:h}}}},mI);BigInt(0),Fo.ProjectivePoint;const hh="0x0000000000000000000000000000000000000000",QI="0x0000000000000000000000000000000000000000000000000000000000000000",YI=BigInt(0),JI=BigInt(1),XI=BigInt(2),tS=BigInt(27),eS=BigInt(28),cp=BigInt(35),$u={};function nS(n){return Va(mr(n),32)}const Oi=class Oi{constructor(t,e,r,i){Y(this,ll);Y(this,fl);Y(this,hl);Y(this,gc);q0(t,$u,"Signature"),F(this,ll,e),F(this,fl,r),F(this,hl,i),F(this,gc,null)}get r(){return S(this,ll)}set r(t){K(Nu(t)===32,"invalid r","value",t),F(this,ll,Tt(t))}get s(){return S(this,fl)}set s(t){K(Nu(t)===32,"invalid s","value",t);const e=Tt(t);K(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),F(this,fl,e)}get v(){return S(this,hl)}set v(t){const e=ie(t,"value");K(e===27||e===28,"invalid v","v",t),F(this,hl,e)}get networkV(){return S(this,gc)}get legacyChainId(){const t=this.networkV;return t==null?null:Oi.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){const t=we(this.s);return this.yParity&&(t[0]|=128),Tt(t)}get compactSerialized(){return xn([this.r,this.yParityAndS])}get serialized(){return xn([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new Oi($u,this.r,this.s,this.v);return this.networkV&&F(t,gc,this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:t!=null?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Ct(t,"v");return e==tS||e==eS?YI:(K(e>=cp,"invalid EIP-155 v","v",t),(e-cp)/XI)}static getChainIdV(t,e){return Ct(t)*XI+BigInt(35+e-27)}static getNormalizedV(t){const e=Ct(t);return e===YI||e===tS?27:e===JI||e===eS?28:(K(e>=cp,"invalid v","v",t),e&JI?27:28)}static from(t){function e(f,h){K(f,h,"signature",t)}if(t==null)return new Oi($u,QI,QI,27);if(typeof t=="string"){const f=we(t,"signature");if(f.length===64){const h=Tt(f.slice(0,32)),y=f.slice(32,64),_=y[0]&128?28:27;return y[0]&=127,new Oi($u,h,Tt(y),_)}if(f.length===65){const h=Tt(f.slice(0,32)),y=f.slice(32,64);e((y[0]&128)===0,"non-canonical s");const _=Oi.getNormalizedV(f[64]);return new Oi($u,h,Tt(y),_)}e(!1,"invalid raw signature length")}if(t instanceof Oi)return t.clone();const r=t.r;e(r!=null,"missing r");const i=nS(r),s=function(f,h){if(f!=null)return nS(f);if(h!=null){e(Ge(h,32),"invalid yParityAndS");const y=we(h);return y[0]&=127,Tt(y)}e(!1,"missing s")}(t.s,t.yParityAndS);e((we(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(f,h,y){if(f!=null){const _=Ct(f);return{networkV:_>=cp?_:void 0,v:Oi.getNormalizedV(_)}}if(h!=null)return e(Ge(h,32),"invalid yParityAndS"),{v:we(h)[0]&128?28:27};if(y!=null){switch(ie(y,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),u=new Oi($u,i,s,a);return o&&F(u,gc,o),e(t.yParity==null||ie(t.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),e(t.yParityAndS==null||t.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};ll=new WeakMap,fl=new WeakMap,hl=new WeakMap,gc=new WeakMap;let Ri=Oi;const yc=class yc{constructor(t){Y(this,Zs);K(Nu(t)===32,"invalid private key","privateKey","[REDACTED]"),F(this,Zs,Tt(t))}get privateKey(){return S(this,Zs)}get publicKey(){return yc.computePublicKey(S(this,Zs))}get compressedPublicKey(){return yc.computePublicKey(S(this,Zs),!0)}sign(t){K(Nu(t)===32,"invalid digest length","digest",t);const e=Fo.sign(yr(t),yr(S(this,Zs)),{lowS:!0});return Ri.from({r:Bo(e.r,32),s:Bo(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=yc.computePublicKey(t);return Tt(Fo.getSharedSecret(yr(S(this,Zs)),we(e),!1))}static computePublicKey(t,e){let r=we(t,"key");if(r.length===32){const s=Fo.getPublicKey(r,!!e);return Tt(s)}if(r.length===64){const s=new Uint8Array(65);s[0]=4,s.set(r,1),r=s}const i=Fo.ProjectivePoint.fromHex(r);return Tt(i.toRawBytes(e))}static recoverPublicKey(t,e){K(Nu(t)===32,"invalid digest length","digest",t);const r=Ri.from(e);let i=Fo.Signature.fromCompact(yr(xn([r.r,r.s])));i=i.addRecoveryBit(r.yParity);const s=i.recoverPublicKey(yr(t));return K(s!=null,"invalid signautre for digest","signature",e),"0x"+s.toHex(!1)}static addPoints(t,e,r){const i=Fo.ProjectivePoint.fromHex(yc.computePublicKey(t).substring(2)),s=Fo.ProjectivePoint.fromHex(yc.computePublicKey(e).substring(2));return"0x"+i.add(s).toHex(!!r)}};Zs=new WeakMap;let dh=yc;const MH=BigInt(0),LH=BigInt(36);function rS(n){n=n.toLowerCase();const t=n.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const r=we(Nn(e));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(r[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const mw={};for(let n=0;n<10;n++)mw[String(n)]=String(n);for(let n=0;n<26;n++)mw[String.fromCharCode(65+n)]=String(10+n);const iS=15;function UH(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(r=>mw[r]).join("");for(;t.length>=iS;){let r=t.substring(0,iS);t=parseInt(r,10)%97+t.substring(r.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const DH=function(){const n={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];n[e]=BigInt(t)}return n}();function FH(n){n=n.toLowerCase();let t=MH;for(let e=0;e<n.length;e++)t=t*LH+DH[n[e]];return t}function Le(n){if(K(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const t=rS(n);return K(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===n,"bad address checksum","address",n),t}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){K(n.substring(2,4)===UH(n),"bad icap checksum","address",n);let t=FH(n.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return rS("0x"+t)}K(!1,"invalid address","address",n)}function $H(n){const t=Le(n.from);let r=Ct(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,Le(ln(Nn(Ka([t,r])),12))}function sS(n){return n&&typeof n.getAddress=="function"}async function ww(n,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(ht(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),K(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),Le(e)}function br(n,t){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?Le(n):(ht(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),ww(n,t.resolveName(n)));if(sS(n))return ww(n,n.getAddress());if(n&&typeof n.then=="function")return ww(n,n);K(!1,"unsupported addressable value","target",n)}const Fs={};function St(n,t){let e=!1;return t<0&&(e=!0,t*=-1),new sr(Fs,`${e?"":"u"}int${t}`,n,{signed:e,width:t})}function Ae(n,t){return new sr(Fs,`bytes${t||""}`,n,{size:t})}const oS=Symbol.for("_ethers_typed"),qs=class qs{constructor(t,e,r,i){Z(this,"type");Z(this,"value");Y(this,mc);Z(this,"_typedSymbol");i==null&&(i=null),q0(Fs,t,"Typed"),$t(this,{_typedSymbol:oS,type:e,value:r}),F(this,mc,i),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return S(this,mc)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return S(this,mc)===!0?-1:S(this,mc)===!1?this.value.length:null}static from(t,e){return new qs(Fs,t,e)}static uint8(t){return St(t,8)}static uint16(t){return St(t,16)}static uint24(t){return St(t,24)}static uint32(t){return St(t,32)}static uint40(t){return St(t,40)}static uint48(t){return St(t,48)}static uint56(t){return St(t,56)}static uint64(t){return St(t,64)}static uint72(t){return St(t,72)}static uint80(t){return St(t,80)}static uint88(t){return St(t,88)}static uint96(t){return St(t,96)}static uint104(t){return St(t,104)}static uint112(t){return St(t,112)}static uint120(t){return St(t,120)}static uint128(t){return St(t,128)}static uint136(t){return St(t,136)}static uint144(t){return St(t,144)}static uint152(t){return St(t,152)}static uint160(t){return St(t,160)}static uint168(t){return St(t,168)}static uint176(t){return St(t,176)}static uint184(t){return St(t,184)}static uint192(t){return St(t,192)}static uint200(t){return St(t,200)}static uint208(t){return St(t,208)}static uint216(t){return St(t,216)}static uint224(t){return St(t,224)}static uint232(t){return St(t,232)}static uint240(t){return St(t,240)}static uint248(t){return St(t,248)}static uint256(t){return St(t,256)}static uint(t){return St(t,256)}static int8(t){return St(t,-8)}static int16(t){return St(t,-16)}static int24(t){return St(t,-24)}static int32(t){return St(t,-32)}static int40(t){return St(t,-40)}static int48(t){return St(t,-48)}static int56(t){return St(t,-56)}static int64(t){return St(t,-64)}static int72(t){return St(t,-72)}static int80(t){return St(t,-80)}static int88(t){return St(t,-88)}static int96(t){return St(t,-96)}static int104(t){return St(t,-104)}static int112(t){return St(t,-112)}static int120(t){return St(t,-120)}static int128(t){return St(t,-128)}static int136(t){return St(t,-136)}static int144(t){return St(t,-144)}static int152(t){return St(t,-152)}static int160(t){return St(t,-160)}static int168(t){return St(t,-168)}static int176(t){return St(t,-176)}static int184(t){return St(t,-184)}static int192(t){return St(t,-192)}static int200(t){return St(t,-200)}static int208(t){return St(t,-208)}static int216(t){return St(t,-216)}static int224(t){return St(t,-224)}static int232(t){return St(t,-232)}static int240(t){return St(t,-240)}static int248(t){return St(t,-248)}static int256(t){return St(t,-256)}static int(t){return St(t,-256)}static bytes1(t){return Ae(t,1)}static bytes2(t){return Ae(t,2)}static bytes3(t){return Ae(t,3)}static bytes4(t){return Ae(t,4)}static bytes5(t){return Ae(t,5)}static bytes6(t){return Ae(t,6)}static bytes7(t){return Ae(t,7)}static bytes8(t){return Ae(t,8)}static bytes9(t){return Ae(t,9)}static bytes10(t){return Ae(t,10)}static bytes11(t){return Ae(t,11)}static bytes12(t){return Ae(t,12)}static bytes13(t){return Ae(t,13)}static bytes14(t){return Ae(t,14)}static bytes15(t){return Ae(t,15)}static bytes16(t){return Ae(t,16)}static bytes17(t){return Ae(t,17)}static bytes18(t){return Ae(t,18)}static bytes19(t){return Ae(t,19)}static bytes20(t){return Ae(t,20)}static bytes21(t){return Ae(t,21)}static bytes22(t){return Ae(t,22)}static bytes23(t){return Ae(t,23)}static bytes24(t){return Ae(t,24)}static bytes25(t){return Ae(t,25)}static bytes26(t){return Ae(t,26)}static bytes27(t){return Ae(t,27)}static bytes28(t){return Ae(t,28)}static bytes29(t){return Ae(t,29)}static bytes30(t){return Ae(t,30)}static bytes31(t){return Ae(t,31)}static bytes32(t){return Ae(t,32)}static address(t){return new qs(Fs,"address",t)}static bool(t){return new qs(Fs,"bool",!!t)}static bytes(t){return new qs(Fs,"bytes",t)}static string(t){return new qs(Fs,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new qs(Fs,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===oS}static dereference(t,e){if(qs.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};mc=new WeakMap;let sr=qs;class HH extends Us{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=sr.dereference(e,"string");try{r=Le(r)}catch(i){return this._throwError(i.message,e)}return t.writeValue(r)}decode(t){return Le(Bo(t.readValue(),20))}}class zH extends Us{constructor(e){super(e.name,e.type,"_",e.dynamic);Z(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}function aS(n,t,e){let r=[];if(Array.isArray(e))r=e;else if(e&&typeof e=="object"){let u={};r=t.map(f=>{const h=f.localName;return ht(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),ht(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),u[h]=!0,e[h]})}else K(!1,"invalid tuple value","tuple",e);K(t.length===r.length,"types/value length mismatch","tuple",e);let i=new Jm,s=new Jm,o=[];t.forEach((u,f)=>{let h=r[f];if(u.dynamic){let y=s.length;u.encode(s,h);let _=i.writeUpdatableValue();o.push(w=>{_(w+y)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let a=n.appendWriter(i);return a+=n.appendWriter(s),a}function cS(n,t){let e=[],r=[],i=n.subReader(0);return t.forEach(s=>{let o=null;if(s.dynamic){let a=n.readIndex(),u=i.subReader(a);try{o=s.decode(u)}catch(f){if(qn(f,"BUFFER_OVERRUN"))throw f;o=f,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(n)}catch(a){if(qn(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");e.push(o),r.push(s.localName||null)}),Pu.fromItems(e,r)}class GH extends Us{constructor(e,r,i){const s=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",s,i,o);Z(this,"coder");Z(this,"length");$t(this,{coder:e,length:r})}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){const i=sr.dereference(r,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,e.writeValue(i.length)),HR(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return aS(e,o,i)}decode(e){let r=this.length;r===-1&&(r=e.readIndex(),ht(r*wr<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:r*wr,length:e.dataLength}));let i=[];for(let s=0;s<r;s++)i.push(new zH(this.coder));return cS(e,i)}}class VH extends Us{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=sr.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class uS extends Us{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=yr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class KH extends uS{constructor(t){super("bytes",t)}decode(t){return Tt(super.decode(t))}}class jH extends Us{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1);Z(this,"size");$t(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=yr(sr.dereference(r,this.type));return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return Tt(e.readBytes(this.size))}}const WH=new Uint8Array([]);class ZH extends Us{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(WH)}decode(t){return t.readBytes(0),null}}const qH=BigInt(0),QH=BigInt(1),YH=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class JH extends Us{constructor(e,r,i){const s=(r?"int":"uint")+e*8;super(s,s,i,!1);Z(this,"size");Z(this,"signed");$t(this,{size:e,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,r){let i=Ct(sr.dereference(r,this.type)),s=ah(YH,wr*8);if(this.signed){let o=ah(s,this.size*8-1);(i>o||i<-(o+QH))&&this._throwError("value out-of-bounds",r),i=KR(i,8*wr)}else(i<qH||i>ah(s,this.size*8))&&this._throwError("value out-of-bounds",r);return e.writeValue(i)}decode(e){let r=ah(e.readValue(),this.size*8);return this.signed&&(r=r$(r,this.size*8)),r}}class XH extends uS{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Ms(sr.dereference(e,"string")))}decode(t){return J0(super.decode(t))}}class up extends Us{constructor(e,r){let i=!1;const s=[];e.forEach(a=>{a.dynamic&&(i=!0),s.push(a.type)});const o="tuple("+s.join(",")+")";super("tuple",o,r,i);Z(this,"coders");$t(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(i=>{e.push(i.defaultValue())});const r=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[s]))}),Object.freeze(e)}encode(e,r){const i=sr.dereference(r,"tuple");return aS(e,this.coders,i)}decode(e){return cS(e,this.coders)}}function Qa(n){return Nn(Ms(n))}var tz="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 lS=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),fS=4;function ez(n){let t=0;function e(){return n[t++]<<8|n[t++]}let r=e(),i=1,s=[0,1];for(let W=1;W<r;W++)s.push(i+=e());let o=e(),a=t;t+=o;let u=0,f=0;function h(){return u==0&&(f=f<<8|n[t++],u=8),f>>--u&1}const y=31,_=2**y,w=_>>>1,R=w>>1,T=_-1;let I=0;for(let W=0;W<y;W++)I=I<<1|h();let B=[],H=0,U=_;for(;;){let W=Math.floor(((I-H+1)*i-1)/U),X=0,j=r;for(;j-X>1;){let ut=X+j>>>1;W<s[ut]?j=ut:X=ut}if(X==0)break;B.push(X);let J=H+Math.floor(U*s[X]/i),it=H+Math.floor(U*s[X+1]/i)-1;for(;!((J^it)&w);)I=I<<1&T|h(),J=J<<1&T,it=it<<1&T|1;for(;J&~it&R;)I=I&w|I<<1&T>>>1|h(),J=J<<1^w,it=(it^w)<<1|w|1;H=J,U=1+it-J}let G=r-4;return B.map(W=>{switch(W-G){case 3:return G+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return G+256+(n[a++]<<8|n[a++]);case 1:return G+n[a++];default:return W-1}})}function nz(n){let t=0;return()=>n[t++]}function hS(n){return nz(ez(rz(n)))}function rz(n){let t=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>t[i.charCodeAt(0)]=s);let e=n.length,r=new Uint8Array(6*e>>3);for(let i=0,s=0,o=0,a=0;i<e;i++)a=a<<6|t[n.charCodeAt(i)],o+=6,o>=8&&(r[s++]=a>>(o-=8));return r}function iz(n){return n&1?~n>>1:n>>1}function sz(n,t){let e=Array(n);for(let r=0,i=0;r<n;r++)e[r]=i+=iz(t());return e}function ph(n,t=0){let e=[];for(;;){let r=n(),i=n();if(!i)break;t+=r;for(let s=0;s<i;s++)e.push(t+s);t+=i+1}return e}function dS(n){return gh(()=>{let t=ph(n);if(t.length)return t})}function pS(n){let t=[];for(;;){let e=n();if(e==0)break;t.push(oz(e,n))}for(;;){let e=n()-1;if(e<0)break;t.push(az(e,n))}return t.flat()}function gh(n){let t=[];for(;;){let e=n(t.length);if(!e)break;t.push(e)}return t}function gS(n,t,e){let r=Array(n).fill().map(()=>[]);for(let i=0;i<t;i++)sz(n,e).forEach((s,o)=>r[o].push(s));return r}function oz(n,t){let e=1+t(),r=t(),i=gh(t);return gS(i.length,1+n,t).flatMap((o,a)=>{let[u,...f]=o;return Array(i[a]).fill().map((h,y)=>{let _=y*r;return[u+y*e,f.map(w=>w+_)]})})}function az(n,t){let e=1+t();return gS(e,1+n,t).map(i=>[i[0],i.slice(1)])}function cz(n){let t=[],e=ph(n);return i(r([]),[]),t;function r(s){let o=n(),a=gh(()=>{let u=ph(n).map(f=>e[f]);if(u.length)return r(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&&t.push(a);for(let f of o)for(let h of f.Q)i(f,[...a,h],u)}}}function uz(n){return n.toString(16).toUpperCase().padStart(2,"0")}function yS(n){return`{${uz(n)}}`}function lz(n){let t=[];for(let e=0,r=n.length;e<r;){let i=n.codePointAt(e);e+=i<65536?1:2,t.push(i)}return t}function Hu(n){let e=n.length;if(e<4096)return String.fromCodePoint(...n);let r=[];for(let i=0;i<e;)r.push(String.fromCodePoint(...n.slice(i,i+=4096)));return r.join("")}function fz(n,t){let e=n.length,r=e-t.length;for(let i=0;r==0&&i<e;i++)r=n[i]-t[i];return r}var hz="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 yh=44032,lp=4352,fp=4449,hp=4519,mS=19,wS=21,zu=28,dp=wS*zu,dz=mS*dp,pz=yh+dz,gz=lp+mS,yz=fp+wS,mz=hp+zu;function mh(n){return n>>24&255}function bS(n){return n&16777215}let bw,_S,_w,pp;function wz(){let n=hS(hz);bw=new Map(dS(n).flatMap((t,e)=>t.map(r=>[r,e+1<<24]))),_S=new Set(ph(n)),_w=new Map,pp=new Map;for(let[t,e]of pS(n)){if(!_S.has(t)&&e.length==2){let[r,i]=e,s=pp.get(r);s||(s=new Map,pp.set(r,s)),s.set(i,t)}_w.set(t,e.reverse())}}function AS(n){return n>=yh&&n<pz}function bz(n,t){if(n>=lp&&n<gz&&t>=fp&&t<yz)return yh+(n-lp)*dp+(t-fp)*zu;if(AS(n)&&t>hp&&t<mz&&(n-yh)%zu==0)return n+(t-hp);{let e=pp.get(n);return e&&(e=e.get(t),e)?e:-1}}function ES(n){bw||wz();let t=[],e=[],r=!1;function i(s){let o=bw.get(s);o&&(r=!0,s|=o),t.push(s)}for(let s of n)for(;;){if(s<128)t.push(s);else if(AS(s)){let o=s-yh,a=o/dp|0,u=o%dp/zu|0,f=o%zu;i(lp+a),i(fp+u),f>0&&i(hp+f)}else{let o=_w.get(s);o?e.push(...o):i(s)}if(!e.length)break;s=e.pop()}if(r&&t.length>1){let s=mh(t[0]);for(let o=1;o<t.length;o++){let a=mh(t[o]);if(a==0||s<=a){s=a;continue}let u=o-1;for(;;){let f=t[u+1];if(t[u+1]=t[u],t[u]=f,!u||(s=mh(t[--u]),s<=a))break}s=mh(t[o])}}return t}function _z(n){let t=[],e=[],r=-1,i=0;for(let s of n){let o=mh(s),a=bS(s);if(r==-1)o==0?r=a:t.push(a);else if(i>0&&i>=o)o==0?(t.push(r,...e),e.length=0,r=a):e.push(a),i=o;else{let u=bz(r,a);u>=0?r=u:i==0&&o==0?(t.push(r),r=a):(e.push(a),i=o)}}return r>=0&&t.push(r,...e),t}function vS(n){return ES(n).map(bS)}function Az(n){return _z(ES(n))}const xS=45,RS=".",IS=65039,SS=1,gp=n=>Array.from(n);function wh(n,t){return n.P.has(t)||n.Q.has(t)}class Ez extends Array{get is_emoji(){return!0}}let Aw,kS,Ya,Ew,TS,Gu,vw,Vu,Ja,OS,xw;function Rw(){if(Aw)return;let n=hS(tz);const t=()=>ph(n),e=()=>new Set(t()),r=(h,y)=>y.forEach(_=>h.add(_));Aw=new Map(pS(n)),kS=e(),Ya=t(),Ew=new Set(t().map(h=>Ya[h])),Ya=new Set(Ya),TS=e(),e();let i=dS(n),s=n();const o=()=>{let h=new Set;return t().forEach(y=>r(h,i[y])),r(h,t()),h};Gu=gh(h=>{let y=gh(n).map(_=>_+96);if(y.length){let _=h>=s;y[0]-=32,y=Hu(y),_&&(y=`Restricted[${y}]`);let w=o(),R=o(),T=!n();return{N:y,P:w,Q:R,M:T,R:_}}}),vw=e(),Vu=new Map;let a=t().concat(gp(vw)).sort((h,y)=>h-y);a.forEach((h,y)=>{let _=n(),w=a[y]=_?a[y-_]:{V:[],M:new Map};w.V.push(h),vw.has(h)||Vu.set(h,w)});for(let{V:h,M:y}of new Set(Vu.values())){let _=[];for(let R of h){let T=Gu.filter(B=>wh(B,R)),I=_.find(({G:B})=>T.some(H=>B.has(H)));I||(I={G:new Set,V:[]},_.push(I)),I.V.push(R),r(I.G,T)}let w=_.flatMap(R=>gp(R.G));for(let{G:R,V:T}of _){let I=new Set(w.filter(B=>!R.has(B)));for(let B of T)y.set(B,I)}}Ja=new Set;let u=new Set;const f=h=>Ja.has(h)?u.add(h):Ja.add(h);for(let h of Gu){for(let y of h.P)f(y);for(let y of h.Q)f(y)}for(let h of Ja)!Vu.has(h)&&!u.has(h)&&Vu.set(h,SS);r(Ja,vS(Ja)),OS=cz(n).map(h=>Ez.from(h)).sort(fz),xw=new Map;for(let h of OS){let y=[xw];for(let _ of h){let w=y.map(R=>{let T=R.get(_);return T||(T=new Map,R.set(_,T)),T});_===IS?y.push(...w):y=w}for(let _ of y)_.V=h}}function Iw(n){return(NS(n)?"":`${Sw(yp([n]))} `)+yS(n)}function Sw(n){return`"${n}"`}function vz(n){if(n.length>=4&&n[2]==xS&&n[3]==xS)throw new Error(`invalid label extension: "${Hu(n.slice(0,4))}"`)}function xz(n){for(let e=n.lastIndexOf(95);e>0;)if(n[--e]!==95)throw new Error("underscore allowed only at start")}function Rz(n){let t=n[0],e=lS.get(t);if(e)throw bh(`leading ${e}`);let r=n.length,i=-1;for(let s=1;s<r;s++){t=n[s];let o=lS.get(t);if(o){if(i==s)throw bh(`${e} + ${o}`);i=s+1,e=o}}if(i==r)throw bh(`trailing ${e}`)}function yp(n,t=1/0,e=yS){let r=[];Iz(n[0])&&r.push("◌"),n.length>t&&(t>>=1,n=[...n.slice(0,t),8230,...n.slice(-t)]);let i=0,s=n.length;for(let o=0;o<s;o++){let a=n[o];NS(a)&&(r.push(Hu(n.slice(i,o))),r.push(e(a)),i=o+1)}return r.push(Hu(n.slice(i,s))),r.join("")}function Iz(n){return Rw(),Ya.has(n)}function NS(n){return Rw(),TS.has(n)}function Sz(n){return Nz(kz(n,Az,Pz))}function kz(n,t,e){if(!n)return[];Rw();let r=0;return n.split(RS).map(i=>{let s=lz(i),o={input:s,offset:r};r+=s.length+1;try{let a=o.tokens=Bz(s,t,e),u=a.length,f;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(xz(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(_=>_<128))vz(h),f="ASCII";else{let _=a.flatMap(w=>w.is_emoji?[]:w);if(!_.length)f="Emoji";else{if(Ya.has(h[0]))throw bh("leading combining mark");for(let T=1;T<u;T++){let I=a[T];if(!I.is_emoji&&Ya.has(I[0]))throw bh(`emoji + combining mark: "${Hu(a[T-1])} + ${yp([I[0]])}"`)}Rz(h);let w=gp(new Set(_)),[R]=Oz(w);Cz(R,_),Tz(R,w),f=R.N}}o.type=f}catch(a){o.error=a}return o})}function Tz(n,t){let e,r=[];for(let i of t){let s=Vu.get(i);if(s===SS)return;if(s){let o=s.M.get(i);if(e=e?e.filter(a=>o.has(a)):gp(o),!e.length)return}else r.push(i)}if(e){for(let i of e)if(r.every(s=>wh(i,s)))throw new Error(`whole-script confusable: ${n.N}/${i.N}`)}}function Oz(n){let t=Gu;for(let e of n){let r=t.filter(i=>wh(i,e));if(!r.length)throw Gu.some(i=>wh(i,e))?BS(t[0],e):CS(e);if(t=r,r.length==1)break}return t}function Nz(n){return n.map(({input:t,error:e,output:r})=>{if(e){let i=e.message;throw new Error(n.length==1?i:`Invalid label ${Sw(yp(t,63))}: ${i}`)}return Hu(r)}).join(RS)}function CS(n){return new Error(`disallowed character: ${Iw(n)}`)}function BS(n,t){let e=Iw(t),r=Gu.find(i=>i.P.has(t));return r&&(e=`${r.N} ${e}`),new Error(`illegal mixture: ${n.N} + ${e}`)}function bh(n){return new Error(`illegal placement: ${n}`)}function Cz(n,t){for(let e of t)if(!wh(n,e))throw BS(n,e);if(n.M){let e=vS(t);for(let r=1,i=e.length;r<i;r++)if(Ew.has(e[r])){let s=r+1;for(let o;s<i&&Ew.has(o=e[s]);s++)for(let a=r;a<s;a++)if(e[a]==o)throw new Error(`duplicate non-spacing marks: ${Iw(o)}`);if(s-r>fS)throw new Error(`excessive non-spacing marks: ${Sw(yp(e.slice(r-1,s)))} (${s-r}/${fS})`);r=s}}}function Bz(n,t,e){let r=[],i=[];for(n=n.slice().reverse();n.length;){let s=Mz(n);if(s)i.length&&(r.push(t(i)),i=[]),r.push(e(s));else{let o=n.pop();if(Ja.has(o))i.push(o);else{let a=Aw.get(o);if(a)i.push(...a);else if(!kS.has(o))throw CS(o)}}}return i.length&&r.push(t(i)),r}function Pz(n){return n.filter(t=>t!=IS)}function Mz(n,t){let e=xw,r,i=n.length;for(;i&&(e=e.get(n[--i]),!!e);){let{V:s}=e;s&&(r=s,n.length=i)}return r}const PS=new Uint8Array(32);PS.fill(0);function MS(n){return K(n.length!==0,"invalid ENS name; empty component","comp",n),n}function LS(n){const t=Ms(Lz(n)),e=[];if(n.length===0)return e;let r=0;for(let i=0;i<t.length;i++)t[i]===46&&(e.push(MS(t.slice(r,i))),r=i+1);return K(r<t.length,"invalid ENS name; empty component","name",n),e.push(MS(t.slice(r))),e}function Lz(n){try{if(n.length===0)throw new Error("empty label");return Sz(n)}catch(t){K(!1,`invalid ENS name (${t.message})`,"name",n)}}function kw(n){K(typeof n=="string","invalid ENS name; not a string","name",n),K(n.length,"invalid ENS name (empty label)","name",n);let t=PS;const e=LS(n);for(;e.length;)t=Nn(xn([t,Nn(e.pop())]));return Tt(t)}function Uz(n,t){const e=t;return K(e<=255,"DNS encoded label cannot exceed 255","length",e),Tt(xn(LS(n).map(r=>{K(r.length<=e,`label ${JSON.stringify(n)} exceeds ${e} bytes`,"name",n);const i=new Uint8Array(r.length+1);return i.set(r,1),i[0]=i.length-1,i})))+"00"}function Tw(n,t){return{address:Le(n),storageKeys:t.map((e,r)=>(K(Ge(e,32),"invalid slot",`storageKeys[${r}]`,e),e.toLowerCase()))}}function Xa(n){if(Array.isArray(n))return n.map((e,r)=>Array.isArray(e)?(K(e.length===2,"invalid slot set",`value[${r}]`,e),Tw(e[0],e[1])):(K(e!=null&&typeof e=="object","invalid address-slot set","value",n),Tw(e.address,e.storageKeys)));K(n!=null&&typeof n=="object","invalid access list","value",n);const t=Object.keys(n).map(e=>{const r=n[e].reduce((i,s)=>(i[s]=!0,i),{});return Tw(e,Object.keys(r).sort())});return t.sort((e,r)=>e.address.localeCompare(r.address)),t}function Dz(n){let t;return typeof n=="string"?t=dh.computePublicKey(n,!1):t=n.publicKey,Le(Nn("0x"+t.substring(4)).substring(26))}function Fz(n,t){return Dz(dh.recoverPublicKey(n,t))}const Fn=BigInt(0),$z=BigInt(2),Hz=BigInt(27),zz=BigInt(28),Gz=BigInt(35),Vz=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ow=4096*32;function US(n,t){let e=n.toString(16);for(;e.length<2;)e="0"+e;return e+=Lu(t).substring(4),"0x"+e}function mp(n){return n==="0x"?null:Le(n)}function Nw(n,t){try{return Xa(n)}catch(e){K(!1,e.message,t,n)}}function _h(n,t){return n==="0x"?0:ie(n,t)}function In(n,t){if(n==="0x")return Fn;const e=Ct(n,t);return K(e<=Vz,"value exceeds uint size",t,e),e}function Ze(n,t){const e=Ct(n,"value"),r=mr(e);return K(r.length<=32,"value too large",`tx.${t}`,e),r}function Cw(n){return Xa(n).map(t=>[t.address,t.storageKeys])}function Kz(n,t){K(Array.isArray(n),`invalid ${t}`,"value",n);for(let e=0;e<n.length;e++)K(Ge(n[e],32),"invalid ${ param } hash",`value[${e}]`,n[e]);return n}function jz(n){const t=ep(n);K(Array.isArray(t)&&(t.length===9||t.length===6),"invalid field count for legacy transaction","data",n);const e={type:0,nonce:_h(t[0],"nonce"),gasPrice:In(t[1],"gasPrice"),gasLimit:In(t[2],"gasLimit"),to:mp(t[3]),value:In(t[4],"value"),data:Tt(t[5]),chainId:Fn};if(t.length===6)return e;const r=In(t[6],"v"),i=In(t[7],"r"),s=In(t[8],"s");if(i===Fn&&s===Fn)e.chainId=r;else{let o=(r-Gz)/$z;o<Fn&&(o=Fn),e.chainId=o,K(o!==Fn||r===Hz||r===zz,"non-canonical legacy v","v",t[6]),e.signature=Ri.from({r:Va(t[7],32),s:Va(t[8],32),v:r})}return e}function Wz(n,t){const e=[Ze(n.nonce,"nonce"),Ze(n.gasPrice||0,"gasPrice"),Ze(n.gasLimit,"gasLimit"),n.to||"0x",Ze(n.value,"value"),n.data];let r=Fn;if(n.chainId!=Fn)r=Ct(n.chainId,"tx.chainId"),K(!t||t.networkV==null||t.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",t);else if(n.signature){const s=n.signature.legacyChainId;s!=null&&(r=s)}if(!t)return r!==Fn&&(e.push(mr(r)),e.push("0x"),e.push("0x")),Ka(e);let i=BigInt(27+t.yParity);return r!==Fn?i=Ri.getChainIdV(r,t.v):BigInt(t.v)!==i&&K(!1,"tx.chainId/sig.v mismatch","sig",t),e.push(mr(i)),e.push(mr(t.r)),e.push(mr(t.s)),Ka(e)}function Bw(n,t){let e;try{if(e=_h(t[0],"yParity"),e!==0&&e!==1)throw new Error("bad yParity")}catch{K(!1,"invalid yParity","yParity",t[0])}const r=Va(t[1],32),i=Va(t[2],32),s=Ri.from({r,s:i,yParity:e});n.signature=s}function Zz(n){const t=ep(we(n).slice(1));K(Array.isArray(t)&&(t.length===9||t.length===12),"invalid field count for transaction type: 2","data",Tt(n));const e={type:2,chainId:In(t[0],"chainId"),nonce:_h(t[1],"nonce"),maxPriorityFeePerGas:In(t[2],"maxPriorityFeePerGas"),maxFeePerGas:In(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:In(t[4],"gasLimit"),to:mp(t[5]),value:In(t[6],"value"),data:Tt(t[7]),accessList:Nw(t[8],"accessList")};return t.length===9||Bw(e,t.slice(9)),e}function qz(n,t){const e=[Ze(n.chainId,"chainId"),Ze(n.nonce,"nonce"),Ze(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ze(n.maxFeePerGas||0,"maxFeePerGas"),Ze(n.gasLimit,"gasLimit"),n.to||"0x",Ze(n.value,"value"),n.data,Cw(n.accessList||[])];return t&&(e.push(Ze(t.yParity,"yParity")),e.push(mr(t.r)),e.push(mr(t.s))),xn(["0x02",Ka(e)])}function Qz(n){const t=ep(we(n).slice(1));K(Array.isArray(t)&&(t.length===8||t.length===11),"invalid field count for transaction type: 1","data",Tt(n));const e={type:1,chainId:In(t[0],"chainId"),nonce:_h(t[1],"nonce"),gasPrice:In(t[2],"gasPrice"),gasLimit:In(t[3],"gasLimit"),to:mp(t[4]),value:In(t[5],"value"),data:Tt(t[6]),accessList:Nw(t[7],"accessList")};return t.length===8||Bw(e,t.slice(8)),e}function Yz(n,t){const e=[Ze(n.chainId,"chainId"),Ze(n.nonce,"nonce"),Ze(n.gasPrice||0,"gasPrice"),Ze(n.gasLimit,"gasLimit"),n.to||"0x",Ze(n.value,"value"),n.data,Cw(n.accessList||[])];return t&&(e.push(Ze(t.yParity,"recoveryParam")),e.push(mr(t.r)),e.push(mr(t.s))),xn(["0x01",Ka(e)])}function Jz(n){let t=ep(we(n).slice(1)),e="3",r=null;if(t.length===4&&Array.isArray(t[0])){e="3 (network format)";const s=t[1],o=t[2],a=t[3];K(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),K(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),K(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),K(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",t),K(s.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",t),r=[];for(let u=0;u<t[1].length;u++)r.push({data:s[u],commitment:o[u],proof:a[u]});t=t[0]}K(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${e}`,"data",Tt(n));const i={type:3,chainId:In(t[0],"chainId"),nonce:_h(t[1],"nonce"),maxPriorityFeePerGas:In(t[2],"maxPriorityFeePerGas"),maxFeePerGas:In(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:In(t[4],"gasLimit"),to:mp(t[5]),value:In(t[6],"value"),data:Tt(t[7]),accessList:Nw(t[8],"accessList"),maxFeePerBlobGas:In(t[9],"maxFeePerBlobGas"),blobVersionedHashes:t[10]};r&&(i.blobs=r),K(i.to!=null,`invalid address for transaction type: ${e}`,"data",n),K(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let s=0;s<i.blobVersionedHashes.length;s++)K(Ge(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",n);return t.length===11||Bw(i,t.slice(11)),i}function Xz(n,t,e){const r=[Ze(n.chainId,"chainId"),Ze(n.nonce,"nonce"),Ze(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ze(n.maxFeePerGas||0,"maxFeePerGas"),Ze(n.gasLimit,"gasLimit"),n.to||hh,Ze(n.value,"value"),n.data,Cw(n.accessList||[]),Ze(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Kz(n.blobVersionedHashes||[],"blobVersionedHashes")];return t&&(r.push(Ze(t.yParity,"yParity")),r.push(mr(t.r)),r.push(mr(t.s)),e)?xn(["0x03",Ka([r,e.map(i=>i.data),e.map(i=>i.commitment),e.map(i=>i.proof)])]):xn(["0x03",Ka(r)])}const Ys=class Ys{constructor(){Y(this,xl);Y(this,os);Y(this,dl);Y(this,pl);Y(this,gl);Y(this,yl);Y(this,ml);Y(this,wl);Y(this,bl);Y(this,_l);Y(this,Al);Y(this,El);Y(this,vl);Y(this,wc);Y(this,Ko);Y(this,Qs);Y(this,jo);F(this,os,null),F(this,dl,null),F(this,gl,0),F(this,yl,Fn),F(this,ml,null),F(this,wl,null),F(this,bl,null),F(this,pl,"0x"),F(this,_l,Fn),F(this,Al,Fn),F(this,El,null),F(this,vl,null),F(this,wc,null),F(this,Ko,null),F(this,jo,null),F(this,Qs,null)}get type(){return S(this,os)}set type(t){switch(t){case null:F(this,os,null);break;case 0:case"legacy":F(this,os,0);break;case 1:case"berlin":case"eip-2930":F(this,os,1);break;case 2:case"london":case"eip-1559":F(this,os,2);break;case 3:case"cancun":case"eip-4844":F(this,os,3);break;default:K(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const t=S(this,dl);return t==null&&this.type===3?hh:t}set to(t){F(this,dl,t==null?null:Le(t))}get nonce(){return S(this,gl)}set nonce(t){F(this,gl,ie(t,"value"))}get gasLimit(){return S(this,yl)}set gasLimit(t){F(this,yl,Ct(t))}get gasPrice(){const t=S(this,ml);return t==null&&(this.type===0||this.type===1)?Fn:t}set gasPrice(t){F(this,ml,t==null?null:Ct(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=S(this,wl);return t??(this.type===2||this.type===3?Fn:null)}set maxPriorityFeePerGas(t){F(this,wl,t==null?null:Ct(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=S(this,bl);return t??(this.type===2||this.type===3?Fn:null)}set maxFeePerGas(t){F(this,bl,t==null?null:Ct(t,"maxFeePerGas"))}get data(){return S(this,pl)}set data(t){F(this,pl,Tt(t))}get value(){return S(this,_l)}set value(t){F(this,_l,Ct(t,"value"))}get chainId(){return S(this,Al)}set chainId(t){F(this,Al,Ct(t))}get signature(){return S(this,El)||null}set signature(t){F(this,El,t==null?null:Ri.from(t))}get accessList(){const t=S(this,vl)||null;return t??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(t){F(this,vl,t==null?null:Xa(t))}get maxFeePerBlobGas(){const t=S(this,wc);return t==null&&this.type===3?Fn:t}set maxFeePerBlobGas(t){F(this,wc,t==null?null:Ct(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=S(this,Ko);return t==null&&this.type===3?[]:t}set blobVersionedHashes(t){if(t!=null){K(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)K(Ge(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}F(this,Ko,t)}get blobs(){return S(this,jo)==null?null:S(this,jo).map(t=>Object.assign({},t))}set blobs(t){if(t==null){F(this,jo,null);return}const e=[],r=[];for(let i=0;i<t.length;i++){const s=t[i];if(Wm(s)){ht(S(this,Qs),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=we(s);if(K(o.length<=Ow,"blob is too large",`blobs[${i}]`,s),o.length!==Ow){const f=new Uint8Array(Ow);f.set(o),o=f}const a=S(this,Qs).blobToKzgCommitment(o),u=Tt(S(this,Qs).computeBlobKzgProof(o,a));e.push({data:Tt(o),commitment:Tt(a),proof:u}),r.push(US(1,a))}else{const o=Tt(s.commitment);e.push({data:Tt(s.data),commitment:o,proof:Tt(s.proof)}),r.push(US(1,o))}}F(this,jo,e),F(this,Ko,r)}get kzg(){return S(this,Qs)}set kzg(t){F(this,Qs,t)}get hash(){return this.signature==null?null:Nn(yt(this,xl,cg).call(this,!0,!1))}get unsignedHash(){return Nn(this.unsignedSerialized)}get from(){return this.signature==null?null:Fz(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:dh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return yt(this,xl,cg).call(this,!0,!0)}get unsignedSerialized(){return yt(this,xl,cg).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=this.gasPrice!=null,e=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,i=S(this,wc)!=null||S(this,Ko);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ht(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ht(!e||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ht(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):e?s.push(2):t?(s.push(1),r||s.push(0)):r?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Ys.from(this)}toJSON(){const t=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new Ys;if(typeof t=="string"){const r=we(t);if(r[0]>=127)return Ys.from(jz(r));switch(r[0]){case 1:return Ys.from(Qz(r));case 2:return Ys.from(Zz(r));case 3:return Ys.from(Jz(r))}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new Ys;return t.type!=null&&(e.type=t.type),t.to!=null&&(e.to=t.to),t.nonce!=null&&(e.nonce=t.nonce),t.gasLimit!=null&&(e.gasLimit=t.gasLimit),t.gasPrice!=null&&(e.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(e.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(e.data=t.data),t.value!=null&&(e.value=t.value),t.chainId!=null&&(e.chainId=t.chainId),t.signature!=null&&(e.signature=Ri.from(t.signature)),t.accessList!=null&&(e.accessList=t.accessList),t.blobVersionedHashes!=null&&(e.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(e.kzg=t.kzg),t.blobs!=null&&(e.blobs=t.blobs),t.hash!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),K(e.hash===t.hash,"hash mismatch","tx",t)),t.from!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),K(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}};os=new WeakMap,dl=new WeakMap,pl=new WeakMap,gl=new WeakMap,yl=new WeakMap,ml=new WeakMap,wl=new WeakMap,bl=new WeakMap,_l=new WeakMap,Al=new WeakMap,El=new WeakMap,vl=new WeakMap,wc=new WeakMap,Ko=new WeakMap,Qs=new WeakMap,jo=new WeakMap,xl=new WeakSet,cg=function(t,e){ht(!t||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return Wz(this,r);case 1:return Yz(this,r);case 2:return qz(this,r);case 3:return Xz(this,r,e?this.blobs:null)}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let wp=Ys;const DS=new Uint8Array(32);DS.fill(0);const tG=BigInt(-1),FS=BigInt(0),$S=BigInt(1),eG=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function nG(n){const t=we(n),e=t.length%32;return e?xn([t,DS.slice(e)]):Tt(t)}const rG=Bo($S,32),iG=Bo(FS,32),HS={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Pw=["name","version","chainId","verifyingContract","salt"];function zS(n){return function(t){return K(typeof t=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const sG={name:zS("name"),version:zS("version"),chainId:function(n){const t=Ct(n,"domain.chainId");return K(t>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(t)?Number(t):Bu(t)},verifyingContract:function(n){try{return Le(n).toLowerCase()}catch{}K(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const t=we(n,"domain.salt");return K(t.length===32,'invalid domain value "salt"',"domain.salt",n),Tt(t)}};function Mw(n){{const t=n.match(/^(u?)int(\d+)$/);if(t){const e=t[1]==="",r=parseInt(t[2]);K(r%8===0&&r!==0&&r<=256&&t[2]===String(r),"invalid numeric width","type",n);const i=ah(eG,e?r-1:r),s=e?(i+$S)*tG:FS;return function(o){const a=Ct(o,"value");return K(a>=s&&a<=i,`value out-of-bounds for ${n}`,"value",a),Bo(e?KR(a,256):a,32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return K(e!==0&&e<=32&&t[1]===String(e),"invalid bytes width","type",n),function(r){const i=we(r);return K(i.length===e,`invalid length for ${n}`,"value",r),nG(r)}}}switch(n){case"address":return function(t){return Va(Le(t),32)};case"bool":return function(t){return t?rG:iG};case"bytes":return function(t){return Nn(t)};case"string":return function(t){return Qa(t)}}return null}function GS(n,t){return`${n}(${t.map(({name:e,type:r})=>r+" "+e).join(",")})`}function bp(n){const t=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:n}}const ui=class ui{constructor(t){Y(this,Up);Z(this,"primaryType");Y(this,Mh);Y(this,Js);Y(this,Rl);F(this,Js,new Map),F(this,Rl,new Map);const e=new Map,r=new Map,i=new Map,s={};Object.keys(t).forEach(u=>{s[u]=t[u].map(({name:f,type:h})=>{let{base:y,index:_}=bp(h);return y==="int"&&!t.int&&(y="int256"),y==="uint"&&!t.uint&&(y="uint256"),{name:f,type:y+(_||"")}}),e.set(u,new Set),r.set(u,[]),i.set(u,new Set)}),F(this,Mh,JSON.stringify(s));for(const u in s){const f=new Set;for(const h of s[u]){K(!f.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",t),f.add(h.name);const y=bp(h.type).base;K(y!==u,`circular type reference to ${JSON.stringify(y)}`,"types",t),!Mw(y)&&(K(r.has(y),`unknown type ${JSON.stringify(y)}`,"types",t),r.get(y).push(u),e.get(u).add(y))}}const o=Array.from(r.keys()).filter(u=>r.get(u).length===0);K(o.length!==0,"missing primary type","types",t),K(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",t),$t(this,{primaryType:o[0]});function a(u,f){K(!f.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",t),f.add(u);for(const h of e.get(u))if(r.has(h)){a(h,f);for(const y of f)i.get(y).add(h)}f.delete(u)}a(this.primaryType,new Set);for(const[u,f]of i){const h=Array.from(f);h.sort(),S(this,Js).set(u,GS(u,s[u])+h.map(y=>GS(y,s[y])).join(""))}}get types(){return JSON.parse(S(this,Mh))}getEncoder(t){let e=S(this,Rl).get(t);return e||(e=yt(this,Up,cO).call(this,t),S(this,Rl).set(t,e)),e}encodeType(t){const e=S(this,Js).get(t);return K(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Nn(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Mw(t))return r(t,e);const i=bp(t).array;if(i)return K(i.count===-1||i.count===e.length,`array length mismatch; expected length ${i.count}`,"value",e),e.map(o=>this._visit(i.prefix,o,r));const s=this.types[t];if(s)return s.reduce((o,{name:a,type:u})=>(o[a]=this._visit(u,e[a],r),o),{});K(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new ui(t)}static getPrimaryType(t){return ui.from(t).primaryType}static hashStruct(t,e,r){return ui.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(t[r]==null)continue;const i=HS[r];K(i,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort((r,i)=>Pw.indexOf(r.name)-Pw.indexOf(i.name)),ui.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return xn(["0x1901",ui.hashDomain(t),ui.from(e).hash(r)])}static hash(t,e,r){return Nn(ui.encode(t,e,r))}static async resolveNames(t,e,r,i){t=Object.assign({},t);for(const a in t)t[a]==null&&delete t[a];const s={};t.verifyingContract&&!Ge(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const o=ui.from(e);o.visit(r,(a,u)=>(a==="address"&&!Ge(u,20)&&(s[u]="0x"),u));for(const a in s)s[a]=await i(a);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),r=o.visit(r,(a,u)=>a==="address"&&s[u]?s[u]:u),{domain:t,value:r}}static getPayload(t,e,r){ui.hashDomain(t);const i={},s=[];Pw.forEach(u=>{const f=t[u];f!=null&&(i[u]=sG[u](f),s.push({name:u,type:HS[u]}))});const o=ui.from(e);e=o.types;const a=Object.assign({},e);return K(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",e),a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,(u,f)=>{if(u.match(/^bytes(\d*)/))return Tt(we(f));if(u.match(/^u?int/))return Ct(f).toString();switch(u){case"address":return f.toLowerCase();case"bool":return!!f;case"string":return K(typeof f=="string","invalid string","value",f),f}K(!1,"unsupported type","type",u)})}}};Mh=new WeakMap,Js=new WeakMap,Rl=new WeakMap,Up=new WeakSet,cO=function(t){{const i=Mw(t);if(i)return i}const e=bp(t).array;if(e){const i=e.prefix,s=this.getEncoder(i);return o=>{K(e.count===-1||e.count===o.length,`array length mismatch; expected length ${e.count}`,"value",o);let a=o.map(s);return S(this,Js).has(i)&&(a=a.map(Nn)),Nn(xn(a))}}const r=this.types[t];if(r){const i=Qa(S(this,Js).get(t));return s=>{const o=r.map(({name:a,type:u})=>{const f=this.getEncoder(u)(s[a]);return S(this,Js).has(u)?Nn(f):f});return o.unshift(i),xn(o)}}K(!1,`unknown type: ${t}`,"type",t)};let _p=ui;function _r(n){const t=new Set;return n.forEach(e=>t.add(e)),Object.freeze(t)}const oG=_r("external public payable override".split(" ")),VS="constant external internal payable private public pure view override",aG=_r(VS.split(" ")),KS="constructor error event fallback function receive struct",jS=_r(KS.split(" ")),WS="calldata memory storage payable indexed",cG=_r(WS.split(" ")),uG=[KS,WS,"tuple returns",VS].join(" "),lG=_r(uG.split(" ")),fG={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},hG=new RegExp("^(\\s*)"),dG=new RegExp("^([0-9]+)"),pG=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),ZS=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),qS=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Dp=class Dp{constructor(t){Y(this,Lh);Y(this,Jn);Y(this,Ni);F(this,Jn,0),F(this,Ni,t.slice())}get offset(){return S(this,Jn)}get length(){return S(this,Ni).length-S(this,Jn)}clone(){return new Dp(S(this,Ni))}reset(){F(this,Jn,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=yt(this,Lh,Tb).call(this,S(this,Jn)+1,t.match+1);return F(this,Jn,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;S(this,Jn)<t.match-1;){const r=this.peek().linkNext;e.push(yt(this,Lh,Tb).call(this,S(this,Jn)+1,r)),F(this,Jn,r)}return F(this,Jn,t.match+1),e}peek(){if(S(this,Jn)>=S(this,Ni).length)throw new Error("out-of-bounds");return S(this,Ni)[S(this,Jn)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return ao(this,Jn)._++,t}toString(){const t=[];for(let e=S(this,Jn);e<S(this,Ni).length;e++){const r=S(this,Ni)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Jn=new WeakMap,Ni=new WeakMap,Lh=new WeakSet,Tb=function(t=0,e=0){return new Dp(S(this,Ni).slice(t,e).map(r=>Object.freeze(Object.assign({},r,{match:r.match-t,linkBack:r.linkBack-t,linkNext:r.linkNext-t}))))};let Ii=Dp;function $o(n){const t=[],e=o=>{const a=s<n.length?JSON.stringify(n[s]):"$EOI";throw new Error(`invalid token ${a} at ${s}: ${o}`)};let r=[],i=[],s=0;for(;s<n.length;){let o=n.substring(s),a=o.match(hG);a&&(s+=a[1].length,o=n.substring(s));const u={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};t.push(u);let f=fG[o[0]]||"";if(f){if(u.type=f,u.text=o[0],s++,f==="OPEN_PAREN")r.push(t.length-1),i.push(t.length-1);else if(f=="CLOSE_PAREN")r.length===0&&e("no matching open bracket"),u.match=r.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1;else if(f==="COMMA")u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(f==="OPEN_BRACKET")u.type="BRACKET";else if(f==="CLOSE_BRACKET"){let h=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const y=t.pop().text;h=y+h,t[t.length-1].value=ie(y)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=h}continue}if(a=o.match(pG),a){if(u.text=a[1],s+=u.text.length,lG.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(qS)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(dG),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 Ii(t.map(o=>Object.freeze(o)))}function QS(n,t){let e=[];for(const r in t.keys())n.has(r)&&e.push(r);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function Ap(n,t){if(t.peekKeyword(jS)){const e=t.pop().text;if(e!==n)throw new Error(`expected ${n}, got ${e}`)}return t.popType("ID")}function $s(n,t){const e=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||t&&!t.has(r))break;if(n.pop(),e.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);e.add(r)}return Object.freeze(e)}function YS(n){let t=$s(n,aG);return QS(t,_r("constant payable nonpayable".split(" "))),QS(t,_r("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Hs(n,t){return n.popParams().map(e=>Qn.from(e,t))}function JS(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ct(n.pop().text);throw new Error("invalid gas")}return null}function tc(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const gG=new RegExp(/^(.*)\[([0-9]*)\]$/);function XS(n){const t=n.match(qS);if(K(t,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(t[2]){const e=parseInt(t[2]);K(e!==0&&e<=32,"invalid bytes length","type",n)}else if(t[3]){const e=parseInt(t[3]);K(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",n)}return n}const rn={},Nr=Symbol.for("_ethers_internal"),tk="_ParamTypeInternal",ek="_ErrorInternal",nk="_EventInternal",rk="_ConstructorInternal",ik="_FallbackInternal",sk="_FunctionInternal",ok="_StructInternal",li=class li{constructor(t,e,r,i,s,o,a,u){Y(this,Il);Z(this,"name");Z(this,"type");Z(this,"baseType");Z(this,"indexed");Z(this,"components");Z(this,"arrayLength");Z(this,"arrayChildren");if(q0(t,rn,"ParamType"),Object.defineProperty(this,Nr,{value:tk}),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("");$t(this,{name:e,type:r,baseType:i,indexed:s,components:o,arrayLength:a,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const r=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=r,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(t)))),JSON.stringify(i)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(r=>r.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map(i=>r.arrayChildren.walk(i,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map((i,s)=>r.components[s].walk(i,e))}return e(this.type,t)}async walkAsync(t,e){const r=[],i=[t];return yt(this,Il,ug).call(this,r,t,e,s=>{i[0]=s}),r.length&&await Promise.all(r),i[0]}static from(t,e){if(li.isParamType(t))return t;if(typeof t=="string")try{return li.from($o(t),e)}catch{K(!1,"invalid param type","obj",t)}else if(t instanceof Ii){let a="",u="",f=null;$s(t,_r(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",f=t.popParams().map(T=>li.from(T)),a=`tuple(${f.map(T=>T.format()).join(",")})`):(a=XS(t.popType("TYPE")),u=a);let h=null,y=null;for(;t.length&&t.peekType("BRACKET");){const T=t.pop();h=new li(rn,"",a,u,null,f,y,h),y=T.value,a+=T.text,u="array",f=null}let _=null;if($s(t,cG).has("indexed")){if(!e)throw new Error("");_=!0}const R=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new li(rn,R,a,u,_,f,y,h)}const r=t.name;K(!r||typeof r=="string"&&r.match(ZS),"invalid name","obj.name",r);let i=t.indexed;i!=null&&(K(e,"parameter cannot be indexed","obj.indexed",t.indexed),i=!!i);let s=t.type,o=s.match(gG);if(o){const a=parseInt(o[2]||"-1"),u=li.from({type:o[1],components:t.components});return new li(rn,r||"",s,"array",i,null,a,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const a=t.components!=null?t.components.map(f=>li.from(f)):null;return new li(rn,r||"",s,"tuple",i,a,null,null)}return s=XS(t.type),new li(rn,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Nr]===tk}};Il=new WeakSet,ug=function(t,e,r,i){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=e.slice();a.forEach((u,f)=>{var h;yt(h=o,Il,ug).call(h,t,u,r,y=>{a[f]=y})}),i(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(e))a=e.slice();else{if(e==null||typeof e!="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 e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((u,f)=>{var h;yt(h=o[f],Il,ug).call(h,t,u,r,y=>{a[f]=y})}),i(a);return}const s=r(this.type,e);s.then?t.push(async function(){i(await s)}()):i(s)};let Qn=li;class ec{constructor(t,e,r){Z(this,"type");Z(this,"inputs");q0(t,rn,"Fragment"),r=Object.freeze(r.slice()),$t(this,{type:e,inputs:r})}static from(t){if(typeof t=="string"){try{ec.from(JSON.parse(t))}catch{}return ec.from($o(t))}if(t instanceof Ii)switch(t.peekKeyword(jS)){case"constructor":return zs.from(t);case"error":return Cr.from(t);case"event":return ns.from(t);case"fallback":case"receive":return Gs.from(t);case"function":return rs.from(t);case"struct":return nc.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return zs.from(t);case"error":return Cr.from(t);case"event":return ns.from(t);case"fallback":case"receive":return Gs.from(t);case"function":return rs.from(t);case"struct":return nc.from(t)}ht(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}K(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return zs.isFragment(t)}static isError(t){return Cr.isFragment(t)}static isEvent(t){return ns.isFragment(t)}static isFunction(t){return rs.isFragment(t)}static isStruct(t){return nc.isFragment(t)}}class Ep extends ec{constructor(e,r,i,s){super(e,r,s);Z(this,"name");K(typeof i=="string"&&i.match(ZS),"invalid identifier","name",i),s=Object.freeze(s.slice()),$t(this,{name:i})}}function Ah(n,t){return"("+t.map(e=>e.format(n)).join(n==="full"?", ":",")+")"}class Cr extends Ep{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Nr,{value:ek})}get selector(){return Qa(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+Ah(t,this.inputs)),e.join(" ")}static from(t){if(Cr.isFragment(t))return t;if(typeof t=="string")return Cr.from($o(t));if(t instanceof Ii){const e=Ap("error",t),r=Hs(t);return tc(t),new Cr(rn,e,r)}return new Cr(rn,t.name,t.inputs?t.inputs.map(Qn.from):[])}static isFragment(t){return t&&t[Nr]===ek}}class ns extends Ep{constructor(e,r,i,s){super(e,"event",r,i);Z(this,"anonymous");Object.defineProperty(this,Nr,{value:nk}),$t(this,{anonymous:s})}get topicHash(){return Qa(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("event"),r.push(this.name+Ah(e,this.inputs)),e!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(e,r){return r=(r||[]).map(s=>Qn.from(s)),new ns(rn,e,r,!1).topicHash}static from(e){if(ns.isFragment(e))return e;if(typeof e=="string")try{return ns.from($o(e))}catch{K(!1,"invalid event fragment","obj",e)}else if(e instanceof Ii){const r=Ap("event",e),i=Hs(e,!0),s=!!$s(e,_r(["anonymous"])).has("anonymous");return tc(e),new ns(rn,r,i,s)}return new ns(rn,e.name,e.inputs?e.inputs.map(r=>Qn.from(r,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[Nr]===nk}}class zs extends ec{constructor(e,r,i,s,o){super(e,r,i);Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Nr,{value:rk}),$t(this,{payable:s,gas:o})}format(e){if(ht(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[`constructor${Ah(e,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(e){if(zs.isFragment(e))return e;if(typeof e=="string")try{return zs.from($o(e))}catch{K(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof Ii){$s(e,_r(["constructor"]));const r=Hs(e),i=!!$s(e,oG).has("payable"),s=JS(e);return tc(e),new zs(rn,"constructor",r,i,s)}return new zs(rn,"constructor",e.inputs?e.inputs.map(Qn.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Nr]===rk}}class Gs extends ec{constructor(e,r,i){super(e,"fallback",r);Z(this,"payable");Object.defineProperty(this,Nr,{value:ik}),$t(this,{payable:i})}format(e){const r=this.inputs.length===0?"receive":"fallback";if(e==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:i})}return`${r}()${this.payable?" payable":""}`}static from(e){if(Gs.isFragment(e))return e;if(typeof e=="string")try{return Gs.from($o(e))}catch{K(!1,"invalid fallback fragment","obj",e)}else if(e instanceof Ii){const r=e.toString(),i=e.peekKeyword(_r(["fallback","receive"]));if(K(i,"type must be fallback or receive","obj",r),e.popKeyword(_r(["fallback","receive"]))==="receive"){const u=Hs(e);return K(u.length===0,"receive cannot have arguments","obj.inputs",u),$s(e,_r(["payable"])),tc(e),new Gs(rn,[],!0)}let o=Hs(e);o.length?K(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Qn.from("bytes")];const a=YS(e);if(K(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),$s(e,_r(["returns"])).has("returns")){const u=Hs(e);K(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(f=>f.format("minimal")).join(", "))}return tc(e),new Gs(rn,o,a==="payable")}if(e.type==="receive")return new Gs(rn,[],!0);if(e.type==="fallback"){const r=[Qn.from("bytes")],i=e.stateMutability==="payable";return new Gs(rn,r,i)}K(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Nr]===ik}}class rs extends Ep{constructor(e,r,i,s,o,a){super(e,"function",r,s);Z(this,"constant");Z(this,"outputs");Z(this,"stateMutability");Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Nr,{value:sk}),o=Object.freeze(o.slice()),$t(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return Qa(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("function"),r.push(this.name+Ah(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Ah(e,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(e,r){return r=(r||[]).map(s=>Qn.from(s)),new rs(rn,e,"view",r,[],null).selector}static from(e){if(rs.isFragment(e))return e;if(typeof e=="string")try{return rs.from($o(e))}catch{K(!1,"invalid function fragment","obj",e)}else if(e instanceof Ii){const i=Ap("function",e),s=Hs(e),o=YS(e);let a=[];$s(e,_r(["returns"])).has("returns")&&(a=Hs(e));const u=JS(e);return tc(e),new rs(rn,i,o,s,a,u)}let r=e.stateMutability;return r==null&&(r="payable",typeof e.constant=="boolean"?(r="view",e.constant||(r="payable",typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable")),new rs(rn,e.name,r,e.inputs?e.inputs.map(Qn.from):[],e.outputs?e.outputs.map(Qn.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Nr]===sk}}class nc extends Ep{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Nr,{value:ok})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return nc.from($o(t))}catch{K(!1,"invalid struct fragment","obj",t)}else if(t instanceof Ii){const e=Ap("struct",t),r=Hs(t);return tc(t),new nc(rn,e,r)}return new nc(rn,t.name,t.inputs?t.inputs.map(Qn.from):[])}static isFragment(t){return t&&t[Nr]===ok}}const Si=new Map;Si.set(0,"GENERIC_PANIC"),Si.set(1,"ASSERT_FALSE"),Si.set(17,"OVERFLOW"),Si.set(18,"DIVIDE_BY_ZERO"),Si.set(33,"ENUM_RANGE_ERROR"),Si.set(34,"BAD_STORAGE_DATA"),Si.set(49,"STACK_UNDERFLOW"),Si.set(50,"ARRAY_RANGE_ERROR"),Si.set(65,"OUT_OF_MEMORY"),Si.set(81,"UNINITIALIZED_FUNCTION_CALL");const yG=new RegExp(/^bytes([0-9]*)$/),mG=new RegExp(/^(u?int)([0-9]*)$/);let Lw=null,ak=1024;function wG(n,t,e,r){let i="missing revert data",s=null;const o=null;let a=null;if(e){i="execution reverted";const f=we(e);if(e=Tt(e),f.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(f.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(Tt(f.slice(0,4))==="0x08c379a0")try{s=r.decode(["string"],f.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(Tt(f.slice(0,4))==="0x4e487b71")try{const h=Number(r.decode(["uint256"],f.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Si.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:t.to?Le(t.to):null,data:t.data||"0x"};return t.from&&(u.from=Le(t.from)),Ye(i,"CALL_EXCEPTION",{action:n,data:e,reason:s,transaction:u,invocation:o,revert:a})}const Fp=class Fp{constructor(){Y(this,Wo)}getDefaultValue(t){const e=t.map(i=>yt(this,Wo,Jl).call(this,Qn.from(i)));return new up(e,"_").defaultValue()}encode(t,e){HR(e.length,t.length,"types/values length mismatch");const r=t.map(o=>yt(this,Wo,Jl).call(this,Qn.from(o))),i=new up(r,"_"),s=new Jm;return i.encode(s,e),s.data}decode(t,e,r){const i=t.map(o=>yt(this,Wo,Jl).call(this,Qn.from(o)));return new up(i,"_").decode(new Xm(e,r,ak))}static _setDefaultMaxInflation(t){K(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),ak=t}static defaultAbiCoder(){return Lw==null&&(Lw=new Fp),Lw}static getBuiltinCallException(t,e,r){return wG(t,e,r,Fp.defaultAbiCoder())}};Wo=new WeakSet,Jl=function(t){if(t.isArray())return new GH(yt(this,Wo,Jl).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new up(t.components.map(r=>yt(this,Wo,Jl).call(this,r)),t.name);switch(t.baseType){case"address":return new HH(t.name);case"bool":return new VH(t.name);case"string":return new XH(t.name);case"bytes":return new KH(t.name);case"":return new ZH(t.name)}let e=t.type.match(mG);if(e){let r=parseInt(e[2]||"256");return K(r!==0&&r<=256&&r%8===0,"invalid "+e[1]+" bit length","param",t),new JH(r/8,e[1]==="int",t.name)}if(e=t.type.match(yG),e){let r=parseInt(e[1]);return K(r!==0&&r<=32,"invalid bytes length","param",t),new jH(r,t.name)}K(!1,"invalid type","type",t.type)};let Eh=Fp;class bG{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"signature");Z(this,"topic");Z(this,"args");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,signature:s,topic:e,args:r})}}class _G{constructor(t,e,r,i){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");Z(this,"value");const s=t.name,o=t.format();$t(this,{fragment:t,name:s,args:r,signature:o,selector:e,value:i})}}class AG{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,args:r,signature:s,selector:e})}}class ck{constructor(t){Z(this,"hash");Z(this,"_isIndexed");$t(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const uk={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"},lk={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let t="unknown panic code";return n>=0&&n<=255&&uk[n.toString()]&&(t=uk[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${t})`}}},bc=class bc{constructor(t){Y(this,ls);Z(this,"fragments");Z(this,"deploy");Z(this,"fallback");Z(this,"receive");Y(this,as);Y(this,cs);Y(this,us);Y(this,or);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,F(this,us,new Map),F(this,as,new Map),F(this,cs,new Map);const r=[];for(const o of e)try{r.push(ec.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}$t(this,{fragments:Object.freeze(r)});let i=null,s=!1;F(this,or,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}$t(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(K(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${a}]`,o),i=o,s=i.payable);return;case"function":u=S(this,us);break;case"event":u=S(this,cs);break;case"error":u=S(this,as);break;default:return}const f=o.format();u.has(f)||u.set(f,o)}),this.deploy||$t(this,{deploy:zs.from("constructor()")}),$t(this,{fallback:i,receive:s})}format(t){const e=t?"minimal":"full";return this.fragments.map(i=>i.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return Eh.defaultAbiCoder()}getFunctionName(t){const e=yt(this,ls,lg).call(this,t,null,!1);return K(e,"no matching function","key",t),e.name}hasFunction(t){return!!yt(this,ls,lg).call(this,t,null,!1)}getFunction(t,e){return yt(this,ls,lg).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(S(this,us).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,us).get(i),r)}}getEventName(t){const e=yt(this,ls,fg).call(this,t,null,!1);return K(e,"no matching event","key",t),e.name}hasEvent(t){return!!yt(this,ls,fg).call(this,t,null,!1)}getEvent(t,e){return yt(this,ls,fg).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(S(this,cs).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,cs).get(i),r)}}getError(t,e){if(Ge(t)){const i=t.toLowerCase();if(lk[i])return Cr.from(lk[i].signature);for(const s of S(this,as).values())if(i===s.selector)return s;return null}if(t.indexOf("(")===-1){const i=[];for(const[s,o]of S(this,as))s.split("(")[0]===t&&i.push(o);if(i.length===0)return t==="Error"?Cr.from("error Error(string)"):t==="Panic"?Cr.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");K(!1,`ambiguous error description (i.e. ${s})`,"name",t)}return i[0]}if(t=Cr.from(t).format(),t==="Error(string)")return Cr.from("error Error(string)");if(t==="Panic(uint256)")return Cr.from("error Panic(uint256)");const r=S(this,as).get(t);return r||null}forEachError(t){const e=Array.from(S(this,as).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,as).get(i),r)}}_decodeParams(t,e){return S(this,or).decode(t,e)}_encodeParams(t,e){return S(this,or).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return K(ln(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,ln(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return xn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return K(ln(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,ln(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return xn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const s=this.getFunction(t);K(s,"unknown function","fragment",t),t=s}let r="invalid length for result data";const i=yr(e);if(i.length%32===0)try{return S(this,or).decode(t.outputs,i)}catch{r="could not decode result data"}ht(!1,r,"BAD_DATA",{value:Tt(i),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=we(t,"data"),i=Eh.getBuiltinCallException("call",e,r);if(i.message.startsWith("execution reverted (unknown custom error)")){const a=Tt(r.slice(0,4)),u=this.getError(a);if(u)try{const f=S(this,or).decode(u.inputs,r.slice(4));i.revert={name:u.name,signature:u.format(),args:f},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return Tt(S(this,or).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const s=this.getEvent(t);K(s,"unknown event","eventFragment",t),t=s}ht(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const i=(s,o)=>s.type==="string"?Qa(o):s.type==="bytes"?Nn(Tt(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=Bo(o):s.type.match(/^bytes/)?o=n$(o,32):s.type==="address"&&S(this,or).encode(["address"],[o]),Va(Tt(o),32));for(e.forEach((s,o)=>{const a=t.inputs[o];if(!a.indexed){K(s==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?K(!1,"filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?r.push(s.map(u=>i(a,u))):r.push(i(a,s))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);K(o,"unknown event","eventFragment",t),t=o}const r=[],i=[],s=[];return t.anonymous||r.push(t.topicHash),K(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,a)=>{const u=e[a];if(o.indexed)if(o.type==="string")r.push(Qa(u));else if(o.type==="bytes")r.push(Nn(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(S(this,or).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:S(this,or).encode(i,s),topics:r}}decodeEventLog(t,e,r){if(typeof t=="string"){const w=this.getEvent(t);K(w,"unknown event","eventFragment",t),t=w}if(r!=null&&!t.anonymous){const w=t.topicHash;K(Ge(r[0],32)&&r[0].toLowerCase()===w,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const i=[],s=[],o=[];t.inputs.forEach((w,R)=>{w.indexed?w.type==="string"||w.type==="bytes"||w.baseType==="tuple"||w.baseType==="array"?(i.push(Qn.from({type:"bytes32",name:w.name})),o.push(!0)):(i.push(w),o.push(!1)):(s.push(w),o.push(!1))});const a=r!=null?S(this,or).decode(i,xn(r)):null,u=S(this,or).decode(s,e,!0),f=[],h=[];let y=0,_=0;return t.inputs.forEach((w,R)=>{let T=null;if(w.indexed)if(a==null)T=new ck(null);else if(o[R])T=new ck(a[_++]);else try{T=a[_++]}catch(I){T=I}else try{T=u[y++]}catch(I){T=I}f.push(T),h.push(w.name||null)}),Pu.fromItems(f,h)}parseTransaction(t){const e=we(t.data,"tx.data"),r=Ct(t.value!=null?t.value:0,"tx.value"),i=this.getFunction(Tt(e.slice(0,4)));if(!i)return null;const s=S(this,or).decode(i.inputs,e.slice(4));return new _G(i,i.selector,s,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new bG(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Tt(t),r=this.getError(ln(e,0,4));if(!r)return null;const i=S(this,or).decode(r.inputs,ln(e,4));return new AG(r,r.selector,i)}static from(t){return t instanceof bc?t:typeof t=="string"?new bc(JSON.parse(t)):typeof t.formatJson=="function"?new bc(t.formatJson()):typeof t.format=="function"?new bc(t.format("json")):new bc(t)}};as=new WeakMap,cs=new WeakMap,us=new WeakMap,or=new WeakMap,ls=new WeakSet,lg=function(t,e,r){if(Ge(t)){const s=t.toLowerCase();for(const o of S(this,us).values())if(s===o.selector)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,a]of S(this,us))o.split("(")[0]===t&&s.push(a);if(e){const o=e.length>0?e[e.length-1]:null;let a=e.length,u=!0;sr.isTyped(o)&&o.type==="overrides"&&(u=!1,a--);for(let f=s.length-1;f>=0;f--){const h=s[f].inputs.length;h!==a&&(!u||h!==a-1)&&s.splice(f,1)}for(let f=s.length-1;f>=0;f--){const h=s[f].inputs;for(let y=0;y<e.length;y++)if(sr.isTyped(e[y])){if(y>=h.length){if(e[y].type==="overrides")continue;s.splice(f,1);break}if(e[y].type!==h[y].baseType){s.splice(f,1);break}}}}if(s.length===1&&e&&e.length!==s[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(a=>JSON.stringify(a.format())).join(", ");K(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return s[0]}const i=S(this,us).get(rs.from(t).format());return i||null},fg=function(t,e,r){if(Ge(t)){const s=t.toLowerCase();for(const o of S(this,cs).values())if(s===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,a]of S(this,cs))o.split("(")[0]===t&&s.push(a);if(e){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<e.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const a=s[o].inputs;for(let u=0;u<e.length;u++)if(sr.isTyped(e[u])&&e[u].type!==a[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(a=>JSON.stringify(a.format())).join(", ");K(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return s[0]}const i=S(this,cs).get(ns.from(t).format());return i||null};let Uw=bc;const fk=BigInt(0);function Ku(n){return n??null}function Sn(n){return n==null?null:n.toString()}class hk{constructor(t,e,r){Z(this,"gasPrice");Z(this,"maxFeePerGas");Z(this,"maxPriorityFeePerGas");$t(this,{gasPrice:Ku(t),maxFeePerGas:Ku(e),maxPriorityFeePerGas:Ku(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Sn(t),maxFeePerGas:Sn(e),maxPriorityFeePerGas:Sn(r)}}}function vp(n){const t={};n.to&&(t.to=n.to),n.from&&(t.from=n.from),n.data&&(t.data=Tt(n.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of e)!(i in n)||n[i]==null||(t[i]=Ct(n[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)!(i in n)||n[i]==null||(t[i]=ie(n[i],`request.${i}`));return n.accessList&&(t.accessList=Xa(n.accessList)),"blockTag"in n&&(t.blockTag=n.blockTag),"enableCcipRead"in n&&(t.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(t.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(t.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(t.kzg=n.kzg),"blobs"in n&&n.blobs&&(t.blobs=n.blobs.map(i=>Wm(i)?Tt(i):Object.assign({},i))),t}class EG{constructor(t,e){Z(this,"provider");Z(this,"number");Z(this,"hash");Z(this,"timestamp");Z(this,"parentHash");Z(this,"parentBeaconBlockRoot");Z(this,"nonce");Z(this,"difficulty");Z(this,"gasLimit");Z(this,"gasUsed");Z(this,"stateRoot");Z(this,"receiptsRoot");Z(this,"blobGasUsed");Z(this,"excessBlobGas");Z(this,"miner");Z(this,"prevRandao");Z(this,"extraData");Z(this,"baseFeePerGas");Y(this,Xs);F(this,Xs,t.transactions.map(r=>typeof r!="string"?new xh(r,e):r)),$t(this,{provider:e,hash:Ku(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:Ku(t.prevRandao),extraData:t.extraData,baseFeePerGas:Ku(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return S(this,Xs).map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=S(this,Xs).slice();return t.length===0?[]:(ht(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:i,gasUsed:s,hash:o,miner:a,prevRandao:u,nonce:f,number:h,parentHash:y,parentBeaconBlockRoot:_,stateRoot:w,receiptsRoot:R,timestamp:T,transactions:I}=this;return{_type:"Block",baseFeePerGas:Sn(t),difficulty:Sn(e),extraData:r,gasLimit:Sn(i),gasUsed:Sn(s),blobGasUsed:Sn(this.blobGasUsed),excessBlobGas:Sn(this.excessBlobGas),hash:o,miner:a,prevRandao:u,nonce:f,number:h,parentHash:y,timestamp:T,parentBeaconBlockRoot:_,stateRoot:w,receiptsRoot:R,transactions:I}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return S(this,Xs).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=S(this,Xs)[t];else{const r=t.toLowerCase();for(const i of S(this,Xs))if(typeof i=="string"){if(i!==r)continue;e=i;break}else{if(i.hash!==r)continue;e=i;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;K(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return vG(this)}}Xs=new WeakMap;class vh{constructor(t,e){Z(this,"provider");Z(this,"transactionHash");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"removed");Z(this,"address");Z(this,"data");Z(this,"topics");Z(this,"index");Z(this,"transactionIndex");this.provider=e;const r=Object.freeze(t.topics.slice());$t(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:f}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:f}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return ht(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return xG(this)}}class dk{constructor(t,e){Z(this,"provider");Z(this,"to");Z(this,"from");Z(this,"contractAddress");Z(this,"hash");Z(this,"index");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"logsBloom");Z(this,"gasUsed");Z(this,"blobGasUsed");Z(this,"cumulativeGasUsed");Z(this,"gasPrice");Z(this,"blobGasPrice");Z(this,"type");Z(this,"status");Z(this,"root");Y(this,Uh);F(this,Uh,Object.freeze(t.logs.map(i=>new vh(i,e))));let r=fk;t.effectiveGasPrice!=null?r=t.effectiveGasPrice:t.gasPrice!=null&&(r=t.gasPrice),$t(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return S(this,Uh)}toJSON(){const{to:t,from:e,contractAddress:r,hash:i,index:s,blockHash:o,blockNumber:a,logsBloom:u,logs:f,status:h,root:y}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Sn(this.cumulativeGasUsed),from:e,gasPrice:Sn(this.gasPrice),blobGasUsed:Sn(this.blobGasUsed),blobGasPrice:Sn(this.blobGasPrice),gasUsed:Sn(this.gasUsed),hash:i,index:s,logs:f,logsBloom:u,root:y,status:h,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return gk(this)}reorderedEvent(t){return ht(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),pk(this,t)}}Uh=new WeakMap;const o1=class o1{constructor(t,e){Z(this,"provider");Z(this,"blockNumber");Z(this,"blockHash");Z(this,"index");Z(this,"hash");Z(this,"type");Z(this,"to");Z(this,"from");Z(this,"nonce");Z(this,"gasLimit");Z(this,"gasPrice");Z(this,"maxPriorityFeePerGas");Z(this,"maxFeePerGas");Z(this,"maxFeePerBlobGas");Z(this,"data");Z(this,"value");Z(this,"chainId");Z(this,"signature");Z(this,"accessList");Z(this,"blobVersionedHashes");Y(this,Zo);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,F(this,Zo,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:i,type:s,to:o,from:a,nonce:u,data:f,signature:h,accessList:y,blobVersionedHashes:_}=this;return{_type:"TransactionResponse",accessList:y,blockNumber:t,blockHash:e,blobVersionedHashes:_,chainId:Sn(this.chainId),data:f,from:a,gasLimit:Sn(this.gasLimit),gasPrice:Sn(this.gasPrice),hash:i,maxFeePerGas:Sn(this.maxFeePerGas),maxPriorityFeePerGas:Sn(this.maxPriorityFeePerGas),maxFeePerBlobGas:Sn(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:r,type:s,value:Sn(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const r=await this.getTransaction();r&&(t=r.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:r}=await gr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:r-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=t??1,i=e??0;let s=S(this,Zo),o=-1,a=s===-1;const u=async()=>{if(a)return null;const{blockNumber:_,nonce:w}=await gr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(w<this.nonce){s=_;return}if(a)return null;const R=await this.getTransaction();if(!(R&&R.blockNumber!=null))for(o===-1&&(o=s-3,o<S(this,Zo)&&(o=S(this,Zo)));o<=_;){if(a)return null;const T=await this.provider.getBlock(o,!0);if(T==null)return;for(const I of T)if(I===this.hash)return;for(let I=0;I<T.length;I++){const B=await T.getTransaction(I);if(B.from===this.from&&B.nonce===this.nonce){if(a)return null;const H=await this.provider.getTransactionReceipt(B.hash);if(H==null||_-H.blockNumber+1<r)return;let U="replaced";B.data===this.data&&B.to===this.to&&B.value===this.value?U="repriced":B.data==="0x"&&B.from===B.to&&B.value===fk&&(U="cancelled"),ht(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:U==="replaced"||U==="cancelled",reason:U,replacement:B.replaceableTransaction(s),hash:B.hash,receipt:H})}}o++}},f=_=>{if(_==null||_.status!==0)return _;ht(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:_.to,from:_.from,data:""},receipt:_})},h=await this.provider.getTransactionReceipt(this.hash);if(r===0)return f(h);if(h){if(await h.confirmations()>=r)return f(h)}else if(await u(),r===0)return null;return await new Promise((_,w)=>{const R=[],T=()=>{R.forEach(B=>B())};if(R.push(()=>{a=!0}),i>0){const B=setTimeout(()=>{T(),w(Ye("wait for transaction timeout","TIMEOUT"))},i);R.push(()=>{clearTimeout(B)})}const I=async B=>{if(await B.confirmations()>=r){T();try{_(f(B))}catch(H){w(H)}}};if(R.push(()=>{this.provider.off(this.hash,I)}),this.provider.on(this.hash,I),s>=0){const B=async()=>{try{await u()}catch(H){if(qn(H,"TRANSACTION_REPLACED")){T(),w(H);return}}a||this.provider.once("block",B)};R.push(()=>{this.provider.off("block",B)}),this.provider.once("block",B)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),gk(this)}reorderedEvent(t){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ht(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),pk(this,t)}replaceableTransaction(t){K(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new o1(this,this.provider);return F(e,Zo,t),e}};Zo=new WeakMap;let xh=o1;function vG(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function pk(n,t){return{orphan:"reorder-transaction",tx:n,other:t}}function gk(n){return{orphan:"drop-transaction",tx:n}}function xG(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Dw extends vh{constructor(e,r,i){super(e,e.provider);Z(this,"interface");Z(this,"fragment");Z(this,"args");const s=r.decodeEventLog(i,e.data,e.topics);$t(this,{args:s,fragment:i,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class yk extends vh{constructor(e,r){super(e,e.provider);Z(this,"error");$t(this,{error:r})}}class RG extends dk{constructor(e,r,i){super(i,r);Y(this,Sl);F(this,Sl,e)}get logs(){return super.logs.map(e=>{const r=e.topics.length?S(this,Sl).getEvent(e.topics[0]):null;if(r)try{return new Dw(e,S(this,Sl),r)}catch(i){return new yk(e,i)}return e})}}Sl=new WeakMap;class Fw extends xh{constructor(e,r,i){super(i,r);Y(this,Dh);F(this,Dh,e)}async wait(e,r){const i=await super.wait(e,r);return i==null?null:new RG(S(this,Dh),this.provider,i)}}Dh=new WeakMap;class mk extends qR{constructor(e,r,i,s){super(e,r,i);Z(this,"log");$t(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class IG extends mk{constructor(t,e,r,i,s){super(t,e,r,new Dw(s,t.interface,i));const o=t.interface.decodeEventLog(i,this.log.data,this.log.topics);$t(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const wk=BigInt(0);function bk(n){return n&&typeof n.call=="function"}function _k(n){return n&&typeof n.estimateGas=="function"}function xp(n){return n&&typeof n.resolveName=="function"}function Ak(n){return n&&typeof n.sendTransaction=="function"}function Ek(n){if(n!=null){if(xp(n))return n;if(n.provider)return n.provider}}class SG{constructor(t,e,r){Y(this,Fh);Z(this,"fragment");if($t(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const i=rc(t.runner,"resolveName"),s=xp(i)?i:null;F(this,Fh,async function(){const o=await Promise.all(e.inputs.map((a,u)=>r[u]==null?null:a.walkAsync(r[u],(h,y)=>h==="address"?Array.isArray(y)?Promise.all(y.map(_=>br(_,s))):br(y,s):y)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return S(this,Fh)}}Fh=new WeakMap;function rc(n,t){return n==null?null:typeof n[t]=="function"?n:n.provider&&typeof n.provider[t]=="function"?n.provider:null}function ic(n){return n==null?null:n.provider||null}async function vk(n,t){const e=sr.dereference(n,"overrides");K(typeof e=="object","invalid overrides parameter","overrides",n);const r=vp(e);return K(r.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),K(r.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function kG(n,t,e){const r=rc(n,"resolveName"),i=xp(r)?r:null;return await Promise.all(t.map((s,o)=>s.walkAsync(e[o],(a,u)=>(u=sr.dereference(u,a),a==="address"?br(u,i):u))))}function TG(n){const t=async function(o){const a=await vk(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await br(a.from,Ek(n.runner)));const u=n.interface,f=Ct(a.value||wk,"overrides.value")===wk,h=(a.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!f&&K(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const y=u.receive||u.fallback&&u.fallback.payable;return K(y||f,"cannot send value to non-payable fallback","overrides.value",a.value),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},e=async function(o){const a=rc(n.runner,"call");ht(bk(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(o);try{return await a.call(u)}catch(f){throw jm(f)&&f.data?n.interface.makeError(f.data,u):f}},r=async function(o){const a=n.runner;ht(Ak(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await t(o)),f=ic(n.runner);return new Fw(n.interface,f,u)},i=async function(o){const a=rc(n.runner,"estimateGas");return ht(_k(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await t(o))},s=async o=>await r(o);return $t(s,{_contract:n,estimateGas:i,populateTransaction:t,send:r,staticCall:e}),s}function OG(n,t){const e=function(...f){const h=n.interface.getFunction(t,f);return ht(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:f}}),h},r=async function(...f){const h=e(...f);let y={};if(h.inputs.length+1===f.length&&(y=await vk(f.pop()),y.from&&(y.from=await br(y.from,Ek(n.runner)))),h.inputs.length!==f.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const _=await kG(n.runner,h.inputs,f);return Object.assign({},y,await gr({to:n.getAddress(),data:n.interface.encodeFunctionData(h,_)}))},i=async function(...f){const h=await a(...f);return h.length===1?h[0]:h},s=async function(...f){const h=n.runner;ht(Ak(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const y=await h.sendTransaction(await r(...f)),_=ic(n.runner);return new Fw(n.interface,_,y)},o=async function(...f){const h=rc(n.runner,"estimateGas");return ht(_k(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await r(...f))},a=async function(...f){const h=rc(n.runner,"call");ht(bk(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const y=await r(...f);let _="0x";try{_=await h.call(y)}catch(R){throw jm(R)&&R.data?n.interface.makeError(R.data,y):R}const w=e(...f);return n.interface.decodeFunctionResult(w,_)},u=async(...f)=>e(...f).constant?await i(...f):await s(...f);return $t(u,{name:n.interface.getFunctionName(t),_contract:n,_key:t,getFragment:e,estimateGas:o,populateTransaction:r,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const f=n.interface.getFunction(t);return ht(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),f}}),u}function NG(n,t){const e=function(...i){const s=n.interface.getEvent(t,i);return ht(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:i}}),s},r=function(...i){return new SG(n,e(...i),i)};return $t(r,{name:n.interface.getEventName(t),_contract:n,_key:t,getFragment:e}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=n.interface.getEvent(t);return ht(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),i}}),r}const Rp=Symbol.for("_ethersInternal_contract"),xk=new WeakMap;function CG(n,t){xk.set(n[Rp],t)}function Kr(n){return xk.get(n[Rp])}function BG(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function $w(n,t){let e,r=null;if(Array.isArray(t)){const s=function(o){if(Ge(o,32))return o;const a=n.interface.getEvent(o);return K(a,"unknown fragment","name",o),a.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else t==="*"?e=[null]:typeof t=="string"?Ge(t,32)?e=[t]:(r=n.interface.getEvent(t),K(r,"unknown fragment","event",t),e=[r.topicHash]):BG(t)?e=await t.getTopicFilter():"fragment"in t?(r=t.fragment,e=[r.topicHash]):K(!1,"unknown event name","event",t);e=e.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=e.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:r,tag:i,topics:e}}async function Rh(n,t){const{subs:e}=Kr(n);return e.get((await $w(n,t)).tag)||null}async function Rk(n,t,e){const r=ic(n.runner);ht(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:i,tag:s,topics:o}=await $w(n,e),{addr:a,subs:u}=Kr(n);let f=u.get(s);if(!f){const y={address:a||n,topics:o},_=I=>{let B=i;if(B==null)try{B=n.interface.getEvent(I.topics[0])}catch{}if(B){const H=B,U=i?n.interface.decodeEventLog(i,I.data,I.topics):[];zw(n,e,U,G=>new IG(n,G,e,H,I))}else zw(n,e,[],H=>new mk(n,H,e,I))};let w=[];f={tag:s,listeners:[],start:()=>{w.length||w.push(r.on(y,_))},stop:async()=>{if(w.length==0)return;let I=w;w=[],await Promise.all(I),r.off(y,_)}},u.set(s,f)}return f}let Hw=Promise.resolve();async function PG(n,t,e,r){await Hw;const i=await Rh(n,t);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:a})=>{const u=Array.from(e);r&&u.push(r(a?null:o));try{o.call(n,...u)}catch{}return!a}),i.listeners.length===0&&(i.stop(),Kr(n).subs.delete(i.tag)),s>0}async function zw(n,t,e,r){try{await Hw}catch{}const i=PG(n,t,e,r);return Hw=i,await i}const Ip=["then"];Vk=Rp;const $h=class $h{constructor(t,e,r,i){Z(this,"target");Z(this,"interface");Z(this,"runner");Z(this,"filters");Z(this,Vk);Z(this,"fallback");K(typeof t=="string"||sS(t),"invalid value for Contract target","target",t),r==null&&(r=null);const s=Uw.from(e);$t(this,{target:t,runner:r,interface:s}),Object.defineProperty(this,Rp,{value:{}});let o,a=null,u=null;if(i){const y=ic(r);u=new Fw(this.interface,y,i)}let f=new Map;if(typeof t=="string")if(Ge(t))a=t,o=Promise.resolve(t);else{const y=rc(r,"resolveName");if(!xp(y))throw Ye("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=y.resolveName(t).then(_=>{if(_==null)throw Ye("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Kr(this).addr=_,_})}else o=t.getAddress().then(y=>{if(y==null)throw new Error("TODO");return Kr(this).addr=y,y});CG(this,{addrPromise:o,addr:a,deployTx:u,subs:f});const h=new Proxy({},{get:(y,_,w)=>{if(typeof _=="symbol"||Ip.indexOf(_)>=0)return Reflect.get(y,_,w);try{return this.getEvent(_)}catch(R){if(!qn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,_)=>Ip.indexOf(_)>=0?Reflect.has(y,_):Reflect.has(y,_)||this.interface.hasEvent(String(_))});return $t(this,{filters:h}),$t(this,{fallback:s.receive||s.fallback?TG(this):null}),new Proxy(this,{get:(y,_,w)=>{if(typeof _=="symbol"||_ in y||Ip.indexOf(_)>=0)return Reflect.get(y,_,w);try{return y.getFunction(_)}catch(R){if(!qn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,_)=>typeof _=="symbol"||_ in y||Ip.indexOf(_)>=0?Reflect.has(y,_):y.interface.hasFunction(_)})}connect(t){return new $h(this.target,this.interface,t)}attach(t){return new $h(t,this.interface,this.runner)}async getAddress(){return await Kr(this).addrPromise}async getDeployedCode(){const t=ic(this.runner);ht(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=ic(this.runner);return ht(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);r.once("block",o)}catch(a){s(a)}};o()})}deploymentTransaction(){return Kr(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),OG(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),NG(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){e==null&&(e=0),r==null&&(r="latest");const{addr:i,addrPromise:s}=Kr(this),o=i||await s,{fragment:a,topics:u}=await $w(this,t),f={address:o,topics:u,fromBlock:e,toBlock:r},h=ic(this.runner);return ht(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(f)).map(y=>{let _=a;if(_==null)try{_=this.interface.getEvent(y.topics[0])}catch{}if(_)try{return new Dw(y,this.interface,_)}catch(w){return new yk(y,w)}return new vh(y,h)})}async on(t,e){const r=await Rk(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await Rk(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await zw(this,t,e,null)}async listenerCount(t){if(t){const i=await Rh(this,t);return i?i.listeners.length:0}const{subs:e}=Kr(this);let r=0;for(const{listeners:i}of e.values())r+=i.length;return r}async listeners(t){if(t){const i=await Rh(this,t);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:e}=Kr(this);let r=[];for(const{listeners:i}of e.values())r=r.concat(i.map(({listener:s})=>s));return r}async off(t,e){const r=await Rh(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(e==null||r.listeners.length===0)&&(r.stop(),Kr(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await Rh(this,t);if(!e)return this;e.stop(),Kr(this).subs.delete(e.tag)}else{const{subs:e}=Kr(this);for(const{tag:r,stop:i}of e.values())i(),e.delete(r)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends $h{constructor(i,s=null){super(i,t,s)}}return e}static from(t,e,r){return r==null&&(r=null),new this(t,e,r)}};let Gw=$h;function MG(){return Gw}class ju extends MG(){}function Vw(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):K(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class LG{constructor(t){Z(this,"name");$t(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const Ik=new RegExp("^(ipfs)://(.*)$","i"),Sk=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Ik,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],kl=class kl{constructor(t,e,r){Y(this,Qo);Z(this,"provider");Z(this,"address");Z(this,"name");Y(this,qo);Y(this,_c);$t(this,{provider:t,address:e,name:r}),F(this,qo,null),F(this,_c,new ju(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t))}async supportsWildcard(){return S(this,qo)==null&&F(this,qo,(async()=>{try{return await S(this,_c).supportsInterface("0x9061b923")}catch(t){if(qn(t,"CALL_EXCEPTION"))return!1;throw F(this,qo,null),t}})()),await S(this,qo)}async getAddress(t){if(t==null&&(t=60),t===60)try{const s=await yt(this,Qo,Xl).call(this,"addr(bytes32)");return s==null||s===hh?null:s}catch(s){if(qn(s,"CALL_EXCEPTION"))return null;throw s}if(t>=0&&t<2147483648){let s=t+2147483648;const o=await yt(this,Qo,Xl).call(this,"addr(bytes32,uint)",[s]);if(Ge(o,20))return Le(o)}let e=null;for(const s of this.provider.plugins)if(s instanceof LG&&s.supportsCoinType(t)){e=s;break}if(e==null)return null;const r=await yt(this,Qo,Xl).call(this,"addr(bytes32,uint)",[t]);if(r==null||r==="0x")return null;const i=await e.decodeAddress(t,r);if(i!=null)return i;ht(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await yt(this,Qo,Xl).call(this,"text(bytes32,string)",[t]);return e==null||e==="0x"?null:e}async getContentHash(){const t=await yt(this,Qo,Xl).call(this,"contenthash(bytes32)");if(t==null||t==="0x")return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const i=e[1]==="e3010170"?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===s*2)return`${i}://${s$("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ht(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(e==null)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<Sk.length;r++){const i=e.match(Sk[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const o=Vw(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:o}),{linkage:t,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";t.push({type:s,value:e});const a=await this.getAddress();if(a==null)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const u=(i[2]||"").split("/");if(u.length!==2)return t.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:t};const f=u[1],h=new 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 T=await h.ownerOf(f);if(a!==T)return t.push({type:"!owner",value:T}),{url:null,linkage:t};t.push({type:"owner",value:T})}else if(s==="erc1155"){const T=await h.balanceOf(a,f);if(!T)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:T.toString()})}let y=await h[o](f);if(y==null||y==="0x")return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:y}),s==="erc1155"&&(y=y.replace("{id}",Bo(f,32).substring(2)),t.push({type:"metadata-url-expanded",value:y})),y.match(/^ipfs:/i)&&(y=Vw(y)),t.push({type:"metadata-url",value:y});let _={};const w=await new Ls(y).send();w.assertOk();try{_=w.bodyJson}catch{try{t.push({type:"!metadata",value:w.bodyText})}catch{const B=w.body;return B&&t.push({type:"!metadata",value:Tt(B)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!_)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(_)});let R=_.image;if(typeof R!="string")return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(!R.match(/^(https:\/\/|data:)/i)){if(R.match(Ik)==null)return t.push({type:"!imageUrl-ipfs",value:R}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:R}),R=Vw(R)}return t.push({type:"url",value:R}),{linkage:t,url:R}}}}}catch{}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return ht(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async fromName(t,e){var i;let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const s=await yt(i=kl,$p,uO).call(i,t,r);if(s!=null){const o=new kl(t,s,e);return r!==e&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};qo=new WeakMap,_c=new WeakMap,Qo=new WeakSet,Xl=async function(t,e){e=(e||[]).slice();const r=S(this,_c).interface;e.unshift(kw(this.name));let i=null;await this.supportsWildcard()&&(i=r.getFunction(t),ht(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[Uz(this.name,255),r.encodeFunctionData(i,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const s=await S(this,_c)[t](...e);return i?r.decodeFunctionResult(i,s)[0]:s}catch(s){if(!qn(s,"CALL_EXCEPTION"))throw s}return null},$p=new WeakSet,uO=async function(t,e){const r=await kl.getEnsAddress(t);try{const s=await new ju(r,["function resolver(bytes32) view returns (address)"],t).resolver(kw(e),{enableCcipRead:!0});return s===hh?null:s}catch(i){throw i}return null},Y(kl,$p);let Sp=kl;const kk=BigInt(0);function ye(n,t){return function(e){return e==null?t:n(e)}}function kp(n,t){return e=>{if(t&&e==null)return null;if(!Array.isArray(e))throw new Error("not an array");return e.map(r=>n(r))}}function Ih(n,t){return e=>{const r={};for(const i in n){let s=i;if(t&&i in t&&!(s in e)){for(const o of t[i])if(o in e){s=o;break}}try{const o=n[i](e[s]);o!==void 0&&(r[i]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ht(!1,`invalid value for value.${i} (${a})`,"BAD_DATA",{value:e})}}return r}}function UG(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}K(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Wu(n){return K(Ge(n,!0),"invalid data","value",n),n}function Yn(n){return K(Ge(n,32),"invalid hash","value",n),n}const DG=Ih({address:Le,blockHash:Yn,blockNumber:ie,data:Wu,index:ie,removed:ye(UG,!1),topics:kp(Yn),transactionHash:Yn,transactionIndex:ie},{index:["logIndex"]});function FG(n){return DG(n)}const $G=Ih({hash:ye(Yn),parentHash:Yn,parentBeaconBlockRoot:ye(Yn,null),number:ie,timestamp:ie,nonce:ye(Wu),difficulty:Ct,gasLimit:Ct,gasUsed:Ct,stateRoot:ye(Yn,null),receiptsRoot:ye(Yn,null),blobGasUsed:ye(Ct,null),excessBlobGas:ye(Ct,null),miner:ye(Le),prevRandao:ye(Yn,null),extraData:Wu,baseFeePerGas:ye(Ct)},{prevRandao:["mixHash"]});function HG(n){const t=$G(n);return t.transactions=n.transactions.map(e=>typeof e=="string"?e:Tk(e)),t}const zG=Ih({transactionIndex:ie,blockNumber:ie,transactionHash:Yn,address:Le,topics:kp(Yn),data:Wu,index:ie,blockHash:Yn},{index:["logIndex"]});function GG(n){return zG(n)}const VG=Ih({to:ye(Le,null),from:ye(Le,null),contractAddress:ye(Le,null),index:ie,root:ye(Tt),gasUsed:Ct,blobGasUsed:ye(Ct,null),logsBloom:ye(Wu),blockHash:Yn,hash:Yn,logs:kp(GG),blockNumber:ie,cumulativeGasUsed:Ct,effectiveGasPrice:ye(Ct),blobGasPrice:ye(Ct,null),status:ye(ie),type:ye(ie,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function KG(n){return VG(n)}function Tk(n){n.to&&Ct(n.to)===kk&&(n.to="0x0000000000000000000000000000000000000000");const t=Ih({hash:Yn,index:ye(ie,void 0),type:e=>e==="0x"||e==null?0:ie(e),accessList:ye(Xa,null),blobVersionedHashes:ye(kp(Yn,!0),null),blockHash:ye(Yn,null),blockNumber:ye(ie,null),transactionIndex:ye(ie,null),from:Le,gasPrice:ye(Ct),maxPriorityFeePerGas:ye(Ct),maxFeePerGas:ye(Ct),maxFeePerBlobGas:ye(Ct,null),gasLimit:Ct,to:ye(Le,null),value:Ct,nonce:ie,data:Wu,creates:ye(Le,null),chainId:ye(Ct,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(t.to==null&&t.creates==null&&(t.creates=$H(t)),(n.type===1||n.type===2)&&n.accessList==null&&(t.accessList=[]),n.signature?t.signature=Ri.from(n.signature):t.signature=Ri.from(n),t.chainId==null){const e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&Ct(t.blockHash)===kk&&(t.blockHash=null),t}const jG="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Sh{constructor(t){Z(this,"name");$t(this,{name:t})}clone(){return new Sh(this.name)}}class Tp extends Sh{constructor(e,r){e==null&&(e=0);super(`org.ethers.network.plugins.GasCost#${e||0}`);Z(this,"effectiveBlock");Z(this,"txBase");Z(this,"txCreate");Z(this,"txDataZero");Z(this,"txDataNonzero");Z(this,"txAccessListStorageKey");Z(this,"txAccessListAddress");const i={effectiveBlock:e};function s(o,a){let u=(r||{})[o];u==null&&(u=a),K(typeof u=="number",`invalud value for ${o}`,"costs",r),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),$t(this,i)}clone(){return new Tp(this.effectiveBlock,this)}}class Op extends Sh{constructor(e,r){super("org.ethers.plugins.network.Ens");Z(this,"address");Z(this,"targetNetwork");$t(this,{address:e||jG,targetNetwork:r??1})}clone(){return new Op(this.address,this.targetNetwork)}}class WG extends Sh{constructor(e,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");Y(this,Hh);Y(this,zh);F(this,Hh,e),F(this,zh,r)}get url(){return S(this,Hh)}get processFunc(){return S(this,zh)}clone(){return this}}Hh=new WeakMap,zh=new WeakMap;const Kw=new Map,Nl=class Nl{constructor(t,e){Y(this,Tl);Y(this,Ol);Y(this,Yo);F(this,Tl,t),F(this,Ol,Ct(e)),F(this,Yo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return S(this,Tl)}set name(t){F(this,Tl,t)}get chainId(){return S(this,Ol)}set chainId(t){F(this,Ol,Ct(t,"chainId"))}matches(t){if(t==null)return!1;if(typeof t=="string"){try{return this.chainId===Ct(t)}catch{}return this.name===t}if(typeof t=="number"||typeof t=="bigint"){try{return this.chainId===Ct(t)}catch{}return!1}if(typeof t=="object"){if(t.chainId!=null){try{return this.chainId===Ct(t.chainId)}catch{}return!1}return t.name!=null?this.name===t.name:!1}return!1}get plugins(){return Array.from(S(this,Yo).values())}attachPlugin(t){if(S(this,Yo).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return S(this,Yo).set(t.name,t.clone()),this}getPlugin(t){return S(this,Yo).get(t)||null}getPlugins(t){return this.plugins.filter(e=>e.name.split("#")[0]===t)}clone(){const t=new Nl(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new Tp;let r=e.txBase;if(t.to==null&&(r+=e.txCreate),t.data)for(let i=2;i<t.data.length;i+=2)t.data.substring(i,i+2)==="00"?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const i=Xa(t.accessList);for(const s in i)r+=e.txAccessListAddress+e.txAccessListStorageKey*i[s].storageKeys.length}return r}static from(t){if(ZG(),t==null)return Nl.from("mainnet");if(typeof t=="number"&&(t=BigInt(t)),typeof t=="string"||typeof t=="bigint"){const e=Kw.get(t);if(e)return e();if(typeof t=="bigint")return new Nl("unknown",t);K(!1,"unknown network","network",t)}if(typeof t.clone=="function")return t.clone();if(typeof t=="object"){K(typeof t.name=="string"&&typeof t.chainId=="number","invalid network object name or chainId","network",t);const e=new Nl(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&e.attachPlugin(new Op(t.ensAddress,t.ensNetwork)),e}K(!1,"invalid network","network",t)}static register(t,e){typeof t=="number"&&(t=BigInt(t));const r=Kw.get(t);r&&K(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Kw.set(t,e)}};Tl=new WeakMap,Ol=new WeakMap,Yo=new WeakMap;let is=Nl;function Ok(n,t){const e=String(n);if(!e.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=e.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<t;)r[1]+="0";if(r[1].length>9){let i=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||i++,r[1]=i.toString()}return BigInt(r[0]+r[1])}function Nk(n){return new WG(n,async(t,e,r)=>{r.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([r.send(),t()]);i=s;const a=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:Ok(a.maxFee,9),maxPriorityFeePerGas:Ok(a.maxPriorityFee,9)}}catch(s){ht(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:i,error:s})}})}let Ck=!1;function ZG(){if(Ck)return;Ck=!0;function n(t,e,r){const i=function(){const s=new is(t,e);return r.ensNetwork!=null&&s.attachPlugin(new Op(null,r.ensNetwork)),s.attachPlugin(new Tp),(r.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};is.register(t,i),is.register(e,i),r.altNames&&r.altNames.forEach(s=>{is.register(s,i)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[Nk("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Nk("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function jw(n){return JSON.parse(JSON.stringify(n))}class qG{constructor(t){Y(this,Cl);Y(this,to);Y(this,fi);Y(this,Jo);Y(this,fs);F(this,to,t),F(this,fi,null),F(this,Jo,4e3),F(this,fs,-2)}get pollingInterval(){return S(this,Jo)}set pollingInterval(t){F(this,Jo,t)}start(){S(this,fi)||(F(this,fi,S(this,to)._setTimeout(yt(this,Cl,hg).bind(this),S(this,Jo))),yt(this,Cl,hg).call(this))}stop(){S(this,fi)&&(S(this,to)._clearTimeout(S(this,fi)),F(this,fi,null))}pause(t){this.stop(),t&&F(this,fs,-2)}resume(){this.start()}}to=new WeakMap,fi=new WeakMap,Jo=new WeakMap,fs=new WeakMap,Cl=new WeakSet,hg=async function(){try{const t=await S(this,to).getBlockNumber();if(S(this,fs)===-2){F(this,fs,t);return}if(t!==S(this,fs)){for(let e=S(this,fs)+1;e<=t;e++){if(S(this,fi)==null)return;await S(this,to).emit("block",e)}F(this,fs,t)}}catch{}S(this,fi)!=null&&F(this,fi,S(this,to)._setTimeout(yt(this,Cl,hg).bind(this),S(this,Jo)))};class Ww{constructor(t){Y(this,Ac);Y(this,Ec);Y(this,Xo);F(this,Ac,t),F(this,Xo,!1),F(this,Ec,e=>{this._poll(e,S(this,Ac))})}async _poll(t,e){throw new Error("sub-classes must override this")}start(){S(this,Xo)||(F(this,Xo,!0),S(this,Ec).call(this,-2),S(this,Ac).on("block",S(this,Ec)))}stop(){S(this,Xo)&&(F(this,Xo,!1),S(this,Ac).off("block",S(this,Ec)))}pause(t){this.stop()}resume(){this.start()}}Ac=new WeakMap,Ec=new WeakMap,Xo=new WeakMap;class QG extends Ww{constructor(e,r){super(e);Y(this,Bl);Y(this,eo);F(this,Bl,r),F(this,eo,-2)}pause(e){e&&F(this,eo,-2),super.pause(e)}async _poll(e,r){const i=await r.getBlock(S(this,Bl));i!=null&&(S(this,eo)===-2?F(this,eo,i.number):i.number>S(this,eo)&&(r.emit(S(this,Bl),i.number),F(this,eo,i.number)))}}Bl=new WeakMap,eo=new WeakMap;class YG extends Ww{constructor(e,r){super(e);Y(this,Hp);F(this,Hp,jw(r))}async _poll(e,r){throw new Error("@TODO")}}Hp=new WeakMap;class JG extends Ww{constructor(e,r){super(e);Y(this,Pl);F(this,Pl,r)}async _poll(e,r){const i=await r.getTransactionReceipt(S(this,Pl));i&&r.emit(S(this,Pl),i)}}Pl=new WeakMap;class Zw{constructor(t,e){Y(this,zp);Y(this,no);Y(this,Ml);Y(this,Ll);Y(this,ta);Y(this,hi);F(this,no,t),F(this,Ml,jw(e)),F(this,Ll,yt(this,zp,lO).bind(this)),F(this,ta,!1),F(this,hi,-2)}start(){S(this,ta)||(F(this,ta,!0),S(this,hi)===-2&&S(this,no).getBlockNumber().then(t=>{F(this,hi,t)}),S(this,no).on("block",S(this,Ll)))}stop(){S(this,ta)&&(F(this,ta,!1),S(this,no).off("block",S(this,Ll)))}pause(t){this.stop(),t&&F(this,hi,-2)}resume(){this.start()}}no=new WeakMap,Ml=new WeakMap,Ll=new WeakMap,ta=new WeakMap,hi=new WeakMap,zp=new WeakSet,lO=async function(t){if(S(this,hi)===-2)return;const e=jw(S(this,Ml));e.fromBlock=S(this,hi)+1,e.toBlock=t;const r=await S(this,no).getLogs(e);if(r.length===0){S(this,hi)<t-60&&F(this,hi,t-60);return}for(const i of r)S(this,no).emit(S(this,Ml),i),F(this,hi,i.blockNumber)};const XG=BigInt(2),tV=10;function Np(n){return n&&typeof n.then=="function"}function Cp(n,t){return n+":"+JSON.stringify(t,(e,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const i=Object.keys(r);return i.sort(),i.reduce((s,o)=>(s[o]=r[o],s),{})}return r})}class Bp{constructor(t){Z(this,"name");$t(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function eV(n){return JSON.parse(JSON.stringify(n))}function qw(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function Qw(n,t){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(Ge(n,32)){const e=n.toLowerCase();return{type:"transaction",tag:Cp("tx",{hash:e}),hash:e}}if(n.orphan){const e=n;return{type:"orphan",tag:Cp("orphan",e),filter:eV(e)}}if(n.address||n.topics){const e=n,r={topics:(e.topics||[]).map(i=>i==null?null:Array.isArray(i)?qw(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(e.address){const i=[],s=[],o=a=>{Ge(a)?i.push(a):s.push((async()=>{i.push(await br(a,t))})())};Array.isArray(e.address)?e.address.forEach(o):o(e.address),s.length&&await Promise.all(s),r.address=qw(i.map(a=>a.toLowerCase()))}return{filter:r,tag:Cp("event",r),type:"event"}}K(!1,"unknown ProviderEvent","event",n)}function Yw(){return new Date().getTime()}const nV={cacheTimeout:250,pollingInterval:4e3};class rV{constructor(t,e){Y(this,se);Y(this,ar);Y(this,ea);Y(this,cr);Y(this,Ul);Y(this,qr);Y(this,vc);Y(this,na);Y(this,ro);Y(this,Gh);Y(this,di);Y(this,Dl);Y(this,Fl);if(F(this,Fl,Object.assign({},nV,e||{})),t==="any")F(this,vc,!0),F(this,qr,null);else if(t){const r=is.from(t);F(this,vc,!1),F(this,qr,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else F(this,vc,!1),F(this,qr,null);F(this,ro,-1),F(this,na,new Map),F(this,ar,new Map),F(this,ea,new Map),F(this,cr,null),F(this,Ul,!1),F(this,Gh,1),F(this,di,new Map),F(this,Dl,!1)}get pollingInterval(){return S(this,Fl).pollingInterval}get provider(){return this}get plugins(){return Array.from(S(this,ea).values())}attachPlugin(t){if(S(this,ea).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return S(this,ea).set(t.name,t.connect(this)),this}getPlugin(t){return S(this,ea).get(t)||null}get disableCcipRead(){return S(this,Dl)}set disableCcipRead(t){F(this,Dl,!!t)}async ccipReadFetch(t,e,r){if(this.disableCcipRead||r.length===0||t.to==null)return null;const i=t.to.toLowerCase(),s=e.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const u=r[a],f=u.replace("{sender}",i).replace("{data}",s),h=new Ls(f);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:r});let y="unknown error",_;try{_=await h.send()}catch(w){o.push(w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:w}});continue}try{const w=_.bodyJson;if(w.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:w}),w.data;w.message&&(y=w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:w})}catch{}ht(_.statusCode<400||_.statusCode>=500,`response not found during CCIP fetch: ${y}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:u,errorMessage:y}}),o.push(y)}ht(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new EG(HG(t),this)}_wrapLog(t,e){return new vh(FG(t),this)}_wrapTransactionReceipt(t,e){return new dk(KG(t),this)}_wrapTransactionResponse(t,e){return new xh(Tk(t),this)}_detectNetwork(){ht(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){ht(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=ie(await yt(this,se,Qr).call(this,{method:"getBlockNumber"}),"%response");return S(this,ro)>=0&&F(this,ro,t),t}_getAddress(t){return br(t,this)}_getBlockTag(t){if(t==null)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}if(Ge(t))return Ge(t,32)?t:Bu(t);if(typeof t=="bigint"&&(t=ie(t,"blockTag")),typeof t=="number")return t>=0?Bu(t):S(this,ro)>=0?Bu(S(this,ro)+t):this.getBlockNumber().then(e=>Bu(e+t));K(!1,"invalid blockTag","blockTag",t)}_getFilter(t){const e=(t.topics||[]).map(u=>u==null?null:Array.isArray(u)?qw(u.map(f=>f.toLowerCase())):u.toLowerCase()),r="blockHash"in t?t.blockHash:void 0,i=(u,f,h)=>{let y;switch(u.length){case 0:break;case 1:y=u[0];break;default:u.sort(),y=u}if(r&&(f!=null||h!=null))throw new Error("invalid filter");const _={};return y&&(_.address=y),e.length&&(_.topics=e),f&&(_.fromBlock=f),h&&(_.toBlock=h),r&&(_.blockHash=r),_};let s=[];if(t.address)if(Array.isArray(t.address))for(const u of t.address)s.push(this._getAddress(u));else s.push(this._getAddress(t.address));let o;"fromBlock"in t&&(o=this._getBlockTag(t.fromBlock));let a;return"toBlock"in t&&(a=this._getBlockTag(t.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(t){const e=vp(t),r=[];if(["to","from"].forEach(i=>{if(e[i]==null)return;const s=br(e[i],this);Np(s)?r.push(async function(){e[i]=await s}()):e[i]=s}),e.blockTag!=null){const i=this._getBlockTag(e.blockTag);Np(i)?r.push(async function(){e.blockTag=await i}()):e.blockTag=i}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(S(this,qr)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw S(this,qr)===i&&F(this,qr,null),s}})();return F(this,qr,i),(await i).clone()}const t=S(this,qr),[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(S(this,vc)?(this.emit("network",r,e),S(this,qr)===t&&F(this,qr,Promise.resolve(r))):ht(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await gr({_block:yt(this,se,Cb).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await yt(this,se,Qr).call(this,{method:"getGasPrice"});return Ct(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await yt(this,se,Qr).call(this,{method:"getPriorityFee"});return Ct(h,"%response")}catch{}return null})()});let a=null,u=null;const f=this._wrapBlock(i,t);return f&&f.baseFeePerGas&&(u=o??BigInt("1000000000"),a=f.baseFeePerGas*XG+u),new hk(s,a,u)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const i=new Ls(r.url),s=await r.processFunc(e,this,i);return new hk(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return Np(e)&&(e=await e),Ct(await yt(this,se,Qr).call(this,{method:"estimateGas",transaction:e}),"%response")}async call(t){const{tx:e,blockTag:r}=await gr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await yt(this,se,Nb).call(this,yt(this,se,Ob).call(this,e,r,t.enableCcipRead?0:-1))}async getBalance(t,e){return Ct(await yt(this,se,Ad).call(this,{method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return ie(await yt(this,se,Ad).call(this,{method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return Tt(await yt(this,se,Ad).call(this,{method:"getCode"},t,e))}async getStorage(t,e,r){const i=Ct(e,"position");return Tt(await yt(this,se,Ad).call(this,{method:"getStorage",position:i},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:i}=await gr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),s=wp.from(t);if(s.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(e)}async getBlock(t,e){const{network:r,params:i}=await gr({network:this.getNetwork(),params:yt(this,se,Cb).call(this,t,!!e)});return i==null?null:this._wrapBlock(i,r)}async getTransaction(t){const{network:e,params:r}=await gr({network:this.getNetwork(),params:yt(this,se,Qr).call(this,{method:"getTransaction",hash:t})});return r==null?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await gr({network:this.getNetwork(),params:yt(this,se,Qr).call(this,{method:"getTransactionReceipt",hash:t})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const i=await yt(this,se,Qr).call(this,{method:"getTransaction",hash:t});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await gr({network:this.getNetwork(),result:yt(this,se,Qr).call(this,{method:"getTransactionResult",hash:t})});return e==null?null:Tt(e)}async getLogs(t){let e=this._getFilter(t);Np(e)&&(e=await e);const{network:r,params:i}=await gr({network:this.getNetwork(),params:yt(this,se,Qr).call(this,{method:"getLogs",filter:e})});return i.map(s=>this._wrapLog(s,r))}_getProvider(t){ht(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await Sp.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=Le(t);const e=kw(t.substring(2).toLowerCase()+".addr.reverse");try{const r=await Sp.getEnsAddress(this),s=await new ju(r,["function resolver(bytes32) view returns (address)"],this).resolver(e);if(s==null||s===hh)return null;const a=await new ju(s,["function name(bytes32) view returns (string)"],this).name(e);return await this.resolveName(a)!==t?null:a}catch(r){if(qn(r,"BAD_DATA")&&r.value==="0x"||qn(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(t,e,r){const i=e??1;return i===0?this.getTransactionReceipt(t):new Promise(async(s,o)=>{let a=null;const u=async f=>{try{const h=await this.getTransactionReceipt(t);if(h!=null&&f-h.blockNumber+1>=i){s(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",u),o(Ye("timeout","TIMEOUT",{reason:"timeout"})))},r)),u(await this.getBlockNumber())})}async waitForBlock(t){ht(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=S(this,di).get(t);e&&(e.timer&&clearTimeout(e.timer),S(this,di).delete(t))}_setTimeout(t,e){e==null&&(e=0);const r=ao(this,Gh)._++,i=()=>{S(this,di).delete(r),t()};if(this.paused)S(this,di).set(r,{timer:null,func:i,time:e});else{const s=setTimeout(i,e);S(this,di).set(r,{timer:s,func:i,time:Yw()})}return r}_forEachSubscriber(t){for(const e of S(this,ar).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Bp(t.type);case"block":{const e=new qG(this);return e.pollingInterval=this.pollingInterval,e}case"safe":case"finalized":return new QG(this,t.type);case"event":return new Zw(this,t.filter);case"transaction":return new JG(this,t.hash);case"orphan":return new YG(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of S(this,ar).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),S(this,cr)!=null&&e.pause(S(this,cr));break}}async on(t,e){const r=await yt(this,se,dg).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,S(this,cr)!=null&&r.subscriber.pause(S(this,cr))),this}async once(t,e){const r=await yt(this,se,dg).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,S(this,cr)!=null&&r.subscriber.pause(S(this,cr))),this}async emit(t,...e){const r=await yt(this,se,Ed).call(this,t,e);if(!r||r.listeners.length===0)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:s,once:o})=>{const a=new qR(this,o?null:s,t);try{s.call(this,...e,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),S(this,ar).delete(r.tag)),i>0}async listenerCount(t){if(t){const r=await yt(this,se,Ed).call(this,t);return r?r.listeners.length:0}let e=0;for(const{listeners:r}of S(this,ar).values())e+=r.length;return e}async listeners(t){if(t){const r=await yt(this,se,Ed).call(this,t);return r?r.listeners.map(({listener:i})=>i):[]}let e=[];for(const{listeners:r}of S(this,ar).values())e=e.concat(r.map(({listener:i})=>i));return e}async off(t,e){const r=await yt(this,se,Ed).call(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(!e||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),S(this,ar).delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:i}=await yt(this,se,dg).call(this,t);r&&i.stop(),S(this,ar).delete(e)}else for(const[e,{started:r,subscriber:i}]of S(this,ar))r&&i.stop(),S(this,ar).delete(e);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return S(this,Ul)}destroy(){this.removeAllListeners();for(const t of S(this,di).keys())this._clearTimeout(t);F(this,Ul,!0)}get paused(){return S(this,cr)!=null}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(F(this,ro,-1),S(this,cr)!=null){if(S(this,cr)==!!t)return;ht(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(e=>e.pause(t)),F(this,cr,!!t);for(const e of S(this,di).values())e.timer&&clearTimeout(e.timer),e.time=Yw()-e.time}resume(){if(S(this,cr)!=null){this._forEachSubscriber(t=>t.resume()),F(this,cr,null);for(const t of S(this,di).values()){let e=t.time;e<0&&(e=0),t.time=Yw(),setTimeout(t.func,e)}}}}ar=new WeakMap,ea=new WeakMap,cr=new WeakMap,Ul=new WeakMap,qr=new WeakMap,vc=new WeakMap,na=new WeakMap,ro=new WeakMap,Gh=new WeakMap,di=new WeakMap,Dl=new WeakMap,Fl=new WeakMap,se=new WeakSet,Qr=async function(t){const e=S(this,Fl).cacheTimeout;if(e<0)return await this._perform(t);const r=Cp(t.method,t);let i=S(this,na).get(r);return i||(i=this._perform(t),S(this,na).set(r,i),setTimeout(()=>{S(this,na).get(r)===i&&S(this,na).delete(r)},e)),await i},Ob=async function(t,e,r){ht(r<tV,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const i=vp(t);try{return Tt(await this._perform({method:"call",transaction:i,blockTag:e}))}catch(s){if(!this.disableCcipRead&&jm(s)&&s.data&&r>=0&&e==="latest"&&i.to!=null&&ln(s.data,0,4)==="0x556f1830"){const o=s.data,a=await br(i.to,this);let u;try{u=cV(ln(s.data,4))}catch(y){ht(!1,y.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ht(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 f=await this.ccipReadFetch(i,u.calldata,u.urls);ht(f!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:a,data:xn([u.selector,aV([f,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const y=await yt(this,se,Ob).call(this,h,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:y}),y}catch(y){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:y}),y}}throw s}},Nb=async function(t){const{value:e}=await gr({network:this.getNetwork(),value:t});return e},Ad=async function(t,e,r){let i=this._getAddress(e),s=this._getBlockTag(r);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await yt(this,se,Nb).call(this,yt(this,se,Qr).call(this,Object.assign(t,{address:i,blockTag:s})))},Cb=async function(t,e){if(Ge(t,32))return await yt(this,se,Qr).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return typeof r!="string"&&(r=await r),await yt(this,se,Qr).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})},Ed=async function(t,e){let r=await Qw(t,this);return r.type==="event"&&e&&e.length>0&&e[0].removed===!0&&(r=await Qw({orphan:"drop-log",log:e[0]},this)),S(this,ar).get(r.tag)||null},dg=async function(t){const e=await Qw(t,this),r=e.tag;let i=S(this,ar).get(r);return i||(i={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},S(this,ar).set(r,i)),i};function iV(n,t){try{const e=Jw(n,t);if(e)return J0(e)}catch{}return null}function Jw(n,t){if(n==="0x")return null;try{const e=ie(ln(n,t,t+32)),r=ie(ln(n,e,e+32));return ln(n,e+32,e+32+r)}catch{}return null}function Bk(n){const t=mr(n);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function sV(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}const oV=new Uint8Array([]);function aV(n){const t=[];let e=0;for(let r=0;r<n.length;r++)t.push(oV),e+=32;for(let r=0;r<n.length;r++){const i=we(n[r]);t[r]=Bk(e),t.push(Bk(i.length)),t.push(sV(i)),e+=32+Math.ceil(i.length/32)*32}return xn(t)}const Pk="0x0000000000000000000000000000000000000000000000000000000000000000";function cV(n){const t={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ht(Nu(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const e=ln(n,0,32);ht(ln(e,0,12)===ln(Pk,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),t.sender=ln(e,12);try{const r=[],i=ie(ln(n,32,64)),s=ie(ln(n,i,i+32)),o=ln(n,i+32);for(let a=0;a<s;a++){const u=iV(o,a*32);if(u==null)throw new Error("abort");r.push(u)}t.urls=r}catch{ht(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Jw(n,64);if(r==null)throw new Error("abort");t.calldata=r}catch{ht(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ht(ln(n,100,128)===ln(Pk,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),t.selector=ln(n,96,100);try{const r=Jw(n,128);if(r==null)throw new Error("abort");t.extraData=r}catch{ht(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return t.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>t[r]),t}function Zu(n,t){if(n.provider)return n.provider;ht(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:t})}async function Mk(n,t){let e=vp(t);if(e.to!=null&&(e.to=br(e.to,n)),e.from!=null){const r=e.from;e.from=Promise.all([n.getAddress(),br(r,n)]).then(([i,s])=>(K(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else e.from=n.getAddress();return await gr(e)}class uV{constructor(t){Z(this,"provider");$t(this,{provider:t||null})}async getNonce(t){return Zu(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Mk(this,t)}async populateTransaction(t){const e=Zu(this,"populateTransaction"),r=await Mk(this,t);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const i=await this.provider.getNetwork();if(r.chainId!=null){const o=Ct(r.chainId);K(o===i.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=i.chainId;const s=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||s)?K(!1,"eip-1559 transaction do not support gasPrice","tx",t):(r.type===0||r.type===1)&&s&&K(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await e.getFeeData();ht(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await e.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ht(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ht(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await gr(r)}async estimateGas(t){return Zu(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return Zu(this,"call").call(await this.populateCall(t))}async resolveName(t){return await Zu(this,"resolveName").resolveName(t)}async sendTransaction(t){const e=Zu(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const i=wp.from(r);return await e.broadcastTransaction(await this.signTransaction(i))}}function lV(n){return JSON.parse(JSON.stringify(n))}class Lk{constructor(t){Y(this,ia);Y(this,Er);Y(this,hs);Y(this,xc);Y(this,ra);Y(this,Rc);Y(this,$l);F(this,Er,t),F(this,hs,null),F(this,xc,yt(this,ia,Bb).bind(this)),F(this,ra,!1),F(this,Rc,null),F(this,$l,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){S(this,ra)||(F(this,ra,!0),yt(this,ia,Bb).call(this,-2))}stop(){S(this,ra)&&(F(this,ra,!1),F(this,$l,!0),yt(this,ia,Pb).call(this),S(this,Er).off("block",S(this,xc)))}pause(t){t&&yt(this,ia,Pb).call(this),S(this,Er).off("block",S(this,xc))}resume(){this.start()}}Er=new WeakMap,hs=new WeakMap,xc=new WeakMap,ra=new WeakMap,Rc=new WeakMap,$l=new WeakMap,ia=new WeakSet,Bb=async function(t){try{S(this,hs)==null&&F(this,hs,this._subscribe(S(this,Er)));let e=null;try{e=await S(this,hs)}catch(s){if(!qn(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(e==null){F(this,hs,null),S(this,Er)._recoverSubscriber(this,this._recover(S(this,Er)));return}const r=await S(this,Er).getNetwork();if(S(this,Rc)||F(this,Rc,r),S(this,Rc).chainId!==r.chainId)throw new Error("chaid changed");if(S(this,$l))return;const i=await S(this,Er).send("eth_getFilterChanges",[e]);await this._emitResults(S(this,Er),i)}catch(e){console.log("@TODO",e)}S(this,Er).once("block",S(this,xc))},Pb=function(){const t=S(this,hs);t&&(F(this,hs,null),t.then(e=>{S(this,Er).destroyed||S(this,Er).send("eth_uninstallFilter",[e])}))};class fV extends Lk{constructor(e,r){super(e);Y(this,Ic);F(this,Ic,lV(r))}_recover(e){return new Zw(e,S(this,Ic))}async _subscribe(e){return await e.send("eth_newFilter",[S(this,Ic)])}async _emitResults(e,r){for(const i of r)e.emit(S(this,Ic),e._wrapLog(i,e._network))}}Ic=new WeakMap;class hV extends Lk{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const dV="bigint,boolean,function,number,string,symbol".split(/,/g);function Pp(n){if(n==null||dV.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(Pp);if(typeof n=="object")return Object.keys(n).reduce((t,e)=>(t[e]=n[e],t),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function pV(n){return new Promise(t=>{setTimeout(t,n)})}function qu(n){return n&&n.toLowerCase()}function Uk(n){return n&&typeof n.pollingInterval=="number"}const Dk={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Xw extends uV{constructor(e,r){super(e);Z(this,"address");r=Le(r),$t(this,{address:r})}connect(e){ht(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const r=Pp(e),i=[];if(r.from){const o=r.from;i.push((async()=>{const a=await br(o,this.provider);K(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&i.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;i.push((async()=>{r.to=await br(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const r=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(e);return await new Promise((s,o)=>{const a=[1e3,100];let u=0;const f=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(r));return}}catch(h){if(qn(h,"CANCELLED")||qn(h,"BAD_DATA")||qn(h,"NETWORK_ERROR")||qn(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(qn(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Ye("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{f()},a.pop()||4e3)};f()})}async signTransaction(e){const r=Pp(e);if(r.from){const s=await br(r.from,this.provider);K(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=s}else r.from=this.address;const i=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[i])}async signMessage(e){const r=typeof e=="string"?Ms(e):e;return await this.provider.send("personal_sign",[Tt(r),this.address.toLowerCase()])}async signTypedData(e,r,i){const s=Pp(i),o=await _p.resolveNames(e,r,s,async a=>{const u=await br(a);return K(u!=null,"TypedData does not support null address","value",a),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(_p.getPayload(o.domain,r,o.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const r=typeof e=="string"?Ms(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Tt(r)])}}class Fk extends rV{constructor(e,r){super(e,r);Y(this,Vh);Y(this,Sc);Y(this,Hl);Y(this,io);Y(this,ds);Y(this,Ci);Y(this,pi);Y(this,Pr);F(this,Hl,1),F(this,Sc,Object.assign({},Dk,r||{})),F(this,io,[]),F(this,ds,null),F(this,pi,null),F(this,Pr,null);{let s=null;const o=new Promise(a=>{s=a});F(this,Ci,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(K(!i||e!=="any","staticNetwork cannot be used on special network 'any'","options",r),i&&e!=null&&F(this,pi,is.from(e))):i&&(K(e==null||i.matches(e),"staticNetwork MUST match network object","options",r),F(this,pi,i))}_getOption(e){return S(this,Sc)[e]}get _network(){return ht(S(this,pi),"network is not available yet","NETWORK_ERROR"),S(this,pi)}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let i=e.transaction;if(i&&i.type!=null&&Ct(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},i,{type:void 0})}))}}const r=this.getRpcRequest(e);return r!=null?await this.send(r.method,r.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(S(this,pi))return S(this,pi)}else return e;return S(this,Pr)?await S(this,Pr):this.ready?(F(this,Pr,(async()=>{try{const r=is.from(Ct(await this.send("eth_chainId",[])));return F(this,Pr,null),r}catch(r){throw F(this,Pr,null),r}})()),await S(this,Pr)):(F(this,Pr,(async()=>{const r={id:ao(this,Hl)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let i;try{i=(await this._send(r))[0],F(this,Pr,null)}catch(s){throw F(this,Pr,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return is.from(Ct(i.result));throw this.getRpcError(r,i)})()),await S(this,Pr))}_start(){S(this,Ci)==null||S(this,Ci).resolve==null||(S(this,Ci).resolve(),F(this,Ci,null),(async()=>{for(;S(this,pi)==null&&!this.destroyed;)try{F(this,pi,await this._detectNetwork())}catch(e){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Ye("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await pV(1e3)}yt(this,Vh,Mb).call(this)})())}async _waitUntilReady(){if(S(this,Ci)!=null)return await S(this,Ci).promise}_getSubscriber(e){return e.type==="pending"?new hV(this):e.type==="event"?this._getOption("polling")?new Zw(this,e.filter):new fV(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new Bp("orphan"):super._getSubscriber(e)}get ready(){return S(this,Ci)==null}getRpcTransaction(e){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(e[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),r[s]=Bu(Ct(e[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{e[i]!=null&&(r[i]=Tt(e[i]))}),e.accessList&&(r.accessList=Xa(e.accessList)),e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes.map(i=>i.toLowerCase())),r}getRpcRequest(e){switch(e.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[qu(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[qu(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[qu(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[qu(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(qu):e.filter.address=qu(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,r){const{method:i}=e,{error:s}=r;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Ye("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=t1(s),f=Eh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",e.params[0],u?u.data:null);return f.info={error:s,payload:e},f}const o=JSON.stringify(mV(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Ye("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[i]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=e.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Ye("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Ye("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Ye("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Ye("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?Ye("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):Ye("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,r){if(this.destroyed)return Promise.reject(Ye("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const i=ao(this,Hl)._++,s=new Promise((o,a)=>{S(this,io).push({resolve:o,reject:a,payload:{method:e,params:r,id:i,jsonrpc:"2.0"}})});return yt(this,Vh,Mb).call(this),s}async getSigner(e){e==null&&(e=0);const r=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await r;if(e>=s.length)throw new Error("no such account");return new Xw(this,s[e])}const{accounts:i}=await gr({network:this.getNetwork(),accounts:r});e=Le(e);for(const s of i)if(Le(s)===e)return new Xw(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new Xw(this,r))}destroy(){S(this,ds)&&(clearTimeout(S(this,ds)),F(this,ds,null));for(const{payload:e,reject:r}of S(this,io))r(Ye("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));F(this,io,[]),super.destroy()}}Sc=new WeakMap,Hl=new WeakMap,io=new WeakMap,ds=new WeakMap,Ci=new WeakMap,pi=new WeakMap,Pr=new WeakMap,Vh=new WeakSet,Mb=function(){if(S(this,ds))return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");F(this,ds,setTimeout(()=>{F(this,ds,null);const r=S(this,io);for(F(this,io,[]);r.length;){const i=[r.shift()];for(;r.length&&i.length!==S(this,Sc).batchMaxCount;)if(i.push(r.shift()),JSON.stringify(i.map(o=>o.payload)).length>S(this,Sc).batchMaxSize){r.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:u,payload:f}of i){if(this.destroyed){u(Ye("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:f.method}));continue}const h=o.filter(y=>y.id===f.id)[0];if(h==null){const y=Ye("missing response for request","BAD_DATA",{value:o,info:{payload:f}});this.emit("error",y),u(y);continue}if("error"in h){u(this.getRpcError(f,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of i)a(o)}})()}},e))};class gV extends Fk{constructor(e,r){super(e,r);Y(this,sa);let i=this._getOption("pollingInterval");i==null&&(i=Dk.pollingInterval),F(this,sa,i)}_getSubscriber(e){const r=super._getSubscriber(e);return Uk(r)&&(r.pollingInterval=S(this,sa)),r}get pollingInterval(){return S(this,sa)}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");F(this,sa,e),this._forEachSubscriber(r=>{Uk(r)&&(r.pollingInterval=S(this,sa))})}}sa=new WeakMap;class yV extends gV{constructor(e,r,i){e==null&&(e="http://localhost:8545");super(r,i);Y(this,zl);typeof e=="string"?F(this,zl,new Ls(e)):F(this,zl,e.clone())}_getConnection(){return S(this,zl).clone()}async send(e,r){return await this._start(),await super.send(e,r)}async _send(e){const r=this._getConnection();r.body=JSON.stringify(e),r.setHeader("content-type","application/json");const i=await r.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}zl=new WeakMap;function t1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&Ge(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const t in n){const e=t1(n[t]);if(e)return e}return null}if(typeof n=="string")try{return t1(JSON.parse(n))}catch{}return null}function e1(n,t){if(n!=null){if(typeof n.message=="string"&&t.push(n.message),typeof n=="object")for(const e in n)e1(n[e],t);if(typeof n=="string")try{return e1(JSON.parse(n),t)}catch{}}}function mV(n){const t=[];return e1(n,t),t}function wV(){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 bV=wV().WebSocket;class n1{constructor(t,e){Y(this,ps);Y(this,Kh);Y(this,oa);Y(this,kc);Y(this,aa);F(this,ps,t),F(this,Kh,JSON.stringify(e)),F(this,oa,null),F(this,kc,null),F(this,aa,null)}get filter(){return JSON.parse(S(this,Kh))}start(){F(this,oa,S(this,ps).send("eth_subscribe",this.filter).then(t=>(S(this,ps)._register(t,this),t)))}stop(){S(this,oa).then(t=>{S(this,ps).destroyed||S(this,ps).send("eth_unsubscribe",[t])}),F(this,oa,null)}pause(t){ht(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),F(this,kc,!!t)}resume(){F(this,kc,null)}_handleMessage(t){if(S(this,oa)!=null&&S(this,kc)===null){let e=S(this,aa);e==null?e=this._emit(S(this,ps),t):e=e.then(async()=>{await this._emit(S(this,ps),t)}),F(this,aa,e.then(()=>{S(this,aa)===e&&F(this,aa,null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}ps=new WeakMap,Kh=new WeakMap,oa=new WeakMap,kc=new WeakMap,aa=new WeakMap;class _V extends n1{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class AV extends n1{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}class EV extends n1{constructor(e,r){super(e,["logs",r]);Y(this,jh);F(this,jh,JSON.stringify(r))}get logFilter(){return JSON.parse(S(this,jh))}async _emit(e,r){e.emit(this.logFilter,e._wrapLog(r,e._network))}}jh=new WeakMap;class vV extends Fk{constructor(e,r){const i=Object.assign({},r??{});K(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(e,i);Y(this,Tc);Y(this,Gl);Y(this,ca);F(this,Tc,new Map),F(this,Gl,new Map),F(this,ca,new Map)}_getSubscriber(e){switch(e.type){case"close":return new Bp("close");case"block":return new _V(this);case"pending":return new AV(this);case"event":return new EV(this,e.filter);case"orphan":if(e.filter.orphan==="drop-log")return new Bp("drop-log")}return super._getSubscriber(e)}_register(e,r){S(this,Gl).set(e,r);const i=S(this,ca).get(e);if(i){for(const s of i)r._handleMessage(s);S(this,ca).delete(e)}}async _send(e){K(!Array.isArray(e),"WebSocket does not support batch send","payload",e);const r=new Promise((i,s)=>{S(this,Tc).set(e.id,{payload:e,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(e)),[await r]}async _processMessage(e){const r=JSON.parse(e);if(r&&typeof r=="object"&&"id"in r){const i=S(this,Tc).get(r.id);if(i==null){this.emit("error",Ye("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}S(this,Tc).delete(r.id),i.resolve(r)}else if(r&&r.method==="eth_subscription"){const i=r.params.subscription,s=S(this,Gl).get(i);if(s)s._handleMessage(r.params.result);else{let o=S(this,ca).get(i);o==null&&(o=[],S(this,ca).set(i,o)),o.push(r.params.result)}}else{this.emit("error",Ye("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(e){throw new Error("sub-classes must override this")}}Tc=new WeakMap,Gl=new WeakMap,ca=new WeakMap;class xV extends vV{constructor(e,r,i){super(r,i);Y(this,Oc);Y(this,Bi);typeof e=="string"?(F(this,Oc,()=>new bV(e)),F(this,Bi,S(this,Oc).call(this))):typeof e=="function"?(F(this,Oc,e),F(this,Bi,e())):(F(this,Oc,null),F(this,Bi,e)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(S(this,Bi)==null)throw new Error("websocket closed");return S(this,Bi)}async _write(e){this.websocket.send(e)}async destroy(){S(this,Bi)!=null&&(S(this,Bi).close(),F(this,Bi,null)),super.destroy()}}Oc=new WeakMap,Bi=new WeakMap;const RV={_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:{}},IV={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 SV{constructor(t){this.settings=t,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:t,contractAddress:e}=this.settings;if(!e)throw new Error("Contract address is required for EVM chain type");const r=t.startsWith("ws")?new xV(t):new yV(t),i=new ju(e,RV.abi,r);this.evm={provider:r,contract:i}}initSvm(){const t=new zE(this.settings.rpcUrl,"confirmed"),e=Ba.generate(),r={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:e.publicKey},i=new nh(t,r,{}),s=new Tu(IV,i);this.svm={provider:t,program:s}}async onMessageFrom(t,e){this.settings.chainType==="EVM"?this.listenToEvm(t,e):this.settings.chainType==="SVM"&&await this.listenToSvm(t,e)}listenToEvm(t,e){var r;(r=this.evm)==null||r.contract.on("MessageLogged",(i,s)=>{const[o,a]=s.split("_");ef(i.toLowerCase())===ef(this.settings.swarmEmitterAddress.toLowerCase())&&o===t&&e(i,s)})}async listenToSvm(t,e){var i;const r=(i=this.svm)==null?void 0:i.program.addEventListener("messageLogged",s=>{const{sender:o,message:a}=s,[u,f]=a.split("_");o.toBase58()===this.settings.swarmEmitterAddress&&u===t&&e(o.toBase58(),a)});this.svm&&r!==void 0&&(this.svm.listenerId=r)}async removeAllListeners(){var t,e;this.settings.chainType==="EVM"&&((t=this.evm)==null||t.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((e=this.svm)==null?void 0:e.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const kV=new TextEncoder,$k=1,Hk=4096,r1=4096,TV=32;function OV(n,t){return t=typeof t=="number"?xt.FeedIndex.fromBigInt(BigInt(t)):t,new xt.Identifier(Xn.keccak256(Xn.concatBytes(n.toUint8Array(),t.toUint8Array())))}function NV(n){const t=n.slice(0,xt.Span.LENGTH),e=n.slice(xt.Span.LENGTH),r=CV(e),i=Xn.keccak256(Xn.concatBytes(t,r));return new xt.Reference(i)}function CV(n){if(n.length>r1)throw new xt.BeeArgumentError(`payload size ${n.length} exceeds maximum chunk payload size ${r1}`,n);const t=new Uint8Array(r1);return t.set(n),Xn.log2Reduce(Xn.partition(t,TV),(e,r)=>Xn.keccak256(Xn.concatBytes(e,r)))}function zk(n){if(n instanceof Uint8Array||(n=kV.encode(n)),n.length<$k||n.length>Hk)throw new RangeError(`payload size ${n.length} exceeds limits [${$k}, ${Hk}]`);const t=xt.Span.fromBigInt(BigInt(n.length)),e=Xn.concatBytes(t.toUint8Array(),n);return{data:e,span:t,payload:xt.Bytes.fromSlice(e,xt.Span.LENGTH),address:NV(e)}}function BV(n,t){return new xt.Reference(Xn.keccak256(Xn.concatBytes(n.toUint8Array(),t.toUint8Array())))}function Gk(n,t,e){t=new xt.Identifier(t),e=new xt.PrivateKey(e);const r=BV(t,e.publicKey().address()),i=e.sign(Xn.concatBytes(t.toUint8Array(),n.address.toUint8Array())),s=Xn.concatBytes(t.toUint8Array(),i.toUint8Array(),n.data),o=xt.Span.fromSlice(n.data,0),a=xt.Bytes.fromSlice(n.data,xt.Span.LENGTH);return{data:s,identifier:t,signature:i,span:o,payload:a,address:r,owner:e.publicKey().address()}}class PV{constructor(t,e){this.userDetails=t,this.swarmSettings=e,this.depth=24,this.logger=Mi.getInstance(),this.errorHandler=new Sg,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(t,e){const{enveloped:r,stamp:i}=this.swarmSettings;if(!r)await this.writeOwnFeedDataByIndexOwned(t,e);else if(i)await this.writeOwnFeedDataByIndexEnvelope(t,e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),f=xt.Topic.fromString(u);console.log("DEBUG: feedID write",f.toString(),a,t,u),await r.makeFeedWriter(f,new xt.PrivateKey(o)).uploadPayload(i,JSON.stringify(e),{index:t})}async writeOwnFeedDataByIndexEnvelope(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new xt.PrivateKey(o),f=xt.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),y=xt.Topic.fromString(h),_=OV(y,t),w=zk(e),R=Gk(w,_,u),T={hash:()=>R.address.toUint8Array()},I=f.stamp(T),{upload:B}=r.makeSOCWriter(u),H=xt.Bytes.fromUtf8(e);return(await B(I,_,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(t,e,r){const{bee:i,chatTopic:s}=this.swarmSettings,o=(r==null?void 0:r.timeout)??1500,a=this.generateUserOwnedFeedId(s,t),u=xt.Topic.fromString(a);return console.log("DEBUG: feedID read",u.toString(),t,e,a),(await i.makeFeedReader(u,t,{timeout:o}).downloadPayload({index:e})).payload.toJSON()}orderMessages(t){return t.sort((e,r)=>e.timestamp-r.timestamp)}async retryAwaitableAsync(t,e=3,r=250){return new Promise((i,s)=>{t().then(i).catch(o=>{e>0?(this.logger.info(`Retrying... Attempts left: ${e}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(t,e-1,r).then(i).catch(s)},r)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(e){if(r)return this.uploadObjectToBeeEnvelope(t);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(t)}async uploadObjectToBeeOwn(t){try{const{bee:e,stamp:r}=this.swarmSettings,i=await e.uploadData(r,JSON.stringify(t),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(t){try{const{bee:e,stamp:r}=this.swarmSettings,{privateKey:i}=this.userDetails,s=xt.Stamper.fromBlank(i,r,this.depth),o=xt.Bytes.fromUtf8(JSON.stringify(t)),a=new q8(async f=>{await e.uploadChunk(s.stamp(f),f.build())});await a.append(o.toUint8Array());const u=await a.finalize();return Xn.uint8ArrayToHex(u.hash())}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(t){try{const{bee:e}=this.swarmSettings;return(await e.downloadData(t)).toJSON()}catch(e){return this.errorHandler.handleError(e,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:t,chatTopic:e}=this.swarmSettings,{ownAddress:r}=this.userDetails,i=this.generateUserOwnedFeedId(e,r),s=xt.Topic.fromString(i),a=await t.makeFeedReader(s,r).downloadPayload(),u=Number(a.feedIndex.toBigInt()),f=u+1;return console.log("DEBUG: getLatestFeedIndex",u,f),{latestIndex:u,nextIndex:f}}catch(t){if(this.isNotFoundError(t))return{latestIndex:-1,nextIndex:0};throw t}}async fetchLatestChatMessage(){const{bee:t,chatTopic:e,chatAddress:r}=this.swarmSettings,s=await t.makeFeedReader(xt.Topic.fromString(e),ef(r)).downloadPayload();return{message:s.payload.toJSON(),index:s.feedIndex}}async fetchChatMessage(t){const{bee:e,chatTopic:r,chatAddress:i}=this.swarmSettings;return(await e.makeFeedReader(xt.Topic.fromString(r),ef(i)).downloadPayload({index:t})).payload.toJSON()}async sendMessageToGsoc(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(!e)await this.sendMessageToGsocOwn(t);else if(r)await this.sendMessageToGsocEnvelope(t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new xt.PrivateKey(s),a=xt.Identifier.fromString(i),u=xt.Bytes.fromUtf8(t),{upload:f}=e.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await f(r,a,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=xt.Stamper.fromBlank(o,r,this.depth),u=new xt.PrivateKey(s),f=xt.Identifier.fromString(i),h=xt.Bytes.fromUtf8(t),y=zk(h.toUint8Array()),_=Gk(y,f,u),w={hash:()=>_.address.toUint8Array()},R=a.stamp(w),{upload:T}=e.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await T(R,f,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(t,e){return`${t}_EthercastChat_${e}`}isNotFoundError(t){return t.stack.includes("404")||t.message.includes("Not Found")||t.message.includes("404")}}class MV{constructor(t){var r,i,s;this.logger=Mi.getInstance(),this.errorHandler=new Sg,this.messagesQueue=new I_({concurrency:1}),this.gsocListenerQueue=new I_({concurrency:1}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const e=new xt.PrivateKey(ef(t.user.privateKey));this.userDetails={privateKey:t.user.privateKey,ownAddress:e.publicKey().address().toString(),nickname:t.user.nickname,ownIndex:-1},this.swarmSettings={bee:new xt.Bee(t.infra.swarm.beeUrl),stamp:t.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:t.infra.swarm.enveloped,customGsocCallback:t.infra.swarm.customGsocCallback,gsocTopic:t.infra.swarm.gsocTopic,gsocResourceId:t.infra.swarm.gsocResourceId,chatTopic:t.infra.swarm.chatTopic,chatAddress:t.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((r=t.options)==null?void 0:r.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=t.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=t.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new Z8,this.utils=new PV(this.userDetails,this.swarmSettings),this.history=new sP(this.utils,this.emitter),!this.swarmSettings.customGsocCallback&&t.infra.chain&&(this.swarmEventEmitterReader=new SV(t.infra.chain))}start(){this.init(),this.startMessagesFetchProcess(),this.startIdleUserCleanup(),this.swarmSettings.customGsocCallback||this.subscribeToGSOCEvent()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.emitter.cleanAll(),this.swarmSettings.customGsocCallback||this.unsubFromGSOCEvent()}getEmitter(){return this.emitter}orderMessages(t){return this.utils.orderMessages(t)}async sendMessage(t,e){const r=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:e||W8(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:r,message:t};try{this.emitter.emit(Ur.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(r,JSON.stringify(i)),this.userDetails.ownIndex=r,this.emitter.emit(Ur.MESSAGE_REQUEST_UPLOADED,i),await this.broadcastUserMessage()}catch(s){this.emitter.emit(Ur.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Ur.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages()}finally{this.emitter.emit(Ur.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(t){this.sendMessage(t.message,t.id)}async retryBroadcastUserMessage(t){this.broadcastUserMessage()}async init(){try{this.emitter.emit(Ur.LOADING_INIT,!0);const[t,e]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(t.status==="rejected")throw t.reason;e.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${e.reason}`),this.emitter.emit(Ur.LOADING_INIT,!1)}catch(t){this.errorHandler.handleError(t,"Chat.initSelfState"),this.emitter.emit(Ur.CRITICAL_ERROR,t)}}async initOwnIndex(){const{latestIndex:r}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=r}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom(this.swarmSettings.chatTopic,(t,e)=>this.gsocListenerQueue.add(()=>this.processGsocEvent(e)))}catch(t){this.errorHandler.handleError(t,"Chat.subscribeToGSOCEvent"),this.emitter.emit(Ur.CRITICAL_ERROR,t)}}callbackProcessGsocEvent(t){try{this.gsocListenerQueue.add(()=>this.processGsocEvent(t))}catch(e){this.errorHandler.handleError(e,"Chat.callbackProcessGsocEvent"),this.emitter.emit(Ur.CRITICAL_ERROR,e)}}async processGsocEvent(t){try{console.log("processGsocMessage CALLED",t);const[e,r]=t.split("_"),i=xt.FeedIndex.fromBigInt(BigInt(`0x${r}`)),s=await this.utils.fetchChatMessage(i);if(console.log("DEBUG processGsocMessage",s),!tP(s)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",s),D8(this.latestMessage,s))return;this.updateActiveUsers(s.messageSender),this.latestMessage=s}catch(e){this.errorHandler.handleError(e,"Chat.processGsocMessage")}}async waitForMessageBroadcast(t){return rP({condition:()=>Object.values(this.activeUsers).some(e=>e.index===t),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const t=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",t),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({topic:this.swarmSettings.chatTopic,messageSender:t})))}catch(t){this.errorHandler.handleError(t,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:t,privateKey:e,nickname:r}=this.userDetails,i=new xt.EthAddress(t).toString(),s=new xt.PrivateKey(e);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const a=Date.now(),u=s.sign(JSON.stringify({username:r,address:i,timestamp:a}));return{address:i,timestamp:a,signature:u.toHex(),index:this.getOwnIndex(),username:r}}async readAllActiveUserMessage(){if(!(this.messagesQueue.size>0||this.messagesQueue.pending>0))for(const e of Object.values(this.activeUsers))this.messagesQueue.add(()=>this.readMessage(e))}async readMessage(t){try{let e;const r=this.isUserIndexRead(t.address,t.index);if(r.isIndexRead)return;e=r.cachedIndex?r.cachedIndex+1:t.index;const i=await this.utils.fetchUserFeedDataByIndex(t.address,e);this.setUserIndexCache(t.address,e),this.emitter.emit(Ur.MESSAGE_RECEIVED,JSON.parse(i))}catch(e){this.errorHandler.handleError(e,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:t,FETCH_MESSAGE_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),e)}stopMessagesFetchProcess(){const{fetchMessageTimer:t}=this.options;t&&(clearInterval(t),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:t,IDLE_USER_CLEANUP_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),e)}stopIdleUserCleanup(){const{idleUserCleanupInterval:t}=this.options;t&&(clearInterval(t),this.options.idleUserCleanupInterval=null)}isUserIndexRead(t,e){const r=this.userIndexCache[t];return{cachedIndex:r,isIndexRead:r===e}}setUserIndexCache(t,e){this.userIndexCache[t]=e}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const t=Date.now();for(const e of Object.values(this.activeUsers))t-e.timestamp>300*iP&&delete this.activeUsers[e.address]}updateActiveUsers(t){this.activeUsers[t.address]=t}}ue.EVENTS=Ur,ue.SwarmChat=MV,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})});
|