@multiplechain/bitcoin 0.4.3 → 0.4.5

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.
@@ -1,6 +1,6 @@
1
1
  import { CoinInterface, TransferAmount, WalletAddress } from '@multiplechain/types';
2
- import { TransactionSigner } from '../services/TransactionSigner.ts';
3
- import { Provider } from '../services/Provider.ts';
2
+ import { TransactionSigner } from '../services/TransactionSigner';
3
+ import { Provider } from '../services/Provider';
4
4
 
5
5
  export declare class Coin implements CoinInterface<TransactionSigner> {
6
6
  /**
@@ -1 +1 @@
1
- export * from './Coin.ts';
1
+ export * from './Coin';
@@ -1,5 +1,5 @@
1
- import { TransactionSigner } from '../services/TransactionSigner.ts';
2
- import { Provider } from '../services/Provider.ts';
1
+ import { TransactionSigner } from '../services/TransactionSigner';
2
+ import { Provider } from '../services/Provider';
3
3
  import { WalletInterface, WalletAdapterInterface, WalletPlatformEnum, UnknownConfig, ConnectConfig, WalletAddress, SignedMessage, TransactionId } from '@multiplechain/types';
4
4
 
5
5
  export interface WalletProvider {
@@ -1,6 +1,6 @@
1
1
  import { WalletAdapterInterface } from '@multiplechain/types';
2
- import { Provider } from '../../services/Provider.ts';
3
- import { WalletProvider } from '../Wallet.ts';
2
+ import { Provider } from '../../services/Provider';
3
+ import { WalletProvider } from '../Wallet';
4
4
 
5
5
  declare global {
6
6
  interface Window {
@@ -1,6 +1,6 @@
1
1
  import { WalletAdapterInterface } from '@multiplechain/types';
2
- import { Provider } from '../../services/Provider.ts';
3
- import { WalletProvider } from '../Wallet.ts';
2
+ import { Provider } from '../../services/Provider';
3
+ import { WalletProvider } from '../Wallet';
4
4
 
5
5
  declare global {
6
6
  interface Window {
@@ -1,6 +1,6 @@
1
1
  import { WalletAdapterInterface } from '@multiplechain/types';
2
- import { Provider } from '../../services/Provider.ts';
3
- import { WalletProvider } from '../Wallet.ts';
2
+ import { Provider } from '../../services/Provider';
3
+ import { WalletProvider } from '../Wallet';
4
4
 
5
5
  declare const Xverse: WalletAdapterInterface<Provider, WalletProvider>;
6
6
  export default Xverse;
@@ -1,3 +1,3 @@
1
- export { default as UniSat } from './UniSat.ts';
2
- export { default as Xverse } from './Xverse.ts';
3
- export { default as Leather } from './Leather.ts';
1
+ export { default as UniSat } from './UniSat';
2
+ export { default as Xverse } from './Xverse';
3
+ export { default as Leather } from './Leather';
@@ -1,9 +1,9 @@
1
1
  import { WalletAdapterListType, RegisterWalletAdapterType } from '@multiplechain/types';
2
- import { Wallet, WalletProvider } from './Wallet.ts';
2
+ import { Wallet, WalletProvider } from './Wallet';
3
3
  import { Provider } from 'sats-connect';
4
4
 
5
- import * as adapterList from './adapters/index.ts';
6
- export * from '../index.ts';
5
+ import * as adapterList from './adapters/index';
6
+ export * from '../index';
7
7
  export declare const browser: {
8
8
  Wallet: typeof Wallet;
9
9
  registerAdapter: RegisterWalletAdapterType<Provider, WalletProvider>;
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ function print() { __p += __j.call(arguments, '') }
35
35
  `):" "+I2(a[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return i},adapters:Wm};function Gm(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Dn(null,e)}function Yp(e){return Gm(e),e.headers=Vr.from(e.headers),e.data=lf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Xp.getAdapter(e.adapter||Dc.adapter)(e).then(function(i){return Gm(e),i.data=lf.call(e,e.transformResponse,i),i.headers=Vr.from(i.headers),i},function(i){return pf(i)||(Gm(e),i&&i.response&&(i.response.data=lf.call(e,e.transformResponse,i.response),i.response.headers=Vr.from(i.response.headers))),Promise.reject(i)})}var R2=e=>e instanceof Vr?{...e}:e;function Xs(e,t){t=t||{};let r={};function i(w,T,I){return z.isPlainObject(w)&&z.isPlainObject(T)?z.merge.call({caseless:I},w,T):z.isPlainObject(T)?z.merge({},T):z.isArray(T)?T.slice():T}function n(w,T,I){if(z.isUndefined(T)){if(!z.isUndefined(w))return i(void 0,w,I)}else return i(w,T,I)}function a(w,T){if(!z.isUndefined(T))return i(void 0,T)}function u(w,T){if(z.isUndefined(T)){if(!z.isUndefined(w))return i(void 0,w)}else return i(void 0,T)}function h(w,T,I){if(I in t)return i(w,T);if(I in e)return i(void 0,w)}let b={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:h,headers:(w,T)=>n(R2(w),R2(T),!0)};return z.forEach(Object.keys(Object.assign({},e,t)),function(T){let I=b[T]||n,B=I(e[T],t[T],T);z.isUndefined(B)&&I!==h||(r[T]=B)}),r}var $m={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{$m[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}});var A2={};$m.transitional=function(t,r,i){function n(a,u){return"[Axios v"+Ao+"] Transitional option '"+a+"'"+u+(i?". "+i:"")}return(a,u,h)=>{if(t===!1)throw new Se(n(u," has been removed"+(r?" in "+r:"")),Se.ERR_DEPRECATED);return r&&!A2[u]&&(A2[u]=!0,console.warn(n(u," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(a,u,h):!0}};function eN(e,t,r){if(typeof e!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);let i=Object.keys(e),n=i.length;for(;n-- >0;){let a=i[n],u=t[a];if(u){let h=e[a],b=h===void 0||u(h,a,e);if(b!==!0)throw new Se("option "+a+" must be "+b,Se.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Se("Unknown option "+a,Se.ERR_BAD_OPTION)}}var Zp={assertOptions:eN,validators:$m};var Ba=Zp.validators,Fc=class{constructor(t){this.defaults=t,this.interceptors={request:new wm,response:new wm}}async request(t,r){try{return await this._request(t,r)}catch(i){if(i instanceof Error){let n;Error.captureStackTrace?Error.captureStackTrace(n={}):n=new Error;let a=n.stack?n.stack.replace(/^.+\n/,""):"";i.stack?a&&!String(i.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(i.stack+=`
36
36
  `+a):i.stack=a}throw i}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xs(this.defaults,r);let{transitional:i,paramsSerializer:n,headers:a}=r;i!==void 0&&Zp.assertOptions(i,{silentJSONParsing:Ba.transitional(Ba.boolean),forcedJSONParsing:Ba.transitional(Ba.boolean),clarifyTimeoutError:Ba.transitional(Ba.boolean)},!1),n!=null&&(z.isFunction(n)?r.paramsSerializer={serialize:n}:Zp.assertOptions(n,{encode:Ba.function,serialize:Ba.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let u=a&&z.merge(a.common,a[r.method]);a&&z.forEach(["delete","get","head","post","put","patch","common"],P=>{delete a[P]}),r.headers=Vr.concat(u,a);let h=[],b=!0;this.interceptors.request.forEach(function(L){typeof L.runWhen=="function"&&L.runWhen(r)===!1||(b=b&&L.synchronous,h.unshift(L.fulfilled,L.rejected))});let w=[];this.interceptors.response.forEach(function(L){w.push(L.fulfilled,L.rejected)});let T,I=0,B;if(!b){let P=[Yp.bind(this),void 0];for(P.unshift.apply(P,h),P.push.apply(P,w),B=P.length,T=Promise.resolve(r);I<B;)T=T.then(P[I++],P[I++]);return T}B=h.length;let M=r;for(I=0;I<B;){let P=h[I++],L=h[I++];try{M=P(M)}catch(X){L.call(this,X);break}}try{T=Yp.call(this,M)}catch(P){return Promise.reject(P)}for(I=0,B=w.length;I<B;)T=T.then(w[I++],w[I++]);return T}getUri(t){t=Xs(this.defaults,t);let r=Io(t.baseURL,t.url);return To(r,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Fc.prototype[t]=function(r,i){return this.request(Xs(i||{},{method:t,url:r,data:(i||{}).data}))}});z.forEach(["post","put","patch"],function(t){function r(i){return function(a,u,h){return this.request(Xs(h||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}Fc.prototype[t]=r(),Fc.prototype[t+"Form"]=r(!0)});var _f=Fc;var Xm=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});let i=this;this.promise.then(n=>{if(!i._listeners)return;let a=i._listeners.length;for(;a-- >0;)i._listeners[a](n);i._listeners=null}),this.promise.then=n=>{let a,u=new Promise(h=>{i.subscribe(h),a=h}).then(n);return u.cancel=function(){i.unsubscribe(a)},u},t(function(a,u,h){i.reason||(i.reason=new Dn(a,u,h),r(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(n){t=n}),cancel:t}}},O2=Xm;function Ym(e){return function(r){return e.apply(null,r)}}function Zm(e){return z.isObject(e)&&e.isAxiosError===!0}var Jm={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Jm).forEach(([e,t])=>{Jm[t]=e});var k2=Jm;function N2(e){let t=new _f(e),r=of(_f.prototype.request,t);return z.extend(r,_f.prototype,t,{allOwnKeys:!0}),z.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return N2(Xs(e,n))},r}var Cr=N2(Dc);Cr.Axios=_f;Cr.CanceledError=Dn;Cr.CancelToken=O2;Cr.isCancel=pf;Cr.VERSION=Ao;Cr.toFormData=ka;Cr.AxiosError=Se;Cr.Cancel=Cr.CanceledError;Cr.all=function(t){return Promise.all(t)};Cr.spread=Ym;Cr.isAxiosError=Zm;Cr.mergeConfig=Xs;Cr.AxiosHeaders=Vr;Cr.formToJSON=e=>Vp(z.isHTMLForm(e)?new FormData(e):e);Cr.getAdapter=Xp.getAdapter;Cr.HttpStatusCode=k2;Cr.default=Cr;var vn=Cr;var{Axios:OV,AxiosError:kV,CanceledError:NV,isCancel:PV,CancelToken:BV,VERSION:MV,all:CV,Cancel:LV,isAxiosError:DV,spread:UV,toFormData:qV,AxiosHeaders:FV,HttpStatusCode:HV,formToJSON:zV,getAdapter:jV,mergeConfig:VV}=vn;function Hc(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function tN(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function rN(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Jp(e,...t){if(!rN(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function iN(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Hc(e.outputLen),Hc(e.blockLen)}function Qp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Qm(e,t){Jp(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var nN={number:Hc,bool:tN,bytes:Jp,hash:iN,exists:Qp,output:Qm},eh=nN;var th=BigInt(4294967295),P2=BigInt(32);function sN(e,t=!1){return t?{h:Number(e&th),l:Number(e>>P2&th)}:{h:Number(e>>P2&th)|0,l:Number(e&th)|0}}function B2(e,t=!1){let r=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let n=0;n<e.length;n++){let{h:a,l:u}=sN(e[n],t);[r[n],i[n]]=[a,u]}return[r,i]}var M2=(e,t,r)=>e<<r|t>>>32-r,C2=(e,t,r)=>t<<r|e>>>32-r,L2=(e,t,r)=>t<<r-32|e>>>64-r,D2=(e,t,r)=>e<<r-32|t>>>64-r;var U2=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function aN(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var oN=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!oN)throw new Error("Non little-endian hardware is not supported");function zc(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ih(e){if(typeof e=="string"&&(e=zc(e)),!aN(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var rh=class{clone(){return this._cloneInto()}},$V={}.toString;function q2(e){let t=i=>e().update(ih(i)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function F2(e){let t=(i,n)=>e(n).update(ih(i)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=i=>e(i),t}var[j2,V2,K2]=[[],[],[]],cN=BigInt(0),yf=BigInt(1),uN=BigInt(2),fN=BigInt(7),lN=BigInt(256),pN=BigInt(113);for(let e=0,t=yf,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],j2.push(2*(5*i+r)),V2.push((e+1)*(e+2)/2%64);let n=cN;for(let a=0;a<7;a++)t=(t<<yf^(t>>fN)*pN)%lN,t&uN&&(n^=yf<<(yf<<BigInt(a))-yf);K2.push(n)}var[hN,dN]=B2(K2,!0),H2=(e,t,r)=>r>32?L2(e,t,r):M2(e,t,r),z2=(e,t,r)=>r>32?D2(e,t,r):C2(e,t,r);function mN(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let u=0;u<10;u++)r[u]=e[u]^e[u+10]^e[u+20]^e[u+30]^e[u+40];for(let u=0;u<10;u+=2){let h=(u+8)%10,b=(u+2)%10,w=r[b],T=r[b+1],I=H2(w,T,1)^r[h],B=z2(w,T,1)^r[h+1];for(let M=0;M<50;M+=10)e[u+M]^=I,e[u+M+1]^=B}let n=e[2],a=e[3];for(let u=0;u<24;u++){let h=V2[u],b=H2(n,a,h),w=z2(n,a,h),T=j2[u];n=e[T],a=e[T+1],e[T]=b,e[T+1]=w}for(let u=0;u<50;u+=10){for(let h=0;h<10;h++)r[h]=e[u+h];for(let h=0;h<10;h++)e[u+h]^=~r[(h+2)%10]&r[(h+4)%10]}e[0]^=hN[i],e[1]^=dN[i]}r.fill(0)}var nh=class e extends rh{constructor(t,r,i,n=!1,a=24){if(super(),this.blockLen=t,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Hc(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=U2(this.state)}keccak(){mN(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Qp(this);let{blockLen:r,state:i}=this;t=ih(t);let n=t.length;for(let a=0;a<n;){let u=Math.min(r-this.pos,n-a);for(let h=0;h<u;h++)i[this.pos++]^=t[a++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:i,blockLen:n}=this;t[i]^=r,r&128&&i===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){Qp(this,!1),Jp(t),this.finish();let r=this.state,{blockLen:i}=this;for(let n=0,a=t.length;n<a;){this.posOut>=i&&this.keccak();let u=Math.min(i-this.posOut,a-n);t.set(r.subarray(this.posOut,this.posOut+u),n),this.posOut+=u,n+=u}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Hc(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Qm(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:r,suffix:i,outputLen:n,rounds:a,enableXOF:u}=this;return t||(t=new e(r,i,n,u,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=i,t.outputLen=n,t.enableXOF=u,t.destroyed=this.destroyed,t}},Ma=(e,t,r)=>q2(()=>new nh(t,e,r)),QV=Ma(6,144,224/8),eK=Ma(6,136,256/8),tK=Ma(6,104,384/8),rK=Ma(6,72,512/8),W2=Ma(1,144,224/8),ev=Ma(1,136,256/8),G2=Ma(1,104,384/8),$2=Ma(1,72,512/8),X2=(e,t,r)=>F2((i={})=>new nh(t,e,i.dkLen===void 0?r:i.dkLen,!0)),iK=X2(31,168,128/8),nK=X2(31,136,256/8);var uK=eh.bool,fK=eh.bytes;function wf(e){return t=>(eh.bytes(t),e(t))}var lK=(()=>{let e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,t=typeof module<"u"&&typeof module.require=="function"&&module.require.bind(module);return{node:t&&!e?t("crypto"):void 0,web:e}})();var vK=wf(W2),Sf=(()=>{let e=wf(ev);return e.create=ev.create,e})(),gK=wf(G2),bK=wf($2);var Kr=class extends Error{constructor(t,r){super(t),this.innerError=r,this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(new.target.constructor):this.stack=new Error().stack}static convertToString(t,r=!1){if(t==null)return"undefined";let i=JSON.stringify(t,(n,a)=>typeof a=="bigint"?a.toString():a);return r&&["bigint","string"].includes(typeof t)?i.replace(/['\\"]+/g,""):i}toJSON(){return{name:this.name,code:this.code,message:this.message,innerError:this.innerError}}},Ys=class extends Kr{constructor(t,r){super(`Invalid value given "${Kr.convertToString(t,!0)}". Error: ${r}.`),this.name=this.constructor.name}};var Ca=class extends Ys{constructor(t){super(t,"can not parse as byte data"),this.code=1002}},Ef=class extends Ys{constructor(t){super(t,"can not parse as number data"),this.code=1003}};var sh=class extends Ys{constructor(t){super(t,"can not be converted to hex"),this.code=1006}};var Y2="An Rpc error has occured with a code of *code*",Yi={[-32700]:{message:"Parse error",description:"Invalid JSON"},[-32600]:{message:"Invalid request",description:"JSON is not a valid request object "},[-32601]:{message:"Method not found",description:"Method does not exist "},[-32602]:{message:"Invalid params",description:"Invalid method parameters"},[-32603]:{message:"Internal error",description:"Internal JSON-RPC error"},[-32e3]:{message:"Invalid input",description:"Missing or invalid parameters"},[-32001]:{message:"Resource not found",description:"Requested resource not found"},[-32002]:{message:"Resource unavailable",description:"Requested resource not available"},[-32003]:{message:"Transaction rejected",description:"Transaction creation failed"},[-32004]:{message:"Method not supported",description:"Method is not implemented"},[-32005]:{message:"Limit exceeded",description:"Request exceeds defined limit"},[-32006]:{message:"JSON-RPC version not supported",description:"Version of JSON-RPC protocol is not supported"},[4001]:{name:"User Rejected Request",message:"The user rejected the request."},[4100]:{name:"Unauthorized",message:"The requested method and/or account has not been authorized by the user."},[4200]:{name:"Unsupported Method",message:"The Provider does not support the requested method."},[4900]:{name:"Disconnected",message:"The Provider is disconnected from all chains."},[4901]:{name:"Chain Disconnected",message:"The Provider is not connected to the requested chain."},"0-999":{name:"",message:"Not used."},1e3:{name:"Normal Closure",message:"The connection successfully completed the purpose for which it was created."},1001:{name:"Going Away",message:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{name:"Protocol error",message:"The endpoint is terminating the connection due to a protocol error."},1003:{name:"Unsupported Data",message:"The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)"},1004:{name:"Reserved",message:"Reserved. A meaning might be defined in the future."},1005:{name:"No Status Rcvd",message:"Reserved. Indicates that no status code was provided even though one was expected."},1006:{name:"Abnormal Closure",message:"Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{name:"Invalid frame payload data",message:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{name:"Policy Violation",message:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{name:"Message Too Big",message:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{name:"Mandatory Ext.",message:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{name:"Internal Error",message:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{name:"Service Restart",message:"The server is terminating the connection because it is restarting."},1013:{name:"Try Again Later",message:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{name:"Bad Gateway",message:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{name:"TLS handshake",message:"Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},"1016-2999":{name:"",message:"For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications."},"3000-3999":{name:"",message:"For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol."},"4000-4999":{name:"",message:"For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol."}};var Ni=class extends Kr{constructor(t,r){super(r??Y2.replace("*code*",t.error.code.toString())),this.code=t.error.code,this.id=t.id,this.jsonrpc=t.jsonrpc,this.jsonRpcError=t.error}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{error:this.jsonRpcError,id:this.id,jsonRpc:this.jsonrpc})}};var tv=class extends Ni{constructor(t){super(t,Yi[-32700].message),this.code=-32700}},rv=class extends Ni{constructor(t){super(t,Yi[-32600].message),this.code=-32600}},iv=class extends Ni{constructor(t){super(t,Yi[-32601].message),this.code=-32601}},nv=class extends Ni{constructor(t){super(t,Yi[-32602].message),this.code=-32602}},sv=class extends Ni{constructor(t){super(t,Yi[-32603].message),this.code=-32603}},av=class extends Ni{constructor(t){super(t,Yi[-32e3].message),this.code=-32e3}},ov=class extends Ni{constructor(t){super(t,Yi[-32004].message),this.code=-32004}},cv=class extends Ni{constructor(t){super(t,Yi[-32002].message),this.code=-32002}},uv=class extends Ni{constructor(t){super(t,Yi[-32001].message),this.code=-32001}},fv=class extends Ni{constructor(t){super(t,Yi[-32006].message),this.code=-32006}},lv=class extends Ni{constructor(t){super(t,Yi[-32003].message),this.code=-32003}},pv=class extends Ni{constructor(t){super(t,Yi[-32005].message),this.code=-32005}},Zi=new Map;Zi.set(-32700,{error:tv});Zi.set(-32600,{error:rv});Zi.set(-32601,{error:iv});Zi.set(-32602,{error:nv});Zi.set(-32603,{error:sv});Zi.set(-32e3,{error:av});Zi.set(-32004,{error:ov});Zi.set(-32002,{error:cv});Zi.set(-32003,{error:lv});Zi.set(-32001,{error:uv});Zi.set(-32006,{error:fv});Zi.set(-32005,{error:pv});var ah=class extends Kr{constructor(t){super(`Format for the type ${t} is unsupported`),this.type=t,this.code=1200}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{type:this.type})}};var Et;(function(e){e.assertEqual=n=>n;function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let a={};for(let u of n)a[u]=u;return a},e.getValidEnumValues=n=>{let a=e.objectKeys(n).filter(h=>typeof n[n[h]]!="number"),u={};for(let h of a)u[h]=n[h];return e.objectValues(u)},e.objectValues=n=>e.objectKeys(n).map(function(a){return n[a]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let u in n)Object.prototype.hasOwnProperty.call(n,u)&&a.push(u);return a},e.find=(n,a)=>{for(let u of n)if(a(u))return u},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function i(n,a=" | "){return n.map(u=>typeof u=="string"?`'${u}'`:u).join(a)}e.joinValues=i,e.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(Et||(Et={}));var dv;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(dv||(dv={}));var xe=Et.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),La=e=>{switch(typeof e){case"undefined":return xe.undefined;case"string":return xe.string;case"number":return isNaN(e)?xe.nan:xe.number;case"boolean":return xe.boolean;case"function":return xe.function;case"bigint":return xe.bigint;case"symbol":return xe.symbol;case"object":return Array.isArray(e)?xe.array:e===null?xe.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?xe.promise:typeof Map<"u"&&e instanceof Map?xe.map:typeof Set<"u"&&e instanceof Set?xe.set:typeof Date<"u"&&e instanceof Date?xe.date:xe.object;default:return xe.unknown}},le=Et.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),IN=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Ji=class extends Error{constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(a){return a.message},i={_errors:[]},n=a=>{for(let u of a.issues)if(u.code==="invalid_union")u.unionErrors.map(n);else if(u.code==="invalid_return_type")n(u.returnTypeError);else if(u.code==="invalid_arguments")n(u.argumentsError);else if(u.path.length===0)i._errors.push(r(u));else{let h=i,b=0;for(;b<u.path.length;){let w=u.path[b];b===u.path.length-1?(h[w]=h[w]||{_errors:[]},h[w]._errors.push(r(u))):h[w]=h[w]||{_errors:[]},h=h[w],b++}}};return n(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,Et.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},i=[];for(let n of this.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Ji.create=e=>new Ji(e);var Df=(e,t)=>{let r;switch(e.code){case le.invalid_type:e.received===xe.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case le.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Et.jsonStringifyReplacer)}`;break;case le.unrecognized_keys:r=`Unrecognized key(s) in object: ${Et.joinValues(e.keys,", ")}`;break;case le.invalid_union:r="Invalid input";break;case le.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Et.joinValues(e.options)}`;break;case le.invalid_enum_value:r=`Invalid enum value. Expected ${Et.joinValues(e.options)}, received '${e.received}'`;break;case le.invalid_arguments:r="Invalid function arguments";break;case le.invalid_return_type:r="Invalid function return type";break;case le.invalid_date:r="Invalid date";break;case le.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Et.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case le.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case le.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case le.custom:r="Invalid input";break;case le.invalid_intersection_types:r="Intersection results could not be merged";break;case le.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case le.not_finite:r="Number must be finite";break;default:r=t.defaultError,Et.assertNever(e)}return{message:r}},Q2=Df;function RN(e){Q2=e}function ch(){return Q2}var uh=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],u={...n,path:a},h="",b=i.filter(w=>!!w).slice().reverse();for(let w of b)h=w(u,{data:t,defaultError:h}).message;return{...n,path:a,message:n.message||h}},AN=[];function we(e,t){let r=uh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,ch(),Df].filter(i=>!!i)});e.common.issues.push(r)}var li=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let i=[];for(let n of r){if(n.status==="aborted")return je;n.status==="dirty"&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let n of r)i.push({key:await n.key,value:await n.value});return e.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:a,value:u}=n;if(a.status==="aborted"||u.status==="aborted")return je;a.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof u.value<"u"||n.alwaysSet)&&(i[a.value]=u.value)}return{status:t.value,value:i}}},je=Object.freeze({status:"aborted"}),ew=e=>({status:"dirty",value:e}),_i=e=>({status:"valid",value:e}),mv=e=>e.status==="aborted",vv=e=>e.status==="dirty",Uf=e=>e.status==="valid",fh=e=>typeof Promise<"u"&&e instanceof Promise,ke;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ke||(ke={}));var gn=class{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Z2=(e,t)=>{if(Uf(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ji(e.common.issues);return this._error=r,this._error}}};function it(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(u,h)=>u.code!=="invalid_type"?{message:h.defaultError}:typeof h.data>"u"?{message:i??h.defaultError}:{message:r??h.defaultError},description:n}}var nt=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return La(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:La(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new li,ctx:{common:t.parent.common,data:t.data,parsedType:La(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(fh(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){var i;let n={common:{issues:[],async:(i=r?.async)!==null&&i!==void 0?i:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:La(t)},a=this._parseSync({data:t,path:n.path,parent:n});return Z2(n,a)}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:La(t)},n=this._parse({data:t,path:i.path,parent:i}),a=await(fh(n)?n:Promise.resolve(n));return Z2(i,a)}refine(t,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{let u=t(n),h=()=>a.addIssue({code:le.custom,...i(n)});return typeof Promise<"u"&&u instanceof Promise?u.then(b=>b?!0:(h(),!1)):u?!0:(h(),!1)})}refinement(t,r){return this._refinement((i,n)=>t(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(t){return new Qi({schema:this,typeName:Ce.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Un.create(this,this._def)}nullable(){return Qs.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Js.create(this,this._def)}promise(){return qa.create(this,this._def)}or(t){return Lo.create([this,t],this._def)}and(t){return Do.create(this,t,this._def)}transform(t){return new Qi({...it(this._def),schema:this,typeName:Ce.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new zo({...it(this._def),innerType:this,defaultValue:r,typeName:Ce.ZodDefault})}brand(){return new dh({typeName:Ce.ZodBranded,type:this,...it(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new $c({...it(this._def),innerType:this,catchValue:r,typeName:Ce.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return qf.create(this,t)}readonly(){return Yc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ON=/^c[^\s-]{8,}$/i,kN=/^[a-z][a-z0-9]*$/,NN=/^[0-9A-HJKMNP-TV-Z]{26}$/,PN=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,BN=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,MN="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",hv,CN=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,LN=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,DN=e=>e.precision?e.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`):e.precision===0?e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function UN(e,t){return!!((t==="v4"||!t)&&CN.test(e)||(t==="v6"||!t)&&LN.test(e))}var Da=class e extends nt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==xe.string){let a=this._getOrReturnCtx(t);return we(a,{code:le.invalid_type,expected:xe.string,received:a.parsedType}),je}let i=new li,n;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),we(n,{code:le.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),we(n,{code:le.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="length"){let u=t.data.length>a.value,h=t.data.length<a.value;(u||h)&&(n=this._getOrReturnCtx(t,n),u?we(n,{code:le.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):h&&we(n,{code:le.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),i.dirty())}else if(a.kind==="email")BN.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"email",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="emoji")hv||(hv=new RegExp(MN,"u")),hv.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"emoji",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="uuid")PN.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"uuid",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid")ON.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"cuid",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid2")kN.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"cuid2",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="ulid")NN.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"ulid",code:le.invalid_string,message:a.message}),i.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),we(n,{validation:"url",code:le.invalid_string,message:a.message}),i.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"regex",code:le.invalid_string,message:a.message}),i.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),we(n,{code:le.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),i.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),we(n,{code:le.invalid_string,validation:{startsWith:a.value},message:a.message}),i.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),we(n,{code:le.invalid_string,validation:{endsWith:a.value},message:a.message}),i.dirty()):a.kind==="datetime"?DN(a).test(t.data)||(n=this._getOrReturnCtx(t,n),we(n,{code:le.invalid_string,validation:"datetime",message:a.message}),i.dirty()):a.kind==="ip"?UN(t.data,a.version)||(n=this._getOrReturnCtx(t,n),we(n,{validation:"ip",code:le.invalid_string,message:a.message}),i.dirty()):Et.assertNever(a);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:le.invalid_string,...ke.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ke.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ke.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ke.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ke.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ke.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ke.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ke.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ke.errToObj(t)})}datetime(t){var r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,...ke.errToObj(t?.message)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ke.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ke.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ke.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ke.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ke.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ke.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ke.errToObj(r)})}nonempty(t){return this.min(1,ke.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Da.create=e=>{var t;return new Da({checks:[],typeName:Ce.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...it(e)})};function qN(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i,a=parseInt(e.toFixed(n).replace(".","")),u=parseInt(t.toFixed(n).replace(".",""));return a%u/Math.pow(10,n)}var ko=class e extends nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==xe.number){let a=this._getOrReturnCtx(t);return we(a,{code:le.invalid_type,expected:xe.number,received:a.parsedType}),je}let i,n=new li;for(let a of this._def.checks)a.kind==="int"?Et.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),we(i,{code:le.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?qN(t.data,a.value)!==0&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),we(i,{code:le.not_finite,message:a.message}),n.dirty()):Et.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ke.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ke.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ke.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ke.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ke.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ke.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ke.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ke.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ke.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ke.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ke.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ke.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ke.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ke.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Et.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ko.create=e=>new ko({checks:[],typeName:Ce.ZodNumber,coerce:e?.coerce||!1,...it(e)});var No=class e extends nt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==xe.bigint){let a=this._getOrReturnCtx(t);return we(a,{code:le.invalid_type,expected:xe.bigint,received:a.parsedType}),je}let i,n=new li;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),we(i,{code:le.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Et.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ke.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ke.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ke.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ke.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ke.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ke.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ke.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ke.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ke.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ke.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};No.create=e=>{var t;return new No({checks:[],typeName:Ce.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...it(e)})};var Po=class extends nt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==xe.boolean){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.boolean,received:i.parsedType}),je}return _i(t.data)}};Po.create=e=>new Po({typeName:Ce.ZodBoolean,coerce:e?.coerce||!1,...it(e)});var Bo=class e extends nt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==xe.date){let a=this._getOrReturnCtx(t);return we(a,{code:le.invalid_type,expected:xe.date,received:a.parsedType}),je}if(isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return we(a,{code:le.invalid_date}),je}let i=new li,n;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),we(n,{code:le.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),i.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),we(n,{code:le.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),i.dirty()):Et.assertNever(a);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:ke.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ke.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Bo.create=e=>new Bo({checks:[],coerce:e?.coerce||!1,typeName:Ce.ZodDate,...it(e)});var Vc=class extends nt{_parse(t){if(this._getType(t)!==xe.symbol){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.symbol,received:i.parsedType}),je}return _i(t.data)}};Vc.create=e=>new Vc({typeName:Ce.ZodSymbol,...it(e)});var Mo=class extends nt{_parse(t){if(this._getType(t)!==xe.undefined){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.undefined,received:i.parsedType}),je}return _i(t.data)}};Mo.create=e=>new Mo({typeName:Ce.ZodUndefined,...it(e)});var Co=class extends nt{_parse(t){if(this._getType(t)!==xe.null){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.null,received:i.parsedType}),je}return _i(t.data)}};Co.create=e=>new Co({typeName:Ce.ZodNull,...it(e)});var Ua=class extends nt{constructor(){super(...arguments),this._any=!0}_parse(t){return _i(t.data)}};Ua.create=e=>new Ua({typeName:Ce.ZodAny,...it(e)});var Zs=class extends nt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return _i(t.data)}};Zs.create=e=>new Zs({typeName:Ce.ZodUnknown,...it(e)});var qn=class extends nt{_parse(t){let r=this._getOrReturnCtx(t);return we(r,{code:le.invalid_type,expected:xe.never,received:r.parsedType}),je}};qn.create=e=>new qn({typeName:Ce.ZodNever,...it(e)});var Kc=class extends nt{_parse(t){if(this._getType(t)!==xe.undefined){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.void,received:i.parsedType}),je}return _i(t.data)}};Kc.create=e=>new Kc({typeName:Ce.ZodVoid,...it(e)});var Js=class e extends nt{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==xe.array)return we(r,{code:le.invalid_type,expected:xe.array,received:r.parsedType}),je;if(n.exactLength!==null){let u=r.data.length>n.exactLength.value,h=r.data.length<n.exactLength.value;(u||h)&&(we(r,{code:u?le.too_big:le.too_small,minimum:h?n.exactLength.value:void 0,maximum:u?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(we(r,{code:le.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(we(r,{code:le.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((u,h)=>n.type._parseAsync(new gn(r,u,r.path,h)))).then(u=>li.mergeArray(i,u));let a=[...r.data].map((u,h)=>n.type._parseSync(new gn(r,u,r.path,h)));return li.mergeArray(i,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:ke.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:ke.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:ke.toString(r)}})}nonempty(t){return this.min(1,t)}};Js.create=(e,t)=>new Js({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ce.ZodArray,...it(t)});function jc(e){if(e instanceof Pi){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=Un.create(jc(i))}return new Pi({...e._def,shape:()=>t})}else return e instanceof Js?new Js({...e._def,type:jc(e.element)}):e instanceof Un?Un.create(jc(e.unwrap())):e instanceof Qs?Qs.create(jc(e.unwrap())):e instanceof us?us.create(e.items.map(t=>jc(t))):e}var Pi=class e extends nt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Et.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==xe.object){let w=this._getOrReturnCtx(t);return we(w,{code:le.invalid_type,expected:xe.object,received:w.parsedType}),je}let{status:i,ctx:n}=this._processInputParams(t),{shape:a,keys:u}=this._getCached(),h=[];if(!(this._def.catchall instanceof qn&&this._def.unknownKeys==="strip"))for(let w in n.data)u.includes(w)||h.push(w);let b=[];for(let w of u){let T=a[w],I=n.data[w];b.push({key:{status:"valid",value:w},value:T._parse(new gn(n,I,n.path,w)),alwaysSet:w in n.data})}if(this._def.catchall instanceof qn){let w=this._def.unknownKeys;if(w==="passthrough")for(let T of h)b.push({key:{status:"valid",value:T},value:{status:"valid",value:n.data[T]}});else if(w==="strict")h.length>0&&(we(n,{code:le.unrecognized_keys,keys:h}),i.dirty());else if(w!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let T of h){let I=n.data[T];b.push({key:{status:"valid",value:T},value:w._parse(new gn(n,I,n.path,T)),alwaysSet:T in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let w=[];for(let T of b){let I=await T.key;w.push({key:I,value:await T.value,alwaysSet:T.alwaysSet})}return w}).then(w=>li.mergeObjectSync(i,w)):li.mergeObjectSync(i,b)}get shape(){return this._def.shape()}strict(t){return ke.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,i)=>{var n,a,u,h;let b=(u=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,r,i).message)!==null&&u!==void 0?u:i.defaultError;return r.code==="unrecognized_keys"?{message:(h=ke.errToObj(t).message)!==null&&h!==void 0?h:b}:{message:b}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ce.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return Et.objectKeys(t).forEach(i=>{t[i]&&this.shape[i]&&(r[i]=this.shape[i])}),new e({...this._def,shape:()=>r})}omit(t){let r={};return Et.objectKeys(this.shape).forEach(i=>{t[i]||(r[i]=this.shape[i])}),new e({...this._def,shape:()=>r})}deepPartial(){return jc(this)}partial(t){let r={};return Et.objectKeys(this.shape).forEach(i=>{let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}),new e({...this._def,shape:()=>r})}required(t){let r={};return Et.objectKeys(this.shape).forEach(i=>{if(t&&!t[i])r[i]=this.shape[i];else{let a=this.shape[i];for(;a instanceof Un;)a=a._def.innerType;r[i]=a}}),new e({...this._def,shape:()=>r})}keyof(){return tw(Et.objectKeys(this.shape))}};Pi.create=(e,t)=>new Pi({shape:()=>e,unknownKeys:"strip",catchall:qn.create(),typeName:Ce.ZodObject,...it(t)});Pi.strictCreate=(e,t)=>new Pi({shape:()=>e,unknownKeys:"strict",catchall:qn.create(),typeName:Ce.ZodObject,...it(t)});Pi.lazycreate=(e,t)=>new Pi({shape:e,unknownKeys:"strip",catchall:qn.create(),typeName:Ce.ZodObject,...it(t)});var Lo=class extends nt{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function n(a){for(let h of a)if(h.result.status==="valid")return h.result;for(let h of a)if(h.result.status==="dirty")return r.common.issues.push(...h.ctx.common.issues),h.result;let u=a.map(h=>new Ji(h.ctx.common.issues));return we(r,{code:le.invalid_union,unionErrors:u}),je}if(r.common.async)return Promise.all(i.map(async a=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(n);{let a,u=[];for(let b of i){let w={...r,common:{...r.common,issues:[]},parent:null},T=b._parseSync({data:r.data,path:r.path,parent:w});if(T.status==="valid")return T;T.status==="dirty"&&!a&&(a={result:T,ctx:w}),w.common.issues.length&&u.push(w.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let h=u.map(b=>new Ji(b));return we(r,{code:le.invalid_union,unionErrors:h}),je}}get options(){return this._def.options}};Lo.create=(e,t)=>new Lo({options:e,typeName:Ce.ZodUnion,...it(t)});var oh=e=>e instanceof Uo?oh(e.schema):e instanceof Qi?oh(e.innerType()):e instanceof qo?[e.value]:e instanceof Fo?e.options:e instanceof Ho?Object.keys(e.enum):e instanceof zo?oh(e._def.innerType):e instanceof Mo?[void 0]:e instanceof Co?[null]:null,lh=class e extends nt{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==xe.object)return we(r,{code:le.invalid_type,expected:xe.object,received:r.parsedType}),je;let i=this.discriminator,n=r.data[i],a=this.optionsMap.get(n);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(we(r,{code:le.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),je)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let a of r){let u=oh(a.shape[t]);if(!u)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let h of u){if(n.has(h))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(h)}`);n.set(h,a)}}return new e({typeName:Ce.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...it(i)})}};function gv(e,t){let r=La(e),i=La(t);if(e===t)return{valid:!0,data:e};if(r===xe.object&&i===xe.object){let n=Et.objectKeys(t),a=Et.objectKeys(e).filter(h=>n.indexOf(h)!==-1),u={...e,...t};for(let h of a){let b=gv(e[h],t[h]);if(!b.valid)return{valid:!1};u[h]=b.data}return{valid:!0,data:u}}else if(r===xe.array&&i===xe.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let a=0;a<e.length;a++){let u=e[a],h=t[a],b=gv(u,h);if(!b.valid)return{valid:!1};n.push(b.data)}return{valid:!0,data:n}}else return r===xe.date&&i===xe.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Do=class extends nt{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(a,u)=>{if(mv(a)||mv(u))return je;let h=gv(a.value,u.value);return h.valid?((vv(a)||vv(u))&&r.dirty(),{status:r.value,value:h.data}):(we(i,{code:le.invalid_intersection_types}),je)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([a,u])=>n(a,u)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Do.create=(e,t,r)=>new Do({left:e,right:t,typeName:Ce.ZodIntersection,...it(r)});var us=class e extends nt{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==xe.array)return we(i,{code:le.invalid_type,expected:xe.array,received:i.parsedType}),je;if(i.data.length<this._def.items.length)return we(i,{code:le.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),je;!this._def.rest&&i.data.length>this._def.items.length&&(we(i,{code:le.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...i.data].map((u,h)=>{let b=this._def.items[h]||this._def.rest;return b?b._parse(new gn(i,u,i.path,h)):null}).filter(u=>!!u);return i.common.async?Promise.all(a).then(u=>li.mergeArray(r,u)):li.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};us.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new us({items:e,typeName:Ce.ZodTuple,rest:null,...it(t)})};var ph=class e extends nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==xe.object)return we(i,{code:le.invalid_type,expected:xe.object,received:i.parsedType}),je;let n=[],a=this._def.keyType,u=this._def.valueType;for(let h in i.data)n.push({key:a._parse(new gn(i,h,i.path,h)),value:u._parse(new gn(i,i.data[h],i.path,h))});return i.common.async?li.mergeObjectAsync(r,n):li.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return r instanceof nt?new e({keyType:t,valueType:r,typeName:Ce.ZodRecord,...it(i)}):new e({keyType:Da.create(),valueType:t,typeName:Ce.ZodRecord,...it(r)})}},Wc=class extends nt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==xe.map)return we(i,{code:le.invalid_type,expected:xe.map,received:i.parsedType}),je;let n=this._def.keyType,a=this._def.valueType,u=[...i.data.entries()].map(([h,b],w)=>({key:n._parse(new gn(i,h,i.path,[w,"key"])),value:a._parse(new gn(i,b,i.path,[w,"value"]))}));if(i.common.async){let h=new Map;return Promise.resolve().then(async()=>{for(let b of u){let w=await b.key,T=await b.value;if(w.status==="aborted"||T.status==="aborted")return je;(w.status==="dirty"||T.status==="dirty")&&r.dirty(),h.set(w.value,T.value)}return{status:r.value,value:h}})}else{let h=new Map;for(let b of u){let w=b.key,T=b.value;if(w.status==="aborted"||T.status==="aborted")return je;(w.status==="dirty"||T.status==="dirty")&&r.dirty(),h.set(w.value,T.value)}return{status:r.value,value:h}}}};Wc.create=(e,t,r)=>new Wc({valueType:t,keyType:e,typeName:Ce.ZodMap,...it(r)});var Gc=class e extends nt{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==xe.set)return we(i,{code:le.invalid_type,expected:xe.set,received:i.parsedType}),je;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(we(i,{code:le.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(we(i,{code:le.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let a=this._def.valueType;function u(b){let w=new Set;for(let T of b){if(T.status==="aborted")return je;T.status==="dirty"&&r.dirty(),w.add(T.value)}return{status:r.value,value:w}}let h=[...i.data.values()].map((b,w)=>a._parse(new gn(i,b,i.path,w)));return i.common.async?Promise.all(h).then(b=>u(b)):u(h)}min(t,r){return new e({...this._def,minSize:{value:t,message:ke.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:ke.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Gc.create=(e,t)=>new Gc({valueType:e,minSize:null,maxSize:null,typeName:Ce.ZodSet,...it(t)});var hh=class e extends nt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==xe.function)return we(r,{code:le.invalid_type,expected:xe.function,received:r.parsedType}),je;function i(h,b){return uh({data:h,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ch(),Df].filter(w=>!!w),issueData:{code:le.invalid_arguments,argumentsError:b}})}function n(h,b){return uh({data:h,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ch(),Df].filter(w=>!!w),issueData:{code:le.invalid_return_type,returnTypeError:b}})}let a={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof qa){let h=this;return _i(async function(...b){let w=new Ji([]),T=await h._def.args.parseAsync(b,a).catch(M=>{throw w.addIssue(i(b,M)),w}),I=await Reflect.apply(u,this,T);return await h._def.returns._def.type.parseAsync(I,a).catch(M=>{throw w.addIssue(n(I,M)),w})})}else{let h=this;return _i(function(...b){let w=h._def.args.safeParse(b,a);if(!w.success)throw new Ji([i(b,w.error)]);let T=Reflect.apply(u,this,w.data),I=h._def.returns.safeParse(T,a);if(!I.success)throw new Ji([n(T,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:us.create(t).rest(Zs.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,i){return new e({args:t||us.create([]).rest(Zs.create()),returns:r||Zs.create(),typeName:Ce.ZodFunction,...it(i)})}},Uo=class extends nt{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Uo.create=(e,t)=>new Uo({getter:e,typeName:Ce.ZodLazy,...it(t)});var qo=class extends nt{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return we(r,{received:r.data,code:le.invalid_literal,expected:this._def.value}),je}return{status:"valid",value:t.data}}get value(){return this._def.value}};qo.create=(e,t)=>new qo({value:e,typeName:Ce.ZodLiteral,...it(t)});function tw(e,t){return new Fo({values:e,typeName:Ce.ZodEnum,...it(t)})}var Fo=class e extends nt{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return we(r,{expected:Et.joinValues(i),received:r.parsedType,code:le.invalid_type}),je}if(this._def.values.indexOf(t.data)===-1){let r=this._getOrReturnCtx(t),i=this._def.values;return we(r,{received:r.data,code:le.invalid_enum_value,options:i}),je}return _i(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t){return e.create(t)}exclude(t){return e.create(this.options.filter(r=>!t.includes(r)))}};Fo.create=tw;var Ho=class extends nt{_parse(t){let r=Et.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==xe.string&&i.parsedType!==xe.number){let n=Et.objectValues(r);return we(i,{expected:Et.joinValues(n),received:i.parsedType,code:le.invalid_type}),je}if(r.indexOf(t.data)===-1){let n=Et.objectValues(r);return we(i,{received:i.data,code:le.invalid_enum_value,options:n}),je}return _i(t.data)}get enum(){return this._def.values}};Ho.create=(e,t)=>new Ho({values:e,typeName:Ce.ZodNativeEnum,...it(t)});var qa=class extends nt{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==xe.promise&&r.common.async===!1)return we(r,{code:le.invalid_type,expected:xe.promise,received:r.parsedType}),je;let i=r.parsedType===xe.promise?r.data:Promise.resolve(r.data);return _i(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};qa.create=(e,t)=>new qa({type:e,typeName:Ce.ZodPromise,...it(t)});var Qi=class extends nt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ce.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:u=>{we(i,u),u.fatal?r.abort():r.dirty()},get path(){return i.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let u=n.transform(i.data,a);return i.common.issues.length?{status:"dirty",value:i.data}:i.common.async?Promise.resolve(u).then(h=>this._def.schema._parseAsync({data:h,path:i.path,parent:i})):this._def.schema._parseSync({data:u,path:i.path,parent:i})}if(n.type==="refinement"){let u=h=>{let b=n.refinement(h,a);if(i.common.async)return Promise.resolve(b);if(b instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return h};if(i.common.async===!1){let h=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return h.status==="aborted"?je:(h.status==="dirty"&&r.dirty(),u(h.value),{status:r.value,value:h.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(h=>h.status==="aborted"?je:(h.status==="dirty"&&r.dirty(),u(h.value).then(()=>({status:r.value,value:h.value}))))}if(n.type==="transform")if(i.common.async===!1){let u=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Uf(u))return u;let h=n.transform(u.value,a);if(h instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:h}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(u=>Uf(u)?Promise.resolve(n.transform(u.value,a)).then(h=>({status:r.value,value:h})):u);Et.assertNever(n)}};Qi.create=(e,t,r)=>new Qi({schema:e,typeName:Ce.ZodEffects,effect:t,...it(r)});Qi.createWithPreprocess=(e,t,r)=>new Qi({schema:t,effect:{type:"preprocess",transform:e},typeName:Ce.ZodEffects,...it(r)});var Un=class extends nt{_parse(t){return this._getType(t)===xe.undefined?_i(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Un.create=(e,t)=>new Un({innerType:e,typeName:Ce.ZodOptional,...it(t)});var Qs=class extends nt{_parse(t){return this._getType(t)===xe.null?_i(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Qs.create=(e,t)=>new Qs({innerType:e,typeName:Ce.ZodNullable,...it(t)});var zo=class extends nt{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===xe.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};zo.create=(e,t)=>new zo({innerType:e,typeName:Ce.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...it(t)});var $c=class extends nt{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return fh(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ji(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ji(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};$c.create=(e,t)=>new $c({innerType:e,typeName:Ce.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...it(t)});var Xc=class extends nt{_parse(t){if(this._getType(t)!==xe.nan){let i=this._getOrReturnCtx(t);return we(i,{code:le.invalid_type,expected:xe.nan,received:i.parsedType}),je}return{status:"valid",value:t.data}}};Xc.create=e=>new Xc({typeName:Ce.ZodNaN,...it(e)});var FN=Symbol("zod_brand"),dh=class extends nt{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},qf=class e extends nt{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?je:a.status==="dirty"?(r.dirty(),ew(a.value)):this._def.out._parseAsync({data:a.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?je:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(t,r){return new e({in:t,out:r,typeName:Ce.ZodPipeline})}},Yc=class extends nt{_parse(t){let r=this._def.innerType._parse(t);return Uf(r)&&(r.value=Object.freeze(r.value)),r}};Yc.create=(e,t)=>new Yc({innerType:e,typeName:Ce.ZodReadonly,...it(t)});var rw=(e,t={},r)=>e?Ua.create().superRefine((i,n)=>{var a,u;if(!e(i)){let h=typeof t=="function"?t(i):typeof t=="string"?{message:t}:t,b=(u=(a=h.fatal)!==null&&a!==void 0?a:r)!==null&&u!==void 0?u:!0,w=typeof h=="string"?{message:h}:h;n.addIssue({code:"custom",...w,fatal:b})}}):Ua.create(),HN={object:Pi.lazycreate},Ce;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ce||(Ce={}));var zN=(e,t={message:`Input not instance of ${e.name}`})=>rw(r=>r instanceof e,t),iw=Da.create,nw=ko.create,jN=Xc.create,VN=No.create,sw=Po.create,KN=Bo.create,WN=Vc.create,GN=Mo.create,$N=Co.create,XN=Ua.create,YN=Zs.create,ZN=qn.create,JN=Kc.create,QN=Js.create,eP=Pi.create,tP=Pi.strictCreate,rP=Lo.create,iP=lh.create,nP=Do.create,sP=us.create,aP=ph.create,oP=Wc.create,cP=Gc.create,uP=hh.create,fP=Uo.create,lP=qo.create,pP=Fo.create,hP=Ho.create,dP=qa.create,J2=Qi.create,mP=Un.create,vP=Qs.create,gP=Qi.createWithPreprocess,bP=qf.create,xP=()=>iw().optional(),_P=()=>nw().optional(),yP=()=>sw().optional(),wP={string:e=>Da.create({...e,coerce:!0}),number:e=>ko.create({...e,coerce:!0}),boolean:e=>Po.create({...e,coerce:!0}),bigint:e=>No.create({...e,coerce:!0}),date:e=>Bo.create({...e,coerce:!0})},SP=je,Fn=Object.freeze({__proto__:null,defaultErrorMap:Df,setErrorMap:RN,getErrorMap:ch,makeIssue:uh,EMPTY_PATH:AN,addIssueToContext:we,ParseStatus:li,INVALID:je,DIRTY:ew,OK:_i,isAborted:mv,isDirty:vv,isValid:Uf,isAsync:fh,get util(){return Et},get objectUtil(){return dv},ZodParsedType:xe,getParsedType:La,ZodType:nt,ZodString:Da,ZodNumber:ko,ZodBigInt:No,ZodBoolean:Po,ZodDate:Bo,ZodSymbol:Vc,ZodUndefined:Mo,ZodNull:Co,ZodAny:Ua,ZodUnknown:Zs,ZodNever:qn,ZodVoid:Kc,ZodArray:Js,ZodObject:Pi,ZodUnion:Lo,ZodDiscriminatedUnion:lh,ZodIntersection:Do,ZodTuple:us,ZodRecord:ph,ZodMap:Wc,ZodSet:Gc,ZodFunction:hh,ZodLazy:Uo,ZodLiteral:qo,ZodEnum:Fo,ZodNativeEnum:Ho,ZodPromise:qa,ZodEffects:Qi,ZodTransformer:Qi,ZodOptional:Un,ZodNullable:Qs,ZodDefault:zo,ZodCatch:$c,ZodNaN:Xc,BRAND:FN,ZodBranded:dh,ZodPipeline:qf,ZodReadonly:Yc,custom:rw,Schema:nt,ZodSchema:nt,late:HN,get ZodFirstPartyTypeKind(){return Ce},coerce:wP,any:XN,array:QN,bigint:VN,boolean:sw,date:KN,discriminatedUnion:iP,effect:J2,enum:pP,function:uP,instanceof:zN,intersection:nP,lazy:fP,literal:lP,map:oP,nan:jN,nativeEnum:hP,never:ZN,null:$N,nullable:vP,number:nw,object:eP,oboolean:yP,onumber:_P,optional:mP,ostring:xP,pipeline:bP,preprocess:gP,promise:dP,record:aP,set:cP,strictObject:tP,string:iw,symbol:WN,transformer:J2,tuple:sP,undefined:GN,union:rP,unknown:YN,void:JN,NEVER:SP,ZodIssueCode:le,quotelessJson:IN,ZodError:Ji});var TP=e=>e.message?e.message:"unspecified error",ea=class extends Kr{constructor(t){super(),this.code=1100,this.errors=t,super.message=`Web3 validator found ${t.length} error[s]:
37
37
  ${this._compileErrors().join(`
38
- `)}`}_compileErrors(){return this.errors.map(TP)}};var Hn={};Oa(Hn,{abiSchemaToJsonSchema:()=>gh,codePointToInt:()=>uw,ensureIfUint8Array:()=>Sv,ethAbiToJsonSchema:()=>_v,fetchArrayElement:()=>yv,hexToNumber:()=>bh,hexToUint8Array:()=>xh,numberToHex:()=>wv,padLeft:()=>fw,parseBaseType:()=>fs,transformJsonDataToAbiFormat:()=>vh,uint8ArrayToHexString:()=>Ff});var aw=["bool","int","uint","bytes","string","address","tuple"];var bv=e=>typeof e=="object"&&"type"in e&&"name"in e;var ow=e=>typeof e=="string",hr=e=>typeof e=="string"&&/^((-)?0x[0-9a-f]+|(0x))$/i.test(e);var mh=e=>typeof e=="number"||typeof e=="bigint"||typeof e=="string"&&/^((-0x|0x|-)?[0-9a-f]+|(0x))$/i.test(e);var IP=["hex","number","blockNumber","blockNumberOrTag","filter","bloom"],fs=e=>{let t=e.replace(/ /,""),r,i=!1,n=[];if(e.includes("[")&&(t=t.slice(0,t.indexOf("[")),n=[...e.matchAll(/(?:\[(\d*)\])/g)].map(a=>parseInt(a[1],10)).map(a=>Number.isNaN(a)?-1:a),i=n.length>0),aw.includes(t))return{baseType:t,isArray:i,baseTypeSize:r,arraySizes:n};if(t.startsWith("int"))r=parseInt(t.substring(3),10),t="int";else if(t.startsWith("uint"))r=parseInt(e.substring(4),10),t="uint";else if(t.startsWith("bytes"))r=parseInt(t.substring(5),10),t="bytes";else return{baseType:void 0,isArray:!1,baseTypeSize:void 0,arraySizes:n};return{baseType:t,isArray:i,baseTypeSize:r,arraySizes:n}},xv=(e,t={})=>{if(Object.keys(t).includes("type"))throw new ea([{keyword:"eth",message:'Either "eth" or "type" can be presented in schema',params:{eth:e},instancePath:"",schemaPath:""}]);let{baseType:i,baseTypeSize:n}=fs(e);if(!i&&!IP.includes(e))throw new ea([{keyword:"eth",message:`Eth data type "${e}" is not valid`,params:{eth:e},instancePath:"",schemaPath:""}]);if(i){if(i==="tuple")throw new Error('"tuple" type is not implemented directly.');return{format:`${i}${n??""}`,required:!0}}return e?{format:e,required:!0}:{}},gh=(e,t="/0")=>{let r={type:"array",items:[],maxItems:e.length,minItems:e.length};for(let[i,n]of e.entries()){let a,u,h=[];bv(n)?(a=n.type,u=n.name,h=n.components):typeof n=="string"?(a=n,u=`${t}/${i}`):Array.isArray(n)&&(n[0]&&typeof n[0]=="string"&&n[0].startsWith("tuple")&&!Array.isArray(n[0])&&n[1]&&Array.isArray(n[1])?(a=n[0],u=`${t}/${i}`,h=n[1]):(a="tuple",u=`${t}/${i}`,h=n));let{baseType:b,isArray:w,arraySizes:T}=fs(a),I,B=r;for(let M=T.length-1;M>0;M-=1)I={type:"array",items:[],maxItems:T[M],minItems:T[M]},T[M]<0&&(delete I.maxItems,delete I.minItems),Array.isArray(B.items)?B.items.length===0?B.items=I:B.items.push(I):B.items=[B.items,I],B=I;if(b==="tuple"&&!w){let M=gh(h,u);M.$id=u,B.items.push(M)}else if(b==="tuple"&&w){let M=T[0],P={$id:u,type:"array",items:gh(h,u),maxItems:M,minItems:M};M<0&&(delete P.maxItems,delete P.minItems),B.items.push(P)}else if(w){let M=T[0],P={type:"array",$id:u,items:xv(String(b)),minItems:M,maxItems:M};M<0&&(delete P.maxItems,delete P.minItems),B.items.push(P)}else Array.isArray(B.items)?B.items.push(Object.assign({$id:u},xv(a))):B.items.items.push(Object.assign({$id:u},xv(a)));B=r}return r},_v=e=>gh(e),yv=(e,t)=>t===1?e:yv(e[0],t-1),vh=(e,t,r)=>{let i=[];for(let[n,a]of e.entries()){let u,h,b=[];bv(a)?(u=a.type,h=a.name,b=a.components):typeof a=="string"?u=a:Array.isArray(a)&&(a[1]&&Array.isArray(a[1])?(u=a[0],b=a[1]):(u="tuple",b=a));let{baseType:w,isArray:T,arraySizes:I}=fs(u),B=Array.isArray(t)?t[n]:t[h];if(w==="tuple"&&!T)i.push(vh(b,B,r));else if(w==="tuple"&&T){let M=[];for(let P of B)if(I.length>1){let L=yv(P,I.length-1),X=[];for(let V of L)X.push(vh(b,V,r));M.push(X)}else M.push(vh(b,P,r));i.push(M)}else i.push(B)}return r=r??[],r.push(...i),r},uw=e=>{if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-55;if(e>=97&&e<=102)return e-87;throw new Error(`Invalid code point: ${e}`)},bh=e=>{if(!hr(e))throw new Error("Invalid hex string");let[t,r]=e.startsWith("-")?[!0,e.slice(1)]:[!1,e],i=BigInt(r);return i>Number.MAX_SAFE_INTEGER?t?-i:i:i<Number.MIN_SAFE_INTEGER?i:t?-1*Number(i):Number(i)},wv=e=>{if((typeof e=="number"||typeof e=="bigint")&&e<0)return`-0x${e.toString(16).slice(1)}`;if((typeof e=="number"||typeof e=="bigint")&&e>=0)return`0x${e.toString(16)}`;if(typeof e=="string"&&hr(e)){let[t,r]=e.startsWith("-")?[!0,e.slice(1)]:[!1,e],i=r.split(/^(-)?0(x|X)/).slice(-1)[0];return`${t?"-":""}0x${i.replace(/^0+/,"").toLowerCase()}`}if(typeof e=="string"&&!hr(e))return wv(BigInt(e));throw new Ef(e)},fw=(e,t,r="0")=>{if(typeof e=="string"&&!hr(e))return e.padStart(t,r);let i=typeof e=="string"&&hr(e)?e:wv(e),[n,a]=i.startsWith("-")?["-0x",i.slice(3)]:["0x",i.slice(2)];return`${n}${a.padStart(t,r)}`};function Ff(e){let t="0x";for(let r of e){let i=r.toString(16);t+=i.length===1?`0${i}`:i}return t}var ta={zero:48,nine:57,A:65,F:70,a:97,f:102};function cw(e){if(e>=ta.zero&&e<=ta.nine)return e-ta.zero;if(e>=ta.A&&e<=ta.F)return e-(ta.A-10);if(e>=ta.a&&e<=ta.f)return e-(ta.a-10)}function xh(e){let t=0;if(e.startsWith("0")&&(e[1]==="x"||e[1]==="X")&&(t=2),e.length%2!==0)throw new Ca(`hex string has odd length: ${e}`);let r=(e.length-t)/2,i=new Uint8Array(r);for(let n=0,a=t;n<r;n+=1){let u=cw(e.charCodeAt(a++)),h=cw(e.charCodeAt(a++));if(u===void 0||h===void 0)throw new Ca(`Invalid byte sequence ("${e[a-2]}${e[a-1]}" in "${e}").`);i[n]=u*16+h}return i}function Sv(e){var t;return!(e instanceof Uint8Array)&&((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"?Uint8Array.from(e):e}var _h=e=>{var t;return e instanceof Uint8Array||((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"},Ev=(e,t={abiType:"bytes"})=>{if(typeof e!="string"&&!Array.isArray(e)&&!_h(e)||typeof e=="string"&&hr(e)&&e.startsWith("-")||typeof e=="string"&&!hr(e))return!1;let r;if(typeof e=="string"){if(e.length%2!==0)return!1;r=xh(e)}else if(Array.isArray(e)){if(e.some(i=>i<0||i>255||!Number.isInteger(i)))return!1;r=new Uint8Array(e)}else r=e;if(t?.abiType){let{baseTypeSize:i}=fs(t.abiType);return i?r.length===i:!0}return t?.size?r.length===t?.size:!0};var lw=e=>{if(!/^(0x)?[0-9a-f]{40}$/i.test(e))return!1;let t=e.slice(2),r=zc(t.toLowerCase()),i=Ff(Sf(Sv(r))).slice(2);for(let n=0;n<40;n+=1)if(parseInt(i[n],16)>7&&t[n].toUpperCase()!==t[n]||parseInt(i[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},ls=(e,t=!0)=>{if(typeof e!="string"&&!_h(e))return!1;let r;return _h(e)?r=Ff(e):typeof e=="string"&&!hr(e)?r=e.toLowerCase().startsWith("0x")?e:`0x${e}`:r=e,/^(0x)?[0-9a-f]{40}$/i.test(r)?/^(0x|0X)?[0-9a-f]{40}$/.test(r)||/^(0x|0X)?[0-9A-F]{40}$/.test(r)?!0:t?lw(r):!0:!1};var Hf;(function(e){e.NUMBER="NUMBER_NUMBER",e.HEX="NUMBER_HEX",e.STR="NUMBER_STR",e.BIGINT="NUMBER_BIGINT"})(Hf||(Hf={}));var zf;(function(e){e.HEX="BYTES_HEX",e.UINT8ARRAY="BYTES_UINT8ARRAY"})(zf||(zf={}));var H$={number:Hf.BIGINT,bytes:zf.HEX},z$={number:Hf.HEX,bytes:zf.HEX};var jf;(function(e){e.EARLIEST="earliest",e.LATEST="latest",e.PENDING="pending",e.SAFE="safe",e.FINALIZED="finalized"})(jf||(jf={}));var pw;(function(e){e.chainstart="chainstart",e.frontier="frontier",e.homestead="homestead",e.dao="dao",e.tangerineWhistle="tangerineWhistle",e.spuriousDragon="spuriousDragon",e.byzantium="byzantium",e.constantinople="constantinople",e.petersburg="petersburg",e.istanbul="istanbul",e.muirGlacier="muirGlacier",e.berlin="berlin",e.london="london",e.altair="altair",e.arrowGlacier="arrowGlacier",e.grayGlacier="grayGlacier",e.bellatrix="bellatrix",e.merge="merge",e.capella="capella",e.shanghai="shanghai"})(pw||(pw={}));var hw=Object.getPrototypeOf(Uint8Array);var dw=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function h(T){try{w(i.next(T))}catch(I){u(I)}}function b(T){try{w(i.throw(T))}catch(I){u(I)}}function w(T){T.done?a(T.value):n(T.value).then(h,b)}w((i=i.apply(e,t||[])).next())})},mw=Symbol.for("web3/base-provider"),Tv=class e{static isWeb3Provider(t){return t instanceof e||!!(t&&t[mw])}get[mw](){return!0}send(t,r){this.request(t).then(i=>{r(null,i)}).catch(i=>{r(i)})}sendAsync(t){return dw(this,void 0,void 0,function*(){return this.request(t)})}asEIP1193Provider(){let t=Object.create(this),r=t.request;return t.request=function(n){return dw(this,void 0,void 0,function*(){return(yield r(n)).result})},t.asEIP1193Provider=void 0,t}};var yh=(e,t)=>{let r=e;for(let i=1;i<t;i+=1)r*=e;return r},Fa=(e,t={abiType:"uint"})=>{if(!["number","string","bigint"].includes(typeof e)||typeof e=="string"&&e.length===0)return!1;let r;if(t?.abiType){let{baseTypeSize:n}=fs(t.abiType);n&&(r=n)}else t.bitSize&&(r=t.bitSize);let i=yh(BigInt(2),BigInt(r??256))-BigInt(1);try{let n=typeof e=="string"&&hr(e)?BigInt(bh(e)):BigInt(e);return n>=0&&n<=i}catch{return!1}},jo=(e,t={abiType:"int"})=>{if(!["number","string","bigint"].includes(typeof e)||typeof e=="number"&&e>Number.MAX_SAFE_INTEGER)return!1;let r;if(t?.abiType){let{baseTypeSize:a,baseType:u}=fs(t.abiType);if(u!=="int")return!1;a&&(r=a)}else t.bitSize&&(r=t.bitSize);let i=yh(BigInt(2),BigInt((r??256)-1)),n=BigInt(-1)*yh(BigInt(2),BigInt((r??256)-1));try{let a=typeof e=="string"&&hr(e)?BigInt(bh(e)):BigInt(e);return a>=n&&a<=i}catch{return!1}},vw=e=>!!(jo(e)||typeof e=="string"&&/[0-9.]/.test(e)&&e.indexOf(".")===e.lastIndexOf(".")||typeof e=="number");var Iv=e=>Fa(e),wh=e=>Object.values(jf).includes(e),Vf=e=>wh(e)||Iv(e);var Sh=e=>typeof e!="string"||!/^(0x)?[0-9a-f]{512}$/i.test(e)?!1:!!(/^(0x)?[0-9a-f]{512}$/.test(e)||/^(0x)?[0-9A-F]{512}$/.test(e));var gw=e=>["number","string","boolean"].includes(typeof e)?typeof e=="boolean"?!0:typeof e=="string"&&!hr(e)?e==="1"||e==="0":typeof e=="string"&&hr(e)?e==="0x1"||e==="0x0":e===1||e===0:!1;var Bi=e=>e==null;var Eh=e=>typeof e!="string"||!/^(0x)?[0-9a-f]{64}$/i.test(e)?!1:!!(/^(0x)?[0-9a-f]{64}$/.test(e)||/^(0x)?[0-9A-F]{64}$/.test(e));var bw=e=>{let t=["fromBlock","toBlock","address","topics","blockHash"];if(Bi(e)||typeof e!="object"||!Object.keys(e).every(r=>t.includes(r))||!Bi(e.fromBlock)&&!Vf(e.fromBlock)||!Bi(e.toBlock)&&!Vf(e.toBlock))return!1;if(!Bi(e.address)){if(Array.isArray(e.address)){if(!e.address.every(r=>ls(r)))return!1}else if(!ls(e.address))return!1}return!(!Bi(e.topics)&&!e.topics.every(r=>Bi(r)?!0:Array.isArray(r)?r.every(i=>Eh(i)):!!Eh(r)))};var Zc={address:e=>ls(e),bloom:e=>Sh(e),blockNumber:e=>Iv(e),blockTag:e=>wh(e),blockNumberOrTag:e=>Vf(e),bool:e=>gw(e),bytes:e=>Ev(e),filter:e=>bw(e),hex:e=>hr(e),uint:e=>Fa(e),int:e=>jo(e),number:e=>vw(e),string:e=>ow(e)};for(let e=8;e<=256;e+=8)Zc[`int${e}`]=t=>jo(t,{bitSize:e}),Zc[`uint${e}`]=t=>Fa(t,{bitSize:e});for(let e=1;e<=32;e+=1)Zc[`bytes${e}`]=t=>Ev(t,{size:e});Zc.bytes256=Zc.bytes;var Rv=Zc;var Kf=e=>{if((!e?.type||e?.type==="object")&&e?.properties){let t={};for(let r of Object.keys(e.properties)){let i=Kf(e.properties[r]);i&&(t[r]=i)}return Array.isArray(e.required)?Fn.object(t).partial().required(e.required.reduce((r,i)=>Object.assign(Object.assign({},r),{[i]:!0}),{})):Fn.object(t).partial()}if(e?.type==="array"&&e?.items){if(Array.isArray(e.items)&&e.items.length>0){let t=[];for(let r of e.items){let i=Kf(r);i&&t.push(i)}return Fn.tuple(t)}return Fn.array(Kf(e.items))}if(e.oneOf&&Array.isArray(e.oneOf))return Fn.union(e.oneOf.map(t=>Kf(t)));if(e?.format){if(!Rv[e.format])throw new ah(e.format);return Fn.any().refine(Rv[e.format],t=>({params:{value:t,format:e.format}}))}return e?.type&&e?.type!=="object"&&typeof Fn[String(e.type)]=="function"?Fn[String(e.type)]():Fn.object({data:Fn.any()}).partial()},Th=class e{static factory(){return e.validatorInstance||(e.validatorInstance=new e),e.validatorInstance}validate(t,r,i){var n,a;let h=Kf(t).safeParse(r);if(!h.success){let b=this.convertErrors((a=(n=h.error)===null||n===void 0?void 0:n.issues)!==null&&a!==void 0?a:[]);if(b){if(i?.silent)return b;throw new ea(b)}}}convertErrors(t){if(t&&Array.isArray(t)&&t.length>0)return t.map(r=>{var i;let n,a,u,h;h=r.path.join("/");let b=String(r.path[r.path.length-1]),w=r.path.join("/");if(r.code===le.too_big)a="maxItems",h=`${w}/maxItems`,u={limit:r.maximum},n=`must NOT have more than ${r.maximum} items`;else if(r.code===le.too_small)a="minItems",h=`${w}/minItems`,u={limit:r.minimum},n=`must NOT have fewer than ${r.minimum} items`;else if(r.code===le.custom){let{value:T,format:I}=(i=r.params)!==null&&i!==void 0?i:{};typeof T>"u"?n=`value at "/${h}" is required`:n=`value "${typeof T=="object"?JSON.stringify(T):T}" at "/${h}" must pass "${I}" validation`,u={value:T}}return{keyword:a??b,instancePath:w?`/${w}`:"",schemaPath:h?`#${h}`:"#",params:u??{value:r.message},message:n??r.message}})}};var Ih=class{constructor(){this._validator=Th.factory()}validateJSONSchema(t,r,i){return this._validator.validate(t,r,i)}validate(t,r,i={silent:!1}){var n,a;let u=_v(t);if(!(Array.isArray(u.items)&&((n=u.items)===null||n===void 0?void 0:n.length)===0&&r.length===0)){if(Array.isArray(u.items)&&((a=u.items)===null||a===void 0?void 0:a.length)===0&&r.length!==0)throw new ea([{instancePath:"/0",schemaPath:"/",keyword:"required",message:"empty schema against data can not be validated",params:r}]);return this._validator.validate(u,r,i)}}};var Wf=new Ih;function Av(e){var t;return e instanceof Uint8Array||((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"}var AY={noether:BigInt(0),wei:BigInt(1),kwei:BigInt(1e3),Kwei:BigInt(1e3),babbage:BigInt(1e3),femtoether:BigInt(1e3),mwei:BigInt(1e6),Mwei:BigInt(1e6),lovelace:BigInt(1e6),picoether:BigInt(1e6),gwei:BigInt(1e9),Gwei:BigInt(1e9),shannon:BigInt(1e9),nanoether:BigInt(1e9),nano:BigInt(1e9),szabo:BigInt(1e12),microether:BigInt(1e12),micro:BigInt(1e12),finney:BigInt(1e15),milliether:BigInt(1e15),milli:BigInt(1e15),ether:BigInt("1000000000000000000"),kether:BigInt("1000000000000000000000"),grand:BigInt("1000000000000000000000"),mether:BigInt("1000000000000000000000000"),gether:BigInt("1000000000000000000000000000"),tether:BigInt("1000000000000000000000000000000")},kv=e=>{if(Wf.validate(["bytes"],[e]),Av(e))return e;if(Array.isArray(e))return new Uint8Array(e);if(typeof e=="string")return Hn.hexToUint8Array(e);throw new Ca(e)},{uint8ArrayToHexString:kP}=Hn,Gf=e=>kP(kv(e));var Jc=(e,t)=>{typeof e!="bigint"&&Wf.validate(["int"],[e]);let r=Hn.numberToHex(e);return t&&(!r.startsWith("-")&&r.length%2===1?r="0x0".concat(r.slice(2)):r.length%2===0&&r.startsWith("-")&&(r="-0x0".concat(r.slice(3)))),r};var Ov=e=>{Wf.validate(["string"],[e]);let t=e.replace(/^(?:\u0000)/,"");return t=t.replace(/(?:\u0000)$/,""),Gf(new TextEncoder().encode(t))};var $f=(e,t)=>{if(typeof e=="string"&&ls(e))return t?"address":`0x${e.toLowerCase().replace(/^0x/i,"")}`;if(typeof e=="boolean")return t?"bool":e?"0x01":"0x00";if(typeof e=="number")return t?e<0?"int256":"uint256":Jc(e);if(typeof e=="bigint")return t?"bigint":Jc(e);if(typeof e=="object"&&e)return t?"string":Ov(JSON.stringify(e));if(typeof e=="string"){if(e.startsWith("-0x")||e.startsWith("-0X"))return t?"int256":Jc(e);if(hr(e))return t?"bytes":e;if(mh(e)&&!jo(e)&&!Fa(e))return t?"bytes":`0x${e}`;if(mh(e)&&!jo(e)&&Fa(e))return t?"uint":Jc(e);if(!Number.isFinite(e))return t?"string":Ov(e)}throw new sh(e)};var yw=Yr(_w(),1);var{parseBaseType:uZ}=Hn;var CP;CP=Symbol.toStringTag;var LP=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Pv=Math.ceil,xn=Math.floor,Mi="[BigNumber Error] ",Sw=Mi+"Number primitive has more than 15 significant digits: ",zn=1e14,tt=14,Bv=9007199254740991,Mv=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Ha=1e7,Zr=1e9;function Ew(e){var t,r,i,n=q.prototype={constructor:q,toString:null,valueOf:null},a=new q(1),u=20,h=4,b=-7,w=21,T=-1e7,I=1e7,B=!1,M=1,P=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},X="0123456789abcdefghijklmnopqrstuvwxyz",V=!0;function q(O,E){var f,c,p,v,g,x,S,_,l=this;if(!(l instanceof q))return new q(O,E);if(E==null){if(O&&O._isBigNumber===!0){l.s=O.s,!O.c||O.e>I?l.c=l.e=null:O.e<T?l.c=[l.e=0]:(l.e=O.e,l.c=O.c.slice());return}if((x=typeof O=="number")&&O*0==0){if(l.s=1/O<0?(O=-O,-1):1,O===~~O){for(v=0,g=O;g>=10;g/=10,v++);v>I?l.c=l.e=null:(l.e=v,l.c=[O]);return}_=String(O)}else{if(!LP.test(_=String(O)))return i(l,_,x);l.s=_.charCodeAt(0)==45?(_=_.slice(1),-1):1}(v=_.indexOf("."))>-1&&(_=_.replace(".","")),(g=_.search(/e/i))>0?(v<0&&(v=g),v+=+_.slice(g+1),_=_.substring(0,g)):v<0&&(v=_.length)}else{if(xr(E,2,X.length,"Base"),E==10&&V)return l=new q(O),Te(l,u+l.e+1,h);if(_=String(O),x=typeof O=="number"){if(O*0!=0)return i(l,_,x,E);if(l.s=1/O<0?(_=_.slice(1),-1):1,q.DEBUG&&_.replace(/^0\.0*|\./,"").length>15)throw Error(Sw+O)}else l.s=_.charCodeAt(0)===45?(_=_.slice(1),-1):1;for(f=X.slice(0,E),v=g=0,S=_.length;g<S;g++)if(f.indexOf(c=_.charAt(g))<0){if(c=="."){if(g>v){v=S;continue}}else if(!p&&(_==_.toUpperCase()&&(_=_.toLowerCase())||_==_.toLowerCase()&&(_=_.toUpperCase()))){p=!0,g=-1,v=0;continue}return i(l,String(O),x,E)}x=!1,_=r(_,E,10,l.s),(v=_.indexOf("."))>-1?_=_.replace(".",""):v=_.length}for(g=0;_.charCodeAt(g)===48;g++);for(S=_.length;_.charCodeAt(--S)===48;);if(_=_.slice(g,++S)){if(S-=g,x&&q.DEBUG&&S>15&&(O>Bv||O!==xn(O)))throw Error(Sw+l.s*O);if((v=v-g-1)>I)l.c=l.e=null;else if(v<T)l.c=[l.e=0];else{if(l.e=v,l.c=[],g=(v+1)%tt,v<0&&(g+=tt),g<S){for(g&&l.c.push(+_.slice(0,g)),S-=tt;g<S;)l.c.push(+_.slice(g,g+=tt));g=tt-(_=_.slice(g)).length}else g-=S;for(;g--;_+="0");l.c.push(+_)}}else l.c=[l.e=0]}q.clone=Ew,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(O){var E,f;if(O!=null)if(typeof O=="object"){if(O.hasOwnProperty(E="DECIMAL_PLACES")&&(f=O[E],xr(f,0,Zr,E),u=f),O.hasOwnProperty(E="ROUNDING_MODE")&&(f=O[E],xr(f,0,8,E),h=f),O.hasOwnProperty(E="EXPONENTIAL_AT")&&(f=O[E],f&&f.pop?(xr(f[0],-Zr,0,E),xr(f[1],0,Zr,E),b=f[0],w=f[1]):(xr(f,-Zr,Zr,E),b=-(w=f<0?-f:f))),O.hasOwnProperty(E="RANGE"))if(f=O[E],f&&f.pop)xr(f[0],-Zr,-1,E),xr(f[1],1,Zr,E),T=f[0],I=f[1];else if(xr(f,-Zr,Zr,E),f)T=-(I=f<0?-f:f);else throw Error(Mi+E+" cannot be zero: "+f);if(O.hasOwnProperty(E="CRYPTO"))if(f=O[E],f===!!f)if(f)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=f;else throw B=!f,Error(Mi+"crypto unavailable");else B=f;else throw Error(Mi+E+" not true or false: "+f);if(O.hasOwnProperty(E="MODULO_MODE")&&(f=O[E],xr(f,0,9,E),M=f),O.hasOwnProperty(E="POW_PRECISION")&&(f=O[E],xr(f,0,Zr,E),P=f),O.hasOwnProperty(E="FORMAT"))if(f=O[E],typeof f=="object")L=f;else throw Error(Mi+E+" not an object: "+f);if(O.hasOwnProperty(E="ALPHABET"))if(f=O[E],typeof f=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(f))V=f.slice(0,10)=="0123456789",X=f;else throw Error(Mi+E+" invalid: "+f)}else throw Error(Mi+"Object expected: "+O);return{DECIMAL_PLACES:u,ROUNDING_MODE:h,EXPONENTIAL_AT:[b,w],RANGE:[T,I],CRYPTO:B,MODULO_MODE:M,POW_PRECISION:P,FORMAT:L,ALPHABET:X}},q.isBigNumber=function(O){if(!O||O._isBigNumber!==!0)return!1;if(!q.DEBUG)return!0;var E,f,c=O.c,p=O.e,v=O.s;e:if({}.toString.call(c)=="[object Array]"){if((v===1||v===-1)&&p>=-Zr&&p<=Zr&&p===xn(p)){if(c[0]===0){if(p===0&&c.length===1)return!0;break e}if(E=(p+1)%tt,E<1&&(E+=tt),String(c[0]).length==E){for(E=0;E<c.length;E++)if(f=c[E],f<0||f>=zn||f!==xn(f))break e;if(f!==0)return!0}}}else if(c===null&&p===null&&(v===null||v===1||v===-1))return!0;throw Error(Mi+"Invalid BigNumber: "+O)},q.maximum=q.max=function(){return fe(arguments,-1)},q.minimum=q.min=function(){return fe(arguments,1)},q.random=function(){var O=9007199254740992,E=Math.random()*O&2097151?function(){return xn(Math.random()*O)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(f){var c,p,v,g,x,S=0,_=[],l=new q(a);if(f==null?f=u:xr(f,0,Zr),g=Pv(f/tt),B)if(crypto.getRandomValues){for(c=crypto.getRandomValues(new Uint32Array(g*=2));S<g;)x=c[S]*131072+(c[S+1]>>>11),x>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),c[S]=p[0],c[S+1]=p[1]):(_.push(x%1e14),S+=2);S=g/2}else if(crypto.randomBytes){for(c=crypto.randomBytes(g*=7);S<g;)x=(c[S]&31)*281474976710656+c[S+1]*1099511627776+c[S+2]*4294967296+c[S+3]*16777216+(c[S+4]<<16)+(c[S+5]<<8)+c[S+6],x>=9e15?crypto.randomBytes(7).copy(c,S):(_.push(x%1e14),S+=7);S=g/7}else throw B=!1,Error(Mi+"crypto unavailable");if(!B)for(;S<g;)x=E(),x<9e15&&(_[S++]=x%1e14);for(g=_[--S],f%=tt,g&&f&&(x=Mv[tt-f],_[S]=xn(g/x)*x);_[S]===0;_.pop(),S--);if(S<0)_=[v=0];else{for(v=-1;_[0]===0;_.splice(0,1),v-=tt);for(S=1,x=_[0];x>=10;x/=10,S++);S<tt&&(v-=tt-S)}return l.e=v,l.c=_,l}}(),q.sum=function(){for(var O=1,E=arguments,f=new q(E[0]);O<E.length;)f=f.plus(E[O++]);return f},r=function(){var O="0123456789";function E(f,c,p,v){for(var g,x=[0],S,_=0,l=f.length;_<l;){for(S=x.length;S--;x[S]*=c);for(x[0]+=v.indexOf(f.charAt(_++)),g=0;g<x.length;g++)x[g]>p-1&&(x[g+1]==null&&(x[g+1]=0),x[g+1]+=x[g]/p|0,x[g]%=p)}return x.reverse()}return function(f,c,p,v,g){var x,S,_,l,m,A,U,j,Z=f.indexOf("."),se=u,ae=h;for(Z>=0&&(l=P,P=0,f=f.replace(".",""),j=new q(c),A=j.pow(f.length-Z),P=l,j.c=E(ra(bn(A.c),A.e,"0"),10,p,O),j.e=j.c.length),U=E(f,c,p,g?(x=X,O):(x=O,X)),_=l=U.length;U[--l]==0;U.pop());if(!U[0])return x.charAt(0);if(Z<0?--_:(A.c=U,A.e=_,A.s=v,A=t(A,j,se,ae,p),U=A.c,m=A.r,_=A.e),S=_+se+1,Z=U[S],l=p/2,m=m||S<0||U[S+1]!=null,m=ae<4?(Z!=null||m)&&(ae==0||ae==(A.s<0?3:2)):Z>l||Z==l&&(ae==4||m||ae==6&&U[S-1]&1||ae==(A.s<0?8:7)),S<1||!U[0])f=m?ra(x.charAt(1),-se,x.charAt(0)):x.charAt(0);else{if(U.length=S,m)for(--p;++U[--S]>p;)U[S]=0,S||(++_,U=[1].concat(U));for(l=U.length;!U[--l];);for(Z=0,f="";Z<=l;f+=x.charAt(U[Z++]));f=ra(f,_,x.charAt(0))}return f}}(),t=function(){function O(c,p,v){var g,x,S,_,l=0,m=c.length,A=p%Ha,U=p/Ha|0;for(c=c.slice();m--;)S=c[m]%Ha,_=c[m]/Ha|0,g=U*S+_*A,x=A*S+g%Ha*Ha+l,l=(x/v|0)+(g/Ha|0)+U*_,c[m]=x%v;return l&&(c=[l].concat(c)),c}function E(c,p,v,g){var x,S;if(v!=g)S=v>g?1:-1;else for(x=S=0;x<v;x++)if(c[x]!=p[x]){S=c[x]>p[x]?1:-1;break}return S}function f(c,p,v,g){for(var x=0;v--;)c[v]-=x,x=c[v]<p[v]?1:0,c[v]=x*g+c[v]-p[v];for(;!c[0]&&c.length>1;c.splice(0,1));}return function(c,p,v,g,x){var S,_,l,m,A,U,j,Z,se,ae,he,Ee,me,dt,St,Oe,st,rt=c.s==p.s?1:-1,Re=c.c,Ae=p.c;if(!Re||!Re[0]||!Ae||!Ae[0])return new q(!c.s||!p.s||(Re?Ae&&Re[0]==Ae[0]:!Ae)?NaN:Re&&Re[0]==0||!Ae?rt*0:rt/0);for(Z=new q(rt),se=Z.c=[],_=c.e-p.e,rt=v+_+1,x||(x=zn,_=_n(c.e/tt)-_n(p.e/tt),rt=rt/tt|0),l=0;Ae[l]==(Re[l]||0);l++);if(Ae[l]>(Re[l]||0)&&_--,rt<0)se.push(1),m=!0;else{for(dt=Re.length,Oe=Ae.length,l=0,rt+=2,A=xn(x/(Ae[0]+1)),A>1&&(Ae=O(Ae,A,x),Re=O(Re,A,x),Oe=Ae.length,dt=Re.length),me=Oe,ae=Re.slice(0,Oe),he=ae.length;he<Oe;ae[he++]=0);st=Ae.slice(),st=[0].concat(st),St=Ae[0],Ae[1]>=x/2&&St++;do{if(A=0,S=E(Ae,ae,Oe,he),S<0){if(Ee=ae[0],Oe!=he&&(Ee=Ee*x+(ae[1]||0)),A=xn(Ee/St),A>1)for(A>=x&&(A=x-1),U=O(Ae,A,x),j=U.length,he=ae.length;E(U,ae,j,he)==1;)A--,f(U,Oe<j?st:Ae,j,x),j=U.length,S=1;else A==0&&(S=A=1),U=Ae.slice(),j=U.length;if(j<he&&(U=[0].concat(U)),f(ae,U,he,x),he=ae.length,S==-1)for(;E(Ae,ae,Oe,he)<1;)A++,f(ae,Oe<he?st:Ae,he,x),he=ae.length}else S===0&&(A++,ae=[0]);se[l++]=A,ae[0]?ae[he++]=Re[me]||0:(ae=[Re[me]],he=1)}while((me++<dt||ae[0]!=null)&&rt--);m=ae[0]!=null,se[0]||se.splice(0,1)}if(x==zn){for(l=1,rt=se[0];rt>=10;rt/=10,l++);Te(Z,v+(Z.e=l+_*tt-1)+1,g,m)}else Z.e=_,Z.r=+m;return Z}}();function ee(O,E,f,c){var p,v,g,x,S;if(f==null?f=h:xr(f,0,8),!O.c)return O.toString();if(p=O.c[0],g=O.e,E==null)S=bn(O.c),S=c==1||c==2&&(g<=b||g>=w)?Oh(S,g):ra(S,g,"0");else if(O=Te(new q(O),E,f),v=O.e,S=bn(O.c),x=S.length,c==1||c==2&&(E<=v||v<=b)){for(;x<E;S+="0",x++);S=Oh(S,v)}else if(E-=g,S=ra(S,v,"0"),v+1>x){if(--E>0)for(S+=".";E--;S+="0");}else if(E+=v-x,E>0)for(v+1==x&&(S+=".");E--;S+="0");return O.s<0&&p?"-"+S:S}function fe(O,E){for(var f,c,p=1,v=new q(O[0]);p<O.length;p++)c=new q(O[p]),(!c.s||(f=Vo(v,c))===E||f===0&&v.s===E)&&(v=c);return v}function _e(O,E,f){for(var c=1,p=E.length;!E[--p];E.pop());for(p=E[0];p>=10;p/=10,c++);return(f=c+f*tt-1)>I?O.c=O.e=null:f<T?O.c=[O.e=0]:(O.e=f,O.c=E),O}i=function(){var O=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,f=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,g,x,S){var _,l=x?g:g.replace(p,"");if(c.test(l))v.s=isNaN(l)?null:l<0?-1:1;else{if(!x&&(l=l.replace(O,function(m,A,U){return _=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!S||S==_?A:m}),S&&(_=S,l=l.replace(E,"$1").replace(f,"0.$1")),g!=l))return new q(l,_);if(q.DEBUG)throw Error(Mi+"Not a"+(S?" base "+S:"")+" number: "+g);v.s=null}v.c=v.e=null}}();function Te(O,E,f,c){var p,v,g,x,S,_,l,m=O.c,A=Mv;if(m){e:{for(p=1,x=m[0];x>=10;x/=10,p++);if(v=E-p,v<0)v+=tt,g=E,S=m[_=0],l=xn(S/A[p-g-1]%10);else if(_=Pv((v+1)/tt),_>=m.length)if(c){for(;m.length<=_;m.push(0));S=l=0,p=1,v%=tt,g=v-tt+1}else break e;else{for(S=x=m[_],p=1;x>=10;x/=10,p++);v%=tt,g=v-tt+p,l=g<0?0:xn(S/A[p-g-1]%10)}if(c=c||E<0||m[_+1]!=null||(g<0?S:S%A[p-g-1]),c=f<4?(l||c)&&(f==0||f==(O.s<0?3:2)):l>5||l==5&&(f==4||c||f==6&&(v>0?g>0?S/A[p-g]:0:m[_-1])%10&1||f==(O.s<0?8:7)),E<1||!m[0])return m.length=0,c?(E-=O.e+1,m[0]=A[(tt-E%tt)%tt],O.e=-E||0):m[0]=O.e=0,O;if(v==0?(m.length=_,x=1,_--):(m.length=_+1,x=A[tt-v],m[_]=g>0?xn(S/A[p-g]%A[g])*x:0),c)for(;;)if(_==0){for(v=1,g=m[0];g>=10;g/=10,v++);for(g=m[0]+=x,x=1;g>=10;g/=10,x++);v!=x&&(O.e++,m[0]==zn&&(m[0]=1));break}else{if(m[_]+=x,m[_]!=zn)break;m[_--]=0,x=1}for(v=m.length;m[--v]===0;m.pop());}O.e>I?O.c=O.e=null:O.e<T&&(O.c=[O.e=0])}return O}function be(O){var E,f=O.e;return f===null?O.toString():(E=bn(O.c),E=f<=b||f>=w?Oh(E,f):ra(E,f,"0"),O.s<0?"-"+E:E)}return n.absoluteValue=n.abs=function(){var O=new q(this);return O.s<0&&(O.s=1),O},n.comparedTo=function(O,E){return Vo(this,new q(O,E))},n.decimalPlaces=n.dp=function(O,E){var f,c,p,v=this;if(O!=null)return xr(O,0,Zr),E==null?E=h:xr(E,0,8),Te(new q(v),O+v.e+1,E);if(!(f=v.c))return null;if(c=((p=f.length-1)-_n(this.e/tt))*tt,p=f[p])for(;p%10==0;p/=10,c--);return c<0&&(c=0),c},n.dividedBy=n.div=function(O,E){return t(this,new q(O,E),u,h)},n.dividedToIntegerBy=n.idiv=function(O,E){return t(this,new q(O,E),0,1)},n.exponentiatedBy=n.pow=function(O,E){var f,c,p,v,g,x,S,_,l,m=this;if(O=new q(O),O.c&&!O.isInteger())throw Error(Mi+"Exponent not an integer: "+be(O));if(E!=null&&(E=new q(E)),x=O.e>14,!m.c||!m.c[0]||m.c[0]==1&&!m.e&&m.c.length==1||!O.c||!O.c[0])return l=new q(Math.pow(+be(m),x?O.s*(2-Ah(O)):+be(O))),E?l.mod(E):l;if(S=O.s<0,E){if(E.c?!E.c[0]:!E.s)return new q(NaN);c=!S&&m.isInteger()&&E.isInteger(),c&&(m=m.mod(E))}else{if(O.e>9&&(m.e>0||m.e<-1||(m.e==0?m.c[0]>1||x&&m.c[1]>=24e7:m.c[0]<8e13||x&&m.c[0]<=9999975e7)))return v=m.s<0&&Ah(O)?-0:0,m.e>-1&&(v=1/v),new q(S?1/v:v);P&&(v=Pv(P/tt+2))}for(x?(f=new q(.5),S&&(O.s=1),_=Ah(O)):(p=Math.abs(+be(O)),_=p%2),l=new q(a);;){if(_){if(l=l.times(m),!l.c)break;v?l.c.length>v&&(l.c.length=v):c&&(l=l.mod(E))}if(p){if(p=xn(p/2),p===0)break;_=p%2}else if(O=O.times(f),Te(O,O.e+1,1),O.e>14)_=Ah(O);else{if(p=+be(O),p===0)break;_=p%2}m=m.times(m),v?m.c&&m.c.length>v&&(m.c.length=v):c&&(m=m.mod(E))}return c?l:(S&&(l=a.div(l)),E?l.mod(E):v?Te(l,P,h,g):l)},n.integerValue=function(O){var E=new q(this);return O==null?O=h:xr(O,0,8),Te(E,E.e+1,O)},n.isEqualTo=n.eq=function(O,E){return Vo(this,new q(O,E))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(O,E){return Vo(this,new q(O,E))>0},n.isGreaterThanOrEqualTo=n.gte=function(O,E){return(E=Vo(this,new q(O,E)))===1||E===0},n.isInteger=function(){return!!this.c&&_n(this.e/tt)>this.c.length-2},n.isLessThan=n.lt=function(O,E){return Vo(this,new q(O,E))<0},n.isLessThanOrEqualTo=n.lte=function(O,E){return(E=Vo(this,new q(O,E)))===-1||E===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(O,E){var f,c,p,v,g=this,x=g.s;if(O=new q(O,E),E=O.s,!x||!E)return new q(NaN);if(x!=E)return O.s=-E,g.plus(O);var S=g.e/tt,_=O.e/tt,l=g.c,m=O.c;if(!S||!_){if(!l||!m)return l?(O.s=-E,O):new q(m?g:NaN);if(!l[0]||!m[0])return m[0]?(O.s=-E,O):new q(l[0]?g:h==3?-0:0)}if(S=_n(S),_=_n(_),l=l.slice(),x=S-_){for((v=x<0)?(x=-x,p=l):(_=S,p=m),p.reverse(),E=x;E--;p.push(0));p.reverse()}else for(c=(v=(x=l.length)<(E=m.length))?x:E,x=E=0;E<c;E++)if(l[E]!=m[E]){v=l[E]<m[E];break}if(v&&(p=l,l=m,m=p,O.s=-O.s),E=(c=m.length)-(f=l.length),E>0)for(;E--;l[f++]=0);for(E=zn-1;c>x;){if(l[--c]<m[c]){for(f=c;f&&!l[--f];l[f]=E);--l[f],l[c]+=zn}l[c]-=m[c]}for(;l[0]==0;l.splice(0,1),--_);return l[0]?_e(O,l,_):(O.s=h==3?-1:1,O.c=[O.e=0],O)},n.modulo=n.mod=function(O,E){var f,c,p=this;return O=new q(O,E),!p.c||!O.s||O.c&&!O.c[0]?new q(NaN):!O.c||p.c&&!p.c[0]?new q(p):(M==9?(c=O.s,O.s=1,f=t(p,O,0,3),O.s=c,f.s*=c):f=t(p,O,0,M),O=p.minus(f.times(O)),!O.c[0]&&M==1&&(O.s=p.s),O)},n.multipliedBy=n.times=function(O,E){var f,c,p,v,g,x,S,_,l,m,A,U,j,Z,se,ae=this,he=ae.c,Ee=(O=new q(O,E)).c;if(!he||!Ee||!he[0]||!Ee[0])return!ae.s||!O.s||he&&!he[0]&&!Ee||Ee&&!Ee[0]&&!he?O.c=O.e=O.s=null:(O.s*=ae.s,!he||!Ee?O.c=O.e=null:(O.c=[0],O.e=0)),O;for(c=_n(ae.e/tt)+_n(O.e/tt),O.s*=ae.s,S=he.length,m=Ee.length,S<m&&(j=he,he=Ee,Ee=j,p=S,S=m,m=p),p=S+m,j=[];p--;j.push(0));for(Z=zn,se=Ha,p=m;--p>=0;){for(f=0,A=Ee[p]%se,U=Ee[p]/se|0,g=S,v=p+g;v>p;)_=he[--g]%se,l=he[g]/se|0,x=U*_+l*A,_=A*_+x%se*se+j[v]+f,f=(_/Z|0)+(x/se|0)+U*l,j[v--]=_%Z;j[v]=f}return f?++c:j.splice(0,1),_e(O,j,c)},n.negated=function(){var O=new q(this);return O.s=-O.s||null,O},n.plus=function(O,E){var f,c=this,p=c.s;if(O=new q(O,E),E=O.s,!p||!E)return new q(NaN);if(p!=E)return O.s=-E,c.minus(O);var v=c.e/tt,g=O.e/tt,x=c.c,S=O.c;if(!v||!g){if(!x||!S)return new q(p/0);if(!x[0]||!S[0])return S[0]?O:new q(x[0]?c:p*0)}if(v=_n(v),g=_n(g),x=x.slice(),p=v-g){for(p>0?(g=v,f=S):(p=-p,f=x),f.reverse();p--;f.push(0));f.reverse()}for(p=x.length,E=S.length,p-E<0&&(f=S,S=x,x=f,E=p),p=0;E;)p=(x[--E]=x[E]+S[E]+p)/zn|0,x[E]=zn===x[E]?0:x[E]%zn;return p&&(x=[p].concat(x),++g),_e(O,x,g)},n.precision=n.sd=function(O,E){var f,c,p,v=this;if(O!=null&&O!==!!O)return xr(O,1,Zr),E==null?E=h:xr(E,0,8),Te(new q(v),O,E);if(!(f=v.c))return null;if(p=f.length-1,c=p*tt+1,p=f[p]){for(;p%10==0;p/=10,c--);for(p=f[0];p>=10;p/=10,c++);}return O&&v.e+1>c&&(c=v.e+1),c},n.shiftedBy=function(O){return xr(O,-Bv,Bv),this.times("1e"+O)},n.squareRoot=n.sqrt=function(){var O,E,f,c,p,v=this,g=v.c,x=v.s,S=v.e,_=u+4,l=new q("0.5");if(x!==1||!g||!g[0])return new q(!x||x<0&&(!g||g[0])?NaN:g?v:1/0);if(x=Math.sqrt(+be(v)),x==0||x==1/0?(E=bn(g),(E.length+S)%2==0&&(E+="0"),x=Math.sqrt(+E),S=_n((S+1)/2)-(S<0||S%2),x==1/0?E="5e"+S:(E=x.toExponential(),E=E.slice(0,E.indexOf("e")+1)+S),f=new q(E)):f=new q(x+""),f.c[0]){for(S=f.e,x=S+_,x<3&&(x=0);;)if(p=f,f=l.times(p.plus(t(v,p,_,1))),bn(p.c).slice(0,x)===(E=bn(f.c)).slice(0,x))if(f.e<S&&--x,E=E.slice(x-3,x+1),E=="9999"||!c&&E=="4999"){if(!c&&(Te(p,p.e+u+2,0),p.times(p).eq(v))){f=p;break}_+=4,x+=4,c=1}else{(!+E||!+E.slice(1)&&E.charAt(0)=="5")&&(Te(f,f.e+u+2,1),O=!f.times(f).eq(v));break}}return Te(f,f.e+u+1,h,O)},n.toExponential=function(O,E){return O!=null&&(xr(O,0,Zr),O++),ee(this,O,E,1)},n.toFixed=function(O,E){return O!=null&&(xr(O,0,Zr),O=O+this.e+1),ee(this,O,E)},n.toFormat=function(O,E,f){var c,p=this;if(f==null)O!=null&&E&&typeof E=="object"?(f=E,E=null):O&&typeof O=="object"?(f=O,O=E=null):f=L;else if(typeof f!="object")throw Error(Mi+"Argument not an object: "+f);if(c=p.toFixed(O,E),p.c){var v,g=c.split("."),x=+f.groupSize,S=+f.secondaryGroupSize,_=f.groupSeparator||"",l=g[0],m=g[1],A=p.s<0,U=A?l.slice(1):l,j=U.length;if(S&&(v=x,x=S,S=v,j-=v),x>0&&j>0){for(v=j%x||x,l=U.substr(0,v);v<j;v+=x)l+=_+U.substr(v,x);S>0&&(l+=_+U.slice(v)),A&&(l="-"+l)}c=m?l+(f.decimalSeparator||"")+((S=+f.fractionGroupSize)?m.replace(new RegExp("\\d{"+S+"}\\B","g"),"$&"+(f.fractionGroupSeparator||"")):m):l}return(f.prefix||"")+c+(f.suffix||"")},n.toFraction=function(O){var E,f,c,p,v,g,x,S,_,l,m,A,U=this,j=U.c;if(O!=null&&(x=new q(O),!x.isInteger()&&(x.c||x.s!==1)||x.lt(a)))throw Error(Mi+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+be(x));if(!j)return new q(U);for(E=new q(a),_=f=new q(a),c=S=new q(a),A=bn(j),v=E.e=A.length-U.e-1,E.c[0]=Mv[(g=v%tt)<0?tt+g:g],O=!O||x.comparedTo(E)>0?v>0?E:_:x,g=I,I=1/0,x=new q(A),S.c[0]=0;l=t(x,E,0,1),p=f.plus(l.times(c)),p.comparedTo(O)!=1;)f=c,c=p,_=S.plus(l.times(p=_)),S=p,E=x.minus(l.times(p=E)),x=p;return p=t(O.minus(f),c,0,1),S=S.plus(p.times(_)),f=f.plus(p.times(c)),S.s=_.s=U.s,v=v*2,m=t(_,c,v,h).minus(U).abs().comparedTo(t(S,f,v,h).minus(U).abs())<1?[_,c]:[S,f],I=g,m},n.toNumber=function(){return+be(this)},n.toPrecision=function(O,E){return O!=null&&xr(O,1,Zr),ee(this,O,E,2)},n.toString=function(O){var E,f=this,c=f.s,p=f.e;return p===null?c?(E="Infinity",c<0&&(E="-"+E)):E="NaN":(O==null?E=p<=b||p>=w?Oh(bn(f.c),p):ra(bn(f.c),p,"0"):O===10&&V?(f=Te(new q(f),u+p+1,h),E=ra(bn(f.c),f.e,"0")):(xr(O,2,X.length,"Base"),E=r(ra(bn(f.c),p,"0"),10,O,c,!0)),c<0&&f.c[0]&&(E="-"+E)),E},n.valueOf=n.toJSON=function(){return be(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,e!=null&&q.set(e),q}function _n(e){var t=e|0;return e>0||e===t?t:t-1}function bn(e){for(var t,r,i=1,n=e.length,a=e[0]+"";i<n;){for(t=e[i++]+"",r=tt-t.length;r--;t="0"+t);a+=t}for(n=a.length;a.charCodeAt(--n)===48;);return a.slice(0,n+1||1)}function Vo(e,t){var r,i,n=e.c,a=t.c,u=e.s,h=t.s,b=e.e,w=t.e;if(!u||!h)return null;if(r=n&&!n[0],i=a&&!a[0],r||i)return r?i?0:-h:u;if(u!=h)return u;if(r=u<0,i=b==w,!n||!a)return i?0:!n^r?1:-1;if(!i)return b>w^r?1:-1;for(h=(b=n.length)<(w=a.length)?b:w,u=0;u<h;u++)if(n[u]!=a[u])return n[u]>a[u]^r?1:-1;return b==w?0:b>w^r?1:-1}function xr(e,t,r,i){if(e<t||e>r||e!==xn(e))throw Error(Mi+(i||"Argument")+(typeof e=="number"?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ah(e){var t=e.c.length-1;return _n(e.e/tt)==t&&e.c[t]%2!=0}function Oh(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ra(e,t,r){var i,n;if(t<0){for(n=r+".";++t;n+=r);e=n+e}else if(i=e.length,++t>i){for(n=r,t-=i;--t;n+=r);e+=n}else t<i&&(e=e.slice(0,t)+"."+e.slice(t));return e}var DP=Ew(),Lr=DP;var GB=Yr(Aw(),1),$B=Yr(Kv(),1),XB=Yr(Gv(),1),zh=Yr(eg(),1),YB=Yr(TS(),1);var IS=zh.default;var rg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ZB=(e,t)=>{let r="1"+"0".repeat(t),i=new Lr(e.toString(10),10);return $f(i.times(r).toString(16))},JB=(e,t)=>{let r="1"+"0".repeat(t),i=new Lr(e.toString(),10);return parseFloat(i.dividedBy(r).toString())},QB=e=>{typeof e=="string"&&(e=new Uint8Array(Buffer.from(e)));let t=[],r=BigInt("0x"+Buffer.from(e).toString("hex"));for(;r>BigInt(0);){let i=Number(r%BigInt(58));t.unshift(rg[i]),r=r/BigInt(58)}for(let i=0;i<e.length&&e[i]===0;i++)t.unshift(rg[0]);return t.join("")},eM=e=>{let t=BigInt(0);for(let n=0;n<e.length;n++)t=t*BigInt(58)+BigInt(rg.indexOf(e[n]));let r=t.toString(16),i=r.length%2===0?r:"0"+r;return new Uint8Array(Buffer.from(i,"hex"))},tM=e=>Buffer.from(e).toString("utf8"),rM=e=>Buffer.from(e,"utf8"),iM=e=>!isNaN(Number(e)),ig=async e=>{await new Promise(t=>setTimeout(t,e))},ng=(e,t)=>JSON.stringify(e)===JSON.stringify(t),nM=e=>{let[t,r]=e.toExponential().split("e").map(n=>parseFloat(n)),i=(t*Math.pow(10,r)).toString();return i=parseFloat(i).toString(),i},al=async e=>await new Promise((t,r)=>{let i;typeof window<"u"?i=new WebSocket(e):i=new zh.default(e),i.onopen=()=>{t(!0),i.close()},i.onerror=n=>{r(new Error(n.message)),i.close()}}),jh={add:(e,t,r=18)=>parseFloat(new Lr(e).plus(new Lr(t)).toFixed(r)),sub:(e,t,r=18)=>parseFloat(new Lr(e).minus(new Lr(t)).toFixed(r)),mul:(e,t,r=18)=>parseFloat(new Lr(e).times(new Lr(t)).toFixed(r)),div:(e,t,r=18)=>parseFloat(new Lr(e).div(new Lr(t)).toFixed(r)),pow:(e,t,r=18)=>parseFloat(new Lr(e).pow(t).toFixed(r)),sqrt:(e,t=18)=>parseFloat(new Lr(e).sqrt().toFixed(t)),abs:(e,t=18)=>parseFloat(new Lr(e).absoluteValue().toFixed(t)),ceil:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_CEIL).toFixed(t)),floor:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_FLOOR).toFixed(t)),round:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_HALF_UP).toFixed(t))},sM=()=>typeof window>"u"?!1:function(e){return!!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(e.substr(0,4)))}(navigator.userAgent||navigator.vendor||window.opera),aM=()=>{if(typeof window>"u")return!1;let e=window.navigator;if(window.WebViewJavascriptBridge||window.webkit&&window.webkit.messageHandlers||e.userAgent.match(/WebView/i))return!0;let t=e.standalone,r=e.userAgent.toLowerCase(),i=/safari/.test(r);return/iphone|ipod|ipad/.test(r)?!t&&!i:r.includes("wv")};var ag={};Oa(ag,{AssetDirectionEnum:()=>sg,ErrorTypeEnum:()=>ol,TransactionListenerProcessIndex:()=>Wh,TransactionStatusEnum:()=>Kh,TransactionTypeEnum:()=>Vh,WalletPlatformEnum:()=>RS});var sg=(r=>(r.INCOMING="INCOMING",r.OUTGOING="OUTGOING",r))(sg||{}),Vh=(a=>(a.GENERAL="GENERAL",a.CONTRACT="CONTRACT",a.COIN="COIN",a.TOKEN="TOKEN",a.NFT="NFT",a))(Vh||{}),Kh=(i=>(i.FAILED="FAILED",i.PENDING="PENDING",i.CONFIRMED="CONFIRMED",i))(Kh||{}),ol=(c=>(c.RPC_TIMEOUT="RPC_TIMEOUT",c.RPC_REQUEST_ERROR="RPC_REQUEST_ERROR",c.RPC_ACCESS_DENIED="RPC_ACCESS_DENIED",c.WS_URL_NOT_DEFINED="WS_URL_NOT_DEFINED",c.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",c.UNACCEPTED_CHAIN="UNACCEPTED_CHAIN",c.UNAUTHORIZED_ADDRESS="UNAUTHORIZED_ADDRESS",c.INSUFFICIENT_BALANCE="INSUFFICIENT_BALANCE",c.INVALID_AMOUNT="INVALID_AMOUNT",c.INVALID_ADDRESS="INVALID_ADDRESS",c.INVALID_PRIVATE_KEY="INVALID_PRIVATE_KEY",c.INVALID_PUBLIC_KEY="INVALID_PUBLIC_KEY",c.INVALID_TRANSACTION_ID="INVALID_TRANSACTION_ID",c.PROVIDER_IS_REQUIRED="PROVIDER_IS_REQUIRED",c.PROVIDER_IS_NOT_INITIALIZED="PROVIDER_IS_NOT_INITIALIZED",c.PROVIDER_IS_ALREADY_INITIALIZED="PROVIDER_IS_ALREADY_INITIALIZED",c.WALLET_ALREADY_PROCESSING="WALLET_ALREADY_PROCESSING",c.WALLET_CONNECT_REJECTED="WALLET_CONNECT_REJECTED",c.WALLET_REQUEST_REJECTED="WALLET_REQUEST_REJECTED",c.WALLET_CONNECTION_FAILED="WALLET_CONNECTION_FAILED",c.WALLET_CONNECTION_TIMEOUT="WALLET_CONNECTION_TIMEOUT",c.TRANSACTION_CREATION_FAILED="TRANSACTION_CREATION_FAILED",c.TRANSACTION_NOT_FOUND="TRANSACTION_NOT_FOUND",c.CLOSED_WALLETCONNECT_MODAL="CLOSED_WALLETCONNECT_MODAL",c.PROJECT_ID_IS_REQUIRED="PROJECT_ID_IS_REQUIRED",c.METADATA_IS_REQUIRED="METADATA_IS_REQUIRED",c.CONFIG_IS_REQUIRED="CONFIG_IS_REQUIRED",c))(ol||{}),RS=(n=>(n.BROWSER="BROWSER",n.MOBILE="MOBILE",n.DESKTOP="DESKTOP",n.UNIVERSAL="UNIVERSAL",n))(RS||{});var Wh={GENERAL:"generalProcess",CONTRACT:"contractProcess",COIN:"coinProcess",TOKEN:"tokenProcess",NFT:"nftProcess"};var Vn=class e{network;api;explorer;wsUrl;blockCypherToken;defaultBlockCypherToken="49d43a59a4f24d31a9731eb067ab971c";static _instance;constructor(t){this.update(t)}static get instance(){if(e._instance===void 0)throw new Error("PROVIDER_IS_NOT_INITIALIZED");return e._instance}static initialize(t){if(e._instance!==void 0)throw new Error("PROVIDER_IS_ALREADY_INITIALIZED");e._instance=new e(t)}async checkRpcConnection(t){try{let r=await vn.get(t??this.createEndpoint("blocks/tip/height"));return r.status!==200?new Error(r.statusText+": "+JSON.stringify(r.data)):!0}catch(r){return r}}async checkWsConnection(t){try{let r=await al(t??this.wsUrl);return r instanceof Error?r:!0}catch(r){return r}}update(t){if(this.network=t,e._instance=this,this.blockCypherToken=this.network.blockCypherToken,this.network.testnet){this.api="https://blockstream.info/testnet/api/",this.explorer="https://blockstream.info/testnet/";let r=this.network.blockCypherToken??this.defaultBlockCypherToken;this.wsUrl="wss://socket.blockcypher.com/v1/btc/test3?token="+r}else this.api="https://blockstream.info/api/",this.explorer="https://blockstream.info/",this.network.blockCypherToken!==void 0?this.wsUrl="wss://socket.blockcypher.com/v1/btc/main?token="+this.network.blockCypherToken:this.wsUrl="wss://ws.blockchain.info/inv"}createEndpoint(t){return this.api+t}isTestnet(){return this.network?.testnet??!1}};var hx={};Oa(hx,{Coin:()=>px});var cg={};Oa(cg,{base58Decode:()=>eM,base58Encode:()=>QB,bufferToString:()=>tM,checkWebSocket:()=>al,fromSatoshi:()=>hs,hexToNumber:()=>JB,isMobile:()=>sM,isNumeric:()=>iM,isWebview:()=>aM,math:()=>jh,numberToHex:()=>ZB,objectsEqual:()=>ng,sleep:()=>ig,stringToBuffer:()=>rM,toHex:()=>$f,toReadableString:()=>nM,toSatoshi:()=>og});var hs=e=>jh.div(e,1e8,8),og=e=>jh.mul(e,1e8,8);var xc=Yr(MT(),1);var $l=class{rawData;signedData;provider;constructor(t,r){this.rawData=t,this.provider=r??Vn.instance}async sign(t){return this.rawData.bitcoreLib.sign(t),this.signedData=this.rawData.bitcoreLib.serialize(),this}async send(){try{return(await vn({method:"POST",url:"https://blockstream.info/testnet/api/tx",data:this.signedData})).data}catch(t){throw new Error(JSON.stringify(t.response?.data))}}getRawData(){return this.rawData}getSignedData(){return this.signedData??""}};var px=class{provider;constructor(t){this.provider=t??Vn.instance}getName(){return"Bitcoin"}getSymbol(){return"BTC"}getDecimals(){return 8}async getBalance(t){let r=this.provider.createEndpoint("address/"+t),i=await vn.get(r).then(a=>a.data),n=i.chain_stats.funded_txo_sum-i.chain_stats.spent_txo_sum;return hs(n)}async transfer(t,r,i){if(i<0)throw new Error("INVALID_AMOUNT");if(i>await this.getBalance(t))throw new Error("INSUFFICIENT_BALANCE");if(t===r)throw new Error("INVALID_ADDRESS");let n=[],a=new xc.Transaction,u=new xc.Address(t),h=og(i),b=await vn.get(this.provider.createEndpoint("address/"+t+"/utxo")).then(w=>w.data);for(let w of b)n.push(new xc.Transaction.UnspentOutput({txId:w.txid,satoshis:w.value,address:u,outputIndex:w.vout,script:xc.Script.fromAddress(u)}));return a.from(n),a.change(t),a.to(r,h),new $l({sender:t,receiver:r,amount:h,bitcoreLib:a})}};var dx={};Oa(dx,{CoinTransaction:()=>Xl,Transaction:()=>_c});var CT=0,_c=class{id;provider;data=null;constructor(t,r){this.id=t,this.provider=r??Vn.instance}async getData(){if(this.data!==null)return this.data;try{let t=(await vn.get(this.provider.createEndpoint("tx/"+this.id))).data;return t?.txid!==this.id?this.data=null:this.data=t}catch(t){if(String(t?.response?.data).includes("Transaction not found")){if(CT>5)throw new Error("TRANSACTION_NOT_FOUND");return CT++,await ig(2e3),await this.getData()}throw new Error("RPC_REQUEST_ERROR")}}async wait(t=4e3){return await new Promise((r,i)=>{let n=async()=>{try{let a=await this.getStatus();if(a==="CONFIRMED"){r("CONFIRMED");return}else if(a==="FAILED"){i("FAILED");return}setTimeout(n,t)}catch{i("FAILED")}};n()})}getId(){return this.id}async getType(){return"COIN"}getUrl(){return this.provider.explorer+"tx/"+this.id}async getSigner(){return(await this.getData())?.vin[0].prevout.scriptpubkey_address??""}async getFee(){let t=await this.getData();return hs(t?.fee??0)}async getBlockNumber(){return(await this.getData())?.status?.block_height??0}async getBlockTimestamp(){return(await this.getData())?.status?.block_time??0}async getBlockConfirmationCount(){let t=await this.getData();return t===null?0:(await vn.get(this.provider.createEndpoint("blocks/tip/height"))).data-t?.status?.block_height}async getStatus(){let t=await this.getData();return t===null?"PENDING":t.status?.block_height!==void 0?t.status.confirmed?"CONFIRMED":"FAILED":"PENDING"}};var Xl=class extends _c{async getReceiver(){return(await this.getData())?.vout[0].scriptpubkey_address??""}async getSender(){return await this.getSigner()}async getAmount(){let t=await this.getData();return hs(t?.vout[0].value??0)}async verifyTransfer(t,r,i){if(await this.getStatus()==="PENDING")return"PENDING";if(await this.getAmount()!==i)return"FAILED";if(t==="INCOMING"){if((await this.getReceiver()).toLowerCase()!==r.toLowerCase())return"FAILED"}else if((await this.getSender()).toLowerCase()!==r.toLowerCase())return"FAILED";return"CONFIRMED"}};var vx={};Oa(vx,{TransactionListener:()=>mx,TransactionSigner:()=>$l});var mx=class{type;provider;status=!1;callbacks=[];triggeredTransactions=[];filter;webSocket;dynamicStop=()=>{};constructor(t,r,i){this.type=t,this.filter=r??{},this.provider=i??Vn.instance}stop(){this.status&&(this.status=!1,this.dynamicStop())}start(){this.status||(this.status=!0,this[Wh[this.type]]())}getStatus(){return this.status}async on(t){if(this.webSocket===void 0)try{await al(this.provider.wsUrl),this.webSocket=new IS(this.provider.wsUrl)}catch(r){throw new Error("WebSocket connection is not available"+(r instanceof Error?": "+r.message:""))}return this.start(),this.callbacks.push(t),!0}trigger(t){this.triggeredTransactions.includes(t.id)||(this.triggeredTransactions.push(t.id),this.callbacks.forEach(r=>{r(t)}))}isBlockCypherProcess(){return this.provider.isTestnet()||this.provider.blockCypherToken!==void 0}createMessage(t){let r;if(this.isBlockCypherProcess()){let i={event:"unconfirmed-tx",token:this.provider.blockCypherToken??this.provider.defaultBlockCypherToken};t!==void 0&&(i.address=t),r=JSON.stringify(i)}else r=JSON.stringify({op:"unconfirmed_sub"});return this.dynamicStop=()=>{this.isBlockCypherProcess()||this.webSocket.send(JSON.stringify({op:"unconfirmed_unsub"})),this.webSocket.close()},r}getValues(t){let r={txId:""};return this.isBlockCypherProcess()?(r.txId=t.hash,r.sender=t.inputs[0].addresses[0],r.receiver=t.outputs[0].addresses[0],r.amount=hs(t.outputs[0].value)):(r.txId=t.x.hash,r.receiver=t.x.out[0].addr,r.sender=t.x.inputs[0].prev_out.addr,r.amount=hs(t.x.out[0].value)),r}generalProcess(){let t=this.createMessage();this.webSocket.addEventListener("open",()=>{this.webSocket.send(t)}),this.webSocket.addEventListener("message",async r=>{let i=this.getValues(JSON.parse(r.data));this.filter?.signer!==void 0&&i.sender!==this.filter.signer.toLowerCase()||this.trigger(new _c(i.txId))})}contractProcess(){throw new Error("This method is not implemented for Bitcoin.")}coinProcess(){let t=this.filter;if(t.signer!==void 0&&t.sender!==void 0&&t.signer!==t.sender)throw new Error("Sender and signer must be the same in coin transactions. Or only one of them can be defined.");let r=t.sender??t.signer,i=this.createMessage(t.receiver);this.webSocket.addEventListener("open",()=>{this.webSocket.send(i)}),this.webSocket.addEventListener("message",async n=>{let a=JSON.parse(n.data),u={},h={};if(String(a.event).includes("events limit reached"))throw new Error("BlockCypher events limit reached.");let b=this.getValues(a);if(r!==void 0&&(u.sender=r.toLowerCase(),h.sender=b.sender?.toLowerCase()),t.receiver!==void 0&&(u.receiver=t.receiver.toLowerCase(),h.receiver=b.receiver?.toLowerCase()),!ng(u,h))return;let w=new Xl(b.txId);t.amount!==void 0&&b.amount!==t.amount||this.trigger(w)})}tokenProcess(){throw new Error("This method is not implemented for Bitcoin.")}nftProcess(){throw new Error("This method is not implemented for Bitcoin.")}};0&&(module.exports={Provider,assets,models,services,types,utils});
38
+ `)}`}_compileErrors(){return this.errors.map(TP)}};var Hn={};Oa(Hn,{abiSchemaToJsonSchema:()=>gh,codePointToInt:()=>uw,ensureIfUint8Array:()=>Sv,ethAbiToJsonSchema:()=>_v,fetchArrayElement:()=>yv,hexToNumber:()=>bh,hexToUint8Array:()=>xh,numberToHex:()=>wv,padLeft:()=>fw,parseBaseType:()=>fs,transformJsonDataToAbiFormat:()=>vh,uint8ArrayToHexString:()=>Ff});var aw=["bool","int","uint","bytes","string","address","tuple"];var bv=e=>typeof e=="object"&&"type"in e&&"name"in e;var ow=e=>typeof e=="string",hr=e=>typeof e=="string"&&/^((-)?0x[0-9a-f]+|(0x))$/i.test(e);var mh=e=>typeof e=="number"||typeof e=="bigint"||typeof e=="string"&&/^((-0x|0x|-)?[0-9a-f]+|(0x))$/i.test(e);var IP=["hex","number","blockNumber","blockNumberOrTag","filter","bloom"],fs=e=>{let t=e.replace(/ /,""),r,i=!1,n=[];if(e.includes("[")&&(t=t.slice(0,t.indexOf("[")),n=[...e.matchAll(/(?:\[(\d*)\])/g)].map(a=>parseInt(a[1],10)).map(a=>Number.isNaN(a)?-1:a),i=n.length>0),aw.includes(t))return{baseType:t,isArray:i,baseTypeSize:r,arraySizes:n};if(t.startsWith("int"))r=parseInt(t.substring(3),10),t="int";else if(t.startsWith("uint"))r=parseInt(e.substring(4),10),t="uint";else if(t.startsWith("bytes"))r=parseInt(t.substring(5),10),t="bytes";else return{baseType:void 0,isArray:!1,baseTypeSize:void 0,arraySizes:n};return{baseType:t,isArray:i,baseTypeSize:r,arraySizes:n}},xv=(e,t={})=>{if(Object.keys(t).includes("type"))throw new ea([{keyword:"eth",message:'Either "eth" or "type" can be presented in schema',params:{eth:e},instancePath:"",schemaPath:""}]);let{baseType:i,baseTypeSize:n}=fs(e);if(!i&&!IP.includes(e))throw new ea([{keyword:"eth",message:`Eth data type "${e}" is not valid`,params:{eth:e},instancePath:"",schemaPath:""}]);if(i){if(i==="tuple")throw new Error('"tuple" type is not implemented directly.');return{format:`${i}${n??""}`,required:!0}}return e?{format:e,required:!0}:{}},gh=(e,t="/0")=>{let r={type:"array",items:[],maxItems:e.length,minItems:e.length};for(let[i,n]of e.entries()){let a,u,h=[];bv(n)?(a=n.type,u=n.name,h=n.components):typeof n=="string"?(a=n,u=`${t}/${i}`):Array.isArray(n)&&(n[0]&&typeof n[0]=="string"&&n[0].startsWith("tuple")&&!Array.isArray(n[0])&&n[1]&&Array.isArray(n[1])?(a=n[0],u=`${t}/${i}`,h=n[1]):(a="tuple",u=`${t}/${i}`,h=n));let{baseType:b,isArray:w,arraySizes:T}=fs(a),I,B=r;for(let M=T.length-1;M>0;M-=1)I={type:"array",items:[],maxItems:T[M],minItems:T[M]},T[M]<0&&(delete I.maxItems,delete I.minItems),Array.isArray(B.items)?B.items.length===0?B.items=I:B.items.push(I):B.items=[B.items,I],B=I;if(b==="tuple"&&!w){let M=gh(h,u);M.$id=u,B.items.push(M)}else if(b==="tuple"&&w){let M=T[0],P={$id:u,type:"array",items:gh(h,u),maxItems:M,minItems:M};M<0&&(delete P.maxItems,delete P.minItems),B.items.push(P)}else if(w){let M=T[0],P={type:"array",$id:u,items:xv(String(b)),minItems:M,maxItems:M};M<0&&(delete P.maxItems,delete P.minItems),B.items.push(P)}else Array.isArray(B.items)?B.items.push(Object.assign({$id:u},xv(a))):B.items.items.push(Object.assign({$id:u},xv(a)));B=r}return r},_v=e=>gh(e),yv=(e,t)=>t===1?e:yv(e[0],t-1),vh=(e,t,r)=>{let i=[];for(let[n,a]of e.entries()){let u,h,b=[];bv(a)?(u=a.type,h=a.name,b=a.components):typeof a=="string"?u=a:Array.isArray(a)&&(a[1]&&Array.isArray(a[1])?(u=a[0],b=a[1]):(u="tuple",b=a));let{baseType:w,isArray:T,arraySizes:I}=fs(u),B=Array.isArray(t)?t[n]:t[h];if(w==="tuple"&&!T)i.push(vh(b,B,r));else if(w==="tuple"&&T){let M=[];for(let P of B)if(I.length>1){let L=yv(P,I.length-1),X=[];for(let V of L)X.push(vh(b,V,r));M.push(X)}else M.push(vh(b,P,r));i.push(M)}else i.push(B)}return r=r??[],r.push(...i),r},uw=e=>{if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-55;if(e>=97&&e<=102)return e-87;throw new Error(`Invalid code point: ${e}`)},bh=e=>{if(!hr(e))throw new Error("Invalid hex string");let[t,r]=e.startsWith("-")?[!0,e.slice(1)]:[!1,e],i=BigInt(r);return i>Number.MAX_SAFE_INTEGER?t?-i:i:i<Number.MIN_SAFE_INTEGER?i:t?-1*Number(i):Number(i)},wv=e=>{if((typeof e=="number"||typeof e=="bigint")&&e<0)return`-0x${e.toString(16).slice(1)}`;if((typeof e=="number"||typeof e=="bigint")&&e>=0)return`0x${e.toString(16)}`;if(typeof e=="string"&&hr(e)){let[t,r]=e.startsWith("-")?[!0,e.slice(1)]:[!1,e],i=r.split(/^(-)?0(x|X)/).slice(-1)[0];return`${t?"-":""}0x${i.replace(/^0+/,"").toLowerCase()}`}if(typeof e=="string"&&!hr(e))return wv(BigInt(e));throw new Ef(e)},fw=(e,t,r="0")=>{if(typeof e=="string"&&!hr(e))return e.padStart(t,r);let i=typeof e=="string"&&hr(e)?e:wv(e),[n,a]=i.startsWith("-")?["-0x",i.slice(3)]:["0x",i.slice(2)];return`${n}${a.padStart(t,r)}`};function Ff(e){let t="0x";for(let r of e){let i=r.toString(16);t+=i.length===1?`0${i}`:i}return t}var ta={zero:48,nine:57,A:65,F:70,a:97,f:102};function cw(e){if(e>=ta.zero&&e<=ta.nine)return e-ta.zero;if(e>=ta.A&&e<=ta.F)return e-(ta.A-10);if(e>=ta.a&&e<=ta.f)return e-(ta.a-10)}function xh(e){let t=0;if(e.startsWith("0")&&(e[1]==="x"||e[1]==="X")&&(t=2),e.length%2!==0)throw new Ca(`hex string has odd length: ${e}`);let r=(e.length-t)/2,i=new Uint8Array(r);for(let n=0,a=t;n<r;n+=1){let u=cw(e.charCodeAt(a++)),h=cw(e.charCodeAt(a++));if(u===void 0||h===void 0)throw new Ca(`Invalid byte sequence ("${e[a-2]}${e[a-1]}" in "${e}").`);i[n]=u*16+h}return i}function Sv(e){var t;return!(e instanceof Uint8Array)&&((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"?Uint8Array.from(e):e}var _h=e=>{var t;return e instanceof Uint8Array||((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"},Ev=(e,t={abiType:"bytes"})=>{if(typeof e!="string"&&!Array.isArray(e)&&!_h(e)||typeof e=="string"&&hr(e)&&e.startsWith("-")||typeof e=="string"&&!hr(e))return!1;let r;if(typeof e=="string"){if(e.length%2!==0)return!1;r=xh(e)}else if(Array.isArray(e)){if(e.some(i=>i<0||i>255||!Number.isInteger(i)))return!1;r=new Uint8Array(e)}else r=e;if(t?.abiType){let{baseTypeSize:i}=fs(t.abiType);return i?r.length===i:!0}return t?.size?r.length===t?.size:!0};var lw=e=>{if(!/^(0x)?[0-9a-f]{40}$/i.test(e))return!1;let t=e.slice(2),r=zc(t.toLowerCase()),i=Ff(Sf(Sv(r))).slice(2);for(let n=0;n<40;n+=1)if(parseInt(i[n],16)>7&&t[n].toUpperCase()!==t[n]||parseInt(i[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},ls=(e,t=!0)=>{if(typeof e!="string"&&!_h(e))return!1;let r;return _h(e)?r=Ff(e):typeof e=="string"&&!hr(e)?r=e.toLowerCase().startsWith("0x")?e:`0x${e}`:r=e,/^(0x)?[0-9a-f]{40}$/i.test(r)?/^(0x|0X)?[0-9a-f]{40}$/.test(r)||/^(0x|0X)?[0-9A-F]{40}$/.test(r)?!0:t?lw(r):!0:!1};var Hf;(function(e){e.NUMBER="NUMBER_NUMBER",e.HEX="NUMBER_HEX",e.STR="NUMBER_STR",e.BIGINT="NUMBER_BIGINT"})(Hf||(Hf={}));var zf;(function(e){e.HEX="BYTES_HEX",e.UINT8ARRAY="BYTES_UINT8ARRAY"})(zf||(zf={}));var H$={number:Hf.BIGINT,bytes:zf.HEX},z$={number:Hf.HEX,bytes:zf.HEX};var jf;(function(e){e.EARLIEST="earliest",e.LATEST="latest",e.PENDING="pending",e.SAFE="safe",e.FINALIZED="finalized"})(jf||(jf={}));var pw;(function(e){e.chainstart="chainstart",e.frontier="frontier",e.homestead="homestead",e.dao="dao",e.tangerineWhistle="tangerineWhistle",e.spuriousDragon="spuriousDragon",e.byzantium="byzantium",e.constantinople="constantinople",e.petersburg="petersburg",e.istanbul="istanbul",e.muirGlacier="muirGlacier",e.berlin="berlin",e.london="london",e.altair="altair",e.arrowGlacier="arrowGlacier",e.grayGlacier="grayGlacier",e.bellatrix="bellatrix",e.merge="merge",e.capella="capella",e.shanghai="shanghai"})(pw||(pw={}));var hw=Object.getPrototypeOf(Uint8Array);var dw=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function h(T){try{w(i.next(T))}catch(I){u(I)}}function b(T){try{w(i.throw(T))}catch(I){u(I)}}function w(T){T.done?a(T.value):n(T.value).then(h,b)}w((i=i.apply(e,t||[])).next())})},mw=Symbol.for("web3/base-provider"),Tv=class e{static isWeb3Provider(t){return t instanceof e||!!(t&&t[mw])}get[mw](){return!0}send(t,r){this.request(t).then(i=>{r(null,i)}).catch(i=>{r(i)})}sendAsync(t){return dw(this,void 0,void 0,function*(){return this.request(t)})}asEIP1193Provider(){let t=Object.create(this),r=t.request;return t.request=function(n){return dw(this,void 0,void 0,function*(){return(yield r(n)).result})},t.asEIP1193Provider=void 0,t}};var yh=(e,t)=>{let r=e;for(let i=1;i<t;i+=1)r*=e;return r},Fa=(e,t={abiType:"uint"})=>{if(!["number","string","bigint"].includes(typeof e)||typeof e=="string"&&e.length===0)return!1;let r;if(t?.abiType){let{baseTypeSize:n}=fs(t.abiType);n&&(r=n)}else t.bitSize&&(r=t.bitSize);let i=yh(BigInt(2),BigInt(r??256))-BigInt(1);try{let n=typeof e=="string"&&hr(e)?BigInt(bh(e)):BigInt(e);return n>=0&&n<=i}catch{return!1}},jo=(e,t={abiType:"int"})=>{if(!["number","string","bigint"].includes(typeof e)||typeof e=="number"&&e>Number.MAX_SAFE_INTEGER)return!1;let r;if(t?.abiType){let{baseTypeSize:a,baseType:u}=fs(t.abiType);if(u!=="int")return!1;a&&(r=a)}else t.bitSize&&(r=t.bitSize);let i=yh(BigInt(2),BigInt((r??256)-1)),n=BigInt(-1)*yh(BigInt(2),BigInt((r??256)-1));try{let a=typeof e=="string"&&hr(e)?BigInt(bh(e)):BigInt(e);return a>=n&&a<=i}catch{return!1}},vw=e=>!!(jo(e)||typeof e=="string"&&/[0-9.]/.test(e)&&e.indexOf(".")===e.lastIndexOf(".")||typeof e=="number");var Iv=e=>Fa(e),wh=e=>Object.values(jf).includes(e),Vf=e=>wh(e)||Iv(e);var Sh=e=>typeof e!="string"||!/^(0x)?[0-9a-f]{512}$/i.test(e)?!1:!!(/^(0x)?[0-9a-f]{512}$/.test(e)||/^(0x)?[0-9A-F]{512}$/.test(e));var gw=e=>["number","string","boolean"].includes(typeof e)?typeof e=="boolean"?!0:typeof e=="string"&&!hr(e)?e==="1"||e==="0":typeof e=="string"&&hr(e)?e==="0x1"||e==="0x0":e===1||e===0:!1;var Bi=e=>e==null;var Eh=e=>typeof e!="string"||!/^(0x)?[0-9a-f]{64}$/i.test(e)?!1:!!(/^(0x)?[0-9a-f]{64}$/.test(e)||/^(0x)?[0-9A-F]{64}$/.test(e));var bw=e=>{let t=["fromBlock","toBlock","address","topics","blockHash"];if(Bi(e)||typeof e!="object"||!Object.keys(e).every(r=>t.includes(r))||!Bi(e.fromBlock)&&!Vf(e.fromBlock)||!Bi(e.toBlock)&&!Vf(e.toBlock))return!1;if(!Bi(e.address)){if(Array.isArray(e.address)){if(!e.address.every(r=>ls(r)))return!1}else if(!ls(e.address))return!1}return!(!Bi(e.topics)&&!e.topics.every(r=>Bi(r)?!0:Array.isArray(r)?r.every(i=>Eh(i)):!!Eh(r)))};var Zc={address:e=>ls(e),bloom:e=>Sh(e),blockNumber:e=>Iv(e),blockTag:e=>wh(e),blockNumberOrTag:e=>Vf(e),bool:e=>gw(e),bytes:e=>Ev(e),filter:e=>bw(e),hex:e=>hr(e),uint:e=>Fa(e),int:e=>jo(e),number:e=>vw(e),string:e=>ow(e)};for(let e=8;e<=256;e+=8)Zc[`int${e}`]=t=>jo(t,{bitSize:e}),Zc[`uint${e}`]=t=>Fa(t,{bitSize:e});for(let e=1;e<=32;e+=1)Zc[`bytes${e}`]=t=>Ev(t,{size:e});Zc.bytes256=Zc.bytes;var Rv=Zc;var Kf=e=>{if((!e?.type||e?.type==="object")&&e?.properties){let t={};for(let r of Object.keys(e.properties)){let i=Kf(e.properties[r]);i&&(t[r]=i)}return Array.isArray(e.required)?Fn.object(t).partial().required(e.required.reduce((r,i)=>Object.assign(Object.assign({},r),{[i]:!0}),{})):Fn.object(t).partial()}if(e?.type==="array"&&e?.items){if(Array.isArray(e.items)&&e.items.length>0){let t=[];for(let r of e.items){let i=Kf(r);i&&t.push(i)}return Fn.tuple(t)}return Fn.array(Kf(e.items))}if(e.oneOf&&Array.isArray(e.oneOf))return Fn.union(e.oneOf.map(t=>Kf(t)));if(e?.format){if(!Rv[e.format])throw new ah(e.format);return Fn.any().refine(Rv[e.format],t=>({params:{value:t,format:e.format}}))}return e?.type&&e?.type!=="object"&&typeof Fn[String(e.type)]=="function"?Fn[String(e.type)]():Fn.object({data:Fn.any()}).partial()},Th=class e{static factory(){return e.validatorInstance||(e.validatorInstance=new e),e.validatorInstance}validate(t,r,i){var n,a;let h=Kf(t).safeParse(r);if(!h.success){let b=this.convertErrors((a=(n=h.error)===null||n===void 0?void 0:n.issues)!==null&&a!==void 0?a:[]);if(b){if(i?.silent)return b;throw new ea(b)}}}convertErrors(t){if(t&&Array.isArray(t)&&t.length>0)return t.map(r=>{var i;let n,a,u,h;h=r.path.join("/");let b=String(r.path[r.path.length-1]),w=r.path.join("/");if(r.code===le.too_big)a="maxItems",h=`${w}/maxItems`,u={limit:r.maximum},n=`must NOT have more than ${r.maximum} items`;else if(r.code===le.too_small)a="minItems",h=`${w}/minItems`,u={limit:r.minimum},n=`must NOT have fewer than ${r.minimum} items`;else if(r.code===le.custom){let{value:T,format:I}=(i=r.params)!==null&&i!==void 0?i:{};typeof T>"u"?n=`value at "/${h}" is required`:n=`value "${typeof T=="object"?JSON.stringify(T):T}" at "/${h}" must pass "${I}" validation`,u={value:T}}return{keyword:a??b,instancePath:w?`/${w}`:"",schemaPath:h?`#${h}`:"#",params:u??{value:r.message},message:n??r.message}})}};var Ih=class{constructor(){this._validator=Th.factory()}validateJSONSchema(t,r,i){return this._validator.validate(t,r,i)}validate(t,r,i={silent:!1}){var n,a;let u=_v(t);if(!(Array.isArray(u.items)&&((n=u.items)===null||n===void 0?void 0:n.length)===0&&r.length===0)){if(Array.isArray(u.items)&&((a=u.items)===null||a===void 0?void 0:a.length)===0&&r.length!==0)throw new ea([{instancePath:"/0",schemaPath:"/",keyword:"required",message:"empty schema against data can not be validated",params:r}]);return this._validator.validate(u,r,i)}}};var Wf=new Ih;function Av(e){var t;return e instanceof Uint8Array||((t=e?.constructor)===null||t===void 0?void 0:t.name)==="Uint8Array"}var AY={noether:BigInt(0),wei:BigInt(1),kwei:BigInt(1e3),Kwei:BigInt(1e3),babbage:BigInt(1e3),femtoether:BigInt(1e3),mwei:BigInt(1e6),Mwei:BigInt(1e6),lovelace:BigInt(1e6),picoether:BigInt(1e6),gwei:BigInt(1e9),Gwei:BigInt(1e9),shannon:BigInt(1e9),nanoether:BigInt(1e9),nano:BigInt(1e9),szabo:BigInt(1e12),microether:BigInt(1e12),micro:BigInt(1e12),finney:BigInt(1e15),milliether:BigInt(1e15),milli:BigInt(1e15),ether:BigInt("1000000000000000000"),kether:BigInt("1000000000000000000000"),grand:BigInt("1000000000000000000000"),mether:BigInt("1000000000000000000000000"),gether:BigInt("1000000000000000000000000000"),tether:BigInt("1000000000000000000000000000000")},kv=e=>{if(Wf.validate(["bytes"],[e]),Av(e))return e;if(Array.isArray(e))return new Uint8Array(e);if(typeof e=="string")return Hn.hexToUint8Array(e);throw new Ca(e)},{uint8ArrayToHexString:kP}=Hn,Gf=e=>kP(kv(e));var Jc=(e,t)=>{typeof e!="bigint"&&Wf.validate(["int"],[e]);let r=Hn.numberToHex(e);return t&&(!r.startsWith("-")&&r.length%2===1?r="0x0".concat(r.slice(2)):r.length%2===0&&r.startsWith("-")&&(r="-0x0".concat(r.slice(3)))),r};var Ov=e=>{Wf.validate(["string"],[e]);let t=e.replace(/^(?:\u0000)/,"");return t=t.replace(/(?:\u0000)$/,""),Gf(new TextEncoder().encode(t))};var $f=(e,t)=>{if(typeof e=="string"&&ls(e))return t?"address":`0x${e.toLowerCase().replace(/^0x/i,"")}`;if(typeof e=="boolean")return t?"bool":e?"0x01":"0x00";if(typeof e=="number")return t?e<0?"int256":"uint256":Jc(e);if(typeof e=="bigint")return t?"bigint":Jc(e);if(typeof e=="object"&&e)return t?"string":Ov(JSON.stringify(e));if(typeof e=="string"){if(e.startsWith("-0x")||e.startsWith("-0X"))return t?"int256":Jc(e);if(hr(e))return t?"bytes":e;if(mh(e)&&!jo(e)&&!Fa(e))return t?"bytes":`0x${e}`;if(mh(e)&&!jo(e)&&Fa(e))return t?"uint":Jc(e);if(!Number.isFinite(e))return t?"string":Ov(e)}throw new sh(e)};var yw=Yr(_w(),1);var{parseBaseType:uZ}=Hn;var CP;CP=Symbol.toStringTag;var LP=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Pv=Math.ceil,xn=Math.floor,Mi="[BigNumber Error] ",Sw=Mi+"Number primitive has more than 15 significant digits: ",zn=1e14,tt=14,Bv=9007199254740991,Mv=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Ha=1e7,Zr=1e9;function Ew(e){var t,r,i,n=q.prototype={constructor:q,toString:null,valueOf:null},a=new q(1),u=20,h=4,b=-7,w=21,T=-1e7,I=1e7,B=!1,M=1,P=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},X="0123456789abcdefghijklmnopqrstuvwxyz",V=!0;function q(O,E){var f,c,p,v,g,x,S,_,l=this;if(!(l instanceof q))return new q(O,E);if(E==null){if(O&&O._isBigNumber===!0){l.s=O.s,!O.c||O.e>I?l.c=l.e=null:O.e<T?l.c=[l.e=0]:(l.e=O.e,l.c=O.c.slice());return}if((x=typeof O=="number")&&O*0==0){if(l.s=1/O<0?(O=-O,-1):1,O===~~O){for(v=0,g=O;g>=10;g/=10,v++);v>I?l.c=l.e=null:(l.e=v,l.c=[O]);return}_=String(O)}else{if(!LP.test(_=String(O)))return i(l,_,x);l.s=_.charCodeAt(0)==45?(_=_.slice(1),-1):1}(v=_.indexOf("."))>-1&&(_=_.replace(".","")),(g=_.search(/e/i))>0?(v<0&&(v=g),v+=+_.slice(g+1),_=_.substring(0,g)):v<0&&(v=_.length)}else{if(xr(E,2,X.length,"Base"),E==10&&V)return l=new q(O),Te(l,u+l.e+1,h);if(_=String(O),x=typeof O=="number"){if(O*0!=0)return i(l,_,x,E);if(l.s=1/O<0?(_=_.slice(1),-1):1,q.DEBUG&&_.replace(/^0\.0*|\./,"").length>15)throw Error(Sw+O)}else l.s=_.charCodeAt(0)===45?(_=_.slice(1),-1):1;for(f=X.slice(0,E),v=g=0,S=_.length;g<S;g++)if(f.indexOf(c=_.charAt(g))<0){if(c=="."){if(g>v){v=S;continue}}else if(!p&&(_==_.toUpperCase()&&(_=_.toLowerCase())||_==_.toLowerCase()&&(_=_.toUpperCase()))){p=!0,g=-1,v=0;continue}return i(l,String(O),x,E)}x=!1,_=r(_,E,10,l.s),(v=_.indexOf("."))>-1?_=_.replace(".",""):v=_.length}for(g=0;_.charCodeAt(g)===48;g++);for(S=_.length;_.charCodeAt(--S)===48;);if(_=_.slice(g,++S)){if(S-=g,x&&q.DEBUG&&S>15&&(O>Bv||O!==xn(O)))throw Error(Sw+l.s*O);if((v=v-g-1)>I)l.c=l.e=null;else if(v<T)l.c=[l.e=0];else{if(l.e=v,l.c=[],g=(v+1)%tt,v<0&&(g+=tt),g<S){for(g&&l.c.push(+_.slice(0,g)),S-=tt;g<S;)l.c.push(+_.slice(g,g+=tt));g=tt-(_=_.slice(g)).length}else g-=S;for(;g--;_+="0");l.c.push(+_)}}else l.c=[l.e=0]}q.clone=Ew,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(O){var E,f;if(O!=null)if(typeof O=="object"){if(O.hasOwnProperty(E="DECIMAL_PLACES")&&(f=O[E],xr(f,0,Zr,E),u=f),O.hasOwnProperty(E="ROUNDING_MODE")&&(f=O[E],xr(f,0,8,E),h=f),O.hasOwnProperty(E="EXPONENTIAL_AT")&&(f=O[E],f&&f.pop?(xr(f[0],-Zr,0,E),xr(f[1],0,Zr,E),b=f[0],w=f[1]):(xr(f,-Zr,Zr,E),b=-(w=f<0?-f:f))),O.hasOwnProperty(E="RANGE"))if(f=O[E],f&&f.pop)xr(f[0],-Zr,-1,E),xr(f[1],1,Zr,E),T=f[0],I=f[1];else if(xr(f,-Zr,Zr,E),f)T=-(I=f<0?-f:f);else throw Error(Mi+E+" cannot be zero: "+f);if(O.hasOwnProperty(E="CRYPTO"))if(f=O[E],f===!!f)if(f)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=f;else throw B=!f,Error(Mi+"crypto unavailable");else B=f;else throw Error(Mi+E+" not true or false: "+f);if(O.hasOwnProperty(E="MODULO_MODE")&&(f=O[E],xr(f,0,9,E),M=f),O.hasOwnProperty(E="POW_PRECISION")&&(f=O[E],xr(f,0,Zr,E),P=f),O.hasOwnProperty(E="FORMAT"))if(f=O[E],typeof f=="object")L=f;else throw Error(Mi+E+" not an object: "+f);if(O.hasOwnProperty(E="ALPHABET"))if(f=O[E],typeof f=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(f))V=f.slice(0,10)=="0123456789",X=f;else throw Error(Mi+E+" invalid: "+f)}else throw Error(Mi+"Object expected: "+O);return{DECIMAL_PLACES:u,ROUNDING_MODE:h,EXPONENTIAL_AT:[b,w],RANGE:[T,I],CRYPTO:B,MODULO_MODE:M,POW_PRECISION:P,FORMAT:L,ALPHABET:X}},q.isBigNumber=function(O){if(!O||O._isBigNumber!==!0)return!1;if(!q.DEBUG)return!0;var E,f,c=O.c,p=O.e,v=O.s;e:if({}.toString.call(c)=="[object Array]"){if((v===1||v===-1)&&p>=-Zr&&p<=Zr&&p===xn(p)){if(c[0]===0){if(p===0&&c.length===1)return!0;break e}if(E=(p+1)%tt,E<1&&(E+=tt),String(c[0]).length==E){for(E=0;E<c.length;E++)if(f=c[E],f<0||f>=zn||f!==xn(f))break e;if(f!==0)return!0}}}else if(c===null&&p===null&&(v===null||v===1||v===-1))return!0;throw Error(Mi+"Invalid BigNumber: "+O)},q.maximum=q.max=function(){return fe(arguments,-1)},q.minimum=q.min=function(){return fe(arguments,1)},q.random=function(){var O=9007199254740992,E=Math.random()*O&2097151?function(){return xn(Math.random()*O)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(f){var c,p,v,g,x,S=0,_=[],l=new q(a);if(f==null?f=u:xr(f,0,Zr),g=Pv(f/tt),B)if(crypto.getRandomValues){for(c=crypto.getRandomValues(new Uint32Array(g*=2));S<g;)x=c[S]*131072+(c[S+1]>>>11),x>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),c[S]=p[0],c[S+1]=p[1]):(_.push(x%1e14),S+=2);S=g/2}else if(crypto.randomBytes){for(c=crypto.randomBytes(g*=7);S<g;)x=(c[S]&31)*281474976710656+c[S+1]*1099511627776+c[S+2]*4294967296+c[S+3]*16777216+(c[S+4]<<16)+(c[S+5]<<8)+c[S+6],x>=9e15?crypto.randomBytes(7).copy(c,S):(_.push(x%1e14),S+=7);S=g/7}else throw B=!1,Error(Mi+"crypto unavailable");if(!B)for(;S<g;)x=E(),x<9e15&&(_[S++]=x%1e14);for(g=_[--S],f%=tt,g&&f&&(x=Mv[tt-f],_[S]=xn(g/x)*x);_[S]===0;_.pop(),S--);if(S<0)_=[v=0];else{for(v=-1;_[0]===0;_.splice(0,1),v-=tt);for(S=1,x=_[0];x>=10;x/=10,S++);S<tt&&(v-=tt-S)}return l.e=v,l.c=_,l}}(),q.sum=function(){for(var O=1,E=arguments,f=new q(E[0]);O<E.length;)f=f.plus(E[O++]);return f},r=function(){var O="0123456789";function E(f,c,p,v){for(var g,x=[0],S,_=0,l=f.length;_<l;){for(S=x.length;S--;x[S]*=c);for(x[0]+=v.indexOf(f.charAt(_++)),g=0;g<x.length;g++)x[g]>p-1&&(x[g+1]==null&&(x[g+1]=0),x[g+1]+=x[g]/p|0,x[g]%=p)}return x.reverse()}return function(f,c,p,v,g){var x,S,_,l,m,A,U,j,Z=f.indexOf("."),se=u,ae=h;for(Z>=0&&(l=P,P=0,f=f.replace(".",""),j=new q(c),A=j.pow(f.length-Z),P=l,j.c=E(ra(bn(A.c),A.e,"0"),10,p,O),j.e=j.c.length),U=E(f,c,p,g?(x=X,O):(x=O,X)),_=l=U.length;U[--l]==0;U.pop());if(!U[0])return x.charAt(0);if(Z<0?--_:(A.c=U,A.e=_,A.s=v,A=t(A,j,se,ae,p),U=A.c,m=A.r,_=A.e),S=_+se+1,Z=U[S],l=p/2,m=m||S<0||U[S+1]!=null,m=ae<4?(Z!=null||m)&&(ae==0||ae==(A.s<0?3:2)):Z>l||Z==l&&(ae==4||m||ae==6&&U[S-1]&1||ae==(A.s<0?8:7)),S<1||!U[0])f=m?ra(x.charAt(1),-se,x.charAt(0)):x.charAt(0);else{if(U.length=S,m)for(--p;++U[--S]>p;)U[S]=0,S||(++_,U=[1].concat(U));for(l=U.length;!U[--l];);for(Z=0,f="";Z<=l;f+=x.charAt(U[Z++]));f=ra(f,_,x.charAt(0))}return f}}(),t=function(){function O(c,p,v){var g,x,S,_,l=0,m=c.length,A=p%Ha,U=p/Ha|0;for(c=c.slice();m--;)S=c[m]%Ha,_=c[m]/Ha|0,g=U*S+_*A,x=A*S+g%Ha*Ha+l,l=(x/v|0)+(g/Ha|0)+U*_,c[m]=x%v;return l&&(c=[l].concat(c)),c}function E(c,p,v,g){var x,S;if(v!=g)S=v>g?1:-1;else for(x=S=0;x<v;x++)if(c[x]!=p[x]){S=c[x]>p[x]?1:-1;break}return S}function f(c,p,v,g){for(var x=0;v--;)c[v]-=x,x=c[v]<p[v]?1:0,c[v]=x*g+c[v]-p[v];for(;!c[0]&&c.length>1;c.splice(0,1));}return function(c,p,v,g,x){var S,_,l,m,A,U,j,Z,se,ae,he,Ee,me,dt,St,Oe,st,rt=c.s==p.s?1:-1,Re=c.c,Ae=p.c;if(!Re||!Re[0]||!Ae||!Ae[0])return new q(!c.s||!p.s||(Re?Ae&&Re[0]==Ae[0]:!Ae)?NaN:Re&&Re[0]==0||!Ae?rt*0:rt/0);for(Z=new q(rt),se=Z.c=[],_=c.e-p.e,rt=v+_+1,x||(x=zn,_=_n(c.e/tt)-_n(p.e/tt),rt=rt/tt|0),l=0;Ae[l]==(Re[l]||0);l++);if(Ae[l]>(Re[l]||0)&&_--,rt<0)se.push(1),m=!0;else{for(dt=Re.length,Oe=Ae.length,l=0,rt+=2,A=xn(x/(Ae[0]+1)),A>1&&(Ae=O(Ae,A,x),Re=O(Re,A,x),Oe=Ae.length,dt=Re.length),me=Oe,ae=Re.slice(0,Oe),he=ae.length;he<Oe;ae[he++]=0);st=Ae.slice(),st=[0].concat(st),St=Ae[0],Ae[1]>=x/2&&St++;do{if(A=0,S=E(Ae,ae,Oe,he),S<0){if(Ee=ae[0],Oe!=he&&(Ee=Ee*x+(ae[1]||0)),A=xn(Ee/St),A>1)for(A>=x&&(A=x-1),U=O(Ae,A,x),j=U.length,he=ae.length;E(U,ae,j,he)==1;)A--,f(U,Oe<j?st:Ae,j,x),j=U.length,S=1;else A==0&&(S=A=1),U=Ae.slice(),j=U.length;if(j<he&&(U=[0].concat(U)),f(ae,U,he,x),he=ae.length,S==-1)for(;E(Ae,ae,Oe,he)<1;)A++,f(ae,Oe<he?st:Ae,he,x),he=ae.length}else S===0&&(A++,ae=[0]);se[l++]=A,ae[0]?ae[he++]=Re[me]||0:(ae=[Re[me]],he=1)}while((me++<dt||ae[0]!=null)&&rt--);m=ae[0]!=null,se[0]||se.splice(0,1)}if(x==zn){for(l=1,rt=se[0];rt>=10;rt/=10,l++);Te(Z,v+(Z.e=l+_*tt-1)+1,g,m)}else Z.e=_,Z.r=+m;return Z}}();function ee(O,E,f,c){var p,v,g,x,S;if(f==null?f=h:xr(f,0,8),!O.c)return O.toString();if(p=O.c[0],g=O.e,E==null)S=bn(O.c),S=c==1||c==2&&(g<=b||g>=w)?Oh(S,g):ra(S,g,"0");else if(O=Te(new q(O),E,f),v=O.e,S=bn(O.c),x=S.length,c==1||c==2&&(E<=v||v<=b)){for(;x<E;S+="0",x++);S=Oh(S,v)}else if(E-=g,S=ra(S,v,"0"),v+1>x){if(--E>0)for(S+=".";E--;S+="0");}else if(E+=v-x,E>0)for(v+1==x&&(S+=".");E--;S+="0");return O.s<0&&p?"-"+S:S}function fe(O,E){for(var f,c,p=1,v=new q(O[0]);p<O.length;p++)c=new q(O[p]),(!c.s||(f=Vo(v,c))===E||f===0&&v.s===E)&&(v=c);return v}function _e(O,E,f){for(var c=1,p=E.length;!E[--p];E.pop());for(p=E[0];p>=10;p/=10,c++);return(f=c+f*tt-1)>I?O.c=O.e=null:f<T?O.c=[O.e=0]:(O.e=f,O.c=E),O}i=function(){var O=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,f=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,g,x,S){var _,l=x?g:g.replace(p,"");if(c.test(l))v.s=isNaN(l)?null:l<0?-1:1;else{if(!x&&(l=l.replace(O,function(m,A,U){return _=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!S||S==_?A:m}),S&&(_=S,l=l.replace(E,"$1").replace(f,"0.$1")),g!=l))return new q(l,_);if(q.DEBUG)throw Error(Mi+"Not a"+(S?" base "+S:"")+" number: "+g);v.s=null}v.c=v.e=null}}();function Te(O,E,f,c){var p,v,g,x,S,_,l,m=O.c,A=Mv;if(m){e:{for(p=1,x=m[0];x>=10;x/=10,p++);if(v=E-p,v<0)v+=tt,g=E,S=m[_=0],l=xn(S/A[p-g-1]%10);else if(_=Pv((v+1)/tt),_>=m.length)if(c){for(;m.length<=_;m.push(0));S=l=0,p=1,v%=tt,g=v-tt+1}else break e;else{for(S=x=m[_],p=1;x>=10;x/=10,p++);v%=tt,g=v-tt+p,l=g<0?0:xn(S/A[p-g-1]%10)}if(c=c||E<0||m[_+1]!=null||(g<0?S:S%A[p-g-1]),c=f<4?(l||c)&&(f==0||f==(O.s<0?3:2)):l>5||l==5&&(f==4||c||f==6&&(v>0?g>0?S/A[p-g]:0:m[_-1])%10&1||f==(O.s<0?8:7)),E<1||!m[0])return m.length=0,c?(E-=O.e+1,m[0]=A[(tt-E%tt)%tt],O.e=-E||0):m[0]=O.e=0,O;if(v==0?(m.length=_,x=1,_--):(m.length=_+1,x=A[tt-v],m[_]=g>0?xn(S/A[p-g]%A[g])*x:0),c)for(;;)if(_==0){for(v=1,g=m[0];g>=10;g/=10,v++);for(g=m[0]+=x,x=1;g>=10;g/=10,x++);v!=x&&(O.e++,m[0]==zn&&(m[0]=1));break}else{if(m[_]+=x,m[_]!=zn)break;m[_--]=0,x=1}for(v=m.length;m[--v]===0;m.pop());}O.e>I?O.c=O.e=null:O.e<T&&(O.c=[O.e=0])}return O}function be(O){var E,f=O.e;return f===null?O.toString():(E=bn(O.c),E=f<=b||f>=w?Oh(E,f):ra(E,f,"0"),O.s<0?"-"+E:E)}return n.absoluteValue=n.abs=function(){var O=new q(this);return O.s<0&&(O.s=1),O},n.comparedTo=function(O,E){return Vo(this,new q(O,E))},n.decimalPlaces=n.dp=function(O,E){var f,c,p,v=this;if(O!=null)return xr(O,0,Zr),E==null?E=h:xr(E,0,8),Te(new q(v),O+v.e+1,E);if(!(f=v.c))return null;if(c=((p=f.length-1)-_n(this.e/tt))*tt,p=f[p])for(;p%10==0;p/=10,c--);return c<0&&(c=0),c},n.dividedBy=n.div=function(O,E){return t(this,new q(O,E),u,h)},n.dividedToIntegerBy=n.idiv=function(O,E){return t(this,new q(O,E),0,1)},n.exponentiatedBy=n.pow=function(O,E){var f,c,p,v,g,x,S,_,l,m=this;if(O=new q(O),O.c&&!O.isInteger())throw Error(Mi+"Exponent not an integer: "+be(O));if(E!=null&&(E=new q(E)),x=O.e>14,!m.c||!m.c[0]||m.c[0]==1&&!m.e&&m.c.length==1||!O.c||!O.c[0])return l=new q(Math.pow(+be(m),x?O.s*(2-Ah(O)):+be(O))),E?l.mod(E):l;if(S=O.s<0,E){if(E.c?!E.c[0]:!E.s)return new q(NaN);c=!S&&m.isInteger()&&E.isInteger(),c&&(m=m.mod(E))}else{if(O.e>9&&(m.e>0||m.e<-1||(m.e==0?m.c[0]>1||x&&m.c[1]>=24e7:m.c[0]<8e13||x&&m.c[0]<=9999975e7)))return v=m.s<0&&Ah(O)?-0:0,m.e>-1&&(v=1/v),new q(S?1/v:v);P&&(v=Pv(P/tt+2))}for(x?(f=new q(.5),S&&(O.s=1),_=Ah(O)):(p=Math.abs(+be(O)),_=p%2),l=new q(a);;){if(_){if(l=l.times(m),!l.c)break;v?l.c.length>v&&(l.c.length=v):c&&(l=l.mod(E))}if(p){if(p=xn(p/2),p===0)break;_=p%2}else if(O=O.times(f),Te(O,O.e+1,1),O.e>14)_=Ah(O);else{if(p=+be(O),p===0)break;_=p%2}m=m.times(m),v?m.c&&m.c.length>v&&(m.c.length=v):c&&(m=m.mod(E))}return c?l:(S&&(l=a.div(l)),E?l.mod(E):v?Te(l,P,h,g):l)},n.integerValue=function(O){var E=new q(this);return O==null?O=h:xr(O,0,8),Te(E,E.e+1,O)},n.isEqualTo=n.eq=function(O,E){return Vo(this,new q(O,E))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(O,E){return Vo(this,new q(O,E))>0},n.isGreaterThanOrEqualTo=n.gte=function(O,E){return(E=Vo(this,new q(O,E)))===1||E===0},n.isInteger=function(){return!!this.c&&_n(this.e/tt)>this.c.length-2},n.isLessThan=n.lt=function(O,E){return Vo(this,new q(O,E))<0},n.isLessThanOrEqualTo=n.lte=function(O,E){return(E=Vo(this,new q(O,E)))===-1||E===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(O,E){var f,c,p,v,g=this,x=g.s;if(O=new q(O,E),E=O.s,!x||!E)return new q(NaN);if(x!=E)return O.s=-E,g.plus(O);var S=g.e/tt,_=O.e/tt,l=g.c,m=O.c;if(!S||!_){if(!l||!m)return l?(O.s=-E,O):new q(m?g:NaN);if(!l[0]||!m[0])return m[0]?(O.s=-E,O):new q(l[0]?g:h==3?-0:0)}if(S=_n(S),_=_n(_),l=l.slice(),x=S-_){for((v=x<0)?(x=-x,p=l):(_=S,p=m),p.reverse(),E=x;E--;p.push(0));p.reverse()}else for(c=(v=(x=l.length)<(E=m.length))?x:E,x=E=0;E<c;E++)if(l[E]!=m[E]){v=l[E]<m[E];break}if(v&&(p=l,l=m,m=p,O.s=-O.s),E=(c=m.length)-(f=l.length),E>0)for(;E--;l[f++]=0);for(E=zn-1;c>x;){if(l[--c]<m[c]){for(f=c;f&&!l[--f];l[f]=E);--l[f],l[c]+=zn}l[c]-=m[c]}for(;l[0]==0;l.splice(0,1),--_);return l[0]?_e(O,l,_):(O.s=h==3?-1:1,O.c=[O.e=0],O)},n.modulo=n.mod=function(O,E){var f,c,p=this;return O=new q(O,E),!p.c||!O.s||O.c&&!O.c[0]?new q(NaN):!O.c||p.c&&!p.c[0]?new q(p):(M==9?(c=O.s,O.s=1,f=t(p,O,0,3),O.s=c,f.s*=c):f=t(p,O,0,M),O=p.minus(f.times(O)),!O.c[0]&&M==1&&(O.s=p.s),O)},n.multipliedBy=n.times=function(O,E){var f,c,p,v,g,x,S,_,l,m,A,U,j,Z,se,ae=this,he=ae.c,Ee=(O=new q(O,E)).c;if(!he||!Ee||!he[0]||!Ee[0])return!ae.s||!O.s||he&&!he[0]&&!Ee||Ee&&!Ee[0]&&!he?O.c=O.e=O.s=null:(O.s*=ae.s,!he||!Ee?O.c=O.e=null:(O.c=[0],O.e=0)),O;for(c=_n(ae.e/tt)+_n(O.e/tt),O.s*=ae.s,S=he.length,m=Ee.length,S<m&&(j=he,he=Ee,Ee=j,p=S,S=m,m=p),p=S+m,j=[];p--;j.push(0));for(Z=zn,se=Ha,p=m;--p>=0;){for(f=0,A=Ee[p]%se,U=Ee[p]/se|0,g=S,v=p+g;v>p;)_=he[--g]%se,l=he[g]/se|0,x=U*_+l*A,_=A*_+x%se*se+j[v]+f,f=(_/Z|0)+(x/se|0)+U*l,j[v--]=_%Z;j[v]=f}return f?++c:j.splice(0,1),_e(O,j,c)},n.negated=function(){var O=new q(this);return O.s=-O.s||null,O},n.plus=function(O,E){var f,c=this,p=c.s;if(O=new q(O,E),E=O.s,!p||!E)return new q(NaN);if(p!=E)return O.s=-E,c.minus(O);var v=c.e/tt,g=O.e/tt,x=c.c,S=O.c;if(!v||!g){if(!x||!S)return new q(p/0);if(!x[0]||!S[0])return S[0]?O:new q(x[0]?c:p*0)}if(v=_n(v),g=_n(g),x=x.slice(),p=v-g){for(p>0?(g=v,f=S):(p=-p,f=x),f.reverse();p--;f.push(0));f.reverse()}for(p=x.length,E=S.length,p-E<0&&(f=S,S=x,x=f,E=p),p=0;E;)p=(x[--E]=x[E]+S[E]+p)/zn|0,x[E]=zn===x[E]?0:x[E]%zn;return p&&(x=[p].concat(x),++g),_e(O,x,g)},n.precision=n.sd=function(O,E){var f,c,p,v=this;if(O!=null&&O!==!!O)return xr(O,1,Zr),E==null?E=h:xr(E,0,8),Te(new q(v),O,E);if(!(f=v.c))return null;if(p=f.length-1,c=p*tt+1,p=f[p]){for(;p%10==0;p/=10,c--);for(p=f[0];p>=10;p/=10,c++);}return O&&v.e+1>c&&(c=v.e+1),c},n.shiftedBy=function(O){return xr(O,-Bv,Bv),this.times("1e"+O)},n.squareRoot=n.sqrt=function(){var O,E,f,c,p,v=this,g=v.c,x=v.s,S=v.e,_=u+4,l=new q("0.5");if(x!==1||!g||!g[0])return new q(!x||x<0&&(!g||g[0])?NaN:g?v:1/0);if(x=Math.sqrt(+be(v)),x==0||x==1/0?(E=bn(g),(E.length+S)%2==0&&(E+="0"),x=Math.sqrt(+E),S=_n((S+1)/2)-(S<0||S%2),x==1/0?E="5e"+S:(E=x.toExponential(),E=E.slice(0,E.indexOf("e")+1)+S),f=new q(E)):f=new q(x+""),f.c[0]){for(S=f.e,x=S+_,x<3&&(x=0);;)if(p=f,f=l.times(p.plus(t(v,p,_,1))),bn(p.c).slice(0,x)===(E=bn(f.c)).slice(0,x))if(f.e<S&&--x,E=E.slice(x-3,x+1),E=="9999"||!c&&E=="4999"){if(!c&&(Te(p,p.e+u+2,0),p.times(p).eq(v))){f=p;break}_+=4,x+=4,c=1}else{(!+E||!+E.slice(1)&&E.charAt(0)=="5")&&(Te(f,f.e+u+2,1),O=!f.times(f).eq(v));break}}return Te(f,f.e+u+1,h,O)},n.toExponential=function(O,E){return O!=null&&(xr(O,0,Zr),O++),ee(this,O,E,1)},n.toFixed=function(O,E){return O!=null&&(xr(O,0,Zr),O=O+this.e+1),ee(this,O,E)},n.toFormat=function(O,E,f){var c,p=this;if(f==null)O!=null&&E&&typeof E=="object"?(f=E,E=null):O&&typeof O=="object"?(f=O,O=E=null):f=L;else if(typeof f!="object")throw Error(Mi+"Argument not an object: "+f);if(c=p.toFixed(O,E),p.c){var v,g=c.split("."),x=+f.groupSize,S=+f.secondaryGroupSize,_=f.groupSeparator||"",l=g[0],m=g[1],A=p.s<0,U=A?l.slice(1):l,j=U.length;if(S&&(v=x,x=S,S=v,j-=v),x>0&&j>0){for(v=j%x||x,l=U.substr(0,v);v<j;v+=x)l+=_+U.substr(v,x);S>0&&(l+=_+U.slice(v)),A&&(l="-"+l)}c=m?l+(f.decimalSeparator||"")+((S=+f.fractionGroupSize)?m.replace(new RegExp("\\d{"+S+"}\\B","g"),"$&"+(f.fractionGroupSeparator||"")):m):l}return(f.prefix||"")+c+(f.suffix||"")},n.toFraction=function(O){var E,f,c,p,v,g,x,S,_,l,m,A,U=this,j=U.c;if(O!=null&&(x=new q(O),!x.isInteger()&&(x.c||x.s!==1)||x.lt(a)))throw Error(Mi+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+be(x));if(!j)return new q(U);for(E=new q(a),_=f=new q(a),c=S=new q(a),A=bn(j),v=E.e=A.length-U.e-1,E.c[0]=Mv[(g=v%tt)<0?tt+g:g],O=!O||x.comparedTo(E)>0?v>0?E:_:x,g=I,I=1/0,x=new q(A),S.c[0]=0;l=t(x,E,0,1),p=f.plus(l.times(c)),p.comparedTo(O)!=1;)f=c,c=p,_=S.plus(l.times(p=_)),S=p,E=x.minus(l.times(p=E)),x=p;return p=t(O.minus(f),c,0,1),S=S.plus(p.times(_)),f=f.plus(p.times(c)),S.s=_.s=U.s,v=v*2,m=t(_,c,v,h).minus(U).abs().comparedTo(t(S,f,v,h).minus(U).abs())<1?[_,c]:[S,f],I=g,m},n.toNumber=function(){return+be(this)},n.toPrecision=function(O,E){return O!=null&&xr(O,1,Zr),ee(this,O,E,2)},n.toString=function(O){var E,f=this,c=f.s,p=f.e;return p===null?c?(E="Infinity",c<0&&(E="-"+E)):E="NaN":(O==null?E=p<=b||p>=w?Oh(bn(f.c),p):ra(bn(f.c),p,"0"):O===10&&V?(f=Te(new q(f),u+p+1,h),E=ra(bn(f.c),f.e,"0")):(xr(O,2,X.length,"Base"),E=r(ra(bn(f.c),p,"0"),10,O,c,!0)),c<0&&f.c[0]&&(E="-"+E)),E},n.valueOf=n.toJSON=function(){return be(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,e!=null&&q.set(e),q}function _n(e){var t=e|0;return e>0||e===t?t:t-1}function bn(e){for(var t,r,i=1,n=e.length,a=e[0]+"";i<n;){for(t=e[i++]+"",r=tt-t.length;r--;t="0"+t);a+=t}for(n=a.length;a.charCodeAt(--n)===48;);return a.slice(0,n+1||1)}function Vo(e,t){var r,i,n=e.c,a=t.c,u=e.s,h=t.s,b=e.e,w=t.e;if(!u||!h)return null;if(r=n&&!n[0],i=a&&!a[0],r||i)return r?i?0:-h:u;if(u!=h)return u;if(r=u<0,i=b==w,!n||!a)return i?0:!n^r?1:-1;if(!i)return b>w^r?1:-1;for(h=(b=n.length)<(w=a.length)?b:w,u=0;u<h;u++)if(n[u]!=a[u])return n[u]>a[u]^r?1:-1;return b==w?0:b>w^r?1:-1}function xr(e,t,r,i){if(e<t||e>r||e!==xn(e))throw Error(Mi+(i||"Argument")+(typeof e=="number"?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Ah(e){var t=e.c.length-1;return _n(e.e/tt)==t&&e.c[t]%2!=0}function Oh(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ra(e,t,r){var i,n;if(t<0){for(n=r+".";++t;n+=r);e=n+e}else if(i=e.length,++t>i){for(n=r,t-=i;--t;n+=r);e+=n}else t<i&&(e=e.slice(0,t)+"."+e.slice(t));return e}var DP=Ew(),Lr=DP;var GB=Yr(Aw(),1),$B=Yr(Kv(),1),XB=Yr(Gv(),1),zh=Yr(eg(),1),YB=Yr(TS(),1);var IS=zh.default;var rg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ZB=(e,t)=>{let r="1"+"0".repeat(t),i=new Lr(e.toString(10),10);return $f(i.times(r).toString(16))},JB=(e,t)=>{let r="1"+"0".repeat(t),i=new Lr(e.toString(),10);return parseFloat(i.dividedBy(r).toString())},QB=e=>{typeof e=="string"&&(e=new Uint8Array(Buffer.from(e)));let t=[],r=BigInt("0x"+Buffer.from(e).toString("hex"));for(;r>BigInt(0);){let i=Number(r%BigInt(58));t.unshift(rg[i]),r=r/BigInt(58)}for(let i=0;i<e.length&&e[i]===0;i++)t.unshift(rg[0]);return t.join("")},eM=e=>{let t=BigInt(0);for(let n=0;n<e.length;n++)t=t*BigInt(58)+BigInt(rg.indexOf(e[n]));let r=t.toString(16),i=r.length%2===0?r:"0"+r;return new Uint8Array(Buffer.from(i,"hex"))},tM=e=>Buffer.from(e).toString("utf8"),rM=e=>Buffer.from(e,"utf8"),iM=e=>!isNaN(Number(e)),ig=async e=>{await new Promise(t=>setTimeout(t,e))},ng=(e,t)=>JSON.stringify(e)===JSON.stringify(t),nM=e=>{let[t,r]=e.toExponential().split("e").map(n=>parseFloat(n)),i=(t*Math.pow(10,r)).toString();return i=parseFloat(i).toString(),i},al=async e=>await new Promise((t,r)=>{let i;typeof window<"u"?i=new WebSocket(e):i=new zh.default(e),i.onopen=()=>{t(!0),i.close()},i.onerror=n=>{r(new Error(n.message)),i.close()}}),jh={add:(e,t,r=18)=>parseFloat(new Lr(e).plus(new Lr(t)).toFixed(r)),sub:(e,t,r=18)=>parseFloat(new Lr(e).minus(new Lr(t)).toFixed(r)),mul:(e,t,r=18)=>parseFloat(new Lr(e).times(new Lr(t)).toFixed(r)),div:(e,t,r=18)=>parseFloat(new Lr(e).div(new Lr(t)).toFixed(r)),pow:(e,t,r=18)=>parseFloat(new Lr(e).pow(t).toFixed(r)),sqrt:(e,t=18)=>parseFloat(new Lr(e).sqrt().toFixed(t)),abs:(e,t=18)=>parseFloat(new Lr(e).absoluteValue().toFixed(t)),ceil:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_CEIL).toFixed(t)),floor:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_FLOOR).toFixed(t)),round:(e,t=18)=>parseFloat(new Lr(e).integerValue(Lr.ROUND_HALF_UP).toFixed(t))},sM=()=>typeof window>"u"?!1:function(e){return!!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(e.substr(0,4)))}(navigator.userAgent||navigator.vendor||window.opera),aM=()=>{if(typeof window>"u")return!1;let e=window.navigator;if(window.WebViewJavascriptBridge||window.webkit&&window.webkit.messageHandlers||e.userAgent.match(/WebView/i))return!0;let t=e.standalone,r=e.userAgent.toLowerCase(),i=/safari/.test(r);return/iphone|ipod|ipad/.test(r)?!t&&!i:r.includes("wv")};var ag={};Oa(ag,{AssetDirectionEnum:()=>sg,ErrorTypeEnum:()=>ol,TransactionListenerProcessIndex:()=>Wh,TransactionStatusEnum:()=>Kh,TransactionTypeEnum:()=>Vh,WalletPlatformEnum:()=>RS});var sg=(r=>(r.INCOMING="INCOMING",r.OUTGOING="OUTGOING",r))(sg||{}),Vh=(a=>(a.GENERAL="GENERAL",a.CONTRACT="CONTRACT",a.COIN="COIN",a.TOKEN="TOKEN",a.NFT="NFT",a))(Vh||{}),Kh=(i=>(i.FAILED="FAILED",i.PENDING="PENDING",i.CONFIRMED="CONFIRMED",i))(Kh||{}),ol=(c=>(c.RPC_TIMEOUT="RPC_TIMEOUT",c.RPC_REQUEST_ERROR="RPC_REQUEST_ERROR",c.RPC_ACCESS_DENIED="RPC_ACCESS_DENIED",c.WS_URL_NOT_DEFINED="WS_URL_NOT_DEFINED",c.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",c.UNACCEPTED_CHAIN="UNACCEPTED_CHAIN",c.UNAUTHORIZED_ADDRESS="UNAUTHORIZED_ADDRESS",c.INSUFFICIENT_BALANCE="INSUFFICIENT_BALANCE",c.INVALID_AMOUNT="INVALID_AMOUNT",c.INVALID_ADDRESS="INVALID_ADDRESS",c.INVALID_PRIVATE_KEY="INVALID_PRIVATE_KEY",c.INVALID_PUBLIC_KEY="INVALID_PUBLIC_KEY",c.INVALID_TRANSACTION_ID="INVALID_TRANSACTION_ID",c.PROVIDER_IS_REQUIRED="PROVIDER_IS_REQUIRED",c.PROVIDER_IS_NOT_INITIALIZED="PROVIDER_IS_NOT_INITIALIZED",c.PROVIDER_IS_ALREADY_INITIALIZED="PROVIDER_IS_ALREADY_INITIALIZED",c.WALLET_ALREADY_PROCESSING="WALLET_ALREADY_PROCESSING",c.WALLET_CONNECT_REJECTED="WALLET_CONNECT_REJECTED",c.WALLET_REQUEST_REJECTED="WALLET_REQUEST_REJECTED",c.WALLET_CONNECTION_FAILED="WALLET_CONNECTION_FAILED",c.WALLET_CONNECTION_TIMEOUT="WALLET_CONNECTION_TIMEOUT",c.TRANSACTION_CREATION_FAILED="TRANSACTION_CREATION_FAILED",c.TRANSACTION_NOT_FOUND="TRANSACTION_NOT_FOUND",c.CLOSED_WALLETCONNECT_MODAL="CLOSED_WALLETCONNECT_MODAL",c.PROJECT_ID_IS_REQUIRED="PROJECT_ID_IS_REQUIRED",c.METADATA_IS_REQUIRED="METADATA_IS_REQUIRED",c.CONFIG_IS_REQUIRED="CONFIG_IS_REQUIRED",c))(ol||{}),RS=(n=>(n.BROWSER="BROWSER",n.MOBILE="MOBILE",n.DESKTOP="DESKTOP",n.UNIVERSAL="UNIVERSAL",n))(RS||{});var Wh={GENERAL:"generalProcess",CONTRACT:"contractProcess",COIN:"coinProcess",TOKEN:"tokenProcess",NFT:"nftProcess"};var Vn=class e{network;api;explorer;wsUrl;blockCypherToken;defaultBlockCypherToken="49d43a59a4f24d31a9731eb067ab971c";static _instance;constructor(t){this.update(t)}static get instance(){if(e._instance===void 0)throw new Error("PROVIDER_IS_NOT_INITIALIZED");return e._instance}static initialize(t){if(e._instance!==void 0)throw new Error("PROVIDER_IS_ALREADY_INITIALIZED");e._instance=new e(t)}async checkRpcConnection(t){try{let r=await vn.get(t??this.createEndpoint("blocks/tip/height"));return r.status!==200?new Error(r.statusText+": "+JSON.stringify(r.data)):!0}catch(r){return r}}async checkWsConnection(t){try{let r=await al(t??this.wsUrl);return r instanceof Error?r:!0}catch(r){return r}}update(t){if(this.network=t,e._instance=this,this.blockCypherToken=this.network.blockCypherToken,this.network.testnet){this.api="https://blockstream.info/testnet/api/",this.explorer="https://blockstream.info/testnet/";let r=this.network.blockCypherToken??this.defaultBlockCypherToken;this.wsUrl="wss://socket.blockcypher.com/v1/btc/test3?token="+r}else this.api="https://blockstream.info/api/",this.explorer="https://blockstream.info/",this.network.blockCypherToken!==void 0?this.wsUrl="wss://socket.blockcypher.com/v1/btc/main?token="+this.network.blockCypherToken:this.wsUrl="wss://ws.blockchain.info/inv"}createEndpoint(t){return this.api+t}isTestnet(){return this.network?.testnet??!1}};var hx={};Oa(hx,{Coin:()=>px});var cg={};Oa(cg,{base58Decode:()=>eM,base58Encode:()=>QB,bufferToString:()=>tM,checkWebSocket:()=>al,fromSatoshi:()=>hs,hexToNumber:()=>JB,isMobile:()=>sM,isNumeric:()=>iM,isWebview:()=>aM,math:()=>jh,numberToHex:()=>ZB,objectsEqual:()=>ng,sleep:()=>ig,stringToBuffer:()=>rM,toHex:()=>$f,toReadableString:()=>nM,toSatoshi:()=>og});var hs=e=>jh.div(e,1e8,8),og=e=>jh.mul(e,1e8,8);var xc=Yr(MT(),1);var $l=class{rawData;signedData;provider;constructor(t,r){this.rawData=t,this.provider=r??Vn.instance}async sign(t){return this.rawData.bitcoreLib.sign(t),this.signedData=this.rawData.bitcoreLib.serialize(),this}async send(){try{return(await vn({method:"POST",url:this.provider.createEndpoint("tx"),data:this.signedData})).data}catch(t){throw new Error(JSON.stringify(t.response?.data))}}getRawData(){return this.rawData}getSignedData(){return this.signedData??""}};var px=class{provider;constructor(t){this.provider=t??Vn.instance}getName(){return"Bitcoin"}getSymbol(){return"BTC"}getDecimals(){return 8}async getBalance(t){let r=this.provider.createEndpoint("address/"+t),i=await vn.get(r).then(a=>a.data),n=i.chain_stats.funded_txo_sum-i.chain_stats.spent_txo_sum;return hs(n)}async transfer(t,r,i){if(i<0)throw new Error("INVALID_AMOUNT");if(i>await this.getBalance(t))throw new Error("INSUFFICIENT_BALANCE");if(t===r)throw new Error("INVALID_ADDRESS");let n=[],a=new xc.Transaction,u=new xc.Address(t),h=og(i),b=await vn.get(this.provider.createEndpoint("address/"+t+"/utxo")).then(w=>w.data);for(let w of b)n.push(new xc.Transaction.UnspentOutput({txId:w.txid,satoshis:w.value,address:u,outputIndex:w.vout,script:xc.Script.fromAddress(u)}));return a.from(n),a.change(t),a.to(r,h),new $l({sender:t,receiver:r,amount:h,bitcoreLib:a})}};var dx={};Oa(dx,{CoinTransaction:()=>Xl,Transaction:()=>_c});var CT=0,_c=class{id;provider;data=null;constructor(t,r){this.id=t,this.provider=r??Vn.instance}async getData(){if(this.data!==null)return this.data;try{let t=(await vn.get(this.provider.createEndpoint("tx/"+this.id))).data;return t?.txid!==this.id?this.data=null:this.data=t}catch(t){if(String(t?.response?.data).includes("Transaction not found")){if(CT>5)throw new Error("TRANSACTION_NOT_FOUND");return CT++,await ig(2e3),await this.getData()}throw new Error("RPC_REQUEST_ERROR")}}async wait(t=4e3){return await new Promise((r,i)=>{let n=async()=>{try{let a=await this.getStatus();if(a==="CONFIRMED"){r("CONFIRMED");return}else if(a==="FAILED"){i("FAILED");return}setTimeout(n,t)}catch{i("FAILED")}};n()})}getId(){return this.id}async getType(){return"COIN"}getUrl(){return this.provider.explorer+"tx/"+this.id}async getSigner(){return(await this.getData())?.vin[0].prevout.scriptpubkey_address??""}async getFee(){let t=await this.getData();return hs(t?.fee??0)}async getBlockNumber(){return(await this.getData())?.status?.block_height??0}async getBlockTimestamp(){return(await this.getData())?.status?.block_time??0}async getBlockConfirmationCount(){let t=await this.getData();return t===null?0:(await vn.get(this.provider.createEndpoint("blocks/tip/height"))).data-t?.status?.block_height}async getStatus(){let t=await this.getData();return t===null?"PENDING":t.status?.block_height!==void 0?t.status.confirmed?"CONFIRMED":"FAILED":"PENDING"}};var Xl=class extends _c{async getReceiver(){return(await this.getData())?.vout[0].scriptpubkey_address??""}async getSender(){return await this.getSigner()}async getAmount(){let t=await this.getData();return hs(t?.vout[0].value??0)}async verifyTransfer(t,r,i){if(await this.getStatus()==="PENDING")return"PENDING";if(await this.getAmount()!==i)return"FAILED";if(t==="INCOMING"){if((await this.getReceiver()).toLowerCase()!==r.toLowerCase())return"FAILED"}else if((await this.getSender()).toLowerCase()!==r.toLowerCase())return"FAILED";return"CONFIRMED"}};var vx={};Oa(vx,{TransactionListener:()=>mx,TransactionSigner:()=>$l});var mx=class{type;provider;status=!1;callbacks=[];triggeredTransactions=[];filter;webSocket;dynamicStop=()=>{};constructor(t,r,i){this.type=t,this.filter=r??{},this.provider=i??Vn.instance}stop(){this.status&&(this.status=!1,this.dynamicStop())}start(){this.status||(this.status=!0,this[Wh[this.type]]())}getStatus(){return this.status}async on(t){if(this.webSocket===void 0)try{await al(this.provider.wsUrl),this.webSocket=new IS(this.provider.wsUrl)}catch(r){throw new Error("WebSocket connection is not available"+(r instanceof Error?": "+r.message:""))}return this.start(),this.callbacks.push(t),!0}trigger(t){this.triggeredTransactions.includes(t.id)||(this.triggeredTransactions.push(t.id),this.callbacks.forEach(r=>{r(t)}))}isBlockCypherProcess(){return this.provider.isTestnet()||this.provider.blockCypherToken!==void 0}createMessage(t){let r;if(this.isBlockCypherProcess()){let i={event:"unconfirmed-tx",token:this.provider.blockCypherToken??this.provider.defaultBlockCypherToken};t!==void 0&&(i.address=t),r=JSON.stringify(i)}else r=JSON.stringify({op:"unconfirmed_sub"});return this.dynamicStop=()=>{this.isBlockCypherProcess()||this.webSocket.send(JSON.stringify({op:"unconfirmed_unsub"})),this.webSocket.close()},r}getValues(t){let r={txId:""};return this.isBlockCypherProcess()?(r.txId=t.hash,r.sender=t.inputs[0].addresses[0],r.receiver=t.outputs[0].addresses[0],r.amount=hs(t.outputs[0].value)):(r.txId=t.x.hash,r.receiver=t.x.out[0].addr,r.sender=t.x.inputs[0].prev_out.addr,r.amount=hs(t.x.out[0].value)),r}generalProcess(){let t=this.createMessage();this.webSocket.addEventListener("open",()=>{this.webSocket.send(t)}),this.webSocket.addEventListener("message",async r=>{let i=this.getValues(JSON.parse(r.data));this.filter?.signer!==void 0&&i.sender!==this.filter.signer.toLowerCase()||this.trigger(new _c(i.txId))})}contractProcess(){throw new Error("This method is not implemented for Bitcoin.")}coinProcess(){let t=this.filter;if(t.signer!==void 0&&t.sender!==void 0&&t.signer!==t.sender)throw new Error("Sender and signer must be the same in coin transactions. Or only one of them can be defined.");let r=t.sender??t.signer,i=this.createMessage(t.receiver);this.webSocket.addEventListener("open",()=>{this.webSocket.send(i)}),this.webSocket.addEventListener("message",async n=>{let a=JSON.parse(n.data),u={},h={};if(String(a.event).includes("events limit reached"))throw new Error("BlockCypher events limit reached.");let b=this.getValues(a);if(r!==void 0&&(u.sender=r.toLowerCase(),h.sender=b.sender?.toLowerCase()),t.receiver!==void 0&&(u.receiver=t.receiver.toLowerCase(),h.receiver=b.receiver?.toLowerCase()),!ng(u,h))return;let w=new Xl(b.txId);t.amount!==void 0&&b.amount!==t.amount||this.trigger(w)})}tokenProcess(){throw new Error("This method is not implemented for Bitcoin.")}nftProcess(){throw new Error("This method is not implemented for Bitcoin.")}};0&&(module.exports={Provider,assets,models,services,types,utils});
39
39
  /*! Bundled license information:
40
40
 
41
41
  mime-db/index.js: