denotify-client 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +36 -15
- package/.lintstagedrc +2 -2
- package/.prettierrc +14 -14
- package/.stylelintrc +16 -16
- package/README.md +1 -1
- package/dist/denotify-client.cjs +1 -1
- package/dist/denotify-client.iife.js +1 -1
- package/dist/denotify-client.mjs +1 -1
- package/dts-bundle-generator.config.ts +12 -12
- package/index.html +10 -10
- package/package.json +56 -52
- package/tsconfig.json +3 -5
- package/types/alertbuilder.d.ts +95 -95
- package/types/client.d.ts +11 -11
- package/types/denotifyclient.d.ts +49 -49
- package/types/functionbuilder.d.ts +28 -28
- package/types/index.d.ts +6 -6
- package/types/notifications/index.d.ts +30 -30
- package/types/notifications/notification.d.ts +17 -17
- package/types/notifications/notify_discord_webhook.d.ts +25 -25
- package/types/triggers/handler_function_call.d.ts +53 -53
- package/types/triggers/handler_function_call_v2.d.ts +83 -83
- package/types/triggers/handler_onchain_event.d.ts +44 -44
- package/types/triggers/index.d.ts +54 -54
- package/types/triggers/trigger.d.ts +50 -50
- package/types/types/notification.d.ts +4 -4
- package/types/types/trigger.d.ts +17 -17
- package/types/types/types.d.ts +14 -14
- package/types/util/filter.d.ts +56 -56
@@ -3,4 +3,4 @@ var denotifyClient=function(R){var Mt,st,Ge,Tt,zt,yn,le,ye,an,la,At,X,Ee,hr,Cs,V
|
|
3
3
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[xi]=this[xi]={accessors:{}}).accessors,s=this.prototype;function i(o){const a=nr(o);r[a]||(ju(s,o),r[a]=!0)}return g.isArray(e)?e.forEach(i):i(e),this}}Rr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),g.freezeMethods(Rr.prototype),g.freezeMethods(Rr);const Fe=Rr;function Bn(n,e){const t=this||Ln,r=e||t,s=Fe.from(r.headers);let i=r.data;return g.forEach(n,function(a){i=a.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function Oi(n){return!!(n&&n.__CANCEL__)}function sr(n,e,t){P.call(this,n??"canceled",P.ERR_CANCELED,e,t),this.name="CanceledError"}g.inherits(sr,P,{__CANCEL__:!0});function Bu(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new P("Request failed with status code "+t.status,[P.ERR_BAD_REQUEST,P.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const Hu=Ae.isStandardBrowserEnv?function(){return{write:function(t,r,s,i,o,a){const c=[];c.push(t+"="+encodeURIComponent(r)),g.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),g.isString(i)&&c.push("path="+i),g.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(t){const r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Mu(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function zu(n,e){return e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n}function Ti(n,e){return n&&!Mu(e)?zu(n,e):e}const Vu=Ae.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(o){const a=g.isString(o)?s(o):o;return a.protocol===r.protocol&&a.host===r.host}}():function(){return function(){return!0}}();function qu(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function Ju(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const u=Date.now(),l=r[i];o||(o=u),t[s]=c,r[s]=u;let h=i,p=0;for(;h!==s;)p+=t[h++],h=h%n;if(s=(s+1)%n,s===i&&(i=(i+1)%n),u-o<e)return;const f=l&&u-l;return f?Math.round(p*1e3/f):void 0}}function Ai(n,e){let t=0;const r=Ju(50,250);return s=>{const i=s.loaded,o=s.lengthComputable?s.total:void 0,a=i-t,c=r(a),u=i<=o;t=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&u?(o-i)/c:void 0,event:s};l[e?"download":"upload"]=!0,n(l)}}const Pr={http:bu,xhr:typeof XMLHttpRequest<"u"&&function(n){return new Promise(function(t,r){let s=n.data;const i=Fe.from(n.headers).normalize(),o=n.responseType;let a;function c(){n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}g.isFormData(s)&&(Ae.isStandardBrowserEnv||Ae.isStandardBrowserWebWorkerEnv)&&i.setContentType(!1);let u=new XMLHttpRequest;if(n.auth){const f=n.auth.username||"",d=n.auth.password?unescape(encodeURIComponent(n.auth.password)):"";i.set("Authorization","Basic "+btoa(f+":"+d))}const l=Ti(n.baseURL,n.url);u.open(n.method.toUpperCase(),bi(l,n.params,n.paramsSerializer),!0),u.timeout=n.timeout;function h(){if(!u)return;const f=Fe.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),w={data:!o||o==="text"||o==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:f,config:n,request:u};Bu(function(O){t(O),c()},function(O){r(O),c()},w),u=null}if("onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(h)},u.onabort=function(){u&&(r(new P("Request aborted",P.ECONNABORTED,n,u)),u=null)},u.onerror=function(){r(new P("Network Error",P.ERR_NETWORK,n,u)),u=null},u.ontimeout=function(){let d=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const w=n.transitional||_i;n.timeoutErrorMessage&&(d=n.timeoutErrorMessage),r(new P(d,w.clarifyTimeoutError?P.ETIMEDOUT:P.ECONNABORTED,n,u)),u=null},Ae.isStandardBrowserEnv){const f=(n.withCredentials||Vu(l))&&n.xsrfCookieName&&Hu.read(n.xsrfCookieName);f&&i.set(n.xsrfHeaderName,f)}s===void 0&&i.setContentType(null),"setRequestHeader"in u&&g.forEach(i.toJSON(),function(d,w){u.setRequestHeader(w,d)}),g.isUndefined(n.withCredentials)||(u.withCredentials=!!n.withCredentials),o&&o!=="json"&&(u.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&u.addEventListener("progress",Ai(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Ai(n.onUploadProgress)),(n.cancelToken||n.signal)&&(a=f=>{u&&(r(!f||f.type?new sr(null,n,u):f),u.abort(),u=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const p=qu(l);if(p&&Ae.protocols.indexOf(p)===-1){r(new P("Unsupported protocol "+p+":",P.ERR_BAD_REQUEST,n));return}u.send(s||null)})}};g.forEach(Pr,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Gu={getAdapter:n=>{n=g.isArray(n)?n:[n];const{length:e}=n;let t,r;for(let s=0;s<e&&(t=n[s],!(r=g.isString(t)?Pr[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new P(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(g.hasOwnProp(Pr,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!g.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:Pr};function Hn(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new sr(null,n)}function Si(n){return Hn(n),n.headers=Fe.from(n.headers),n.data=Bn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Gu.getAdapter(n.adapter||Ln.adapter)(n).then(function(r){return Hn(n),r.data=Bn.call(n,n.transformResponse,r),r.headers=Fe.from(r.headers),r},function(r){return Oi(r)||(Hn(n),r&&r.response&&(r.response.data=Bn.call(n,n.transformResponse,r.response),r.response.headers=Fe.from(r.response.headers))),Promise.reject(r)})}const ki=n=>n instanceof Fe?n.toJSON():n;function Ct(n,e){e=e||{};const t={};function r(u,l,h){return g.isPlainObject(u)&&g.isPlainObject(l)?g.merge.call({caseless:h},u,l):g.isPlainObject(l)?g.merge({},l):g.isArray(l)?l.slice():l}function s(u,l,h){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u,h)}else return r(u,l,h)}function i(u,l){if(!g.isUndefined(l))return r(void 0,l)}function o(u,l){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function a(u,l,h){if(h in e)return r(u,l);if(h in n)return r(void 0,u)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,l)=>s(ki(u),ki(l),!0)};return g.forEach(Object.keys(n).concat(Object.keys(e)),function(l){const h=c[l]||s,p=h(n[l],e[l],l);g.isUndefined(p)&&h!==a||(t[l]=p)}),t}const Ri="1.3.4",Mn={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Mn[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const Pi={};Mn.transitional=function(e,t,r){function s(i,o){return"[Axios v"+Ri+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,a)=>{if(e===!1)throw new P(s(o," has been removed"+(t?" in "+t:"")),P.ERR_DEPRECATED);return t&&!Pi[o]&&(Pi[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};function Wu(n,e,t){if(typeof n!="object")throw new P("options must be an object",P.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const a=n[i],c=a===void 0||o(a,i,n);if(c!==!0)throw new P("option "+i+" must be "+c,P.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new P("Unknown option "+i,P.ERR_BAD_OPTION)}}const zn={assertOptions:Wu,validators:Mn},Xe=zn.validators;class Nr{constructor(e){this.defaults=e,this.interceptors={request:new vi,response:new vi}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ct(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:i}=t;r!==void 0&&zn.assertOptions(r,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1),s!==void 0&&zn.assertOptions(s,{encode:Xe.function,serialize:Xe.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o;o=i&&g.merge(i.common,i[t.method]),o&&g.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),t.headers=Fe.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(t)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let l,h=0,p;if(!c){const d=[Si.bind(this),void 0];for(d.unshift.apply(d,a),d.push.apply(d,u),p=d.length,l=Promise.resolve(t);h<p;)l=l.then(d[h++],d[h++]);return l}p=a.length;let f=t;for(h=0;h<p;){const d=a[h++],w=a[h++];try{f=d(f)}catch(b){w.call(this,b);break}}try{l=Si.call(this,f)}catch(d){return Promise.reject(d)}for(h=0,p=u.length;h<p;)l=l.then(u[h++],u[h++]);return l}getUri(e){e=Ct(this.defaults,e);const t=Ti(e.baseURL,e.url);return bi(t,e.params,e.paramsSerializer)}}g.forEach(["delete","get","head","options"],function(e){Nr.prototype[e]=function(t,r){return this.request(Ct(r||{},{method:e,url:t,data:(r||{}).data}))}}),g.forEach(["post","put","patch"],function(e){function t(r){return function(i,o,a){return this.request(Ct(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Nr.prototype[e]=t(),Nr.prototype[e+"Form"]=t(!0)});const $r=Nr;class Vn{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{r.subscribe(a),i=a}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,a){r.reason||(r.reason=new sr(i,o,a),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new Vn(function(s){e=s}),cancel:e}}}const Ku=Vn;function Xu(n){return function(t){return n.apply(null,t)}}function Zu(n){return g.isObject(n)&&n.isAxiosError===!0}const qn={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(qn).forEach(([n,e])=>{qn[e]=n});const Yu=qn;function Ni(n){const e=new $r(n),t=ri($r.prototype.request,e);return g.extend(t,$r.prototype,e,{allOwnKeys:!0}),g.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Ni(Ct(n,s))},t}const J=Ni(Ln);J.Axios=$r,J.CanceledError=sr,J.CancelToken=Ku,J.isCancel=Oi,J.VERSION=Ri,J.toFormData=Ar,J.AxiosError=P,J.Cancel=J.CanceledError,J.all=function(e){return Promise.all(e)},J.spread=Xu,J.isAxiosError=Zu,J.mergeConfig=Ct,J.AxiosHeaders=Fe,J.formToJSON=n=>Ei(g.isHTMLForm(n)?new FormData(n):n),J.HttpStatusCode=Yu,J.default=J;const Qu=J;function pt(n){this._maxSize=n,this.clear()}pt.prototype.clear=function(){this._size=0,this._values=Object.create(null)},pt.prototype.get=function(n){return this._values[n]},pt.prototype.set=function(n,e){return this._size>=this._maxSize&&this.clear(),n in this._values||this._size++,this._values[n]=e};var el=/[^.^\]^[]+|(?=\[\]|\.\.)/g,$i=/^\d+$/,tl=/^\d/,rl=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,nl=/^\s*(['"]?)(.*?)(\1)\s*$/,Jn=512,Ci=new pt(Jn),Ii=new pt(Jn),Fi=new pt(Jn),yt={Cache:pt,split:Wn,normalizePath:Gn,setter:function(n){var e=Gn(n);return Ii.get(n)||Ii.set(n,function(r,s){for(var i=0,o=e.length,a=r;i<o-1;){var c=e[i];if(c==="__proto__"||c==="constructor"||c==="prototype")return r;a=a[e[i++]]}a[e[i]]=s})},getter:function(n,e){var t=Gn(n);return Fi.get(n)||Fi.set(n,function(s){for(var i=0,o=t.length;i<o;)if(s!=null||!e)s=s[t[i++]];else return;return s})},join:function(n){return n.reduce(function(e,t){return e+(Kn(t)||$i.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(n,e,t){sl(Array.isArray(n)?n:Wn(n),e,t)}};function Gn(n){return Ci.get(n)||Ci.set(n,Wn(n).map(function(e){return e.replace(nl,"$2")}))}function Wn(n){return n.match(el)||[""]}function sl(n,e,t){var r=n.length,s,i,o,a;for(i=0;i<r;i++)s=n[i],s&&(al(s)&&(s='"'+s+'"'),a=Kn(s),o=!a&&/^\d+$/.test(s),e.call(t,s,a,o,i,n))}function Kn(n){return typeof n=="string"&&n&&["'",'"'].indexOf(n.charAt(0))!==-1}function il(n){return n.match(tl)&&!n.match($i)}function ol(n){return rl.test(n)}function al(n){return!Kn(n)&&(il(n)||ol(n))}const cl=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,Cr=n=>n.match(cl)||[],Ir=n=>n[0].toUpperCase()+n.slice(1),Xn=(n,e)=>Cr(n).join(e).toLowerCase(),Di=n=>Cr(n).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,"");var Zn={words:Cr,upperFirst:Ir,camelCase:Di,pascalCase:n=>Ir(Di(n)),snakeCase:n=>Xn(n,"_"),kebabCase:n=>Xn(n,"-"),sentenceCase:n=>Ir(Xn(n," ")),titleCase:n=>Cr(n).map(Ir).join(" ")},Fr={},ul={get exports(){return Fr},set exports(n){Fr=n}};ul.exports=function(n){return Ui(ll(n),n)},Fr.array=Ui;function Ui(n,e){var t=n.length,r=new Array(t),s={},i=t,o=hl(e),a=fl(n);for(e.forEach(function(u){if(!a.has(u[0])||!a.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});i--;)s[i]||c(n[i],i,new Set);return r;function c(u,l,h){if(h.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!a.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!s[l]){s[l]=!0;var f=o.get(u)||new Set;if(f=Array.from(f),l=f.length){h.add(u);do{var d=f[--l];c(d,a.get(d),h)}while(l);h.delete(u)}r[--t]=u}}}function ll(n){for(var e=new Set,t=0,r=n.length;t<r;t++){var s=n[t];e.add(s[0]),e.add(s[1])}return Array.from(e)}function hl(n){for(var e=new Map,t=0,r=n.length;t<r;t++){var s=n[t];e.has(s[0])||e.set(s[0],new Set),e.has(s[1])||e.set(s[1],new Set),e.get(s[0]).add(s[1])}return e}function fl(n){for(var e=new Map,t=0,r=n.length;t<r;t++)e.set(n[t],t);return e}const dl=Object.prototype.toString,pl=Error.prototype.toString,yl=RegExp.prototype.toString,ml=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",gl=/^Symbol\((.*)\)(.*)$/;function wl(n){return n!=+n?"NaN":n===0&&1/n<0?"-0":""+n}function Li(n,e=!1){if(n==null||n===!0||n===!1)return""+n;const t=typeof n;if(t==="number")return wl(n);if(t==="string")return e?`"${n}"`:n;if(t==="function")return"[Function "+(n.name||"anonymous")+"]";if(t==="symbol")return ml.call(n).replace(gl,"Symbol($1)");const r=dl.call(n).slice(8,-1);return r==="Date"?isNaN(n.getTime())?""+n:n.toISOString(n):r==="Error"||n instanceof Error?"["+pl.call(n)+"]":r==="RegExp"?yl.call(n):null}function mt(n,e){let t=Li(n,e);return t!==null?t:JSON.stringify(n,function(r,s){let i=Li(this[r],e);return i!==null?i:s},2)}function ji(n){return n==null?[]:[].concat(n)}let bl=/\$\{\s*(\w+)\s*\}/g;class ue extends Error{static formatError(e,t){const r=t.label||t.path||"this";return r!==t.path&&(t=Object.assign({},t,{path:r})),typeof e=="string"?e.replace(bl,(s,i)=>mt(t[i])):typeof e=="function"?e(t):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,t,r,s){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=r,this.type=s,this.errors=[],this.inner=[],ji(e).forEach(i=>{ue.isError(i)?(this.errors.push(...i.errors),this.inner=this.inner.concat(i.inner.length?i.inner:i)):this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,ue)}}let De={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:n,type:e,value:t,originalValue:r})=>{const s=r!=null&&r!==t?` (cast from the value \`${mt(r,!0)}\`).`:".";return e!=="mixed"?`${n} must be a \`${e}\` type, but the final value was: \`${mt(t,!0)}\``+s:`${n} must match the configured type. The validated value was: \`${mt(t,!0)}\``+s}},we={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},Ze={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Yn={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Qn={isValue:"${path} field must be ${value}"},es={noUnknown:"${path} field has unspecified keys: ${unknown}"},Dr={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};Object.assign(Object.create(null),{mixed:De,string:we,number:Ze,date:Yn,object:es,array:Dr,boolean:Qn});const Ur=n=>n&&n.__isYupSchema__;class Lr{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:s,otherwise:i}=t,o=typeof r=="function"?r:(...a)=>a.every(c=>c===r);return new Lr(e,(a,c)=>{var u;let l=o(...a)?s:i;return(u=l==null?void 0:l(c))!=null?u:c})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let r=this.refs.map(i=>i.getValue(t==null?void 0:t.value,t==null?void 0:t.parent,t==null?void 0:t.context)),s=this.fn(r,e,t);if(s===void 0||s===e)return e;if(!Ur(s))throw new TypeError("conditions must return a schema object");return s.resolve(t)}}const jr={context:"$",value:"."};class gt{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===jr.context,this.isValue=this.key[0]===jr.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?jr.context:this.isValue?jr.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&yt.getter(this.path,!0),this.map=t.map}getValue(e,t,r){let s=this.isContext?r:this.isValue?e:t;return this.getter&&(s=this.getter(s||{})),this.map&&(s=this.map(s)),s}cast(e,t){return this.getValue(e,t==null?void 0:t.parent,t==null?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}gt.prototype.__isYupRef=!0;const fe=n=>n==null;function It(n){function e({value:t,path:r="",options:s,originalValue:i,schema:o},a,c){const{name:u,test:l,params:h,message:p,skipAbsent:f}=n;let{parent:d,context:w,abortEarly:b=o.spec.abortEarly}=s;function O(V){return gt.isRef(V)?V.getValue(t,d,w):V}function N(V={}){const Z=Object.assign({value:t,originalValue:i,label:o.spec.label,path:V.path||r,spec:o.spec},h,V.params);for(const Gt of Object.keys(Z))Z[Gt]=O(Z[Gt]);const dn=new ue(ue.formatError(V.message||p,Z),t,Z.path,V.type||u);return dn.params=Z,dn}const q=b?a:c;let j={path:r,parent:d,type:u,from:s.from,createError:N,resolve:O,options:s,originalValue:i,schema:o};const $e=V=>{ue.isError(V)?q(V):V?c(null):q(N())},gr=V=>{ue.isError(V)?q(V):a(V)},hn=f&&fe(t);if(!s.sync){try{Promise.resolve(hn?!0:l.call(j,t,j)).then($e,gr)}catch(V){gr(V)}return}let xe;try{var fn;if(xe=hn?!0:l.call(j,t,j),typeof((fn=xe)==null?void 0:fn.then)=="function")throw new Error(`Validation test of type: "${j.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(V){gr(V);return}$e(xe)}return e.OPTIONS=n,e}function vl(n,e,t,r=t){let s,i,o;return e?(yt.forEach(e,(a,c,u)=>{let l=c?a.slice(1,a.length-1):a;n=n.resolve({context:r,parent:s,value:t});let h=n.type==="tuple",p=u?parseInt(l,10):0;if(n.innerType||h){if(h&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(t&&p>=t.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);s=t,t=t&&t[p],n=h?n.spec.types[p]:n.innerType}if(!u){if(!n.fields||!n.fields[l])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${o} which is a type: "${n.type}")`);s=t,t=t&&t[l],n=n.fields[l]}i=l,o=c?"["+a+"]":"."+a}),{schema:n,parent:s,parentPath:i}):{parent:s,parentPath:e,schema:n}}class Br extends Set{describe(){const e=[];for(const t of this.values())e.push(gt.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const r of this.values())t.push(e(r));return t}clone(){return new Br(this.values())}merge(e,t){const r=this.clone();return e.forEach(s=>r.add(s)),t.forEach(s=>r.delete(s)),r}}function Ft(n,e=new Map){if(Ur(n)||!n||typeof n!="object")return n;if(e.has(n))return e.get(n);let t;if(n instanceof Date)t=new Date(n.getTime()),e.set(n,t);else if(n instanceof RegExp)t=new RegExp(n),e.set(n,t);else if(Array.isArray(n)){t=new Array(n.length),e.set(n,t);for(let r=0;r<n.length;r++)t[r]=Ft(n[r],e)}else if(n instanceof Map){t=new Map,e.set(n,t);for(const[r,s]of n.entries())t.set(r,Ft(s,e))}else if(n instanceof Set){t=new Set,e.set(n,t);for(const r of n)t.add(Ft(r,e))}else if(n instanceof Object){t={},e.set(n,t);for(const[r,s]of Object.entries(n))t[r]=Ft(s,e)}else throw Error(`Unable to clone ${n}`);return t}class ie{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Br,this._blacklist=new Br,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(De.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(t=>{t.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Ft(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(e.length===0)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=t,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,r=e.clone();const s=Object.assign({},t.spec,r.spec);return r.spec=s,r.internalTests=Object.assign({},t.internalTests,r.internalTests),r._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),r.tests=t.tests,r.exclusiveTests=t.exclusiveTests,r.withMutation(i=>{e.tests.forEach(o=>{i.test(o.OPTIONS)})}),r.transforms=[...t.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let r=t.conditions;t=t.clone(),t.conditions=[],t=r.reduce((s,i)=>i.resolve(s,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,r,s;return Object.assign({},e,{from:e.from||[],strict:(t=e.strict)!=null?t:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(s=e.recursive)!=null?s:this.spec.recursive})}cast(e,t={}){let r=this.resolve(Object.assign({value:e},t)),s=t.assert==="ignore-optionality",i=r._cast(e,t);if(t.assert!==!1&&!r.isType(i)){if(s&&fe(i))return i;let o=mt(e),a=mt(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
|
4
4
|
|
5
5
|
attempted value: ${o}
|
6
|
-
`+(a!==o?`result of cast: ${a}`:""))}return i}_cast(e,t){let r=e===void 0?e:this.transforms.reduce((s,i)=>i.call(this,s,e,this),e);return r===void 0&&(r=this.getDefault()),r}_validate(e,t={},r,s){let{path:i,originalValue:o=e,strict:a=this.spec.strict}=t,c=e;a||(c=this._cast(c,Object.assign({assert:!1},t)));let u=[];for(let l of Object.values(this.internalTests))l&&u.push(l);this.runTests({path:i,value:c,originalValue:o,options:t,tests:u},r,l=>{if(l.length)return s(l,c);this.runTests({path:i,value:c,originalValue:o,options:t,tests:this.tests},r,s)})}runTests(e,t,r){let s=!1,{tests:i,value:o,originalValue:a,path:c,options:u}=e,l=w=>{s||(s=!0,t(w,o))},h=w=>{s||(s=!0,r(w,o))},p=i.length,f=[];if(!p)return h([]);let d={value:o,originalValue:a,path:c,options:u,schema:this};for(let w=0;w<i.length;w++){const b=i[w];b(d,l,function(N){N&&(f=f.concat(N)),--p<=0&&h(f)})}}asNestedTest({key:e,index:t,parent:r,parentPath:s,originalParent:i,options:o}){const a=e??t;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof a=="number";let u=r[a];const l=Object.assign({},o,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${s||""}[${u?a:`"${a}"`}]`:(s?`${s}.`:"")+e});return(h,p,f)=>this.resolve(l)._validate(u,l,p,f)}validate(e,t){let r=this.resolve(Object.assign({},t,{value:e}));return new Promise((s,i)=>r._validate(e,t,(o,a)=>{ue.isError(o)&&(o.value=a),i(o)},(o,a)=>{o.length?i(new ue(o,a)):s(a)}))}validateSync(e,t){let r=this.resolve(Object.assign({},t,{value:e})),s;return r._validate(e,Object.assign({},t,{sync:!0}),(i,o)=>{throw ue.isError(i)&&(i.value=o),i},(i,o)=>{if(i.length)throw new ue(i,e);s=o}),s}isValid(e,t){return this.validate(e,t).then(()=>!0,r=>{if(ue.isError(r))return!1;throw r})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(r){if(ue.isError(r))return!1;throw r}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):Ft(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const r=this.clone({nullable:e});return r.internalTests.nullable=It({message:t,name:"nullable",test(s){return s===null?this.schema.spec.nullable:!0}}),r}optionality(e,t){const r=this.clone({optional:e});return r.internalTests.optionality=It({message:t,name:"optionality",test(s){return s===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=De.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=De.notNull){return this.nullability(!1,e)}required(e=De.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(e.length===1?typeof e[0]=="function"?t={test:e[0]}:t=e[0]:e.length===2?t={name:e[0],test:e[1]}:t={name:e[0],message:e[1],test:e[2]},t.message===void 0&&(t.message=De.default),typeof t.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),s=It(t),i=t.exclusive||t.name&&r.exclusiveTests[t.name]===!0;if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(r.exclusiveTests[t.name]=!!t.exclusive),r.tests=r.tests.filter(o=>!(o.OPTIONS.name===t.name&&(i||o.OPTIONS.test===s.OPTIONS.test))),r.tests.push(s),r}when(e,t){!Array.isArray(e)&&typeof e!="string"&&(t=e,e=".");let r=this.clone(),s=ji(e).map(i=>new gt(i));return s.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof t=="function"?new Lr(s,t):Lr.fromOptions(s,t)),r}typeError(e){let t=this.clone();return t.internalTests.typeError=It({message:e,name:"typeError",test(r){return!fe(r)&&!this.schema._typeCheck(r)?this.createError({params:{type:this.schema.type}}):!0}}),t}oneOf(e,t=De.oneOf){let r=this.clone();return e.forEach(s=>{r._whitelist.add(s),r._blacklist.delete(s)}),r.internalTests.whiteList=It({message:t,name:"oneOf",skipAbsent:!0,test(s){let i=this.schema._whitelist,o=i.resolveAll(this.resolve);return o.includes(s)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:o}})}}),r}notOneOf(e,t=De.notOneOf){let r=this.clone();return e.forEach(s=>{r._blacklist.add(s),r._whitelist.delete(s)}),r.internalTests.blacklist=It({message:t,name:"notOneOf",test(s){let i=this.schema._blacklist,o=i.resolveAll(this.resolve);return o.includes(s)?this.createError({params:{values:Array.from(i).join(", "),resolved:o}}):!0}}),r}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:r,meta:s,optional:i,nullable:o}=t.spec;return{meta:s,label:r,optional:i,nullable:o,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,l)=>l.findIndex(h=>h.name===c.name)===u)}}}ie.prototype.__isYupSchema__=!0;for(const n of["validate","validateSync"])ie.prototype[`${n}At`]=function(e,t,r={}){const{parent:s,parentPath:i,schema:o}=vl(this,e,t,r.context);return o[n](s&&s[i],Object.assign({},r,{parent:s,path:e}))};for(const n of["equals","is"])ie.prototype[n]=ie.prototype.oneOf;for(const n of["not","nope"])ie.prototype[n]=ie.prototype.notOneOf;const _l=()=>!0;function Bi(n){return new Hi(n)}class Hi extends ie{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:_l},e))}}Bi.prototype=Hi.prototype;function Mi(){return new zi}class zi extends ie{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(r.spec.coerce&&!r.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=Qn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(t){return fe(t)||t===!0}})}isFalse(e=Qn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(t){return fe(t)||t===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}}Mi.prototype=zi.prototype;let El=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,xl=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Ol=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Tl=n=>fe(n)||n===n.trim(),Al={}.toString();function H(){return new Vi}class Vi extends ie{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce||r.isType(e)||Array.isArray(e))return e;const s=e!=null&&e.toString?e.toString():e;return s===Al?e:s})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||De.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(t=>t.OPTIONS.name!=="required"),e))}length(e,t=we.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t=we.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t=we.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,t){let r=!1,s,i;return t&&(typeof t=="object"?{excludeEmptyString:r=!1,message:s,name:i}=t:s=t),this.test({name:i||"matches",message:s||we.matches,params:{regex:e},skipAbsent:!0,test:o=>o===""&&r||o.search(e)!==-1})}email(e=we.email){return this.matches(El,{name:"email",message:e,excludeEmptyString:!0})}url(e=we.url){return this.matches(xl,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=we.uuid){return this.matches(Ol,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=we.trim){return this.transform(t=>t!=null?t.trim():t).test({message:e,name:"trim",test:Tl})}lowercase(e=we.lowercase){return this.transform(t=>fe(t)?t:t.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>fe(t)||t===t.toLowerCase()})}uppercase(e=we.uppercase){return this.transform(t=>fe(t)?t:t.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>fe(t)||t===t.toUpperCase()})}}H.prototype=Vi.prototype;let Sl=n=>n!=+n;function de(){return new qi}class qi extends ie{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!Sl(e)}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce)return e;let s=e;if(typeof s=="string"){if(s=s.replace(/\s/g,""),s==="")return NaN;s=+s}return r.isType(s)?s:parseFloat(s)})})}min(e,t=Ze.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r>=this.resolve(e)}})}max(e,t=Ze.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r<=this.resolve(e)}})}lessThan(e,t=Ze.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(r){return r<this.resolve(e)}})}moreThan(e,t=Ze.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(r){return r>this.resolve(e)}})}positive(e=Ze.positive){return this.moreThan(0,e)}negative(e=Ze.negative){return this.lessThan(0,e)}integer(e=Ze.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:t=>Number.isInteger(t)})}truncate(){return this.transform(e=>fe(e)?e:e|0)}round(e){var t;let r=["ceil","floor","round","trunc"];if(e=((t=e)==null?void 0:t.toLowerCase())||"round",e==="trunc")return this.truncate();if(r.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+r.join(", "));return this.transform(s=>fe(s)?s:Math[e](s))}}de.prototype=qi.prototype;var kl=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function Rl(n){var e=[1,4,5,6,7,10,11],t=0,r,s;if(s=kl.exec(n)){for(var i=0,o;o=e[i];++i)s[o]=+s[o]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,(s[8]===void 0||s[8]==="")&&(s[9]===void 0||s[9]==="")?r=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7]):(s[8]!=="Z"&&s[9]!==void 0&&(t=s[10]*60+s[11],s[9]==="+"&&(t=0-t)),r=Date.UTC(s[1],s[2],s[3],s[4],s[5]+t,s[6],s[7]))}else r=Date.parse?Date.parse(n):NaN;return r}let Pl=new Date(""),Nl=n=>Object.prototype.toString.call(n)==="[object Date]";class Hr extends ie{constructor(){super({type:"date",check(e){return Nl(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,t,r)=>!r.spec.coerce||r.isType(e)?e:(e=Rl(e),isNaN(e)?Hr.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let r;if(gt.isRef(e))r=e;else{let s=this.cast(e);if(!this._typeCheck(s))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);r=s}return r}min(e,t=Yn.min){let r=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(s){return s>=this.resolve(r)}})}max(e,t=Yn.max){let r=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(s){return s<=this.resolve(r)}})}}Hr.INVALID_DATE=Pl,Hr.prototype;function $l(n,e=[]){let t=[],r=new Set,s=new Set(e.map(([o,a])=>`${o}-${a}`));function i(o,a){let c=yt.split(o)[0];r.add(c),s.has(`${a}-${c}`)||t.push([a,c])}for(const o of Object.keys(n)){let a=n[o];r.add(o),gt.isRef(a)&&a.isSibling?i(a.path,o):Ur(a)&&"deps"in a&&a.deps.forEach(c=>i(c,o))}return Fr.array(Array.from(r),t).reverse()}function Ji(n,e){let t=1/0;return n.some((r,s)=>{var i;if((i=e.path)!=null&&i.includes(r))return t=s,!0}),t}function Gi(n){return(e,t)=>Ji(n,e)-Ji(n,t)}const Wi=(n,e,t)=>{if(typeof n!="string")return n;let r=n;try{r=JSON.parse(n)}catch{}return t.isType(r)?r:n};function Mr(n){if("fields"in n){const e={};for(const[t,r]of Object.entries(n.fields))e[t]=Mr(r);return n.setFields(e)}if(n.type==="array"){const e=n.optional();return e.innerType&&(e.innerType=Mr(e.innerType)),e}return n.type==="tuple"?n.optional().clone({types:n.spec.types.map(Mr)}):"optional"in n?n.optional():n}const Cl=(n,e)=>{const t=[...yt.normalizePath(e)];if(t.length===1)return t[0]in n;let r=t.pop(),s=yt.getter(yt.join(t),!0)(n);return!!(s&&r in s)};let Ki=n=>Object.prototype.toString.call(n)==="[object Object]";function Il(n,e){let t=Object.keys(n.fields);return Object.keys(e).filter(r=>t.indexOf(r)===-1)}const Fl=Gi([]);function Ye(n){return new Xi(n)}class Xi extends ie{constructor(e){super({type:"object",check(t){return Ki(t)||typeof t=="function"}}),this.fields=Object.create(null),this._sortErrors=Fl,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var r;let s=super._cast(e,t);if(s===void 0)return this.getDefault();if(!this._typeCheck(s))return s;let i=this.fields,o=(r=t.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(s).filter(h=>!this._nodes.includes(h))),c={},u=Object.assign({},t,{parent:c,__validating:t.__validating||!1}),l=!1;for(const h of a){let p=i[h],f=h in s;if(p){let d,w=s[h];u.path=(t.path?`${t.path}.`:"")+h,p=p.resolve({value:w,context:t.context,parent:c});let b=p instanceof ie?p.spec:void 0,O=b==null?void 0:b.strict;if(b!=null&&b.strip){l=l||h in s;continue}d=!t.__validating||!O?p.cast(s[h],u):s[h],d!==void 0&&(c[h]=d)}else f&&!o&&(c[h]=s[h]);(f!==h in c||c[h]!==s[h])&&(l=!0)}return l?c:s}_validate(e,t={},r,s){let{from:i=[],originalValue:o=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:o},...i],t.__validating=!0,t.originalValue=o,super._validate(e,t,r,(c,u)=>{if(!a||!Ki(u)){s(c,u);return}o=o||u;let l=[];for(let h of this._nodes){let p=this.fields[h];!p||gt.isRef(p)||l.push(p.asNestedTest({options:t,key:h,parent:u,parentPath:t.path,originalParent:o}))}this.runTests({tests:l,value:u,originalValue:o,options:t},r,h=>{s(h.sort(this._sortErrors).concat(c),u)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),r=t.fields;for(let[s,i]of Object.entries(this.fields)){const o=r[s];r[s]=o===void 0?i:o}return t.withMutation(s=>s.setFields(r,this._excludedEdges))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach(t=>{const r=this.fields[t];e[t]=r&&"getDefault"in r?r.getDefault():void 0}),e}setFields(e,t){let r=this.clone();return r.fields=e,r._nodes=$l(e,t),r._sortErrors=Gi(Object.keys(e)),t&&(r._excludedEdges=t),r}shape(e,t=[]){return this.clone().withMutation(r=>{let s=r._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),s=[...r._excludedEdges,...t]),r.setFields(Object.assign(r.fields,e),s)})}partial(){const e={};for(const[t,r]of Object.entries(this.fields))e[t]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Mr(this)}pick(e){const t={};for(const r of e)this.fields[r]&&(t[r]=this.fields[r]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const r of e)delete t[r];return this.setFields(t)}from(e,t,r){let s=yt.getter(e,!0);return this.transform(i=>{if(!i)return i;let o=i;return Cl(i,e)&&(o=Object.assign({},i),r||delete o[e],o[t]=s(i)),o})}json(){return this.transform(Wi)}noUnknown(e=!0,t=es.noUnknown){typeof e!="boolean"&&(t=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:t,test(s){if(s==null)return!0;const i=Il(this.schema,s);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,t=es.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const r={};for(const s of Object.keys(t))r[e(s)]=t[s];return r})}camelCase(){return this.transformKeys(Zn.camelCase)}snakeCase(){return this.transformKeys(Zn.snakeCase)}constantCase(){return this.transformKeys(e=>Zn.snakeCase(e).toUpperCase())}describe(e){let t=super.describe(e);t.fields={};for(const[s,i]of Object.entries(this.fields)){var r;let o=e;(r=o)!=null&&r.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[s]})),t.fields[s]=i.describe(o)}return t}}Ye.prototype=Xi.prototype;function Dt(n){return new Zi(n)}class Zi extends ie{constructor(e){super({type:"array",check(t){return Array.isArray(t)}}),this.innerType=void 0,this.innerType=e}_cast(e,t){const r=super._cast(e,t);if(!this._typeCheck(r)||!this.innerType)return r;let s=!1;const i=r.map((o,a)=>{const c=this.innerType.cast(o,Object.assign({},t,{path:`${t.path||""}[${a}]`}));return c!==o&&(s=!0),c});return s?i:r}_validate(e,t={},r,s){var i;let o=this.innerType,a=(i=t.recursive)!=null?i:this.spec.recursive;t.originalValue!=null&&t.originalValue,super._validate(e,t,r,(c,u)=>{var l;if(!a||!o||!this._typeCheck(u)){s(c,u);return}let h=new Array(u.length);for(let f=0;f<u.length;f++){var p;h[f]=o.asNestedTest({options:t,index:f,parent:u,parentPath:t.path,originalParent:(p=t.originalValue)!=null?p:e})}this.runTests({value:u,tests:h,originalValue:(l=t.originalValue)!=null?l:e,options:t},r,f=>s(f.concat(c),u))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(Wi)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!Ur(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+mt(e));return t.innerType=e,t}length(e,t=Dr.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t){return t=t||Dr.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t){return t=t||Dr.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:t==null?[]:[].concat(t))}compact(e){let t=e?(r,s,i)=>!e(r,s,i):r=>!!r;return this.transform(r=>r!=null?r.filter(t):r)}describe(e){let t=super.describe(e);if(this.innerType){var r;let s=e;(r=s)!=null&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),t.innerType=this.innerType.describe(e)}return t}}Dt.prototype=Zi.prototype;const Dl="notify_discord_webhook";class ts{static SimpleToRaw(e){return{name:"",notify_type:Dl,notify:e}}static validateCreate(e){const t=/^(https?|ftp):\/\/(-\.)?([^\s/?.#]+\.?)+([^\s.?#]+)?(\?\S*)?$/;return Ye({url:H().matches(t,"url is not a valid url").required(),username:H(),avatar_url:H().matches(t,"url is not a valid url"),message:H().required()}).validate(e)}}class Yi{static SimpleToRaw(e,t){switch(e){case"Discord":return ts.SimpleToRaw(t)}}}const Ul="handler_function_call";class rs{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Ul,handler:r}}static validateCreate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return Ye({address:H().required(),abi:Dt().required(),nBlocks:de().min(10),condition:H().oneOf([">",">=","<","<=","=","true"]),constant:de().min(0).when("condition",t),responseArgIndex:de().min(0).when("condition",t),responseArgDecimals:de().min(0).when("condition",t)}).validate(e)}}const Ll="handler_onchain_event";class ns{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Ll,handler:r}}static validateCreate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return Ye({address:H().required(),event:H().required(),abi:Dt().required(),condition:H().oneOf([">",">=","<","<=","=","true"]),constant:de().min(0).when("condition",t),paramsIndex:de().min(0).when("condition",t),paramsDecimals:de().min(0).when("condition",t)}).validate(e)}}const jl="6.1.0";function Bl(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function Qi(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function k(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&Bl(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ut(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ut).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ut(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ut(t)}: ${Ut(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function zr(n,e){return n&&n.code===e}function eo(n){return zr(n,"CALL_EXCEPTION")}function Vr(n,e,t){{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ut(t)}`);for(const i in t){const o=t[i];s.push(i+"="+Ut(o))}}s.push(`code=${e}`),s.push(`version=${jl}`),s.length&&(n+=" ("+s.join(", ")+")")}let r;switch(e){case"INVALID_ARGUMENT":r=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(n);break;default:r=new Error(n)}return k(r,{code:e}),t&&Object.assign(r,t),r}function T(n,e,t,r){if(!n)throw Vr(e,t,r)}function E(n,e,t,r){T(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function to(n,e,t){t==null&&(t=""),t&&(t=": "+t),T(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),T(n<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}const Hl=["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"){const t=String.fromCharCode(233).normalize("NFD"),r=String.fromCharCode(101,769);if(t!==r)throw new Error("broken")}n.push(e)}catch{}return n},[]);function Ml(n){T(Hl.indexOf(n)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:n}})}function ss(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),T(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function ro(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x([0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}E(!1,"invalid BytesLike value",e||"value",n)}function Ue(n,e){return ro(n,e,!1)}function Le(n,e){return ro(n,e,!0)}function Qe(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}const no="0123456789abcdef";function W(n){const e=Ue(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=no[(s&240)>>4]+no[s&15]}return t}function Lt(n){return"0x"+n.map(e=>W(e).substring(2)).join("")}function jt(n,e,t){const r=Ue(n);return t!=null&&t>r.length&&T(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),W(r.slice(e??0,t??r.length))}function zl(n,e,t){const r=Ue(n);T(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),W(s)}function Vl(n,e){return zl(n,e,!0)}const qr=BigInt(0),be=BigInt(1),Bt=9007199254740991;function ql(n,e){const t=Gr(n,"value"),r=BigInt(je(e,"width"));if(T(t>>r===qr,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-be){const s=(be<<r)-be;return-((~t&s)+be)}return t}function Jl(n,e){let t=wt(n,"value");const r=BigInt(je(e,"width")),s=be<<r-be;if(t<qr){t=-t,T(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(be<<r)-be;return(~t&i)+be}else T(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function Jr(n,e){const t=Gr(n,"value"),r=BigInt(je(e,"bits"));return t&(be<<r)-be}function wt(n,e){switch(typeof n){case"bigint":return n;case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){E(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}E(!1,"invalid BigNumberish value",e||"value",n)}function Gr(n,e){const t=wt(n,e);return T(t>=qr,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const so="0123456789abcdef";function io(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=so[t>>4],e+=so[t&15];return BigInt(e)}return wt(n)}function je(n,e){switch(typeof n){case"bigint":return E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),Number(n);case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return je(BigInt(n),e)}catch(t){E(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}E(!1,"invalid numeric value",e||"value",n)}function Gl(n){return je(io(n))}function oo(n,e){let r=Gr(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=je(e,"width");for(T(s*2>=r.length,`value exceeds width (${s} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Wl(n){const e=Gr(n,"value");if(e===qr)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}class Kl{constructor(e,t,r){m(this,"filter");m(this,"emitter");B(this,Mt,void 0);I(this,Mt,t),k(this,{emitter:e,filter:r})}async removeListener(){v(this,Mt)!=null&&await this.emitter.off(this.filter,v(this,Mt))}}Mt=new WeakMap;function Xl(n,e,t,r,s){E(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ao(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function Zl(n,e,t,r,s){return n==="OVERLONG"?(E(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ao(n,e,t))}const Yl=Object.freeze({error:Xl,ignore:ao,replace:Zl});function Ql(n,e){e==null&&(e=Yl.error);const t=Ue(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[s];if((l&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),c=null;break}c=c<<6|l&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,r,c);continue}r.push(c)}}return r}function co(n,e){e!=null&&(Ml(e),n=n.normalize(e));let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);E(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function eh(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function th(n,e){return eh(Ql(n,e))}const re=32,is=new Uint8Array(re),rh=["then"],Wr={};function Kr(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}const lr=class extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==Wr&&(s=t,i=[],o=!1);super(s.length);B(this,st,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(I(this,st,Object.freeze(s.map((c,u)=>{const l=i[u];return l!=null&&a.get(l)===1?l:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,l)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const p=je(u,"%index");if(p<0||p>=this.length)throw new RangeError("out of result range");const f=c[p];return f instanceof Error&&Kr(`index ${p}`,f),f}if(rh.indexOf(u)>=0)return Reflect.get(c,u,l);const h=c[u];if(h instanceof Function)return function(...p){return h.apply(this===l?c:this,p)};if(!(u in c))return c.getValue.apply(this===l?c:this,[u])}return Reflect.get(c,u,l)}})}toArray(){const t=[];return this.forEach((r,s)=>{r instanceof Error&&Kr(`index ${s}`,r),t.push(r)}),t}toObject(){return v(this,st).reduce((t,r,s)=>(T(r!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),r in t||(t[r]=this.getValue(r)),t),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=[],i=[];for(let o=t;o<r;o++)s.push(this[o]),i.push(v(this,st)[o]);return new lr(Wr,s,i)}filter(t,r){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Kr(`index ${o}`,a),t.call(r,a,o,this)&&(s.push(a),i.push(v(this,st)[o]))}return new lr(Wr,s,i)}getValue(t){const r=v(this,st).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Kr(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new lr(Wr,t,r)}};let Xr=lr;st=new WeakMap;function uo(n){let e=Wl(n);return T(e.length<=re,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:re,offset:e.length}),e.length!==re&&(e=Le(Lt([is.slice(e.length%re),e]))),e}class Be{constructor(e,t,r,s){m(this,"name");m(this,"type");m(this,"localName");m(this,"dynamic");k(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){E(!1,e,this.localName,t)}}class os{constructor(){B(this,zt);B(this,Ge,void 0);B(this,Tt,void 0);I(this,Ge,[]),I(this,Tt,0)}get data(){return Lt(v(this,Ge))}get length(){return v(this,Tt)}appendWriter(e){return G(this,zt,yn).call(this,Le(e.data))}writeBytes(e){let t=Le(e);const r=t.length%re;return r&&(t=Le(Lt([t,is.slice(r)]))),G(this,zt,yn).call(this,t)}writeValue(e){return G(this,zt,yn).call(this,uo(e))}writeUpdatableValue(){const e=v(this,Ge).length;return v(this,Ge).push(is),I(this,Tt,v(this,Tt)+re),t=>{v(this,Ge)[e]=uo(t)}}}Ge=new WeakMap,Tt=new WeakMap,zt=new WeakSet,yn=function(e){return v(this,Ge).push(e),I(this,Tt,v(this,Tt)+e.length),e.length};const Rs=class{constructor(e,t){B(this,an);m(this,"allowLoose");B(this,le,void 0);B(this,ye,void 0);k(this,{allowLoose:!!t}),I(this,le,Le(e)),I(this,ye,0)}get data(){return W(v(this,le))}get dataLength(){return v(this,le).length}get consumed(){return v(this,ye)}get bytes(){return new Uint8Array(v(this,le))}subReader(e){return new Rs(v(this,le).slice(v(this,ye)+e),this.allowLoose)}readBytes(e,t){let r=G(this,an,la).call(this,0,e,!!t);return I(this,ye,v(this,ye)+r.length),r.slice(0,e)}readValue(){return io(this.readBytes(re))}readIndex(){return Gl(this.readBytes(re))}};let as=Rs;le=new WeakMap,ye=new WeakMap,an=new WeakSet,la=function(e,t,r){let s=Math.ceil(t/re)*re;return v(this,ye)+s>v(this,le).length&&(this.allowLoose&&r&&v(this,ye)+t<=v(this,le).length?s=t:T(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Le(v(this,le)),length:v(this,le).length,offset:v(this,ye)+s})),v(this,le).slice(v(this,ye),v(this,ye)+s)};function cs(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function nh(n){if(typeof n!="boolean")throw new Error(`Expected boolean, not ${n}`)}function lo(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function sh(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");cs(n.outputLen),cs(n.blockLen)}function ih(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function oh(n,e){lo(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Ht={number:cs,bool:nh,bytes:lo,hash:sh,exists:ih,output:oh};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ah=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ch(n){if(typeof n!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof n}`);return new TextEncoder().encode(n)}function us(n){if(typeof n=="string"&&(n=ch(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}class uh{clone(){return this._cloneInto()}}function lh(n){const e=r=>n().update(us(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function hh(n){const e=(r,s)=>n(s).update(us(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}const Zr=BigInt(2**32-1),ls=BigInt(32);function ho(n,e=!1){return e?{h:Number(n&Zr),l:Number(n>>ls&Zr)}:{h:Number(n>>ls&Zr)|0,l:Number(n&Zr)|0}}function fh(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=ho(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const dh=(n,e)=>BigInt(n>>>0)<<ls|BigInt(e>>>0),ph=(n,e,t)=>n>>>t,yh=(n,e,t)=>n<<32-t|e>>>t,mh=(n,e,t)=>n>>>t|e<<32-t,gh=(n,e,t)=>n<<32-t|e>>>t,wh=(n,e,t)=>n<<64-t|e>>>t-32,bh=(n,e,t)=>n>>>t-32|e<<64-t,vh=(n,e)=>e,_h=(n,e)=>n,Eh=(n,e,t)=>n<<t|e>>>32-t,xh=(n,e,t)=>e<<t|n>>>32-t,Oh=(n,e,t)=>e<<t-32|n>>>64-t,Th=(n,e,t)=>n<<t-32|e>>>64-t;function Ah(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/4294967296|0)|0,l:s|0}}const ir={fromBig:ho,split:fh,toBig:dh,shrSH:ph,shrSL:yh,rotrSH:mh,rotrSL:gh,rotrBH:wh,rotrBL:bh,rotr32H:vh,rotr32L:_h,rotlSH:Eh,rotlSL:xh,rotlBH:Oh,rotlBL:Th,add:Ah,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[fo,po,yo]=[[],[],[]],Sh=BigInt(0),or=BigInt(1),kh=BigInt(2),Rh=BigInt(7),Ph=BigInt(256),Nh=BigInt(113);for(let n=0,e=or,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],fo.push(2*(5*r+t)),po.push((n+1)*(n+2)/2%64);let s=Sh;for(let i=0;i<7;i++)e=(e<<or^(e>>Rh)*Nh)%Ph,e&kh&&(s^=or<<(or<<BigInt(i))-or);yo.push(s)}const[$h,Ch]=ir.split(yo,!0),mo=(n,e,t)=>t>32?ir.rotlBH(n,e,t):ir.rotlSH(n,e,t),go=(n,e,t)=>t>32?ir.rotlBL(n,e,t):ir.rotlSL(n,e,t);function Ih(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=t[c],l=t[c+1],h=mo(u,l,1)^t[a],p=go(u,l,1)^t[a+1];for(let f=0;f<50;f+=10)n[o+f]^=h,n[o+f+1]^=p}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=po[o],c=mo(s,i,a),u=go(s,i,a),l=fo[o];s=n[l],i=n[l+1],n[l]=c,n[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=$h[r],n[1]^=Ch[r]}t.fill(0)}class Yr extends uh{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ht.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ah(this.state)}keccak(){Ih(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ht.exists(this);const{blockLen:t,state:r}=this;e=us(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ht.exists(this,!1),Ht.bytes(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ht.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ht.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Yr(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const et=(n,e,t)=>lh(()=>new Yr(e,n,t));et(6,144,28),et(6,136,32),et(6,104,48),et(6,72,64),et(1,144,28);const Fh=et(1,136,256/8);et(1,104,48),et(1,72,64);const wo=(n,e,t)=>hh((r={})=>new Yr(e,n,r.dkLen===void 0?t:r.dkLen,!0));wo(31,168,16),wo(31,136,32);let bo=!1;const vo=function(n){return Fh(n)};let _o=vo;function tt(n){const e=Ue(n,"data");return W(_o(e))}tt._=vo,tt.lock=function(){bo=!0},tt.register=function(n){if(bo)throw new TypeError("keccak256 is locked");_o=n},Object.freeze(tt);const Dh=BigInt(0),Uh=BigInt(36);function Eo(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=Ue(tt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const hs={};for(let n=0;n<10;n++)hs[String(n)]=String(n);for(let n=0;n<26;n++)hs[String.fromCharCode(65+n)]=String(10+n);const xo=15;function Lh(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>hs[r]).join("");for(;e.length>=xo;){let r=e.substring(0,xo);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const jh=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function Bh(n){n=n.toLowerCase();let e=Dh;for(let t=0;t<n.length;t++)e=e*Uh+jh[n[t]];return e}function bt(n){if(E(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=Eo(n);return E(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){E(n.substring(2,4)===Lh(n),"bad icap checksum","address",n);let e=Bh(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Eo("0x"+e)}E(!1,"invalid address","address",n)}function Hh(n){return n&&typeof n.getAddress=="function"}async function fs(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(T(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),E(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),bt(t)}function ds(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?bt(n):(T(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),fs(n,e.resolveName(n)));if(Hh(n))return fs(n,n.getAddress());if(n&&typeof n.then=="function")return fs(n,n);E(!1,"unsupported addressable value","target",n)}const He={};function x(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new Q(He,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function $(n,e){return new Q(He,`bytes${e||""}`,n,{size:e})}const Oo=Symbol.for("_ethers_typed"),We=class{constructor(e,t,r,s){m(this,"type");m(this,"value");B(this,At,void 0);m(this,"_typedSymbol");s==null&&(s=null),ss(He,e,"Typed"),k(this,{_typedSymbol:Oo,type:t,value:r}),I(this,At,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return v(this,At)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return v(this,At)===!0?-1:v(this,At)===!1?this.value.length:null}static from(e,t){return new We(He,e,t)}static uint8(e){return x(e,8)}static uint16(e){return x(e,16)}static uint24(e){return x(e,24)}static uint32(e){return x(e,32)}static uint40(e){return x(e,40)}static uint48(e){return x(e,48)}static uint56(e){return x(e,56)}static uint64(e){return x(e,64)}static uint72(e){return x(e,72)}static uint80(e){return x(e,80)}static uint88(e){return x(e,88)}static uint96(e){return x(e,96)}static uint104(e){return x(e,104)}static uint112(e){return x(e,112)}static uint120(e){return x(e,120)}static uint128(e){return x(e,128)}static uint136(e){return x(e,136)}static uint144(e){return x(e,144)}static uint152(e){return x(e,152)}static uint160(e){return x(e,160)}static uint168(e){return x(e,168)}static uint176(e){return x(e,176)}static uint184(e){return x(e,184)}static uint192(e){return x(e,192)}static uint200(e){return x(e,200)}static uint208(e){return x(e,208)}static uint216(e){return x(e,216)}static uint224(e){return x(e,224)}static uint232(e){return x(e,232)}static uint240(e){return x(e,240)}static uint248(e){return x(e,248)}static uint256(e){return x(e,256)}static uint(e){return x(e,256)}static int8(e){return x(e,-8)}static int16(e){return x(e,-16)}static int24(e){return x(e,-24)}static int32(e){return x(e,-32)}static int40(e){return x(e,-40)}static int48(e){return x(e,-48)}static int56(e){return x(e,-56)}static int64(e){return x(e,-64)}static int72(e){return x(e,-72)}static int80(e){return x(e,-80)}static int88(e){return x(e,-88)}static int96(e){return x(e,-96)}static int104(e){return x(e,-104)}static int112(e){return x(e,-112)}static int120(e){return x(e,-120)}static int128(e){return x(e,-128)}static int136(e){return x(e,-136)}static int144(e){return x(e,-144)}static int152(e){return x(e,-152)}static int160(e){return x(e,-160)}static int168(e){return x(e,-168)}static int176(e){return x(e,-176)}static int184(e){return x(e,-184)}static int192(e){return x(e,-192)}static int200(e){return x(e,-200)}static int208(e){return x(e,-208)}static int216(e){return x(e,-216)}static int224(e){return x(e,-224)}static int232(e){return x(e,-232)}static int240(e){return x(e,-240)}static int248(e){return x(e,-248)}static int256(e){return x(e,-256)}static int(e){return x(e,-256)}static bytes1(e){return $(e,1)}static bytes2(e){return $(e,2)}static bytes3(e){return $(e,3)}static bytes4(e){return $(e,4)}static bytes5(e){return $(e,5)}static bytes6(e){return $(e,6)}static bytes7(e){return $(e,7)}static bytes8(e){return $(e,8)}static bytes9(e){return $(e,9)}static bytes10(e){return $(e,10)}static bytes11(e){return $(e,11)}static bytes12(e){return $(e,12)}static bytes13(e){return $(e,13)}static bytes14(e){return $(e,14)}static bytes15(e){return $(e,15)}static bytes16(e){return $(e,16)}static bytes17(e){return $(e,17)}static bytes18(e){return $(e,18)}static bytes19(e){return $(e,19)}static bytes20(e){return $(e,20)}static bytes21(e){return $(e,21)}static bytes22(e){return $(e,22)}static bytes23(e){return $(e,23)}static bytes24(e){return $(e,24)}static bytes25(e){return $(e,25)}static bytes26(e){return $(e,26)}static bytes27(e){return $(e,27)}static bytes28(e){return $(e,28)}static bytes29(e){return $(e,29)}static bytes30(e){return $(e,30)}static bytes31(e){return $(e,31)}static bytes32(e){return $(e,32)}static address(e){return new We(He,"address",e)}static bool(e){return new We(He,"bool",!!e)}static bytes(e){return new We(He,"bytes",e)}static string(e){return new We(He,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new We(He,"overrides",Object.assign({},e))}static isTyped(e){return e&&e._typedSymbol===Oo}static dereference(e,t){if(We.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};let Q=We;At=new WeakMap;class Mh extends Be{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Q.dereference(t,"string");try{r=bt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return bt(oo(e.readValue(),20))}}class zh extends Be{constructor(t){super(t.name,t.type,"_",t.dynamic);m(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function To(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let c={};r=e.map(u=>{const l=u.localName;return T(l,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),T(!c[l],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),c[l]=!0,t[l]})}else E(!1,"invalid tuple value","tuple",t);E(e.length===r.length,"types/value length mismatch","tuple",t);let s=new os,i=new os,o=[];e.forEach((c,u)=>{let l=r[u];if(c.dynamic){let h=i.length;c.encode(i,l);let p=s.writeUpdatableValue();o.push(f=>{p(f+h)})}else c.encode(s,l)}),o.forEach(c=>{c(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function Ao(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(zr(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(zr(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Xr.fromItems(t,r)}class Vh extends Be{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);m(this,"coder");m(this,"length");k(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=Q.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),to(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return To(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),T(r*re<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*re,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new zh(this.coder));return Ao(t,s)}}class qh extends Be{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Q.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class So extends Be{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Le(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class Jh extends So{constructor(e){super("bytes",e)}decode(e){return W(super.decode(e))}}class Gh extends Be{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);m(this,"size");k(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Le(Q.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return W(t.readBytes(this.size))}}const Wh=new Uint8Array([]);class Kh extends Be{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(Wh)}decode(e){return e.readBytes(0),null}}const Xh=BigInt(0),Zh=BigInt(1),Yh=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Qh extends Be{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);m(this,"size");m(this,"signed");k(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=wt(Q.dereference(r,this.type)),i=Jr(Yh,re*8);if(this.signed){let o=Jr(i,this.size*8-1);(s>o||s<-(o+Zh))&&this._throwError("value out-of-bounds",r),s=Jl(s,8*re)}else(s<Xh||s>Jr(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=Jr(t.readValue(),this.size*8);return this.signed&&(r=ql(r,this.size*8)),r}}class ef extends So{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,co(Q.dereference(t,"string")))}decode(e){return th(super.decode(e))}}class Qr extends Be{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);m(this,"coders");k(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=Q.dereference(r,"tuple");return To(t,this.coders,s)}decode(t){return Ao(t,this.coders)}}function ar(n){return tt(co(n))}function ps(n,e){return{address:bt(n),storageKeys:e.map((t,r)=>(E(Qe(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function tf(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(E(t.length===2,"invalid slot set",`value[${r}]`,t),ps(t[0],t[1])):(E(t!=null&&typeof t=="object","invalid address-slot set","value",n),ps(t.address,t.storageKeys)));E(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return ps(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function ne(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const ko="constant external internal payable private public pure view",rf=ne(ko.split(" ")),Ro="constructor error event fallback function receive struct",Po=ne(Ro.split(" ")),No="calldata memory storage payable indexed",nf=ne(No.split(" ")),sf=[Ro,No,"tuple returns",ko].join(" "),of=ne(sf.split(" ")),af={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},cf=new RegExp("^(\\s*)"),uf=new RegExp("^([0-9]+)"),lf=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),$o=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Co=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),cn=class{constructor(e){B(this,hr);B(this,X,void 0);B(this,Ee,void 0);I(this,X,0),I(this,Ee,e.slice())}get offset(){return v(this,X)}get length(){return v(this,Ee).length-v(this,X)}clone(){return new cn(v(this,Ee))}reset(){I(this,X,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=G(this,hr,Cs).call(this,v(this,X)+1,e.match+1);return I(this,X,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;v(this,X)<e.match-1;){const r=this.peek().linkNext;t.push(G(this,hr,Cs).call(this,v(this,X)+1,r)),I(this,X,r)}return I(this,X,e.match+1),t}peek(){if(v(this,X)>=v(this,Ee).length)throw new Error("out-of-bounds");return v(this,Ee)[v(this,X)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return ua(this,X)._++,e}toString(){const e=[];for(let t=v(this,X);t<v(this,Ee).length;t++){const r=v(this,Ee)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};let ve=cn;X=new WeakMap,Ee=new WeakMap,hr=new WeakSet,Cs=function(e=0,t=0){return new cn(v(this,Ee).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};function rt(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(cf);a&&(i+=a[1].length,o=n.substring(i));const c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let u=af[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(u=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),c.match=r.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(u==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let l=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;l=h+l,e[e.length-1].value=je(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=l}continue}if(a=o.match(lf),a){if(c.text=a[1],i+=c.text.length,of.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(Co)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(uf),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ve(e.map(o=>Object.freeze(o)))}function Io(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function en(n,e){if(e.peekKeyword(Po)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Me(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function Fo(n){let e=Me(n,rf);return Io(e,ne("constant payable nonpayable".split(" "))),Io(e,ne("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function ze(n,e){return n.popParams().map(t=>K.from(t,e))}function Do(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return wt(n.pop().text);throw new Error("invalid gas")}return null}function vt(n){if(n.length)throw new Error(`unexpected tokens: ${n.toString()}`)}const hf=new RegExp(/^(.*)\[([0-9]*)\]$/);function Uo(n){const e=n.match(Co);if(E(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);E(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);E(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const M={},oe=Symbol.for("_ethers_internal"),Lo="_ParamTypeInternal",jo="_ErrorInternal",Bo="_EventInternal",Ho="_ConstructorInternal",Mo="_FallbackInternal",zo="_FunctionInternal",Vo="_StructInternal",me=class{constructor(e,t,r,s,i,o,a,c){B(this,Vt);m(this,"name");m(this,"type");m(this,"baseType");m(this,"indexed");m(this,"components");m(this,"arrayLength");m(this,"arrayChildren");if(ss(e,M,"ParamType"),Object.defineProperty(this,oe,{value:Lo}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");k(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){let r={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(r)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?(e!=="sighash"&&(t+=this.type),t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")"):t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return G(this,Vt,mn).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(me.isParamType(e))return e;if(typeof e=="string")return me.from(rt(e),t);if(e instanceof ve){let a="",c="",u=null;Me(e,ne(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",u=e.popParams().map(w=>me.from(w)),a=`tuple(${u.map(w=>w.format()).join(",")})`):(a=Uo(e.popType("TYPE")),c=a);let l=null,h=null;for(;e.length&&e.peekType("BRACKET");){const w=e.pop();l=new me(M,"",a,c,null,u,h,l),h=w.value,a+=w.text,c="array",u=null}let p=null;if(Me(e,nf).has("indexed")){if(!t)throw new Error("");p=!0}const d=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new me(M,d,a,c,p,u,h,l)}const r=e.name;E(!r||typeof r=="string"&&r.match($o),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(E(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(hf);if(o){const a=parseInt(o[2]||"-1"),c=me.from({type:o[1],components:e.components});return new me(M,r||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(u=>me.from(u)):null;return new me(M,r||"",i,"tuple",s,a,null,null)}return i=Uo(e.type),new me(M,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[oe]===Lo}};let K=me;Vt=new WeakSet,mn=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,u)=>{var l;G(l=o,Vt,mn).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var l;G(l=o[u],Vt,mn).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};class _t{constructor(e,t,r){m(this,"type");m(this,"inputs");ss(e,M,"Fragment"),r=Object.freeze(r.slice()),k(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{_t.from(JSON.parse(e))}catch{}return _t.from(rt(e))}if(e instanceof ve)switch(e.peekKeyword(Po)){case"constructor":return Ve.from(e);case"error":return ae.from(e);case"event":return Se.from(e);case"fallback":case"receive":return qe.from(e);case"function":return ke.from(e);case"struct":return Et.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Ve.from(e);case"error":return ae.from(e);case"event":return Se.from(e);case"fallback":case"receive":return qe.from(e);case"function":return ke.from(e);case"struct":return Et.from(e)}T(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}E(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Ve.isFragment(e)}static isError(e){return ae.isFragment(e)}static isEvent(e){return Se.isFragment(e)}static isFunction(e){return ke.isFragment(e)}static isStruct(e){return Et.isFragment(e)}}class tn extends _t{constructor(t,r,s,i){super(t,r,i);m(this,"name");E(typeof s=="string"&&s.match($o),"invalid identifier","name",s),i=Object.freeze(i.slice()),k(this,{name:s})}}function cr(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class ae extends tn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,oe,{value:jo})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+cr(e,this.inputs)),t.join(" ")}static from(e){if(ae.isFragment(e))return e;if(typeof e=="string")return ae.from(rt(e));if(e instanceof ve){const t=en("error",e),r=ze(e);return vt(e),new ae(M,t,r)}return new ae(M,e.name,e.inputs?e.inputs.map(K.from):[])}static isFragment(e){return e&&e[oe]===jo}}class Se extends tn{constructor(t,r,s,i){super(t,"event",r,s);m(this,"anonymous");Object.defineProperty(this,oe,{value:Bo}),k(this,{anonymous:i})}get topicHash(){return ar(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+cr(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>K.from(i)),new Se(M,t,r,!1).topicHash}static from(t){if(Se.isFragment(t))return t;if(typeof t=="string")return Se.from(rt(t));if(t instanceof ve){const r=en("event",t),s=ze(t,!0),i=!!Me(t,ne(["anonymous"])).has("anonymous");return vt(t),new Se(M,r,s,i)}return new Se(M,t.name,t.inputs?t.inputs.map(r=>K.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[oe]===Bo}}class Ve extends _t{constructor(t,r,s,i,o){super(t,r,s);m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:Ho}),k(this,{payable:i,gas:o})}format(t){if(T(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${cr(t,this.inputs)}`];return r.push(this.payable?"payable":"nonpayable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(Ve.isFragment(t))return t;if(typeof t=="string")return Ve.from(rt(t));if(t instanceof ve){Me(t,ne(["constructor"]));const r=ze(t),s=!!Me(t,ne(["payable"])).has("payable"),i=Do(t);return vt(t),new Ve(M,"constructor",r,s,i)}return new Ve(M,"constructor",t.inputs?t.inputs.map(K.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===Ho}}class qe extends _t{constructor(t,r,s){super(t,"fallback",r);m(this,"payable");Object.defineProperty(this,oe,{value:Mo}),k(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(qe.isFragment(t))return t;if(typeof t=="string")return qe.from(rt(t));if(t instanceof ve){const r=t.toString(),s=t.peekKeyword(ne(["fallback","receive"]));if(E(s,"type must be fallback or receive","obj",r),t.popKeyword(ne(["fallback","receive"]))==="receive"){const c=ze(t);return E(c.length===0,"receive cannot have arguments","obj.inputs",c),Me(t,ne(["payable"])),vt(t),new qe(M,[],!0)}let o=ze(t);o.length?E(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[K.from("bytes")];const a=Fo(t);if(E(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Me(t,ne(["returns"])).has("returns")){const c=ze(t);E(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return vt(t),new qe(M,o,a==="payable")}if(t.type==="receive")return new qe(M,[],!0);if(t.type==="fallback"){const r=[K.from("bytes")],s=t.stateMutability==="payable";return new qe(M,r,s)}E(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[oe]===Mo}}class ke extends tn{constructor(t,r,s,i,o,a){super(t,"function",r,i);m(this,"constant");m(this,"outputs");m(this,"stateMutability");m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:zo}),o=Object.freeze(o.slice()),k(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+cr(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(cr(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>K.from(i)),new ke(M,t,"view",r,[],null).selector}static from(t){if(ke.isFragment(t))return t;if(typeof t=="string")return ke.from(rt(t));if(t instanceof ve){const r=en("function",t),s=ze(t),i=Fo(t);let o=[];Me(t,ne(["returns"])).has("returns")&&(o=ze(t));const a=Do(t);return vt(t),new ke(M,r,i,s,o,a)}return new ke(M,t.name,t.stateMutability,t.inputs?t.inputs.map(K.from):[],t.outputs?t.outputs.map(K.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===zo}}class Et extends tn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,oe,{value:Vo})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")return Et.from(rt(e));if(e instanceof ve){const t=en("struct",e),r=ze(e);return vt(e),new Et(M,t,r)}return new Et(M,e.name,e.inputs?e.inputs.map(K.from):[])}static isFragment(e){return e&&e[oe]===Vo}}const _e=new Map;_e.set(0,"GENERIC_PANIC"),_e.set(1,"ASSERT_FALSE"),_e.set(17,"OVERFLOW"),_e.set(18,"DIVIDE_BY_ZERO"),_e.set(33,"ENUM_RANGE_ERROR"),_e.set(34,"BAD_STORAGE_DATA"),_e.set(49,"STACK_UNDERFLOW"),_e.set(50,"ARRAY_RANGE_ERROR"),_e.set(65,"OUT_OF_MEMORY"),_e.set(81,"UNINITIALIZED_FUNCTION_CALL");const ff=new RegExp(/^bytes([0-9]*)$/),df=new RegExp(/^(u?int)([0-9]*)$/);let ys=null;function pf(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const u=Ue(t);if(t=W(t),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(W(u.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(W(u.slice(0,4))==="0x4e487b71")try{const l=Number(r.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[l]},i=`Panic due to ${_e.get(l)||"UNKNOWN"}(${l})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?bt(e.to):null,data:e.data||"0x"};return e.from&&(c.from=bt(e.from)),Vr(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:c,invocation:o,revert:a})}const un=class{constructor(){B(this,it)}getDefaultValue(e){const t=e.map(s=>G(this,it,Wt).call(this,K.from(s)));return new Qr(t,"_").defaultValue()}encode(e,t){to(t.length,e.length,"types/values length mismatch");const r=e.map(o=>G(this,it,Wt).call(this,K.from(o))),s=new Qr(r,"_"),i=new os;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>G(this,it,Wt).call(this,K.from(o)));return new Qr(s,"_").decode(new as(t,r))}static defaultAbiCoder(){return ys==null&&(ys=new un),ys}static getBuiltinCallException(e,t,r){return pf(e,t,r,un.defaultAbiCoder())}};let rn=un;it=new WeakSet,Wt=function(e){if(e.isArray())return new Vh(G(this,it,Wt).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Qr(e.components.map(r=>G(this,it,Wt).call(this,r)),e.name);switch(e.baseType){case"address":return new Mh(e.name);case"bool":return new qh(e.name);case"string":return new ef(e.name);case"bytes":return new Jh(e.name);case"":return new Kh(e.name)}let t=e.type.match(df);if(t){let r=parseInt(t[2]||"256");return E(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new Qh(r/8,t[1]==="int",e.name)}if(t=e.type.match(ff),t){let r=parseInt(t[1]);return E(r!==0&&r<=32,"invalid bytes length","param",e),new Gh(r,e.name)}E(!1,"invalid type","type",e.type)};class yf{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"signature");m(this,"topic");m(this,"args");const s=e.name,i=e.format();k(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class mf{constructor(e,t,r,s){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");m(this,"value");const i=e.name,o=e.format();k(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class gf{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");const s=e.name,i=e.format();k(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class qo{constructor(e){m(this,"hash");m(this,"_isIndexed");k(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const Jo={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Go={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&Jo[n.toString()]&&(e=Jo[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},qt=class{constructor(e){B(this,fr);B(this,dr);m(this,"fragments");m(this,"deploy");m(this,"fallback");m(this,"receive");B(this,Re,void 0);B(this,Pe,void 0);B(this,Ne,void 0);B(this,ee,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Ne,new Map),I(this,Re,new Map),I(this,Pe,new Map);const r=[];for(const o of t)try{r.push(_t.from(o))}catch(a){console.log("EE",a)}k(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,ee,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}k(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(E(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=v(this,Ne);break;case"event":c=v(this,Pe);break;case"error":c=v(this,Re);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||k(this,{deploy:Ve.from("constructor()")}),k(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return rn.defaultAbiCoder()}getFunctionName(e){const t=G(this,fr,Is).call(this,e,null,!1);return E(t,"no matching function","key",e),t.name}getFunction(e,t){return G(this,fr,Is).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(v(this,Ne).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Ne).get(s),r)}}getEventName(e){const t=G(this,dr,Fs).call(this,e,null,!1);return E(t,"no matching event","key",e),t.name}getEvent(e,t){return G(this,dr,Fs).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(v(this,Pe).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Pe).get(s),r)}}getError(e,t){if(Qe(e)){const s=e.toLowerCase();if(Go[s])return ae.from(Go[s].signature);for(const i of v(this,Re).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of v(this,Re))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?ae.from("error Error(string)"):e==="Panic"?ae.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");E(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=ae.from(e).format(),e==="Error(string)")return ae.from("error Error(string)");if(e==="Panic(uint256)")return ae.from("error Panic(uint256)");const r=v(this,Re).get(e);return r||null}forEachError(e){const t=Array.from(v(this,Re).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Re).get(s),r)}}_decodeParams(e,t){return v(this,ee).decode(e,t)}_encodeParams(e,t){return v(this,ee).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return E(jt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,jt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return Lt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return E(jt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,jt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return Lt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);E(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Le(t);if(s.length%32===0)try{return v(this,ee).decode(e.outputs,s)}catch{r="could not decode result data"}T(!1,r,"BAD_DATA",{value:W(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=Ue(e,"data"),s=rn.getBuiltinCallException("call",t,r),i="execution reverted (unknown custom error)";if(s.message.startsWith(i)){const a=W(r.slice(0,4)),c=this.getError(a);if(c)try{const u=v(this,ee).decode(c.inputs,r.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return W(v(this,ee).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);E(i,"unknown event","eventFragment",e),e=i}T(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?ar(o):i.type==="bytes"?tt(W(o)):(i.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),i.type.match(/^u?int/)&&(o=oo(o)),i.type==="address"&&v(this,ee).encode(["address"],[o]),Vl(W(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){E(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?E(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(c=>s(a,c))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);E(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),E(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")r.push(ar(c));else if(o.type==="bytes")r.push(tt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(v(this,ee).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:v(this,ee).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const f=this.getEvent(e);E(f,"unknown event","eventFragment",e),e=f}if(r!=null&&!e.anonymous){const f=e.topicHash;E(Qe(r[0],32)&&r[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((f,d)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(K.from({type:"bytes32",name:f.name})),o.push(!0)):(s.push(f),o.push(!1)):(i.push(f),o.push(!1))});const a=r!=null?v(this,ee).decode(s,Lt(r)):null,c=v(this,ee).decode(i,t,!0),u=[],l=[];let h=0,p=0;return e.inputs.forEach((f,d)=>{let w=null;if(f.indexed)if(a==null)w=new qo(null);else if(o[d])w=new qo(a[p++]);else try{w=a[p++]}catch(b){w=b}else try{w=c[h++]}catch(b){w=b}u.push(w),l.push(f.name||null)}),Xr.fromItems(u,l)}parseTransaction(e){const t=Ue(e.data,"tx.data"),r=wt(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(W(t.slice(0,4)));if(!s)return null;const i=v(this,ee).decode(s.inputs,t.slice(4));return new mf(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new yf(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=W(e),r=this.getError(jt(t,0,4));if(!r)return null;const s=v(this,ee).decode(r.inputs,jt(t,4));return new gf(r,r.selector,s)}static from(e){return e instanceof qt?e:typeof e=="string"?new qt(JSON.parse(e)):typeof e.format=="function"?new qt(e.format("json")):new qt(e)}};let ms=qt;Re=new WeakMap,Pe=new WeakMap,Ne=new WeakMap,ee=new WeakMap,fr=new WeakSet,Is=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Ne).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Ne))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;Q.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const l=i[u].inputs.length;l!==a&&(!c||l!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const l=i[u].inputs;for(let h=0;h<t.length;h++)if(Q.isTyped(t[h])){if(h>=l.length){if(t[h].type==="overrides")continue;i.splice(u,1);break}if(t[h].type!==l[h].baseType){i.splice(u,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Ne).get(ke.from(e).format());return s||null},dr=new WeakSet,Fs=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Pe).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Pe))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(Q.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Pe).get(Se.from(e).format());return s||null};const wf=BigInt(0);function Je(n){return n==null?null:n.toString()}function bf(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=W(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=wt(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=je(n[s],`request.${s}`));return n.accessList&&(e.accessList=tf(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipReadEnabled=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),e}class gs{constructor(e,t){m(this,"provider");m(this,"transactionHash");m(this,"blockHash");m(this,"blockNumber");m(this,"removed");m(this,"address");m(this,"data");m(this,"topics");m(this,"index");m(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());k(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return T(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return _f(this)}}class vf{constructor(e,t){m(this,"provider");m(this,"to");m(this,"from");m(this,"contractAddress");m(this,"hash");m(this,"index");m(this,"blockHash");m(this,"blockNumber");m(this,"logsBloom");m(this,"gasUsed");m(this,"cumulativeGasUsed");m(this,"gasPrice");m(this,"type");m(this,"status");m(this,"root");B(this,pr,void 0);I(this,pr,Object.freeze(e.logs.map(r=>new gs(r,t)))),k(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,gasPrice:e.effectiveGasPrice||e.gasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return v(this,pr)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:l,root:h}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Je(this.cumulativeGasUsed),from:t,gasPrice:Je(this.gasPrice),gasUsed:Je(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:h,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Ko(this)}reorderedEvent(e){return T(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Wo(this,e)}}pr=new WeakMap;const Ps=class{constructor(e,t){m(this,"provider");m(this,"blockNumber");m(this,"blockHash");m(this,"index");m(this,"hash");m(this,"type");m(this,"to");m(this,"from");m(this,"nonce");m(this,"gasLimit");m(this,"gasPrice");m(this,"maxPriorityFeePerGas");m(this,"maxFeePerGas");m(this,"data");m(this,"value");m(this,"chainId");m(this,"signature");m(this,"accessList");B(this,ot,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,I(this,ot,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:l,accessList:h}=this;return{_type:"TransactionReceipt",accessList:h,blockNumber:e,blockHash:t,chainId:Je(this.chainId),data:u,from:a,gasLimit:Je(this.gasLimit),gasPrice:Je(this.gasPrice),hash:s,maxFeePerGas:Je(this.maxFeePerGas),maxPriorityFeePerGas:Je(this.maxPriorityFeePerGas),nonce:c,signature:l,to:o,index:r,type:i,value:Je(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async wait(e,t){const r=e??1,s=t??0;let i=v(this,ot),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:h,nonce:p}=await Qi({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(p<this.nonce){i=h;return}if(a)return null;const f=await this.getTransaction();if(!(f&&f.blockNumber!=null))for(o===-1&&(o=i-3,o<v(this,ot)&&(o=v(this,ot)));o<=h;){if(a)return null;const d=await this.provider.getBlock(o,!0);if(d==null)return;for(const w of d)if(w===this.hash)return;for(let w=0;w<d.length;w++){const b=await d.getTransaction(w);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const O=await this.provider.getTransactionReceipt(b.hash);if(O==null||h-O.blockNumber+1<r)return;let N="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?N="repriced":b.data==="0x"&&b.from===b.to&&b.value===wf&&(N="cancelled"),T(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:N==="replaced"||N==="cancelled",reason:N,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:O})}}o++}},u=await this.provider.getTransactionReceipt(this.hash);if(u){if(await u.confirmations()>=r)return u}else if(await c(),r===0)return null;return await new Promise((h,p)=>{const f=[],d=()=>{f.forEach(b=>b())};if(f.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{d(),p(Vr("wait for transaction timeout","TIMEOUT"))},s);f.push(()=>{clearTimeout(b)})}const w=async b=>{await b.confirmations()>=r&&(d(),h(b))};if(f.push(()=>{this.provider.off(this.hash,w)}),this.provider.on(this.hash,w),i>=0){const b=async()=>{try{await c()}catch(O){if(zr(O,"TRANSACTION_REPLACED")){d(),p(O);return}}a||this.provider.once("block",b)};f.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}removedEvent(){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ko(this)}reorderedEvent(e){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),T(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Wo(this,e)}replaceableTransaction(e){E(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Ps(this,this.provider);return I(t,ot,e),t}};let ws=Ps;ot=new WeakMap;function Wo(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function Ko(n){return{orphan:"drop-transaction",tx:n}}function _f(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class bs extends gs{constructor(t,r,s){super(t,t.provider);m(this,"interface");m(this,"fragment");m(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);k(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Ef extends vf{constructor(t,r,s){super(s,r);B(this,Jt,void 0);I(this,Jt,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?v(this,Jt).getEvent(t.topics[0]):null;return r?new bs(t,v(this,Jt),r):t})}}Jt=new WeakMap;class vs extends ws{constructor(t,r,s){super(s,r);B(this,yr,void 0);I(this,yr,t)}async wait(t){const r=await super.wait();return r==null?null:new Ef(v(this,yr),this.provider,r)}}yr=new WeakMap;class Xo extends Kl{constructor(t,r,s,i){super(t,r,s);m(this,"log");k(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class xf extends Xo{constructor(e,t,r,s,i){super(e,t,r,new bs(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);k(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Zo=BigInt(0);function Yo(n){return n&&typeof n.call=="function"}function Qo(n){return n&&typeof n.estimateGas=="function"}function _s(n){return n&&typeof n.resolveName=="function"}function ea(n){return n&&typeof n.sendTransaction=="function"}class Of{constructor(e,t,r){B(this,mr,void 0);m(this,"fragment");if(k(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=xt(e.runner,"resolveName"),i=_s(s)?s:null;I(this,mr,async function(){const o=await Promise.all(t.inputs.map((a,c)=>r[c]==null?null:a.walkAsync(r[c],(l,h)=>l==="address"?ds(h,i):h)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return v(this,mr)}}mr=new WeakMap;function Tf(){return Function}function xt(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ot(n){return n==null?null:n.provider||null}async function ta(n,e){const t=bf(Q.dereference(n,"overrides"));return E(t.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",t.to),E(t.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",t.data),t.from&&(t.from=await ds(t.from)),t}async function Af(n,e,t){const r=xt(n,"resolveName"),s=_s(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=Q.dereference(c,a),a==="address"?ds(c,s):c))))}class Sf{constructor(e){m(this,"_contract");return k(this,{_contract:e}),new Proxy(this,{apply:async(r,s,i)=>await r.send(...i)})}async populateTransaction(e){const t=await ta(e,["data"]);t.to=await this._contract.getAddress();const r=this._contract.interface,s=r.receive||r.fallback&&r.fallback.payable;return E(s||(t.value||Zo)===Zo,"cannot send value to non-payable contract","overrides.value",t.value),E(r.fallback||(t.data||"0x")==="0x","cannot send data to receive-only contract","overrides.data",t.data),t}async staticCall(e){const t=xt(this._contract.runner,"call");T(Yo(t),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const r=await this.populateTransaction(e);try{return await t.call(r)}catch(s){throw eo(s)&&s.data?this._contract.interface.makeError(s.data,r):s}}async send(e){const t=this._contract.runner;T(ea(t),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const r=await t.sendTransaction(await this.populateTransaction(e)),s=Ot(this._contract.runner);return new vs(this._contract.interface,s,r)}async estimateGas(e){const t=xt(this._contract.runner,"estimateGas");return T(Qo(t),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await t.estimateGas(await this.populateTransaction(e))}}class kf extends Tf(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return k(this,{name:t.interface.getFunctionName(r),_contract:t,_key:r}),new Proxy(this,{apply:async(i,o,a)=>i.getFragment(...a).constant?await i.staticCall(...a):await i.send(...a)})}get fragment(){const t=this._contract.interface.getFunction(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getFunction(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}async populateTransaction(...t){const r=this.getFragment(...t);let s={};if(r.inputs.length+1===t.length&&(s=await ta(t.pop())),r.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=await Af(this._contract.runner,r.inputs,t);return Object.assign({},s,await Qi({to:this._contract.getAddress(),data:this._contract.interface.encodeFunctionData(r,i)}))}async staticCall(...t){const r=await this.staticCallResult(...t);return r.length===1?r[0]:r}async send(...t){const r=this._contract.runner;T(ea(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=await r.sendTransaction(await this.populateTransaction(...t)),i=Ot(this._contract.runner);return new vs(this._contract.interface,i,s)}async estimateGas(...t){const r=xt(this._contract.runner,"estimateGas");return T(Qo(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await this.populateTransaction(...t))}async staticCallResult(...t){const r=xt(this._contract.runner,"call");T(Yo(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=await this.populateTransaction(...t);let i="0x";try{i=await r.call(s)}catch(a){throw eo(a)&&a.data?this._contract.interface.makeError(a.data,s):a}const o=this.getFragment(...t);return this._contract.interface.decodeFunctionResult(o,i)}}function Rf(){return Function}class Pf extends Rf(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return k(this,{name:t.interface.getEventName(r),_contract:t,_key:r}),new Proxy(this,{apply:(s,i,o)=>new Of(t,s.getFragment(...o),o)})}get fragment(){const t=this._contract.interface.getEvent(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getEvent(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}}const nn=Symbol.for("_ethersInternal_contract"),ra=new WeakMap;function Nf(n,e){ra.set(n[nn],e)}function pe(n){return ra.get(n[nn])}function $f(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Es(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(Qe(o,32))return o;const a=n.interface.getEvent(o);return E(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?Qe(e,32)?t=[e]:(r=n.interface.getEvent(e),E(r,"unknown fragment","event",e),t=[r.topicHash]):$f(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):E(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function ur(n,e){const{subs:t}=pe(n);return t.get((await Es(n,e)).tag)||null}async function na(n,e,t){const r=Ot(n.runner);T(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Es(n,t),{addr:a,subs:c}=pe(n);let u=c.get(i);if(!u){const h={address:a||n,topics:o},p=b=>{let O=s;if(O==null)try{O=n.interface.getEvent(b.topics[0])}catch{}if(O){const N=O,q=s?n.interface.decodeEventLog(s,b.data,b.topics):[];Os(n,t,q,j=>new xf(n,j,t,N,b))}else Os(n,t,[],N=>new Xo(n,N,t,b))};let f=[];u={tag:i,listeners:[],start:()=>{f.length||f.push(r.on(h,p))},stop:async()=>{if(f.length==0)return;let b=f;f=[],await Promise.all(b),r.off(h,p)}},c.set(i,u)}return u}let xs=Promise.resolve();async function Cf(n,e,t,r){await xs;const s=await ur(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);r&&c.push(r(a?null:o));try{o.call(n,...c)}catch{}return!a}),i>0}async function Os(n,e,t,r){try{await xs}catch{}const s=Cf(n,e,t,r);return xs=s,await s}const sa=["then"],ln=class{constructor(e,t,r,s){m(this,"target");m(this,"interface");m(this,"runner");m(this,"filters");m(this,Bf);m(this,"fallback");r==null&&(r=null);const i=ms.from(t);k(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,nn,{value:{}});let o,a=null,c=null;if(s){const h=Ot(r);c=new vs(this.interface,h,s)}let u=new Map;if(typeof e=="string")if(Qe(e))a=e,o=Promise.resolve(e);else{const h=xt(r,"resolveName");if(!_s(h))throw Vr("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=h.resolveName(e).then(p=>{if(p==null)throw new Error("TODO");return pe(this).addr=p,p})}else o=e.getAddress().then(h=>{if(h==null)throw new Error("TODO");return pe(this).addr=h,h});Nf(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const l=new Proxy({},{get:(h,p,f)=>{if(sa.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=this.getEvent(d);if(w)return w;throw new Error(`unknown contract event: ${d}`)}});return k(this,{filters:l}),k(this,{fallback:i.receive||i.fallback?new Sf(this):null}),new Proxy(this,{get:(h,p,f)=>{if(p in h||sa.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=h.getFunction(d);if(w)return w;throw new Error(`unknown contract method: ${d}`)}})}connect(e){return new ln(this.target,this.interface,e)}async getAddress(){return await pe(this).addrPromise}async getDeployedCode(){const e=Ot(this.runner);T(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ot(this.runner);return T(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return pe(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),new kf(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),new Pf(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=pe(this),o=s||await i,{fragment:a,topics:c}=await Es(this,e),u={address:o,topics:c,fromBlock:t,toBlock:r},l=Ot(this.runner);return T(l,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await l.getLogs(u)).map(h=>{let p=a;if(p==null)try{p=this.interface.getEvent(h.topics[0])}catch{}return p?new bs(h,this.interface,p):new gs(h,l)})}async on(e,t){const r=await na(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await na(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await Os(this,e,t,null)}async listenerCount(e){if(e){const s=await ur(this,e);return s?s.listeners.length:0}const{subs:t}=pe(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await ur(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=pe(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await ur(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),pe(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await ur(this,e);if(!t)return this;t.stop(),pe(this).subs.delete(t.tag)}else{const{subs:t}=pe(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends ln{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let Ts=ln;Bf=nn;function If(){return Ts}class Ff extends If(){}class sn{constructor(e){m(this,"data",[]);this.api=e}static create(e){return new sn(e)}getAbiHash(e){if(this.api===void 0)throw new Error("FunctionBuilder must be initialised with api");return this.api.getAbiHash(e)}async addFunction(e,t,r,s){const i=new Ff(e,s);return i.interface.encodeFunctionData(t,r),this.data.push({address:e,bytecode:i.interface.encodeFunctionData(t,r),abiHash:await this.getAbiHash(s),function:t}),this}get(){return this.data}static schema(){return Dt().of(Ye({address:H().required(),bytecode:H().matches(/^(0x)?([0-9a-fA-F]{2})*$/).required(),abiHash:H().matches(/^[A-Fa-f0-9]{64}/).required(),function:H().required()}))}}class nt{static version(){return"v1"}static execute(e,t,r="v1"){const s=JSON.parse(JSON.stringify(t));let i=!0;for(const o of s){const a=nt.process(e,o.conditions);i=nt.execLogic(i,o.logic,a)}return i}static process(e,t,r){const s=t.shift();if(!s)return r===void 0?!0:r;const i=nt.execCondition(e,s);if(r===void 0||s.logic==="WHERE")return nt.process(e,t,i);if(s.logic===void 0)throw new Error("Invalid filter. FilterCondition must have logic value");const o=nt.execLogic(r,s.logic,i);return nt.process(e,t,o)}static execLogic(e,t,r){switch(t){case"AND":return e&&r;case"OR":return e||r;case"XOR":return(e||r)&&!(e&&r);case"NAND":return!(e&&r);case"NOR":return!(e&&r);case"WHERE":return r;default:throw new Error(`Invalid Filter. Bad logic value: ${t}`)}}static execCondition(e,t){const r=e[t.key];if(t.type==="Number"){if(typeof t.constant!="number"||typeof r!="number")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"eq":return s===i;case"!eq":return s!==i;case"gt":return s>i;case"gte":return s>=i;case"lt":return s<i;case"lte":return s<=i;default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="String"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.includes(i);case"!contains":return!s.includes(i);case"is":return s===i;case"!is":return s!==i;case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="Address"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.toLowerCase().includes(i.toLowerCase());case"!contains":return!s.toLowerCase().includes(i.toLowerCase());case"is":return s.toLowerCase()===i.toLowerCase();case"!is":return s.toLowerCase()!==i.toLowerCase();case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}throw new Error("Invalid Filter. Unknown Type")}}class on{constructor(){m(this,"groups",[]);this.newGroup("WHERE")}static version(){return nt.version()}static new(){return new on}newGroup(e){if(this.groups.length!==0&&e==="WHERE")throw new Error('Only the first groups can start with "WHERE"');return this.groups.push({logic:"WHERE",conditions:[]}),this}addCondition(e,t,r,s,i){const o=this.groups[this.groups.length-1];if(o.conditions.length===0&&e!=="WHERE")throw new Error('Logic for the first condition of a group must be "WHERE"');if(o.conditions.length>0&&e==="WHERE")throw new Error('Only the first condition of a group can be "WHERE"');return o.conditions.push({logic:e,key:t,type:r,operation:s,constant:i}),this}finalise(){for(const e of this.groups)if(e.conditions.length===0)throw new Error("Bad Filter. All Groups must have atleast one condition");return this.groups}static schema(){const e=H().oneOf(["AND","OR","XOR","NAND","NOR","WHERE"]).required(),t=Ye({logic:e,key:H().required(),type:H().oneOf(["String","Address","Number"]).required(),operation:H().when("type",([r],s)=>{switch(r){case"String":return s.oneOf(["contains","!contains","is","!is","isEmpty","!isEmpty"]);case"Address":return s.oneOf(["is","!is","isEmpty","!isEmpty"]);case"Number":return s.oneOf(["String","Address","Number"]);default:throw new Error("Invalid Filter Data Type")}}),constant:Bi().when("type",([r])=>{switch(r){case"String":return H();case"Address":return H();case"Number":return de();default:throw new Error("Invalid Filter Data Type")}})});return Dt().of(Ye({logic:e,conditions:Dt().of(t)}))}}const Df="handler_function_call_v2";class As{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Df,handler:r}}static validateCreate(e){const t=/^(\d+)([SMHD])$/i;return Ye({timeBase:H().oneOf(["blocks","time"]).required(),nBlocks:de().min(10).when("timeBase",([s],i)=>s==="blocks"?i.required():i),timePeriod:H().matches(t,"timePeriod must be of the format n[s|m|h|d], eg 10s for 10 seconds").when("timeBase",([s],i)=>s==="time"?i.required():i),startTime:de().default(0),debounceCount:de(),functions:sn.schema(),triggerOn:H().oneOf(["always","filter"]).default("always"),latch:Mi().default(!1),filterVersion:H().when("triggerOn",([s],i)=>s==="filter"?i.required():i),filter:on.schema().when("triggerOn",([s],i)=>s==="filter"?i.required():i)}).validate(e)}}class ia{static SimpleToRaw(e,t,r,s){switch(t){case"PollFunctionV2":return As.SimpleToRaw(e,r,s);case"PollFunctionV1":return rs.SimpleToRaw(e,r,s);case"OnchainEventV1":return ns.SimpleToRaw(e,r,s);default:throw new Error("Invalid Trigger ID")}}}const oa=n=>`https://${n}.functions.supabase.co/`,aa=n=>`https://${n}.supabase.co/`,ca="fdgtrxmmrtlokhgkvcjz",Uf="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4";class Ss{constructor(e,t){m(this,"headers",{});this.url=e,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){var t,r;if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const s=e.projectId?aa(e.projectId):aa(ca),i=e.projectId?oa(e.projectId):oa(ca),o=e.anonKey?e.anonKey:Uf,a=Mc(s,o),{data:c,error:u}=await a.auth.signInWithPassword({email:e.email,password:e.password});if(u)throw u;if(((t=c.session)==null?void 0:t.access_token)===void 0)throw new Error("Access token not found");return new Ss(i,(r=c.session)==null?void 0:r.access_token)}else throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t){const r="alert-history",s=t||{};return e&&(s.id=e),Object.keys(s).length>0?await this.request("get",r,{params:t}):await this.request("get",r)}async getAlert(e){return(await this.request("get",`alerts/${e}`))[0]}async getAlerts(){return await this.request("get","alerts")}async createAlert(e){const t=ia.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),r=Yi.SimpleToRaw(e.notificationId,e.notification);return await this.request("post","alerts",{body:{trigger:t,notification:r}})}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async request(e,t,r={}){const s=new URL(`${this.url}${t}`);if(r.params)for(const a of Object.keys(r.params))s.searchParams.append(a,r.params[a]);console.log(s.toString());const i={method:e,url:s.toString(),headers:this.headers};return r.body&&(i.data=r.body),(await Qu(i)).data}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async setAlertName(e,t){throw new Error("Not yet supported - Sorry!")}async enableAlert(e){throw new Error("Not yet supported - Sorry!")}async disableAlert(e){throw new Error("Not yet supported - Sorry!")}async updateNotification(e){throw new Error("Not yet supported - Sorry!")}async updateTrigger(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}class ks{constructor(e){m(this,"network");m(this,"triggerId");m(this,"trigger");m(this,"notificationId");m(this,"notification");this.name=e}static create(e){return new ks(e)}onNetwork(e){return this.network=e,this}withTrigger(e,t){return this.triggerId=e,this.trigger=t,this}withNotification(e,t){return this.notificationId=e,this.notification=t,this}async validate(){switch(this.triggerId){case"OnchainEventV1":return ns.validateCreate(this.trigger);case"PollFunctionV1":return rs.validateCreate(this.trigger);case"PollFunctionV2":return As.validateCreate(this.trigger)}switch(this.notificationId){case"Discord":return ts.validateCreate(this.notification);default:throw new Error("Invalid notification type")}}async config(){if(this.trigger===void 0||this.triggerId===void 0)throw new Error("Trigger not configured");if(this.notification===void 0||this.notificationId===void 0)throw new Error("Notification not configured");if(this.network===void 0)throw new Error("Network not configured");return await this.validate(),{name:this.name,network:this.network,triggerId:this.triggerId,trigger:this.trigger,notificationId:this.notificationId,notification:this.notification}}}const Lf=Object.freeze(Object.defineProperty({__proto__:null,HandlerFunctionCall:rs,HandlerFunctionCallV2:As,HandlerOnchainEvent:ns,Trigger:ia},Symbol.toStringTag,{value:"Module"})),jf=Object.freeze(Object.defineProperty({__proto__:null,Notification:Yi,NotifyDiscordWebhook:ts},Symbol.toStringTag,{value:"Module"}));return R.AlertBuilder=ks,R.DeNotifyClient=Ss,R.FilterBuilder=on,R.FunctionBuilder=sn,R.Notification=jf,R.Trigger=Lf,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),R}({});
|
6
|
+
`+(a!==o?`result of cast: ${a}`:""))}return i}_cast(e,t){let r=e===void 0?e:this.transforms.reduce((s,i)=>i.call(this,s,e,this),e);return r===void 0&&(r=this.getDefault()),r}_validate(e,t={},r,s){let{path:i,originalValue:o=e,strict:a=this.spec.strict}=t,c=e;a||(c=this._cast(c,Object.assign({assert:!1},t)));let u=[];for(let l of Object.values(this.internalTests))l&&u.push(l);this.runTests({path:i,value:c,originalValue:o,options:t,tests:u},r,l=>{if(l.length)return s(l,c);this.runTests({path:i,value:c,originalValue:o,options:t,tests:this.tests},r,s)})}runTests(e,t,r){let s=!1,{tests:i,value:o,originalValue:a,path:c,options:u}=e,l=w=>{s||(s=!0,t(w,o))},h=w=>{s||(s=!0,r(w,o))},p=i.length,f=[];if(!p)return h([]);let d={value:o,originalValue:a,path:c,options:u,schema:this};for(let w=0;w<i.length;w++){const b=i[w];b(d,l,function(N){N&&(f=f.concat(N)),--p<=0&&h(f)})}}asNestedTest({key:e,index:t,parent:r,parentPath:s,originalParent:i,options:o}){const a=e??t;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof a=="number";let u=r[a];const l=Object.assign({},o,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${s||""}[${u?a:`"${a}"`}]`:(s?`${s}.`:"")+e});return(h,p,f)=>this.resolve(l)._validate(u,l,p,f)}validate(e,t){let r=this.resolve(Object.assign({},t,{value:e}));return new Promise((s,i)=>r._validate(e,t,(o,a)=>{ue.isError(o)&&(o.value=a),i(o)},(o,a)=>{o.length?i(new ue(o,a)):s(a)}))}validateSync(e,t){let r=this.resolve(Object.assign({},t,{value:e})),s;return r._validate(e,Object.assign({},t,{sync:!0}),(i,o)=>{throw ue.isError(i)&&(i.value=o),i},(i,o)=>{if(i.length)throw new ue(i,e);s=o}),s}isValid(e,t){return this.validate(e,t).then(()=>!0,r=>{if(ue.isError(r))return!1;throw r})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(r){if(ue.isError(r))return!1;throw r}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):Ft(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const r=this.clone({nullable:e});return r.internalTests.nullable=It({message:t,name:"nullable",test(s){return s===null?this.schema.spec.nullable:!0}}),r}optionality(e,t){const r=this.clone({optional:e});return r.internalTests.optionality=It({message:t,name:"optionality",test(s){return s===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=De.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=De.notNull){return this.nullability(!1,e)}required(e=De.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(e.length===1?typeof e[0]=="function"?t={test:e[0]}:t=e[0]:e.length===2?t={name:e[0],test:e[1]}:t={name:e[0],message:e[1],test:e[2]},t.message===void 0&&(t.message=De.default),typeof t.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),s=It(t),i=t.exclusive||t.name&&r.exclusiveTests[t.name]===!0;if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(r.exclusiveTests[t.name]=!!t.exclusive),r.tests=r.tests.filter(o=>!(o.OPTIONS.name===t.name&&(i||o.OPTIONS.test===s.OPTIONS.test))),r.tests.push(s),r}when(e,t){!Array.isArray(e)&&typeof e!="string"&&(t=e,e=".");let r=this.clone(),s=ji(e).map(i=>new gt(i));return s.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof t=="function"?new Lr(s,t):Lr.fromOptions(s,t)),r}typeError(e){let t=this.clone();return t.internalTests.typeError=It({message:e,name:"typeError",test(r){return!fe(r)&&!this.schema._typeCheck(r)?this.createError({params:{type:this.schema.type}}):!0}}),t}oneOf(e,t=De.oneOf){let r=this.clone();return e.forEach(s=>{r._whitelist.add(s),r._blacklist.delete(s)}),r.internalTests.whiteList=It({message:t,name:"oneOf",skipAbsent:!0,test(s){let i=this.schema._whitelist,o=i.resolveAll(this.resolve);return o.includes(s)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:o}})}}),r}notOneOf(e,t=De.notOneOf){let r=this.clone();return e.forEach(s=>{r._blacklist.add(s),r._whitelist.delete(s)}),r.internalTests.blacklist=It({message:t,name:"notOneOf",test(s){let i=this.schema._blacklist,o=i.resolveAll(this.resolve);return o.includes(s)?this.createError({params:{values:Array.from(i).join(", "),resolved:o}}):!0}}),r}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:r,meta:s,optional:i,nullable:o}=t.spec;return{meta:s,label:r,optional:i,nullable:o,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,l)=>l.findIndex(h=>h.name===c.name)===u)}}}ie.prototype.__isYupSchema__=!0;for(const n of["validate","validateSync"])ie.prototype[`${n}At`]=function(e,t,r={}){const{parent:s,parentPath:i,schema:o}=vl(this,e,t,r.context);return o[n](s&&s[i],Object.assign({},r,{parent:s,path:e}))};for(const n of["equals","is"])ie.prototype[n]=ie.prototype.oneOf;for(const n of["not","nope"])ie.prototype[n]=ie.prototype.notOneOf;const _l=()=>!0;function Bi(n){return new Hi(n)}class Hi extends ie{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:_l},e))}}Bi.prototype=Hi.prototype;function Mi(){return new zi}class zi extends ie{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(r.spec.coerce&&!r.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=Qn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(t){return fe(t)||t===!0}})}isFalse(e=Qn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(t){return fe(t)||t===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}}Mi.prototype=zi.prototype;let El=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,xl=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Ol=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Tl=n=>fe(n)||n===n.trim(),Al={}.toString();function H(){return new Vi}class Vi extends ie{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce||r.isType(e)||Array.isArray(e))return e;const s=e!=null&&e.toString?e.toString():e;return s===Al?e:s})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||De.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(t=>t.OPTIONS.name!=="required"),e))}length(e,t=we.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t=we.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t=we.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,t){let r=!1,s,i;return t&&(typeof t=="object"?{excludeEmptyString:r=!1,message:s,name:i}=t:s=t),this.test({name:i||"matches",message:s||we.matches,params:{regex:e},skipAbsent:!0,test:o=>o===""&&r||o.search(e)!==-1})}email(e=we.email){return this.matches(El,{name:"email",message:e,excludeEmptyString:!0})}url(e=we.url){return this.matches(xl,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=we.uuid){return this.matches(Ol,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=we.trim){return this.transform(t=>t!=null?t.trim():t).test({message:e,name:"trim",test:Tl})}lowercase(e=we.lowercase){return this.transform(t=>fe(t)?t:t.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>fe(t)||t===t.toLowerCase()})}uppercase(e=we.uppercase){return this.transform(t=>fe(t)?t:t.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>fe(t)||t===t.toUpperCase()})}}H.prototype=Vi.prototype;let Sl=n=>n!=+n;function de(){return new qi}class qi extends ie{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!Sl(e)}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce)return e;let s=e;if(typeof s=="string"){if(s=s.replace(/\s/g,""),s==="")return NaN;s=+s}return r.isType(s)?s:parseFloat(s)})})}min(e,t=Ze.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r>=this.resolve(e)}})}max(e,t=Ze.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r<=this.resolve(e)}})}lessThan(e,t=Ze.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(r){return r<this.resolve(e)}})}moreThan(e,t=Ze.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(r){return r>this.resolve(e)}})}positive(e=Ze.positive){return this.moreThan(0,e)}negative(e=Ze.negative){return this.lessThan(0,e)}integer(e=Ze.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:t=>Number.isInteger(t)})}truncate(){return this.transform(e=>fe(e)?e:e|0)}round(e){var t;let r=["ceil","floor","round","trunc"];if(e=((t=e)==null?void 0:t.toLowerCase())||"round",e==="trunc")return this.truncate();if(r.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+r.join(", "));return this.transform(s=>fe(s)?s:Math[e](s))}}de.prototype=qi.prototype;var kl=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function Rl(n){var e=[1,4,5,6,7,10,11],t=0,r,s;if(s=kl.exec(n)){for(var i=0,o;o=e[i];++i)s[o]=+s[o]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,(s[8]===void 0||s[8]==="")&&(s[9]===void 0||s[9]==="")?r=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7]):(s[8]!=="Z"&&s[9]!==void 0&&(t=s[10]*60+s[11],s[9]==="+"&&(t=0-t)),r=Date.UTC(s[1],s[2],s[3],s[4],s[5]+t,s[6],s[7]))}else r=Date.parse?Date.parse(n):NaN;return r}let Pl=new Date(""),Nl=n=>Object.prototype.toString.call(n)==="[object Date]";class Hr extends ie{constructor(){super({type:"date",check(e){return Nl(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,t,r)=>!r.spec.coerce||r.isType(e)?e:(e=Rl(e),isNaN(e)?Hr.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let r;if(gt.isRef(e))r=e;else{let s=this.cast(e);if(!this._typeCheck(s))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);r=s}return r}min(e,t=Yn.min){let r=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(s){return s>=this.resolve(r)}})}max(e,t=Yn.max){let r=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(s){return s<=this.resolve(r)}})}}Hr.INVALID_DATE=Pl,Hr.prototype;function $l(n,e=[]){let t=[],r=new Set,s=new Set(e.map(([o,a])=>`${o}-${a}`));function i(o,a){let c=yt.split(o)[0];r.add(c),s.has(`${a}-${c}`)||t.push([a,c])}for(const o of Object.keys(n)){let a=n[o];r.add(o),gt.isRef(a)&&a.isSibling?i(a.path,o):Ur(a)&&"deps"in a&&a.deps.forEach(c=>i(c,o))}return Fr.array(Array.from(r),t).reverse()}function Ji(n,e){let t=1/0;return n.some((r,s)=>{var i;if((i=e.path)!=null&&i.includes(r))return t=s,!0}),t}function Gi(n){return(e,t)=>Ji(n,e)-Ji(n,t)}const Wi=(n,e,t)=>{if(typeof n!="string")return n;let r=n;try{r=JSON.parse(n)}catch{}return t.isType(r)?r:n};function Mr(n){if("fields"in n){const e={};for(const[t,r]of Object.entries(n.fields))e[t]=Mr(r);return n.setFields(e)}if(n.type==="array"){const e=n.optional();return e.innerType&&(e.innerType=Mr(e.innerType)),e}return n.type==="tuple"?n.optional().clone({types:n.spec.types.map(Mr)}):"optional"in n?n.optional():n}const Cl=(n,e)=>{const t=[...yt.normalizePath(e)];if(t.length===1)return t[0]in n;let r=t.pop(),s=yt.getter(yt.join(t),!0)(n);return!!(s&&r in s)};let Ki=n=>Object.prototype.toString.call(n)==="[object Object]";function Il(n,e){let t=Object.keys(n.fields);return Object.keys(e).filter(r=>t.indexOf(r)===-1)}const Fl=Gi([]);function Ye(n){return new Xi(n)}class Xi extends ie{constructor(e){super({type:"object",check(t){return Ki(t)||typeof t=="function"}}),this.fields=Object.create(null),this._sortErrors=Fl,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var r;let s=super._cast(e,t);if(s===void 0)return this.getDefault();if(!this._typeCheck(s))return s;let i=this.fields,o=(r=t.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(s).filter(h=>!this._nodes.includes(h))),c={},u=Object.assign({},t,{parent:c,__validating:t.__validating||!1}),l=!1;for(const h of a){let p=i[h],f=h in s;if(p){let d,w=s[h];u.path=(t.path?`${t.path}.`:"")+h,p=p.resolve({value:w,context:t.context,parent:c});let b=p instanceof ie?p.spec:void 0,O=b==null?void 0:b.strict;if(b!=null&&b.strip){l=l||h in s;continue}d=!t.__validating||!O?p.cast(s[h],u):s[h],d!==void 0&&(c[h]=d)}else f&&!o&&(c[h]=s[h]);(f!==h in c||c[h]!==s[h])&&(l=!0)}return l?c:s}_validate(e,t={},r,s){let{from:i=[],originalValue:o=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:o},...i],t.__validating=!0,t.originalValue=o,super._validate(e,t,r,(c,u)=>{if(!a||!Ki(u)){s(c,u);return}o=o||u;let l=[];for(let h of this._nodes){let p=this.fields[h];!p||gt.isRef(p)||l.push(p.asNestedTest({options:t,key:h,parent:u,parentPath:t.path,originalParent:o}))}this.runTests({tests:l,value:u,originalValue:o,options:t},r,h=>{s(h.sort(this._sortErrors).concat(c),u)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),r=t.fields;for(let[s,i]of Object.entries(this.fields)){const o=r[s];r[s]=o===void 0?i:o}return t.withMutation(s=>s.setFields(r,this._excludedEdges))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach(t=>{const r=this.fields[t];e[t]=r&&"getDefault"in r?r.getDefault():void 0}),e}setFields(e,t){let r=this.clone();return r.fields=e,r._nodes=$l(e,t),r._sortErrors=Gi(Object.keys(e)),t&&(r._excludedEdges=t),r}shape(e,t=[]){return this.clone().withMutation(r=>{let s=r._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),s=[...r._excludedEdges,...t]),r.setFields(Object.assign(r.fields,e),s)})}partial(){const e={};for(const[t,r]of Object.entries(this.fields))e[t]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Mr(this)}pick(e){const t={};for(const r of e)this.fields[r]&&(t[r]=this.fields[r]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const r of e)delete t[r];return this.setFields(t)}from(e,t,r){let s=yt.getter(e,!0);return this.transform(i=>{if(!i)return i;let o=i;return Cl(i,e)&&(o=Object.assign({},i),r||delete o[e],o[t]=s(i)),o})}json(){return this.transform(Wi)}noUnknown(e=!0,t=es.noUnknown){typeof e!="boolean"&&(t=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:t,test(s){if(s==null)return!0;const i=Il(this.schema,s);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,t=es.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const r={};for(const s of Object.keys(t))r[e(s)]=t[s];return r})}camelCase(){return this.transformKeys(Zn.camelCase)}snakeCase(){return this.transformKeys(Zn.snakeCase)}constantCase(){return this.transformKeys(e=>Zn.snakeCase(e).toUpperCase())}describe(e){let t=super.describe(e);t.fields={};for(const[s,i]of Object.entries(this.fields)){var r;let o=e;(r=o)!=null&&r.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[s]})),t.fields[s]=i.describe(o)}return t}}Ye.prototype=Xi.prototype;function Dt(n){return new Zi(n)}class Zi extends ie{constructor(e){super({type:"array",check(t){return Array.isArray(t)}}),this.innerType=void 0,this.innerType=e}_cast(e,t){const r=super._cast(e,t);if(!this._typeCheck(r)||!this.innerType)return r;let s=!1;const i=r.map((o,a)=>{const c=this.innerType.cast(o,Object.assign({},t,{path:`${t.path||""}[${a}]`}));return c!==o&&(s=!0),c});return s?i:r}_validate(e,t={},r,s){var i;let o=this.innerType,a=(i=t.recursive)!=null?i:this.spec.recursive;t.originalValue!=null&&t.originalValue,super._validate(e,t,r,(c,u)=>{var l;if(!a||!o||!this._typeCheck(u)){s(c,u);return}let h=new Array(u.length);for(let f=0;f<u.length;f++){var p;h[f]=o.asNestedTest({options:t,index:f,parent:u,parentPath:t.path,originalParent:(p=t.originalValue)!=null?p:e})}this.runTests({value:u,tests:h,originalValue:(l=t.originalValue)!=null?l:e,options:t},r,f=>s(f.concat(c),u))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(Wi)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!Ur(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+mt(e));return t.innerType=e,t}length(e,t=Dr.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t){return t=t||Dr.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t){return t=t||Dr.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:t==null?[]:[].concat(t))}compact(e){let t=e?(r,s,i)=>!e(r,s,i):r=>!!r;return this.transform(r=>r!=null?r.filter(t):r)}describe(e){let t=super.describe(e);if(this.innerType){var r;let s=e;(r=s)!=null&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),t.innerType=this.innerType.describe(e)}return t}}Dt.prototype=Zi.prototype;const Dl="notify_discord_webhook";class ts{static SimpleToRaw(e){return{name:"",notify_type:Dl,notify:e}}static validateCreate(e){const t=/^(https?|ftp):\/\/(-\.)?([^\s/?.#]+\.?)+([^\s.?#]+)?(\?\S*)?$/;return Ye({url:H().matches(t,"url is not a valid url").required(),username:H(),avatar_url:H().matches(t,"url is not a valid url"),message:H().required()}).validate(e)}}class Yi{static SimpleToRaw(e,t){switch(e){case"Discord":return ts.SimpleToRaw(t)}}}const Ul="handler_function_call";class rs{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Ul,handler:r}}static validateCreate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return Ye({address:H().required(),abi:Dt().required(),nBlocks:de().min(10),condition:H().oneOf([">",">=","<","<=","=","true"]),constant:de().min(0).when("condition",t),responseArgIndex:de().min(0).when("condition",t),responseArgDecimals:de().min(0).when("condition",t)}).validate(e)}}const Ll="handler_onchain_event";class ns{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Ll,handler:r}}static validateCreate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return Ye({address:H().required(),event:H().required(),abi:Dt().required(),condition:H().oneOf([">",">=","<","<=","=","true"]),constant:de().min(0).when("condition",t),paramsIndex:de().min(0).when("condition",t),paramsDecimals:de().min(0).when("condition",t)}).validate(e)}}const jl="6.1.0";function Bl(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function Qi(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function k(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&Bl(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ut(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ut).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ut(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ut(t)}: ${Ut(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function zr(n,e){return n&&n.code===e}function eo(n){return zr(n,"CALL_EXCEPTION")}function Vr(n,e,t){{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ut(t)}`);for(const i in t){const o=t[i];s.push(i+"="+Ut(o))}}s.push(`code=${e}`),s.push(`version=${jl}`),s.length&&(n+=" ("+s.join(", ")+")")}let r;switch(e){case"INVALID_ARGUMENT":r=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(n);break;default:r=new Error(n)}return k(r,{code:e}),t&&Object.assign(r,t),r}function T(n,e,t,r){if(!n)throw Vr(e,t,r)}function E(n,e,t,r){T(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function to(n,e,t){t==null&&(t=""),t&&(t=": "+t),T(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),T(n<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}const Hl=["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"){const t=String.fromCharCode(233).normalize("NFD"),r=String.fromCharCode(101,769);if(t!==r)throw new Error("broken")}n.push(e)}catch{}return n},[]);function Ml(n){T(Hl.indexOf(n)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:n}})}function ss(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),T(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function ro(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x([0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}E(!1,"invalid BytesLike value",e||"value",n)}function Ue(n,e){return ro(n,e,!1)}function Le(n,e){return ro(n,e,!0)}function Qe(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}const no="0123456789abcdef";function W(n){const e=Ue(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=no[(s&240)>>4]+no[s&15]}return t}function Lt(n){return"0x"+n.map(e=>W(e).substring(2)).join("")}function jt(n,e,t){const r=Ue(n);return t!=null&&t>r.length&&T(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),W(r.slice(e??0,t??r.length))}function zl(n,e,t){const r=Ue(n);T(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),W(s)}function Vl(n,e){return zl(n,e,!0)}const qr=BigInt(0),be=BigInt(1),Bt=9007199254740991;function ql(n,e){const t=Gr(n,"value"),r=BigInt(je(e,"width"));if(T(t>>r===qr,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-be){const s=(be<<r)-be;return-((~t&s)+be)}return t}function Jl(n,e){let t=wt(n,"value");const r=BigInt(je(e,"width")),s=be<<r-be;if(t<qr){t=-t,T(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(be<<r)-be;return(~t&i)+be}else T(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function Jr(n,e){const t=Gr(n,"value"),r=BigInt(je(e,"bits"));return t&(be<<r)-be}function wt(n,e){switch(typeof n){case"bigint":return n;case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){E(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}E(!1,"invalid BigNumberish value",e||"value",n)}function Gr(n,e){const t=wt(n,e);return T(t>=qr,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const so="0123456789abcdef";function io(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=so[t>>4],e+=so[t&15];return BigInt(e)}return wt(n)}function je(n,e){switch(typeof n){case"bigint":return E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),Number(n);case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-Bt&&n<=Bt,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return je(BigInt(n),e)}catch(t){E(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}E(!1,"invalid numeric value",e||"value",n)}function Gl(n){return je(io(n))}function oo(n,e){let r=Gr(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=je(e,"width");for(T(s*2>=r.length,`value exceeds width (${s} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Wl(n){const e=Gr(n,"value");if(e===qr)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}class Kl{constructor(e,t,r){m(this,"filter");m(this,"emitter");B(this,Mt,void 0);I(this,Mt,t),k(this,{emitter:e,filter:r})}async removeListener(){v(this,Mt)!=null&&await this.emitter.off(this.filter,v(this,Mt))}}Mt=new WeakMap;function Xl(n,e,t,r,s){E(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ao(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function Zl(n,e,t,r,s){return n==="OVERLONG"?(E(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ao(n,e,t))}const Yl=Object.freeze({error:Xl,ignore:ao,replace:Zl});function Ql(n,e){e==null&&(e=Yl.error);const t=Ue(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[s];if((l&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),c=null;break}c=c<<6|l&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,r,c);continue}r.push(c)}}return r}function co(n,e){e!=null&&(Ml(e),n=n.normalize(e));let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);E(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function eh(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function th(n,e){return eh(Ql(n,e))}const re=32,is=new Uint8Array(re),rh=["then"],Wr={};function Kr(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}const lr=class extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==Wr&&(s=t,i=[],o=!1);super(s.length);B(this,st,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(I(this,st,Object.freeze(s.map((c,u)=>{const l=i[u];return l!=null&&a.get(l)===1?l:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,l)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const p=je(u,"%index");if(p<0||p>=this.length)throw new RangeError("out of result range");const f=c[p];return f instanceof Error&&Kr(`index ${p}`,f),f}if(rh.indexOf(u)>=0)return Reflect.get(c,u,l);const h=c[u];if(h instanceof Function)return function(...p){return h.apply(this===l?c:this,p)};if(!(u in c))return c.getValue.apply(this===l?c:this,[u])}return Reflect.get(c,u,l)}})}toArray(){const t=[];return this.forEach((r,s)=>{r instanceof Error&&Kr(`index ${s}`,r),t.push(r)}),t}toObject(){return v(this,st).reduce((t,r,s)=>(T(r!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),r in t||(t[r]=this.getValue(r)),t),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=[],i=[];for(let o=t;o<r;o++)s.push(this[o]),i.push(v(this,st)[o]);return new lr(Wr,s,i)}filter(t,r){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Kr(`index ${o}`,a),t.call(r,a,o,this)&&(s.push(a),i.push(v(this,st)[o]))}return new lr(Wr,s,i)}getValue(t){const r=v(this,st).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Kr(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new lr(Wr,t,r)}};let Xr=lr;st=new WeakMap;function uo(n){let e=Wl(n);return T(e.length<=re,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:re,offset:e.length}),e.length!==re&&(e=Le(Lt([is.slice(e.length%re),e]))),e}class Be{constructor(e,t,r,s){m(this,"name");m(this,"type");m(this,"localName");m(this,"dynamic");k(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){E(!1,e,this.localName,t)}}class os{constructor(){B(this,zt);B(this,Ge,void 0);B(this,Tt,void 0);I(this,Ge,[]),I(this,Tt,0)}get data(){return Lt(v(this,Ge))}get length(){return v(this,Tt)}appendWriter(e){return G(this,zt,yn).call(this,Le(e.data))}writeBytes(e){let t=Le(e);const r=t.length%re;return r&&(t=Le(Lt([t,is.slice(r)]))),G(this,zt,yn).call(this,t)}writeValue(e){return G(this,zt,yn).call(this,uo(e))}writeUpdatableValue(){const e=v(this,Ge).length;return v(this,Ge).push(is),I(this,Tt,v(this,Tt)+re),t=>{v(this,Ge)[e]=uo(t)}}}Ge=new WeakMap,Tt=new WeakMap,zt=new WeakSet,yn=function(e){return v(this,Ge).push(e),I(this,Tt,v(this,Tt)+e.length),e.length};const Rs=class{constructor(e,t){B(this,an);m(this,"allowLoose");B(this,le,void 0);B(this,ye,void 0);k(this,{allowLoose:!!t}),I(this,le,Le(e)),I(this,ye,0)}get data(){return W(v(this,le))}get dataLength(){return v(this,le).length}get consumed(){return v(this,ye)}get bytes(){return new Uint8Array(v(this,le))}subReader(e){return new Rs(v(this,le).slice(v(this,ye)+e),this.allowLoose)}readBytes(e,t){let r=G(this,an,la).call(this,0,e,!!t);return I(this,ye,v(this,ye)+r.length),r.slice(0,e)}readValue(){return io(this.readBytes(re))}readIndex(){return Gl(this.readBytes(re))}};let as=Rs;le=new WeakMap,ye=new WeakMap,an=new WeakSet,la=function(e,t,r){let s=Math.ceil(t/re)*re;return v(this,ye)+s>v(this,le).length&&(this.allowLoose&&r&&v(this,ye)+t<=v(this,le).length?s=t:T(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Le(v(this,le)),length:v(this,le).length,offset:v(this,ye)+s})),v(this,le).slice(v(this,ye),v(this,ye)+s)};function cs(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function nh(n){if(typeof n!="boolean")throw new Error(`Expected boolean, not ${n}`)}function lo(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function sh(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");cs(n.outputLen),cs(n.blockLen)}function ih(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function oh(n,e){lo(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Ht={number:cs,bool:nh,bytes:lo,hash:sh,exists:ih,output:oh};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ah=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ch(n){if(typeof n!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof n}`);return new TextEncoder().encode(n)}function us(n){if(typeof n=="string"&&(n=ch(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}class uh{clone(){return this._cloneInto()}}function lh(n){const e=r=>n().update(us(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function hh(n){const e=(r,s)=>n(s).update(us(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}const Zr=BigInt(2**32-1),ls=BigInt(32);function ho(n,e=!1){return e?{h:Number(n&Zr),l:Number(n>>ls&Zr)}:{h:Number(n>>ls&Zr)|0,l:Number(n&Zr)|0}}function fh(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=ho(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const dh=(n,e)=>BigInt(n>>>0)<<ls|BigInt(e>>>0),ph=(n,e,t)=>n>>>t,yh=(n,e,t)=>n<<32-t|e>>>t,mh=(n,e,t)=>n>>>t|e<<32-t,gh=(n,e,t)=>n<<32-t|e>>>t,wh=(n,e,t)=>n<<64-t|e>>>t-32,bh=(n,e,t)=>n>>>t-32|e<<64-t,vh=(n,e)=>e,_h=(n,e)=>n,Eh=(n,e,t)=>n<<t|e>>>32-t,xh=(n,e,t)=>e<<t|n>>>32-t,Oh=(n,e,t)=>e<<t-32|n>>>64-t,Th=(n,e,t)=>n<<t-32|e>>>64-t;function Ah(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/4294967296|0)|0,l:s|0}}const ir={fromBig:ho,split:fh,toBig:dh,shrSH:ph,shrSL:yh,rotrSH:mh,rotrSL:gh,rotrBH:wh,rotrBL:bh,rotr32H:vh,rotr32L:_h,rotlSH:Eh,rotlSL:xh,rotlBH:Oh,rotlBL:Th,add:Ah,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[fo,po,yo]=[[],[],[]],Sh=BigInt(0),or=BigInt(1),kh=BigInt(2),Rh=BigInt(7),Ph=BigInt(256),Nh=BigInt(113);for(let n=0,e=or,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],fo.push(2*(5*r+t)),po.push((n+1)*(n+2)/2%64);let s=Sh;for(let i=0;i<7;i++)e=(e<<or^(e>>Rh)*Nh)%Ph,e&kh&&(s^=or<<(or<<BigInt(i))-or);yo.push(s)}const[$h,Ch]=ir.split(yo,!0),mo=(n,e,t)=>t>32?ir.rotlBH(n,e,t):ir.rotlSH(n,e,t),go=(n,e,t)=>t>32?ir.rotlBL(n,e,t):ir.rotlSL(n,e,t);function Ih(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=t[c],l=t[c+1],h=mo(u,l,1)^t[a],p=go(u,l,1)^t[a+1];for(let f=0;f<50;f+=10)n[o+f]^=h,n[o+f+1]^=p}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=po[o],c=mo(s,i,a),u=go(s,i,a),l=fo[o];s=n[l],i=n[l+1],n[l]=c,n[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=$h[r],n[1]^=Ch[r]}t.fill(0)}class Yr extends uh{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ht.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ah(this.state)}keccak(){Ih(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ht.exists(this);const{blockLen:t,state:r}=this;e=us(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ht.exists(this,!1),Ht.bytes(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ht.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ht.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Yr(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const et=(n,e,t)=>lh(()=>new Yr(e,n,t));et(6,144,28),et(6,136,32),et(6,104,48),et(6,72,64),et(1,144,28);const Fh=et(1,136,256/8);et(1,104,48),et(1,72,64);const wo=(n,e,t)=>hh((r={})=>new Yr(e,n,r.dkLen===void 0?t:r.dkLen,!0));wo(31,168,16),wo(31,136,32);let bo=!1;const vo=function(n){return Fh(n)};let _o=vo;function tt(n){const e=Ue(n,"data");return W(_o(e))}tt._=vo,tt.lock=function(){bo=!0},tt.register=function(n){if(bo)throw new TypeError("keccak256 is locked");_o=n},Object.freeze(tt);const Dh=BigInt(0),Uh=BigInt(36);function Eo(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=Ue(tt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const hs={};for(let n=0;n<10;n++)hs[String(n)]=String(n);for(let n=0;n<26;n++)hs[String.fromCharCode(65+n)]=String(10+n);const xo=15;function Lh(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>hs[r]).join("");for(;e.length>=xo;){let r=e.substring(0,xo);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const jh=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function Bh(n){n=n.toLowerCase();let e=Dh;for(let t=0;t<n.length;t++)e=e*Uh+jh[n[t]];return e}function bt(n){if(E(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=Eo(n);return E(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){E(n.substring(2,4)===Lh(n),"bad icap checksum","address",n);let e=Bh(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Eo("0x"+e)}E(!1,"invalid address","address",n)}function Hh(n){return n&&typeof n.getAddress=="function"}async function fs(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(T(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),E(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),bt(t)}function ds(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?bt(n):(T(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),fs(n,e.resolveName(n)));if(Hh(n))return fs(n,n.getAddress());if(n&&typeof n.then=="function")return fs(n,n);E(!1,"unsupported addressable value","target",n)}const He={};function x(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new Q(He,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function $(n,e){return new Q(He,`bytes${e||""}`,n,{size:e})}const Oo=Symbol.for("_ethers_typed"),We=class{constructor(e,t,r,s){m(this,"type");m(this,"value");B(this,At,void 0);m(this,"_typedSymbol");s==null&&(s=null),ss(He,e,"Typed"),k(this,{_typedSymbol:Oo,type:t,value:r}),I(this,At,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return v(this,At)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return v(this,At)===!0?-1:v(this,At)===!1?this.value.length:null}static from(e,t){return new We(He,e,t)}static uint8(e){return x(e,8)}static uint16(e){return x(e,16)}static uint24(e){return x(e,24)}static uint32(e){return x(e,32)}static uint40(e){return x(e,40)}static uint48(e){return x(e,48)}static uint56(e){return x(e,56)}static uint64(e){return x(e,64)}static uint72(e){return x(e,72)}static uint80(e){return x(e,80)}static uint88(e){return x(e,88)}static uint96(e){return x(e,96)}static uint104(e){return x(e,104)}static uint112(e){return x(e,112)}static uint120(e){return x(e,120)}static uint128(e){return x(e,128)}static uint136(e){return x(e,136)}static uint144(e){return x(e,144)}static uint152(e){return x(e,152)}static uint160(e){return x(e,160)}static uint168(e){return x(e,168)}static uint176(e){return x(e,176)}static uint184(e){return x(e,184)}static uint192(e){return x(e,192)}static uint200(e){return x(e,200)}static uint208(e){return x(e,208)}static uint216(e){return x(e,216)}static uint224(e){return x(e,224)}static uint232(e){return x(e,232)}static uint240(e){return x(e,240)}static uint248(e){return x(e,248)}static uint256(e){return x(e,256)}static uint(e){return x(e,256)}static int8(e){return x(e,-8)}static int16(e){return x(e,-16)}static int24(e){return x(e,-24)}static int32(e){return x(e,-32)}static int40(e){return x(e,-40)}static int48(e){return x(e,-48)}static int56(e){return x(e,-56)}static int64(e){return x(e,-64)}static int72(e){return x(e,-72)}static int80(e){return x(e,-80)}static int88(e){return x(e,-88)}static int96(e){return x(e,-96)}static int104(e){return x(e,-104)}static int112(e){return x(e,-112)}static int120(e){return x(e,-120)}static int128(e){return x(e,-128)}static int136(e){return x(e,-136)}static int144(e){return x(e,-144)}static int152(e){return x(e,-152)}static int160(e){return x(e,-160)}static int168(e){return x(e,-168)}static int176(e){return x(e,-176)}static int184(e){return x(e,-184)}static int192(e){return x(e,-192)}static int200(e){return x(e,-200)}static int208(e){return x(e,-208)}static int216(e){return x(e,-216)}static int224(e){return x(e,-224)}static int232(e){return x(e,-232)}static int240(e){return x(e,-240)}static int248(e){return x(e,-248)}static int256(e){return x(e,-256)}static int(e){return x(e,-256)}static bytes1(e){return $(e,1)}static bytes2(e){return $(e,2)}static bytes3(e){return $(e,3)}static bytes4(e){return $(e,4)}static bytes5(e){return $(e,5)}static bytes6(e){return $(e,6)}static bytes7(e){return $(e,7)}static bytes8(e){return $(e,8)}static bytes9(e){return $(e,9)}static bytes10(e){return $(e,10)}static bytes11(e){return $(e,11)}static bytes12(e){return $(e,12)}static bytes13(e){return $(e,13)}static bytes14(e){return $(e,14)}static bytes15(e){return $(e,15)}static bytes16(e){return $(e,16)}static bytes17(e){return $(e,17)}static bytes18(e){return $(e,18)}static bytes19(e){return $(e,19)}static bytes20(e){return $(e,20)}static bytes21(e){return $(e,21)}static bytes22(e){return $(e,22)}static bytes23(e){return $(e,23)}static bytes24(e){return $(e,24)}static bytes25(e){return $(e,25)}static bytes26(e){return $(e,26)}static bytes27(e){return $(e,27)}static bytes28(e){return $(e,28)}static bytes29(e){return $(e,29)}static bytes30(e){return $(e,30)}static bytes31(e){return $(e,31)}static bytes32(e){return $(e,32)}static address(e){return new We(He,"address",e)}static bool(e){return new We(He,"bool",!!e)}static bytes(e){return new We(He,"bytes",e)}static string(e){return new We(He,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new We(He,"overrides",Object.assign({},e))}static isTyped(e){return e&&e._typedSymbol===Oo}static dereference(e,t){if(We.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};let Q=We;At=new WeakMap;class Mh extends Be{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Q.dereference(t,"string");try{r=bt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return bt(oo(e.readValue(),20))}}class zh extends Be{constructor(t){super(t.name,t.type,"_",t.dynamic);m(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function To(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let c={};r=e.map(u=>{const l=u.localName;return T(l,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),T(!c[l],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),c[l]=!0,t[l]})}else E(!1,"invalid tuple value","tuple",t);E(e.length===r.length,"types/value length mismatch","tuple",t);let s=new os,i=new os,o=[];e.forEach((c,u)=>{let l=r[u];if(c.dynamic){let h=i.length;c.encode(i,l);let p=s.writeUpdatableValue();o.push(f=>{p(f+h)})}else c.encode(s,l)}),o.forEach(c=>{c(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function Ao(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(zr(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(zr(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Xr.fromItems(t,r)}class Vh extends Be{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);m(this,"coder");m(this,"length");k(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=Q.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),to(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return To(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),T(r*re<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*re,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new zh(this.coder));return Ao(t,s)}}class qh extends Be{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Q.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class So extends Be{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Le(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class Jh extends So{constructor(e){super("bytes",e)}decode(e){return W(super.decode(e))}}class Gh extends Be{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);m(this,"size");k(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Le(Q.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return W(t.readBytes(this.size))}}const Wh=new Uint8Array([]);class Kh extends Be{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(Wh)}decode(e){return e.readBytes(0),null}}const Xh=BigInt(0),Zh=BigInt(1),Yh=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Qh extends Be{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);m(this,"size");m(this,"signed");k(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=wt(Q.dereference(r,this.type)),i=Jr(Yh,re*8);if(this.signed){let o=Jr(i,this.size*8-1);(s>o||s<-(o+Zh))&&this._throwError("value out-of-bounds",r),s=Jl(s,8*re)}else(s<Xh||s>Jr(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=Jr(t.readValue(),this.size*8);return this.signed&&(r=ql(r,this.size*8)),r}}class ef extends So{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,co(Q.dereference(t,"string")))}decode(e){return th(super.decode(e))}}class Qr extends Be{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);m(this,"coders");k(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=Q.dereference(r,"tuple");return To(t,this.coders,s)}decode(t){return Ao(t,this.coders)}}function ar(n){return tt(co(n))}function ps(n,e){return{address:bt(n),storageKeys:e.map((t,r)=>(E(Qe(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function tf(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(E(t.length===2,"invalid slot set",`value[${r}]`,t),ps(t[0],t[1])):(E(t!=null&&typeof t=="object","invalid address-slot set","value",n),ps(t.address,t.storageKeys)));E(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return ps(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function ne(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const ko="constant external internal payable private public pure view",rf=ne(ko.split(" ")),Ro="constructor error event fallback function receive struct",Po=ne(Ro.split(" ")),No="calldata memory storage payable indexed",nf=ne(No.split(" ")),sf=[Ro,No,"tuple returns",ko].join(" "),of=ne(sf.split(" ")),af={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},cf=new RegExp("^(\\s*)"),uf=new RegExp("^([0-9]+)"),lf=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),$o=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Co=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),cn=class{constructor(e){B(this,hr);B(this,X,void 0);B(this,Ee,void 0);I(this,X,0),I(this,Ee,e.slice())}get offset(){return v(this,X)}get length(){return v(this,Ee).length-v(this,X)}clone(){return new cn(v(this,Ee))}reset(){I(this,X,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=G(this,hr,Cs).call(this,v(this,X)+1,e.match+1);return I(this,X,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;v(this,X)<e.match-1;){const r=this.peek().linkNext;t.push(G(this,hr,Cs).call(this,v(this,X)+1,r)),I(this,X,r)}return I(this,X,e.match+1),t}peek(){if(v(this,X)>=v(this,Ee).length)throw new Error("out-of-bounds");return v(this,Ee)[v(this,X)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return ua(this,X)._++,e}toString(){const e=[];for(let t=v(this,X);t<v(this,Ee).length;t++){const r=v(this,Ee)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};let ve=cn;X=new WeakMap,Ee=new WeakMap,hr=new WeakSet,Cs=function(e=0,t=0){return new cn(v(this,Ee).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};function rt(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(cf);a&&(i+=a[1].length,o=n.substring(i));const c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let u=af[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(u=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),c.match=r.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(u==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let l=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;l=h+l,e[e.length-1].value=je(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=l}continue}if(a=o.match(lf),a){if(c.text=a[1],i+=c.text.length,of.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(Co)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(uf),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ve(e.map(o=>Object.freeze(o)))}function Io(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function en(n,e){if(e.peekKeyword(Po)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Me(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function Fo(n){let e=Me(n,rf);return Io(e,ne("constant payable nonpayable".split(" "))),Io(e,ne("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function ze(n,e){return n.popParams().map(t=>K.from(t,e))}function Do(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return wt(n.pop().text);throw new Error("invalid gas")}return null}function vt(n){if(n.length)throw new Error(`unexpected tokens: ${n.toString()}`)}const hf=new RegExp(/^(.*)\[([0-9]*)\]$/);function Uo(n){const e=n.match(Co);if(E(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);E(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);E(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const M={},oe=Symbol.for("_ethers_internal"),Lo="_ParamTypeInternal",jo="_ErrorInternal",Bo="_EventInternal",Ho="_ConstructorInternal",Mo="_FallbackInternal",zo="_FunctionInternal",Vo="_StructInternal",me=class{constructor(e,t,r,s,i,o,a,c){B(this,Vt);m(this,"name");m(this,"type");m(this,"baseType");m(this,"indexed");m(this,"components");m(this,"arrayLength");m(this,"arrayChildren");if(ss(e,M,"ParamType"),Object.defineProperty(this,oe,{value:Lo}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");k(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){let r={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(r)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?(e!=="sighash"&&(t+=this.type),t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")"):t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return G(this,Vt,mn).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(me.isParamType(e))return e;if(typeof e=="string")return me.from(rt(e),t);if(e instanceof ve){let a="",c="",u=null;Me(e,ne(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",u=e.popParams().map(w=>me.from(w)),a=`tuple(${u.map(w=>w.format()).join(",")})`):(a=Uo(e.popType("TYPE")),c=a);let l=null,h=null;for(;e.length&&e.peekType("BRACKET");){const w=e.pop();l=new me(M,"",a,c,null,u,h,l),h=w.value,a+=w.text,c="array",u=null}let p=null;if(Me(e,nf).has("indexed")){if(!t)throw new Error("");p=!0}const d=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new me(M,d,a,c,p,u,h,l)}const r=e.name;E(!r||typeof r=="string"&&r.match($o),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(E(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(hf);if(o){const a=parseInt(o[2]||"-1"),c=me.from({type:o[1],components:e.components});return new me(M,r||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(u=>me.from(u)):null;return new me(M,r||"",i,"tuple",s,a,null,null)}return i=Uo(e.type),new me(M,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[oe]===Lo}};let K=me;Vt=new WeakSet,mn=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,u)=>{var l;G(l=o,Vt,mn).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var l;G(l=o[u],Vt,mn).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};class _t{constructor(e,t,r){m(this,"type");m(this,"inputs");ss(e,M,"Fragment"),r=Object.freeze(r.slice()),k(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{_t.from(JSON.parse(e))}catch{}return _t.from(rt(e))}if(e instanceof ve)switch(e.peekKeyword(Po)){case"constructor":return Ve.from(e);case"error":return ae.from(e);case"event":return Se.from(e);case"fallback":case"receive":return qe.from(e);case"function":return ke.from(e);case"struct":return Et.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Ve.from(e);case"error":return ae.from(e);case"event":return Se.from(e);case"fallback":case"receive":return qe.from(e);case"function":return ke.from(e);case"struct":return Et.from(e)}T(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}E(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Ve.isFragment(e)}static isError(e){return ae.isFragment(e)}static isEvent(e){return Se.isFragment(e)}static isFunction(e){return ke.isFragment(e)}static isStruct(e){return Et.isFragment(e)}}class tn extends _t{constructor(t,r,s,i){super(t,r,i);m(this,"name");E(typeof s=="string"&&s.match($o),"invalid identifier","name",s),i=Object.freeze(i.slice()),k(this,{name:s})}}function cr(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class ae extends tn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,oe,{value:jo})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+cr(e,this.inputs)),t.join(" ")}static from(e){if(ae.isFragment(e))return e;if(typeof e=="string")return ae.from(rt(e));if(e instanceof ve){const t=en("error",e),r=ze(e);return vt(e),new ae(M,t,r)}return new ae(M,e.name,e.inputs?e.inputs.map(K.from):[])}static isFragment(e){return e&&e[oe]===jo}}class Se extends tn{constructor(t,r,s,i){super(t,"event",r,s);m(this,"anonymous");Object.defineProperty(this,oe,{value:Bo}),k(this,{anonymous:i})}get topicHash(){return ar(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+cr(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>K.from(i)),new Se(M,t,r,!1).topicHash}static from(t){if(Se.isFragment(t))return t;if(typeof t=="string")return Se.from(rt(t));if(t instanceof ve){const r=en("event",t),s=ze(t,!0),i=!!Me(t,ne(["anonymous"])).has("anonymous");return vt(t),new Se(M,r,s,i)}return new Se(M,t.name,t.inputs?t.inputs.map(r=>K.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[oe]===Bo}}class Ve extends _t{constructor(t,r,s,i,o){super(t,r,s);m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:Ho}),k(this,{payable:i,gas:o})}format(t){if(T(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${cr(t,this.inputs)}`];return r.push(this.payable?"payable":"nonpayable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(Ve.isFragment(t))return t;if(typeof t=="string")return Ve.from(rt(t));if(t instanceof ve){Me(t,ne(["constructor"]));const r=ze(t),s=!!Me(t,ne(["payable"])).has("payable"),i=Do(t);return vt(t),new Ve(M,"constructor",r,s,i)}return new Ve(M,"constructor",t.inputs?t.inputs.map(K.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===Ho}}class qe extends _t{constructor(t,r,s){super(t,"fallback",r);m(this,"payable");Object.defineProperty(this,oe,{value:Mo}),k(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(qe.isFragment(t))return t;if(typeof t=="string")return qe.from(rt(t));if(t instanceof ve){const r=t.toString(),s=t.peekKeyword(ne(["fallback","receive"]));if(E(s,"type must be fallback or receive","obj",r),t.popKeyword(ne(["fallback","receive"]))==="receive"){const c=ze(t);return E(c.length===0,"receive cannot have arguments","obj.inputs",c),Me(t,ne(["payable"])),vt(t),new qe(M,[],!0)}let o=ze(t);o.length?E(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[K.from("bytes")];const a=Fo(t);if(E(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Me(t,ne(["returns"])).has("returns")){const c=ze(t);E(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return vt(t),new qe(M,o,a==="payable")}if(t.type==="receive")return new qe(M,[],!0);if(t.type==="fallback"){const r=[K.from("bytes")],s=t.stateMutability==="payable";return new qe(M,r,s)}E(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[oe]===Mo}}class ke extends tn{constructor(t,r,s,i,o,a){super(t,"function",r,i);m(this,"constant");m(this,"outputs");m(this,"stateMutability");m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:zo}),o=Object.freeze(o.slice()),k(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+cr(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(cr(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>K.from(i)),new ke(M,t,"view",r,[],null).selector}static from(t){if(ke.isFragment(t))return t;if(typeof t=="string")return ke.from(rt(t));if(t instanceof ve){const r=en("function",t),s=ze(t),i=Fo(t);let o=[];Me(t,ne(["returns"])).has("returns")&&(o=ze(t));const a=Do(t);return vt(t),new ke(M,r,i,s,o,a)}return new ke(M,t.name,t.stateMutability,t.inputs?t.inputs.map(K.from):[],t.outputs?t.outputs.map(K.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===zo}}class Et extends tn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,oe,{value:Vo})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")return Et.from(rt(e));if(e instanceof ve){const t=en("struct",e),r=ze(e);return vt(e),new Et(M,t,r)}return new Et(M,e.name,e.inputs?e.inputs.map(K.from):[])}static isFragment(e){return e&&e[oe]===Vo}}const _e=new Map;_e.set(0,"GENERIC_PANIC"),_e.set(1,"ASSERT_FALSE"),_e.set(17,"OVERFLOW"),_e.set(18,"DIVIDE_BY_ZERO"),_e.set(33,"ENUM_RANGE_ERROR"),_e.set(34,"BAD_STORAGE_DATA"),_e.set(49,"STACK_UNDERFLOW"),_e.set(50,"ARRAY_RANGE_ERROR"),_e.set(65,"OUT_OF_MEMORY"),_e.set(81,"UNINITIALIZED_FUNCTION_CALL");const ff=new RegExp(/^bytes([0-9]*)$/),df=new RegExp(/^(u?int)([0-9]*)$/);let ys=null;function pf(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const u=Ue(t);if(t=W(t),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(W(u.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(W(u.slice(0,4))==="0x4e487b71")try{const l=Number(r.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[l]},i=`Panic due to ${_e.get(l)||"UNKNOWN"}(${l})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?bt(e.to):null,data:e.data||"0x"};return e.from&&(c.from=bt(e.from)),Vr(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:c,invocation:o,revert:a})}const un=class{constructor(){B(this,it)}getDefaultValue(e){const t=e.map(s=>G(this,it,Wt).call(this,K.from(s)));return new Qr(t,"_").defaultValue()}encode(e,t){to(t.length,e.length,"types/values length mismatch");const r=e.map(o=>G(this,it,Wt).call(this,K.from(o))),s=new Qr(r,"_"),i=new os;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>G(this,it,Wt).call(this,K.from(o)));return new Qr(s,"_").decode(new as(t,r))}static defaultAbiCoder(){return ys==null&&(ys=new un),ys}static getBuiltinCallException(e,t,r){return pf(e,t,r,un.defaultAbiCoder())}};let rn=un;it=new WeakSet,Wt=function(e){if(e.isArray())return new Vh(G(this,it,Wt).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Qr(e.components.map(r=>G(this,it,Wt).call(this,r)),e.name);switch(e.baseType){case"address":return new Mh(e.name);case"bool":return new qh(e.name);case"string":return new ef(e.name);case"bytes":return new Jh(e.name);case"":return new Kh(e.name)}let t=e.type.match(df);if(t){let r=parseInt(t[2]||"256");return E(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new Qh(r/8,t[1]==="int",e.name)}if(t=e.type.match(ff),t){let r=parseInt(t[1]);return E(r!==0&&r<=32,"invalid bytes length","param",e),new Gh(r,e.name)}E(!1,"invalid type","type",e.type)};class yf{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"signature");m(this,"topic");m(this,"args");const s=e.name,i=e.format();k(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class mf{constructor(e,t,r,s){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");m(this,"value");const i=e.name,o=e.format();k(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class gf{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");const s=e.name,i=e.format();k(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class qo{constructor(e){m(this,"hash");m(this,"_isIndexed");k(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const Jo={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Go={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&Jo[n.toString()]&&(e=Jo[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},qt=class{constructor(e){B(this,fr);B(this,dr);m(this,"fragments");m(this,"deploy");m(this,"fallback");m(this,"receive");B(this,Re,void 0);B(this,Pe,void 0);B(this,Ne,void 0);B(this,ee,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Ne,new Map),I(this,Re,new Map),I(this,Pe,new Map);const r=[];for(const o of t)try{r.push(_t.from(o))}catch(a){console.log("EE",a)}k(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,ee,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}k(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(E(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=v(this,Ne);break;case"event":c=v(this,Pe);break;case"error":c=v(this,Re);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||k(this,{deploy:Ve.from("constructor()")}),k(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return rn.defaultAbiCoder()}getFunctionName(e){const t=G(this,fr,Is).call(this,e,null,!1);return E(t,"no matching function","key",e),t.name}getFunction(e,t){return G(this,fr,Is).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(v(this,Ne).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Ne).get(s),r)}}getEventName(e){const t=G(this,dr,Fs).call(this,e,null,!1);return E(t,"no matching event","key",e),t.name}getEvent(e,t){return G(this,dr,Fs).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(v(this,Pe).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Pe).get(s),r)}}getError(e,t){if(Qe(e)){const s=e.toLowerCase();if(Go[s])return ae.from(Go[s].signature);for(const i of v(this,Re).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of v(this,Re))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?ae.from("error Error(string)"):e==="Panic"?ae.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");E(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=ae.from(e).format(),e==="Error(string)")return ae.from("error Error(string)");if(e==="Panic(uint256)")return ae.from("error Panic(uint256)");const r=v(this,Re).get(e);return r||null}forEachError(e){const t=Array.from(v(this,Re).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Re).get(s),r)}}_decodeParams(e,t){return v(this,ee).decode(e,t)}_encodeParams(e,t){return v(this,ee).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return E(jt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,jt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return Lt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return E(jt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,jt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return Lt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);E(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Le(t);if(s.length%32===0)try{return v(this,ee).decode(e.outputs,s)}catch{r="could not decode result data"}T(!1,r,"BAD_DATA",{value:W(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=Ue(e,"data"),s=rn.getBuiltinCallException("call",t,r),i="execution reverted (unknown custom error)";if(s.message.startsWith(i)){const a=W(r.slice(0,4)),c=this.getError(a);if(c)try{const u=v(this,ee).decode(c.inputs,r.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return W(v(this,ee).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);E(i,"unknown event","eventFragment",e),e=i}T(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?ar(o):i.type==="bytes"?tt(W(o)):(i.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),i.type.match(/^u?int/)&&(o=oo(o)),i.type==="address"&&v(this,ee).encode(["address"],[o]),Vl(W(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){E(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?E(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(c=>s(a,c))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);E(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),E(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")r.push(ar(c));else if(o.type==="bytes")r.push(tt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(v(this,ee).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:v(this,ee).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const f=this.getEvent(e);E(f,"unknown event","eventFragment",e),e=f}if(r!=null&&!e.anonymous){const f=e.topicHash;E(Qe(r[0],32)&&r[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((f,d)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(K.from({type:"bytes32",name:f.name})),o.push(!0)):(s.push(f),o.push(!1)):(i.push(f),o.push(!1))});const a=r!=null?v(this,ee).decode(s,Lt(r)):null,c=v(this,ee).decode(i,t,!0),u=[],l=[];let h=0,p=0;return e.inputs.forEach((f,d)=>{let w=null;if(f.indexed)if(a==null)w=new qo(null);else if(o[d])w=new qo(a[p++]);else try{w=a[p++]}catch(b){w=b}else try{w=c[h++]}catch(b){w=b}u.push(w),l.push(f.name||null)}),Xr.fromItems(u,l)}parseTransaction(e){const t=Ue(e.data,"tx.data"),r=wt(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(W(t.slice(0,4)));if(!s)return null;const i=v(this,ee).decode(s.inputs,t.slice(4));return new mf(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new yf(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=W(e),r=this.getError(jt(t,0,4));if(!r)return null;const s=v(this,ee).decode(r.inputs,jt(t,4));return new gf(r,r.selector,s)}static from(e){return e instanceof qt?e:typeof e=="string"?new qt(JSON.parse(e)):typeof e.format=="function"?new qt(e.format("json")):new qt(e)}};let ms=qt;Re=new WeakMap,Pe=new WeakMap,Ne=new WeakMap,ee=new WeakMap,fr=new WeakSet,Is=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Ne).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Ne))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;Q.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const l=i[u].inputs.length;l!==a&&(!c||l!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const l=i[u].inputs;for(let h=0;h<t.length;h++)if(Q.isTyped(t[h])){if(h>=l.length){if(t[h].type==="overrides")continue;i.splice(u,1);break}if(t[h].type!==l[h].baseType){i.splice(u,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Ne).get(ke.from(e).format());return s||null},dr=new WeakSet,Fs=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Pe).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Pe))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(Q.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Pe).get(Se.from(e).format());return s||null};const wf=BigInt(0);function Je(n){return n==null?null:n.toString()}function bf(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=W(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=wt(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=je(n[s],`request.${s}`));return n.accessList&&(e.accessList=tf(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipReadEnabled=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),e}class gs{constructor(e,t){m(this,"provider");m(this,"transactionHash");m(this,"blockHash");m(this,"blockNumber");m(this,"removed");m(this,"address");m(this,"data");m(this,"topics");m(this,"index");m(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());k(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return T(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return _f(this)}}class vf{constructor(e,t){m(this,"provider");m(this,"to");m(this,"from");m(this,"contractAddress");m(this,"hash");m(this,"index");m(this,"blockHash");m(this,"blockNumber");m(this,"logsBloom");m(this,"gasUsed");m(this,"cumulativeGasUsed");m(this,"gasPrice");m(this,"type");m(this,"status");m(this,"root");B(this,pr,void 0);I(this,pr,Object.freeze(e.logs.map(r=>new gs(r,t)))),k(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,gasPrice:e.effectiveGasPrice||e.gasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return v(this,pr)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:l,root:h}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Je(this.cumulativeGasUsed),from:t,gasPrice:Je(this.gasPrice),gasUsed:Je(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:h,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Ko(this)}reorderedEvent(e){return T(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Wo(this,e)}}pr=new WeakMap;const Ps=class{constructor(e,t){m(this,"provider");m(this,"blockNumber");m(this,"blockHash");m(this,"index");m(this,"hash");m(this,"type");m(this,"to");m(this,"from");m(this,"nonce");m(this,"gasLimit");m(this,"gasPrice");m(this,"maxPriorityFeePerGas");m(this,"maxFeePerGas");m(this,"data");m(this,"value");m(this,"chainId");m(this,"signature");m(this,"accessList");B(this,ot,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,I(this,ot,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:l,accessList:h}=this;return{_type:"TransactionReceipt",accessList:h,blockNumber:e,blockHash:t,chainId:Je(this.chainId),data:u,from:a,gasLimit:Je(this.gasLimit),gasPrice:Je(this.gasPrice),hash:s,maxFeePerGas:Je(this.maxFeePerGas),maxPriorityFeePerGas:Je(this.maxPriorityFeePerGas),nonce:c,signature:l,to:o,index:r,type:i,value:Je(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async wait(e,t){const r=e??1,s=t??0;let i=v(this,ot),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:h,nonce:p}=await Qi({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(p<this.nonce){i=h;return}if(a)return null;const f=await this.getTransaction();if(!(f&&f.blockNumber!=null))for(o===-1&&(o=i-3,o<v(this,ot)&&(o=v(this,ot)));o<=h;){if(a)return null;const d=await this.provider.getBlock(o,!0);if(d==null)return;for(const w of d)if(w===this.hash)return;for(let w=0;w<d.length;w++){const b=await d.getTransaction(w);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const O=await this.provider.getTransactionReceipt(b.hash);if(O==null||h-O.blockNumber+1<r)return;let N="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?N="repriced":b.data==="0x"&&b.from===b.to&&b.value===wf&&(N="cancelled"),T(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:N==="replaced"||N==="cancelled",reason:N,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:O})}}o++}},u=await this.provider.getTransactionReceipt(this.hash);if(u){if(await u.confirmations()>=r)return u}else if(await c(),r===0)return null;return await new Promise((h,p)=>{const f=[],d=()=>{f.forEach(b=>b())};if(f.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{d(),p(Vr("wait for transaction timeout","TIMEOUT"))},s);f.push(()=>{clearTimeout(b)})}const w=async b=>{await b.confirmations()>=r&&(d(),h(b))};if(f.push(()=>{this.provider.off(this.hash,w)}),this.provider.on(this.hash,w),i>=0){const b=async()=>{try{await c()}catch(O){if(zr(O,"TRANSACTION_REPLACED")){d(),p(O);return}}a||this.provider.once("block",b)};f.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}removedEvent(){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ko(this)}reorderedEvent(e){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),T(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Wo(this,e)}replaceableTransaction(e){E(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Ps(this,this.provider);return I(t,ot,e),t}};let ws=Ps;ot=new WeakMap;function Wo(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function Ko(n){return{orphan:"drop-transaction",tx:n}}function _f(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class bs extends gs{constructor(t,r,s){super(t,t.provider);m(this,"interface");m(this,"fragment");m(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);k(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Ef extends vf{constructor(t,r,s){super(s,r);B(this,Jt,void 0);I(this,Jt,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?v(this,Jt).getEvent(t.topics[0]):null;return r?new bs(t,v(this,Jt),r):t})}}Jt=new WeakMap;class vs extends ws{constructor(t,r,s){super(s,r);B(this,yr,void 0);I(this,yr,t)}async wait(t){const r=await super.wait();return r==null?null:new Ef(v(this,yr),this.provider,r)}}yr=new WeakMap;class Xo extends Kl{constructor(t,r,s,i){super(t,r,s);m(this,"log");k(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class xf extends Xo{constructor(e,t,r,s,i){super(e,t,r,new bs(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);k(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Zo=BigInt(0);function Yo(n){return n&&typeof n.call=="function"}function Qo(n){return n&&typeof n.estimateGas=="function"}function _s(n){return n&&typeof n.resolveName=="function"}function ea(n){return n&&typeof n.sendTransaction=="function"}class Of{constructor(e,t,r){B(this,mr,void 0);m(this,"fragment");if(k(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=xt(e.runner,"resolveName"),i=_s(s)?s:null;I(this,mr,async function(){const o=await Promise.all(t.inputs.map((a,c)=>r[c]==null?null:a.walkAsync(r[c],(l,h)=>l==="address"?ds(h,i):h)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return v(this,mr)}}mr=new WeakMap;function Tf(){return Function}function xt(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ot(n){return n==null?null:n.provider||null}async function ta(n,e){const t=bf(Q.dereference(n,"overrides"));return E(t.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",t.to),E(t.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",t.data),t.from&&(t.from=await ds(t.from)),t}async function Af(n,e,t){const r=xt(n,"resolveName"),s=_s(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=Q.dereference(c,a),a==="address"?ds(c,s):c))))}class Sf{constructor(e){m(this,"_contract");return k(this,{_contract:e}),new Proxy(this,{apply:async(r,s,i)=>await r.send(...i)})}async populateTransaction(e){const t=await ta(e,["data"]);t.to=await this._contract.getAddress();const r=this._contract.interface,s=r.receive||r.fallback&&r.fallback.payable;return E(s||(t.value||Zo)===Zo,"cannot send value to non-payable contract","overrides.value",t.value),E(r.fallback||(t.data||"0x")==="0x","cannot send data to receive-only contract","overrides.data",t.data),t}async staticCall(e){const t=xt(this._contract.runner,"call");T(Yo(t),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const r=await this.populateTransaction(e);try{return await t.call(r)}catch(s){throw eo(s)&&s.data?this._contract.interface.makeError(s.data,r):s}}async send(e){const t=this._contract.runner;T(ea(t),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const r=await t.sendTransaction(await this.populateTransaction(e)),s=Ot(this._contract.runner);return new vs(this._contract.interface,s,r)}async estimateGas(e){const t=xt(this._contract.runner,"estimateGas");return T(Qo(t),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await t.estimateGas(await this.populateTransaction(e))}}class kf extends Tf(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return k(this,{name:t.interface.getFunctionName(r),_contract:t,_key:r}),new Proxy(this,{apply:async(i,o,a)=>i.getFragment(...a).constant?await i.staticCall(...a):await i.send(...a)})}get fragment(){const t=this._contract.interface.getFunction(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getFunction(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}async populateTransaction(...t){const r=this.getFragment(...t);let s={};if(r.inputs.length+1===t.length&&(s=await ta(t.pop())),r.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=await Af(this._contract.runner,r.inputs,t);return Object.assign({},s,await Qi({to:this._contract.getAddress(),data:this._contract.interface.encodeFunctionData(r,i)}))}async staticCall(...t){const r=await this.staticCallResult(...t);return r.length===1?r[0]:r}async send(...t){const r=this._contract.runner;T(ea(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=await r.sendTransaction(await this.populateTransaction(...t)),i=Ot(this._contract.runner);return new vs(this._contract.interface,i,s)}async estimateGas(...t){const r=xt(this._contract.runner,"estimateGas");return T(Qo(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await this.populateTransaction(...t))}async staticCallResult(...t){const r=xt(this._contract.runner,"call");T(Yo(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=await this.populateTransaction(...t);let i="0x";try{i=await r.call(s)}catch(a){throw eo(a)&&a.data?this._contract.interface.makeError(a.data,s):a}const o=this.getFragment(...t);return this._contract.interface.decodeFunctionResult(o,i)}}function Rf(){return Function}class Pf extends Rf(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return k(this,{name:t.interface.getEventName(r),_contract:t,_key:r}),new Proxy(this,{apply:(s,i,o)=>new Of(t,s.getFragment(...o),o)})}get fragment(){const t=this._contract.interface.getEvent(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getEvent(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}}const nn=Symbol.for("_ethersInternal_contract"),ra=new WeakMap;function Nf(n,e){ra.set(n[nn],e)}function pe(n){return ra.get(n[nn])}function $f(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Es(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(Qe(o,32))return o;const a=n.interface.getEvent(o);return E(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?Qe(e,32)?t=[e]:(r=n.interface.getEvent(e),E(r,"unknown fragment","event",e),t=[r.topicHash]):$f(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):E(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function ur(n,e){const{subs:t}=pe(n);return t.get((await Es(n,e)).tag)||null}async function na(n,e,t){const r=Ot(n.runner);T(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Es(n,t),{addr:a,subs:c}=pe(n);let u=c.get(i);if(!u){const h={address:a||n,topics:o},p=b=>{let O=s;if(O==null)try{O=n.interface.getEvent(b.topics[0])}catch{}if(O){const N=O,q=s?n.interface.decodeEventLog(s,b.data,b.topics):[];Os(n,t,q,j=>new xf(n,j,t,N,b))}else Os(n,t,[],N=>new Xo(n,N,t,b))};let f=[];u={tag:i,listeners:[],start:()=>{f.length||f.push(r.on(h,p))},stop:async()=>{if(f.length==0)return;let b=f;f=[],await Promise.all(b),r.off(h,p)}},c.set(i,u)}return u}let xs=Promise.resolve();async function Cf(n,e,t,r){await xs;const s=await ur(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);r&&c.push(r(a?null:o));try{o.call(n,...c)}catch{}return!a}),i>0}async function Os(n,e,t,r){try{await xs}catch{}const s=Cf(n,e,t,r);return xs=s,await s}const sa=["then"],ln=class{constructor(e,t,r,s){m(this,"target");m(this,"interface");m(this,"runner");m(this,"filters");m(this,Bf);m(this,"fallback");r==null&&(r=null);const i=ms.from(t);k(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,nn,{value:{}});let o,a=null,c=null;if(s){const h=Ot(r);c=new vs(this.interface,h,s)}let u=new Map;if(typeof e=="string")if(Qe(e))a=e,o=Promise.resolve(e);else{const h=xt(r,"resolveName");if(!_s(h))throw Vr("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=h.resolveName(e).then(p=>{if(p==null)throw new Error("TODO");return pe(this).addr=p,p})}else o=e.getAddress().then(h=>{if(h==null)throw new Error("TODO");return pe(this).addr=h,h});Nf(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const l=new Proxy({},{get:(h,p,f)=>{if(sa.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=this.getEvent(d);if(w)return w;throw new Error(`unknown contract event: ${d}`)}});return k(this,{filters:l}),k(this,{fallback:i.receive||i.fallback?new Sf(this):null}),new Proxy(this,{get:(h,p,f)=>{if(p in h||sa.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=h.getFunction(d);if(w)return w;throw new Error(`unknown contract method: ${d}`)}})}connect(e){return new ln(this.target,this.interface,e)}async getAddress(){return await pe(this).addrPromise}async getDeployedCode(){const e=Ot(this.runner);T(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ot(this.runner);return T(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return pe(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),new kf(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),new Pf(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=pe(this),o=s||await i,{fragment:a,topics:c}=await Es(this,e),u={address:o,topics:c,fromBlock:t,toBlock:r},l=Ot(this.runner);return T(l,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await l.getLogs(u)).map(h=>{let p=a;if(p==null)try{p=this.interface.getEvent(h.topics[0])}catch{}return p?new bs(h,this.interface,p):new gs(h,l)})}async on(e,t){const r=await na(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await na(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await Os(this,e,t,null)}async listenerCount(e){if(e){const s=await ur(this,e);return s?s.listeners.length:0}const{subs:t}=pe(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await ur(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=pe(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await ur(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),pe(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await ur(this,e);if(!t)return this;t.stop(),pe(this).subs.delete(t.tag)}else{const{subs:t}=pe(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends ln{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let Ts=ln;Bf=nn;function If(){return Ts}class Ff extends If(){}class sn{constructor(e){m(this,"data",[]);this.api=e}static create(e){return new sn(e)}getAbiHash(e){if(this.api===void 0)throw new Error("FunctionBuilder must be initialised with api");return this.api.getAbiHash(e)}async addFunction(e,t,r,s){const i=new Ff(e,s);return i.interface.encodeFunctionData(t,r),this.data.push({address:e,bytecode:i.interface.encodeFunctionData(t,r),abiHash:await this.getAbiHash(s),function:t}),this}get(){return this.data}static schema(){return Dt().of(Ye({address:H().required(),bytecode:H().matches(/^(0x)?([0-9a-fA-F]{2})*$/).required(),abiHash:H().matches(/^[A-Fa-f0-9]{64}/).required(),function:H().required()}))}}class nt{static version(){return"v1"}static execute(e,t,r="v1"){const s=JSON.parse(JSON.stringify(t));let i=!0;for(const o of s){const a=nt.process(e,o.conditions);i=nt.execLogic(i,o.logic,a)}return i}static process(e,t,r){const s=t.shift();if(!s)return r===void 0?!0:r;const i=nt.execCondition(e,s);if(r===void 0||s.logic==="WHERE")return nt.process(e,t,i);if(s.logic===void 0)throw new Error("Invalid filter. FilterCondition must have logic value");const o=nt.execLogic(r,s.logic,i);return nt.process(e,t,o)}static execLogic(e,t,r){switch(t){case"AND":return e&&r;case"OR":return e||r;case"XOR":return(e||r)&&!(e&&r);case"NAND":return!(e&&r);case"NOR":return!(e&&r);case"WHERE":return r;default:throw new Error(`Invalid Filter. Bad logic value: ${t}`)}}static execCondition(e,t){const r=e[t.key];if(t.type==="Number"){if(typeof t.constant!="number"||typeof r!="number")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"eq":return s===i;case"!eq":return s!==i;case"gt":return s>i;case"gte":return s>=i;case"lt":return s<i;case"lte":return s<=i;default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="String"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.includes(i);case"!contains":return!s.includes(i);case"is":return s===i;case"!is":return s!==i;case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="Address"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.toLowerCase().includes(i.toLowerCase());case"!contains":return!s.toLowerCase().includes(i.toLowerCase());case"is":return s.toLowerCase()===i.toLowerCase();case"!is":return s.toLowerCase()!==i.toLowerCase();case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}throw new Error("Invalid Filter. Unknown Type")}}class on{constructor(){m(this,"groups",[]);this.newGroup("WHERE")}static version(){return nt.version()}static new(){return new on}newGroup(e){if(this.groups.length!==0&&e==="WHERE")throw new Error('Only the first groups can start with "WHERE"');return this.groups.push({logic:"WHERE",conditions:[]}),this}addCondition(e,t,r,s,i){const o=this.groups[this.groups.length-1];if(o.conditions.length===0&&e!=="WHERE")throw new Error('Logic for the first condition of a group must be "WHERE"');if(o.conditions.length>0&&e==="WHERE")throw new Error('Only the first condition of a group can be "WHERE"');return o.conditions.push({logic:e,key:t,type:r,operation:s,constant:i}),this}finalise(){for(const e of this.groups)if(e.conditions.length===0)throw new Error("Bad Filter. All Groups must have atleast one condition");return this.groups}static schema(){const e=H().oneOf(["AND","OR","XOR","NAND","NOR","WHERE"]).required(),t=Ye({logic:e,key:H().required(),type:H().oneOf(["String","Address","Number"]).required(),operation:H().when("type",([r],s)=>{switch(r){case"String":return s.oneOf(["contains","!contains","is","!is","isEmpty","!isEmpty"]);case"Address":return s.oneOf(["is","!is","isEmpty","!isEmpty"]);case"Number":return s.oneOf(["eq","!eq","gt","gte","lt","lte"]);default:throw new Error("Invalid Filter Data Type")}}),constant:Bi().when("type",([r])=>{switch(r){case"String":return H();case"Address":return H();case"Number":return de();default:throw new Error("Invalid Filter Data Type")}})});return Dt().of(Ye({logic:e,conditions:Dt().of(t)}))}}const Df="handler_function_call_v2";class As{static SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Df,handler:r}}static validateCreate(e){const t=/^(\d+)([SMHD])$/i;return Ye({timeBase:H().oneOf(["blocks","time"]).required(),nBlocks:de().min(10).when("timeBase",([s],i)=>s==="blocks"?i.required():i),timePeriod:H().matches(t,"timePeriod must be of the format n[s|m|h|d], eg 10s for 10 seconds").when("timeBase",([s],i)=>s==="time"?i.required():i),startTime:de().default(0),debounceCount:de(),functions:sn.schema(),triggerOn:H().oneOf(["always","filter"]).default("always"),latch:Mi().default(!1),filterVersion:H().when("triggerOn",([s],i)=>s==="filter"?i.required():i),filter:on.schema().when("triggerOn",([s],i)=>s==="filter"?i.required():i)}).validate(e)}}class ia{static SimpleToRaw(e,t,r,s){switch(t){case"PollFunctionV2":return As.SimpleToRaw(e,r,s);case"PollFunctionV1":return rs.SimpleToRaw(e,r,s);case"OnchainEventV1":return ns.SimpleToRaw(e,r,s);default:throw new Error("Invalid Trigger ID")}}}const oa=n=>`https://${n}.functions.supabase.co/`,aa=n=>`https://${n}.supabase.co/`,ca="fdgtrxmmrtlokhgkvcjz",Uf="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4";class Ss{constructor(e,t){m(this,"headers",{});this.url=e,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){var t,r;if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const s=e.projectId?aa(e.projectId):aa(ca),i=e.projectId?oa(e.projectId):oa(ca),o=e.anonKey?e.anonKey:Uf,a=Mc(s,o),{data:c,error:u}=await a.auth.signInWithPassword({email:e.email,password:e.password});if(u)throw u;if(((t=c.session)==null?void 0:t.access_token)===void 0)throw new Error("Access token not found");return new Ss(i,(r=c.session)==null?void 0:r.access_token)}else throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t){const r="alert-history",s=t||{};return e&&(s.id=e),Object.keys(s).length>0?await this.request("get",r,{params:t}):await this.request("get",r)}async getAlert(e){return(await this.request("get",`alerts/${e}`))[0]}async getAlerts(){return await this.request("get","alerts")}async createAlert(e){const t=ia.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),r=Yi.SimpleToRaw(e.notificationId,e.notification);return await this.request("post","alerts",{body:{trigger:t,notification:r}})}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async request(e,t,r={}){const s=new URL(`${this.url}${t}`);if(r.params)for(const a of Object.keys(r.params))s.searchParams.append(a,r.params[a]);console.log(s.toString());const i={method:e,url:s.toString(),headers:this.headers};return r.body&&(i.data=r.body),(await Qu(i)).data}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async setAlertName(e,t){throw new Error("Not yet supported - Sorry!")}async enableAlert(e){throw new Error("Not yet supported - Sorry!")}async disableAlert(e){throw new Error("Not yet supported - Sorry!")}async updateNotification(e){throw new Error("Not yet supported - Sorry!")}async updateTrigger(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}class ks{constructor(e){m(this,"network");m(this,"triggerId");m(this,"trigger");m(this,"notificationId");m(this,"notification");this.name=e}static create(e){return new ks(e)}onNetwork(e){return this.network=e,this}withTrigger(e,t){return this.triggerId=e,this.trigger=t,this}withNotification(e,t){return this.notificationId=e,this.notification=t,this}async validate(){switch(this.triggerId){case"OnchainEventV1":return ns.validateCreate(this.trigger);case"PollFunctionV1":return rs.validateCreate(this.trigger);case"PollFunctionV2":return As.validateCreate(this.trigger)}switch(this.notificationId){case"Discord":return ts.validateCreate(this.notification);default:throw new Error("Invalid notification type")}}async config(){if(this.trigger===void 0||this.triggerId===void 0)throw new Error("Trigger not configured");if(this.notification===void 0||this.notificationId===void 0)throw new Error("Notification not configured");if(this.network===void 0)throw new Error("Network not configured");return await this.validate(),{name:this.name,network:this.network,triggerId:this.triggerId,trigger:this.trigger,notificationId:this.notificationId,notification:this.notification}}}const Lf=Object.freeze(Object.defineProperty({__proto__:null,HandlerFunctionCall:rs,HandlerFunctionCallV2:As,HandlerOnchainEvent:ns,Trigger:ia},Symbol.toStringTag,{value:"Module"})),jf=Object.freeze(Object.defineProperty({__proto__:null,Notification:Yi,NotifyDiscordWebhook:ts},Symbol.toStringTag,{value:"Module"}));return R.AlertBuilder=ks,R.DeNotifyClient=Ss,R.FilterBuilder=on,R.FunctionBuilder=sn,R.Notification=jf,R.Trigger=Lf,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),R}({});
|