@orderly.network/core 0.0.51 → 0.0.53

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var cn=Object.create;var st=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var ln=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,pn=Object.prototype.hasOwnProperty;var pe=(o,n)=>()=>(o&&(n=o(o=0)),n);var at=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var yn=(o,n,a,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of ln(n))!pn.call(o,d)&&d!==a&&st(o,d,{get:()=>n[d],enumerable:!(u=un(n,d))||u.enumerable});return o};var hn=(o,n,a)=>(a=o!=null?cn(dn(o)):{},yn(n||!o||!o.__esModule?st(a,"default",{value:o,enumerable:!0}):a,o));var E=pe(()=>{"use strict"});function fn(o,n){this.fun=o,this.array=n}function ot(o){var n=Math.floor((Date.now()-te.now())*.001),a=te.now()*.001,u=Math.floor(a)+n,d=Math.floor(a%1*1e9);return o&&(u=u-o[0],d=d-o[1],d<0&&(u--,d+=Ke)),[u,d]}var jn,te,Me,Ke,ct=pe(()=>{"use strict";E();v();T();fn.prototype.run=function(){this.fun.apply(null,this.array)};jn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},te={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};te.now===void 0&&(Me=Date.now(),te.timing&&te.timing.navigationStart&&(Me=te.timing.navigationStart),te.now=()=>Date.now()-Me);Ke=1e9;ot.bigint=function(o){var n=ot(o);return typeof BigInt>"u"?n[0]*Ke+n[1]:BigInt(n[0]*Ke)+BigInt(n[1])}});var T=pe(()=>{"use strict";ct()});function gn(){if(ut)return ye;ut=!0,ye.byteLength=f,ye.toByteArray=I,ye.fromByteArray=_;for(var o=[],n=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=u.length;d<p;++d)o[d]=u[d],n[u.charCodeAt(d)]=d;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;function s(h){var m=h.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=h.indexOf("=");B===-1&&(B=m);var x=B===m?0:4-B%4;return[B,x]}function f(h){var m=s(h),B=m[0],x=m[1];return(B+x)*3/4-x}function w(h,m,B){return(m+B)*3/4-B}function I(h){var m,B=s(h),x=B[0],k=B[1],C=new a(w(h,x,k)),U=0,M=k>0?x-4:x,K;for(K=0;K<M;K+=4)m=n[h.charCodeAt(K)]<<18|n[h.charCodeAt(K+1)]<<12|n[h.charCodeAt(K+2)]<<6|n[h.charCodeAt(K+3)],C[U++]=m>>16&255,C[U++]=m>>8&255,C[U++]=m&255;return k===2&&(m=n[h.charCodeAt(K)]<<2|n[h.charCodeAt(K+1)]>>4,C[U++]=m&255),k===1&&(m=n[h.charCodeAt(K)]<<10|n[h.charCodeAt(K+1)]<<4|n[h.charCodeAt(K+2)]>>2,C[U++]=m>>8&255,C[U++]=m&255),C}function g(h){return o[h>>18&63]+o[h>>12&63]+o[h>>6&63]+o[h&63]}function A(h,m,B){for(var x,k=[],C=m;C<B;C+=3)x=(h[C]<<16&16711680)+(h[C+1]<<8&65280)+(h[C+2]&255),k.push(g(x));return k.join("")}function _(h){for(var m,B=h.length,x=B%3,k=[],C=16383,U=0,M=B-x;U<M;U+=C)k.push(A(h,U,U+C>M?M:U+C));return x===1?(m=h[B-1],k.push(o[m>>2]+o[m<<4&63]+"==")):x===2&&(m=(h[B-2]<<8)+h[B-1],k.push(o[m>>10]+o[m>>4&63]+o[m<<2&63]+"=")),k.join("")}return ye}function mn(){if(lt)return Ae;lt=!0;return Ae.read=function(o,n,a,u,d){var p,s,f=d*8-u-1,w=(1<<f)-1,I=w>>1,g=-7,A=a?d-1:0,_=a?-1:1,h=o[n+A];for(A+=_,p=h&(1<<-g)-1,h>>=-g,g+=f;g>0;p=p*256+o[n+A],A+=_,g-=8);for(s=p&(1<<-g)-1,p>>=-g,g+=u;g>0;s=s*256+o[n+A],A+=_,g-=8);if(p===0)p=1-I;else{if(p===w)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,u),p=p-I}return(h?-1:1)*s*Math.pow(2,p-u)},Ae.write=function(o,n,a,u,d,p){var s,f,w,I=p*8-d-1,g=(1<<I)-1,A=g>>1,_=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=u?0:p-1,m=u?1:-1,B=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(f=isNaN(n)?1:0,s=g):(s=Math.floor(Math.log(n)/Math.LN2),n*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+A>=1?n+=_/w:n+=_*Math.pow(2,1-A),n*w>=2&&(s++,w/=2),s+A>=g?(f=0,s=g):s+A>=1?(f=(n*w-1)*Math.pow(2,d),s=s+A):(f=n*Math.pow(2,A-1)*Math.pow(2,d),s=0));d>=8;o[a+h]=f&255,h+=m,f/=256,d-=8);for(s=s<<d|f,I+=d;I>0;o[a+h]=s&255,h+=m,s/=256,I-=8);o[a+h-m]|=B*128},Ae}function wn(){if(dt)return ne;dt=!0;let o=gn(),n=mn(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ne.Buffer=s,ne.SlowBuffer=k,ne.INSPECT_MAX_BYTES=50;let u=2147483647;ne.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=d(),!s.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 d(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function p(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return f(r,e,t)}s.poolSize=8192;function f(r,e,t){if(typeof r=="string")return A(r,e);if(ArrayBuffer.isView(r))return h(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(Y(r,ArrayBuffer)||r&&Y(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Y(r,SharedArrayBuffer)||r&&Y(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return s.from(i,e,t);let c=B(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return f(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function I(r,e,t){return w(r),r<=0?p(r):e!==void 0?typeof t=="string"?p(r).fill(e,t):p(r).fill(e):p(r)}s.alloc=function(r,e,t){return I(r,e,t)};function g(r){return w(r),p(r<0?0:x(r)|0)}s.allocUnsafe=function(r){return g(r)},s.allocUnsafeSlow=function(r){return g(r)};function A(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=C(r,e)|0,i=p(t),c=i.write(r,e);return c!==t&&(i=i.slice(0,c)),i}function _(r){let e=r.length<0?0:x(r.length)|0,t=p(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function h(r){if(Y(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return _(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,s.prototype),i}function B(r){if(s.isBuffer(r)){let e=x(r.length)|0,t=p(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Pe(r.length)?p(0):_(r);if(r.type==="Buffer"&&Array.isArray(r.data))return _(r.data)}function x(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function k(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,c=t.length;for(let l=0,y=Math.min(i,c);l<y;++l)if(e[l]!==t[l]){i=e[l],c=t[l];break}return i<c?-1:c<i?1:0},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let c=s.allocUnsafe(t),l=0;for(i=0;i<e.length;++i){let y=e[i];if(Y(y,Uint8Array))l+y.length>c.length?(s.isBuffer(y)||(y=s.from(y)),y.copy(c,l)):Uint8Array.prototype.set.call(c,y,l);else if(s.isBuffer(y))y.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=y.length}return c};function C(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Y(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ue(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return it(r).length;default:if(c)return i?-1:Ue(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=C;function U(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Jt(this,e,t);case"utf8":case"utf-8":return Ge(this,e,t);case"ascii":return Xt(this,e,t);case"latin1":case"binary":return Zt(this,e,t);case"base64":return Yt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qt(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}s.prototype._isBuffer=!0;function M(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)M(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ge(this,0,e):U.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=ne.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,i,c,l){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||i>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=i)return 0;if(c>=l)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,c>>>=0,l>>>=0,this===e)return 0;let y=l-c,S=i-t,R=Math.min(y,S),N=this.slice(c,l),D=e.slice(t,i);for(let P=0;P<R;++P)if(N[P]!==D[P]){y=N[P],S=D[P];break}return y<S?-1:S<y?1:0};function K(r,e,t,i,c){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Pe(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,i)),s.isBuffer(e))return e.length===0?-1:H(r,e,t,i,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):H(r,[e],t,i,c);throw new TypeError("val must be string, number or Buffer")}function H(r,e,t,i,c){let l=1,y=r.length,S=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,y/=2,S/=2,t/=2}function R(D,P){return l===1?D[P]:D.readUInt16BE(P*l)}let N;if(c){let D=-1;for(N=t;N<y;N++)if(R(r,N)===R(e,D===-1?0:N-D)){if(D===-1&&(D=N),N-D+1===S)return D*l}else D!==-1&&(N-=N-D),D=-1}else for(t+S>y&&(t=y-S),N=t;N>=0;N--){let D=!0;for(let P=0;P<S;P++)if(R(r,N+P)!==R(e,P)){D=!1;break}if(D)return N}return-1}s.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},s.prototype.indexOf=function(e,t,i){return K(this,e,t,i,!0)},s.prototype.lastIndexOf=function(e,t,i){return K(this,e,t,i,!1)};function q(r,e,t,i){t=Number(t)||0;let c=r.length-t;i?(i=Number(i),i>c&&(i=c)):i=c;let l=e.length;i>l/2&&(i=l/2);let y;for(y=0;y<i;++y){let S=parseInt(e.substr(y*2,2),16);if(Pe(S))return y;r[t+y]=S}return y}function ae(r,e,t,i){return be(Ue(e,r.length-t),r,t,i)}function jt(r,e,t,i){return be(rn(e),r,t,i)}function zt(r,e,t,i){return be(it(e),r,t,i)}function qt(r,e,t,i){return be(sn(e,r.length-t),r,t,i)}s.prototype.write=function(e,t,i,c){if(t===void 0)c="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")c=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,c===void 0&&(c="utf8")):(c=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((i===void 0||i>l)&&(i=l),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let y=!1;for(;;)switch(c){case"hex":return q(this,e,t,i);case"utf8":case"utf-8":return ae(this,e,t,i);case"ascii":case"latin1":case"binary":return jt(this,e,t,i);case"base64":return zt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qt(this,e,t,i);default:if(y)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),y=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yt(r,e,t){return e===0&&t===r.length?o.fromByteArray(r):o.fromByteArray(r.slice(e,t))}function Ge(r,e,t){t=Math.min(r.length,t);let i=[],c=e;for(;c<t;){let l=r[c],y=null,S=l>239?4:l>223?3:l>191?2:1;if(c+S<=t){let R,N,D,P;switch(S){case 1:l<128&&(y=l);break;case 2:R=r[c+1],(R&192)===128&&(P=(l&31)<<6|R&63,P>127&&(y=P));break;case 3:R=r[c+1],N=r[c+2],(R&192)===128&&(N&192)===128&&(P=(l&15)<<12|(R&63)<<6|N&63,P>2047&&(P<55296||P>57343)&&(y=P));break;case 4:R=r[c+1],N=r[c+2],D=r[c+3],(R&192)===128&&(N&192)===128&&(D&192)===128&&(P=(l&15)<<18|(R&63)<<12|(N&63)<<6|D&63,P>65535&&P<1114112&&(y=P))}}y===null?(y=65533,S=1):y>65535&&(y-=65536,i.push(y>>>10&1023|55296),y=56320|y&1023),i.push(y),c+=S}return Gt(i)}let Xe=4096;function Gt(r){let e=r.length;if(e<=Xe)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=Xe));return t}function Xt(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]&127);return i}function Zt(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]);return i}function Jt(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let c="";for(let l=e;l<t;++l)c+=an[r[l]];return c}function Qt(r,e,t){let i=r.slice(e,t),c="";for(let l=0;l<i.length-1;l+=2)c+=String.fromCharCode(i[l]+i[l+1]*256);return c}s.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function V(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||V(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||V(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||V(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||V(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=t,l=1,y=this[e+--c];for(;c>0&&(l*=256);)y+=this[e+--c]*l;return l*=128,y>=l&&(y-=Math.pow(2,8*t)),y},s.prototype.readInt8=function(e,t){return e=e>>>0,t||V(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||V(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||V(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||V(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||V(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||V(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||V(e,8,this.length),n.read(this,e,!1,52,8)};function z(r,e,t,i,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let S=Math.pow(2,8*i)-1;z(this,e,t,i,S,0)}let l=1,y=0;for(this[t]=e&255;++y<i&&(l*=256);)this[t+y]=e/l&255;return t+i},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let S=Math.pow(2,8*i)-1;z(this,e,t,i,S,0)}let l=i-1,y=1;for(this[t+l]=e&255;--l>=0&&(y*=256);)this[t+l]=e/y&255;return t+i},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ze(r,e,t,i,c){rt(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,t}function Je(r,e,t,i,c){rt(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=y,y=y>>8,r[t+2]=y,y=y>>8,r[t+1]=y,y=y>>8,r[t]=y,t+8}s.prototype.writeBigUInt64LE=Z(function(e,t=0){return Ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Z(function(e,t=0){return Je(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let R=Math.pow(2,8*i-1);z(this,e,t,i,R-1,-R)}let l=0,y=1,S=0;for(this[t]=e&255;++l<i&&(y*=256);)e<0&&S===0&&this[t+l-1]!==0&&(S=1),this[t+l]=(e/y>>0)-S&255;return t+i},s.prototype.writeIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let R=Math.pow(2,8*i-1);z(this,e,t,i,R-1,-R)}let l=i-1,y=1,S=0;for(this[t+l]=e&255;--l>=0&&(y*=256);)e<0&&S===0&&this[t+l+1]!==0&&(S=1),this[t+l]=(e/y>>0)-S&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=Z(function(e,t=0){return Ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Z(function(e,t=0){return Je(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Qe(r,e,t,i,c,l){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function et(r,e,t,i,c){return e=+e,t=t>>>0,c||Qe(r,e,t,4),n.write(r,e,t,i,23,4),t+4}s.prototype.writeFloatLE=function(e,t,i){return et(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return et(this,e,t,!1,i)};function tt(r,e,t,i,c){return e=+e,t=t>>>0,c||Qe(r,e,t,8),n.write(r,e,t,i,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,i){return tt(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return tt(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<i&&(c=i),c===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-i&&(c=e.length-t+i);let l=c-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,c):Uint8Array.prototype.set.call(e,this.subarray(i,c),t),l},s.prototype.fill=function(e,t,i,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,i=this.length):typeof i=="string"&&(c=i,i=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let y=e.charCodeAt(0);(c==="utf8"&&y<128||c==="latin1")&&(e=y)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<i;++l)this[l]=e;else{let y=s.isBuffer(e)?e:s.from(e,c),S=y.length;if(S===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<i-t;++l)this[l+t]=y[l%S]}return this};let oe={};function ke(r,e,t){oe[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ke("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ke("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),ke("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=nt(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=nt(c)),c+="n"),i+=` It must be ${e}. Received ${c}`,i},RangeError);function nt(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function en(r,e,t){ce(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function rt(r,e,t,i,c,l){if(r>t||r<e){let y=typeof e=="bigint"?"n":"",S;throw l>3?e===0||e===BigInt(0)?S=`>= 0${y} and < 2${y} ** ${(l+1)*8}${y}`:S=`>= -(2${y} ** ${(l+1)*8-1}${y}) and < 2 ** ${(l+1)*8-1}${y}`:S=`>= ${e}${y} and <= ${t}${y}`,new oe.ERR_OUT_OF_RANGE("value",S,r)}en(i,c,l)}function ce(r,e){if(typeof r!="number")throw new oe.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(ce(r,t),new oe.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new oe.ERR_BUFFER_OUT_OF_BOUNDS:new oe.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}let tn=/[^+/0-9A-Za-z-_]/g;function nn(r){if(r=r.split("=")[0],r=r.trim().replace(tn,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ue(r,e){e=e||1/0;let t,i=r.length,c=null,l=[];for(let y=0;y<i;++y){if(t=r.charCodeAt(y),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(y+1===i){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function rn(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function sn(r,e){let t,i,c,l=[];for(let y=0;y<r.length&&!((e-=2)<0);++y)t=r.charCodeAt(y),i=t>>8,c=t%256,l.push(c),l.push(i);return l}function it(r){return o.toByteArray(nn(r))}function be(r,e,t,i){let c;for(c=0;c<i&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function Y(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Pe(r){return r!==r}let an=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let c=0;c<16;++c)e[i+c]=r[t]+r[c]}return e}();function Z(r){return typeof BigInt>"u"?on:r}function on(){throw new Error("BigInt not supported")}return ne}var ye,ut,Ae,lt,ne,dt,re,O,Zn,Jn,Ne=pe(()=>{"use strict";E();v();T();ye={},ut=!1;Ae={},lt=!1;ne={},dt=!1;re=wn();re.Buffer;re.SlowBuffer;re.INSPECT_MAX_BYTES;re.kMaxLength;O=re.Buffer,Zn=re.INSPECT_MAX_BYTES,Jn=re.kMaxLength});var v=pe(()=>{"use strict";Ne()});var yt=at((sr,pt)=>{"use strict";E();v();T();function bn(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),a=0;a<n.length;a++)n[a]=255;for(var u=0;u<o.length;u++){var d=o.charAt(u),p=d.charCodeAt(0);if(n[p]!==255)throw new TypeError(d+" is ambiguous");n[p]=u}var s=o.length,f=o.charAt(0),w=Math.log(s)/Math.log(256),I=Math.log(256)/Math.log(s);function g(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var m=0,B=0,x=0,k=h.length;x!==k&&h[x]===0;)x++,m++;for(var C=(k-x)*I+1>>>0,U=new Uint8Array(C);x!==k;){for(var M=h[x],K=0,H=C-1;(M!==0||K<B)&&H!==-1;H--,K++)M+=256*U[H]>>>0,U[H]=M%s>>>0,M=M/s>>>0;if(M!==0)throw new Error("Non-zero carry");B=K,x++}for(var q=C-B;q!==C&&U[q]===0;)q++;for(var ae=f.repeat(m);q<C;++q)ae+=o.charAt(U[q]);return ae}function A(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;for(var m=0,B=0,x=0;h[m]===f;)B++,m++;for(var k=(h.length-m)*w+1>>>0,C=new Uint8Array(k);h[m];){var U=n[h.charCodeAt(m)];if(U===255)return;for(var M=0,K=k-1;(U!==0||M<x)&&K!==-1;K--,M++)U+=s*C[K]>>>0,C[K]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");x=M,m++}for(var H=k-x;H!==k&&C[H]===0;)H++;for(var q=new Uint8Array(B+(k-H)),ae=B;H!==k;)q[ae++]=C[H++];return q}function _(h){var m=A(h);if(m)return m;throw new Error("Non-base"+s+" character")}return{encode:g,decodeUnsafe:A,decode:_}}pt.exports=bn});var ft=at((ur,ht)=>{"use strict";E();v();T();var An=yt(),In="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ht.exports=An(In)});E();v();T();E();v();T();E();v();T();var fe=hn(ft());E();v();T();var $=2n**255n-19n,ue=2n**252n+27742317777372353535851937790883648493n,Oe=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Re=0x6666666666666666666666666666666666666666666666666666666666666658n,Ie={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:$,n:ue,h:8,Gx:Oe,Gy:Re},W=(o="")=>{throw new Error(o)},At=o=>typeof o=="string",ve=(o,n)=>!(o instanceof Uint8Array)||typeof n=="number"&&n>0&&o.length!==n?W("Uint8Array expected"):o,le=o=>new Uint8Array(o),Be=(o,n)=>ve(At(o)?Le(o):le(o),n),b=(o,n=$)=>{let a=o%n;return a>=0n?a:n+a},gt=o=>o instanceof J?o:W("Point expected"),mt,J=class o{constructor(n,a,u,d){this.ex=n,this.ey=a,this.ez=u,this.et=d}static fromAffine(n){return new o(n.x,n.y,1n,b(n.x*n.y))}static fromHex(n,a=!0){let{d:u}=Ie;n=Be(n,32);let d=n.slice();d[31]=n[31]&-129;let p=Tt(d);p===0n||(a&&!(0n<p&&p<$)&&W("bad y coord 1"),!a&&!(0n<p&&p<2n**256n)&&W("bad y coord 2"));let s=b(p*p),f=b(s-1n),w=b(u*s+1n),{isValid:I,value:g}=Tn(f,w);I||W("bad y coordinate 3");let A=(g&1n)===1n;return(n[31]&128)!==0!==A&&(g=b(-g)),new o(g,p,1n,b(g*p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(n){let{ex:a,ey:u,ez:d}=this,{ex:p,ey:s,ez:f}=gt(n),w=b(a*f),I=b(p*d),g=b(u*f),A=b(s*d);return w===I&&g===A}is0(){return this.equals(Ee)}negate(){return new o(b(-this.ex),this.ey,this.ez,b(-this.et))}double(){let{ex:n,ey:a,ez:u}=this,{a:d}=Ie,p=b(n*n),s=b(a*a),f=b(2n*b(u*u)),w=b(d*p),I=n+a,g=b(b(I*I)-p-s),A=w+s,_=A-f,h=w-s,m=b(g*_),B=b(A*h),x=b(g*h),k=b(_*A);return new o(m,B,k,x)}add(n){let{ex:a,ey:u,ez:d,et:p}=this,{ex:s,ey:f,ez:w,et:I}=gt(n),{a:g,d:A}=Ie,_=b(a*s),h=b(u*f),m=b(p*A*I),B=b(d*w),x=b((a+u)*(s+f)-_-h),k=b(B-m),C=b(B+m),U=b(h-g*_),M=b(x*k),K=b(C*U),H=b(x*U),q=b(k*C);return new o(M,K,q,H)}mul(n,a=!0){if(n===0n)return a===!0?W("cannot multiply by 0"):Ee;if(typeof n=="bigint"&&0n<n&&n<ue||W("invalid scalar, must be < L"),!a&&this.is0()||n===1n)return this;if(this.equals(se))return Cn(n).p;let u=Ee,d=se;for(let p=this;n>0n;p=p.double(),n>>=1n)n&1n?u=u.add(p):a&&(d=d.add(p));return u}multiply(n){return this.mul(n)}clearCofactor(){return this.mul(BigInt(Ie.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let n=this.mul(ue/2n,!1).double();return ue%2n&&(n=n.add(this)),n.is0()}toAffine(){let{ex:n,ey:a,ez:u}=this;if(this.is0())return{x:0n,y:0n};let d=vt(u);return b(u*d)!==1n&&W("invalid inverse"),{x:b(n*d),y:b(a*d)}}toRawBytes(){let{x:n,y:a}=this.toAffine(),u=Et(a);return u[31]|=n&1n?128:0,u}toHex(){return Fe(this.toRawBytes())}};J.BASE=new J(Oe,Re,1n,b(Oe*Re));J.ZERO=new J(0n,1n,1n,0n);var{BASE:se,ZERO:Ee}=J,It=(o,n)=>o.toString(16).padStart(n,"0"),Fe=o=>Array.from(o).map(n=>It(n,2)).join(""),Le=o=>{let n=o.length;(!At(o)||n%2)&&W("hex invalid 1");let a=le(n/2);for(let u=0;u<a.length;u++){let d=u*2,p=o.slice(d,d+2),s=Number.parseInt(p,16);(Number.isNaN(s)||s<0)&&W("hex invalid 2"),a[u]=s}return a},Et=o=>Le(It(o,32*2)).reverse(),Tt=o=>BigInt("0x"+Fe(le(ve(o)).reverse())),Te=(...o)=>{let n=le(o.reduce((u,d)=>u+ve(d).length,0)),a=0;return o.forEach(u=>{n.set(u,a),a+=u.length}),n},vt=(o,n=$)=>{(o===0n||n<=0n)&&W("no inverse n="+o+" mod="+n);let a=b(o,n),u=n,d=0n,p=1n,s=1n,f=0n;for(;a!==0n;){let w=u/a,I=u%a,g=d-s*w,A=p-f*w;u=a,a=I,d=s,p=f,s=g,f=A}return u===1n?b(d,n):W("no inverse")},G=(o,n)=>{let a=o;for(;n-- >0n;)a*=a,a%=$;return a},En=o=>{let a=o*o%$*o%$,u=G(a,2n)*a%$,d=G(u,1n)*o%$,p=G(d,5n)*d%$,s=G(p,10n)*p%$,f=G(s,20n)*s%$,w=G(f,40n)*f%$,I=G(w,80n)*w%$,g=G(I,80n)*w%$,A=G(g,10n)*p%$;return{pow_p_5_8:G(A,2n)*o%$,b2:a}},wt=19681161376707505956807079304988542015446066515923890162744021073123829784752n,Tn=(o,n)=>{let a=b(n*n*n),u=b(a*a*n),d=En(o*u).pow_p_5_8,p=b(o*a*d),s=b(n*p*p),f=p,w=b(p*wt),I=s===o,g=s===b(-o),A=s===b(-o*wt);return I&&(p=f),(g||A)&&(p=w),(b(p)&1n)===1n&&(p=b(-p)),{isValid:I||g,value:p}},De=o=>b(Tt(o),ue),he,Ve=(...o)=>He.sha512Async(...o),Bt=(...o)=>typeof he=="function"?he(...o):W("etc.sha512Sync not set"),xt=o=>{let n=o.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let a=o.slice(32,64),u=De(n),d=se.mul(u),p=d.toRawBytes();return{head:n,prefix:a,scalar:u,point:d,pointBytes:p}},$e=o=>Ve(Be(o,32)).then(xt),vn=o=>xt(Bt(Be(o,32))),St=o=>$e(o).then(n=>n.pointBytes);function Bn(o,n){return o?Ve(n.hashable).then(n.finish):n.finish(Bt(n.hashable))}var xn=(o,n,a)=>{let{pointBytes:u,scalar:d}=o,p=De(n),s=se.mul(p).toRawBytes();return{hashable:Te(s,u,a),finish:I=>{let g=b(p+De(I)*d,ue);return ve(Te(s,Et(g)),64)}}},Ct=async(o,n)=>{let a=Be(o),u=await $e(n),d=await Ve(u.prefix,a);return Bn(!0,xn(u,d,a))};var bt=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,He={bytesToHex:Fe,hexToBytes:Le,concatBytes:Te,mod:b,invert:vt,randomBytes:o=>{let n=bt();return n||W("crypto.getRandomValues must be defined"),n.getRandomValues(le(o))},sha512Async:async(...o)=>{let n=bt();n||W("crypto.subtle or etc.sha512Async must be defined");let a=Te(...o);return le(await n.subtle.digest("SHA-512",a.buffer))},sha512Sync:void 0};Object.defineProperties(He,{sha512Sync:{configurable:!1,get(){return he},set(o){he||(he=o)}}});var _t={getExtendedPublicKeyAsync:$e,getExtendedPublicKey:vn,randomPrivateKey:()=>He.randomBytes(32),precompute(o=8,n=se){return n.multiply(3n),n}},ie=8,Sn=()=>{let o=[],n=256/ie+1,a=se,u=a;for(let d=0;d<n;d++){u=a,o.push(u);for(let p=1;p<2**(ie-1);p++)u=u.add(a),o.push(u);a=u.double()}return o},Cn=o=>{let n=mt||(mt=Sn()),a=(g,A)=>{let _=A.negate();return g?_:A},u=Ee,d=se,p=1+256/ie,s=2**(ie-1),f=BigInt(2**ie-1),w=2**ie,I=BigInt(ie);for(let g=0;g<p;g++){let A=g*s,_=Number(o&f);o>>=I,_>s&&(_-=w,o+=1n);let h=A,m=A+Math.abs(_)-1,B=g%2!==0,x=_<0;_===0?d=d.add(a(B,n[h])):u=u.add(a(x,n[m]))}return{p:u,f:d}};var Q=class o{static generateKey(){let n,a;do n=_t.randomPrivateKey(),a=(0,fe.encode)(n);while(a.length!==44);return new o(a)}constructor(n){this.secretKey=n;let a=(0,fe.decode)(n);this.privateKey=O.from(a).toString("hex")}async sign(n){return await Ct(n,this.privateKey)}async getPublicKey(){let n=await St(this.privateKey);return`ed25519:${(0,fe.encode)(n)}`}toString(){return this.privateKey}};var xe=class{constructor(n="testnet"){this.networkId=n}get keyPrefix(){return`orderly_${this.networkId}_`}},ge=class extends xe{getOrderlyKey(n){let a;if(n)a=this.getItem(n,"orderlyKey");else{let u=this.getAddress();if(!u)return null;a=this.getItem(u,"orderlyKey")}return a?new Q(a):null}getAccountId(n){return this.getItem(n,"accountId")}setAccountId(n,a){this.setItem(n,{accountId:a})}getAddress(){return localStorage.getItem(`${this.keyPrefix}address`)}setAddress(n){localStorage.setItem(`${this.keyPrefix}address`,n)}generateKey(){return Q.generateKey()}setKey(n,a){this.setItem(n,{orderlyKey:a.secretKey})}cleanAllKey(n){localStorage.removeItem(`${this.keyPrefix}${n}`),localStorage.removeItem(`${this.keyPrefix}address`)}cleanKey(n,a){let u=this.getItem(n);delete u[a],localStorage.setItem(`${this.keyPrefix}${n}`,JSON.stringify(u))}setItem(n,a){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);d?d=JSON.parse(d):d={},localStorage.setItem(u,JSON.stringify({...d,...a}))}getItem(n,a){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);return d?d=JSON.parse(d):d={},typeof a>"u"?d:d[a]}},me=class{constructor(n){this.secretKey=n}generateKey(){return new Q(this.secretKey)}getOrderlyKey(){return new Q(this.secretKey)}getAccountId(){return""}setAccountId(n){}getAddress(){return""}setAddress(n){}setKey(n,a){}cleanAllKey(){}cleanKey(n){}};E();v();T();E();v();T();E();v();T();var X={EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Registration:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"timestamp",type:"uint64"},{name:"registrationNonce",type:"uint256"}],Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}],AddOrderlyKey:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"orderlyKey",type:"string"},{name:"scope",type:"string"},{name:"timestamp",type:"uint64"},{name:"expiration",type:"uint64"}],SettlePnl:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"settleNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},kt="0x6aAd876244E7A1Ad44Ec4824Ce813729E5B6C291",Ut="0xd64AeB281f3E8cd70e668b6cb24De7e532dC214D",Pt="0x1826B75e2ef249173FC735149AE4B8e9ea10abff";import{keccak256 as kn,AbiCoder as Un,solidityPackedKeccak256 as Pn}from"ethers";var Mt=function(o){return o.replace(/\+/g,"-").replace(/\//g,"_")};function Mn(){return"0x8794E7260517B1766fc7b55cAfcd56e6bf08600e"}function Kt(o,n){return{name:"Orderly",version:"1",chainId:o,verifyingContract:n?Mn():"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}function Nt(o){let{chainId:n,registrationNonce:a,brokerId:u}=o,d=Date.now(),p="Registration",s={brokerId:u,chainId:n,timestamp:d,registrationNonce:a},f={EIP712Domain:X.EIP712Domain,[p]:X[p]};return[s,{domain:Kt(n),message:s,primaryType:p,types:f}]}function Ot(o){let{publicKey:n,chainId:a,primaryType:u,brokerId:d,expiration:p=365}=o,s=Date.now(),f={brokerId:d,orderlyKey:n,scope:"read,trading",chainId:a,timestamp:s,expiration:s+1e3*60*60*24*p},w={EIP712Domain:X.EIP712Domain,[u]:X[u]},I={domain:Kt(a),message:f,primaryType:u,types:w};return[f,I]}function Rt(o){let{chainId:n,settlePnlNonce:a,domain:u,brokerId:d}=o,p="SettlePnl",s=new Date().getTime(),f={EIP712Domain:X.EIP712Domain,[p]:X[p]},w={brokerId:d,chainId:n,timestamp:s,settleNonce:a};return[w,{domain:u,message:w,primaryType:p,types:f}]}function We(o){return Lt(o)}function Dt(o,n){let a=Un.defaultAbiCoder();return kn(a.encode(["address","bytes32"],[o,We(n)]))}function Ft(o){return Lt(o)}function Lt(o){return Pn(["string"],[o])}Ne();var ee=class{constructor(n){this.keyStore=n}async sign(n){let a=Date.now().toString(),u=[a,n.method.toUpperCase(),n.url].join("");n.data&&Object.keys(n.data).length&&(u+=JSON.stringify(n.data));let{signature:d,publicKey:p}=await this.signText(u);return{"orderly-key":p,"orderly-timestamp":a,"orderly-signature":d}}async signText(n){let a=this.keyStore.getOrderlyKey();if(!a)throw new Error("orderlyKeyPair is not defined");let u=O.from(n),d=await a.sign(u),p=O.from(d).toString("base64");return{signature:Mt(p),publicKey:await a.getPublicKey()}}};import{default as ns}from"eventemitter3";E();v();T();E();v();T();var Se=class{constructor(){this._restore()}_restore(){this.map=new Map([["apiBaseUrl","https://qa-api-evm.orderly.org"],["klineDataUrl","https://testnet-api-evm.orderly.org"],["publicWsUrl","wss://dev-ws-v2.orderly.org"],["publicWebsocketKey","OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY"],["privateWsUrl","wss://dev-ws-private-v2.orderly.org"],["operatorUrl","https://testnet-operator-evm.orderly.org"],["brokerId","woofi_dex"],["env","dev-evm"]])}get(n){return this.map.get(n)}set(n,a){this.map.set(n,a)}clear(){}},Vt=class extends Se{constructor(a){super();this.configMap=a}_restore(){let a=Object.entries(this.configMap);this.map=new Map(a)}};var Kn=o=>{let n=new me(o||"AFmQSju4FhDwG93cMdKogcnKx7SWmViDtDv5PVzfvRDF");return new ee(n)},Nn=()=>{if(typeof window>"u")throw new Error("the default signer only supports browsers.");let o=new ge("");return new ee(o)};E();v();T();var $t=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"},{internalType:"uint8",name:"decimals_",type:"uint8"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"issue",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_to",type:"address"},{internalType:"uint256",name:"_amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_paused",type:"bool"}],name:"pauseTransfers",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}];var Ht=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccountIdInvalid",type:"error"},{inputs:[{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"}],name:"BalanceNotEnough",type:"error"},{inputs:[],name:"BrokerNotAllowed",type:"error"},{inputs:[],name:"OnlyCrossChainManagerCanCall",type:"error"},{inputs:[],name:"TokenNotAllowed",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"address",name:"userAddress",type:"address"},{indexed:!0,internalType:"uint64",name:"depositNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"}],name:"AccountDeposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"address",name:"userAddress",type:"address"},{indexed:!0,internalType:"uint64",name:"depositNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"}],name:"AccountDepositTo",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"uint64",name:"withdrawNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"brokerHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"address",name:"receiver",type:"address"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fee",type:"uint128"},{indexed:!1,internalType:"uint256",name:"blocktime",type:"uint256"}],name:"AccountWithdraw",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"_tokenAddress",type:"address"}],name:"ChangeTokenAddressAndAllow",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_brokerHash",type:"bytes32"},{indexed:!1,internalType:"bool",name:"_allowed",type:"bool"}],name:"SetAllowedBroker",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{indexed:!1,internalType:"bool",name:"_allowed",type:"bool"}],name:"SetAllowedToken",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"allowedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{internalType:"address",name:"_tokenAddress",type:"address"}],name:"changeTokenAddressAndAllow",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"crossChainManagerAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"}],internalType:"struct VaultTypes.VaultDepositFE",name:"data",type:"tuple"}],name:"deposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"depositId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"receiver",type:"address"},{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"}],internalType:"struct VaultTypes.VaultDepositFE",name:"data",type:"tuple"}],name:"depositTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"emergencyPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"emergencyUnpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"getAllAllowedBroker",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAllAllowedToken",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_brokerHash",type:"bytes32"}],name:"getAllowedBroker",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"}],name:"getAllowedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"_brokerHash",type:"bytes32"},{internalType:"bool",name:"_allowed",type:"bool"}],name:"setAllowedBroker",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{internalType:"bool",name:"_allowed",type:"bool"}],name:"setAllowedToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_crossChainManagerAddress",type:"address"}],name:"setCrossChainManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"},{internalType:"uint128",name:"fee",type:"uint128"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint64",name:"withdrawNonce",type:"uint64"}],internalType:"struct VaultTypes.VaultWithdraw",name:"data",type:"tuple"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}];var je=class{constructor(n){this.configStore=n}getContractInfoByEnv(){return{usdcAddress:kt,usdcAbi:$t,vaultAddress:Ut,vaultAbi:Ht,verifyContractAddress:Pt}}};E();v();T();E();v();T();var ze=class{constructor(n=[],a={}){this.providers=n;this.services=a;this.injectProperties={}}register(...n){this.providers.push(...n),n.forEach(a=>{let u=a;u instanceof Function&&(u=new a),this.add(u)})}registerByName(n,a){let u=a;u instanceof Function&&(u=new a),this.addByName(n,u)}get(n){return this.services[n]}getAll(){return Object.assign({},this.services)}add(n){return this.addByName(n.constructor.name,n)}addByName(n,a){return this.services[n]=a,this.services[n.toLowerCase()]=a,this.injectIntoProperties(a,n),this.get(n)}inject(n,a,u){n&&u&&(n[a]=u)}injectIntoProperties(n,a=n.constructor.name){this.getInjectProperty(a.toLowerCase()).forEach(u=>{this.inject(u.target,u.propertyKey,n)})}getInjectProperty(n){return this.injectProperties[n]||(this.injectProperties[n]=[]),this.injectProperties[n]}},Wt=ze;var qe=class o{static getContainer(){return o.container||(o.container=new Wt),o.container}static register(...n){this.getContainer().register(...n)}static registerByName(n,a){this.getContainer().registerByName(n,a)}static get(n){return this.getContainer().get(n)}static getAll(){return this.getContainer().getAll()}constructor(){}},Dn=qe;E();v();T();import{AccountStatusEnum as j}from"@orderly.network/types";import Ln from"eventemitter3";E();v();T();import{ethers as Fn}from"ethers";var Ce=class{constructor(n,a,u){this.configStore=n;this.contractManger=a;this.account=u}async withdraw(n){if(!this.account.walletClient)throw new Error("walletClient is undefined");if(!this.account.stateValue.address)throw new Error("account address is rqeuired");let{chainId:a,token:u,amount:d}=n,p="/v1/withdraw_request",s=await this.getWithdrawalNonce(),f=this.account.getDomain(!0),[w,I]=this._generateWithdrawMessage({chainId:a,receiver:this.account.stateValue.address,token:u,amount:this.account.walletClient.parseUnits(d.toString()),nonce:s,domain:f}),A={signature:await this.account.signTypedData(I),message:w,userAddress:this.account.stateValue.address,verifyingContract:f.verifyingContract},_={method:"POST",url:p,data:A},h=await this.account.signer.sign(_);return await this._simpleFetch(p,{method:"POST",body:JSON.stringify(A),headers:{"Content-Type":"application/json","orderly-account-id":this.account.stateValue.accountId,...h}})}_generateWithdrawMessage(n){let{chainId:a,receiver:u,token:d,amount:p,domain:s,nonce:f}=n,w="Withdraw",I=Date.now(),g={EIP712Domain:X.EIP712Domain,[w]:X[w]},A={brokerId:this.configStore.get("brokerId"),chainId:a,receiver:u,token:d,amount:p,timestamp:I,withdrawNonce:f};return[A,{domain:s,message:A,primaryType:w,types:g}]}async getWithdrawalNonce(){let n=Date.now().toString(),a="/v1/withdraw_nonce",u=[n,"GET",a].join(""),d=this.account.signer,{publicKey:p,signature:s}=await d.signText(u),f=await this._simpleFetch(a,{headers:{"orderly-account-id":this.account.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":s}});if(f.success)return f.data?.withdraw_nonce;throw new Error(f.message)}async getBalance(){if(!this.account.walletClient)return"0";let n=this.contractManger.getContractInfoByEnv(),a=await this.account.walletClient?.call(n.usdcAddress,"balanceOf",[this.account.stateValue.address],{abi:n.usdcAbi});return this.account.walletClient?.fromUnits(a)}async getAllowance(){if(!this.account.walletClient)return"0";let n=this.contractManger.getContractInfoByEnv(),a=await this.account.walletClient?.call(n.usdcAddress,"allowance",[this.account.stateValue.address,n.vaultAddress],{abi:n.usdcAbi});return this.account.walletClient?.fromUnits(a)}async approve(n){if(!this.account.walletClient)throw new Error("walletClient is undefined");let a=this.contractManger.getContractInfoByEnv(),u=typeof n<"u"&&n!==""?this.account.walletClient.parseUnits(n):Fn.MaxUint256.toString(),d=await this.account.walletClient?.call(a.usdcAddress,"approve",[a.vaultAddress,u],{abi:a.usdcAbi});return console.log("-----*****-----",d),d}async deposit(n){console.log("deposit amount:",n);let a=this.configStore.get("brokerId");if(!a)throw new Error("brokerId is required");let u=this.contractManger.getContractInfoByEnv(),d={accountId:Dt(this.account.stateValue.address,a),brokerHash:We(a),tokenHash:Ft("USDC"),tokenAmount:this.account.walletClient?.parseUnits(n)};return await this.account.walletClient?.call(u.vaultAddress,"deposit",[d],{abi:u.vaultAbi})}async _simpleFetch(n,a={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,a).then(d=>d.json())}};var _e=class{constructor(n,a,u,d){this.configStore=n;this.keyStore=a;this.contractManger=u;this.getWalletAdapter=d;this._ee=new Ln;this._state={status:j.NotConnected,balance:"",checking:!1,leverage:Number.NaN};this.assetsManager=new Ce(n,u,this),this._bindEvents()}login(n){if(!n)throw new Error("address is required")}logout(){}async setAddress(n,a){if(!n)throw new Error("address is required");this.keyStore.setAddress(n);let u={...this.stateValue,status:j.Connected,address:n,connectWallet:a?.wallet};return this._ee.emit("change:status",u),a&&(this.walletClient=this.getWalletAdapter({...a,address:n})),await this._checkAccount(n)}get stateValue(){return this._state}get accountId(){return this.stateValue.accountId}get address(){return this.stateValue.address}get chainId(){return this.walletClient?.chainId}set position(n){let a={...this.stateValue,positon:n};this._ee.emit("change:status",a)}set orders(n){let a={...this.stateValue,orders:n};this._ee.emit("change:status",a)}_bindEvents(){this._ee.addListener("change:status",n=>{console.log("change:status",n),this._state=n})}async _checkAccount(n){console.log("check account is esist",n);let a;try{let u=await this._checkAccountExist(n);if(console.log("accountInfo:",u),u&&u.account_id)console.log("account is exist"),this.keyStore.setAccountId(n,u.account_id),a={...this.stateValue,status:j.SignedIn,accountId:u.account_id,userId:u.user_id},this._ee.emit("change:status",a);else return a={...this.stateValue,status:j.NotSignedIn},this._ee.emit("change:status",a),j.NotSignedIn;let d=this.keyStore.getOrderlyKey();if(console.log("orderlyKey:::::::",d),a={...this.stateValue,status:j.DisabledTrading},!d)return console.log("orderlyKey is null"),this._ee.emit("change:status",a),j.DisabledTrading;let p=await d.getPublicKey(),s=await this._checkOrderlyKeyState(u.account_id,p);if(console.log("orderlyKeyStatus:",s),s&&s.orderly_key&&s.key_status==="ACTIVE"){let f=Date.now(),w=s.expiration;if(f>w)return this.keyStore.cleanKey(n,"orderlyKey"),j.DisabledTrading;let I={...this.stateValue,status:j.EnableTrading};return this._ee.emit("change:status",I),j.EnableTrading}return this.keyStore.cleanKey(n,"orderlyKey"),j.NotConnected}catch(u){console.log("\u68C0\u67E5\u8D26\u6237\u72B6\u6001\u9519\u8BEF:",u)}return j.NotSignedIn}async _checkAccountExist(n){let a=await this._simpleFetch(`/v1/get_account?address=${n}&broker_id=woofi_dex`);return a.success?a.data:null}async createAccount(){if(!this.walletClient)return Promise.reject("walletClient is undefined");let n=await this._getRegisterationNonce(),a=this.stateValue.address;if(!a)throw new Error("address is undefined");let[u,d]=Nt({registrationNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId")}),p=await this.signTypedData(d),s=await this._simpleFetch("/v1/register_account",{method:"POST",body:JSON.stringify({signature:p,message:u,userAddress:a}),headers:{"Content-Type":"application/json"}});if(s.success){this.keyStore.setAccountId(a,s.data.account_id);let f={...this.stateValue,status:j.DisabledTrading,accountId:s.data.account_id,userId:s.data.user_id};return this._ee.emit("change:status",f),s}}async signTypedData(n){return this.walletClient?await this.walletClient.signTypedData(this.stateValue.address,JSON.stringify(n)):Promise.reject("walletClient is undefined")}async createOrderlyKey(n){if(this.stateValue.accountId===void 0)throw new Error("account id is undefined");if(!this.walletClient)throw new Error("walletClient is undefined");let a="AddOrderlyKey",u=this.keyStore.generateKey(),d=await u.getPublicKey(),[p,s]=Ot({publicKey:d,chainId:this.walletClient.chainId,primaryType:a,expiration:n,brokerId:this.configStore.get("brokerId")}),f=this.stateValue.address;if(!f)throw new Error("address is undefined");let w=await this.signTypedData(s),I=await this._simpleFetch("/v1/orderly_key",{method:"POST",body:JSON.stringify({signature:w,message:p,userAddress:f}),headers:{"X-Account-Id":this.stateValue.accountId,"Content-Type":"application/json"}});if(I.success){this.keyStore.setKey(f,u);let g={...this.stateValue,status:j.EnableTrading};return this._ee.emit("change:status",g),I}else throw new Error(I.message)}async settle(){if(!this.walletClient)return Promise.reject("walletClient is undefined");let n=await this._getSettleNonce(),a=this.stateValue.address,u=this.getDomain(!0),d="/v1/settle_pnl",[p,s]=Rt({settlePnlNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId"),domain:u}),w={signature:await this.signTypedData(s),message:p,userAddress:a,verifyingContract:u.verifyingContract},I={method:"POST",url:d,data:w},g=await this.signer.sign(I),A=await this._simpleFetch(d,{method:"POST",body:JSON.stringify(w),headers:{"Content-Type":"application/json","orderly-account-id":this.stateValue.accountId,...g}});if(A.success)return A;throw new Error(A.message)}async disconnect(){let n={...this.stateValue,status:j.NotConnected,accountId:void 0,userId:void 0,address:void 0};this._ee.emit("change:status",n)}async _checkOrderlyKeyState(n,a){let u=await this._simpleFetch(`/v1/get_orderly_key?account_id=${n}&orderly_key=${a}`);if(u.success)return u.data;throw new Error(u.message)}get signer(){return this._singer||(this._singer=new ee(this.keyStore)),this._singer}get wallet(){return this.walletClient}async _getRegisterationNonce(){let n=await this._simpleFetch("/v1/registration_nonce",{headers:{"orderly-account-id":this.stateValue.accountId}});if(console.log("getRegisterationNonce:",n),n.success)return n.data?.registration_nonce;throw new Error(n.message)}async _getSettleNonce(){let n=Date.now().toString(),u=[n,"GET","/v1/settle_nonce"].join(""),d=this.signer,{publicKey:p,signature:s}=await d.signText(u),f=await this._simpleFetch("/v1/settle_nonce",{headers:{"orderly-account-id":this.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":s}});if(f.success)return f.data?.settle_nonce;throw new Error(f.message)}async _simpleFetch(n,a={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,a).then(d=>d.json())}getDomain(n){if(!this.walletClient)throw new Error("walletClient is undefined");return{name:"Orderly",version:"1",chainId:this.walletClient.chainId,verifyingContract:n?this.contractManger.getContractInfoByEnv().verifyContractAddress:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}get on(){return this._ee.on.bind(this._ee)}get once(){return this._ee.once.bind(this._ee)}get off(){return this._ee.off.bind(this._ee)}};_e.instanceName="account";E();v();T();E();v();T();import{BrowserProvider as Vn,ethers as we}from"ethers";import{getParsedEthersError as $n}from"@enzoferey/ethers-error-parser";var Ye=class{constructor(n){console.log("EtherAdapter constructor",n),this._chainId=parseInt(n.chain.id,16),this.provider=new Vn(n.provider,"any"),this._address=n.address}parseUnits(n){return we.parseUnits(n,6).toString()}fromUnits(n){return we.formatUnits(n,6)}getBalance(n,a,u){return new we.Contract(n,u.abi,this.provider).balanceOf(a)}deposit(n,a,u){throw new Error("Method not implemented.")}async call(n,a,u,d){let p=await this.provider?.getSigner();return new we.Contract(n,d.abi,p)[a].apply(null,u).catch(f=>{throw $n(f)})}get chainId(){return this._chainId}get addresses(){return this._address}async send(n,a){return await this.provider?.send(n,a)}async signTypedData(n,a){return await this.provider?.send("eth_signTypedData_v4",[n,a])}async verify(n,a){let{domain:u,types:d,message:p}=n,s=we.verifyTypedData(u,d,p,a);console.log("recovered",s)}};export{_e as Account,Vt as BaseConfigStore,je as BaseContractManager,xe as BaseKeyStore,Q as BaseOrderlyKeyPair,ee as BaseSigner,Ye as EtherAdapter,ns as EventEmitter,ge as LocalStorageStore,Se as MemoryConfigStore,me as MockKeyStore,Dn as SimpleDI,Nn as getDefaultSigner,Kn as getMockSigner};
1
+ var cn=Object.create;var at=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var ln=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,pn=Object.prototype.hasOwnProperty;var pe=(o,n)=>()=>(o&&(n=o(o=0)),n);var ot=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var yn=(o,n,a,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of ln(n))!pn.call(o,d)&&d!==a&&at(o,d,{get:()=>n[d],enumerable:!(u=un(n,d))||u.enumerable});return o};var hn=(o,n,a)=>(a=o!=null?cn(dn(o)):{},yn(n||!o||!o.__esModule?at(a,"default",{value:o,enumerable:!0}):a,o));var E=pe(()=>{"use strict"});function gn(o,n){this.fun=o,this.array=n}function ct(o){var n=Math.floor((Date.now()-te.now())*.001),a=te.now()*.001,u=Math.floor(a)+n,d=Math.floor(a%1*1e9);return o&&(u=u-o[0],d=d-o[1],d<0&&(u--,d+=Ke)),[u,d]}var jn,te,Me,Ke,ut=pe(()=>{"use strict";E();T();v();gn.prototype.run=function(){this.fun.apply(null,this.array)};jn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},te={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};te.now===void 0&&(Me=Date.now(),te.timing&&te.timing.navigationStart&&(Me=te.timing.navigationStart),te.now=()=>Date.now()-Me);Ke=1e9;ct.bigint=function(o){var n=ct(o);return typeof BigInt>"u"?n[0]*Ke+n[1]:BigInt(n[0]*Ke)+BigInt(n[1])}});var v=pe(()=>{"use strict";ut()});function fn(){if(lt)return ye;lt=!0,ye.byteLength=g,ye.toByteArray=I,ye.fromByteArray=_;for(var o=[],n=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=u.length;d<p;++d)o[d]=u[d],n[u.charCodeAt(d)]=d;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;function s(h){var m=h.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=h.indexOf("=");B===-1&&(B=m);var x=B===m?0:4-B%4;return[B,x]}function g(h){var m=s(h),B=m[0],x=m[1];return(B+x)*3/4-x}function w(h,m,B){return(m+B)*3/4-B}function I(h){var m,B=s(h),x=B[0],k=B[1],C=new a(w(h,x,k)),U=0,M=k>0?x-4:x,K;for(K=0;K<M;K+=4)m=n[h.charCodeAt(K)]<<18|n[h.charCodeAt(K+1)]<<12|n[h.charCodeAt(K+2)]<<6|n[h.charCodeAt(K+3)],C[U++]=m>>16&255,C[U++]=m>>8&255,C[U++]=m&255;return k===2&&(m=n[h.charCodeAt(K)]<<2|n[h.charCodeAt(K+1)]>>4,C[U++]=m&255),k===1&&(m=n[h.charCodeAt(K)]<<10|n[h.charCodeAt(K+1)]<<4|n[h.charCodeAt(K+2)]>>2,C[U++]=m>>8&255,C[U++]=m&255),C}function f(h){return o[h>>18&63]+o[h>>12&63]+o[h>>6&63]+o[h&63]}function A(h,m,B){for(var x,k=[],C=m;C<B;C+=3)x=(h[C]<<16&16711680)+(h[C+1]<<8&65280)+(h[C+2]&255),k.push(f(x));return k.join("")}function _(h){for(var m,B=h.length,x=B%3,k=[],C=16383,U=0,M=B-x;U<M;U+=C)k.push(A(h,U,U+C>M?M:U+C));return x===1?(m=h[B-1],k.push(o[m>>2]+o[m<<4&63]+"==")):x===2&&(m=(h[B-2]<<8)+h[B-1],k.push(o[m>>10]+o[m>>4&63]+o[m<<2&63]+"=")),k.join("")}return ye}function mn(){if(dt)return be;dt=!0;return be.read=function(o,n,a,u,d){var p,s,g=d*8-u-1,w=(1<<g)-1,I=w>>1,f=-7,A=a?d-1:0,_=a?-1:1,h=o[n+A];for(A+=_,p=h&(1<<-f)-1,h>>=-f,f+=g;f>0;p=p*256+o[n+A],A+=_,f-=8);for(s=p&(1<<-f)-1,p>>=-f,f+=u;f>0;s=s*256+o[n+A],A+=_,f-=8);if(p===0)p=1-I;else{if(p===w)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,u),p=p-I}return(h?-1:1)*s*Math.pow(2,p-u)},be.write=function(o,n,a,u,d,p){var s,g,w,I=p*8-d-1,f=(1<<I)-1,A=f>>1,_=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=u?0:p-1,m=u?1:-1,B=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(g=isNaN(n)?1:0,s=f):(s=Math.floor(Math.log(n)/Math.LN2),n*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+A>=1?n+=_/w:n+=_*Math.pow(2,1-A),n*w>=2&&(s++,w/=2),s+A>=f?(g=0,s=f):s+A>=1?(g=(n*w-1)*Math.pow(2,d),s=s+A):(g=n*Math.pow(2,A-1)*Math.pow(2,d),s=0));d>=8;o[a+h]=g&255,h+=m,g/=256,d-=8);for(s=s<<d|g,I+=d;I>0;o[a+h]=s&255,h+=m,s/=256,I-=8);o[a+h-m]|=B*128},be}function wn(){if(pt)return ne;pt=!0;let o=fn(),n=mn(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ne.Buffer=s,ne.SlowBuffer=k,ne.INSPECT_MAX_BYTES=50;let u=2147483647;ne.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=d(),!s.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 d(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function p(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return f(r)}return g(r,e,t)}s.poolSize=8192;function g(r,e,t){if(typeof r=="string")return A(r,e);if(ArrayBuffer.isView(r))return h(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(Y(r,ArrayBuffer)||r&&Y(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Y(r,SharedArrayBuffer)||r&&Y(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return s.from(i,e,t);let c=B(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return g(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function I(r,e,t){return w(r),r<=0?p(r):e!==void 0?typeof t=="string"?p(r).fill(e,t):p(r).fill(e):p(r)}s.alloc=function(r,e,t){return I(r,e,t)};function f(r){return w(r),p(r<0?0:x(r)|0)}s.allocUnsafe=function(r){return f(r)},s.allocUnsafeSlow=function(r){return f(r)};function A(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=C(r,e)|0,i=p(t),c=i.write(r,e);return c!==t&&(i=i.slice(0,c)),i}function _(r){let e=r.length<0?0:x(r.length)|0,t=p(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function h(r){if(Y(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return _(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,s.prototype),i}function B(r){if(s.isBuffer(r)){let e=x(r.length)|0,t=p(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Pe(r.length)?p(0):_(r);if(r.type==="Buffer"&&Array.isArray(r.data))return _(r.data)}function x(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function k(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,c=t.length;for(let l=0,y=Math.min(i,c);l<y;++l)if(e[l]!==t[l]){i=e[l],c=t[l];break}return i<c?-1:c<i?1:0},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let c=s.allocUnsafe(t),l=0;for(i=0;i<e.length;++i){let y=e[i];if(Y(y,Uint8Array))l+y.length>c.length?(s.isBuffer(y)||(y=s.from(y)),y.copy(c,l)):Uint8Array.prototype.set.call(c,y,l);else if(s.isBuffer(y))y.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=y.length}return c};function C(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Y(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ue(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return st(r).length;default:if(c)return i?-1:Ue(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=C;function U(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Jt(this,e,t);case"utf8":case"utf-8":return Xe(this,e,t);case"ascii":return Xt(this,e,t);case"latin1":case"binary":return Zt(this,e,t);case"base64":return Yt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qt(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}s.prototype._isBuffer=!0;function M(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)M(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Xe(this,0,e):U.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=ne.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,i,c,l){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||i>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=i)return 0;if(c>=l)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,c>>>=0,l>>>=0,this===e)return 0;let y=l-c,S=i-t,R=Math.min(y,S),N=this.slice(c,l),D=e.slice(t,i);for(let P=0;P<R;++P)if(N[P]!==D[P]){y=N[P],S=D[P];break}return y<S?-1:S<y?1:0};function K(r,e,t,i,c){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Pe(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,i)),s.isBuffer(e))return e.length===0?-1:H(r,e,t,i,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):H(r,[e],t,i,c);throw new TypeError("val must be string, number or Buffer")}function H(r,e,t,i,c){let l=1,y=r.length,S=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,y/=2,S/=2,t/=2}function R(D,P){return l===1?D[P]:D.readUInt16BE(P*l)}let N;if(c){let D=-1;for(N=t;N<y;N++)if(R(r,N)===R(e,D===-1?0:N-D)){if(D===-1&&(D=N),N-D+1===S)return D*l}else D!==-1&&(N-=N-D),D=-1}else for(t+S>y&&(t=y-S),N=t;N>=0;N--){let D=!0;for(let P=0;P<S;P++)if(R(r,N+P)!==R(e,P)){D=!1;break}if(D)return N}return-1}s.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},s.prototype.indexOf=function(e,t,i){return K(this,e,t,i,!0)},s.prototype.lastIndexOf=function(e,t,i){return K(this,e,t,i,!1)};function q(r,e,t,i){t=Number(t)||0;let c=r.length-t;i?(i=Number(i),i>c&&(i=c)):i=c;let l=e.length;i>l/2&&(i=l/2);let y;for(y=0;y<i;++y){let S=parseInt(e.substr(y*2,2),16);if(Pe(S))return y;r[t+y]=S}return y}function ae(r,e,t,i){return we(Ue(e,r.length-t),r,t,i)}function jt(r,e,t,i){return we(rn(e),r,t,i)}function zt(r,e,t,i){return we(st(e),r,t,i)}function qt(r,e,t,i){return we(sn(e,r.length-t),r,t,i)}s.prototype.write=function(e,t,i,c){if(t===void 0)c="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")c=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,c===void 0&&(c="utf8")):(c=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((i===void 0||i>l)&&(i=l),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let y=!1;for(;;)switch(c){case"hex":return q(this,e,t,i);case"utf8":case"utf-8":return ae(this,e,t,i);case"ascii":case"latin1":case"binary":return jt(this,e,t,i);case"base64":return zt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qt(this,e,t,i);default:if(y)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),y=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yt(r,e,t){return e===0&&t===r.length?o.fromByteArray(r):o.fromByteArray(r.slice(e,t))}function Xe(r,e,t){t=Math.min(r.length,t);let i=[],c=e;for(;c<t;){let l=r[c],y=null,S=l>239?4:l>223?3:l>191?2:1;if(c+S<=t){let R,N,D,P;switch(S){case 1:l<128&&(y=l);break;case 2:R=r[c+1],(R&192)===128&&(P=(l&31)<<6|R&63,P>127&&(y=P));break;case 3:R=r[c+1],N=r[c+2],(R&192)===128&&(N&192)===128&&(P=(l&15)<<12|(R&63)<<6|N&63,P>2047&&(P<55296||P>57343)&&(y=P));break;case 4:R=r[c+1],N=r[c+2],D=r[c+3],(R&192)===128&&(N&192)===128&&(D&192)===128&&(P=(l&15)<<18|(R&63)<<12|(N&63)<<6|D&63,P>65535&&P<1114112&&(y=P))}}y===null?(y=65533,S=1):y>65535&&(y-=65536,i.push(y>>>10&1023|55296),y=56320|y&1023),i.push(y),c+=S}return Gt(i)}let Ze=4096;function Gt(r){let e=r.length;if(e<=Ze)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=Ze));return t}function Xt(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]&127);return i}function Zt(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]);return i}function Jt(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let c="";for(let l=e;l<t;++l)c+=an[r[l]];return c}function Qt(r,e,t){let i=r.slice(e,t),c="";for(let l=0;l<i.length-1;l+=2)c+=String.fromCharCode(i[l]+i[l+1]*256);return c}s.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function V(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||V(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||V(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||V(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||V(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||V(e,t,this.length);let c=t,l=1,y=this[e+--c];for(;c>0&&(l*=256);)y+=this[e+--c]*l;return l*=128,y>=l&&(y-=Math.pow(2,8*t)),y},s.prototype.readInt8=function(e,t){return e=e>>>0,t||V(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||V(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||V(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||V(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=Z(function(e){e=e>>>0,ce(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||V(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||V(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||V(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||V(e,8,this.length),n.read(this,e,!1,52,8)};function z(r,e,t,i,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let S=Math.pow(2,8*i)-1;z(this,e,t,i,S,0)}let l=1,y=0;for(this[t]=e&255;++y<i&&(l*=256);)this[t+y]=e/l&255;return t+i},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let S=Math.pow(2,8*i)-1;z(this,e,t,i,S,0)}let l=i-1,y=1;for(this[t+l]=e&255;--l>=0&&(y*=256);)this[t+l]=e/y&255;return t+i},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Je(r,e,t,i,c){it(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,t}function Qe(r,e,t,i,c){it(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=y,y=y>>8,r[t+2]=y,y=y>>8,r[t+1]=y,y=y>>8,r[t]=y,t+8}s.prototype.writeBigUInt64LE=Z(function(e,t=0){return Je(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Z(function(e,t=0){return Qe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let R=Math.pow(2,8*i-1);z(this,e,t,i,R-1,-R)}let l=0,y=1,S=0;for(this[t]=e&255;++l<i&&(y*=256);)e<0&&S===0&&this[t+l-1]!==0&&(S=1),this[t+l]=(e/y>>0)-S&255;return t+i},s.prototype.writeIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let R=Math.pow(2,8*i-1);z(this,e,t,i,R-1,-R)}let l=i-1,y=1,S=0;for(this[t+l]=e&255;--l>=0&&(y*=256);)e<0&&S===0&&this[t+l+1]!==0&&(S=1),this[t+l]=(e/y>>0)-S&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=Z(function(e,t=0){return Je(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Z(function(e,t=0){return Qe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function et(r,e,t,i,c,l){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function tt(r,e,t,i,c){return e=+e,t=t>>>0,c||et(r,e,t,4),n.write(r,e,t,i,23,4),t+4}s.prototype.writeFloatLE=function(e,t,i){return tt(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return tt(this,e,t,!1,i)};function nt(r,e,t,i,c){return e=+e,t=t>>>0,c||et(r,e,t,8),n.write(r,e,t,i,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,i){return nt(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return nt(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<i&&(c=i),c===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-i&&(c=e.length-t+i);let l=c-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,c):Uint8Array.prototype.set.call(e,this.subarray(i,c),t),l},s.prototype.fill=function(e,t,i,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,i=this.length):typeof i=="string"&&(c=i,i=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let y=e.charCodeAt(0);(c==="utf8"&&y<128||c==="latin1")&&(e=y)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<i;++l)this[l]=e;else{let y=s.isBuffer(e)?e:s.from(e,c),S=y.length;if(S===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<i-t;++l)this[l+t]=y[l%S]}return this};let oe={};function ke(r,e,t){oe[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ke("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ke("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),ke("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=rt(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=rt(c)),c+="n"),i+=` It must be ${e}. Received ${c}`,i},RangeError);function rt(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function en(r,e,t){ce(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function it(r,e,t,i,c,l){if(r>t||r<e){let y=typeof e=="bigint"?"n":"",S;throw l>3?e===0||e===BigInt(0)?S=`>= 0${y} and < 2${y} ** ${(l+1)*8}${y}`:S=`>= -(2${y} ** ${(l+1)*8-1}${y}) and < 2 ** ${(l+1)*8-1}${y}`:S=`>= ${e}${y} and <= ${t}${y}`,new oe.ERR_OUT_OF_RANGE("value",S,r)}en(i,c,l)}function ce(r,e){if(typeof r!="number")throw new oe.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(ce(r,t),new oe.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new oe.ERR_BUFFER_OUT_OF_BOUNDS:new oe.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}let tn=/[^+/0-9A-Za-z-_]/g;function nn(r){if(r=r.split("=")[0],r=r.trim().replace(tn,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ue(r,e){e=e||1/0;let t,i=r.length,c=null,l=[];for(let y=0;y<i;++y){if(t=r.charCodeAt(y),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(y+1===i){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function rn(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function sn(r,e){let t,i,c,l=[];for(let y=0;y<r.length&&!((e-=2)<0);++y)t=r.charCodeAt(y),i=t>>8,c=t%256,l.push(c),l.push(i);return l}function st(r){return o.toByteArray(nn(r))}function we(r,e,t,i){let c;for(c=0;c<i&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function Y(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Pe(r){return r!==r}let an=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let c=0;c<16;++c)e[i+c]=r[t]+r[c]}return e}();function Z(r){return typeof BigInt>"u"?on:r}function on(){throw new Error("BigInt not supported")}return ne}var ye,lt,be,dt,ne,pt,re,O,Zn,Jn,Ne=pe(()=>{"use strict";E();T();v();ye={},lt=!1;be={},dt=!1;ne={},pt=!1;re=wn();re.Buffer;re.SlowBuffer;re.INSPECT_MAX_BYTES;re.kMaxLength;O=re.Buffer,Zn=re.INSPECT_MAX_BYTES,Jn=re.kMaxLength});var T=pe(()=>{"use strict";Ne()});var ht=ot((sr,yt)=>{"use strict";E();T();v();function bn(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),a=0;a<n.length;a++)n[a]=255;for(var u=0;u<o.length;u++){var d=o.charAt(u),p=d.charCodeAt(0);if(n[p]!==255)throw new TypeError(d+" is ambiguous");n[p]=u}var s=o.length,g=o.charAt(0),w=Math.log(s)/Math.log(256),I=Math.log(256)/Math.log(s);function f(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var m=0,B=0,x=0,k=h.length;x!==k&&h[x]===0;)x++,m++;for(var C=(k-x)*I+1>>>0,U=new Uint8Array(C);x!==k;){for(var M=h[x],K=0,H=C-1;(M!==0||K<B)&&H!==-1;H--,K++)M+=256*U[H]>>>0,U[H]=M%s>>>0,M=M/s>>>0;if(M!==0)throw new Error("Non-zero carry");B=K,x++}for(var q=C-B;q!==C&&U[q]===0;)q++;for(var ae=g.repeat(m);q<C;++q)ae+=o.charAt(U[q]);return ae}function A(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;for(var m=0,B=0,x=0;h[m]===g;)B++,m++;for(var k=(h.length-m)*w+1>>>0,C=new Uint8Array(k);h[m];){var U=n[h.charCodeAt(m)];if(U===255)return;for(var M=0,K=k-1;(U!==0||M<x)&&K!==-1;K--,M++)U+=s*C[K]>>>0,C[K]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");x=M,m++}for(var H=k-x;H!==k&&C[H]===0;)H++;for(var q=new Uint8Array(B+(k-H)),ae=B;H!==k;)q[ae++]=C[H++];return q}function _(h){var m=A(h);if(m)return m;throw new Error("Non-base"+s+" character")}return{encode:f,decodeUnsafe:A,decode:_}}yt.exports=bn});var ft=ot((ur,gt)=>{"use strict";E();T();v();var An=ht(),In="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";gt.exports=An(In)});E();T();v();E();T();v();E();T();v();var ge=hn(ft());E();T();v();var $=2n**255n-19n,ue=2n**252n+27742317777372353535851937790883648493n,Oe=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Re=0x6666666666666666666666666666666666666666666666666666666666666658n,Ae={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:$,n:ue,h:8,Gx:Oe,Gy:Re},W=(o="")=>{throw new Error(o)},It=o=>typeof o=="string",ve=(o,n)=>!(o instanceof Uint8Array)||typeof n=="number"&&n>0&&o.length!==n?W("Uint8Array expected"):o,le=o=>new Uint8Array(o),Te=(o,n)=>ve(It(o)?Le(o):le(o),n),b=(o,n=$)=>{let a=o%n;return a>=0n?a:n+a},mt=o=>o instanceof J?o:W("Point expected"),wt,J=class o{constructor(n,a,u,d){this.ex=n,this.ey=a,this.ez=u,this.et=d}static fromAffine(n){return new o(n.x,n.y,1n,b(n.x*n.y))}static fromHex(n,a=!0){let{d:u}=Ae;n=Te(n,32);let d=n.slice();d[31]=n[31]&-129;let p=Tt(d);p===0n||(a&&!(0n<p&&p<$)&&W("bad y coord 1"),!a&&!(0n<p&&p<2n**256n)&&W("bad y coord 2"));let s=b(p*p),g=b(s-1n),w=b(u*s+1n),{isValid:I,value:f}=vn(g,w);I||W("bad y coordinate 3");let A=(f&1n)===1n;return(n[31]&128)!==0!==A&&(f=b(-f)),new o(f,p,1n,b(f*p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(n){let{ex:a,ey:u,ez:d}=this,{ex:p,ey:s,ez:g}=mt(n),w=b(a*g),I=b(p*d),f=b(u*g),A=b(s*d);return w===I&&f===A}is0(){return this.equals(Ie)}negate(){return new o(b(-this.ex),this.ey,this.ez,b(-this.et))}double(){let{ex:n,ey:a,ez:u}=this,{a:d}=Ae,p=b(n*n),s=b(a*a),g=b(2n*b(u*u)),w=b(d*p),I=n+a,f=b(b(I*I)-p-s),A=w+s,_=A-g,h=w-s,m=b(f*_),B=b(A*h),x=b(f*h),k=b(_*A);return new o(m,B,k,x)}add(n){let{ex:a,ey:u,ez:d,et:p}=this,{ex:s,ey:g,ez:w,et:I}=mt(n),{a:f,d:A}=Ae,_=b(a*s),h=b(u*g),m=b(p*A*I),B=b(d*w),x=b((a+u)*(s+g)-_-h),k=b(B-m),C=b(B+m),U=b(h-f*_),M=b(x*k),K=b(C*U),H=b(x*U),q=b(k*C);return new o(M,K,q,H)}mul(n,a=!0){if(n===0n)return a===!0?W("cannot multiply by 0"):Ie;if(typeof n=="bigint"&&0n<n&&n<ue||W("invalid scalar, must be < L"),!a&&this.is0()||n===1n)return this;if(this.equals(se))return Cn(n).p;let u=Ie,d=se;for(let p=this;n>0n;p=p.double(),n>>=1n)n&1n?u=u.add(p):a&&(d=d.add(p));return u}multiply(n){return this.mul(n)}clearCofactor(){return this.mul(BigInt(Ae.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let n=this.mul(ue/2n,!1).double();return ue%2n&&(n=n.add(this)),n.is0()}toAffine(){let{ex:n,ey:a,ez:u}=this;if(this.is0())return{x:0n,y:0n};let d=Bt(u);return b(u*d)!==1n&&W("invalid inverse"),{x:b(n*d),y:b(a*d)}}toRawBytes(){let{x:n,y:a}=this.toAffine(),u=vt(a);return u[31]|=n&1n?128:0,u}toHex(){return Fe(this.toRawBytes())}};J.BASE=new J(Oe,Re,1n,b(Oe*Re));J.ZERO=new J(0n,1n,1n,0n);var{BASE:se,ZERO:Ie}=J,Et=(o,n)=>o.toString(16).padStart(n,"0"),Fe=o=>Array.from(o).map(n=>Et(n,2)).join(""),Le=o=>{let n=o.length;(!It(o)||n%2)&&W("hex invalid 1");let a=le(n/2);for(let u=0;u<a.length;u++){let d=u*2,p=o.slice(d,d+2),s=Number.parseInt(p,16);(Number.isNaN(s)||s<0)&&W("hex invalid 2"),a[u]=s}return a},vt=o=>Le(Et(o,32*2)).reverse(),Tt=o=>BigInt("0x"+Fe(le(ve(o)).reverse())),Ee=(...o)=>{let n=le(o.reduce((u,d)=>u+ve(d).length,0)),a=0;return o.forEach(u=>{n.set(u,a),a+=u.length}),n},Bt=(o,n=$)=>{(o===0n||n<=0n)&&W("no inverse n="+o+" mod="+n);let a=b(o,n),u=n,d=0n,p=1n,s=1n,g=0n;for(;a!==0n;){let w=u/a,I=u%a,f=d-s*w,A=p-g*w;u=a,a=I,d=s,p=g,s=f,g=A}return u===1n?b(d,n):W("no inverse")},G=(o,n)=>{let a=o;for(;n-- >0n;)a*=a,a%=$;return a},En=o=>{let a=o*o%$*o%$,u=G(a,2n)*a%$,d=G(u,1n)*o%$,p=G(d,5n)*d%$,s=G(p,10n)*p%$,g=G(s,20n)*s%$,w=G(g,40n)*g%$,I=G(w,80n)*w%$,f=G(I,80n)*w%$,A=G(f,10n)*p%$;return{pow_p_5_8:G(A,2n)*o%$,b2:a}},bt=19681161376707505956807079304988542015446066515923890162744021073123829784752n,vn=(o,n)=>{let a=b(n*n*n),u=b(a*a*n),d=En(o*u).pow_p_5_8,p=b(o*a*d),s=b(n*p*p),g=p,w=b(p*bt),I=s===o,f=s===b(-o),A=s===b(-o*bt);return I&&(p=g),(f||A)&&(p=w),(b(p)&1n)===1n&&(p=b(-p)),{isValid:I||f,value:p}},De=o=>b(Tt(o),ue),he,Ve=(...o)=>He.sha512Async(...o),xt=(...o)=>typeof he=="function"?he(...o):W("etc.sha512Sync not set"),St=o=>{let n=o.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let a=o.slice(32,64),u=De(n),d=se.mul(u),p=d.toRawBytes();return{head:n,prefix:a,scalar:u,point:d,pointBytes:p}},$e=o=>Ve(Te(o,32)).then(St),Tn=o=>St(xt(Te(o,32))),Ct=o=>$e(o).then(n=>n.pointBytes);function Bn(o,n){return o?Ve(n.hashable).then(n.finish):n.finish(xt(n.hashable))}var xn=(o,n,a)=>{let{pointBytes:u,scalar:d}=o,p=De(n),s=se.mul(p).toRawBytes();return{hashable:Ee(s,u,a),finish:I=>{let f=b(p+De(I)*d,ue);return ve(Ee(s,vt(f)),64)}}},_t=async(o,n)=>{let a=Te(o),u=await $e(n),d=await Ve(u.prefix,a);return Bn(!0,xn(u,d,a))};var At=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,He={bytesToHex:Fe,hexToBytes:Le,concatBytes:Ee,mod:b,invert:Bt,randomBytes:o=>{let n=At();return n||W("crypto.getRandomValues must be defined"),n.getRandomValues(le(o))},sha512Async:async(...o)=>{let n=At();n||W("crypto.subtle or etc.sha512Async must be defined");let a=Ee(...o);return le(await n.subtle.digest("SHA-512",a.buffer))},sha512Sync:void 0};Object.defineProperties(He,{sha512Sync:{configurable:!1,get(){return he},set(o){he||(he=o)}}});var kt={getExtendedPublicKeyAsync:$e,getExtendedPublicKey:Tn,randomPrivateKey:()=>He.randomBytes(32),precompute(o=8,n=se){return n.multiply(3n),n}},ie=8,Sn=()=>{let o=[],n=256/ie+1,a=se,u=a;for(let d=0;d<n;d++){u=a,o.push(u);for(let p=1;p<2**(ie-1);p++)u=u.add(a),o.push(u);a=u.double()}return o},Cn=o=>{let n=wt||(wt=Sn()),a=(f,A)=>{let _=A.negate();return f?_:A},u=Ie,d=se,p=1+256/ie,s=2**(ie-1),g=BigInt(2**ie-1),w=2**ie,I=BigInt(ie);for(let f=0;f<p;f++){let A=f*s,_=Number(o&g);o>>=I,_>s&&(_-=w,o+=1n);let h=A,m=A+Math.abs(_)-1,B=f%2!==0,x=_<0;_===0?d=d.add(a(B,n[h])):u=u.add(a(x,n[m]))}return{p:u,f:d}};var Q=class o{static generateKey(){let n,a;do n=kt.randomPrivateKey(),a=(0,ge.encode)(n);while(a.length!==44);return new o(a)}constructor(n){this.secretKey=n;let a=(0,ge.decode)(n);this.privateKey=O.from(a).toString("hex")}async sign(n){return await _t(n,this.privateKey)}async getPublicKey(){let n=await Ct(this.privateKey);return`ed25519:${(0,ge.encode)(n)}`}toString(){return this.privateKey}};var Be=class{constructor(n="testnet"){this.networkId=n}get keyPrefix(){return`orderly_${this.networkId}_`}},fe=class extends Be{getOrderlyKey(n){let a;if(n)a=this.getItem(n,"orderlyKey");else{let u=this.getAddress();if(!u)return null;a=this.getItem(u,"orderlyKey")}return a?new Q(a):null}getAccountId(n){return this.getItem(n,"accountId")}setAccountId(n,a){this.setItem(n,{accountId:a})}getAddress(){return localStorage.getItem(`${this.keyPrefix}address`)}setAddress(n){localStorage.setItem(`${this.keyPrefix}address`,n)}generateKey(){return Q.generateKey()}setKey(n,a){this.setItem(n,{orderlyKey:a.secretKey})}cleanAllKey(n){localStorage.removeItem(`${this.keyPrefix}${n}`),localStorage.removeItem(`${this.keyPrefix}address`)}cleanKey(n,a){let u=this.getItem(n);delete u[a],localStorage.setItem(`${this.keyPrefix}${n}`,JSON.stringify(u))}setItem(n,a){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);d?d=JSON.parse(d):d={},localStorage.setItem(u,JSON.stringify({...d,...a}))}getItem(n,a){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);return d?d=JSON.parse(d):d={},typeof a>"u"?d:d[a]}},me=class{constructor(n){this.secretKey=n}generateKey(){return new Q(this.secretKey)}getOrderlyKey(){return new Q(this.secretKey)}getAccountId(){return""}setAccountId(n){}getAddress(){return""}setAddress(n){}setKey(n,a){}cleanAllKey(){}cleanKey(n){}};E();T();v();E();T();v();E();T();v();var X={EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Registration:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"timestamp",type:"uint64"},{name:"registrationNonce",type:"uint256"}],Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}],AddOrderlyKey:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"orderlyKey",type:"string"},{name:"scope",type:"string"},{name:"timestamp",type:"uint64"},{name:"expiration",type:"uint64"}],SettlePnl:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"settleNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},Ut="0x6aAd876244E7A1Ad44Ec4824Ce813729E5B6C291",Pt="0xd64AeB281f3E8cd70e668b6cb24De7e532dC214D",Mt="0x1826B75e2ef249173FC735149AE4B8e9ea10abff";import{keccak256 as kn,AbiCoder as Un,solidityPackedKeccak256 as Pn}from"ethers";var Kt=function(o){return o.replace(/\+/g,"-").replace(/\//g,"_")};function Mn(){return"0x8794E7260517B1766fc7b55cAfcd56e6bf08600e"}function Nt(o,n){return{name:"Orderly",version:"1",chainId:o,verifyingContract:n?Mn():"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}function Ot(o){let{chainId:n,registrationNonce:a,brokerId:u}=o,d=Date.now(),p="Registration",s={brokerId:u,chainId:n,timestamp:d,registrationNonce:a},g={EIP712Domain:X.EIP712Domain,[p]:X[p]};return[s,{domain:Nt(n),message:s,primaryType:p,types:g}]}function Rt(o){let{publicKey:n,chainId:a,primaryType:u,brokerId:d,expiration:p=365}=o,s=Date.now(),g={brokerId:d,orderlyKey:n,scope:"read,trading",chainId:a,timestamp:s,expiration:s+1e3*60*60*24*p},w={EIP712Domain:X.EIP712Domain,[u]:X[u]},I={domain:Nt(a),message:g,primaryType:u,types:w};return[g,I]}function Dt(o){let{chainId:n,settlePnlNonce:a,domain:u,brokerId:d}=o,p="SettlePnl",s=new Date().getTime(),g={EIP712Domain:X.EIP712Domain,[p]:X[p]},w={brokerId:d,chainId:n,timestamp:s,settleNonce:a};return[w,{domain:u,message:w,primaryType:p,types:g}]}function We(o){return Vt(o)}function Ft(o,n){let a=Un.defaultAbiCoder();return kn(a.encode(["address","bytes32"],[o,We(n)]))}function Lt(o){return Vt(o)}function Vt(o){return Pn(["string"],[o])}Ne();var ee=class{constructor(n){this.keyStore=n}async sign(n){let a=Date.now().toString(),u=[a,n.method.toUpperCase(),n.url].join("");n.data&&Object.keys(n.data).length&&(u+=JSON.stringify(n.data));let{signature:d,publicKey:p}=await this.signText(u);return{"orderly-key":p,"orderly-timestamp":a,"orderly-signature":d}}async signText(n){let a=this.keyStore.getOrderlyKey();if(!a)throw new Error("orderlyKeyPair is not defined");let u=O.from(n),d=await a.sign(u),p=O.from(d).toString("base64");return{signature:Kt(p),publicKey:await a.getPublicKey()}}};import{default as ns}from"eventemitter3";E();T();v();E();T();v();var xe=class{constructor(){this._restore()}_restore(){this.map=new Map([["apiBaseUrl","https://dev-api-iap-v2.orderly.org"],["klineDataUrl","https://testnet-api-evm.orderly.org"],["publicWsUrl","wss://dev-ws-v2.orderly.org"],["publicWebsocketKey","OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY"],["privateWsUrl","wss://dev-ws-private-v2.orderly.org"],["operatorUrl","https://testnet-operator-evm.orderly.org"],["swapSupportApiUrl","https://woofi-api.mer1in.com"],["brokerId","woofi_dex"],["env","dev-evm"]])}get(n){return this.map.get(n)}set(n,a){this.map.set(n,a)}clear(){}},$t=class extends xe{constructor(a){super();this.configMap=a}_restore(){let a=Object.entries(this.configMap);this.map=new Map(a)}};var Kn=o=>{let n=new me(o||"AFmQSju4FhDwG93cMdKogcnKx7SWmViDtDv5PVzfvRDF");return new ee(n)},Nn=()=>{if(typeof window>"u")throw new Error("the default signer only supports browsers.");let o=new fe("");return new ee(o)};E();T();v();var je=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"},{internalType:"uint8",name:"decimals_",type:"uint8"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"issue",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_to",type:"address"},{internalType:"uint256",name:"_amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_paused",type:"bool"}],name:"pauseTransfers",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}];var Ht=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccountIdInvalid",type:"error"},{inputs:[{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint128",name:"amount",type:"uint128"}],name:"BalanceNotEnough",type:"error"},{inputs:[],name:"BrokerNotAllowed",type:"error"},{inputs:[],name:"OnlyCrossChainManagerCanCall",type:"error"},{inputs:[],name:"TokenNotAllowed",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"address",name:"userAddress",type:"address"},{indexed:!0,internalType:"uint64",name:"depositNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"}],name:"AccountDeposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"address",name:"userAddress",type:"address"},{indexed:!0,internalType:"uint64",name:"depositNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"}],name:"AccountDepositTo",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"accountId",type:"bytes32"},{indexed:!0,internalType:"uint64",name:"withdrawNonce",type:"uint64"},{indexed:!1,internalType:"bytes32",name:"brokerHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"address",name:"receiver",type:"address"},{indexed:!1,internalType:"bytes32",name:"tokenHash",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"tokenAmount",type:"uint128"},{indexed:!1,internalType:"uint128",name:"fee",type:"uint128"},{indexed:!1,internalType:"uint256",name:"blocktime",type:"uint256"}],name:"AccountWithdraw",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"_tokenAddress",type:"address"}],name:"ChangeTokenAddressAndAllow",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_brokerHash",type:"bytes32"},{indexed:!1,internalType:"bool",name:"_allowed",type:"bool"}],name:"SetAllowedBroker",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{indexed:!1,internalType:"bool",name:"_allowed",type:"bool"}],name:"SetAllowedToken",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"allowedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{internalType:"address",name:"_tokenAddress",type:"address"}],name:"changeTokenAddressAndAllow",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"crossChainManagerAddress",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"}],internalType:"struct VaultTypes.VaultDepositFE",name:"data",type:"tuple"}],name:"deposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"depositId",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"receiver",type:"address"},{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"}],internalType:"struct VaultTypes.VaultDepositFE",name:"data",type:"tuple"}],name:"depositTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"emergencyPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"emergencyUnpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"getAllAllowedBroker",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAllAllowedToken",outputs:[{internalType:"bytes32[]",name:"",type:"bytes32[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_brokerHash",type:"bytes32"}],name:"getAllowedBroker",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"}],name:"getAllowedToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"_brokerHash",type:"bytes32"},{internalType:"bool",name:"_allowed",type:"bool"}],name:"setAllowedBroker",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"_tokenHash",type:"bytes32"},{internalType:"bool",name:"_allowed",type:"bool"}],name:"setAllowedToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_crossChainManagerAddress",type:"address"}],name:"setCrossChainManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"accountId",type:"bytes32"},{internalType:"bytes32",name:"brokerHash",type:"bytes32"},{internalType:"bytes32",name:"tokenHash",type:"bytes32"},{internalType:"uint128",name:"tokenAmount",type:"uint128"},{internalType:"uint128",name:"fee",type:"uint128"},{internalType:"address",name:"sender",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint64",name:"withdrawNonce",type:"uint64"}],internalType:"struct VaultTypes.VaultWithdraw",name:"data",type:"tuple"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}];var ze=class{constructor(n){this.configStore=n}getContractInfoByEnv(){return{usdcAddress:Ut,usdcAbi:je,vaultAddress:Pt,vaultAbi:Ht,verifyContractAddress:Mt,erc20Abi:je}}};E();T();v();E();T();v();var qe=class{constructor(n=[],a={}){this.providers=n;this.services=a;this.injectProperties={}}register(...n){this.providers.push(...n),n.forEach(a=>{let u=a;u instanceof Function&&(u=new a),this.add(u)})}registerByName(n,a){let u=a;u instanceof Function&&(u=new a),this.addByName(n,u)}get(n){return this.services[n]}getAll(){return Object.assign({},this.services)}add(n){return this.addByName(n.constructor.name,n)}addByName(n,a){return this.services[n]=a,this.services[n.toLowerCase()]=a,this.injectIntoProperties(a,n),this.get(n)}inject(n,a,u){n&&u&&(n[a]=u)}injectIntoProperties(n,a=n.constructor.name){this.getInjectProperty(a.toLowerCase()).forEach(u=>{this.inject(u.target,u.propertyKey,n)})}getInjectProperty(n){return this.injectProperties[n]||(this.injectProperties[n]=[]),this.injectProperties[n]}},Wt=qe;var Ye=class o{static getContainer(){return o.container||(o.container=new Wt),o.container}static register(...n){this.getContainer().register(...n)}static registerByName(n,a){this.getContainer().registerByName(n,a)}static get(n){return this.getContainer().get(n)}static getAll(){return this.getContainer().getAll()}constructor(){}},Dn=Ye;E();T();v();import{AccountStatusEnum as j}from"@orderly.network/types";import Ln from"eventemitter3";E();T();v();import{ethers as Fn}from"ethers";var Se=class{constructor(n,a,u){this.configStore=n;this.contractManger=a;this.account=u}async withdraw(n){if(!this.account.walletClient)throw new Error("walletClient is undefined");if(!this.account.stateValue.address)throw new Error("account address is rqeuired");let{chainId:a,token:u,amount:d}=n,p="/v1/withdraw_request",s=await this.getWithdrawalNonce(),g=this.account.getDomain(!0),[w,I]=this._generateWithdrawMessage({chainId:a,receiver:this.account.stateValue.address,token:u,amount:this.account.walletClient.parseUnits(d.toString()),nonce:s,domain:g}),A={signature:await this.account.signTypedData(I),message:w,userAddress:this.account.stateValue.address,verifyingContract:g.verifyingContract},_={method:"POST",url:p,data:A},h=await this.account.signer.sign(_);return await this._simpleFetch(p,{method:"POST",body:JSON.stringify(A),headers:{"Content-Type":"application/json","orderly-account-id":this.account.stateValue.accountId,...h}})}_generateWithdrawMessage(n){let{chainId:a,receiver:u,token:d,amount:p,domain:s,nonce:g}=n,w="Withdraw",I=Date.now(),f={EIP712Domain:X.EIP712Domain,[w]:X[w]},A={brokerId:this.configStore.get("brokerId"),chainId:a,receiver:u,token:d,amount:p,timestamp:I,withdrawNonce:g};return[A,{domain:s,message:A,primaryType:w,types:f}]}async getWithdrawalNonce(){let n=Date.now().toString(),a="/v1/withdraw_nonce",u=[n,"GET",a].join(""),d=this.account.signer,{publicKey:p,signature:s}=await d.signText(u),g=await this._simpleFetch(a,{headers:{"orderly-account-id":this.account.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":s}});if(g.success)return g.data?.withdraw_nonce;throw new Error(g.message)}async getNativeBalance(){console.log("getNativeBalance",this.account.stateValue.address);let n=await this.account.walletClient?.getBalance(this.account.stateValue.address);return this.account.walletClient.fromUnits(n)}async getBalance(n){if(!this.account.walletClient)return"0";let a=this.contractManger.getContractInfoByEnv(),u=await this.account.walletClient?.call(n??a.usdcAddress,"balanceOf",[this.account.stateValue.address],{abi:a.usdcAbi});return console.log("-----*****-----",u),this.account.walletClient?.fromUnits(u)}async getBalanceByAddress(n){if(!this.account.walletClient)return"0";let a=this.contractManger.getContractInfoByEnv();console.log("address:::::",n);let u=await this.account.walletClient?.call(n,"balanceOf",[this.account.stateValue.address],{abi:a.erc20Abi});return this.account.walletClient?.fromUnits(u)}async getAllowance(n){if(!this.account.walletClient)return"0";let a=this.contractManger.getContractInfoByEnv(),u=await this.account.walletClient?.call(n??a.usdcAddress,"allowance",[this.account.stateValue.address,a.vaultAddress],{abi:a.usdcAbi});return this.account.walletClient?.fromUnits(u)}async approve(n){if(!this.account.walletClient)throw new Error("walletClient is undefined");let a=this.contractManger.getContractInfoByEnv(),u=typeof n<"u"&&n!==""?this.account.walletClient.parseUnits(n):Fn.MaxUint256.toString(),d=await this.account.walletClient?.call(a.usdcAddress,"approve",[a.vaultAddress,u],{abi:a.usdcAbi});return console.log("-----*****-----",d),d}async deposit(n){console.log("deposit amount:",n);let a=this.configStore.get("brokerId");if(!a)throw new Error("brokerId is required");let u=this.contractManger.getContractInfoByEnv(),d={accountId:Ft(this.account.stateValue.address,a),brokerHash:We(a),tokenHash:Lt("USDC"),tokenAmount:this.account.walletClient?.parseUnits(n)};return await this.account.walletClient?.call(u.vaultAddress,"deposit",[d],{abi:u.vaultAbi})}async _simpleFetch(n,a={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,a).then(d=>d.json())}};var Ce=class{constructor(n,a,u,d){this.configStore=n;this.keyStore=a;this.contractManger=u;this.getWalletAdapter=d;this._ee=new Ln;this._state={status:j.NotConnected,balance:"",checking:!1,leverage:Number.NaN};this.assetsManager=new Se(n,u,this),this._bindEvents()}login(n){if(!n)throw new Error("address is required")}logout(){}async setAddress(n,a){if(!n)throw new Error("address is required");this.keyStore.setAddress(n);let u={...this.stateValue,status:j.Connected,address:n,connectWallet:a?.wallet};return this._ee.emit("change:status",u),a&&(this.walletClient=this.getWalletAdapter({...a,address:n})),await this._checkAccount(n)}get stateValue(){return this._state}get accountId(){return this.stateValue.accountId}get address(){return this.stateValue.address}get chainId(){return this.walletClient?.chainId}set position(n){let a={...this.stateValue,positon:n};this._ee.emit("change:status",a)}set orders(n){let a={...this.stateValue,orders:n};this._ee.emit("change:status",a)}_bindEvents(){this._ee.addListener("change:status",n=>{console.log("change:status",n),this._state=n})}async _checkAccount(n){let a;try{let u=await this._checkAccountExist(n);if(u&&u.account_id)console.log("account is exist"),this.keyStore.setAccountId(n,u.account_id),a={...this.stateValue,status:j.SignedIn,accountId:u.account_id,userId:u.user_id},this._ee.emit("change:status",a);else return a={...this.stateValue,status:j.NotSignedIn},this._ee.emit("change:status",a),j.NotSignedIn;let d=this.keyStore.getOrderlyKey();if(a={...this.stateValue,status:j.DisabledTrading},!d)return console.log("orderlyKey is null"),this._ee.emit("change:status",a),j.DisabledTrading;let p=await d.getPublicKey(),s=await this._checkOrderlyKeyState(u.account_id,p);if(s&&s.orderly_key&&s.key_status==="ACTIVE"){let g=Date.now(),w=s.expiration;if(g>w)return this.keyStore.cleanKey(n,"orderlyKey"),j.DisabledTrading;let I={...this.stateValue,status:j.EnableTrading};return this._ee.emit("change:status",I),j.EnableTrading}return this.keyStore.cleanKey(n,"orderlyKey"),j.NotConnected}catch(u){console.log("\u68C0\u67E5\u8D26\u6237\u72B6\u6001\u9519\u8BEF:",u)}return j.NotSignedIn}async _checkAccountExist(n){let a=await this._simpleFetch(`/v1/get_account?address=${n}&broker_id=woofi_dex`);return a.success?a.data:null}async createAccount(){if(!this.walletClient)return Promise.reject("walletClient is undefined");let n=await this._getRegisterationNonce(),a=this.stateValue.address;if(!a)throw new Error("address is undefined");let[u,d]=Ot({registrationNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId")}),p=await this.signTypedData(d),s=await this._simpleFetch("/v1/register_account",{method:"POST",body:JSON.stringify({signature:p,message:u,userAddress:a}),headers:{"Content-Type":"application/json"}});if(s.success){this.keyStore.setAccountId(a,s.data.account_id);let g={...this.stateValue,status:j.DisabledTrading,accountId:s.data.account_id,userId:s.data.user_id};return this._ee.emit("change:status",g),s}}async signTypedData(n){return this.walletClient?await this.walletClient.signTypedData(this.stateValue.address,JSON.stringify(n)):Promise.reject("walletClient is undefined")}async createOrderlyKey(n){if(this.stateValue.accountId===void 0)throw new Error("account id is undefined");if(!this.walletClient)throw new Error("walletClient is undefined");let a="AddOrderlyKey",u=this.keyStore.generateKey(),d=await u.getPublicKey(),[p,s]=Rt({publicKey:d,chainId:this.walletClient.chainId,primaryType:a,expiration:n,brokerId:this.configStore.get("brokerId")}),g=this.stateValue.address;if(!g)throw new Error("address is undefined");let w=await this.signTypedData(s),I=await this._simpleFetch("/v1/orderly_key",{method:"POST",body:JSON.stringify({signature:w,message:p,userAddress:g}),headers:{"X-Account-Id":this.stateValue.accountId,"Content-Type":"application/json"}});if(I.success){this.keyStore.setKey(g,u);let f={...this.stateValue,status:j.EnableTrading};return this._ee.emit("change:status",f),I}else throw new Error(I.message)}async settle(){if(!this.walletClient)return Promise.reject("walletClient is undefined");let n=await this._getSettleNonce(),a=this.stateValue.address,u=this.getDomain(!0),d="/v1/settle_pnl",[p,s]=Dt({settlePnlNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId"),domain:u}),w={signature:await this.signTypedData(s),message:p,userAddress:a,verifyingContract:u.verifyingContract},I={method:"POST",url:d,data:w},f=await this.signer.sign(I),A=await this._simpleFetch(d,{method:"POST",body:JSON.stringify(w),headers:{"Content-Type":"application/json","orderly-account-id":this.stateValue.accountId,...f}});if(A.success)return A;throw new Error(A.message)}async disconnect(){let n={...this.stateValue,status:j.NotConnected,accountId:void 0,userId:void 0,address:void 0};this._ee.emit("change:status",n)}async _checkOrderlyKeyState(n,a){let u=await this._simpleFetch(`/v1/get_orderly_key?account_id=${n}&orderly_key=${a}`);if(u.success)return u.data;throw new Error(u.message)}get signer(){return this._singer||(this._singer=new ee(this.keyStore)),this._singer}get wallet(){return this.walletClient}async _getRegisterationNonce(){let n=await this._simpleFetch("/v1/registration_nonce",{headers:{"orderly-account-id":this.stateValue.accountId}});if(n.success)return n.data?.registration_nonce;throw new Error(n.message)}async _getSettleNonce(){let n=Date.now().toString(),u=[n,"GET","/v1/settle_nonce"].join(""),d=this.signer,{publicKey:p,signature:s}=await d.signText(u),g=await this._simpleFetch("/v1/settle_nonce",{headers:{"orderly-account-id":this.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":s}});if(g.success)return g.data?.settle_nonce;throw new Error(g.message)}async _simpleFetch(n,a={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,a).then(d=>d.json())}getDomain(n){if(!this.walletClient)throw new Error("walletClient is undefined");return{name:"Orderly",version:"1",chainId:this.walletClient.chainId,verifyingContract:n?this.contractManger.getContractInfoByEnv().verifyContractAddress:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}get on(){return this._ee.on.bind(this._ee)}get once(){return this._ee.once.bind(this._ee)}get off(){return this._ee.off.bind(this._ee)}};Ce.instanceName="account";E();T();v();E();T();v();import{BrowserProvider as Vn,ethers as _e}from"ethers";import{getParsedEthersError as $n}from"@enzoferey/ethers-error-parser";var Ge=class{constructor(n){console.log("EtherAdapter constructor",n),this._chainId=parseInt(n.chain.id,16),this.provider=new Vn(n.provider,"any"),this._address=n.address}parseUnits(n){return _e.parseUnits(n,6).toString()}fromUnits(n){return _e.formatUnits(n,6)}getBalance(n){return console.log("*********",n),this.provider.getBalance(n).then(a=>(console.log("getBalance",a),a),a=>{console.log("get native token balance error",a)})}deposit(n,a,u){throw new Error("Method not implemented.")}async call(n,a,u,d){let p=await this.provider?.getSigner();return new _e.Contract(n,d.abi,p)[a].apply(null,u).catch(g=>{throw $n(g)})}get chainId(){return this._chainId}get addresses(){return this._address}async send(n,a){return await this.provider?.send(n,a)}async signTypedData(n,a){return await this.provider?.send("eth_signTypedData_v4",[n,a])}async verify(n,a){let{domain:u,types:d,message:p}=n,s=_e.verifyTypedData(u,d,p,a);console.log("recovered",s)}};export{Ce as Account,$t as BaseConfigStore,ze as BaseContractManager,Be as BaseKeyStore,Q as BaseOrderlyKeyPair,ee as BaseSigner,Ge as EtherAdapter,ns as EventEmitter,fe as LocalStorageStore,xe as MemoryConfigStore,me as MockKeyStore,Dn as SimpleDI,Nn as getDefaultSigner,Kn as getMockSigner};
2
2
  /*! Bundled license information:
3
3
 
4
4
  @jspm/core/nodelibs/browser/buffer.js: